diff --git a/android/armeabi/include/anysdk/AgentManager.h b/android/armeabi/include/anysdk/AgentManager.h deleted file mode 100644 index 092a9eaf..00000000 --- a/android/armeabi/include/anysdk/AgentManager.h +++ /dev/null @@ -1,245 +0,0 @@ -/** @file AgentManager.h - */ - - -#ifndef __CCX_AGENTMANAGER_H__ -#define __CCX_AGENTMANAGER_H__ - -#include "PluginManager.h" -#include "ProtocolIAP.h" -#include "ProtocolAnalytics.h" -#include "ProtocolShare.h" -#include "ProtocolAds.h" -#include "ProtocolSocial.h" -#include "ProtocolUser.h" -#include "ProtocolPush.h" -#include "ProtocolCrash.h" -#include "ProtocolREC.h" -#include "ProtocolCustom.h" -#include "ProtocolAdTracking.h" -#include -#include -namespace anysdk { namespace framework { -/** @brief Plugin_type enum, with inline docs */ -typedef enum { - kPluginAds = 16,/**< enum value is the type of Ads. */ - kPluginAnalytics = 1,/**< enum value is the type of Analytics. */ - kPluginIAP = 8,/**< enum value is the type of IAP. */ - kPluginShare = 2,/**< enum value is the type of Share. */ - kPluginUser = 32,/**< enum value is the type of User. */ - kPluginSocial = 4,/**< enum value is the type of Social. */ - kPluginPush = 64,/**< enum value is the type of Push. */ - kPluginCrash = 128,/**< enum value is the type of Crash. */ - kPluginCustom = 256,/**< enum value is the type of Custom. */ - kPluginREC = 512,/**< enum value is the type of REC. */ - kPluginAdTracking = 1024,/**< enum value is the type of AdTracking. */ -}Plugin_type; -/**    - *  @class  AgentManager   - */ -class AgentManager -{ -public: - virtual ~AgentManager(); - /** - @brief Get singleton of AgentManager - */ - - static AgentManager* getInstance(); - /** - @brief Destory the instance of AgentManager - */ - static void end(); - - /** - @breif the init of AgentManager - @param the appKey of anysdk - @param the appSecret of anysdk - @param the privateKey of anysdk - @param the url of oauthLoginServer - @warning Must invoke this interface before loadAllPlugins - */ - void init(std::string appKey,std::string appSecret,std::string privateKey,std::string oauthLoginServer); - - /** - @brief load the plugins - */ - CC_DEPRECATED_ATTRIBUTE void loadALLPlugin(); - /** - @brief unload the plugins - */ - CC_DEPRECATED_ATTRIBUTE void unloadALLPlugin(); - - /** - @brief load the plugins - */ - void loadAllPlugins(); - - /** - @brief unload the plugins - */ - void unloadAllPlugins(); - - /** - @brief Get Analytics plugin - @return if Analytics plugin exist ,return value is Analytics plugin. - else return value is null pointer. - */ - ProtocolAnalytics* getAnalyticsPlugin(){return _pAnalytics;}; - - /** - @brief Get User plugin - @return if User plugin exist ,return value is User plugin. - else return value is null pointer. - */ - ProtocolUser* getUserPlugin(){return _pUser;}; - - /** - @brief Get IAP plugin - @return if IAP plugin exist ,return value is IAP plugin. - else return value is null pointer. - */ - std::map* getIAPPlugin(){return &_pluginsIAPMap;}; - - /** - @brief Get Share plugin - @return if Share plugin exist ,return value is Share plugin. - else return value is null pointer. - */ - ProtocolShare* getSharePlugin(){return _pShare;}; - - /** - @brief Get Social plugin - @return if Social plugin exist ,return value is Social plugin. - else return value is null pointer. - */ - ProtocolSocial* getSocialPlugin(){return _pSocial;}; - - /** - @brief Get Ads plugin - @return if Ads plugin exist ,return value is Ads plugin. - else return value is null pointer. - */ - ProtocolAds* getAdsPlugin(){return _pAds;}; - - /** - @brief Get Push plugin - @return if Push plugin exist ,return value is Push plugin. - else return value is null pointer. - */ - ProtocolPush* getPushPlugin(){return _pPush;}; - - /** - @brief Get Crash plugin - @return if Crash plugin exist ,return value is Crash plugin. - else return value is null pointer. - */ - ProtocolCrash* getCrashPlugin(){return _pCrash;}; - - /** - @brief Get Custom plugin - @return if Crash plugin exist ,return value is Custom plugin. - else return value is null pointer. - */ - ProtocolCustom* getCustomPlugin(){return _pCustom;}; - - - /** - @brief Get REC plugin - @return if REC plugin exist ,return value is REC plugin. - else return value is null pointer. - */ - ProtocolREC* getRECPlugin(){return _pREC;}; - - /** - @brief Get AdTracking plugin - @return if AdTracking plugin exist ,return value is AdTracking plugin. - else return value is null pointer. - */ - ProtocolAdTracking* getAdTrackingPlugin(){return _pAdTracking;}; - - /** - @brief Get channel ID - @return return value is channel ID. - */ - std::string getChannelId(); - - /** - @brief Get custom param - @return return value is custom param for channel. - */ - std::string getCustomParam(); - - /** - @brief Get framework version - @return return value is the version of AnySDKFramework. - */ - std::string getFrameworkVersion(); - - /** - @Title: setIsAnaylticsEnabled - @Description: choose to open or close - @param @param enabled true or false - @return void - */ - void setIsAnaylticsEnabled(bool value){bIsAnaylticsEnabled = value;}; - /** - @Title: isAnaylticsEnabled - @Description: the status of Anayltics - @param @return true or false - @return boolean - */ - bool isAnaylticsEnabled(){return bIsAnaylticsEnabled;}; - - - void loadPlugin(const char* nodeName,int type); -protected: - void setDebugMode(bool flag); - std::string getSupportPlugin(); - void release(); - - -private: - AgentManager(void); - - // Analytics plugin - ProtocolAnalytics* _pAnalytics; - - // user plugin - ProtocolUser* _pUser; - - // IAP plugins - // ProtocolIAP* _pIAP; - std::map _pluginsIAPMap; - - // Share plugin - ProtocolShare* _pShare; - - // Social plugin - ProtocolSocial* _pSocial; - - // Ads plugin - ProtocolAds* _pAds; - - // Push plugin - ProtocolPush* _pPush; - - // Crash plugin - ProtocolCrash* _pCrash; - - // Custom plugin - ProtocolCustom* _pCustom; - - // REC plugin - ProtocolREC* _pREC; - - // AdTracking plugin - ProtocolAdTracking* _pAdTracking; - - bool bIsAnaylticsEnabled; - -}; - -}} //namespace anysdk { namespace framework { - -#endif /* __CCX_AGENTMANAGER_H__ */ diff --git a/android/armeabi/include/anysdk/JSBRelation.h b/android/armeabi/include/anysdk/JSBRelation.h deleted file mode 100644 index 7775b0dc..00000000 --- a/android/armeabi/include/anysdk/JSBRelation.h +++ /dev/null @@ -1,31 +0,0 @@ -/** @file JSBRelation.h - */ -#ifndef __CCX_JSBRELATION_H__ -#define __CCX_JSBRELATION_H__ - -#include "PluginProtocol.h" -#include -#include -#include - -using namespace std; - -namespace anysdk { namespace framework { - -/**    - *  @class  JSBRelation   - */ -class JSBRelation -{ -public: - static string getMethodsOfPlugin(PluginProtocol* plugin); - - - - -private: -}; - -}} //namespace anysdk { namespace framework { - -#endif /* __CCX_JSBRELATION_H__ */ diff --git a/android/armeabi/include/anysdk/PluginFactory.h b/android/armeabi/include/anysdk/PluginFactory.h deleted file mode 100644 index 79922c97..00000000 --- a/android/armeabi/include/anysdk/PluginFactory.h +++ /dev/null @@ -1,41 +0,0 @@ -/** @file PluginFactory.h - */ -#ifndef __CCX_PLUGIN_FACTORY_H__ -#define __CCX_PLUGIN_FACTORY_H__ - -namespace anysdk { namespace framework { - -class PluginProtocol; -class PluginManager; -/**    - *  @class  PluginFactory   - */ -class PluginFactory -{ -public: - virtual ~PluginFactory(); - /** - @brief Get singleton of PluginFactory - */ - static PluginFactory* getInstance(); - - /** - @brief Destory the instance of PluginFactory - */ - static void purgeFactory(); - -private: - friend class PluginManager; - PluginFactory(void); - - /** - @brief create the plugin by name and type - @param the name of plugin - @param the type of plugin - */ - PluginProtocol* createPlugin(const char* name, int pluginType); -}; - -}} //namespace anysdk { namespace framework { - -#endif /* __CCX_PLUGIN_FACTORY_H__ */ diff --git a/android/armeabi/include/anysdk/PluginJavaData.h b/android/armeabi/include/anysdk/PluginJavaData.h deleted file mode 100644 index bd37b745..00000000 --- a/android/armeabi/include/anysdk/PluginJavaData.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef __PLUGIN_JAVA_DATA_H__ -#define __PLUGIN_JAVA_DATA_H__ - -#include -#include - -namespace anysdk { namespace framework { - -typedef struct _PluginJavaData_ -{ - jobject jobj; - std::string jclassName; -} PluginJavaData; - -}} //namespace anysdk { namespace framework { - -#endif // __PLUGIN_JAVA_DATA_H__ diff --git a/android/armeabi/include/anysdk/PluginJniHelper.h b/android/armeabi/include/anysdk/PluginJniHelper.h deleted file mode 100644 index 82981907..00000000 --- a/android/armeabi/include/anysdk/PluginJniHelper.h +++ /dev/null @@ -1,43 +0,0 @@ -#ifndef __PLUGIN_JNI_HELPER_H__ -#define __PLUGIN_JNI_HELPER_H__ - -#include -#include - -namespace anysdk {namespace framework{ - -typedef struct PluginJniMethodInfo_ -{ - JNIEnv * env; - jclass classID; - jmethodID methodID; -} PluginJniMethodInfo; - -class PluginJniHelper -{ -public: - static JavaVM* getJavaVM(); - static void setJavaVM(JavaVM *javaVM); - static JNIEnv* getEnv(); - - static bool getStaticMethodInfo(PluginJniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); - static bool getMethodInfo(PluginJniMethodInfo &methodinfo, const char *className, const char *methodName, const char *paramCode); - static std::string jstring2string(jstring jstr); - static jstring newStringUTF(JNIEnv* env, const std::string& utf8Str); - - static bool setClassLoaderFrom(jobject nativeActivityInstance); - - static jmethodID loadclassMethod_methodID; - static jobject classloader; - -private: - static JavaVM *_psJavaVM; - static bool getMethodInfo_DefaultClassLoader(PluginJniMethodInfo &methodinfo, - const char *className, - const char *methodName, - const char *paramCode); -}; - -}} - -#endif // __PLUGIN_JNI_HELPER_H__ diff --git a/android/armeabi/include/anysdk/PluginJniMacros.h b/android/armeabi/include/anysdk/PluginJniMacros.h deleted file mode 100644 index eace0d9a..00000000 --- a/android/armeabi/include/anysdk/PluginJniMacros.h +++ /dev/null @@ -1,156 +0,0 @@ -#ifndef __PLUGIN_JNI_MACROS_H__ -#define __PLUGIN_JNI_MACROS_H__ - -#define return_if_fails(cond) if (!(cond)) return; -#define return_val_if_fails(cond, ret) if(!(cond)) return (ret); - -#define CALL_BASERET_JAVA_FUNC_WITH_PARAM(retType, paramCode, param, retCode, defaultRet) \ -retType ret = defaultRet; \ -return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret); \ -return_val_if_fails(paramCode != NULL && strlen(paramCode) > 0, ret); \ -PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); \ -return_val_if_fails(pData != NULL, ret); \ - \ -PluginJniMethodInfo t; \ -if (PluginJniHelper::getMethodInfo(t \ - , pData->jclassName.c_str() \ - , funcName \ - , paramCode)) \ -{ \ - ret = t.env->Call##retCode##Method(pData->jobj, t.methodID, param); \ - t.env->DeleteLocalRef(t.classID); \ -} \ -return ret; \ - - -#define CALL_BASERET_JAVA_FUNC(retType, paramCode, retCode, defaultRet) \ -retType ret = defaultRet; \ -return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret); \ -PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); \ -return_val_if_fails(pData != NULL, ret); \ - \ -PluginJniMethodInfo t; \ -if (PluginJniHelper::getMethodInfo(t \ - , pData->jclassName.c_str() \ - , funcName \ - , paramCode)) \ -{ \ - ret = t.env->Call##retCode##Method(pData->jobj, t.methodID); \ - t.env->DeleteLocalRef(t.classID); \ -} \ -return ret; \ - - -#define CALL_JAVA_FUNC_WITH_VALIST(retCode) \ -std::vector allParams; \ -if (NULL != param) \ -{ \ - allParams.push_back(param); \ - \ - va_list argp; \ - PluginParam* pArg = NULL; \ - va_start( argp, param ); \ - while (1) \ - { \ - pArg = va_arg(argp, PluginParam*); \ - if (pArg == NULL) \ - break; \ - \ - allParams.push_back(pArg); \ - } \ - va_end(argp); \ -} \ - \ -return call##retCode##FuncWithParam(funcName, allParams); \ - - -#define CALL_JAVA_FUNC(retType, retCode, defaultRet, jRetCode) \ -retType ret = defaultRet; \ -PluginJavaData* pData = PluginUtils::getPluginJavaData(this); \ -if (NULL == pData) { \ - PluginUtils::outputLog(ANDROID_LOG_ERROR, "PluginProtocol", "Can't find java data for plugin : %s", this->getPluginName()); \ - return ret; \ -} \ - \ -std::string paramCode; \ -int nParamNum = params.size(); \ -if (0 == nParamNum) \ -{ \ - paramCode = "()"; \ - paramCode.append(jRetCode); \ - ret = PluginUtils::callJava##retCode##FuncWithName(this, funcName); \ -} else \ -{ \ - PluginParam* pRetParam = NULL; \ - bool needDel = false; \ - if (nParamNum == 1) { \ - pRetParam = params[0]; \ - } else { \ - std::map allParams; \ - for (int i = 0; i < nParamNum; i++) \ - { \ - PluginParam* pArg = params[i]; \ - if (pArg == NULL) \ - { \ - break; \ - } \ - \ - char strKey[8] = { 0 }; \ - sprintf(strKey, "Param%d", i + 1); \ - allParams[strKey] = pArg; \ - } \ - \ - pRetParam = new PluginParam(allParams); \ - needDel = true; \ - } \ - \ - switch(pRetParam->getCurrentType()) \ - { \ - case PluginParam::kParamTypeInt: \ - paramCode = "(I)"; \ - paramCode.append(jRetCode); \ - ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), pRetParam->getIntValue()); \ - break; \ - case PluginParam::kParamTypeFloat: \ - paramCode = "(F)"; \ - paramCode.append(jRetCode); \ - ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), pRetParam->getFloatValue()); \ - break; \ - case PluginParam::kParamTypeBool: \ - paramCode = "(Z)"; \ - paramCode.append(jRetCode); \ - ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), pRetParam->getBoolValue()); \ - break; \ - case PluginParam::kParamTypeString: \ - { \ - jstring jstr = PluginJniHelper::newStringUTF(PluginUtils::getEnv(), pRetParam->getStringValue()); \ - paramCode = "(Ljava/lang/String;)"; \ - paramCode.append(jRetCode); \ - ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), jstr); \ - PluginUtils::getEnv()->DeleteLocalRef(jstr); \ - } \ - break; \ - case PluginParam::kParamTypeStringMap: \ - case PluginParam::kParamTypeMap: \ - { \ - jobject jMap = PluginUtils::getJObjFromParam(pRetParam); \ - paramCode = "(Lorg/json/JSONObject;)"; \ - paramCode.append(jRetCode); \ - ret = PluginUtils::callJava##retCode##FuncWithName_oneParam(this, funcName, paramCode.c_str(), jMap); \ - PluginUtils::getEnv()->DeleteLocalRef(jMap); \ - } \ - break; \ - default: \ - break; \ - } \ - \ - if (needDel && pRetParam != NULL) \ - { \ - delete pRetParam; \ - pRetParam = NULL; \ - } \ -} \ -return ret; \ - - -#endif // __PLUGIN_JNI_MACROS_H__ diff --git a/android/armeabi/include/anysdk/PluginManager.h b/android/armeabi/include/anysdk/PluginManager.h deleted file mode 100644 index 93282ae7..00000000 --- a/android/armeabi/include/anysdk/PluginManager.h +++ /dev/null @@ -1,51 +0,0 @@ -/** @file PluginFactory.h - */ -#ifndef __CCX_PLUGINMANAGER_H__ -#define __CCX_PLUGINMANAGER_H__ - -#include "PluginProtocol.h" -#include "PluginFactory.h" -#include -#include - -namespace anysdk { namespace framework { - -/**    - *  @class  PluginManager   - */ -class PluginManager -{ -public: - virtual ~PluginManager(); - /** - @brief Get singleton of PluginManager - */ - static PluginManager* getInstance(); - /** - @brief Destory the instance of PluginManager - */ - static void end(); - - /** - @brief load the plugin by name and type - @param the name of plugin - @param the type of plugin - */ - PluginProtocol* loadPlugin(const char* name, int pluginType); - /** - @brief unload the plugin by name and type - @param the name of plugin - @param the type of plugin - */ - void unloadPlugin(const char* name, int pluginType = 0); - - -private: - PluginManager(void); - std::map _pluginsMap; -// bool _isDebug; -}; - -}} //namespace anysdk { namespace framework { - -#endif /* __CCX_PLUGINMANAGER_H__ */ diff --git a/android/armeabi/include/anysdk/PluginParam.h b/android/armeabi/include/anysdk/PluginParam.h deleted file mode 100644 index 1f35d4a7..00000000 --- a/android/armeabi/include/anysdk/PluginParam.h +++ /dev/null @@ -1,126 +0,0 @@ -/** @file PluginParam.h - */ -#ifndef __CCX_PLUGIN_PARAM_H__ -#define __CCX_PLUGIN_PARAM_H__ - -#include -#include -/// \typedef std::map StringMap -/// typedef YString. -typedef std::map StringMap; - -namespace anysdk { namespace framework { - -class PluginProtocol; -/**    - *  @class  PluginParam   - */ -class PluginParam -{ -public: - /** - @brief the default constructor of PluginParam - */ - PluginParam(); - - virtual ~PluginParam(); - /** - @brief the constructor of PluginParam - @param the value is Integer - */ - PluginParam(int nValue); - /** - @brief the constructor of PluginParam - @param the value is float - */ - PluginParam(float fValue); - /** - @brief the constructor of PluginParam - @param the value is boolean - */ - PluginParam(bool bValue); - /** - @brief the default constructor of PluginParam - @param the value is char - */ - PluginParam(const char* strValue); - /** - @brief the default constructor of PluginParam - @param the value is StringMap - */ - PluginParam(StringMap strMapValue); - - typedef enum{ - kParamTypeNull = 0, - kParamTypeInt, - kParamTypeFloat, - kParamTypeBool, - kParamTypeString, - kParamTypeStringMap, - kParamTypeMap, - } ParamType; - /** - @brief get the ParamType of value - */ - inline ParamType getCurrentType() { - return _type; - } - /** - @brief get the int value - */ - inline int getIntValue() { - return _intValue; - } - /** - @brief get the float value - */ - inline float getFloatValue() { - return _floatValue; - } - /** - @brief get the boolean value - */ - inline bool getBoolValue() { - return _boolValue; - } - /** - @brief get the char value - */ - inline const char* getStringValue() { - return _strValue.c_str(); - } - /** - @brief get the map of value - */ - inline std::map getMapValue() { - return _mapValue; - } - /** - @brief get the StringMap value - */ - inline StringMap getStrMapValue() { - return _strMapValue; - } - -private: - friend class PluginProtocol; - /** - @brief the constructor of PluginParam - @param the map of value - */ - PluginParam(std::map mapValue); - -private: - ParamType _type; - - int _intValue; - float _floatValue; - bool _boolValue; - std::string _strValue; - std::map _mapValue; - StringMap _strMapValue; -}; - -}} //namespace anysdk { namespace framework { - -#endif /* __CCX_PLUGIN_PARAM_H__ */ diff --git a/android/armeabi/include/anysdk/PluginProtocol.h b/android/armeabi/include/anysdk/PluginProtocol.h deleted file mode 100644 index 95cf706d..00000000 --- a/android/armeabi/include/anysdk/PluginProtocol.h +++ /dev/null @@ -1,144 +0,0 @@ -/** @file PluginProtocol.h - */ -#ifndef __CCX_IPLUGIN_H__ -#define __CCX_IPLUGIN_H__ - -#include "PluginParam.h" -#include - -#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) -#define CC_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) -#elif _MSC_VER >= 1400 //vs 2005 or higher -#define CC_DEPRECATED_ATTRIBUTE __declspec(deprecated) -#else -#define CC_DEPRECATED_ATTRIBUTE -#endif - -namespace anysdk { namespace framework { - -/** - * @class PluginProtocol - * @brief The super class for all plugins. - */ -class PluginProtocol -{ -public: - virtual ~PluginProtocol() {}; - - /** - *@brief set plugin name - *@param the name of plugin - */ - virtual void setPluginName(const char* name) = 0 ; - /** - *@brief get plugin name - *@return the name of plugin - */ - virtual const char* getPluginName() = 0 ; - - /** - *@brief get the version of plugin - *@return the version of plugin - */ - virtual std::string getPluginVersion(); - /** - *@brief get the version of sdk - *@return the version of sdk - */ - virtual std::string getSDKVersion(); - - /** - *@brief switch debug plug-in on/off - *@param the value of on/off - */ - CC_DEPRECATED_ATTRIBUTE virtual void setDebugMode(bool bDebug); - - /** - *@brief methods for reflections - *@param function name - *@param PluginParam* param - *@return void - */ - virtual void callFuncWithParam(const char* funcName, PluginParam* param, ...); - /** - *@brief methods for reflections - *@param function name - *@param std::vector params - *@return void - */ - virtual void callFuncWithParam(const char* funcName, std::vector params); - - /** - *@brief methods for reflections - *@param function name - *@param PluginParam* param - *@return string - */ - virtual std::string callStringFuncWithParam(const char* funcName, PluginParam* param, ...); - /** - *@brief methods for reflections - *@param function name - *@param std::vector params - *@return string - */ - virtual std::string callStringFuncWithParam(const char* funcName, std::vector params); - - /** - *@brief methods for reflections - *@param function name - *@param PluginParam* param - *@return int - */ - virtual int callIntFuncWithParam(const char* funcName, PluginParam* param, ...); - /** - *@brief methods for reflections - *@param function name - *@param std::vector params - *@return int - */ - virtual int callIntFuncWithParam(const char* funcName, std::vector params); - - /** - *@brief methods for reflections - *@param function name - *@param PluginParam* param - *@return bool - */ - virtual bool callBoolFuncWithParam(const char* funcName, PluginParam* param, ...); - /** - *@brief methods for reflections - *@param function name - *@param std::vector params - *@return bool - */ - virtual bool callBoolFuncWithParam(const char* funcName, std::vector params); - - /** - *@brief methods for reflections - *@param function name - *@param PluginParam* param - *@return float - */ - virtual float callFloatFuncWithParam(const char* funcName, PluginParam* param, ...); - /** - *@brief methods for reflections - *@param function name - *@param std::vector params - *@return float - */ - virtual float callFloatFuncWithParam(const char* funcName, std::vector params); - - /** - @brief Check function the plugin support or not - @param the name of plugin - @return if the function support ,return true - else retur false - */ - virtual bool isFunctionSupported(std::string functionName); - - -}; - -}} //namespace anysdk { namespace framework { - -#endif /* __CCX_IPLUGIN_H__ */ diff --git a/android/armeabi/include/anysdk/PluginUtils.h b/android/armeabi/include/anysdk/PluginUtils.h deleted file mode 100644 index 3742c161..00000000 --- a/android/armeabi/include/anysdk/PluginUtils.h +++ /dev/null @@ -1,157 +0,0 @@ -#ifndef __PLUGIN_UTILS_H__ -#define __PLUGIN_UTILS_H__ - -#include "PluginJniHelper.h" -#include "PluginJavaData.h" -#include -#include -#include "PluginParam.h" -#include "PluginJniMacros.h" -#include -//#include - -namespace anysdk { namespace framework { - -class PluginProtocol; -class PluginUtils -{ -public: -//cjh static void initPluginWrapper(android_app* app); - static jobject createJavaMapObject(std::map* paramMap); - static jobject createJavaListObject(std::list* paramList); - static void initJavaPlugin(PluginProtocol* pPlugin, jobject jObj, const char* className, int type); - static JNIEnv* getEnv(); - - static PluginJavaData* getPluginJavaData(PluginProtocol* pKeyObj); - static void setPluginJavaData(PluginProtocol* pKeyObj, PluginJavaData* pData, int type); - static void erasePluginJavaData(PluginProtocol* pKeyObj,int type); - static void erasePluginJavaData(std::string key); - - static PluginProtocol* getPluginPtr(std::string className); - - static jobject getJObjFromParam(PluginParam* param); - - // methods have no return value - template - static void callJavaFunctionWithName_oneParam(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) - { - return_if_fails(funcName != NULL && strlen(funcName) > 0); - return_if_fails(paramCode != NULL && strlen(paramCode) > 0); - PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); - return_if_fails(pData != NULL); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , funcName - , paramCode)) - { - t.env->CallVoidMethod(pData->jobj, t.methodID, param); - t.env->DeleteLocalRef(t.classID); - } - } - static void callJavaFunctionWithName(PluginProtocol* thiz, const char* funcName) - { - return_if_fails(funcName != NULL && strlen(funcName) > 0); - PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); - return_if_fails(pData != NULL); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , funcName - , "()V")) - { - t.env->CallVoidMethod(pData->jobj, t.methodID); - t.env->DeleteLocalRef(t.classID); - } - } - - // methods return value is string - template - static std::string callJavaStringFuncWithName_oneParam(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) - { - std::string ret = ""; - return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret); - return_val_if_fails(paramCode != NULL && strlen(paramCode) > 0, ret); - PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); - return_val_if_fails(pData != NULL, ret); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , funcName - , paramCode)) - { - jstring strRet = (jstring)t.env->CallObjectMethod(pData->jobj, t.methodID, param); - ret = PluginJniHelper::jstring2string(strRet); - t.env->DeleteLocalRef(t.classID); - } - return ret; - } - static std::string callJavaStringFuncWithName(PluginProtocol* thiz, const char* funcName) - { - std::string ret = ""; - return_val_if_fails(funcName != NULL && strlen(funcName) > 0, ret); - PluginJavaData* pData = PluginUtils::getPluginJavaData(thiz); - return_val_if_fails(pData != NULL, ret); - - PluginJniMethodInfo t; - if (PluginJniHelper::getMethodInfo(t - , pData->jclassName.c_str() - , funcName - , "()Ljava/lang/String;")) - { - jstring strRet = (jstring) t.env->CallObjectMethod(pData->jobj, t.methodID); - ret = PluginJniHelper::jstring2string(strRet); - t.env->DeleteLocalRef(t.classID); - } - return ret; - } - - // methods return value is int - template - static int callJavaIntFuncWithName_oneParam(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) - { - CALL_BASERET_JAVA_FUNC_WITH_PARAM(int, paramCode, param, Int, 0) - } - static int callJavaIntFuncWithName(PluginProtocol* thiz, const char* funcName) - { - CALL_BASERET_JAVA_FUNC(int, "()I", Int, 0) - } - - // methods return value is float - template - static float callJavaFloatFuncWithName_oneParam(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) - { - CALL_BASERET_JAVA_FUNC_WITH_PARAM(float, paramCode, param, Float, 0.0f) - } - static float callJavaFloatFuncWithName(PluginProtocol* thiz, const char* funcName) - { - CALL_BASERET_JAVA_FUNC(float, "()F", Float, 0.0f); - } - - // methods return value is bool - template - static bool callJavaBoolFuncWithName_oneParam(PluginProtocol* thiz, const char* funcName, const char* paramCode, T param) - { - CALL_BASERET_JAVA_FUNC_WITH_PARAM(bool, paramCode, param, Boolean, false) - } - static bool callJavaBoolFuncWithName(PluginProtocol* thiz, const char* funcName) - { - CALL_BASERET_JAVA_FUNC(bool, "()Z", Boolean, false) - } - - static void callJavaFunctionWithName_string_map(PluginProtocol* thiz, const char* funcName, const char* keyParam, std::map* paramMap); - - static void outputLog(int type, const char* logTag, const char* pFormat, ...); - static void output(int type, const char* logTag, const char* contents); - - static void resetLogLevel(); -private: - static std::string _logLevel; -}; - -}} // namespace anysdk { namespace framework { - -#endif //__PLUGIN_UTILS_H__ diff --git a/android/armeabi/include/anysdk/ProtocolAdTracking.h b/android/armeabi/include/anysdk/ProtocolAdTracking.h deleted file mode 100644 index 6fc557a2..00000000 --- a/android/armeabi/include/anysdk/ProtocolAdTracking.h +++ /dev/null @@ -1,58 +0,0 @@ -/** @file ProtocolAdTracking.h - */ -#ifndef __CCX_PROTOCOL_ADTRACKING_H__ -#define __CCX_PROTOCOL_ADTRACKING_H__ - -#include "PluginProtocol.h" -#include -namespace anysdk { namespace framework { -/**    - *@class  ProtocolAdTracking - *@brief the interface of AdTracking   - */ -class ProtocolAdTracking : public PluginProtocol -{ -public: - - /** - * - * @Title: onRegister - * @Description: Call this method if you want to track register events as happening during a section. - * @param userId user identifier - * @return void - */ - virtual void onRegister(const char* userId) = 0; - - /** - * - * @Title: onLogin - * @Description:Call this method if you want to track login events as happening during a section. - * @param userInfo The details of this parameters are already covered by document. - * @return void - */ - virtual void onLogin(std::map userInfo) = 0; - - /** - * - * @Title: onPay - * @Description: Call this method if you want to track pay events as happening during a section. - * @param productInfo The details of this parameters are already covered by document. - * @return void - */ - virtual void onPay(std::map productInfo) = 0; - - /** - * - * @Title: trackEvent - * @Description: Call this method if you want to track custom events with parameters as happening during a section. - * @param eventId The custom event name. - * @param paramMap The details of this parameters are already covered by document. - */ - virtual void trackEvent(const char* eventId, std::map* paramMap = NULL) = 0; - - -}; - -}} // namespace anysdk { namespace framework { - -#endif /* ----- #ifndef __CCX_PROTOCOL_ADTRACKING_H__ ----- */ diff --git a/android/armeabi/include/anysdk/ProtocolAds.h b/android/armeabi/include/anysdk/ProtocolAds.h deleted file mode 100644 index 8e29987f..00000000 --- a/android/armeabi/include/anysdk/ProtocolAds.h +++ /dev/null @@ -1,133 +0,0 @@ -/** @file ProtocolAds.h - */ -#ifndef __CCX_PROTOCOL_ADS_H__ -#define __CCX_PROTOCOL_ADS_H__ - -#include "PluginProtocol.h" -#include -#include - -namespace anysdk { namespace framework { -/// \typedef std::map TAdsDeveloperInfo -/// typedef TAdsDeveloperInfo. -typedef std::map TAdsDeveloperInfo; -/// \typedef std::map TAdsInfo -/// typedef TAdsInfo. -typedef std::map TAdsInfo; -/** @brief AdsResultCode enum, with inline docs */ -typedef enum -{ - kAdsReceived = 0, /**< enum the callback: the ad is received is at center. */ - - kAdsShown, /**< enum the callback: the advertisement dismissed. */ - kAdsDismissed, /**< enum the callback: the advertisement dismissed. */ - - kPointsSpendSucceed, /**< enum the callback: the points spend succeed. */ - kPointsSpendFailed, /**< enum the callback: the points spend failed. */ - - kNetworkError, /**< enum the callback of Network error at center. */ - kUnknownError, /**< enum the callback of Unknown error. */ - kOfferWallOnPointsChanged, /**< enum the callback of Changing the point of offerwall. */ - kRewardedVideoWithReward,/**< enum the callback of receiving the reward of rewardedvideo. */ - kInAppPurchaseFinished,/**< enum the callback of finishing IAP ad. */ - kAdsClicked,/**< enum the callback of the advertisement clicked. */ - kAdsExtension = 40000 /**< enum value is extension code . */ -} AdsResultCode; -/** @brief AdsPos enum, with inline docs */ -typedef enum { - kPosCenter = 0,/**< enum the toolbar is at center. */ - kPosTop,/**< enum the toolbar is at top. */ - kPosTopLeft,/**< enum the toolbar is at topleft. */ - kPosTopRight,/**< enum the toolbar is at topright. */ - kPosBottom,/**< enum the toolbar is at bottom. */ - kPosBottomLeft,/**< enum the toolbar is at bottomleft. */ - kPosBottomRight,/**< enum the toolbar is at bottomright. */ -} AdsPos; -/** @brief AdsType enum, with inline docs */ -typedef enum { - AD_TYPE_BANNER = 0,/**< enum value is banner ads . */ - AD_TYPE_FULLSCREEN,/**< enum value is fullscreen ads . */ - AD_TYPE_MOREAPP,/**< enum value is moreapp ads . */ - AD_TYPE_OFFERWALL,/**< enum value is offerwall ads . */ - AD_TYPE_REWARDEDVIDEO,/**< enum value is rewarded video ads . */ - AD_TYPE_NATIVEEXPRESS,/**< enum value is Native express ads . */ - AD_TYPE_NATIVEADVANCED,/**< enum value is Native advanced ads . */ -} AdsType; - -class ProtocolAds; -class AdsListener -{ -public: - /** - *@brief The advertisement request result - *@param the id of callback - *@param the information of callback - */ - virtual void onAdsResult(AdsResultCode code, const char* msg) = 0; -}; - -class ProtocolAds : public PluginProtocol -{ -public: - - - - /** - @brief show adview - @param the type of ads - @param the idx of ads - */ - virtual void showAds(AdsType adsType, int idx = 1) = 0; - - /** - @brief Hide the adview - @param the type of ads - @param the idx of ads - */ - virtual void hideAds(AdsType adsType, int idx = 1) = 0; - - /** - @brief preload the adview - @param the type of ads - @param the idx of ads - */ - virtual void preloadAds(AdsType adsType, int idx = 1)= 0; - - /** - *@brief Query the points of player - *@return the point - */ - virtual float queryPoints() = 0; - - /** - *@brief Spend the points. - Use this method to notify server spend points. - *@param points Need spend number of points - */ - virtual void spendPoints(int points) = 0; - - /** - @brief set the Ads listener - @param pListener The callback object for Ads result - */ - virtual void setAdsListener(AdsListener* listener) = 0; - - /** - @brief get pListener The callback object for Ads result - @return the listener - */ - virtual AdsListener* getAdsListener() = 0; - - /** - @brief Is it supportive of this type of ads - @param the type of ads - @return if it is supportive ,return true - else retur false - */ - virtual bool isAdTypeSupported(AdsType adType) = 0; - -}; - -}} // namespace anysdk { namespace framework { - -#endif /* __CCX_PROTOCOL_ADS_H__ */ diff --git a/android/armeabi/include/anysdk/ProtocolAnalytics.h b/android/armeabi/include/anysdk/ProtocolAnalytics.h deleted file mode 100644 index ce3372d6..00000000 --- a/android/armeabi/include/anysdk/ProtocolAnalytics.h +++ /dev/null @@ -1,107 +0,0 @@ -/** @file ProtocolAnalytics.h - */ -#ifndef __CCX_PROTOCOL_ANALYTICS_H__ -#define __CCX_PROTOCOL_ANALYTICS_H__ - -#include "PluginProtocol.h" -#include -#include - -namespace anysdk { namespace framework { -/// \typedef std::map LogEventParamPair -/// typedef LogEventParamPair. -typedef std::pair< std::string, std::string > LogEventParamPair; -/// \typedef std::map LogEventParamMap -/// typedef LogEventParamMap. -typedef std::map< std::string, std::string > LogEventParamMap; -typedef enum { - ANONYMOUS,/**< enum value is anonymous typek. */ - REGISTED,/**< enum value is registed type. */ - SINA_WEIBO,/**< enum value is sineweibo type. */ - TENCENT_WEIBO,/**< enum value is tecentweibo type */ - QQ,/**< enum value is qq type */ - ND91,/**< enum value is nd91 type. */ -} AccountType; -typedef enum { - LOGIN,/**< enum value is the login operate. */ - LOGOUT,/**< enum value is the logout operate. */ - REGISTER,/**< enum value is the register operate. */ -} AccountOperate; -typedef enum { - MALE,/**< enum value is male. */ - FEMALE,/**< enum value is female. */ - UNKNOWN,/**< enum value is unknow. */ - -} AccountGender; -typedef enum { - GUIDE_LINE,/**< enum value is the guideline type.. */ - MAIN_LINE,/**< enum value is the mainline type.. */ - BRANCH_LINE,/** -#include - -namespace anysdk { namespace framework { - -class ProtocolCrash : public PluginProtocol -{ -public: - /** - * set user identifier - * - * @param userInfo - */ - virtual void setUserIdentifier(const char* identifier) = 0; - - /** - * The uploader captured in exception information - * - * @param message Set the custom information - * @param exception The exception - */ - virtual void reportException(const char* message, const char* exception) = 0; - - /** - * customize logging - * - * @param string Custom log - */ - virtual void leaveBreadcrumb(const char* breadcrumb) = 0; - - - - -}; - -}} // namespace anysdk { namespace framework { - -#endif /* __CCX_PROTOCOL_CRASH_H__ */ diff --git a/android/armeabi/include/anysdk/ProtocolCustom.h b/android/armeabi/include/anysdk/ProtocolCustom.h deleted file mode 100644 index dc92558e..00000000 --- a/android/armeabi/include/anysdk/ProtocolCustom.h +++ /dev/null @@ -1,50 +0,0 @@ -/** @file ProtocolCustom.h - */ -#ifndef __CCX_PROTOCOL_CUSTOM_H__ -#define __CCX_PROTOCOL_CUSTOM_H__ - -#include "PluginProtocol.h" -#include -#include - -namespace anysdk { namespace framework { -typedef enum -{ - kCustomExtension = 80000 /**< enum value is extension code . */ -} CustomResultCode; -/**    - *@class  CustomResultListener - *@brief the interface of share callback   - */ -class CustomResultListener -{ -public: - /**    - *@brief the interface of share callback  - *@param the id of callback - *@param the information of callback - */ - virtual void onCustomResult(CustomResultCode ret, const char* msg) = 0; -}; -/**    - *@class  ProtocolCustom - *@brief the interface of custom   - */ -class ProtocolCustom : public PluginProtocol -{ -public: - - /** - @breif set the result listener - @param pListener The callback object for custom result - @wraning Must invoke this interface before custom - */ - virtual void setResultListener(CustomResultListener* pListener) = 0; - - virtual CustomResultListener* getCustomListener() = 0; - -}; - -}} // namespace anysdk { namespace framework { - -#endif /* ----- #ifndef __CCX_PROTOCOL_Custom_H__ ----- */ diff --git a/android/armeabi/include/anysdk/ProtocolIAP.h b/android/armeabi/include/anysdk/ProtocolIAP.h deleted file mode 100644 index 4a875b32..00000000 --- a/android/armeabi/include/anysdk/ProtocolIAP.h +++ /dev/null @@ -1,119 +0,0 @@ -/** @file ProtocolIAP.h - */ -#ifndef __CCX_PROTOCOL_IAP_H__ -#define __CCX_PROTOCOL_IAP_H__ - -#include "PluginProtocol.h" -#include -#include - -namespace anysdk { namespace framework { -/// \typedef std::map TIAPDeveloperInfo -/// typedef TIAPDeveloperInfo. -typedef std::map TIAPDeveloperInfo; -/// \typedef std::map TProductInfo -/// typedef TProductInfo. -typedef std::map TProductInfo; -/// typedef TProductsInfo. -typedef std::map AllProductsInfo; -/** @brief PayResultCode enum, with inline docs */ -typedef enum -{ - kPaySuccess = 0,/**< enum value is callback of succeeding in paying . */ - kPayFail,/**< enum value is callback of failing to pay . */ - kPayCancel,/**< enum value is callback of canceling to pay . */ - kPayNetworkError,/**< enum value is callback of network error . */ - kPayProductionInforIncomplete,/**< enum value is callback of incompleting info . */ - kPayInitSuccess,/**< enum value is callback of succeeding in initing sdk . */ - kPayInitFail,/**< enum value is callback of failing to init sdk . */ - kPayNowPaying,/**< enum value is callback of paying now . */ - kPayRechargeSuccess,/**< enum value is callback of succeeding in recharging. */ - kPayExtension = 30000 /**< enum value is extension code . */ -} PayResultCode; -/** @brief RequestResultCode enum, with inline docs */ -typedef enum -{ - kRequestSuccess = 31000,/**< enum value is callback of succeeding in paying . */ - kRequestFail/**< enum value is callback of failing to pay . */ -} RequestResultCode; -/**    - *@class  PayResultListener - *@brief the interface of pay callback   - */ -class PayResultListener -{ -public: - /**    - *@brief the interface of pay callback  - *@param the id of callback - *@param the information of callback - *@param the info of pay - */ - virtual void onPayResult(PayResultCode ret, const char* msg, TProductInfo info) = 0; - /** - *@brief the interface of request callback - *@param the id of callback - *@param the information of callback - *@param the info of request product - */ - virtual void onRequestResult(RequestResultCode ret, const char* msg, AllProductsInfo info) {} -}; -/**    - *@class  ProtocolIAP - *@brief the interface of pay    - */ - -class ProtocolIAP : public PluginProtocol -{ -public: - - /** - @brief pay for product - @param info The info of product, must contains key: - productName The name of product - productPrice The price of product(must can be parse to float) - productDesc The description of product - @warning For different plugin, the parameter should have other keys to pay. - Look at the manual of plugins. - */ - virtual void payForProduct(TProductInfo info) = 0; - /** - @brief get order id - @return the order id - */ - virtual std::string getOrderId() = 0; - - /** - @breif set the result listener - @param pListener The callback object for pay result - @wraning Must invoke this interface before payForProduct. - */ - virtual void setResultListener(PayResultListener* pListener) = 0; - - virtual PayResultListener* getPayListener() = 0 ; - - /** - @brief get plugin id - @return the plugin id - */ - virtual std::string getPluginId() = 0 ; - - /** - @brief change the state of paying - @param the state - */ - - static void resetPayState() - { - _paying = false; - } - static bool _paying; - - - -}; - - -}} // namespace anysdk { namespace framework { - -#endif /* __CCX_PROTOCOL_IAP_H__ */ diff --git a/android/armeabi/include/anysdk/ProtocolPush.h b/android/armeabi/include/anysdk/ProtocolPush.h deleted file mode 100644 index e9e2fac8..00000000 --- a/android/armeabi/include/anysdk/ProtocolPush.h +++ /dev/null @@ -1,104 +0,0 @@ -/** @file PluginFactory.h - */ -#ifndef __CCX_PROTOCOL_PUSH_H__ -#define __CCX_PROTOCOL_PUSH_H__ - -#include "PluginProtocol.h" -#include -#include -#include -using namespace std; - -namespace anysdk { namespace framework { -/** @brief Plugin_type enum, with inline docs */ -typedef enum -{ - kPushReceiveMessage = 0,/**value is callback of Receiving Message . */ - kPushExtensionCode = 60000 /**< enum value is extension code . */ - - -} PushActionResultCode; -class ProtocolPush; -/**    - *@class  PushActionListener - *@brief the interface of Push callback   - */ -class PushActionListener -{ -public: - /**    - *@brief the interface of Push callback  - *@param the adatper of plugin - *@param the id of callback - *@param the information of callback - */ - virtual void onActionResult(ProtocolPush* pPlugin, PushActionResultCode code, const char* msg) = 0; -}; -/**    - *  @class  ProtocolPush   - */ -class ProtocolPush : public PluginProtocol -{ -public: - - - /** - *@brief start/register Push services - *@return void - */ - virtual void startPush() = 0 ; - - - /** - *@brief close Push services - *@return void - */ - virtual void closePush() = 0 ; - - - /** - *@brief set alias - *@param tags - *@return void - */ - virtual void setAlias(string alias) = 0; - - /** - *@brief del alias - *@param tags - *@return void - */ - virtual void delAlias(string alias) = 0; - - /** - *@brief set tag - *@param tags - *@return void - */ - virtual void setTags(list tags) = 0; - - /** - *@brief delete tag - *@param tags - *@return void - */ - virtual void delTags(list tags) = 0; - - /** - @brief set the result listener - @param pListener The callback object for push result - */ - virtual void setActionListener(PushActionListener* listener) = 0 ; - - /** - @brief get pListener The callback object for Push result - @return the listener - */ - virtual PushActionListener* getActionListener() = 0 ; - - -}; - -}} // namespace anysdk { namespace framework { - -#endif /* __CCX_PROTOCOL_PUSH_H__ */ diff --git a/android/armeabi/include/anysdk/ProtocolREC.h b/android/armeabi/include/anysdk/ProtocolREC.h deleted file mode 100644 index b0db2c0d..00000000 --- a/android/armeabi/include/anysdk/ProtocolREC.h +++ /dev/null @@ -1,83 +0,0 @@ -/** @file ProtocolREC.h - */ -#ifndef __CCX_PROTOCOL_REC_H__ -#define __CCX_PROTOCOL_REC_H__ - -#include "PluginProtocol.h" -#include -#include - -namespace anysdk { namespace framework { - -typedef std::map TVideoInfo; - -/** @brief RECResultCode enum, with inline docs */ -typedef enum -{ - kRECInitSuccess = 0,/**< enum value is callback of succeeding in initing sdk . */ - kRECInitFail,/**< enum value is callback of failing to init sdk. */ - kRECStartRecording,/**< enum value is callback of starting to record. */ - kRECStopRecording,/**< enum value is callback of stoping to record. */ - kRECPauseRecording,/**< enum value is callback of pausing to record. */ - kRECResumeRecording,/**< enum value is callback of resuming to record. */ - kRECEnterSDKPage,/**< enum value is callback of entering SDK`s page. */ - kRECQuitSDKPage,/**< enum value is callback of quiting SDK`s page. */ - kRECShareSuccess,/**< enum value is callback of succeeding in sharing. */ - kRECShareFail,/**< enum value is callback of failing to share. */ - kRECExtension = 90000 /**< enum value is extension code . */ -} RECResultCode; -/**    - *@class  RECResultListener - *@brief the interface of REC callback   - */ -class RECResultListener -{ -public: - /**    - *@brief the interface of REC callback  - *@param the id of callback - *@param the information of callback - */ - virtual void onRECResult(RECResultCode ret, const char* msg) = 0; -}; -/**    - *@class  ProtocolREC - *@brief the interface of REC   - */ -class ProtocolREC : public PluginProtocol -{ -public: - - /** - * @Description: Start to record video - */ - virtual void startRecording() = 0; - - /** - * @Description: Stop to record video - */ - virtual void stopRecording() = 0; - - /** - * @Description: share video - * @Param info The info of share - */ - virtual void share(TVideoInfo info) = 0; - - - - /** - @breif set the result listener - @param pListener The callback object for REC result - @wraning Must invoke this interface before REC - */ - virtual void setResultListener(RECResultListener* pListener) = 0; - - virtual RECResultListener* getRECListener() = 0; - - -}; - -}} // namespace anysdk { namespace framework { - -#endif /* ----- #ifndef __CCX_PROTOCOL_SHARE_H__ ----- */ diff --git a/android/armeabi/include/anysdk/ProtocolShare.h b/android/armeabi/include/anysdk/ProtocolShare.h deleted file mode 100644 index 2215a4ff..00000000 --- a/android/armeabi/include/anysdk/ProtocolShare.h +++ /dev/null @@ -1,72 +0,0 @@ -/** @file ProtocolShare.h - */ -#ifndef __CCX_PROTOCOL_SHARE_H__ -#define __CCX_PROTOCOL_SHARE_H__ - -#include "PluginProtocol.h" -#include -#include - -namespace anysdk { namespace framework { -/// \typedef std::map TShareDeveloperInfo -/// typedef TShareDeveloperInfo. -typedef std::map TShareDeveloperInfo; -/// \typedef std::map TShareInfo -/// typedef TShareInfo. -typedef std::map TShareInfo; -/** @brief ShareResultCode enum, with inline docs */ -typedef enum -{ - kShareSuccess = 0,/**< enum value is callback of failing to sharing . */ - kShareFail,/**< enum value is callback of failing to share . */ - kShareCancel,/**< enum value is callback of canceling to share . */ - kShareNetworkError,/**< enum value is callback of network error . */ - kShareExtension = 10000 /**< enum value is extension code . */ -} ShareResultCode; -/**    - *@class  ShareResultListener - *@brief the interface of share callback   - */ -class ShareResultListener -{ -public: - /**    - *@brief the interface of share callback  - *@param the id of callback - *@param the information of callback - */ - virtual void onShareResult(ShareResultCode ret, const char* msg) = 0; -}; -/**    - *@class  ProtocolShare - *@brief the interface of share   - */ -class ProtocolShare : public PluginProtocol -{ -public: - - - - /** - @brief share information - @param info The info of share, contains key: - SharedText The text need to share - SharedImagePath The full path of image file need to share (optinal) - @warning For different plugin, the parameter should have other keys to share. - Look at the manual of plugins. */ - virtual void share(TShareInfo info) = 0; - - /** - @breif set the result listener - @param pListener The callback object for share result - @wraning Must invoke this interface before share - */ - virtual void setResultListener(ShareResultListener* pListener) = 0; - - virtual ShareResultListener* getShareListener() = 0; - -}; - -}} // namespace anysdk { namespace framework { - -#endif /* ----- #ifndef __CCX_PROTOCOL_SHARE_H__ ----- */ diff --git a/android/armeabi/include/anysdk/ProtocolSocial.h b/android/armeabi/include/anysdk/ProtocolSocial.h deleted file mode 100644 index 3fa5639b..00000000 --- a/android/armeabi/include/anysdk/ProtocolSocial.h +++ /dev/null @@ -1,105 +0,0 @@ -/** @file ProtocolSocial.h - */ -#ifndef __CCX_PROTOCOL_SOCIAL_H__ -#define __CCX_PROTOCOL_SOCIAL_H__ - -#include "PluginProtocol.h" -#include -#include - -namespace anysdk { namespace framework { -/// \typedef std::map TSocialDeveloperInfo -/// typedef TSocialDeveloperInfo. -typedef std::map TSocialDeveloperInfo; -/// \typedef std::map TAchievementInfo -/// typedef TAchievementInfo. -typedef std::map TAchievementInfo; -/** @brief SocialRetCode enum, with inline docs */ -typedef enum -{ - // code for leaderboard feature - kScoreSubmitSucceed =1,/**< enum value is callback of succeeding in submiting. */ - kScoreSubmitfail,/**< enum value is callback of failing to submit . */ - - // code for achievement feature - kAchUnlockSucceed,/**< enum value is callback of succeeding in unlocking. */ - kAchUnlockFail,/**< enum value is callback of failing to unlock. */ - - kSocialSignInSucceed,/**< enum value is callback of succeeding to login. */ - kSocialSignInFail,/**< enum value is callback of failing to login. */ - - kSocialSignOutSucceed,/**< enum value is callback of succeeding to login. */ - kSocialSignOutFail,/**< enum value is callback of failing to login. */ - kSocialGetGameFriends,/**< enum value is callback of getGameFriends. */ - kSocialExtensionCode = 20000 /**< enum value is extension code . */ - -} SocialRetCode; -/**    - *@class  SocialListener - *@brief the interface of social callback   - */ -class SocialListener -{ -public: - /**    - *@brief the interface of social callback  - *@param the id of callback - *@param the information of callback - */ - virtual void onSocialResult(SocialRetCode code, const char* msg) = 0; -}; - -/**    - *@class  ProtocolSocial - *@brief the interface of social   - */ -class ProtocolSocial : public PluginProtocol -{ -public: - - /** - @brief user signIn - */ - virtual void signIn() = 0; - - /** - @brief user signOut - */ - virtual void signOut() = 0; - - /** - @brief submit the score - @param leaderboardID - @param the score - */ - virtual void submitScore(const char* leadboardID, long score) = 0; - /** - @brief show the id of Leaderboard page - @param leaderboardID - */ - virtual void showLeaderboard(const char* leaderboardID) = 0; - - /** - @brief methods of achievement feature - @param the info of achievement - */ - virtual void unlockAchievement(TAchievementInfo achInfo) = 0; - /** - @brief show the page of achievements - */ - virtual void showAchievements() = 0; - /** - @brief set pListener The callback object for social result - @param the listener - */ - virtual void setListener(SocialListener* listener) = 0; - /** - @brief get pListener The callback object for social result - @return the listener - */ - virtual SocialListener* getListener() = 0; -}; - -}} // namespace anysdk { namespace framework { - -#endif /* ----- #ifndef __CCX_PROTOCOL_SOCIAL_H__ ----- */ diff --git a/android/armeabi/include/anysdk/ProtocolUser.h b/android/armeabi/include/anysdk/ProtocolUser.h deleted file mode 100644 index 387fb9e8..00000000 --- a/android/armeabi/include/anysdk/ProtocolUser.h +++ /dev/null @@ -1,135 +0,0 @@ -/** @file ProtocolUser.h - */ -#ifndef __CCX_PROTOCOL_USER_H__ -#define __CCX_PROTOCOL_USER_H__ - -#include "PluginProtocol.h" -#include -#include - -namespace anysdk { namespace framework { -/// \typedef std::map TUserDeveloperInfo -/// typedef TUserDeveloperInfo. -typedef std::map TUserDeveloperInfo; -/** @brief Plugin_type enum, with inline docs */ -typedef enum -{ - kInitSuccess = 0,/**< enum value is callback of succeeding in initing sdk. */ - kInitFail,/**< enum value is callback of failing to init sdk. */ - kLoginSuccess,/**< enum value is callback of succeeding in login.*/ - kLoginNetworkError,/**< enum value is callback of network error*/ - kLoginNoNeed,/**< enum value is callback of no need login.*/ - kLoginFail,/**< enum value is callback of failing to login. */ - kLoginCancel,/**< enum value is callback of canceling to login. */ - kLogoutSuccess,/**< enum value is callback of succeeding in logout. */ - kLogoutFail,/**< enum value is callback of failing to logout. */ - kPlatformEnter,/**< enum value is callback after enter platform. */ - kPlatformBack,/**< enum value is callback after exit antiAddiction. */ - kPausePage,/**< enum value is callback after exit pause page. */ - kExitPage,/**< enum value is callback after exit exit page. */ - kAntiAddictionQuery,/**< enum value is callback after querying antiAddiction. */ - kRealNameRegister,/**< enum value is callback after registering realname. */ - kAccountSwitchSuccess,/**< enum value is callback of succeeding in switching account. */ - kAccountSwitchFail,/**< enum value is callback of failing to switch account. */ - kOpenShop,/**< enum value is callback of open the shop. */ - kAccountSwitchCancel,/**< enum value is callback of canceling to switch account. */ - kGameExitPage,/**< enum value is callback of no channel exit page. */ - kUserExtension = 50000 /**< enum value is extension code . */ - - -} UserActionResultCode; -/** @brief ToolBarPlace enum, with inline docs */ -typedef enum -{ - kToolBarTopLeft = 1,/**< enum the toolbar is at topleft. */ - kToolBarTopRight,/**< enum the toolbar is at topright. */ - kToolBarMidLeft,/**< enum the toolbar is at midleft. */ - kToolBarMidRight,/**< enum the toolbar is at midright. */ - kToolBarBottomLeft,/**< enum the toolbar is at bottomleft. */ - kToolBarBottomRight,/**< enum the toolbar is at bottomright. */ -} ToolBarPlace; - -class ProtocolUser; -/**    - *@class  UserActionListener - *@brief the interface of user callback   - */ -class UserActionListener -{ -public: - /**    - *@brief the interface of user callback  - *@param the adatper of plugin - *@param the id of callback - *@param the information of callback - */ - virtual void onActionResult(ProtocolUser* pPlugin, UserActionResultCode code, const char* msg) = 0; -}; -/**    - *  @class  ProtocolUser   - */ -class ProtocolUser : public PluginProtocol -{ -public: - - - /** - @brief User login - */ - virtual void login() = 0 ; - - /** - @brief User login - if the process of logining need to know the param of server_id , - you can use the function - and if you must change oauthloginserver, you can add the param of oauthLoginServer - @param server_id - @param oauthLoginServer - */ - - CC_DEPRECATED_ATTRIBUTE virtual void login(std::string server_id, std::string oauthLoginServer = "") = 0 ; - - /** - @brief User login - if the process of logining need to know the parameters , - you can use the function - @param the parameters - */ - virtual void login(std::map info) = 0 ; - - /** - @brief Check whether the user logined or not - @return If user logined, return value is true; - else return value is false. - */ - virtual bool isLogined() = 0 ; - - /** - @brief Get USER ID - @return If user logined, return value is userID; - else return value is empty string. - */ - virtual std::string getUserID() = 0 ; - /** - @brief set the result listener - @param pListener The callback object for user result - */ - virtual void setActionListener(UserActionListener* listener) = 0 ; - /** - @brief get pListener The callback object for user result - @return the listener - */ - virtual UserActionListener* getActionListener() = 0 ; - - /** - @brief get plugin id - @return the plugin id - */ - virtual std::string getPluginId() = 0 ; - - -}; - -}} // namespace anysdk { namespace framework { - -#endif /* __CCX_PROTOCOL_USER_H__ */ diff --git a/android/armeabi/include/anysdk/Statistics.h b/android/armeabi/include/anysdk/Statistics.h deleted file mode 100644 index bb389ff0..00000000 --- a/android/armeabi/include/anysdk/Statistics.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef __STATISTICS_H__ -#define __STATISTICS_H__ - -#include -namespace anysdk { namespace framework { - -class Statistics -{ -public: - static void initInfo(); - static void createPlugin(std::string pluginName, int pluginType); - static void callFunction(std::string pluginName, std::string functionName); - -}; - -}} // namespace anysdk { namespace framework { - -#endif //__STATISTICS_H__ diff --git a/android/armeabi/include/chipmunk/chipmunk.h b/android/armeabi/include/chipmunk/chipmunk.h deleted file mode 100644 index d7faf039..00000000 --- a/android/armeabi/include/chipmunk/chipmunk.h +++ /dev/null @@ -1,241 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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 CHIPMUNK_H -#define CHIPMUNK_H - -#include -#include - -#ifdef WIN32 - // For alloca(). - #include - #define CP_EXPORT __declspec(dllexport) -#else - #include - #define CP_EXPORT -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -// NUKE -#ifndef CP_ALLOW_PRIVATE_ACCESS - #define CP_ALLOW_PRIVATE_ACCESS 0 -#endif - -#if CP_ALLOW_PRIVATE_ACCESS == 1 - #define CP_PRIVATE(__symbol__) __symbol__ -#else - #define CP_PRIVATE(__symbol__) __symbol__##_private -#endif - -CP_EXPORT void cpMessage(const char *condition, const char *file, int line, int isError, int isHardError, const char *message, ...); -#ifdef NDEBUG - #define cpAssertWarn(__condition__, ...) - #define cpAssertSoft(__condition__, ...) -#else - #define cpAssertSoft(__condition__, ...) if(!(__condition__)){cpMessage(#__condition__, __FILE__, __LINE__, 1, 0, __VA_ARGS__); abort();} - #define cpAssertWarn(__condition__, ...) if(!(__condition__)) cpMessage(#__condition__, __FILE__, __LINE__, 0, 0, __VA_ARGS__) -#endif - -// Hard assertions are used in situations where the program definitely will crash anyway, and the reason is inexpensive to detect. -#define cpAssertHard(__condition__, ...) if(!(__condition__)){cpMessage(#__condition__, __FILE__, __LINE__, 1, 1, __VA_ARGS__); abort();} - -#include "chipmunk_types.h" - -/// @defgroup misc Misc -/// @{ - -/// Allocated size for various Chipmunk buffers -#ifndef CP_BUFFER_BYTES - #define CP_BUFFER_BYTES (32*1024) -#endif - -#ifndef cpcalloc - /// Chipmunk calloc() alias. - #define cpcalloc calloc -#endif - -#ifndef cprealloc - /// Chipmunk realloc() alias. - #define cprealloc realloc -#endif - -#ifndef cpfree - /// Chipmunk free() alias. - #define cpfree free -#endif - -typedef struct cpArray cpArray; -typedef struct cpHashSet cpHashSet; - -typedef struct cpBody cpBody; - -typedef struct cpShape cpShape; -typedef struct cpCircleShape cpCircleShape; -typedef struct cpSegmentShape cpSegmentShape; -typedef struct cpPolyShape cpPolyShape; - -typedef struct cpConstraint cpConstraint; -typedef struct cpPinJoint cpPinJoint; -typedef struct cpSlideJoint cpSlideJoint; -typedef struct cpPivotJoint cpPivotJoint; -typedef struct cpGrooveJoint cpGrooveJoint; -typedef struct cpDampedSpring cpDampedSpring; -typedef struct cpDampedRotarySpring cpDampedRotarySpring; -typedef struct cpRotaryLimitJoint cpRotaryLimitJoint; -typedef struct cpRatchetJoint cpRatchetJoint; -typedef struct cpGearJoint cpGearJoint; -typedef struct cpSimpleMotorJoint cpSimpleMotorJoint; - -typedef struct cpCollisionHandler cpCollisionHandler; -typedef struct cpContactPointSet cpContactPointSet; -typedef struct cpArbiter cpArbiter; - -typedef struct cpSpace cpSpace; - -#include "cpVect.h" -#include "cpBB.h" -#include "cpTransform.h" -#include "cpSpatialIndex.h" - -#include "cpArbiter.h" - -#include "cpBody.h" -#include "cpShape.h" -#include "cpPolyShape.h" - -#include "cpConstraint.h" - -#include "cpSpace.h" -#include "cpHastySpace.h" - -// Chipmunk 7.0.1 -#define CP_VERSION_MAJOR 7 -#define CP_VERSION_MINOR 0 -#define CP_VERSION_RELEASE 1 - -/// Version string. -CP_EXPORT extern const char *cpVersionString; - -/// Calculate the moment of inertia for a circle. -/// @c r1 and @c r2 are the inner and outer diameters. A solid circle has an inner diameter of 0. -CP_EXPORT cpFloat cpMomentForCircle(cpFloat m, cpFloat r1, cpFloat r2, cpVect offset); - -/// Calculate area of a hollow circle. -/// @c r1 and @c r2 are the inner and outer diameters. A solid circle has an inner diameter of 0. -CP_EXPORT cpFloat cpAreaForCircle(cpFloat r1, cpFloat r2); - -/// Calculate the moment of inertia for a line segment. -/// Beveling radius is not supported. -CP_EXPORT cpFloat cpMomentForSegment(cpFloat m, cpVect a, cpVect b, cpFloat radius); - -/// Calculate the area of a fattened (capsule shaped) line segment. -CP_EXPORT cpFloat cpAreaForSegment(cpVect a, cpVect b, cpFloat radius); - -/// Calculate the moment of inertia for a solid polygon shape assuming it's center of gravity is at it's centroid. The offset is added to each vertex. -CP_EXPORT cpFloat cpMomentForPoly(cpFloat m, int count, const cpVect *verts, cpVect offset, cpFloat radius); - -/// Calculate the signed area of a polygon. A Clockwise winding gives positive area. -/// This is probably backwards from what you expect, but matches Chipmunk's the winding for poly shapes. -CP_EXPORT cpFloat cpAreaForPoly(const int count, const cpVect *verts, cpFloat radius); - -/// Calculate the natural centroid of a polygon. -CP_EXPORT cpVect cpCentroidForPoly(const int count, const cpVect *verts); - -/// Calculate the moment of inertia for a solid box. -CP_EXPORT cpFloat cpMomentForBox(cpFloat m, cpFloat width, cpFloat height); - -/// Calculate the moment of inertia for a solid box. -CP_EXPORT cpFloat cpMomentForBox2(cpFloat m, cpBB box); - -/// Calculate the convex hull of a given set of points. Returns the count of points in the hull. -/// @c result must be a pointer to a @c cpVect array with at least @c count elements. If @c verts == @c result, then @c verts will be reduced inplace. -/// @c first is an optional pointer to an integer to store where the first vertex in the hull came from (i.e. verts[first] == result[0]) -/// @c tol is the allowed amount to shrink the hull when simplifying it. A tolerance of 0.0 creates an exact hull. -CP_EXPORT int cpConvexHull(int count, const cpVect *verts, cpVect *result, int *first, cpFloat tol); - -#ifdef _MSC_VER -#include "malloc.h" -#endif - -/// Convenience macro to work with cpConvexHull. -/// @c count and @c verts is the input array passed to cpConvexHull(). -/// @c count_var and @c verts_var are the names of the variables the macro creates to store the result. -/// The output vertex array is allocated on the stack using alloca() so it will be freed automatically, but cannot be returned from the current scope. -#define CP_CONVEX_HULL(__count__, __verts__, __count_var__, __verts_var__) \ -cpVect *__verts_var__ = (cpVect *)alloca(__count__*sizeof(cpVect)); \ -int __count_var__ = cpConvexHull(__count__, __verts__, __verts_var__, NULL, 0.0); \ - -/// Returns the closest point on the line segment ab, to the point p. -static inline cpVect -cpClosetPointOnSegment(const cpVect p, const cpVect a, const cpVect b) -{ - cpVect delta = cpvsub(a, b); - cpFloat t = cpfclamp01(cpvdot(delta, cpvsub(p, b))/cpvlengthsq(delta)); - return cpvadd(b, cpvmult(delta, t)); -} - -#if defined(__has_extension) -#if __has_extension(blocks) -// Define alternate block based alternatives for a few of the callback heavy functions. -// Collision handlers are post-step callbacks are not included to avoid memory management issues. -// If you want to use blocks for those and are aware of how to correctly manage the memory, the implementation is trivial. - -void cpSpaceEachBody_b(cpSpace *space, void (^block)(cpBody *body)); -void cpSpaceEachShape_b(cpSpace *space, void (^block)(cpShape *shape)); -void cpSpaceEachConstraint_b(cpSpace *space, void (^block)(cpConstraint *constraint)); - -void cpBodyEachShape_b(cpBody *body, void (^block)(cpShape *shape)); -void cpBodyEachConstraint_b(cpBody *body, void (^block)(cpConstraint *constraint)); -void cpBodyEachArbiter_b(cpBody *body, void (^block)(cpArbiter *arbiter)); - -typedef void (^cpSpacePointQueryBlock)(cpShape *shape, cpVect point, cpFloat distance, cpVect gradient); -void cpSpacePointQuery_b(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpSpacePointQueryBlock block); - -typedef void (^cpSpaceSegmentQueryBlock)(cpShape *shape, cpVect point, cpVect normal, cpFloat alpha); -void cpSpaceSegmentQuery_b(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSpaceSegmentQueryBlock block); - -typedef void (^cpSpaceBBQueryBlock)(cpShape *shape); -void cpSpaceBBQuery_b(cpSpace *space, cpBB bb, cpShapeFilter filter, cpSpaceBBQueryBlock block); - -typedef void (^cpSpaceShapeQueryBlock)(cpShape *shape, cpContactPointSet *points); -cpBool cpSpaceShapeQuery_b(cpSpace *space, cpShape *shape, cpSpaceShapeQueryBlock block); - -#endif -#endif - - -//@} - -#ifdef __cplusplus -} - -static inline cpVect operator *(const cpVect v, const cpFloat s){return cpvmult(v, s);} -static inline cpVect operator +(const cpVect v1, const cpVect v2){return cpvadd(v1, v2);} -static inline cpVect operator -(const cpVect v1, const cpVect v2){return cpvsub(v1, v2);} -static inline cpBool operator ==(const cpVect v1, const cpVect v2){return cpveql(v1, v2);} -static inline cpVect operator -(const cpVect v){return cpvneg(v);} - -#endif -#endif diff --git a/android/armeabi/include/chipmunk/chipmunk_ffi.h b/android/armeabi/include/chipmunk/chipmunk_ffi.h deleted file mode 100644 index c0248410..00000000 --- a/android/armeabi/include/chipmunk/chipmunk_ffi.h +++ /dev/null @@ -1,107 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -#ifdef CHIPMUNK_FFI - -// Create non static inlined copies of Chipmunk functions, useful for working with dynamic FFIs -// This file should only be included in chipmunk.c - -// TODO: get rid of the reliance on static inlines. -// They make a mess for FFIs. - -#ifdef _MSC_VER - #if _MSC_VER >= 1600 - #define MAKE_REF(name) CP_EXPORT decltype(name) *_##name = name - #else - #define MAKE_REF(name) - #endif -#else - #define MAKE_REF(name) __typeof__(name) *_##name = name -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -MAKE_REF(cpv); // makes a variable named _cpv that contains the function pointer for cpv() -MAKE_REF(cpveql); -MAKE_REF(cpvadd); -MAKE_REF(cpvneg); -MAKE_REF(cpvsub); -MAKE_REF(cpvmult); -MAKE_REF(cpvdot); -MAKE_REF(cpvcross); -MAKE_REF(cpvperp); -MAKE_REF(cpvrperp); -MAKE_REF(cpvproject); -MAKE_REF(cpvforangle); -MAKE_REF(cpvtoangle); -MAKE_REF(cpvrotate); -MAKE_REF(cpvunrotate); -MAKE_REF(cpvlengthsq); -MAKE_REF(cpvlength); -MAKE_REF(cpvlerp); -MAKE_REF(cpvnormalize); -MAKE_REF(cpvclamp); -MAKE_REF(cpvlerpconst); -MAKE_REF(cpvdist); -MAKE_REF(cpvdistsq); -MAKE_REF(cpvnear); - -MAKE_REF(cpfmax); -MAKE_REF(cpfmin); -MAKE_REF(cpfabs); -MAKE_REF(cpfclamp); -MAKE_REF(cpflerp); -MAKE_REF(cpflerpconst); - -MAKE_REF(cpBBNew); -MAKE_REF(cpBBNewForExtents); -MAKE_REF(cpBBNewForCircle); -MAKE_REF(cpBBIntersects); -MAKE_REF(cpBBContainsBB); -MAKE_REF(cpBBContainsVect); -MAKE_REF(cpBBMerge); -MAKE_REF(cpBBExpand); -MAKE_REF(cpBBCenter); -MAKE_REF(cpBBArea); -MAKE_REF(cpBBMergedArea); -MAKE_REF(cpBBSegmentQuery); -MAKE_REF(cpBBIntersectsSegment); -MAKE_REF(cpBBClampVect); - -MAKE_REF(cpSpatialIndexDestroy); -MAKE_REF(cpSpatialIndexCount); -MAKE_REF(cpSpatialIndexEach); -MAKE_REF(cpSpatialIndexContains); -MAKE_REF(cpSpatialIndexInsert); -MAKE_REF(cpSpatialIndexRemove); -MAKE_REF(cpSpatialIndexReindex); -MAKE_REF(cpSpatialIndexReindexObject); -MAKE_REF(cpSpatialIndexSegmentQuery); -MAKE_REF(cpSpatialIndexQuery); -MAKE_REF(cpSpatialIndexReindexQuery); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android/armeabi/include/chipmunk/chipmunk_private.h b/android/armeabi/include/chipmunk/chipmunk_private.h deleted file mode 100644 index abe56395..00000000 --- a/android/armeabi/include/chipmunk/chipmunk_private.h +++ /dev/null @@ -1,766 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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 CHIPMUNK_PRIVATE_H -#define CHIPMUNK_PRIVATE_H -#ifdef CHIPMUNK_H -#error Cannot include chipmunk_private.h after chipmunk.h. -#endif - -#define CP_ALLOW_PRIVATE_ACCESS 1 -#include "chipmunk/chipmunk.h" - -#define CP_HASH_COEF (3344921057ul) -#define CP_HASH_PAIR(A, B) ((cpHashValue)(A)*CP_HASH_COEF ^ (cpHashValue)(B)*CP_HASH_COEF) - -// TODO: Eww. Magic numbers. -#define MAGIC_EPSILON 1e-5 - - -//MARK: cpArray - -struct cpArray { - int num, max; - void **arr; -}; - -cpArray *cpArrayNew(int size); - -void cpArrayFree(cpArray *arr); - -void cpArrayPush(cpArray *arr, void *object); -void *cpArrayPop(cpArray *arr); -void cpArrayDeleteObj(cpArray *arr, void *obj); -cpBool cpArrayContains(cpArray *arr, void *ptr); - -void cpArrayFreeEach(cpArray *arr, void (freeFunc)(void*)); - - -//MARK: cpHashSet - -typedef cpBool (*cpHashSetEqlFunc)(void *ptr, void *elt); -typedef void *(*cpHashSetTransFunc)(void *ptr, void *data); - -cpHashSet *cpHashSetNew(int size, cpHashSetEqlFunc eqlFunc); -void cpHashSetSetDefaultValue(cpHashSet *set, void *default_value); - -void cpHashSetFree(cpHashSet *set); - -int cpHashSetCount(cpHashSet *set); -void *cpHashSetInsert(cpHashSet *set, cpHashValue hash, void *ptr, cpHashSetTransFunc trans, void *data); -void *cpHashSetRemove(cpHashSet *set, cpHashValue hash, void *ptr); -void *cpHashSetFind(cpHashSet *set, cpHashValue hash, void *ptr); - -typedef void (*cpHashSetIteratorFunc)(void *elt, void *data); -void cpHashSetEach(cpHashSet *set, cpHashSetIteratorFunc func, void *data); - -typedef cpBool (*cpHashSetFilterFunc)(void *elt, void *data); -void cpHashSetFilter(cpHashSet *set, cpHashSetFilterFunc func, void *data); - - -//MARK: Bodies - -struct cpBody { - // Integration functions - cpBodyVelocityFunc velocity_func; - cpBodyPositionFunc position_func; - - // mass and it's inverse - cpFloat m; - cpFloat m_inv; - - // moment of inertia and it's inverse - cpFloat i; - cpFloat i_inv; - - // center of gravity - cpVect cog; - - // position, velocity, force - cpVect p; - cpVect v; - cpVect f; - - // Angle, angular velocity, torque (radians) - cpFloat a; - cpFloat w; - cpFloat t; - - cpTransform transform; - - cpDataPointer userData; - - // "pseudo-velocities" used for eliminating overlap. - // Erin Catto has some papers that talk about what these are. - cpVect v_bias; - cpFloat w_bias; - - cpSpace *space; - - cpShape *shapeList; - cpArbiter *arbiterList; - cpConstraint *constraintList; - - struct { - cpBody *root; - cpBody *next; - cpFloat idleTime; - } sleeping; -}; - -void cpBodyAddShape(cpBody *body, cpShape *shape); -void cpBodyRemoveShape(cpBody *body, cpShape *shape); - -//void cpBodyAccumulateMassForShape(cpBody *body, cpShape *shape); -void cpBodyAccumulateMassFromShapes(cpBody *body); - -void cpBodyRemoveConstraint(cpBody *body, cpConstraint *constraint); - - -//MARK: Spatial Index Functions - -cpSpatialIndex *cpSpatialIndexInit(cpSpatialIndex *index, cpSpatialIndexClass *klass, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); - - -//MARK: Arbiters - -enum cpArbiterState { - // Arbiter is active and its the first collision. - CP_ARBITER_STATE_FIRST_COLLISION, - // Arbiter is active and its not the first collision. - CP_ARBITER_STATE_NORMAL, - // Collision has been explicitly ignored. - // Either by returning false from a begin collision handler or calling cpArbiterIgnore(). - CP_ARBITER_STATE_IGNORE, - // Collison is no longer active. A space will cache an arbiter for up to cpSpace.collisionPersistence more steps. - CP_ARBITER_STATE_CACHED, - // Collison arbiter is invalid because one of the shapes was removed. - CP_ARBITER_STATE_INVALIDATED, -}; - -struct cpArbiterThread { - struct cpArbiter *next, *prev; -}; - -struct cpContact { - cpVect r1, r2; - - cpFloat nMass, tMass; - cpFloat bounce; // TODO: look for an alternate bounce solution. - - cpFloat jnAcc, jtAcc, jBias; - cpFloat bias; - - cpHashValue hash; -}; - -struct cpCollisionInfo { - const cpShape *a, *b; - cpCollisionID id; - - cpVect n; - - int count; - // TODO Should this be a unique struct type? - struct cpContact *arr; -}; - -struct cpArbiter { - cpFloat e; - cpFloat u; - cpVect surface_vr; - - cpDataPointer data; - - const cpShape *a, *b; - cpBody *body_a, *body_b; - struct cpArbiterThread thread_a, thread_b; - - int count; - struct cpContact *contacts; - cpVect n; - - // Regular, wildcard A and wildcard B collision handlers. - cpCollisionHandler *handler, *handlerA, *handlerB; - cpBool swapped; - - cpTimestamp stamp; - enum cpArbiterState state; -}; - -cpArbiter* cpArbiterInit(cpArbiter *arb, cpShape *a, cpShape *b); - -static inline struct cpArbiterThread * -cpArbiterThreadForBody(cpArbiter *arb, cpBody *body) -{ - return (arb->body_a == body ? &arb->thread_a : &arb->thread_b); -} - -void cpArbiterUnthread(cpArbiter *arb); - -void cpArbiterUpdate(cpArbiter *arb, struct cpCollisionInfo *info, cpSpace *space); -void cpArbiterPreStep(cpArbiter *arb, cpFloat dt, cpFloat bias, cpFloat slop); -void cpArbiterApplyCachedImpulse(cpArbiter *arb, cpFloat dt_coef); -void cpArbiterApplyImpulse(cpArbiter *arb); - - -//MARK: Shapes/Collisions - -struct cpShapeMassInfo { - cpFloat m; - cpFloat i; - cpVect cog; - cpFloat area; -}; - -typedef enum cpShapeType{ - CP_CIRCLE_SHAPE, - CP_SEGMENT_SHAPE, - CP_POLY_SHAPE, - CP_NUM_SHAPES -} cpShapeType; - -typedef cpBB (*cpShapeCacheDataImpl)(cpShape *shape, cpTransform transform); -typedef void (*cpShapeDestroyImpl)(cpShape *shape); -typedef void (*cpShapePointQueryImpl)(const cpShape *shape, cpVect p, cpPointQueryInfo *info); -typedef void (*cpShapeSegmentQueryImpl)(const cpShape *shape, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo *info); - -typedef struct cpShapeClass cpShapeClass; - -struct cpShapeClass { - cpShapeType type; - - cpShapeCacheDataImpl cacheData; - cpShapeDestroyImpl destroy; - cpShapePointQueryImpl pointQuery; - cpShapeSegmentQueryImpl segmentQuery; -}; - -struct cpShape { - const cpShapeClass *klass; - - cpSpace *space; - cpBody *body; - struct cpShapeMassInfo massInfo; - cpBB bb; - - cpBool sensor; - - cpFloat e; - cpFloat u; - cpVect surfaceV; - - cpDataPointer userData; - - cpCollisionType type; - cpShapeFilter filter; - - cpShape *next; - cpShape *prev; - - cpHashValue hashid; -}; - -struct cpCircleShape { - cpShape shape; - - cpVect c, tc; - cpFloat r; -}; - -struct cpSegmentShape { - cpShape shape; - - cpVect a, b, n; - cpVect ta, tb, tn; - cpFloat r; - - cpVect a_tangent, b_tangent; -}; - -struct cpSplittingPlane { - cpVect v0, n; -}; - -#define CP_POLY_SHAPE_INLINE_ALLOC 6 - -struct cpPolyShape { - cpShape shape; - - cpFloat r; - - int count; - // The untransformed planes are appended at the end of the transformed planes. - struct cpSplittingPlane *planes; - - // Allocate a small number of splitting planes internally for simple poly. - struct cpSplittingPlane _planes[2*CP_POLY_SHAPE_INLINE_ALLOC]; -}; - -cpShape *cpShapeInit(cpShape *shape, const cpShapeClass *klass, cpBody *body, struct cpShapeMassInfo massInfo); - -static inline cpBool -cpShapeActive(cpShape *shape) -{ - // checks if the shape is added to a shape list. - // TODO could this just check the space now? - return (shape->prev || (shape->body && shape->body->shapeList == shape)); -} - -// Note: This function returns contact points with r1/r2 in absolute coordinates, not body relative. -struct cpCollisionInfo cpCollide(const cpShape *a, const cpShape *b, cpCollisionID id, struct cpContact *contacts); - -static inline void -CircleSegmentQuery(cpShape *shape, cpVect center, cpFloat r1, cpVect a, cpVect b, cpFloat r2, cpSegmentQueryInfo *info) -{ - cpVect da = cpvsub(a, center); - cpVect db = cpvsub(b, center); - cpFloat rsum = r1 + r2; - - cpFloat qa = cpvdot(da, da) - 2.0f*cpvdot(da, db) + cpvdot(db, db); - cpFloat qb = cpvdot(da, db) - cpvdot(da, da); - cpFloat det = qb*qb - qa*(cpvdot(da, da) - rsum*rsum); - - if(det >= 0.0f){ - cpFloat t = (-qb - cpfsqrt(det))/(qa); - if(0.0f<= t && t <= 1.0f){ - cpVect n = cpvnormalize(cpvlerp(da, db, t)); - - info->shape = shape; - info->point = cpvsub(cpvlerp(a, b, t), cpvmult(n, r2)); - info->normal = n; - info->alpha = t; - } - } -} - -static inline cpBool -cpShapeFilterReject(cpShapeFilter a, cpShapeFilter b) -{ - // Reject the collision if: - return ( - // They are in the same non-zero group. - (a.group != 0 && a.group == b.group) || - // One of the category/mask combinations fails. - (a.categories & b.mask) == 0 || - (b.categories & a.mask) == 0 - ); -} - -void cpLoopIndexes(const cpVect *verts, int count, int *start, int *end); - - -//MARK: Constraints -// TODO naming conventions here - -typedef void (*cpConstraintPreStepImpl)(cpConstraint *constraint, cpFloat dt); -typedef void (*cpConstraintApplyCachedImpulseImpl)(cpConstraint *constraint, cpFloat dt_coef); -typedef void (*cpConstraintApplyImpulseImpl)(cpConstraint *constraint, cpFloat dt); -typedef cpFloat (*cpConstraintGetImpulseImpl)(cpConstraint *constraint); - -typedef struct cpConstraintClass { - cpConstraintPreStepImpl preStep; - cpConstraintApplyCachedImpulseImpl applyCachedImpulse; - cpConstraintApplyImpulseImpl applyImpulse; - cpConstraintGetImpulseImpl getImpulse; -} cpConstraintClass; - -struct cpConstraint { - const cpConstraintClass *klass; - - cpSpace *space; - - cpBody *a, *b; - cpConstraint *next_a, *next_b; - - cpFloat maxForce; - cpFloat errorBias; - cpFloat maxBias; - - cpBool collideBodies; - - cpConstraintPreSolveFunc preSolve; - cpConstraintPostSolveFunc postSolve; - - cpDataPointer userData; -}; - -struct cpPinJoint { - cpConstraint constraint; - cpVect anchorA, anchorB; - cpFloat dist; - - cpVect r1, r2; - cpVect n; - cpFloat nMass; - - cpFloat jnAcc; - cpFloat bias; -}; - -struct cpSlideJoint { - cpConstraint constraint; - cpVect anchorA, anchorB; - cpFloat min, max; - - cpVect r1, r2; - cpVect n; - cpFloat nMass; - - cpFloat jnAcc; - cpFloat bias; -}; - -struct cpPivotJoint { - cpConstraint constraint; - cpVect anchorA, anchorB; - - cpVect r1, r2; - cpMat2x2 k; - - cpVect jAcc; - cpVect bias; -}; - -struct cpGrooveJoint { - cpConstraint constraint; - cpVect grv_n, grv_a, grv_b; - cpVect anchorB; - - cpVect grv_tn; - cpFloat clamp; - cpVect r1, r2; - cpMat2x2 k; - - cpVect jAcc; - cpVect bias; -}; - -struct cpDampedSpring { - cpConstraint constraint; - cpVect anchorA, anchorB; - cpFloat restLength; - cpFloat stiffness; - cpFloat damping; - cpDampedSpringForceFunc springForceFunc; - - cpFloat target_vrn; - cpFloat v_coef; - - cpVect r1, r2; - cpFloat nMass; - cpVect n; - - cpFloat jAcc; -}; - -struct cpDampedRotarySpring { - cpConstraint constraint; - cpFloat restAngle; - cpFloat stiffness; - cpFloat damping; - cpDampedRotarySpringTorqueFunc springTorqueFunc; - - cpFloat target_wrn; - cpFloat w_coef; - - cpFloat iSum; - cpFloat jAcc; -}; - -struct cpRotaryLimitJoint { - cpConstraint constraint; - cpFloat min, max; - - cpFloat iSum; - - cpFloat bias; - cpFloat jAcc; -}; - -struct cpRatchetJoint { - cpConstraint constraint; - cpFloat angle, phase, ratchet; - - cpFloat iSum; - - cpFloat bias; - cpFloat jAcc; -}; - -struct cpGearJoint { - cpConstraint constraint; - cpFloat phase, ratio; - cpFloat ratio_inv; - - cpFloat iSum; - - cpFloat bias; - cpFloat jAcc; -}; - -struct cpSimpleMotor { - cpConstraint constraint; - cpFloat rate; - - cpFloat iSum; - - cpFloat jAcc; -}; - -void cpConstraintInit(cpConstraint *constraint, const struct cpConstraintClass *klass, cpBody *a, cpBody *b); - -static inline void -cpConstraintActivateBodies(cpConstraint *constraint) -{ - cpBody *a = constraint->a; cpBodyActivate(a); - cpBody *b = constraint->b; cpBodyActivate(b); -} - -static inline cpVect -relative_velocity(cpBody *a, cpBody *b, cpVect r1, cpVect r2){ - cpVect v1_sum = cpvadd(a->CP_PRIVATE(v), cpvmult(cpvperp(r1), a->CP_PRIVATE(w))); - cpVect v2_sum = cpvadd(b->CP_PRIVATE(v), cpvmult(cpvperp(r2), b->CP_PRIVATE(w))); - - return cpvsub(v2_sum, v1_sum); -} - -static inline cpFloat -normal_relative_velocity(cpBody *a, cpBody *b, cpVect r1, cpVect r2, cpVect n){ - return cpvdot(relative_velocity(a, b, r1, r2), n); -} - -static inline void -apply_impulse(cpBody *body, cpVect j, cpVect r){ - body->CP_PRIVATE(v) = cpvadd(body->CP_PRIVATE(v), cpvmult(j, body->CP_PRIVATE(m_inv))); - body->CP_PRIVATE(w) += body->CP_PRIVATE(i_inv)*cpvcross(r, j); -} - -static inline void -apply_impulses(cpBody *a , cpBody *b, cpVect r1, cpVect r2, cpVect j) -{ - apply_impulse(a, cpvneg(j), r1); - apply_impulse(b, j, r2); -} - -static inline void -apply_bias_impulse(cpBody *body, cpVect j, cpVect r) -{ - body->CP_PRIVATE(v_bias) = cpvadd(body->CP_PRIVATE(v_bias), cpvmult(j, body->CP_PRIVATE(m_inv))); - body->CP_PRIVATE(w_bias) += body->CP_PRIVATE(i_inv)*cpvcross(r, j); -} - -static inline void -apply_bias_impulses(cpBody *a , cpBody *b, cpVect r1, cpVect r2, cpVect j) -{ - apply_bias_impulse(a, cpvneg(j), r1); - apply_bias_impulse(b, j, r2); -} - -static inline cpFloat -k_scalar_body(cpBody *body, cpVect r, cpVect n) -{ - cpFloat rcn = cpvcross(r, n); - return body->CP_PRIVATE(m_inv) + body->CP_PRIVATE(i_inv)*rcn*rcn; -} - -static inline cpFloat -k_scalar(cpBody *a, cpBody *b, cpVect r1, cpVect r2, cpVect n) -{ - cpFloat value = k_scalar_body(a, r1, n) + k_scalar_body(b, r2, n); - cpAssertSoft(value != 0.0, "Unsolvable collision or constraint."); - - return value; -} - -static inline cpMat2x2 -k_tensor(cpBody *a, cpBody *b, cpVect r1, cpVect r2) -{ - cpFloat m_sum = a->CP_PRIVATE(m_inv) + b->CP_PRIVATE(m_inv); - - // start with Identity*m_sum - cpFloat k11 = m_sum, k12 = 0.0f; - cpFloat k21 = 0.0f, k22 = m_sum; - - // add the influence from r1 - cpFloat a_i_inv = a->CP_PRIVATE(i_inv); - cpFloat r1xsq = r1.x * r1.x * a_i_inv; - cpFloat r1ysq = r1.y * r1.y * a_i_inv; - cpFloat r1nxy = -r1.x * r1.y * a_i_inv; - k11 += r1ysq; k12 += r1nxy; - k21 += r1nxy; k22 += r1xsq; - - // add the influnce from r2 - cpFloat b_i_inv = b->CP_PRIVATE(i_inv); - cpFloat r2xsq = r2.x * r2.x * b_i_inv; - cpFloat r2ysq = r2.y * r2.y * b_i_inv; - cpFloat r2nxy = -r2.x * r2.y * b_i_inv; - k11 += r2ysq; k12 += r2nxy; - k21 += r2nxy; k22 += r2xsq; - - // invert - cpFloat det = k11*k22 - k12*k21; - cpAssertSoft(det != 0.0, "Unsolvable constraint."); - - cpFloat det_inv = 1.0f/det; - return cpMat2x2New( - k22*det_inv, -k12*det_inv, - -k21*det_inv, k11*det_inv - ); -} - -static inline cpFloat -bias_coef(cpFloat errorBias, cpFloat dt) -{ - return 1.0f - cpfpow(errorBias, dt); -} - - -//MARK: Spaces - -typedef struct cpContactBufferHeader cpContactBufferHeader; -typedef void (*cpSpaceArbiterApplyImpulseFunc)(cpArbiter *arb); - -struct cpSpace { - int iterations; - - cpVect gravity; - cpFloat damping; - - cpFloat idleSpeedThreshold; - cpFloat sleepTimeThreshold; - - cpFloat collisionSlop; - cpFloat collisionBias; - cpTimestamp collisionPersistence; - - cpDataPointer userData; - - cpTimestamp stamp; - cpFloat curr_dt; - - cpArray *dynamicBodies; - cpArray *staticBodies; - cpArray *rousedBodies; - cpArray *sleepingComponents; - - cpHashValue shapeIDCounter; - cpSpatialIndex *staticShapes; - cpSpatialIndex *dynamicShapes; - - cpArray *constraints; - - cpArray *arbiters; - cpContactBufferHeader *contactBuffersHead; - cpHashSet *cachedArbiters; - cpArray *pooledArbiters; - - cpArray *allocatedBuffers; - unsigned int locked; - - cpBool usesWildcards; - cpHashSet *collisionHandlers; - cpCollisionHandler defaultHandler; - - cpBool skipPostStep; - cpArray *postStepCallbacks; - - cpBody *staticBody; - cpBody _staticBody; -}; - -#define cpAssertSpaceUnlocked(space) \ - cpAssertHard(!space->locked, \ - "This operation cannot be done safely during a call to cpSpaceStep() or during a query. " \ - "Put these calls into a post-step callback." \ - ); - -void cpSpaceSetStaticBody(cpSpace *space, cpBody *body); - -extern cpCollisionHandler cpCollisionHandlerDoNothing; - -void cpSpaceProcessComponents(cpSpace *space, cpFloat dt); - -void cpSpacePushFreshContactBuffer(cpSpace *space); -struct cpContact *cpContactBufferGetArray(cpSpace *space); -void cpSpacePushContacts(cpSpace *space, int count); - -typedef struct cpPostStepCallback { - cpPostStepFunc func; - void *key; - void *data; -} cpPostStepCallback; - -cpPostStepCallback *cpSpaceGetPostStepCallback(cpSpace *space, void *key); - -cpBool cpSpaceArbiterSetFilter(cpArbiter *arb, cpSpace *space); -void cpSpaceFilterArbiters(cpSpace *space, cpBody *body, cpShape *filter); - -void cpSpaceActivateBody(cpSpace *space, cpBody *body); -void cpSpaceLock(cpSpace *space); -void cpSpaceUnlock(cpSpace *space, cpBool runPostStep); - -static inline void -cpSpaceUncacheArbiter(cpSpace *space, cpArbiter *arb) -{ - const cpShape *a = arb->a, *b = arb->b; - const cpShape *shape_pair[] = {a, b}; - cpHashValue arbHashID = CP_HASH_PAIR((cpHashValue)a, (cpHashValue)b); - cpHashSetRemove(space->cachedArbiters, arbHashID, shape_pair); - cpArrayDeleteObj(space->arbiters, arb); -} - -static inline cpArray * -cpSpaceArrayForBodyType(cpSpace *space, cpBodyType type) -{ - return (type == CP_BODY_TYPE_STATIC ? space->staticBodies : space->dynamicBodies); -} - -void cpShapeUpdateFunc(cpShape *shape, void *unused); -cpCollisionID cpSpaceCollideShapes(cpShape *a, cpShape *b, cpCollisionID id, cpSpace *space); - - -//MARK: Foreach loops - -static inline cpConstraint * -cpConstraintNext(cpConstraint *node, cpBody *body) -{ - return (node->a == body ? node->next_a : node->next_b); -} - -#define CP_BODY_FOREACH_CONSTRAINT(bdy, var)\ - for(cpConstraint *var = bdy->constraintList; var; var = cpConstraintNext(var, bdy)) - -static inline cpArbiter * -cpArbiterNext(cpArbiter *node, cpBody *body) -{ - return (node->body_a == body ? node->thread_a.next : node->thread_b.next); -} - -#define CP_BODY_FOREACH_ARBITER(bdy, var)\ - for(cpArbiter *var = bdy->arbiterList; var; var = cpArbiterNext(var, bdy)) - -#define CP_BODY_FOREACH_SHAPE(body, var)\ - for(cpShape *var = body->shapeList; var; var = var->next) - -#define CP_BODY_FOREACH_COMPONENT(root, var)\ - for(cpBody *var = root; var; var = var->sleeping.next) - -#endif diff --git a/android/armeabi/include/chipmunk/chipmunk_types.h b/android/armeabi/include/chipmunk/chipmunk_types.h deleted file mode 100644 index 7aee0c79..00000000 --- a/android/armeabi/include/chipmunk/chipmunk_types.h +++ /dev/null @@ -1,242 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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 CHIPMUNK_TYPES_H -#define CHIPMUNK_TYPES_H - -#include -#include -#include - -#ifndef CP_USE_DOUBLES - // Use doubles by default for higher precision. - #define CP_USE_DOUBLES 0 -#endif - -/// @defgroup basicTypes Basic Types -/// Most of these types can be configured at compile time. -/// @{ - -#if CP_USE_DOUBLES -/// Chipmunk's floating point type. -/// Can be reconfigured at compile time. - typedef double cpFloat; - #define cpfsqrt sqrt - #define cpfsin sin - #define cpfcos cos - #define cpfacos acos - #define cpfatan2 atan2 - #define cpfmod fmod - #define cpfexp exp - #define cpfpow pow - #define cpffloor floor - #define cpfceil ceil - #define CPFLOAT_MIN DBL_MIN -#else - typedef float cpFloat; - #define cpfsqrt sqrtf - #define cpfsin sinf - #define cpfcos cosf - #define cpfacos acosf - #define cpfatan2 atan2f - #define cpfmod fmodf - #define cpfexp expf - #define cpfpow powf - #define cpffloor floorf - #define cpfceil ceilf - #define CPFLOAT_MIN FLT_MIN -#endif - -#ifndef INFINITY - #ifdef _MSC_VER - union MSVC_EVIL_FLOAT_HACK - { - unsigned __int8 Bytes[4]; - float Value; - }; - static union MSVC_EVIL_FLOAT_HACK INFINITY_HACK = {{0x00, 0x00, 0x80, 0x7F}}; - #define INFINITY (INFINITY_HACK.Value) - #endif - - #ifdef __GNUC__ - #define INFINITY (__builtin_inf()) - #endif - - #ifndef INFINITY - #define INFINITY (1e1000) - #endif -#endif - - -#define CP_PI ((cpFloat)3.14159265358979323846264338327950288) - - -/// Return the max of two cpFloats. -static inline cpFloat cpfmax(cpFloat a, cpFloat b) -{ - return (a > b) ? a : b; -} - -/// Return the min of two cpFloats. -static inline cpFloat cpfmin(cpFloat a, cpFloat b) -{ - return (a < b) ? a : b; -} - -/// Return the absolute value of a cpFloat. -static inline cpFloat cpfabs(cpFloat f) -{ - return (f < 0) ? -f : f; -} - -/// Clamp @c f to be between @c min and @c max. -static inline cpFloat cpfclamp(cpFloat f, cpFloat min, cpFloat max) -{ - return cpfmin(cpfmax(f, min), max); -} - -/// Clamp @c f to be between 0 and 1. -static inline cpFloat cpfclamp01(cpFloat f) -{ - return cpfmax(0.0f, cpfmin(f, 1.0f)); -} - - - -/// Linearly interpolate (or extrapolate) between @c f1 and @c f2 by @c t percent. -static inline cpFloat cpflerp(cpFloat f1, cpFloat f2, cpFloat t) -{ - return f1*(1.0f - t) + f2*t; -} - -/// Linearly interpolate from @c f1 to @c f2 by no more than @c d. -static inline cpFloat cpflerpconst(cpFloat f1, cpFloat f2, cpFloat d) -{ - return f1 + cpfclamp(f2 - f1, -d, d); -} - -/// Hash value type. -#ifdef CP_HASH_VALUE_TYPE - typedef CP_HASH_VALUE_TYPE cpHashValue; -#else - typedef uintptr_t cpHashValue; -#endif - -/// Type used internally to cache colliding object info for cpCollideShapes(). -/// Should be at least 32 bits. -typedef uint32_t cpCollisionID; - -// Oh C, how we love to define our own boolean types to get compiler compatibility -/// Chipmunk's boolean type. -#ifdef CP_BOOL_TYPE - typedef CP_BOOL_TYPE cpBool; -#else - typedef unsigned char cpBool; -#endif - -#ifndef cpTrue -/// true value. - #define cpTrue 1 -#endif - -#ifndef cpFalse -/// false value. - #define cpFalse 0 -#endif - -#ifdef CP_DATA_POINTER_TYPE - typedef CP_DATA_POINTER_TYPE cpDataPointer; -#else -/// Type used for user data pointers. - typedef void * cpDataPointer; -#endif - -#ifdef CP_COLLISION_TYPE_TYPE - typedef CP_COLLISION_TYPE_TYPE cpCollisionType; -#else -/// Type used for cpSpace.collision_type. - typedef uintptr_t cpCollisionType; -#endif - -#ifdef CP_GROUP_TYPE - typedef CP_GROUP_TYPE cpGroup; -#else -/// Type used for cpShape.group. - typedef uintptr_t cpGroup; -#endif - -#ifdef CP_BITMASK_TYPE - typedef CP_BITMASK_TYPE cpBitmask; -#else -/// Type used for cpShapeFilter category and mask. - typedef unsigned int cpBitmask; -#endif - -#ifdef CP_TIMESTAMP_TYPE - typedef CP_TIMESTAMP_TYPE cpTimestamp; -#else -/// Type used for various timestamps in Chipmunk. - typedef unsigned int cpTimestamp; -#endif - -#ifndef CP_NO_GROUP -/// Value for cpShape.group signifying that a shape is in no group. - #define CP_NO_GROUP ((cpGroup)0) -#endif - -#ifndef CP_ALL_CATEGORIES -/// Value for cpShape.layers signifying that a shape is in every layer. - #define CP_ALL_CATEGORIES (~(cpBitmask)0) -#endif - -#ifndef CP_WILDCARD_COLLISION_TYPE -/// cpCollisionType value internally reserved for hashing wildcard handlers. - #define CP_WILDCARD_COLLISION_TYPE (~(cpCollisionType)0) -#endif - -/// @} - -// CGPoints are structurally the same, and allow -// easy interoperability with other Cocoa libraries -#if CP_USE_CGTYPES - typedef CGPoint cpVect; -#else -/// Chipmunk's 2D vector type. -/// @addtogroup cpVect - typedef struct cpVect{cpFloat x,y;} cpVect; -#endif - -#if CP_USE_CGTYPES - typedef CGAffineTransform cpTransform; -#else - /// Column major affine transform. - typedef struct cpTransform { - cpFloat a, b, c, d, tx, ty; - } cpTransform; -#endif - -// NUKE -typedef struct cpMat2x2 { - // Row major [[a, b][c d]] - cpFloat a, b, c, d; -} cpMat2x2; - -#endif diff --git a/android/armeabi/include/chipmunk/chipmunk_unsafe.h b/android/armeabi/include/chipmunk/chipmunk_unsafe.h deleted file mode 100644 index 990bd012..00000000 --- a/android/armeabi/include/chipmunk/chipmunk_unsafe.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/* This header defines a number of "unsafe" operations on Chipmunk objects. - * In this case "unsafe" is referring to operations which may reduce the - * physical accuracy or numerical stability of the simulation, but will not - * cause crashes. - * - * The prime example is mutating collision shapes. Chipmunk does not support - * this directly. Mutating shapes using this API will caused objects in contact - * to be pushed apart using Chipmunk's overlap solver, but not using real - * persistent velocities. Probably not what you meant, but perhaps close enough. - */ - -/// @defgroup unsafe Chipmunk Unsafe Shape Operations -/// These functions are used for mutating collision shapes. -/// Chipmunk does not have any way to get velocity information on changing shapes, -/// so the results will be unrealistic. You must explicity include the chipmunk_unsafe.h header to use them. -/// @{ - -#ifndef CHIPMUNK_UNSAFE_H -#define CHIPMUNK_UNSAFE_H - -#ifdef __cplusplus -extern "C" { -#endif - -/// Set the radius of a circle shape. -CP_EXPORT void cpCircleShapeSetRadius(cpShape *shape, cpFloat radius); -/// Set the offset of a circle shape. -CP_EXPORT void cpCircleShapeSetOffset(cpShape *shape, cpVect offset); - -/// Set the endpoints of a segment shape. -CP_EXPORT void cpSegmentShapeSetEndpoints(cpShape *shape, cpVect a, cpVect b); -/// Set the radius of a segment shape. -CP_EXPORT void cpSegmentShapeSetRadius(cpShape *shape, cpFloat radius); - -/// Set the vertexes of a poly shape. -CP_EXPORT void cpPolyShapeSetVerts(cpShape *shape, int count, cpVect *verts, cpTransform transform); -CP_EXPORT void cpPolyShapeSetVertsRaw(cpShape *shape, int count, cpVect *verts); -/// Set the radius of a poly shape. -CP_EXPORT void cpPolyShapeSetRadius(cpShape *shape, cpFloat radius); - -#ifdef __cplusplus -} -#endif -#endif -/// @} diff --git a/android/armeabi/include/chipmunk/cpArbiter.h b/android/armeabi/include/chipmunk/cpArbiter.h deleted file mode 100644 index 1dc130af..00000000 --- a/android/armeabi/include/chipmunk/cpArbiter.h +++ /dev/null @@ -1,145 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpArbiter cpArbiter -/// The cpArbiter struct tracks pairs of colliding shapes. -/// They are also used in conjuction with collision handler callbacks -/// allowing you to retrieve information on the collision or change it. -/// A unique arbiter value is used for each pair of colliding objects. It persists until the shapes separate. -/// @{ - -#define CP_MAX_CONTACTS_PER_ARBITER 2 - -/// Get the restitution (elasticity) that will be applied to the pair of colliding objects. -CP_EXPORT cpFloat cpArbiterGetRestitution(const cpArbiter *arb); -/// Override the restitution (elasticity) that will be applied to the pair of colliding objects. -CP_EXPORT void cpArbiterSetRestitution(cpArbiter *arb, cpFloat restitution); -/// Get the friction coefficient that will be applied to the pair of colliding objects. -CP_EXPORT cpFloat cpArbiterGetFriction(const cpArbiter *arb); -/// Override the friction coefficient that will be applied to the pair of colliding objects. -CP_EXPORT void cpArbiterSetFriction(cpArbiter *arb, cpFloat friction); - -// Get the relative surface velocity of the two shapes in contact. -CP_EXPORT cpVect cpArbiterGetSurfaceVelocity(cpArbiter *arb); - -// Override the relative surface velocity of the two shapes in contact. -// By default this is calculated to be the difference of the two surface velocities clamped to the tangent plane. -CP_EXPORT void cpArbiterSetSurfaceVelocity(cpArbiter *arb, cpVect vr); - -/// Get the user data pointer associated with this pair of colliding objects. -CP_EXPORT cpDataPointer cpArbiterGetUserData(const cpArbiter *arb); -/// Set a user data point associated with this pair of colliding objects. -/// If you need to perform any cleanup for this pointer, you must do it yourself, in the separate callback for instance. -CP_EXPORT void cpArbiterSetUserData(cpArbiter *arb, cpDataPointer userData); - -/// Calculate the total impulse including the friction that was applied by this arbiter. -/// This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback. -CP_EXPORT cpVect cpArbiterTotalImpulse(const cpArbiter *arb); -/// Calculate the amount of energy lost in a collision including static, but not dynamic friction. -/// This function should only be called from a post-solve, post-step or cpBodyEachArbiter callback. -CP_EXPORT cpFloat cpArbiterTotalKE(const cpArbiter *arb); - -/// Mark a collision pair to be ignored until the two objects separate. -/// Pre-solve and post-solve callbacks will not be called, but the separate callback will be called. -CP_EXPORT cpBool cpArbiterIgnore(cpArbiter *arb); - -/// Return the colliding shapes involved for this arbiter. -/// The order of their cpSpace.collision_type values will match -/// the order set when the collision handler was registered. -CP_EXPORT void cpArbiterGetShapes(const cpArbiter *arb, cpShape **a, cpShape **b); - -/// A macro shortcut for defining and retrieving the shapes from an arbiter. -#define CP_ARBITER_GET_SHAPES(__arb__, __a__, __b__) cpShape *__a__, *__b__; cpArbiterGetShapes(__arb__, &__a__, &__b__); - -/// Return the colliding bodies involved for this arbiter. -/// The order of the cpSpace.collision_type the bodies are associated with values will match -/// the order set when the collision handler was registered. -CP_EXPORT void cpArbiterGetBodies(const cpArbiter *arb, cpBody **a, cpBody **b); - -/// A macro shortcut for defining and retrieving the bodies from an arbiter. -#define CP_ARBITER_GET_BODIES(__arb__, __a__, __b__) cpBody *__a__, *__b__; cpArbiterGetBodies(__arb__, &__a__, &__b__); - -/// A struct that wraps up the important collision data for an arbiter. -struct cpContactPointSet { - /// The number of contact points in the set. - int count; - - /// The normal of the collision. - cpVect normal; - - /// The array of contact points. - struct { - /// The position of the contact on the surface of each shape. - cpVect pointA, pointB; - /// Penetration distance of the two shapes. Overlapping means it will be negative. - /// This value is calculated as cpvdot(cpvsub(point2, point1), normal) and is ignored by cpArbiterSetContactPointSet(). - cpFloat distance; - } points[CP_MAX_CONTACTS_PER_ARBITER]; -}; - -/// Return a contact set from an arbiter. -CP_EXPORT cpContactPointSet cpArbiterGetContactPointSet(const cpArbiter *arb); - -/// Replace the contact point set for an arbiter. -/// This can be a very powerful feature, but use it with caution! -CP_EXPORT void cpArbiterSetContactPointSet(cpArbiter *arb, cpContactPointSet *set); - -/// Returns true if this is the first step a pair of objects started colliding. -CP_EXPORT cpBool cpArbiterIsFirstContact(const cpArbiter *arb); -/// Returns true if the separate callback is due to a shape being removed from the space. -CP_EXPORT cpBool cpArbiterIsRemoval(const cpArbiter *arb); - -/// Get the number of contact points for this arbiter. -CP_EXPORT int cpArbiterGetCount(const cpArbiter *arb); -/// Get the normal of the collision. -CP_EXPORT cpVect cpArbiterGetNormal(const cpArbiter *arb); -/// Get the position of the @c ith contact point on the surface of the first shape. -CP_EXPORT cpVect cpArbiterGetPointA(const cpArbiter *arb, int i); -/// Get the position of the @c ith contact point on the surface of the second shape. -CP_EXPORT cpVect cpArbiterGetPointB(const cpArbiter *arb, int i); -/// Get the depth of the @c ith contact point. -CP_EXPORT cpFloat cpArbiterGetDepth(const cpArbiter *arb, int i); - -/// If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly. -/// You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own. -CP_EXPORT cpBool cpArbiterCallWildcardBeginA(cpArbiter *arb, cpSpace *space); -/// If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly. -/// You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own. -CP_EXPORT cpBool cpArbiterCallWildcardBeginB(cpArbiter *arb, cpSpace *space); - -/// If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly. -/// You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own. -CP_EXPORT cpBool cpArbiterCallWildcardPreSolveA(cpArbiter *arb, cpSpace *space); -/// If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly. -/// You must decide how to handle the wildcard's return value since it may disagree with the other wildcard handler's return value or your own. -CP_EXPORT cpBool cpArbiterCallWildcardPreSolveB(cpArbiter *arb, cpSpace *space); - -/// If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly. -CP_EXPORT void cpArbiterCallWildcardPostSolveA(cpArbiter *arb, cpSpace *space); -/// If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly. -CP_EXPORT void cpArbiterCallWildcardPostSolveB(cpArbiter *arb, cpSpace *space); - -/// If you want a custom callback to invoke the wildcard callback for the first collision type, you must call this function explicitly. -CP_EXPORT void cpArbiterCallWildcardSeparateA(cpArbiter *arb, cpSpace *space); -/// If you want a custom callback to invoke the wildcard callback for the second collision type, you must call this function explicitly. -CP_EXPORT void cpArbiterCallWildcardSeparateB(cpArbiter *arb, cpSpace *space); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpBB.h b/android/armeabi/include/chipmunk/cpBB.h deleted file mode 100644 index 40200600..00000000 --- a/android/armeabi/include/chipmunk/cpBB.h +++ /dev/null @@ -1,187 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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 CHIPMUNK_BB_H -#define CHIPMUNK_BB_H - -#include "chipmunk_types.h" -#include "cpVect.h" - -/// @defgroup cpBBB cpBB -/// Chipmunk's axis-aligned 2D bounding box type along with a few handy routines. -/// @{ - -/// Chipmunk's axis-aligned 2D bounding box type. (left, bottom, right, top) -typedef struct cpBB{ - cpFloat l, b, r ,t; -} cpBB; - -/// Convenience constructor for cpBB structs. -static inline cpBB cpBBNew(const cpFloat l, const cpFloat b, const cpFloat r, const cpFloat t) -{ - cpBB bb = {l, b, r, t}; - return bb; -} - -/// Constructs a cpBB centered on a point with the given extents (half sizes). -static inline cpBB -cpBBNewForExtents(const cpVect c, const cpFloat hw, const cpFloat hh) -{ - return cpBBNew(c.x - hw, c.y - hh, c.x + hw, c.y + hh); -} - -/// Constructs a cpBB for a circle with the given position and radius. -static inline cpBB cpBBNewForCircle(const cpVect p, const cpFloat r) -{ - return cpBBNewForExtents(p, r, r); -} - -/// Returns true if @c a and @c b intersect. -static inline cpBool cpBBIntersects(const cpBB a, const cpBB b) -{ - return (a.l <= b.r && b.l <= a.r && a.b <= b.t && b.b <= a.t); -} - -/// Returns true if @c other lies completely within @c bb. -static inline cpBool cpBBContainsBB(const cpBB bb, const cpBB other) -{ - return (bb.l <= other.l && bb.r >= other.r && bb.b <= other.b && bb.t >= other.t); -} - -/// Returns true if @c bb contains @c v. -static inline cpBool cpBBContainsVect(const cpBB bb, const cpVect v) -{ - return (bb.l <= v.x && bb.r >= v.x && bb.b <= v.y && bb.t >= v.y); -} - -/// Returns a bounding box that holds both bounding boxes. -static inline cpBB cpBBMerge(const cpBB a, const cpBB b){ - return cpBBNew( - cpfmin(a.l, b.l), - cpfmin(a.b, b.b), - cpfmax(a.r, b.r), - cpfmax(a.t, b.t) - ); -} - -/// Returns a bounding box that holds both @c bb and @c v. -static inline cpBB cpBBExpand(const cpBB bb, const cpVect v){ - return cpBBNew( - cpfmin(bb.l, v.x), - cpfmin(bb.b, v.y), - cpfmax(bb.r, v.x), - cpfmax(bb.t, v.y) - ); -} - -/// Returns the center of a bounding box. -static inline cpVect -cpBBCenter(cpBB bb) -{ - return cpvlerp(cpv(bb.l, bb.b), cpv(bb.r, bb.t), 0.5f); -} - -/// Returns the area of the bounding box. -static inline cpFloat cpBBArea(cpBB bb) -{ - return (bb.r - bb.l)*(bb.t - bb.b); -} - -/// Merges @c a and @c b and returns the area of the merged bounding box. -static inline cpFloat cpBBMergedArea(cpBB a, cpBB b) -{ - return (cpfmax(a.r, b.r) - cpfmin(a.l, b.l))*(cpfmax(a.t, b.t) - cpfmin(a.b, b.b)); -} - -/// Returns the fraction along the segment query the cpBB is hit. Returns INFINITY if it doesn't hit. -static inline cpFloat cpBBSegmentQuery(cpBB bb, cpVect a, cpVect b) -{ - cpFloat idx = 1.0f/(b.x - a.x); -#ifdef _MSC_VER -#pragma warning(disable: 4056) -#endif - cpFloat tx1 = (bb.l == a.x ? -INFINITY : (bb.l - a.x)*idx); - cpFloat tx2 = (bb.r == a.x ? INFINITY : (bb.r - a.x)*idx); - cpFloat txmin = cpfmin(tx1, tx2); - cpFloat txmax = cpfmax(tx1, tx2); - - cpFloat idy = 1.0f/(b.y - a.y); - cpFloat ty1 = (bb.b == a.y ? -INFINITY : (bb.b - a.y)*idy); - cpFloat ty2 = (bb.t == a.y ? INFINITY : (bb.t - a.y)*idy); -#ifdef _MSC_VER -#pragma warning(default: 4056) -#endif - cpFloat tymin = cpfmin(ty1, ty2); - cpFloat tymax = cpfmax(ty1, ty2); - - if(tymin <= txmax && txmin <= tymax){ - cpFloat min = cpfmax(txmin, tymin); - cpFloat max = cpfmin(txmax, tymax); - - if(0.0 <= max && min <= 1.0) return cpfmax(min, 0.0); - } - - return INFINITY; -} - -/// Return true if the bounding box intersects the line segment with ends @c a and @c b. -static inline cpBool cpBBIntersectsSegment(cpBB bb, cpVect a, cpVect b) -{ - return (cpBBSegmentQuery(bb, a, b) != INFINITY); -} - -/// Clamp a vector to a bounding box. -static inline cpVect -cpBBClampVect(const cpBB bb, const cpVect v) -{ - return cpv(cpfclamp(v.x, bb.l, bb.r), cpfclamp(v.y, bb.b, bb.t)); -} - -/// Wrap a vector to a bounding box. -static inline cpVect -cpBBWrapVect(const cpBB bb, const cpVect v) -{ - cpFloat dx = cpfabs(bb.r - bb.l); - cpFloat modx = cpfmod(v.x - bb.l, dx); - cpFloat x = (modx > 0.0f) ? modx : modx + dx; - - cpFloat dy = cpfabs(bb.t - bb.b); - cpFloat mody = cpfmod(v.y - bb.b, dy); - cpFloat y = (mody > 0.0f) ? mody : mody + dy; - - return cpv(x + bb.l, y + bb.b); -} - -/// Returns a bounding box offseted by @c v. -static inline cpBB -cpBBOffset(const cpBB bb, const cpVect v) -{ - return cpBBNew( - bb.l + v.x, - bb.b + v.y, - bb.r + v.x, - bb.t + v.y - ); -} - -///@} - -#endif diff --git a/android/armeabi/include/chipmunk/cpBody.h b/android/armeabi/include/chipmunk/cpBody.h deleted file mode 100644 index 7e6943d1..00000000 --- a/android/armeabi/include/chipmunk/cpBody.h +++ /dev/null @@ -1,189 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpBody cpBody -/// Chipmunk's rigid body type. Rigid bodies hold the physical properties of an object like -/// it's mass, and position and velocity of it's center of gravity. They don't have an shape on their own. -/// They are given a shape by creating collision shapes (cpShape) that point to the body. -/// @{ - -typedef enum cpBodyType { - /// A dynamic body is one that is affected by gravity, forces, and collisions. - /// This is the default body type. - CP_BODY_TYPE_DYNAMIC, - /// A kinematic body is an infinite mass, user controlled body that is not affected by gravity, forces or collisions. - /// Instead the body only moves based on it's velocity. - /// Dynamic bodies collide normally with kinematic bodies, though the kinematic body will be unaffected. - /// Collisions between two kinematic bodies, or a kinematic body and a static body produce collision callbacks, but no collision response. - CP_BODY_TYPE_KINEMATIC, - /// A static body is a body that never (or rarely) moves. If you move a static body, you must call one of the cpSpaceReindex*() functions. - /// Chipmunk uses this information to optimize the collision detection. - /// Static bodies do not produce collision callbacks when colliding with other static bodies. - CP_BODY_TYPE_STATIC, -} cpBodyType; - -/// Rigid body velocity update function type. -typedef void (*cpBodyVelocityFunc)(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt); -/// Rigid body position update function type. -typedef void (*cpBodyPositionFunc)(cpBody *body, cpFloat dt); - -/// Allocate a cpBody. -CP_EXPORT cpBody* cpBodyAlloc(void); -/// Initialize a cpBody. -CP_EXPORT cpBody* cpBodyInit(cpBody *body, cpFloat mass, cpFloat moment); -/// Allocate and initialize a cpBody. -CP_EXPORT cpBody* cpBodyNew(cpFloat mass, cpFloat moment); - -/// Allocate and initialize a cpBody, and set it as a kinematic body. -CP_EXPORT cpBody* cpBodyNewKinematic(void); -/// Allocate and initialize a cpBody, and set it as a static body. -CP_EXPORT cpBody* cpBodyNewStatic(void); - -/// Destroy a cpBody. -CP_EXPORT void cpBodyDestroy(cpBody *body); -/// Destroy and free a cpBody. -CP_EXPORT void cpBodyFree(cpBody *body); - -// Defined in cpSpace.c -/// Wake up a sleeping or idle body. -CP_EXPORT void cpBodyActivate(cpBody *body); -/// Wake up any sleeping or idle bodies touching a static body. -CP_EXPORT void cpBodyActivateStatic(cpBody *body, cpShape *filter); - -/// Force a body to fall asleep immediately. -CP_EXPORT void cpBodySleep(cpBody *body); -/// Force a body to fall asleep immediately along with other bodies in a group. -CP_EXPORT void cpBodySleepWithGroup(cpBody *body, cpBody *group); - -/// Returns true if the body is sleeping. -CP_EXPORT cpBool cpBodyIsSleeping(const cpBody *body); - -/// Get the type of the body. -CP_EXPORT cpBodyType cpBodyGetType(cpBody *body); -/// Set the type of the body. -CP_EXPORT void cpBodySetType(cpBody *body, cpBodyType type); - -/// Get the space this body is added to. -CP_EXPORT cpSpace* cpBodyGetSpace(const cpBody *body); - -/// Get the mass of the body. -CP_EXPORT cpFloat cpBodyGetMass(const cpBody *body); -/// Set the mass of the body. -CP_EXPORT void cpBodySetMass(cpBody *body, cpFloat m); - -/// Get the moment of inertia of the body. -CP_EXPORT cpFloat cpBodyGetMoment(const cpBody *body); -/// Set the moment of inertia of the body. -CP_EXPORT void cpBodySetMoment(cpBody *body, cpFloat i); - -/// Set the position of a body. -CP_EXPORT cpVect cpBodyGetPosition(const cpBody *body); -/// Set the position of the body. -CP_EXPORT void cpBodySetPosition(cpBody *body, cpVect pos); - -/// Get the offset of the center of gravity in body local coordinates. -CP_EXPORT cpVect cpBodyGetCenterOfGravity(const cpBody *body); -/// Set the offset of the center of gravity in body local coordinates. -CP_EXPORT void cpBodySetCenterOfGravity(cpBody *body, cpVect cog); - -/// Get the velocity of the body. -CP_EXPORT cpVect cpBodyGetVelocity(const cpBody *body); -/// Set the velocity of the body. -CP_EXPORT void cpBodySetVelocity(cpBody *body, cpVect velocity); - -/// Get the force applied to the body for the next time step. -CP_EXPORT cpVect cpBodyGetForce(const cpBody *body); -/// Set the force applied to the body for the next time step. -CP_EXPORT void cpBodySetForce(cpBody *body, cpVect force); - -/// Get the angle of the body. -CP_EXPORT cpFloat cpBodyGetAngle(const cpBody *body); -/// Set the angle of a body. -CP_EXPORT void cpBodySetAngle(cpBody *body, cpFloat a); - -/// Get the angular velocity of the body. -CP_EXPORT cpFloat cpBodyGetAngularVelocity(const cpBody *body); -/// Set the angular velocity of the body. -CP_EXPORT void cpBodySetAngularVelocity(cpBody *body, cpFloat angularVelocity); - -/// Get the torque applied to the body for the next time step. -CP_EXPORT cpFloat cpBodyGetTorque(const cpBody *body); -/// Set the torque applied to the body for the next time step. -CP_EXPORT void cpBodySetTorque(cpBody *body, cpFloat torque); - -/// Get the rotation vector of the body. (The x basis vector of it's transform.) -CP_EXPORT cpVect cpBodyGetRotation(const cpBody *body); - -/// Get the user data pointer assigned to the body. -CP_EXPORT cpDataPointer cpBodyGetUserData(const cpBody *body); -/// Set the user data pointer assigned to the body. -CP_EXPORT void cpBodySetUserData(cpBody *body, cpDataPointer userData); - -/// Set the callback used to update a body's velocity. -CP_EXPORT void cpBodySetVelocityUpdateFunc(cpBody *body, cpBodyVelocityFunc velocityFunc); -/// Set the callback used to update a body's position. -/// NOTE: It's not generally recommended to override this unless you call the default position update function. -CP_EXPORT void cpBodySetPositionUpdateFunc(cpBody *body, cpBodyPositionFunc positionFunc); - -/// Default velocity integration function.. -CP_EXPORT void cpBodyUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt); -/// Default position integration function. -CP_EXPORT void cpBodyUpdatePosition(cpBody *body, cpFloat dt); - -/// Convert body relative/local coordinates to absolute/world coordinates. -CP_EXPORT cpVect cpBodyLocalToWorld(const cpBody *body, const cpVect point); -/// Convert body absolute/world coordinates to relative/local coordinates. -CP_EXPORT cpVect cpBodyWorldToLocal(const cpBody *body, const cpVect point); - -/// Apply a force to a body. Both the force and point are expressed in world coordinates. -CP_EXPORT void cpBodyApplyForceAtWorldPoint(cpBody *body, cpVect force, cpVect point); -/// Apply a force to a body. Both the force and point are expressed in body local coordinates. -CP_EXPORT void cpBodyApplyForceAtLocalPoint(cpBody *body, cpVect force, cpVect point); - -/// Apply an impulse to a body. Both the impulse and point are expressed in world coordinates. -CP_EXPORT void cpBodyApplyImpulseAtWorldPoint(cpBody *body, cpVect impulse, cpVect point); -/// Apply an impulse to a body. Both the impulse and point are expressed in body local coordinates. -CP_EXPORT void cpBodyApplyImpulseAtLocalPoint(cpBody *body, cpVect impulse, cpVect point); - -/// Get the velocity on a body (in world units) at a point on the body in world coordinates. -CP_EXPORT cpVect cpBodyGetVelocityAtWorldPoint(const cpBody *body, cpVect point); -/// Get the velocity on a body (in world units) at a point on the body in local coordinates. -CP_EXPORT cpVect cpBodyGetVelocityAtLocalPoint(const cpBody *body, cpVect point); - -/// Get the amount of kinetic energy contained by the body. -CP_EXPORT cpFloat cpBodyKineticEnergy(const cpBody *body); - -/// Body/shape iterator callback function type. -typedef void (*cpBodyShapeIteratorFunc)(cpBody *body, cpShape *shape, void *data); -/// Call @c func once for each shape attached to @c body and added to the space. -CP_EXPORT void cpBodyEachShape(cpBody *body, cpBodyShapeIteratorFunc func, void *data); - -/// Body/constraint iterator callback function type. -typedef void (*cpBodyConstraintIteratorFunc)(cpBody *body, cpConstraint *constraint, void *data); -/// Call @c func once for each constraint attached to @c body and added to the space. -CP_EXPORT void cpBodyEachConstraint(cpBody *body, cpBodyConstraintIteratorFunc func, void *data); - -/// Body/arbiter iterator callback function type. -typedef void (*cpBodyArbiterIteratorFunc)(cpBody *body, cpArbiter *arbiter, void *data); -/// Call @c func once for each arbiter that is currently active on the body. -CP_EXPORT void cpBodyEachArbiter(cpBody *body, cpBodyArbiterIteratorFunc func, void *data); - -///@} diff --git a/android/armeabi/include/chipmunk/cpConstraint.h b/android/armeabi/include/chipmunk/cpConstraint.h deleted file mode 100644 index b1a439f7..00000000 --- a/android/armeabi/include/chipmunk/cpConstraint.h +++ /dev/null @@ -1,95 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpConstraint cpConstraint -/// @{ - -/// Callback function type that gets called before solving a joint. -typedef void (*cpConstraintPreSolveFunc)(cpConstraint *constraint, cpSpace *space); -/// Callback function type that gets called after solving a joint. -typedef void (*cpConstraintPostSolveFunc)(cpConstraint *constraint, cpSpace *space); - -/// Destroy a constraint. -CP_EXPORT void cpConstraintDestroy(cpConstraint *constraint); -/// Destroy and free a constraint. -CP_EXPORT void cpConstraintFree(cpConstraint *constraint); - -/// Get the cpSpace this constraint is added to. -CP_EXPORT cpSpace* cpConstraintGetSpace(const cpConstraint *constraint); - -/// Get the first body the constraint is attached to. -CP_EXPORT cpBody* cpConstraintGetBodyA(const cpConstraint *constraint); - -/// Get the second body the constraint is attached to. -CP_EXPORT cpBody* cpConstraintGetBodyB(const cpConstraint *constraint); - -/// Get the maximum force that this constraint is allowed to use. -CP_EXPORT cpFloat cpConstraintGetMaxForce(const cpConstraint *constraint); -/// Set the maximum force that this constraint is allowed to use. (defaults to INFINITY) -CP_EXPORT void cpConstraintSetMaxForce(cpConstraint *constraint, cpFloat maxForce); - -/// Get rate at which joint error is corrected. -CP_EXPORT cpFloat cpConstraintGetErrorBias(const cpConstraint *constraint); -/// Set rate at which joint error is corrected. -/// Defaults to pow(1.0 - 0.1, 60.0) meaning that it will -/// correct 10% of the error every 1/60th of a second. -CP_EXPORT void cpConstraintSetErrorBias(cpConstraint *constraint, cpFloat errorBias); - -/// Get the maximum rate at which joint error is corrected. -CP_EXPORT cpFloat cpConstraintGetMaxBias(const cpConstraint *constraint); -/// Set the maximum rate at which joint error is corrected. (defaults to INFINITY) -CP_EXPORT void cpConstraintSetMaxBias(cpConstraint *constraint, cpFloat maxBias); - -/// Get if the two bodies connected by the constraint are allowed to collide or not. -CP_EXPORT cpBool cpConstraintGetCollideBodies(const cpConstraint *constraint); -/// Set if the two bodies connected by the constraint are allowed to collide or not. (defaults to cpFalse) -CP_EXPORT void cpConstraintSetCollideBodies(cpConstraint *constraint, cpBool collideBodies); - -/// Get the pre-solve function that is called before the solver runs. -CP_EXPORT cpConstraintPreSolveFunc cpConstraintGetPreSolveFunc(const cpConstraint *constraint); -/// Set the pre-solve function that is called before the solver runs. -CP_EXPORT void cpConstraintSetPreSolveFunc(cpConstraint *constraint, cpConstraintPreSolveFunc preSolveFunc); - -/// Get the post-solve function that is called before the solver runs. -CP_EXPORT cpConstraintPostSolveFunc cpConstraintGetPostSolveFunc(const cpConstraint *constraint); -/// Set the post-solve function that is called before the solver runs. -CP_EXPORT void cpConstraintSetPostSolveFunc(cpConstraint *constraint, cpConstraintPostSolveFunc postSolveFunc); - -/// Get the user definable data pointer for this constraint -CP_EXPORT cpDataPointer cpConstraintGetUserData(const cpConstraint *constraint); -/// Set the user definable data pointer for this constraint -CP_EXPORT void cpConstraintSetUserData(cpConstraint *constraint, cpDataPointer userData); - -/// Get the last impulse applied by this constraint. -CP_EXPORT cpFloat cpConstraintGetImpulse(cpConstraint *constraint); - -#include "cpPinJoint.h" -#include "cpSlideJoint.h" -#include "cpPivotJoint.h" -#include "cpGrooveJoint.h" -#include "cpDampedSpring.h" -#include "cpDampedRotarySpring.h" -#include "cpRotaryLimitJoint.h" -#include "cpRatchetJoint.h" -#include "cpGearJoint.h" -#include "cpSimpleMotor.h" - -///@} diff --git a/android/armeabi/include/chipmunk/cpDampedRotarySpring.h b/android/armeabi/include/chipmunk/cpDampedRotarySpring.h deleted file mode 100644 index 6f60e86e..00000000 --- a/android/armeabi/include/chipmunk/cpDampedRotarySpring.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpDampedRotarySpring cpDampedRotarySpring -/// @{ - -/// Check if a constraint is a damped rotary springs. -CP_EXPORT cpBool cpConstraintIsDampedRotarySpring(const cpConstraint *constraint); - -/// Function type used for damped rotary spring force callbacks. -typedef cpFloat (*cpDampedRotarySpringTorqueFunc)(struct cpConstraint *spring, cpFloat relativeAngle); - -/// Allocate a damped rotary spring. -CP_EXPORT cpDampedRotarySpring* cpDampedRotarySpringAlloc(void); -/// Initialize a damped rotary spring. -CP_EXPORT cpDampedRotarySpring* cpDampedRotarySpringInit(cpDampedRotarySpring *joint, cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); -/// Allocate and initialize a damped rotary spring. -CP_EXPORT cpConstraint* cpDampedRotarySpringNew(cpBody *a, cpBody *b, cpFloat restAngle, cpFloat stiffness, cpFloat damping); - -/// Get the rest length of the spring. -CP_EXPORT cpFloat cpDampedRotarySpringGetRestAngle(const cpConstraint *constraint); -/// Set the rest length of the spring. -CP_EXPORT void cpDampedRotarySpringSetRestAngle(cpConstraint *constraint, cpFloat restAngle); - -/// Get the stiffness of the spring in force/distance. -CP_EXPORT cpFloat cpDampedRotarySpringGetStiffness(const cpConstraint *constraint); -/// Set the stiffness of the spring in force/distance. -CP_EXPORT void cpDampedRotarySpringSetStiffness(cpConstraint *constraint, cpFloat stiffness); - -/// Get the damping of the spring. -CP_EXPORT cpFloat cpDampedRotarySpringGetDamping(const cpConstraint *constraint); -/// Set the damping of the spring. -CP_EXPORT void cpDampedRotarySpringSetDamping(cpConstraint *constraint, cpFloat damping); - -/// Get the damping of the spring. -CP_EXPORT cpDampedRotarySpringTorqueFunc cpDampedRotarySpringGetSpringTorqueFunc(const cpConstraint *constraint); -/// Set the damping of the spring. -CP_EXPORT void cpDampedRotarySpringSetSpringTorqueFunc(cpConstraint *constraint, cpDampedRotarySpringTorqueFunc springTorqueFunc); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpDampedSpring.h b/android/armeabi/include/chipmunk/cpDampedSpring.h deleted file mode 100644 index b332fc7f..00000000 --- a/android/armeabi/include/chipmunk/cpDampedSpring.h +++ /dev/null @@ -1,68 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpDampedSpring cpDampedSpring -/// @{ - -/// Check if a constraint is a slide joint. -CP_EXPORT cpBool cpConstraintIsDampedSpring(const cpConstraint *constraint); - -/// Function type used for damped spring force callbacks. -typedef cpFloat (*cpDampedSpringForceFunc)(cpConstraint *spring, cpFloat dist); - -/// Allocate a damped spring. -CP_EXPORT cpDampedSpring* cpDampedSpringAlloc(void); -/// Initialize a damped spring. -CP_EXPORT cpDampedSpring* cpDampedSpringInit(cpDampedSpring *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat restLength, cpFloat stiffness, cpFloat damping); -/// Allocate and initialize a damped spring. -CP_EXPORT cpConstraint* cpDampedSpringNew(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat restLength, cpFloat stiffness, cpFloat damping); - -/// Get the location of the first anchor relative to the first body. -CP_EXPORT cpVect cpDampedSpringGetAnchorA(const cpConstraint *constraint); -/// Set the location of the first anchor relative to the first body. -CP_EXPORT void cpDampedSpringSetAnchorA(cpConstraint *constraint, cpVect anchorA); - -/// Get the location of the second anchor relative to the second body. -CP_EXPORT cpVect cpDampedSpringGetAnchorB(const cpConstraint *constraint); -/// Set the location of the second anchor relative to the second body. -CP_EXPORT void cpDampedSpringSetAnchorB(cpConstraint *constraint, cpVect anchorB); - -/// Get the rest length of the spring. -CP_EXPORT cpFloat cpDampedSpringGetRestLength(const cpConstraint *constraint); -/// Set the rest length of the spring. -CP_EXPORT void cpDampedSpringSetRestLength(cpConstraint *constraint, cpFloat restLength); - -/// Get the stiffness of the spring in force/distance. -CP_EXPORT cpFloat cpDampedSpringGetStiffness(const cpConstraint *constraint); -/// Set the stiffness of the spring in force/distance. -CP_EXPORT void cpDampedSpringSetStiffness(cpConstraint *constraint, cpFloat stiffness); - -/// Get the damping of the spring. -CP_EXPORT cpFloat cpDampedSpringGetDamping(const cpConstraint *constraint); -/// Set the damping of the spring. -CP_EXPORT void cpDampedSpringSetDamping(cpConstraint *constraint, cpFloat damping); - -/// Get the damping of the spring. -CP_EXPORT cpDampedSpringForceFunc cpDampedSpringGetSpringForceFunc(const cpConstraint *constraint); -/// Set the damping of the spring. -CP_EXPORT void cpDampedSpringSetSpringForceFunc(cpConstraint *constraint, cpDampedSpringForceFunc springForceFunc); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpGearJoint.h b/android/armeabi/include/chipmunk/cpGearJoint.h deleted file mode 100644 index 8cd80e0b..00000000 --- a/android/armeabi/include/chipmunk/cpGearJoint.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpGearJoint cpGearJoint -/// @{ - -/// Check if a constraint is a damped rotary springs. -CP_EXPORT cpBool cpConstraintIsGearJoint(const cpConstraint *constraint); - -/// Allocate a gear joint. -CP_EXPORT cpGearJoint* cpGearJointAlloc(void); -/// Initialize a gear joint. -CP_EXPORT cpGearJoint* cpGearJointInit(cpGearJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); -/// Allocate and initialize a gear joint. -CP_EXPORT cpConstraint* cpGearJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratio); - -/// Get the phase offset of the gears. -CP_EXPORT cpFloat cpGearJointGetPhase(const cpConstraint *constraint); -/// Set the phase offset of the gears. -CP_EXPORT void cpGearJointSetPhase(cpConstraint *constraint, cpFloat phase); - -/// Get the angular distance of each ratchet. -CP_EXPORT cpFloat cpGearJointGetRatio(const cpConstraint *constraint); -/// Set the ratio of a gear joint. -CP_EXPORT void cpGearJointSetRatio(cpConstraint *constraint, cpFloat ratio); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpGrooveJoint.h b/android/armeabi/include/chipmunk/cpGrooveJoint.h deleted file mode 100644 index 8bdafc14..00000000 --- a/android/armeabi/include/chipmunk/cpGrooveJoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpGrooveJoint cpGrooveJoint -/// @{ - -/// Check if a constraint is a slide joint. -CP_EXPORT cpBool cpConstraintIsGrooveJoint(const cpConstraint *constraint); - -/// Allocate a groove joint. -CP_EXPORT cpGrooveJoint* cpGrooveJointAlloc(void); -/// Initialize a groove joint. -CP_EXPORT cpGrooveJoint* cpGrooveJointInit(cpGrooveJoint *joint, cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB); -/// Allocate and initialize a groove joint. -CP_EXPORT cpConstraint* cpGrooveJointNew(cpBody *a, cpBody *b, cpVect groove_a, cpVect groove_b, cpVect anchorB); - -/// Get the first endpoint of the groove relative to the first body. -CP_EXPORT cpVect cpGrooveJointGetGrooveA(const cpConstraint *constraint); -/// Set the first endpoint of the groove relative to the first body. -CP_EXPORT void cpGrooveJointSetGrooveA(cpConstraint *constraint, cpVect grooveA); - -/// Get the first endpoint of the groove relative to the first body. -CP_EXPORT cpVect cpGrooveJointGetGrooveB(const cpConstraint *constraint); -/// Set the first endpoint of the groove relative to the first body. -CP_EXPORT void cpGrooveJointSetGrooveB(cpConstraint *constraint, cpVect grooveB); - -/// Get the location of the second anchor relative to the second body. -CP_EXPORT cpVect cpGrooveJointGetAnchorB(const cpConstraint *constraint); -/// Set the location of the second anchor relative to the second body. -CP_EXPORT void cpGrooveJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpHastySpace.h b/android/armeabi/include/chipmunk/cpHastySpace.h deleted file mode 100644 index 6de2283b..00000000 --- a/android/armeabi/include/chipmunk/cpHastySpace.h +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2013 Howling Moon Software. All rights reserved. -// See http://chipmunk2d.net/legal.php for more information. - -/// cpHastySpace is exclusive to Chipmunk Pro -/// Currently it enables ARM NEON optimizations in the solver, but in the future will include other optimizations such as -/// a multi-threaded solver and multi-threaded collision broadphases. - -struct cpHastySpace; -typedef struct cpHastySpace cpHastySpace; - -/// Create a new hasty space. -/// On ARM platforms that support NEON, this will enable the vectorized solver. -/// cpHastySpace also supports multiple threads, but runs single threaded by default for determinism. -CP_EXPORT cpSpace *cpHastySpaceNew(void); -CP_EXPORT void cpHastySpaceFree(cpSpace *space); - -/// Set the number of threads to use for the solver. -/// Currently Chipmunk is limited to 2 threads as using more generally provides very minimal performance gains. -/// Passing 0 as the thread count on iOS or OS X will cause Chipmunk to automatically detect the number of threads it should use. -/// On other platforms passing 0 for the thread count will set 1 thread. -CP_EXPORT void cpHastySpaceSetThreads(cpSpace *space, unsigned long threads); - -/// Returns the number of threads the solver is using to run. -CP_EXPORT unsigned long cpHastySpaceGetThreads(cpSpace *space); - -/// When stepping a hasty space, you must use this function. -CP_EXPORT void cpHastySpaceStep(cpSpace *space, cpFloat dt); diff --git a/android/armeabi/include/chipmunk/cpMarch.h b/android/armeabi/include/chipmunk/cpMarch.h deleted file mode 100644 index cc1f5c06..00000000 --- a/android/armeabi/include/chipmunk/cpMarch.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright 2013 Howling Moon Software. All rights reserved. -// See http://chipmunk2d.net/legal.php for more information. - -/// Function type used as a callback from the marching squares algorithm to sample an image function. -/// It passes you the point to sample and your context pointer, and you return the density. -typedef cpFloat (*cpMarchSampleFunc)(cpVect point, void *data); - -/// Function type used as a callback from the marching squares algorithm to output a line segment. -/// It passes you the two endpoints and your context pointer. -typedef void (*cpMarchSegmentFunc)(cpVect v0, cpVect v1, void *data); - -/// Trace an anti-aliased contour of an image along a particular threshold. -/// The given number of samples will be taken and spread across the bounding box area using the sampling function and context. -/// The segment function will be called for each segment detected that lies along the density contour for @c threshold. -CP_EXPORT void cpMarchSoft( - cpBB bb, unsigned long x_samples, unsigned long y_samples, cpFloat threshold, - cpMarchSegmentFunc segment, void *segment_data, - cpMarchSampleFunc sample, void *sample_data -); - -/// Trace an aliased curve of an image along a particular threshold. -/// The given number of samples will be taken and spread across the bounding box area using the sampling function and context. -/// The segment function will be called for each segment detected that lies along the density contour for @c threshold. -CP_EXPORT void cpMarchHard( - cpBB bb, unsigned long x_samples, unsigned long y_samples, cpFloat threshold, - cpMarchSegmentFunc segment, void *segment_data, - cpMarchSampleFunc sample, void *sample_data -); diff --git a/android/armeabi/include/chipmunk/cpPinJoint.h b/android/armeabi/include/chipmunk/cpPinJoint.h deleted file mode 100644 index 45aaa3e3..00000000 --- a/android/armeabi/include/chipmunk/cpPinJoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpPinJoint cpPinJoint -/// @{ - -/// Check if a constraint is a pin joint. -CP_EXPORT cpBool cpConstraintIsPinJoint(const cpConstraint *constraint); - -/// Allocate a pin joint. -CP_EXPORT cpPinJoint* cpPinJointAlloc(void); -/// Initialize a pin joint. -CP_EXPORT cpPinJoint* cpPinJointInit(cpPinJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); -/// Allocate and initialize a pin joint. -CP_EXPORT cpConstraint* cpPinJointNew(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); - -/// Get the location of the first anchor relative to the first body. -CP_EXPORT cpVect cpPinJointGetAnchorA(const cpConstraint *constraint); -/// Set the location of the first anchor relative to the first body. -CP_EXPORT void cpPinJointSetAnchorA(cpConstraint *constraint, cpVect anchorA); - -/// Get the location of the second anchor relative to the second body. -CP_EXPORT cpVect cpPinJointGetAnchorB(const cpConstraint *constraint); -/// Set the location of the second anchor relative to the second body. -CP_EXPORT void cpPinJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); - -/// Get the distance the joint will maintain between the two anchors. -CP_EXPORT cpFloat cpPinJointGetDist(const cpConstraint *constraint); -/// Set the distance the joint will maintain between the two anchors. -CP_EXPORT void cpPinJointSetDist(cpConstraint *constraint, cpFloat dist); - -///@} diff --git a/android/armeabi/include/chipmunk/cpPivotJoint.h b/android/armeabi/include/chipmunk/cpPivotJoint.h deleted file mode 100644 index 4a620ef2..00000000 --- a/android/armeabi/include/chipmunk/cpPivotJoint.h +++ /dev/null @@ -1,47 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpPivotJoint cpPivotJoint -/// @{ - -/// Check if a constraint is a slide joint. -CP_EXPORT cpBool cpConstraintIsPivotJoint(const cpConstraint *constraint); - -/// Allocate a pivot joint -CP_EXPORT cpPivotJoint* cpPivotJointAlloc(void); -/// Initialize a pivot joint. -CP_EXPORT cpPivotJoint* cpPivotJointInit(cpPivotJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); -/// Allocate and initialize a pivot joint. -CP_EXPORT cpConstraint* cpPivotJointNew(cpBody *a, cpBody *b, cpVect pivot); -/// Allocate and initialize a pivot joint with specific anchors. -CP_EXPORT cpConstraint* cpPivotJointNew2(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB); - -/// Get the location of the first anchor relative to the first body. -CP_EXPORT cpVect cpPivotJointGetAnchorA(const cpConstraint *constraint); -/// Set the location of the first anchor relative to the first body. -CP_EXPORT void cpPivotJointSetAnchorA(cpConstraint *constraint, cpVect anchorA); - -/// Get the location of the second anchor relative to the second body. -CP_EXPORT cpVect cpPivotJointGetAnchorB(const cpConstraint *constraint); -/// Set the location of the second anchor relative to the second body. -CP_EXPORT void cpPivotJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpPolyShape.h b/android/armeabi/include/chipmunk/cpPolyShape.h deleted file mode 100644 index 25f688b8..00000000 --- a/android/armeabi/include/chipmunk/cpPolyShape.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpPolyShape cpPolyShape -/// @{ - -/// Allocate a polygon shape. -CP_EXPORT cpPolyShape* cpPolyShapeAlloc(void); -/// Initialize a polygon shape with rounded corners. -/// A convex hull will be created from the vertexes. -CP_EXPORT cpPolyShape* cpPolyShapeInit(cpPolyShape *poly, cpBody *body, int count, const cpVect *verts, cpTransform transform, cpFloat radius); -/// Initialize a polygon shape with rounded corners. -/// The vertexes must be convex with a counter-clockwise winding. -CP_EXPORT cpPolyShape* cpPolyShapeInitRaw(cpPolyShape *poly, cpBody *body, int count, const cpVect *verts, cpFloat radius); -/// Allocate and initialize a polygon shape with rounded corners. -/// A convex hull will be created from the vertexes. -CP_EXPORT cpShape* cpPolyShapeNew(cpBody *body, int count, const cpVect *verts, cpTransform transform, cpFloat radius); -/// Allocate and initialize a polygon shape with rounded corners. -/// The vertexes must be convex with a counter-clockwise winding. -CP_EXPORT cpShape* cpPolyShapeNewRaw(cpBody *body, int count, const cpVect *verts, cpFloat radius); - -/// Initialize a box shaped polygon shape with rounded corners. -CP_EXPORT cpPolyShape* cpBoxShapeInit(cpPolyShape *poly, cpBody *body, cpFloat width, cpFloat height, cpFloat radius); -/// Initialize an offset box shaped polygon shape with rounded corners. -CP_EXPORT cpPolyShape* cpBoxShapeInit2(cpPolyShape *poly, cpBody *body, cpBB box, cpFloat radius); -/// Allocate and initialize a box shaped polygon shape. -CP_EXPORT cpShape* cpBoxShapeNew(cpBody *body, cpFloat width, cpFloat height, cpFloat radius); -/// Allocate and initialize an offset box shaped polygon shape. -CP_EXPORT cpShape* cpBoxShapeNew2(cpBody *body, cpBB box, cpFloat radius); - -/// Get the number of verts in a polygon shape. -CP_EXPORT int cpPolyShapeGetCount(const cpShape *shape); -/// Get the @c ith vertex of a polygon shape. -CP_EXPORT cpVect cpPolyShapeGetVert(const cpShape *shape, int index); -/// Get the radius of a polygon shape. -CP_EXPORT cpFloat cpPolyShapeGetRadius(const cpShape *shape); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpPolyline.h b/android/armeabi/include/chipmunk/cpPolyline.h deleted file mode 100644 index c3d2921a..00000000 --- a/android/armeabi/include/chipmunk/cpPolyline.h +++ /dev/null @@ -1,70 +0,0 @@ -// Copyright 2013 Howling Moon Software. All rights reserved. -// See http://chipmunk2d.net/legal.php for more information. - -// Polylines are just arrays of vertexes. -// They are looped if the first vertex is equal to the last. -// cpPolyline structs are intended to be passed by value and destroyed when you are done with them. -typedef struct cpPolyline { - int count, capacity; - cpVect verts[]; -} cpPolyline; - -/// Destroy and free a polyline instance. -CP_EXPORT void cpPolylineFree(cpPolyline *line); - -/// Returns true if the first vertex is equal to the last. -CP_EXPORT cpBool cpPolylineIsClosed(cpPolyline *line); - -/** - Returns a copy of a polyline simplified by using the Douglas-Peucker algorithm. - This works very well on smooth or gently curved shapes, but not well on straight edged or angular shapes. -*/ -CP_EXPORT cpPolyline *cpPolylineSimplifyCurves(cpPolyline *line, cpFloat tol); - -/** - Returns a copy of a polyline simplified by discarding "flat" vertexes. - This works well on straigt edged or angular shapes, not as well on smooth shapes. -*/ -CP_EXPORT cpPolyline *cpPolylineSimplifyVertexes(cpPolyline *line, cpFloat tol); - -/// Get the convex hull of a polyline as a looped polyline. -CP_EXPORT cpPolyline *cpPolylineToConvexHull(cpPolyline *line, cpFloat tol); - - -/// Polyline sets are collections of polylines, generally built by cpMarchSoft() or cpMarchHard(). -typedef struct cpPolylineSet { - int count, capacity; - cpPolyline **lines; -} cpPolylineSet; - -/// Allocate a new polyline set. -CP_EXPORT cpPolylineSet *cpPolylineSetAlloc(void); - -/// Initialize a new polyline set. -CP_EXPORT cpPolylineSet *cpPolylineSetInit(cpPolylineSet *set); - -/// Allocate and initialize a polyline set. -CP_EXPORT cpPolylineSet *cpPolylineSetNew(void); - -/// Destroy a polyline set. -CP_EXPORT void cpPolylineSetDestroy(cpPolylineSet *set, cpBool freePolylines); - -CP_EXPORT /// Destroy and free a polyline set. -void cpPolylineSetFree(cpPolylineSet *set, cpBool freePolylines); - -/** - Add a line segment to a polyline set. - A segment will either start a new polyline, join two others, or add to or loop an existing polyline. - This is mostly intended to be used as a callback directly from cpMarchSoft() or cpMarchHard(). -*/ -CP_EXPORT void cpPolylineSetCollectSegment(cpVect v0, cpVect v1, cpPolylineSet *lines); - -/** - Get an approximate convex decomposition from a polyline. - Returns a cpPolylineSet of convex hulls that match the original shape to within 'tol'. - NOTE: If the input is a self intersecting polygon, the output might end up overly simplified. -*/ - -CP_EXPORT cpPolylineSet *cpPolylineConvexDecomposition(cpPolyline *line, cpFloat tol); - -#define cpPolylineConvexDecomposition_BETA cpPolylineConvexDecomposition diff --git a/android/armeabi/include/chipmunk/cpRatchetJoint.h b/android/armeabi/include/chipmunk/cpRatchetJoint.h deleted file mode 100644 index 3ed4c915..00000000 --- a/android/armeabi/include/chipmunk/cpRatchetJoint.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpRatchetJoint cpRatchetJoint -/// @{ - -/// Check if a constraint is a damped rotary springs. -CP_EXPORT cpBool cpConstraintIsRatchetJoint(const cpConstraint *constraint); - -/// Allocate a ratchet joint. -CP_EXPORT cpRatchetJoint* cpRatchetJointAlloc(void); -/// Initialize a ratched joint. -CP_EXPORT cpRatchetJoint* cpRatchetJointInit(cpRatchetJoint *joint, cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); -/// Allocate and initialize a ratchet joint. -CP_EXPORT cpConstraint* cpRatchetJointNew(cpBody *a, cpBody *b, cpFloat phase, cpFloat ratchet); - -/// Get the angle of the current ratchet tooth. -CP_EXPORT cpFloat cpRatchetJointGetAngle(const cpConstraint *constraint); -/// Set the angle of the current ratchet tooth. -CP_EXPORT void cpRatchetJointSetAngle(cpConstraint *constraint, cpFloat angle); - -/// Get the phase offset of the ratchet. -CP_EXPORT cpFloat cpRatchetJointGetPhase(const cpConstraint *constraint); -/// Get the phase offset of the ratchet. -CP_EXPORT void cpRatchetJointSetPhase(cpConstraint *constraint, cpFloat phase); - -/// Get the angular distance of each ratchet. -CP_EXPORT cpFloat cpRatchetJointGetRatchet(const cpConstraint *constraint); -/// Set the angular distance of each ratchet. -CP_EXPORT void cpRatchetJointSetRatchet(cpConstraint *constraint, cpFloat ratchet); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpRobust.h b/android/armeabi/include/chipmunk/cpRobust.h deleted file mode 100644 index 143dd1b7..00000000 --- a/android/armeabi/include/chipmunk/cpRobust.h +++ /dev/null @@ -1,9 +0,0 @@ -#include "chipmunk/cpVect.h" - -// This is a private header for functions (currently just one) that need strict floating point results. -// It was easier to put this in it's own file than to fiddle with 4 different compiler specific pragmas or attributes. -// "Fast math" should be disabled here. - -// Check that the signed area of the triangle a, b, c is positive. -// Compiler optimizations for associativity break certain edge cases (ex: when a or b equals c) that lead to excessive EPA iteration. -cpBool cpCheckSignedArea(const cpVect a, const cpVect b, const cpVect c); diff --git a/android/armeabi/include/chipmunk/cpRotaryLimitJoint.h b/android/armeabi/include/chipmunk/cpRotaryLimitJoint.h deleted file mode 100644 index fac7ad85..00000000 --- a/android/armeabi/include/chipmunk/cpRotaryLimitJoint.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpRotaryLimitJoint cpRotaryLimitJoint -/// @{ - -/// Check if a constraint is a damped rotary springs. -CP_EXPORT cpBool cpConstraintIsRotaryLimitJoint(const cpConstraint *constraint); - -/// Allocate a damped rotary limit joint. -CP_EXPORT cpRotaryLimitJoint* cpRotaryLimitJointAlloc(void); -/// Initialize a damped rotary limit joint. -CP_EXPORT cpRotaryLimitJoint* cpRotaryLimitJointInit(cpRotaryLimitJoint *joint, cpBody *a, cpBody *b, cpFloat min, cpFloat max); -/// Allocate and initialize a damped rotary limit joint. -CP_EXPORT cpConstraint* cpRotaryLimitJointNew(cpBody *a, cpBody *b, cpFloat min, cpFloat max); - -/// Get the minimum distance the joint will maintain between the two anchors. -CP_EXPORT cpFloat cpRotaryLimitJointGetMin(const cpConstraint *constraint); -/// Set the minimum distance the joint will maintain between the two anchors. -CP_EXPORT void cpRotaryLimitJointSetMin(cpConstraint *constraint, cpFloat min); - -/// Get the maximum distance the joint will maintain between the two anchors. -CP_EXPORT cpFloat cpRotaryLimitJointGetMax(const cpConstraint *constraint); -/// Set the maximum distance the joint will maintain between the two anchors. -CP_EXPORT void cpRotaryLimitJointSetMax(cpConstraint *constraint, cpFloat max); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpShape.h b/android/armeabi/include/chipmunk/cpShape.h deleted file mode 100644 index cc20f809..00000000 --- a/android/armeabi/include/chipmunk/cpShape.h +++ /dev/null @@ -1,199 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpShape cpShape -/// The cpShape struct defines the shape of a rigid body. -/// @{ - -/// Point query info struct. -typedef struct cpPointQueryInfo { - /// The nearest shape, NULL if no shape was within range. - const cpShape *shape; - /// The closest point on the shape's surface. (in world space coordinates) - cpVect point; - /// The distance to the point. The distance is negative if the point is inside the shape. - cpFloat distance; - /// The gradient of the signed distance function. - /// The value should be similar to info.p/info.d, but accurate even for very small values of info.d. - cpVect gradient; -} cpPointQueryInfo; - -/// Segment query info struct. -typedef struct cpSegmentQueryInfo { - /// The shape that was hit, or NULL if no collision occured. - const cpShape *shape; - /// The point of impact. - cpVect point; - /// The normal of the surface hit. - cpVect normal; - /// The normalized distance along the query segment in the range [0, 1]. - cpFloat alpha; -} cpSegmentQueryInfo; - -/// Fast collision filtering type that is used to determine if two objects collide before calling collision or query callbacks. -typedef struct cpShapeFilter { - /// Two objects with the same non-zero group value do not collide. - /// This is generally used to group objects in a composite object together to disable self collisions. - cpGroup group; - /// A bitmask of user definable categories that this object belongs to. - /// The category/mask combinations of both objects in a collision must agree for a collision to occur. - cpBitmask categories; - /// A bitmask of user definable category types that this object object collides with. - /// The category/mask combinations of both objects in a collision must agree for a collision to occur. - cpBitmask mask; -} cpShapeFilter; - -/// Collision filter value for a shape that will collide with anything except CP_SHAPE_FILTER_NONE. -static const cpShapeFilter CP_SHAPE_FILTER_ALL = {CP_NO_GROUP, CP_ALL_CATEGORIES, CP_ALL_CATEGORIES}; -/// Collision filter value for a shape that does not collide with anything. -static const cpShapeFilter CP_SHAPE_FILTER_NONE = {CP_NO_GROUP, ~CP_ALL_CATEGORIES, ~CP_ALL_CATEGORIES}; - -/// Create a new collision filter. -static inline cpShapeFilter -cpShapeFilterNew(cpGroup group, cpBitmask categories, cpBitmask mask) -{ - cpShapeFilter filter = {group, categories, mask}; - return filter; -} - -/// Destroy a shape. -CP_EXPORT void cpShapeDestroy(cpShape *shape); -/// Destroy and Free a shape. -CP_EXPORT void cpShapeFree(cpShape *shape); - -/// Update, cache and return the bounding box of a shape based on the body it's attached to. -CP_EXPORT cpBB cpShapeCacheBB(cpShape *shape); -/// Update, cache and return the bounding box of a shape with an explicit transformation. -CP_EXPORT cpBB cpShapeUpdate(cpShape *shape, cpTransform transform); - -/// Perform a nearest point query. It finds the closest point on the surface of shape to a specific point. -/// The value returned is the distance between the points. A negative distance means the point is inside the shape. -CP_EXPORT cpFloat cpShapePointQuery(const cpShape *shape, cpVect p, cpPointQueryInfo *out); - -/// Perform a segment query against a shape. @c info must be a pointer to a valid cpSegmentQueryInfo structure. -CP_EXPORT cpBool cpShapeSegmentQuery(const cpShape *shape, cpVect a, cpVect b, cpFloat radius, cpSegmentQueryInfo *info); - -/// Return contact information about two shapes. -CP_EXPORT cpContactPointSet cpShapesCollide(const cpShape *a, const cpShape *b); - -/// The cpSpace this body is added to. -CP_EXPORT cpSpace* cpShapeGetSpace(const cpShape *shape); - -/// The cpBody this shape is connected to. -CP_EXPORT cpBody* cpShapeGetBody(const cpShape *shape); -/// Set the cpBody this shape is connected to. -/// Can only be used if the shape is not currently added to a space. -CP_EXPORT void cpShapeSetBody(cpShape *shape, cpBody *body); - -/// Get the mass of the shape if you are having Chipmunk calculate mass properties for you. -cpFloat cpShapeGetMass(cpShape *shape); -/// Set the mass of this shape to have Chipmunk calculate mass properties for you. -CP_EXPORT void cpShapeSetMass(cpShape *shape, cpFloat mass); - -/// Get the density of the shape if you are having Chipmunk calculate mass properties for you. -CP_EXPORT cpFloat cpShapeGetDensity(cpShape *shape); -/// Set the density of this shape to have Chipmunk calculate mass properties for you. -CP_EXPORT void cpShapeSetDensity(cpShape *shape, cpFloat density); - -/// Get the calculated moment of inertia for this shape. -CP_EXPORT cpFloat cpShapeGetMoment(cpShape *shape); -/// Get the calculated area of this shape. -CP_EXPORT cpFloat cpShapeGetArea(cpShape *shape); -/// Get the centroid of this shape. -CP_EXPORT cpVect cpShapeGetCenterOfGravity(cpShape *shape); - -/// Get the bounding box that contains the shape given it's current position and angle. -CP_EXPORT cpBB cpShapeGetBB(const cpShape *shape); - -/// Get if the shape is set to be a sensor or not. -CP_EXPORT cpBool cpShapeGetSensor(const cpShape *shape); -/// Set if the shape is a sensor or not. -CP_EXPORT void cpShapeSetSensor(cpShape *shape, cpBool sensor); - -/// Get the elasticity of this shape. -CP_EXPORT cpFloat cpShapeGetElasticity(const cpShape *shape); -/// Set the elasticity of this shape. -CP_EXPORT void cpShapeSetElasticity(cpShape *shape, cpFloat elasticity); - -/// Get the friction of this shape. -CP_EXPORT cpFloat cpShapeGetFriction(const cpShape *shape); -/// Set the friction of this shape. -CP_EXPORT void cpShapeSetFriction(cpShape *shape, cpFloat friction); - -/// Get the surface velocity of this shape. -CP_EXPORT cpVect cpShapeGetSurfaceVelocity(const cpShape *shape); -/// Set the surface velocity of this shape. -CP_EXPORT void cpShapeSetSurfaceVelocity(cpShape *shape, cpVect surfaceVelocity); - -/// Get the user definable data pointer of this shape. -CP_EXPORT cpDataPointer cpShapeGetUserData(const cpShape *shape); -/// Set the user definable data pointer of this shape. -CP_EXPORT void cpShapeSetUserData(cpShape *shape, cpDataPointer userData); - -/// Set the collision type of this shape. -CP_EXPORT cpCollisionType cpShapeGetCollisionType(const cpShape *shape); -/// Get the collision type of this shape. -CP_EXPORT void cpShapeSetCollisionType(cpShape *shape, cpCollisionType collisionType); - -/// Get the collision filtering parameters of this shape. -CP_EXPORT cpShapeFilter cpShapeGetFilter(const cpShape *shape); -/// Set the collision filtering parameters of this shape. -CP_EXPORT void cpShapeSetFilter(cpShape *shape, cpShapeFilter filter); - - -/// @} -/// @defgroup cpCircleShape cpCircleShape - -/// Allocate a circle shape. -CP_EXPORT cpCircleShape* cpCircleShapeAlloc(void); -/// Initialize a circle shape. -CP_EXPORT cpCircleShape* cpCircleShapeInit(cpCircleShape *circle, cpBody *body, cpFloat radius, cpVect offset); -/// Allocate and initialize a circle shape. -CP_EXPORT cpShape* cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset); - -/// Get the offset of a circle shape. -CP_EXPORT cpVect cpCircleShapeGetOffset(const cpShape *shape); -/// Get the radius of a circle shape. -CP_EXPORT cpFloat cpCircleShapeGetRadius(const cpShape *shape); - -/// @} -/// @defgroup cpSegmentShape cpSegmentShape - -/// Allocate a segment shape. -CP_EXPORT cpSegmentShape* cpSegmentShapeAlloc(void); -/// Initialize a segment shape. -CP_EXPORT cpSegmentShape* cpSegmentShapeInit(cpSegmentShape *seg, cpBody *body, cpVect a, cpVect b, cpFloat radius); -/// Allocate and initialize a segment shape. -CP_EXPORT cpShape* cpSegmentShapeNew(cpBody *body, cpVect a, cpVect b, cpFloat radius); - -/// Let Chipmunk know about the geometry of adjacent segments to avoid colliding with endcaps. -CP_EXPORT void cpSegmentShapeSetNeighbors(cpShape *shape, cpVect prev, cpVect next); - -/// Get the first endpoint of a segment shape. -CP_EXPORT cpVect cpSegmentShapeGetA(const cpShape *shape); -/// Get the second endpoint of a segment shape. -CP_EXPORT cpVect cpSegmentShapeGetB(const cpShape *shape); -/// Get the normal of a segment shape. -CP_EXPORT cpVect cpSegmentShapeGetNormal(const cpShape *shape); -/// Get the first endpoint of a segment shape. -CP_EXPORT cpFloat cpSegmentShapeGetRadius(const cpShape *shape); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpSimpleMotor.h b/android/armeabi/include/chipmunk/cpSimpleMotor.h deleted file mode 100644 index 811b0114..00000000 --- a/android/armeabi/include/chipmunk/cpSimpleMotor.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpSimpleMotor cpSimpleMotor -/// @{ - -/// Opaque struct type for damped rotary springs. -typedef struct cpSimpleMotor cpSimpleMotor; - -/// Check if a constraint is a damped rotary springs. -CP_EXPORT cpBool cpConstraintIsSimpleMotor(const cpConstraint *constraint); - -/// Allocate a simple motor. -CP_EXPORT cpSimpleMotor* cpSimpleMotorAlloc(void); -/// initialize a simple motor. -CP_EXPORT cpSimpleMotor* cpSimpleMotorInit(cpSimpleMotor *joint, cpBody *a, cpBody *b, cpFloat rate); -/// Allocate and initialize a simple motor. -CP_EXPORT cpConstraint* cpSimpleMotorNew(cpBody *a, cpBody *b, cpFloat rate); - -/// Get the rate of the motor. -CP_EXPORT cpFloat cpSimpleMotorGetRate(const cpConstraint *constraint); -/// Set the rate of the motor. -CP_EXPORT void cpSimpleMotorSetRate(cpConstraint *constraint, cpFloat rate); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpSlideJoint.h b/android/armeabi/include/chipmunk/cpSlideJoint.h deleted file mode 100644 index c41f9a42..00000000 --- a/android/armeabi/include/chipmunk/cpSlideJoint.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpSlideJoint cpSlideJoint -/// @{ - -/// Check if a constraint is a slide joint. -CP_EXPORT cpBool cpConstraintIsSlideJoint(const cpConstraint *constraint); - -/// Allocate a slide joint. -CP_EXPORT cpSlideJoint* cpSlideJointAlloc(void); -/// Initialize a slide joint. -CP_EXPORT cpSlideJoint* cpSlideJointInit(cpSlideJoint *joint, cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat min, cpFloat max); -/// Allocate and initialize a slide joint. -CP_EXPORT cpConstraint* cpSlideJointNew(cpBody *a, cpBody *b, cpVect anchorA, cpVect anchorB, cpFloat min, cpFloat max); - -/// Get the location of the first anchor relative to the first body. -CP_EXPORT cpVect cpSlideJointGetAnchorA(const cpConstraint *constraint); -/// Set the location of the first anchor relative to the first body. -CP_EXPORT void cpSlideJointSetAnchorA(cpConstraint *constraint, cpVect anchorA); - -/// Get the location of the second anchor relative to the second body. -CP_EXPORT cpVect cpSlideJointGetAnchorB(const cpConstraint *constraint); -/// Set the location of the second anchor relative to the second body. -CP_EXPORT void cpSlideJointSetAnchorB(cpConstraint *constraint, cpVect anchorB); - -/// Get the minimum distance the joint will maintain between the two anchors. -CP_EXPORT cpFloat cpSlideJointGetMin(const cpConstraint *constraint); -/// Set the minimum distance the joint will maintain between the two anchors. -CP_EXPORT void cpSlideJointSetMin(cpConstraint *constraint, cpFloat min); - -/// Get the maximum distance the joint will maintain between the two anchors. -CP_EXPORT cpFloat cpSlideJointGetMax(const cpConstraint *constraint); -/// Set the maximum distance the joint will maintain between the two anchors. -CP_EXPORT void cpSlideJointSetMax(cpConstraint *constraint, cpFloat max); - -/// @} diff --git a/android/armeabi/include/chipmunk/cpSpace.h b/android/armeabi/include/chipmunk/cpSpace.h deleted file mode 100644 index 7bbabb85..00000000 --- a/android/armeabi/include/chipmunk/cpSpace.h +++ /dev/null @@ -1,319 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/// @defgroup cpSpace cpSpace -/// @{ - -//MARK: Definitions - -/// Collision begin event function callback type. -/// Returning false from a begin callback causes the collision to be ignored until -/// the the separate callback is called when the objects stop colliding. -typedef cpBool (*cpCollisionBeginFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData); -/// Collision pre-solve event function callback type. -/// Returning false from a pre-step callback causes the collision to be ignored until the next step. -typedef cpBool (*cpCollisionPreSolveFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData); -/// Collision post-solve event function callback type. -typedef void (*cpCollisionPostSolveFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData); -/// Collision separate event function callback type. -typedef void (*cpCollisionSeparateFunc)(cpArbiter *arb, cpSpace *space, cpDataPointer userData); - -/// Struct that holds function callback pointers to configure custom collision handling. -/// Collision handlers have a pair of types; when a collision occurs between two shapes that have these types, the collision handler functions are triggered. -struct cpCollisionHandler { - /// Collision type identifier of the first shape that this handler recognizes. - /// In the collision handler callback, the shape with this type will be the first argument. Read only. - const cpCollisionType typeA; - /// Collision type identifier of the second shape that this handler recognizes. - /// In the collision handler callback, the shape with this type will be the second argument. Read only. - const cpCollisionType typeB; - /// This function is called when two shapes with types that match this collision handler begin colliding. - cpCollisionBeginFunc beginFunc; - /// This function is called each step when two shapes with types that match this collision handler are colliding. - /// It's called before the collision solver runs so that you can affect a collision's outcome. - cpCollisionPreSolveFunc preSolveFunc; - /// This function is called each step when two shapes with types that match this collision handler are colliding. - /// It's called after the collision solver runs so that you can read back information about the collision to trigger events in your game. - cpCollisionPostSolveFunc postSolveFunc; - /// This function is called when two shapes with types that match this collision handler stop colliding. - cpCollisionSeparateFunc separateFunc; - /// This is a user definable context pointer that is passed to all of the collision handler functions. - cpDataPointer userData; -}; - -// TODO: Make timestep a parameter? - - -//MARK: Memory and Initialization - -/// Allocate a cpSpace. -CP_EXPORT cpSpace* cpSpaceAlloc(void); -/// Initialize a cpSpace. -CP_EXPORT cpSpace* cpSpaceInit(cpSpace *space); -/// Allocate and initialize a cpSpace. -CP_EXPORT cpSpace* cpSpaceNew(void); - -/// Destroy a cpSpace. -CP_EXPORT void cpSpaceDestroy(cpSpace *space); -/// Destroy and free a cpSpace. -CP_EXPORT void cpSpaceFree(cpSpace *space); - - -//MARK: Properties - -/// Number of iterations to use in the impulse solver to solve contacts and other constraints. -CP_EXPORT int cpSpaceGetIterations(const cpSpace *space); -CP_EXPORT void cpSpaceSetIterations(cpSpace *space, int iterations); - -/// Gravity to pass to rigid bodies when integrating velocity. -CP_EXPORT cpVect cpSpaceGetGravity(const cpSpace *space); -CP_EXPORT void cpSpaceSetGravity(cpSpace *space, cpVect gravity); - -/// Damping rate expressed as the fraction of velocity bodies retain each second. -/// A value of 0.9 would mean that each body's velocity will drop 10% per second. -/// The default value is 1.0, meaning no damping is applied. -/// @note This damping value is different than those of cpDampedSpring and cpDampedRotarySpring. -CP_EXPORT cpFloat cpSpaceGetDamping(const cpSpace *space); -CP_EXPORT void cpSpaceSetDamping(cpSpace *space, cpFloat damping); - -/// Speed threshold for a body to be considered idle. -/// The default value of 0 means to let the space guess a good threshold based on gravity. -CP_EXPORT cpFloat cpSpaceGetIdleSpeedThreshold(const cpSpace *space); -CP_EXPORT void cpSpaceSetIdleSpeedThreshold(cpSpace *space, cpFloat idleSpeedThreshold); - -/// Time a group of bodies must remain idle in order to fall asleep. -/// Enabling sleeping also implicitly enables the the contact graph. -/// The default value of INFINITY disables the sleeping algorithm. -CP_EXPORT cpFloat cpSpaceGetSleepTimeThreshold(const cpSpace *space); -CP_EXPORT void cpSpaceSetSleepTimeThreshold(cpSpace *space, cpFloat sleepTimeThreshold); - -/// Amount of encouraged penetration between colliding shapes. -/// Used to reduce oscillating contacts and keep the collision cache warm. -/// Defaults to 0.1. If you have poor simulation quality, -/// increase this number as much as possible without allowing visible amounts of overlap. -CP_EXPORT cpFloat cpSpaceGetCollisionSlop(const cpSpace *space); -CP_EXPORT void cpSpaceSetCollisionSlop(cpSpace *space, cpFloat collisionSlop); - -/// Determines how fast overlapping shapes are pushed apart. -/// Expressed as a fraction of the error remaining after each second. -/// Defaults to pow(1.0 - 0.1, 60.0) meaning that Chipmunk fixes 10% of overlap each frame at 60Hz. -CP_EXPORT cpFloat cpSpaceGetCollisionBias(const cpSpace *space); -CP_EXPORT void cpSpaceSetCollisionBias(cpSpace *space, cpFloat collisionBias); - -/// Number of frames that contact information should persist. -/// Defaults to 3. There is probably never a reason to change this value. -CP_EXPORT cpTimestamp cpSpaceGetCollisionPersistence(const cpSpace *space); -CP_EXPORT void cpSpaceSetCollisionPersistence(cpSpace *space, cpTimestamp collisionPersistence); - -/// User definable data pointer. -/// Generally this points to your game's controller or game state -/// class so you can access it when given a cpSpace reference in a callback. -CP_EXPORT cpDataPointer cpSpaceGetUserData(const cpSpace *space); -CP_EXPORT void cpSpaceSetUserData(cpSpace *space, cpDataPointer userData); - -/// The Space provided static body for a given cpSpace. -/// This is merely provided for convenience and you are not required to use it. -CP_EXPORT cpBody* cpSpaceGetStaticBody(const cpSpace *space); - -/// Returns the current (or most recent) time step used with the given space. -/// Useful from callbacks if your time step is not a compile-time global. -CP_EXPORT cpFloat cpSpaceGetCurrentTimeStep(const cpSpace *space); - -/// returns true from inside a callback when objects cannot be added/removed. -CP_EXPORT cpBool cpSpaceIsLocked(cpSpace *space); - - -//MARK: Collision Handlers - -/// Create or return the existing collision handler that is called for all collisions that are not handled by a more specific collision handler. -CP_EXPORT cpCollisionHandler *cpSpaceAddDefaultCollisionHandler(cpSpace *space); -/// Create or return the existing collision handler for the specified pair of collision types. -/// If wildcard handlers are used with either of the collision types, it's the responibility of the custom handler to invoke the wildcard handlers. -CP_EXPORT cpCollisionHandler *cpSpaceAddCollisionHandler(cpSpace *space, cpCollisionType a, cpCollisionType b); -/// Create or return the existing wildcard collision handler for the specified type. -CP_EXPORT cpCollisionHandler *cpSpaceAddWildcardHandler(cpSpace *space, cpCollisionType type); - - -//MARK: Add/Remove objects - -/// Add a collision shape to the simulation. -/// If the shape is attached to a static body, it will be added as a static shape. -CP_EXPORT cpShape* cpSpaceAddShape(cpSpace *space, cpShape *shape); -/// Add a rigid body to the simulation. -CP_EXPORT cpBody* cpSpaceAddBody(cpSpace *space, cpBody *body); -/// Add a constraint to the simulation. -CP_EXPORT cpConstraint* cpSpaceAddConstraint(cpSpace *space, cpConstraint *constraint); - -/// Remove a collision shape from the simulation. -CP_EXPORT void cpSpaceRemoveShape(cpSpace *space, cpShape *shape); -/// Remove a rigid body from the simulation. -CP_EXPORT void cpSpaceRemoveBody(cpSpace *space, cpBody *body); -/// Remove a constraint from the simulation. -CP_EXPORT void cpSpaceRemoveConstraint(cpSpace *space, cpConstraint *constraint); - -/// Test if a collision shape has been added to the space. -CP_EXPORT cpBool cpSpaceContainsShape(cpSpace *space, cpShape *shape); -/// Test if a rigid body has been added to the space. -CP_EXPORT cpBool cpSpaceContainsBody(cpSpace *space, cpBody *body); -/// Test if a constraint has been added to the space. -CP_EXPORT cpBool cpSpaceContainsConstraint(cpSpace *space, cpConstraint *constraint); - -//MARK: Post-Step Callbacks - -/// Post Step callback function type. -typedef void (*cpPostStepFunc)(cpSpace *space, void *key, void *data); -/// Schedule a post-step callback to be called when cpSpaceStep() finishes. -/// You can only register one callback per unique value for @c key. -/// Returns true only if @c key has never been scheduled before. -/// It's possible to pass @c NULL for @c func if you only want to mark @c key as being used. -CP_EXPORT cpBool cpSpaceAddPostStepCallback(cpSpace *space, cpPostStepFunc func, void *key, void *data); - - -//MARK: Queries - -// TODO: Queries and iterators should take a cpSpace parametery. -// TODO: They should also be abortable. - -/// Nearest point query callback function type. -typedef void (*cpSpacePointQueryFunc)(cpShape *shape, cpVect point, cpFloat distance, cpVect gradient, void *data); -/// Query the space at a point and call @c func for each shape found. -CP_EXPORT void cpSpacePointQuery(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpSpacePointQueryFunc func, void *data); -/// Query the space at a point and return the nearest shape found. Returns NULL if no shapes were found. -CP_EXPORT cpShape *cpSpacePointQueryNearest(cpSpace *space, cpVect point, cpFloat maxDistance, cpShapeFilter filter, cpPointQueryInfo *out); - -/// Segment query callback function type. -typedef void (*cpSpaceSegmentQueryFunc)(cpShape *shape, cpVect point, cpVect normal, cpFloat alpha, void *data); -/// Perform a directed line segment query (like a raycast) against the space calling @c func for each shape intersected. -CP_EXPORT void cpSpaceSegmentQuery(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSpaceSegmentQueryFunc func, void *data); -/// Perform a directed line segment query (like a raycast) against the space and return the first shape hit. Returns NULL if no shapes were hit. -CP_EXPORT cpShape *cpSpaceSegmentQueryFirst(cpSpace *space, cpVect start, cpVect end, cpFloat radius, cpShapeFilter filter, cpSegmentQueryInfo *out); - -/// Rectangle Query callback function type. -typedef void (*cpSpaceBBQueryFunc)(cpShape *shape, void *data); -/// Perform a fast rectangle query on the space calling @c func for each shape found. -/// Only the shape's bounding boxes are checked for overlap, not their full shape. -CP_EXPORT void cpSpaceBBQuery(cpSpace *space, cpBB bb, cpShapeFilter filter, cpSpaceBBQueryFunc func, void *data); - -/// Shape query callback function type. -typedef void (*cpSpaceShapeQueryFunc)(cpShape *shape, cpContactPointSet *points, void *data); -/// Query a space for any shapes overlapping the given shape and call @c func for each shape found. -CP_EXPORT cpBool cpSpaceShapeQuery(cpSpace *space, cpShape *shape, cpSpaceShapeQueryFunc func, void *data); - - -//MARK: Iteration - -/// Space/body iterator callback function type. -typedef void (*cpSpaceBodyIteratorFunc)(cpBody *body, void *data); -/// Call @c func for each body in the space. -CP_EXPORT void cpSpaceEachBody(cpSpace *space, cpSpaceBodyIteratorFunc func, void *data); - -/// Space/body iterator callback function type. -typedef void (*cpSpaceShapeIteratorFunc)(cpShape *shape, void *data); -/// Call @c func for each shape in the space. -CP_EXPORT void cpSpaceEachShape(cpSpace *space, cpSpaceShapeIteratorFunc func, void *data); - -/// Space/constraint iterator callback function type. -typedef void (*cpSpaceConstraintIteratorFunc)(cpConstraint *constraint, void *data); -/// Call @c func for each shape in the space. -CP_EXPORT void cpSpaceEachConstraint(cpSpace *space, cpSpaceConstraintIteratorFunc func, void *data); - - -//MARK: Indexing - -/// Update the collision detection info for the static shapes in the space. -CP_EXPORT void cpSpaceReindexStatic(cpSpace *space); -/// Update the collision detection data for a specific shape in the space. -CP_EXPORT void cpSpaceReindexShape(cpSpace *space, cpShape *shape); -/// Update the collision detection data for all shapes attached to a body. -CP_EXPORT void cpSpaceReindexShapesForBody(cpSpace *space, cpBody *body); - -/// Switch the space to use a spatial has as it's spatial index. -CP_EXPORT void cpSpaceUseSpatialHash(cpSpace *space, cpFloat dim, int count); - - -//MARK: Time Stepping - -/// Step the space forward in time by @c dt. -CP_EXPORT void cpSpaceStep(cpSpace *space, cpFloat dt); - - -//MARK: Debug API - -#ifndef CP_SPACE_DISABLE_DEBUG_API - -/// Color type to use with the space debug drawing API. -typedef struct cpSpaceDebugColor { - float r, g, b, a; -} cpSpaceDebugColor; - -/// Callback type for a function that draws a filled, stroked circle. -typedef void (*cpSpaceDebugDrawCircleImpl)(cpVect pos, cpFloat angle, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data); -/// Callback type for a function that draws a line segment. -typedef void (*cpSpaceDebugDrawSegmentImpl)(cpVect a, cpVect b, cpSpaceDebugColor color, cpDataPointer data); -/// Callback type for a function that draws a thick line segment. -typedef void (*cpSpaceDebugDrawFatSegmentImpl)(cpVect a, cpVect b, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data); -/// Callback type for a function that draws a convex polygon. -typedef void (*cpSpaceDebugDrawPolygonImpl)(int count, const cpVect *verts, cpFloat radius, cpSpaceDebugColor outlineColor, cpSpaceDebugColor fillColor, cpDataPointer data); -/// Callback type for a function that draws a dot. -typedef void (*cpSpaceDebugDrawDotImpl)(cpFloat size, cpVect pos, cpSpaceDebugColor color, cpDataPointer data); -/// Callback type for a function that returns a color for a given shape. This gives you an opportunity to color shapes based on how they are used in your engine. -typedef cpSpaceDebugColor (*cpSpaceDebugDrawColorForShapeImpl)(cpShape *shape, cpDataPointer data); - -typedef enum cpSpaceDebugDrawFlags { - CP_SPACE_DEBUG_DRAW_SHAPES = 1<<0, - CP_SPACE_DEBUG_DRAW_CONSTRAINTS = 1<<1, - CP_SPACE_DEBUG_DRAW_COLLISION_POINTS = 1<<2, -} cpSpaceDebugDrawFlags; - -/// Struct used with cpSpaceDebugDraw() containing drawing callbacks and other drawing settings. -typedef struct cpSpaceDebugDrawOptions { - /// Function that will be invoked to draw circles. - cpSpaceDebugDrawCircleImpl drawCircle; - /// Function that will be invoked to draw line segments. - cpSpaceDebugDrawSegmentImpl drawSegment; - /// Function that will be invoked to draw thick line segments. - cpSpaceDebugDrawFatSegmentImpl drawFatSegment; - /// Function that will be invoked to draw convex polygons. - cpSpaceDebugDrawPolygonImpl drawPolygon; - /// Function that will be invoked to draw dots. - cpSpaceDebugDrawDotImpl drawDot; - - /// Flags that request which things to draw (collision shapes, constraints, contact points). - cpSpaceDebugDrawFlags flags; - /// Outline color passed to the drawing function. - cpSpaceDebugColor shapeOutlineColor; - /// Function that decides what fill color to draw shapes using. - cpSpaceDebugDrawColorForShapeImpl colorForShape; - /// Color passed to drawing functions for constraints. - cpSpaceDebugColor constraintColor; - /// Color passed to drawing functions for collision points. - cpSpaceDebugColor collisionPointColor; - - /// User defined context pointer passed to all of the callback functions as the 'data' argument. - cpDataPointer data; -} cpSpaceDebugDrawOptions; - -/// Debug draw the current state of the space using the supplied drawing options. -CP_EXPORT void cpSpaceDebugDraw(cpSpace *space, cpSpaceDebugDrawOptions *options); - -#endif - -/// @} diff --git a/android/armeabi/include/chipmunk/cpSpatialIndex.h b/android/armeabi/include/chipmunk/cpSpatialIndex.h deleted file mode 100644 index a386ba9a..00000000 --- a/android/armeabi/include/chipmunk/cpSpatialIndex.h +++ /dev/null @@ -1,227 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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. - */ - -/** - @defgroup cpSpatialIndex cpSpatialIndex - - Spatial indexes are data structures that are used to accelerate collision detection - and spatial queries. Chipmunk provides a number of spatial index algorithms to pick from - and they are programmed in a generic way so that you can use them for holding more than - just cpShape structs. - - It works by using @c void pointers to the objects you add and using a callback to ask your code - for bounding boxes when it needs them. Several types of queries can be performed an index as well - as reindexing and full collision information. All communication to the spatial indexes is performed - through callback functions. - - Spatial indexes should be treated as opaque structs. - This meanns you shouldn't be reading any of the struct fields. - @{ -*/ - -//MARK: Spatial Index - -/// Spatial index bounding box callback function type. -/// The spatial index calls this function and passes you a pointer to an object you added -/// when it needs to get the bounding box associated with that object. -typedef cpBB (*cpSpatialIndexBBFunc)(void *obj); -/// Spatial index/object iterator callback function type. -typedef void (*cpSpatialIndexIteratorFunc)(void *obj, void *data); -/// Spatial query callback function type. -typedef cpCollisionID (*cpSpatialIndexQueryFunc)(void *obj1, void *obj2, cpCollisionID id, void *data); -/// Spatial segment query callback function type. -typedef cpFloat (*cpSpatialIndexSegmentQueryFunc)(void *obj1, void *obj2, void *data); - - -typedef struct cpSpatialIndexClass cpSpatialIndexClass; -typedef struct cpSpatialIndex cpSpatialIndex; - -/// @private -struct cpSpatialIndex { - cpSpatialIndexClass *klass; - - cpSpatialIndexBBFunc bbfunc; - - cpSpatialIndex *staticIndex, *dynamicIndex; -}; - - -//MARK: Spatial Hash - -typedef struct cpSpaceHash cpSpaceHash; - -/// Allocate a spatial hash. -CP_EXPORT cpSpaceHash* cpSpaceHashAlloc(void); -/// Initialize a spatial hash. -CP_EXPORT cpSpatialIndex* cpSpaceHashInit(cpSpaceHash *hash, cpFloat celldim, int numcells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); -/// Allocate and initialize a spatial hash. -CP_EXPORT cpSpatialIndex* cpSpaceHashNew(cpFloat celldim, int cells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); - -/// Change the cell dimensions and table size of the spatial hash to tune it. -/// The cell dimensions should roughly match the average size of your objects -/// and the table size should be ~10 larger than the number of objects inserted. -/// Some trial and error is required to find the optimum numbers for efficiency. -CP_EXPORT void cpSpaceHashResize(cpSpaceHash *hash, cpFloat celldim, int numcells); - -//MARK: AABB Tree - -typedef struct cpBBTree cpBBTree; - -/// Allocate a bounding box tree. -CP_EXPORT cpBBTree* cpBBTreeAlloc(void); -/// Initialize a bounding box tree. -CP_EXPORT cpSpatialIndex* cpBBTreeInit(cpBBTree *tree, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); -/// Allocate and initialize a bounding box tree. -CP_EXPORT cpSpatialIndex* cpBBTreeNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); - -/// Perform a static top down optimization of the tree. -CP_EXPORT void cpBBTreeOptimize(cpSpatialIndex *index); - -/// Bounding box tree velocity callback function. -/// This function should return an estimate for the object's velocity. -typedef cpVect (*cpBBTreeVelocityFunc)(void *obj); -/// Set the velocity function for the bounding box tree to enable temporal coherence. -CP_EXPORT void cpBBTreeSetVelocityFunc(cpSpatialIndex *index, cpBBTreeVelocityFunc func); - -//MARK: Single Axis Sweep - -typedef struct cpSweep1D cpSweep1D; - -/// Allocate a 1D sort and sweep broadphase. -CP_EXPORT cpSweep1D* cpSweep1DAlloc(void); -/// Initialize a 1D sort and sweep broadphase. -CP_EXPORT cpSpatialIndex* cpSweep1DInit(cpSweep1D *sweep, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); -/// Allocate and initialize a 1D sort and sweep broadphase. -CP_EXPORT cpSpatialIndex* cpSweep1DNew(cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex); - -//MARK: Spatial Index Implementation - -typedef void (*cpSpatialIndexDestroyImpl)(cpSpatialIndex *index); - -typedef int (*cpSpatialIndexCountImpl)(cpSpatialIndex *index); -typedef void (*cpSpatialIndexEachImpl)(cpSpatialIndex *index, cpSpatialIndexIteratorFunc func, void *data); - -typedef cpBool (*cpSpatialIndexContainsImpl)(cpSpatialIndex *index, void *obj, cpHashValue hashid); -typedef void (*cpSpatialIndexInsertImpl)(cpSpatialIndex *index, void *obj, cpHashValue hashid); -typedef void (*cpSpatialIndexRemoveImpl)(cpSpatialIndex *index, void *obj, cpHashValue hashid); - -typedef void (*cpSpatialIndexReindexImpl)(cpSpatialIndex *index); -typedef void (*cpSpatialIndexReindexObjectImpl)(cpSpatialIndex *index, void *obj, cpHashValue hashid); -typedef void (*cpSpatialIndexReindexQueryImpl)(cpSpatialIndex *index, cpSpatialIndexQueryFunc func, void *data); - -typedef void (*cpSpatialIndexQueryImpl)(cpSpatialIndex *index, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data); -typedef void (*cpSpatialIndexSegmentQueryImpl)(cpSpatialIndex *index, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data); - -struct cpSpatialIndexClass { - cpSpatialIndexDestroyImpl destroy; - - cpSpatialIndexCountImpl count; - cpSpatialIndexEachImpl each; - - cpSpatialIndexContainsImpl contains; - cpSpatialIndexInsertImpl insert; - cpSpatialIndexRemoveImpl remove; - - cpSpatialIndexReindexImpl reindex; - cpSpatialIndexReindexObjectImpl reindexObject; - cpSpatialIndexReindexQueryImpl reindexQuery; - - cpSpatialIndexQueryImpl query; - cpSpatialIndexSegmentQueryImpl segmentQuery; -}; - -/// Destroy and free a spatial index. -void cpSpatialIndexFree(cpSpatialIndex *index); -/// Collide the objects in @c dynamicIndex against the objects in @c staticIndex using the query callback function. -void cpSpatialIndexCollideStatic(cpSpatialIndex *dynamicIndex, cpSpatialIndex *staticIndex, cpSpatialIndexQueryFunc func, void *data); - -/// Destroy a spatial index. -static inline void cpSpatialIndexDestroy(cpSpatialIndex *index) -{ - if(index->klass) index->klass->destroy(index); -} - -/// Get the number of objects in the spatial index. -static inline int cpSpatialIndexCount(cpSpatialIndex *index) -{ - return index->klass->count(index); -} - -/// Iterate the objects in the spatial index. @c func will be called once for each object. -static inline void cpSpatialIndexEach(cpSpatialIndex *index, cpSpatialIndexIteratorFunc func, void *data) -{ - index->klass->each(index, func, data); -} - -/// Returns true if the spatial index contains the given object. -/// Most spatial indexes use hashed storage, so you must provide a hash value too. -static inline cpBool cpSpatialIndexContains(cpSpatialIndex *index, void *obj, cpHashValue hashid) -{ - return index->klass->contains(index, obj, hashid); -} - -/// Add an object to a spatial index. -/// Most spatial indexes use hashed storage, so you must provide a hash value too. -static inline void cpSpatialIndexInsert(cpSpatialIndex *index, void *obj, cpHashValue hashid) -{ - index->klass->insert(index, obj, hashid); -} - -/// Remove an object from a spatial index. -/// Most spatial indexes use hashed storage, so you must provide a hash value too. -static inline void cpSpatialIndexRemove(cpSpatialIndex *index, void *obj, cpHashValue hashid) -{ - index->klass->remove(index, obj, hashid); -} - -/// Perform a full reindex of a spatial index. -static inline void cpSpatialIndexReindex(cpSpatialIndex *index) -{ - index->klass->reindex(index); -} - -/// Reindex a single object in the spatial index. -static inline void cpSpatialIndexReindexObject(cpSpatialIndex *index, void *obj, cpHashValue hashid) -{ - index->klass->reindexObject(index, obj, hashid); -} - -/// Perform a rectangle query against the spatial index, calling @c func for each potential match. -static inline void cpSpatialIndexQuery(cpSpatialIndex *index, void *obj, cpBB bb, cpSpatialIndexQueryFunc func, void *data) -{ - index->klass->query(index, obj, bb, func, data); -} - -/// Perform a segment query against the spatial index, calling @c func for each potential match. -static inline void cpSpatialIndexSegmentQuery(cpSpatialIndex *index, void *obj, cpVect a, cpVect b, cpFloat t_exit, cpSpatialIndexSegmentQueryFunc func, void *data) -{ - index->klass->segmentQuery(index, obj, a, b, t_exit, func, data); -} - -/// Simultaneously reindex and find all colliding objects. -/// @c func will be called once for each potentially overlapping pair of objects found. -/// If the spatial index was initialized with a static index, it will collide it's objects against that as well. -static inline void cpSpatialIndexReindexQuery(cpSpatialIndex *index, cpSpatialIndexQueryFunc func, void *data) -{ - index->klass->reindexQuery(index, func, data); -} - -///@} diff --git a/android/armeabi/include/chipmunk/cpTransform.h b/android/armeabi/include/chipmunk/cpTransform.h deleted file mode 100644 index 4a6256b9..00000000 --- a/android/armeabi/include/chipmunk/cpTransform.h +++ /dev/null @@ -1,198 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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 CHIPMUNK_TRANSFORM_H -#define CHIPMUNK_TRANSFORM_H - -#include "chipmunk_types.h" -#include "cpVect.h" -#include "cpBB.h" - -/// Identity transform matrix. -static const cpTransform cpTransformIdentity = {1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f}; - -/// Construct a new transform matrix. -/// (a, b) is the x basis vector. -/// (c, d) is the y basis vector. -/// (tx, ty) is the translation. -static inline cpTransform -cpTransformNew(cpFloat a, cpFloat b, cpFloat c, cpFloat d, cpFloat tx, cpFloat ty) -{ - cpTransform t = {a, b, c, d, tx, ty}; - return t; -} - -/// Construct a new transform matrix in transposed order. -static inline cpTransform -cpTransformNewTranspose(cpFloat a, cpFloat c, cpFloat tx, cpFloat b, cpFloat d, cpFloat ty) -{ - cpTransform t = {a, b, c, d, tx, ty}; - return t; -} - -/// Get the inverse of a transform matrix. -static inline cpTransform -cpTransformInverse(cpTransform t) -{ - cpFloat inv_det = 1.0/(t.a*t.d - t.c*t.b); - return cpTransformNewTranspose( - t.d*inv_det, -t.c*inv_det, (t.c*t.ty - t.tx*t.d)*inv_det, - -t.b*inv_det, t.a*inv_det, (t.tx*t.b - t.a*t.ty)*inv_det - ); -} - -/// Multiply two transformation matrices. -static inline cpTransform -cpTransformMult(cpTransform t1, cpTransform t2) -{ - return cpTransformNewTranspose( - t1.a*t2.a + t1.c*t2.b, t1.a*t2.c + t1.c*t2.d, t1.a*t2.tx + t1.c*t2.ty + t1.tx, - t1.b*t2.a + t1.d*t2.b, t1.b*t2.c + t1.d*t2.d, t1.b*t2.tx + t1.d*t2.ty + t1.ty - ); -} - -/// Transform an absolute point. (i.e. a vertex) -static inline cpVect -cpTransformPoint(cpTransform t, cpVect p) -{ - return cpv(t.a*p.x + t.c*p.y + t.tx, t.b*p.x + t.d*p.y + t.ty); -} - -/// Transform a vector (i.e. a normal) -static inline cpVect -cpTransformVect(cpTransform t, cpVect v) -{ - return cpv(t.a*v.x + t.c*v.y, t.b*v.x + t.d*v.y); -} - -/// Transform a cpBB. -static inline cpBB -cpTransformbBB(cpTransform t, cpBB bb) -{ - cpVect center = cpBBCenter(bb); - cpFloat hw = (bb.r - bb.l)*0.5; - cpFloat hh = (bb.t - bb.b)*0.5; - - cpFloat a = t.a*hw, b = t.c*hh, d = t.b*hw, e = t.d*hh; - cpFloat hw_max = cpfmax(cpfabs(a + b), cpfabs(a - b)); - cpFloat hh_max = cpfmax(cpfabs(d + e), cpfabs(d - e)); - return cpBBNewForExtents(cpTransformPoint(t, center), hw_max, hh_max); -} - -/// Create a transation matrix. -static inline cpTransform -cpTransformTranslate(cpVect translate) -{ - return cpTransformNewTranspose( - 1.0, 0.0, translate.x, - 0.0, 1.0, translate.y - ); -} - -/// Create a scale matrix. -static inline cpTransform -cpTransformScale(cpFloat scaleX, cpFloat scaleY) -{ - return cpTransformNewTranspose( - scaleX, 0.0, 0.0, - 0.0, scaleY, 0.0 - ); -} - -/// Create a rotation matrix. -static inline cpTransform -cpTransformRotate(cpFloat radians) -{ - cpVect rot = cpvforangle(radians); - return cpTransformNewTranspose( - rot.x, -rot.y, 0.0, - rot.y, rot.x, 0.0 - ); -} - -/// Create a rigid transformation matrix. (transation + rotation) -static inline cpTransform -cpTransformRigid(cpVect translate, cpFloat radians) -{ - cpVect rot = cpvforangle(radians); - return cpTransformNewTranspose( - rot.x, -rot.y, translate.x, - rot.y, rot.x, translate.y - ); -} - -/// Fast inverse of a rigid transformation matrix. -static inline cpTransform -cpTransformRigidInverse(cpTransform t) -{ - return cpTransformNewTranspose( - t.d, -t.c, (t.c*t.ty - t.tx*t.d), - -t.b, t.a, (t.tx*t.b - t.a*t.ty) - ); -} - -//MARK: Miscellaneous (but useful) transformation matrices. -// See source for documentation... - -static inline cpTransform -cpTransformWrap(cpTransform outer, cpTransform inner) -{ - return cpTransformMult(cpTransformInverse(outer), cpTransformMult(inner, outer)); -} - -static inline cpTransform -cpTransformWrapInverse(cpTransform outer, cpTransform inner) -{ - return cpTransformMult(outer, cpTransformMult(inner, cpTransformInverse(outer))); -} - -static inline cpTransform -cpTransformOrtho(cpBB bb) -{ - return cpTransformNewTranspose( - 2.0/(bb.r - bb.l), 0.0, -(bb.r + bb.l)/(bb.r - bb.l), - 0.0, 2.0/(bb.t - bb.b), -(bb.t + bb.b)/(bb.t - bb.b) - ); -} - -static inline cpTransform -cpTransformBoneScale(cpVect v0, cpVect v1) -{ - cpVect d = cpvsub(v1, v0); - return cpTransformNewTranspose( - d.x, -d.y, v0.x, - d.y, d.x, v0.y - ); -} - -static inline cpTransform -cpTransformAxialScale(cpVect axis, cpVect pivot, cpFloat scale) -{ - cpFloat A = axis.x*axis.y*(scale - 1.0); - cpFloat B = cpvdot(axis, pivot)*(1.0 - scale); - - return cpTransformNewTranspose( - scale*axis.x*axis.x + axis.y*axis.y, A, axis.x*B, - A, axis.x*axis.x + scale*axis.y*axis.y, axis.y*B - ); -} - -#endif diff --git a/android/armeabi/include/chipmunk/cpVect.h b/android/armeabi/include/chipmunk/cpVect.h deleted file mode 100644 index 8ec02bdc..00000000 --- a/android/armeabi/include/chipmunk/cpVect.h +++ /dev/null @@ -1,230 +0,0 @@ -/* Copyright (c) 2013 Scott Lembcke and Howling Moon Software - * - * 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 CHIPMUNK_VECT_H -#define CHIPMUNK_VECT_H - -#include "chipmunk_types.h" - -/// @defgroup cpVect cpVect -/// Chipmunk's 2D vector type along with a handy 2D vector math lib. -/// @{ - -/// Constant for the zero vector. -static const cpVect cpvzero = {0.0f,0.0f}; - -/// Convenience constructor for cpVect structs. -static inline cpVect cpv(const cpFloat x, const cpFloat y) -{ - cpVect v = {x, y}; - return v; -} - -/// Check if two vectors are equal. (Be careful when comparing floating point numbers!) -static inline cpBool cpveql(const cpVect v1, const cpVect v2) -{ - return (v1.x == v2.x && v1.y == v2.y); -} - -/// Add two vectors -static inline cpVect cpvadd(const cpVect v1, const cpVect v2) -{ - return cpv(v1.x + v2.x, v1.y + v2.y); -} - -/// Subtract two vectors. -static inline cpVect cpvsub(const cpVect v1, const cpVect v2) -{ - return cpv(v1.x - v2.x, v1.y - v2.y); -} - -/// Negate a vector. -static inline cpVect cpvneg(const cpVect v) -{ - return cpv(-v.x, -v.y); -} - -/// Scalar multiplication. -static inline cpVect cpvmult(const cpVect v, const cpFloat s) -{ - return cpv(v.x*s, v.y*s); -} - -/// Vector dot product. -static inline cpFloat cpvdot(const cpVect v1, const cpVect v2) -{ - return v1.x*v2.x + v1.y*v2.y; -} - -/// 2D vector cross product analog. -/// The cross product of 2D vectors results in a 3D vector with only a z component. -/// This function returns the magnitude of the z value. -static inline cpFloat cpvcross(const cpVect v1, const cpVect v2) -{ - return v1.x*v2.y - v1.y*v2.x; -} - -/// Returns a perpendicular vector. (90 degree rotation) -static inline cpVect cpvperp(const cpVect v) -{ - return cpv(-v.y, v.x); -} - -/// Returns a perpendicular vector. (-90 degree rotation) -static inline cpVect cpvrperp(const cpVect v) -{ - return cpv(v.y, -v.x); -} - -/// Returns the vector projection of v1 onto v2. -static inline cpVect cpvproject(const cpVect v1, const cpVect v2) -{ - return cpvmult(v2, cpvdot(v1, v2)/cpvdot(v2, v2)); -} - -/// Returns the unit length vector for the given angle (in radians). -static inline cpVect cpvforangle(const cpFloat a) -{ - return cpv(cpfcos(a), cpfsin(a)); -} - -/// Returns the angular direction v is pointing in (in radians). -static inline cpFloat cpvtoangle(const cpVect v) -{ - return cpfatan2(v.y, v.x); -} - -/// Uses complex number multiplication to rotate v1 by v2. Scaling will occur if v1 is not a unit vector. -static inline cpVect cpvrotate(const cpVect v1, const cpVect v2) -{ - return cpv(v1.x*v2.x - v1.y*v2.y, v1.x*v2.y + v1.y*v2.x); -} - -/// Inverse of cpvrotate(). -static inline cpVect cpvunrotate(const cpVect v1, const cpVect v2) -{ - return cpv(v1.x*v2.x + v1.y*v2.y, v1.y*v2.x - v1.x*v2.y); -} - -/// Returns the squared length of v. Faster than cpvlength() when you only need to compare lengths. -static inline cpFloat cpvlengthsq(const cpVect v) -{ - return cpvdot(v, v); -} - -/// Returns the length of v. -static inline cpFloat cpvlength(const cpVect v) -{ - return cpfsqrt(cpvdot(v, v)); -} - -/// Linearly interpolate between v1 and v2. -static inline cpVect cpvlerp(const cpVect v1, const cpVect v2, const cpFloat t) -{ - return cpvadd(cpvmult(v1, 1.0f - t), cpvmult(v2, t)); -} - -/// Returns a normalized copy of v. -static inline cpVect cpvnormalize(const cpVect v) -{ - // Neat trick I saw somewhere to avoid div/0. - return cpvmult(v, 1.0f/(cpvlength(v) + CPFLOAT_MIN)); -} - -/// Spherical linearly interpolate between v1 and v2. -static inline cpVect -cpvslerp(const cpVect v1, const cpVect v2, const cpFloat t) -{ - cpFloat dot = cpvdot(cpvnormalize(v1), cpvnormalize(v2)); - cpFloat omega = cpfacos(cpfclamp(dot, -1.0f, 1.0f)); - - if(omega < 1e-3){ - // If the angle between two vectors is very small, lerp instead to avoid precision issues. - return cpvlerp(v1, v2, t); - } else { - cpFloat denom = 1.0f/cpfsin(omega); - return cpvadd(cpvmult(v1, cpfsin((1.0f - t)*omega)*denom), cpvmult(v2, cpfsin(t*omega)*denom)); - } -} - -/// Spherical linearly interpolate between v1 towards v2 by no more than angle a radians -static inline cpVect -cpvslerpconst(const cpVect v1, const cpVect v2, const cpFloat a) -{ - cpFloat dot = cpvdot(cpvnormalize(v1), cpvnormalize(v2)); - cpFloat omega = cpfacos(cpfclamp(dot, -1.0f, 1.0f)); - - return cpvslerp(v1, v2, cpfmin(a, omega)/omega); -} - -/// Clamp v to length len. -static inline cpVect cpvclamp(const cpVect v, const cpFloat len) -{ - return (cpvdot(v,v) > len*len) ? cpvmult(cpvnormalize(v), len) : v; -} - -/// Linearly interpolate between v1 towards v2 by distance d. -static inline cpVect cpvlerpconst(cpVect v1, cpVect v2, cpFloat d) -{ - return cpvadd(v1, cpvclamp(cpvsub(v2, v1), d)); -} - -/// Returns the distance between v1 and v2. -static inline cpFloat cpvdist(const cpVect v1, const cpVect v2) -{ - return cpvlength(cpvsub(v1, v2)); -} - -/// Returns the squared distance between v1 and v2. Faster than cpvdist() when you only need to compare distances. -static inline cpFloat cpvdistsq(const cpVect v1, const cpVect v2) -{ - return cpvlengthsq(cpvsub(v1, v2)); -} - -/// Returns true if the distance between v1 and v2 is less than dist. -static inline cpBool cpvnear(const cpVect v1, const cpVect v2, const cpFloat dist) -{ - return cpvdistsq(v1, v2) < dist*dist; -} - -/// @} - -/// @defgroup cpMat2x2 cpMat2x2 -/// 2x2 matrix type used for tensors and such. -/// @{ - -// NUKE -static inline cpMat2x2 -cpMat2x2New(cpFloat a, cpFloat b, cpFloat c, cpFloat d) -{ - cpMat2x2 m = {a, b, c, d}; - return m; -} - -static inline cpVect -cpMat2x2Transform(cpMat2x2 m, cpVect v) -{ - return cpv(v.x*m.a + v.y*m.b, v.x*m.c + v.y*m.d); -} - -///@} - -#endif diff --git a/android/armeabi/include/freetype/config/ftconfig.h b/android/armeabi/include/freetype/config/ftconfig.h deleted file mode 100644 index cb9e0a41..00000000 --- a/android/armeabi/include/freetype/config/ftconfig.h +++ /dev/null @@ -1,504 +0,0 @@ -/* ftconfig.h. Generated from ftconfig.in by configure. */ -/***************************************************************************/ -/* */ -/* ftconfig.in */ -/* */ -/* UNIX-specific configuration file (specification only). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This header file contains a number of macro definitions that are used */ - /* by the rest of the engine. Most of the macros here are automatically */ - /* determined at compile time, and you should not need to change it to */ - /* port FreeType, except to compile the library with a non-ANSI */ - /* compiler. */ - /* */ - /* Note however that if some specific modifications are needed, we */ - /* advise you to place a modified copy in your build directory. */ - /* */ - /* The build directory is usually `builds/', and contains */ - /* system-specific files that are always included first when building */ - /* the library. */ - /* */ - /*************************************************************************/ - - -#ifndef FTCONFIG_H_ -#define FTCONFIG_H_ - -#include -#include FT_CONFIG_OPTIONS_H -#include FT_CONFIG_STANDARD_LIBRARY_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* PLATFORM-SPECIFIC CONFIGURATION MACROS */ - /* */ - /* These macros can be toggled to suit a specific system. The current */ - /* ones are defaults used to compile FreeType in an ANSI C environment */ - /* (16bit compilers are also supported). Copy this file to your own */ - /* `builds/' directory, and edit it to port the engine. */ - /* */ - /*************************************************************************/ - - -#define HAVE_UNISTD_H 1 -#define HAVE_FCNTL_H 1 -#define HAVE_STDINT_H 1 - - - /* There are systems (like the Texas Instruments 'C54x) where a `char' */ - /* has 16 bits. ANSI C says that sizeof(char) is always 1. Since an */ - /* `int' has 16 bits also for this system, sizeof(int) gives 1 which */ - /* is probably unexpected. */ - /* */ - /* `CHAR_BIT' (defined in limits.h) gives the number of bits in a */ - /* `char' type. */ - -#ifndef FT_CHAR_BIT -#define FT_CHAR_BIT CHAR_BIT -#endif - - -/* #undef FT_USE_AUTOCONF_SIZEOF_TYPES */ -#ifdef FT_USE_AUTOCONF_SIZEOF_TYPES - -#define SIZEOF_INT 4 -#define SIZEOF_LONG 4 -#define FT_SIZEOF_INT SIZEOF_INT -#define FT_SIZEOF_LONG SIZEOF_LONG - -#else /* !FT_USE_AUTOCONF_SIZEOF_TYPES */ - - /* Following cpp computation of the bit length of int and long */ - /* is copied from default include/freetype/config/ftconfig.h. */ - /* If any improvement is required for this file, it should be */ - /* applied to the original header file for the builders that */ - /* do not use configure script. */ - - /* The size of an `int' type. */ -#if FT_UINT_MAX == 0xFFFFUL -#define FT_SIZEOF_INT (16 / FT_CHAR_BIT) -#elif FT_UINT_MAX == 0xFFFFFFFFUL -#define FT_SIZEOF_INT (32 / FT_CHAR_BIT) -#elif FT_UINT_MAX > 0xFFFFFFFFUL && FT_UINT_MAX == 0xFFFFFFFFFFFFFFFFUL -#define FT_SIZEOF_INT (64 / FT_CHAR_BIT) -#else -#error "Unsupported size of `int' type!" -#endif - - /* The size of a `long' type. A five-byte `long' (as used e.g. on the */ - /* DM642) is recognized but avoided. */ -#if FT_ULONG_MAX == 0xFFFFFFFFUL -#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT) -#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFUL -#define FT_SIZEOF_LONG (32 / FT_CHAR_BIT) -#elif FT_ULONG_MAX > 0xFFFFFFFFUL && FT_ULONG_MAX == 0xFFFFFFFFFFFFFFFFUL -#define FT_SIZEOF_LONG (64 / FT_CHAR_BIT) -#else -#error "Unsupported size of `long' type!" -#endif - -#endif /* !FT_USE_AUTOCONF_SIZEOF_TYPES */ - - - /* FT_UNUSED is a macro used to indicate that a given parameter is not */ - /* used -- this is only used to get rid of unpleasant compiler warnings */ -#ifndef FT_UNUSED -#define FT_UNUSED( arg ) ( (arg) = (arg) ) -#endif - - - /*************************************************************************/ - /* */ - /* AUTOMATIC CONFIGURATION MACROS */ - /* */ - /* These macros are computed from the ones defined above. Don't touch */ - /* their definition, unless you know precisely what you are doing. No */ - /* porter should need to mess with them. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Mac support */ - /* */ - /* This is the only necessary change, so it is defined here instead */ - /* providing a new configuration file. */ - /* */ -#if defined( __APPLE__ ) || ( defined( __MWERKS__ ) && defined( macintosh ) ) - /* no Carbon frameworks for 64bit 10.4.x */ - /* AvailabilityMacros.h is available since Mac OS X 10.2, */ - /* so guess the system version by maximum errno before inclusion */ -#include -#ifdef ECANCELED /* defined since 10.2 */ -#include "AvailabilityMacros.h" -#endif -#if defined( __LP64__ ) && \ - ( MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4 ) -#undef FT_MACINTOSH -#endif - -#elif defined( __SC__ ) || defined( __MRC__ ) - /* Classic MacOS compilers */ -#include "ConditionalMacros.h" -#if TARGET_OS_MAC -#define FT_MACINTOSH 1 -#endif - -#endif - - - /* Fix compiler warning with sgi compiler */ -#if defined( __sgi ) && !defined( __GNUC__ ) -#if defined( _COMPILER_VERSION ) && ( _COMPILER_VERSION >= 730 ) -#pragma set woff 3505 -#endif -#endif - - - /*************************************************************************/ - /* */ - /*
*/ - /* basic_types */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Int16 */ - /* */ - /* */ - /* A typedef for a 16bit signed integer type. */ - /* */ - typedef signed short FT_Int16; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt16 */ - /* */ - /* */ - /* A typedef for a 16bit unsigned integer type. */ - /* */ - typedef unsigned short FT_UInt16; - - /* */ - - - /* this #if 0 ... #endif clause is for documentation purposes */ -#if 0 - - /*************************************************************************/ - /* */ - /* */ - /* FT_Int32 */ - /* */ - /* */ - /* A typedef for a 32bit signed integer type. The size depends on */ - /* the configuration. */ - /* */ - typedef signed XXX FT_Int32; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt32 */ - /* */ - /* A typedef for a 32bit unsigned integer type. The size depends on */ - /* the configuration. */ - /* */ - typedef unsigned XXX FT_UInt32; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_Int64 */ - /* */ - /* A typedef for a 64bit signed integer type. The size depends on */ - /* the configuration. Only defined if there is real 64bit support; */ - /* otherwise, it gets emulated with a structure (if necessary). */ - /* */ - typedef signed XXX FT_Int64; - - - /*************************************************************************/ - /* */ - /* */ - /* FT_UInt64 */ - /* */ - /* A typedef for a 64bit unsigned integer type. The size depends on */ - /* the configuration. Only defined if there is real 64bit support; */ - /* otherwise, it gets emulated with a structure (if necessary). */ - /* */ - typedef unsigned XXX FT_UInt64; - - /* */ - -#endif - -#if FT_SIZEOF_INT == 4 - - typedef signed int FT_Int32; - typedef unsigned int FT_UInt32; - -#elif FT_SIZEOF_LONG == 4 - - typedef signed long FT_Int32; - typedef unsigned long FT_UInt32; - -#else -#error "no 32bit type found -- please check your configuration files" -#endif - - - /* look up an integer type that is at least 32 bits */ -#if FT_SIZEOF_INT >= 4 - - typedef int FT_Fast; - typedef unsigned int FT_UFast; - -#elif FT_SIZEOF_LONG >= 4 - - typedef long FT_Fast; - typedef unsigned long FT_UFast; - -#endif - - - /* determine whether we have a 64-bit int type for platforms without */ - /* Autoconf */ -#if FT_SIZEOF_LONG == 8 - - /* FT_LONG64 must be defined if a 64-bit type is available */ -#define FT_LONG64 -#define FT_INT64 long -#define FT_UINT64 unsigned long - - /*************************************************************************/ - /* */ - /* A 64-bit data type may create compilation problems if you compile */ - /* in strict ANSI mode. To avoid them, we disable other 64-bit data */ - /* types if __STDC__ is defined. You can however ignore this rule */ - /* by defining the FT_CONFIG_OPTION_FORCE_INT64 configuration macro. */ - /* */ -#elif !defined( __STDC__ ) || defined( FT_CONFIG_OPTION_FORCE_INT64 ) - -#if defined( __STDC_VERSION__ ) && __STDC_VERSION__ >= 199901L - -#define FT_LONG64 -#define FT_INT64 long long int -#define FT_UINT64 unsigned long long int - -#elif defined( _MSC_VER ) && _MSC_VER >= 900 /* Visual C++ (and Intel C++) */ - - /* this compiler provides the __int64 type */ -#define FT_LONG64 -#define FT_INT64 __int64 -#define FT_UINT64 unsigned __int64 - -#elif defined( __BORLANDC__ ) /* Borland C++ */ - - /* XXXX: We should probably check the value of __BORLANDC__ in order */ - /* to test the compiler version. */ - - /* this compiler provides the __int64 type */ -#define FT_LONG64 -#define FT_INT64 __int64 -#define FT_UINT64 unsigned __int64 - -#elif defined( __WATCOMC__ ) /* Watcom C++ */ - - /* Watcom doesn't provide 64-bit data types */ - -#elif defined( __MWERKS__ ) /* Metrowerks CodeWarrior */ - -#define FT_LONG64 -#define FT_INT64 long long int -#define FT_UINT64 unsigned long long int - -#elif defined( __GNUC__ ) - - /* GCC provides the `long long' type */ -#define FT_LONG64 -#define FT_INT64 long long int -#define FT_UINT64 unsigned long long int - -#endif /* __STDC_VERSION__ >= 199901L */ - -#endif /* FT_SIZEOF_LONG == 8 */ - -#ifdef FT_LONG64 - typedef FT_INT64 FT_Int64; - typedef FT_UINT64 FT_UInt64; -#endif - - - /*************************************************************************/ - /* */ - /* miscellaneous */ - /* */ - /*************************************************************************/ - - -#define FT_BEGIN_STMNT do { -#define FT_END_STMNT } while ( 0 ) -#define FT_DUMMY_STMNT FT_BEGIN_STMNT FT_END_STMNT - - - /* typeof condition taken from gnulib's `intprops.h' header file */ -#if ( __GNUC__ >= 2 || \ - defined( __IBM__TYPEOF__ ) || \ - ( __SUNPRO_C >= 0x5110 && !__STDC__ ) ) -#define FT_TYPEOF( type ) (__typeof__ (type)) -#else -#define FT_TYPEOF( type ) /* empty */ -#endif - - -#ifdef FT_MAKE_OPTION_SINGLE_OBJECT - -#define FT_LOCAL( x ) static x -#define FT_LOCAL_DEF( x ) static x - -#else - -#ifdef __cplusplus -#define FT_LOCAL( x ) extern "C" x -#define FT_LOCAL_DEF( x ) extern "C" x -#else -#define FT_LOCAL( x ) extern x -#define FT_LOCAL_DEF( x ) x -#endif - -#endif /* FT_MAKE_OPTION_SINGLE_OBJECT */ - -#define FT_LOCAL_ARRAY( x ) extern const x -#define FT_LOCAL_ARRAY_DEF( x ) const x - - -#ifndef FT_BASE - -#ifdef __cplusplus -#define FT_BASE( x ) extern "C" x -#else -#define FT_BASE( x ) extern x -#endif - -#endif /* !FT_BASE */ - - -#ifndef FT_BASE_DEF - -#ifdef __cplusplus -#define FT_BASE_DEF( x ) x -#else -#define FT_BASE_DEF( x ) x -#endif - -#endif /* !FT_BASE_DEF */ - - -#ifndef FT_EXPORT - -#ifdef __cplusplus -#define FT_EXPORT( x ) extern "C" x -#else -#define FT_EXPORT( x ) extern x -#endif - -#endif /* !FT_EXPORT */ - - -#ifndef FT_EXPORT_DEF - -#ifdef __cplusplus -#define FT_EXPORT_DEF( x ) extern "C" x -#else -#define FT_EXPORT_DEF( x ) extern x -#endif - -#endif /* !FT_EXPORT_DEF */ - - -#ifndef FT_EXPORT_VAR - -#ifdef __cplusplus -#define FT_EXPORT_VAR( x ) extern "C" x -#else -#define FT_EXPORT_VAR( x ) extern x -#endif - -#endif /* !FT_EXPORT_VAR */ - - /* The following macros are needed to compile the library with a */ - /* C++ compiler and with 16bit compilers. */ - /* */ - - /* This is special. Within C++, you must specify `extern "C"' for */ - /* functions which are used via function pointers, and you also */ - /* must do that for structures which contain function pointers to */ - /* assure C linkage -- it's not possible to have (local) anonymous */ - /* functions which are accessed by (global) function pointers. */ - /* */ - /* */ - /* FT_CALLBACK_DEF is used to _define_ a callback function. */ - /* */ - /* FT_CALLBACK_TABLE is used to _declare_ a constant variable that */ - /* contains pointers to callback functions. */ - /* */ - /* FT_CALLBACK_TABLE_DEF is used to _define_ a constant variable */ - /* that contains pointers to callback functions. */ - /* */ - /* */ - /* Some 16bit compilers have to redefine these macros to insert */ - /* the infamous `_cdecl' or `__fastcall' declarations. */ - /* */ -#ifndef FT_CALLBACK_DEF -#ifdef __cplusplus -#define FT_CALLBACK_DEF( x ) extern "C" x -#else -#define FT_CALLBACK_DEF( x ) static x -#endif -#endif /* FT_CALLBACK_DEF */ - -#ifndef FT_CALLBACK_TABLE -#ifdef __cplusplus -#define FT_CALLBACK_TABLE extern "C" -#define FT_CALLBACK_TABLE_DEF extern "C" -#else -#define FT_CALLBACK_TABLE extern -#define FT_CALLBACK_TABLE_DEF /* nothing */ -#endif -#endif /* FT_CALLBACK_TABLE */ - - -FT_END_HEADER - - -#endif /* FTCONFIG_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/config/ftheader.h b/android/armeabi/include/freetype/config/ftheader.h deleted file mode 100644 index 68e14834..00000000 --- a/android/armeabi/include/freetype/config/ftheader.h +++ /dev/null @@ -1,833 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftheader.h */ -/* */ -/* Build macros of the FreeType 2 library. */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -#ifndef FTHEADER_H_ -#define FTHEADER_H_ - - - /*@***********************************************************************/ - /* */ - /* */ - /* FT_BEGIN_HEADER */ - /* */ - /* */ - /* This macro is used in association with @FT_END_HEADER in header */ - /* files to ensure that the declarations within are properly */ - /* encapsulated in an `extern "C" { .. }' block when included from a */ - /* C++ compiler. */ - /* */ -#ifdef __cplusplus -#define FT_BEGIN_HEADER extern "C" { -#else -#define FT_BEGIN_HEADER /* nothing */ -#endif - - - /*@***********************************************************************/ - /* */ - /* */ - /* FT_END_HEADER */ - /* */ - /* */ - /* This macro is used in association with @FT_BEGIN_HEADER in header */ - /* files to ensure that the declarations within are properly */ - /* encapsulated in an `extern "C" { .. }' block when included from a */ - /* C++ compiler. */ - /* */ -#ifdef __cplusplus -#define FT_END_HEADER } -#else -#define FT_END_HEADER /* nothing */ -#endif - - - /*************************************************************************/ - /* */ - /* Aliases for the FreeType 2 public and configuration files. */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /*
*/ - /* header_file_macros */ - /* */ - /* */ - /* Header File Macros */ - /* */ - /* <Abstract> */ - /* Macro definitions used to #include specific header files. */ - /* */ - /* <Description> */ - /* The following macros are defined to the name of specific */ - /* FreeType~2 header files. They can be used directly in #include */ - /* statements as in: */ - /* */ - /* { */ - /* #include FT_FREETYPE_H */ - /* #include FT_MULTIPLE_MASTERS_H */ - /* #include FT_GLYPH_H */ - /* } */ - /* */ - /* There are several reasons why we are now using macros to name */ - /* public header files. The first one is that such macros are not */ - /* limited to the infamous 8.3~naming rule required by DOS (and */ - /* `FT_MULTIPLE_MASTERS_H' is a lot more meaningful than `ftmm.h'). */ - /* */ - /* The second reason is that it allows for more flexibility in the */ - /* way FreeType~2 is installed on a given system. */ - /* */ - /*************************************************************************/ - - - /* configuration files */ - - /************************************************************************* - * - * @macro: - * FT_CONFIG_CONFIG_H - * - * @description: - * A macro used in #include statements to name the file containing - * FreeType~2 configuration data. - * - */ -#ifndef FT_CONFIG_CONFIG_H -#define FT_CONFIG_CONFIG_H <freetype/config/ftconfig.h> -#endif - - - /************************************************************************* - * - * @macro: - * FT_CONFIG_STANDARD_LIBRARY_H - * - * @description: - * A macro used in #include statements to name the file containing - * FreeType~2 interface to the standard C library functions. - * - */ -#ifndef FT_CONFIG_STANDARD_LIBRARY_H -#define FT_CONFIG_STANDARD_LIBRARY_H <freetype/config/ftstdlib.h> -#endif - - - /************************************************************************* - * - * @macro: - * FT_CONFIG_OPTIONS_H - * - * @description: - * A macro used in #include statements to name the file containing - * FreeType~2 project-specific configuration options. - * - */ -#ifndef FT_CONFIG_OPTIONS_H -#define FT_CONFIG_OPTIONS_H <freetype/config/ftoption.h> -#endif - - - /************************************************************************* - * - * @macro: - * FT_CONFIG_MODULES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * list of FreeType~2 modules that are statically linked to new library - * instances in @FT_Init_FreeType. - * - */ -#ifndef FT_CONFIG_MODULES_H -#define FT_CONFIG_MODULES_H <freetype/config/ftmodule.h> -#endif - - /* */ - - /* public headers */ - - /************************************************************************* - * - * @macro: - * FT_FREETYPE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * base FreeType~2 API. - * - */ -#define FT_FREETYPE_H <freetype/freetype.h> - - - /************************************************************************* - * - * @macro: - * FT_ERRORS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * list of FreeType~2 error codes (and messages). - * - * It is included by @FT_FREETYPE_H. - * - */ -#define FT_ERRORS_H <freetype/fterrors.h> - - - /************************************************************************* - * - * @macro: - * FT_MODULE_ERRORS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * list of FreeType~2 module error offsets (and messages). - * - */ -#define FT_MODULE_ERRORS_H <freetype/ftmoderr.h> - - - /************************************************************************* - * - * @macro: - * FT_SYSTEM_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 interface to low-level operations (i.e., memory management - * and stream i/o). - * - * It is included by @FT_FREETYPE_H. - * - */ -#define FT_SYSTEM_H <freetype/ftsystem.h> - - - /************************************************************************* - * - * @macro: - * FT_IMAGE_H - * - * @description: - * A macro used in #include statements to name the file containing type - * definitions related to glyph images (i.e., bitmaps, outlines, - * scan-converter parameters). - * - * It is included by @FT_FREETYPE_H. - * - */ -#define FT_IMAGE_H <freetype/ftimage.h> - - - /************************************************************************* - * - * @macro: - * FT_TYPES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * basic data types defined by FreeType~2. - * - * It is included by @FT_FREETYPE_H. - * - */ -#define FT_TYPES_H <freetype/fttypes.h> - - - /************************************************************************* - * - * @macro: - * FT_LIST_H - * - * @description: - * A macro used in #include statements to name the file containing the - * list management API of FreeType~2. - * - * (Most applications will never need to include this file.) - * - */ -#define FT_LIST_H <freetype/ftlist.h> - - - /************************************************************************* - * - * @macro: - * FT_OUTLINE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * scalable outline management API of FreeType~2. - * - */ -#define FT_OUTLINE_H <freetype/ftoutln.h> - - - /************************************************************************* - * - * @macro: - * FT_SIZES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * API which manages multiple @FT_Size objects per face. - * - */ -#define FT_SIZES_H <freetype/ftsizes.h> - - - /************************************************************************* - * - * @macro: - * FT_MODULE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * module management API of FreeType~2. - * - */ -#define FT_MODULE_H <freetype/ftmodapi.h> - - - /************************************************************************* - * - * @macro: - * FT_RENDER_H - * - * @description: - * A macro used in #include statements to name the file containing the - * renderer module management API of FreeType~2. - * - */ -#define FT_RENDER_H <freetype/ftrender.h> - - - /************************************************************************* - * - * @macro: - * FT_AUTOHINTER_H - * - * @description: - * A macro used in #include statements to name the file containing - * structures and macros related to the auto-hinting module. - * - */ -#define FT_AUTOHINTER_H <freetype/ftautoh.h> - - - /************************************************************************* - * - * @macro: - * FT_CFF_DRIVER_H - * - * @description: - * A macro used in #include statements to name the file containing - * structures and macros related to the CFF driver module. - * - */ -#define FT_CFF_DRIVER_H <freetype/ftcffdrv.h> - - - /************************************************************************* - * - * @macro: - * FT_TRUETYPE_DRIVER_H - * - * @description: - * A macro used in #include statements to name the file containing - * structures and macros related to the TrueType driver module. - * - */ -#define FT_TRUETYPE_DRIVER_H <freetype/ftttdrv.h> - - - /************************************************************************* - * - * @macro: - * FT_TYPE1_TABLES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * types and API specific to the Type~1 format. - * - */ -#define FT_TYPE1_TABLES_H <freetype/t1tables.h> - - - /************************************************************************* - * - * @macro: - * FT_TRUETYPE_IDS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * enumeration values which identify name strings, languages, encodings, - * etc. This file really contains a _large_ set of constant macro - * definitions, taken from the TrueType and OpenType specifications. - * - */ -#define FT_TRUETYPE_IDS_H <freetype/ttnameid.h> - - - /************************************************************************* - * - * @macro: - * FT_TRUETYPE_TABLES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * types and API specific to the TrueType (as well as OpenType) format. - * - */ -#define FT_TRUETYPE_TABLES_H <freetype/tttables.h> - - - /************************************************************************* - * - * @macro: - * FT_TRUETYPE_TAGS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of TrueType four-byte `tags' which identify blocks in - * SFNT-based font formats (i.e., TrueType and OpenType). - * - */ -#define FT_TRUETYPE_TAGS_H <freetype/tttags.h> - - - /************************************************************************* - * - * @macro: - * FT_BDF_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which accesses BDF-specific strings from a - * face. - * - */ -#define FT_BDF_H <freetype/ftbdf.h> - - - /************************************************************************* - * - * @macro: - * FT_CID_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which access CID font information from a - * face. - * - */ -#define FT_CID_H <freetype/ftcid.h> - - - /************************************************************************* - * - * @macro: - * FT_GZIP_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which supports gzip-compressed files. - * - */ -#define FT_GZIP_H <freetype/ftgzip.h> - - - /************************************************************************* - * - * @macro: - * FT_LZW_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which supports LZW-compressed files. - * - */ -#define FT_LZW_H <freetype/ftlzw.h> - - - /************************************************************************* - * - * @macro: - * FT_BZIP2_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which supports bzip2-compressed files. - * - */ -#define FT_BZIP2_H <freetype/ftbzip2.h> - - - /************************************************************************* - * - * @macro: - * FT_WINFONTS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * definitions of an API which supports Windows FNT files. - * - */ -#define FT_WINFONTS_H <freetype/ftwinfnt.h> - - - /************************************************************************* - * - * @macro: - * FT_GLYPH_H - * - * @description: - * A macro used in #include statements to name the file containing the - * API of the optional glyph management component. - * - */ -#define FT_GLYPH_H <freetype/ftglyph.h> - - - /************************************************************************* - * - * @macro: - * FT_BITMAP_H - * - * @description: - * A macro used in #include statements to name the file containing the - * API of the optional bitmap conversion component. - * - */ -#define FT_BITMAP_H <freetype/ftbitmap.h> - - - /************************************************************************* - * - * @macro: - * FT_BBOX_H - * - * @description: - * A macro used in #include statements to name the file containing the - * API of the optional exact bounding box computation routines. - * - */ -#define FT_BBOX_H <freetype/ftbbox.h> - - - /************************************************************************* - * - * @macro: - * FT_CACHE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * API of the optional FreeType~2 cache sub-system. - * - */ -#define FT_CACHE_H <freetype/ftcache.h> - - - /************************************************************************* - * - * @macro: - * FT_CACHE_IMAGE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * `glyph image' API of the FreeType~2 cache sub-system. - * - * It is used to define a cache for @FT_Glyph elements. You can also - * use the API defined in @FT_CACHE_SMALL_BITMAPS_H if you only need to - * store small glyph bitmaps, as it will use less memory. - * - * This macro is deprecated. Simply include @FT_CACHE_H to have all - * glyph image-related cache declarations. - * - */ -#define FT_CACHE_IMAGE_H FT_CACHE_H - - - /************************************************************************* - * - * @macro: - * FT_CACHE_SMALL_BITMAPS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * `small bitmaps' API of the FreeType~2 cache sub-system. - * - * It is used to define a cache for small glyph bitmaps in a relatively - * memory-efficient way. You can also use the API defined in - * @FT_CACHE_IMAGE_H if you want to cache arbitrary glyph images, - * including scalable outlines. - * - * This macro is deprecated. Simply include @FT_CACHE_H to have all - * small bitmaps-related cache declarations. - * - */ -#define FT_CACHE_SMALL_BITMAPS_H FT_CACHE_H - - - /************************************************************************* - * - * @macro: - * FT_CACHE_CHARMAP_H - * - * @description: - * A macro used in #include statements to name the file containing the - * `charmap' API of the FreeType~2 cache sub-system. - * - * This macro is deprecated. Simply include @FT_CACHE_H to have all - * charmap-based cache declarations. - * - */ -#define FT_CACHE_CHARMAP_H FT_CACHE_H - - - /************************************************************************* - * - * @macro: - * FT_MAC_H - * - * @description: - * A macro used in #include statements to name the file containing the - * Macintosh-specific FreeType~2 API. The latter is used to access - * fonts embedded in resource forks. - * - * This header file must be explicitly included by client applications - * compiled on the Mac (note that the base API still works though). - * - */ -#define FT_MAC_H <freetype/ftmac.h> - - - /************************************************************************* - * - * @macro: - * FT_MULTIPLE_MASTERS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * optional multiple-masters management API of FreeType~2. - * - */ -#define FT_MULTIPLE_MASTERS_H <freetype/ftmm.h> - - - /************************************************************************* - * - * @macro: - * FT_SFNT_NAMES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which accesses embedded `name' strings in - * SFNT-based font formats (i.e., TrueType and OpenType). - * - */ -#define FT_SFNT_NAMES_H <freetype/ftsnames.h> - - - /************************************************************************* - * - * @macro: - * FT_OPENTYPE_VALIDATE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which validates OpenType tables (BASE, GDEF, - * GPOS, GSUB, JSTF). - * - */ -#define FT_OPENTYPE_VALIDATE_H <freetype/ftotval.h> - - - /************************************************************************* - * - * @macro: - * FT_GX_VALIDATE_H - * - * @description: - * A macro used in #include statements to name the file containing the - * optional FreeType~2 API which validates TrueTypeGX/AAT tables (feat, - * mort, morx, bsln, just, kern, opbd, trak, prop). - * - */ -#define FT_GX_VALIDATE_H <freetype/ftgxval.h> - - - /************************************************************************* - * - * @macro: - * FT_PFR_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which accesses PFR-specific data. - * - */ -#define FT_PFR_H <freetype/ftpfr.h> - - - /************************************************************************* - * - * @macro: - * FT_STROKER_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which provides functions to stroke outline paths. - */ -#define FT_STROKER_H <freetype/ftstroke.h> - - - /************************************************************************* - * - * @macro: - * FT_SYNTHESIS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which performs artificial obliquing and emboldening. - */ -#define FT_SYNTHESIS_H <freetype/ftsynth.h> - - - /************************************************************************* - * - * @macro: - * FT_FONT_FORMATS_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which provides functions specific to font formats. - */ -#define FT_FONT_FORMATS_H <freetype/ftfntfmt.h> - - /* deprecated */ -#define FT_XFREE86_H FT_FONT_FORMATS_H - - - /************************************************************************* - * - * @macro: - * FT_TRIGONOMETRY_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which performs trigonometric computations (e.g., - * cosines and arc tangents). - */ -#define FT_TRIGONOMETRY_H <freetype/fttrigon.h> - - - /************************************************************************* - * - * @macro: - * FT_LCD_FILTER_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which performs color filtering for subpixel rendering. - */ -#define FT_LCD_FILTER_H <freetype/ftlcdfil.h> - - - /************************************************************************* - * - * @macro: - * FT_UNPATENTED_HINTING_H - * - * @description: - * Deprecated. - */ -#define FT_UNPATENTED_HINTING_H <freetype/ttunpat.h> - - - /************************************************************************* - * - * @macro: - * FT_INCREMENTAL_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which performs incremental glyph loading. - */ -#define FT_INCREMENTAL_H <freetype/ftincrem.h> - - - /************************************************************************* - * - * @macro: - * FT_GASP_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which returns entries from the TrueType GASP table. - */ -#define FT_GASP_H <freetype/ftgasp.h> - - - /************************************************************************* - * - * @macro: - * FT_ADVANCES_H - * - * @description: - * A macro used in #include statements to name the file containing the - * FreeType~2 API which returns individual and ranged glyph advances. - */ -#define FT_ADVANCES_H <freetype/ftadvanc.h> - - - /* */ - -#define FT_ERROR_DEFINITIONS_H <freetype/fterrdef.h> - - - /* The internals of the cache sub-system are no longer exposed. We */ - /* default to FT_CACHE_H at the moment just in case, but we know of */ - /* no rogue client that uses them. */ - /* */ -#define FT_CACHE_MANAGER_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_MRU_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_MANAGER_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_CACHE_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_GLYPH_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_IMAGE_H <freetype/ftcache.h> -#define FT_CACHE_INTERNAL_SBITS_H <freetype/ftcache.h> - - -#define FT_INCREMENTAL_H <freetype/ftincrem.h> - -#define FT_TRUETYPE_UNPATENTED_H <freetype/ttunpat.h> - - - /* - * Include internal headers definitions from <internal/...> - * only when building the library. - */ -#ifdef FT2_BUILD_LIBRARY -#define FT_INTERNAL_INTERNAL_H <freetype/internal/internal.h> -#include FT_INTERNAL_INTERNAL_H -#endif /* FT2_BUILD_LIBRARY */ - - -#endif /* FTHEADER_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/config/ftmodule.h b/android/armeabi/include/freetype/config/ftmodule.h deleted file mode 100644 index b7299779..00000000 --- a/android/armeabi/include/freetype/config/ftmodule.h +++ /dev/null @@ -1,20 +0,0 @@ -/* This is a generated file. */ -FT_USE_MODULE( FT_Driver_ClassRec, tt_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, t1_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, cff_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, t1cid_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, pfr_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, t42_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, winfnt_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, pcf_driver_class ) -FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) -FT_USE_MODULE( FT_Module_Class, sfnt_module_class ) -FT_USE_MODULE( FT_Module_Class, autofit_module_class ) -FT_USE_MODULE( FT_Module_Class, pshinter_module_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_raster1_renderer_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class ) -FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class ) -FT_USE_MODULE( FT_Module_Class, psaux_module_class ) -FT_USE_MODULE( FT_Module_Class, psnames_module_class ) -/* EOF */ diff --git a/android/armeabi/include/freetype/config/ftoption.h b/android/armeabi/include/freetype/config/ftoption.h deleted file mode 100644 index a8097feb..00000000 --- a/android/armeabi/include/freetype/config/ftoption.h +++ /dev/null @@ -1,851 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftoption.h */ -/* */ -/* User-selectable configuration macros (specification only). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTOPTION_H_ -#define FTOPTION_H_ - - -#include <ft2build.h> - - -FT_BEGIN_HEADER - - /*************************************************************************/ - /* */ - /* USER-SELECTABLE CONFIGURATION MACROS */ - /* */ - /* This file contains the default configuration macro definitions for */ - /* a standard build of the FreeType library. There are three ways to */ - /* use this file to build project-specific versions of the library: */ - /* */ - /* - You can modify this file by hand, but this is not recommended in */ - /* cases where you would like to build several versions of the */ - /* library from a single source directory. */ - /* */ - /* - You can put a copy of this file in your build directory, more */ - /* precisely in `$BUILD/freetype/config/ftoption.h', where `$BUILD' */ - /* is the name of a directory that is included _before_ the FreeType */ - /* include path during compilation. */ - /* */ - /* The default FreeType Makefiles and Jamfiles use the build */ - /* directory `builds/<system>' by default, but you can easily change */ - /* that for your own projects. */ - /* */ - /* - Copy the file <ft2build.h> to `$BUILD/ft2build.h' and modify it */ - /* slightly to pre-define the macro FT_CONFIG_OPTIONS_H used to */ - /* locate this file during the build. For example, */ - /* */ - /* #define FT_CONFIG_OPTIONS_H <myftoptions.h> */ - /* #include <freetype/config/ftheader.h> */ - /* */ - /* will use `$BUILD/myftoptions.h' instead of this file for macro */ - /* definitions. */ - /* */ - /* Note also that you can similarly pre-define the macro */ - /* FT_CONFIG_MODULES_H used to locate the file listing of the modules */ - /* that are statically linked to the library at compile time. By */ - /* default, this file is <freetype/config/ftmodule.h>. */ - /* */ - /* We highly recommend using the third method whenever possible. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** G E N E R A L F R E E T Y P E 2 C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Uncomment the line below if you want to activate sub-pixel rendering */ - /* (a.k.a. LCD rendering, or ClearType) in this build of the library. */ - /* */ - /* Note that this feature is covered by several Microsoft patents */ - /* and should not be activated in any default build of the library. */ - /* */ - /* This macro has no impact on the FreeType API, only on its */ - /* _implementation_. For example, using FT_RENDER_MODE_LCD when calling */ - /* FT_Render_Glyph still generates a bitmap that is 3 times wider than */ - /* the original size in case this macro isn't defined; however, each */ - /* triplet of subpixels has R=G=B. */ - /* */ - /* This is done to allow FreeType clients to run unmodified, forcing */ - /* them to display normal gray-level anti-aliased glyphs. */ - /* */ -/* #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING */ - - - /*************************************************************************/ - /* */ - /* Many compilers provide a non-ANSI 64-bit data type that can be used */ - /* by FreeType to speed up some computations. However, this will create */ - /* some problems when compiling the library in strict ANSI mode. */ - /* */ - /* For this reason, the use of 64-bit integers is normally disabled when */ - /* the __STDC__ macro is defined. You can however disable this by */ - /* defining the macro FT_CONFIG_OPTION_FORCE_INT64 here. */ - /* */ - /* For most compilers, this will only create compilation warnings when */ - /* building the library. */ - /* */ - /* ObNote: The compiler-specific 64-bit integers are detected in the */ - /* file `ftconfig.h' either statically or through the */ - /* `configure' script on supported platforms. */ - /* */ -#undef FT_CONFIG_OPTION_FORCE_INT64 - - - /*************************************************************************/ - /* */ - /* If this macro is defined, do not try to use an assembler version of */ - /* performance-critical functions (e.g. FT_MulFix). You should only do */ - /* that to verify that the assembler function works properly, or to */ - /* execute benchmark tests of the various implementations. */ -/* #define FT_CONFIG_OPTION_NO_ASSEMBLER */ - - - /*************************************************************************/ - /* */ - /* If this macro is defined, try to use an inlined assembler version of */ - /* the `FT_MulFix' function, which is a `hotspot' when loading and */ - /* hinting glyphs, and which should be executed as fast as possible. */ - /* */ - /* Note that if your compiler or CPU is not supported, this will default */ - /* to the standard and portable implementation found in `ftcalc.c'. */ - /* */ -#define FT_CONFIG_OPTION_INLINE_MULFIX - - - /*************************************************************************/ - /* */ - /* LZW-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `compress' program. This is mostly used to parse many of the PCF */ - /* files that come with various X11 distributions. The implementation */ - /* uses NetBSD's `zopen' to partially uncompress the file on the fly */ - /* (see src/lzw/ftgzip.c). */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ -#define FT_CONFIG_OPTION_USE_LZW - - - /*************************************************************************/ - /* */ - /* Gzip-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `gzip' program. This is mostly used to parse many of the PCF files */ - /* that come with XFree86. The implementation uses `zlib' to */ - /* partially uncompress the file on the fly (see src/gzip/ftgzip.c). */ - /* */ - /* Define this macro if you want to enable this `feature'. See also */ - /* the macro FT_CONFIG_OPTION_SYSTEM_ZLIB below. */ - /* */ -#define FT_CONFIG_OPTION_USE_ZLIB - - - /*************************************************************************/ - /* */ - /* ZLib library selection */ - /* */ - /* This macro is only used when FT_CONFIG_OPTION_USE_ZLIB is defined. */ - /* It allows FreeType's `ftgzip' component to link to the system's */ - /* installation of the ZLib library. This is useful on systems like */ - /* Unix or VMS where it generally is already available. */ - /* */ - /* If you let it undefined, the component will use its own copy */ - /* of the zlib sources instead. These have been modified to be */ - /* included directly within the component and *not* export external */ - /* function names. This allows you to link any program with FreeType */ - /* _and_ ZLib without linking conflicts. */ - /* */ - /* Do not #undef this macro here since the build system might define */ - /* it for certain configurations only. */ - /* */ -/* #define FT_CONFIG_OPTION_SYSTEM_ZLIB */ - - - /*************************************************************************/ - /* */ - /* Bzip2-compressed file support. */ - /* */ - /* FreeType now handles font files that have been compressed with the */ - /* `bzip2' program. This is mostly used to parse many of the PCF */ - /* files that come with XFree86. The implementation uses `libbz2' to */ - /* partially uncompress the file on the fly (see src/bzip2/ftbzip2.c). */ - /* Contrary to gzip, bzip2 currently is not included and need to use */ - /* the system available bzip2 implementation. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ -/* #define FT_CONFIG_OPTION_USE_BZIP2 */ - - - /*************************************************************************/ - /* */ - /* Define to disable the use of file stream functions and types, FILE, */ - /* fopen() etc. Enables the use of smaller system libraries on embedded */ - /* systems that have multiple system libraries, some with or without */ - /* file stream support, in the cases where file stream support is not */ - /* necessary such as memory loading of font files. */ - /* */ -/* #define FT_CONFIG_OPTION_DISABLE_STREAM_SUPPORT */ - - - /*************************************************************************/ - /* */ - /* PNG bitmap support. */ - /* */ - /* FreeType now handles loading color bitmap glyphs in the PNG format. */ - /* This requires help from the external libpng library. Uncompressed */ - /* color bitmaps do not need any external libraries and will be */ - /* supported regardless of this configuration. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ -/* #define FT_CONFIG_OPTION_USE_PNG */ - - - /*************************************************************************/ - /* */ - /* HarfBuzz support. */ - /* */ - /* FreeType uses the HarfBuzz library to improve auto-hinting of */ - /* OpenType fonts. If available, many glyphs not directly addressable */ - /* by a font's character map will be hinted also. */ - /* */ - /* Define this macro if you want to enable this `feature'. */ - /* */ -/* #define FT_CONFIG_OPTION_USE_HARFBUZZ */ - - - /*************************************************************************/ - /* */ - /* DLL export compilation */ - /* */ - /* When compiling FreeType as a DLL, some systems/compilers need a */ - /* special keyword in front OR after the return type of function */ - /* declarations. */ - /* */ - /* Two macros are used within the FreeType source code to define */ - /* exported library functions: FT_EXPORT and FT_EXPORT_DEF. */ - /* */ - /* FT_EXPORT( return_type ) */ - /* */ - /* is used in a function declaration, as in */ - /* */ - /* FT_EXPORT( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ); */ - /* */ - /* */ - /* FT_EXPORT_DEF( return_type ) */ - /* */ - /* is used in a function definition, as in */ - /* */ - /* FT_EXPORT_DEF( FT_Error ) */ - /* FT_Init_FreeType( FT_Library* alibrary ) */ - /* { */ - /* ... some code ... */ - /* return FT_Err_Ok; */ - /* } */ - /* */ - /* You can provide your own implementation of FT_EXPORT and */ - /* FT_EXPORT_DEF here if you want. If you leave them undefined, they */ - /* will be later automatically defined as `extern return_type' to */ - /* allow normal compilation. */ - /* */ - /* Do not #undef these macros here since the build system might define */ - /* them for certain configurations only. */ - /* */ -/* #define FT_EXPORT(x) extern x */ -/* #define FT_EXPORT_DEF(x) x */ - - - /*************************************************************************/ - /* */ - /* Glyph Postscript Names handling */ - /* */ - /* By default, FreeType 2 is compiled with the `psnames' module. This */ - /* module is in charge of converting a glyph name string into a */ - /* Unicode value, or return a Macintosh standard glyph name for the */ - /* use with the TrueType `post' table. */ - /* */ - /* Undefine this macro if you do not want `psnames' compiled in your */ - /* build of FreeType. This has the following effects: */ - /* */ - /* - The TrueType driver will provide its own set of glyph names, */ - /* if you build it to support postscript names in the TrueType */ - /* `post' table. */ - /* */ - /* - The Type 1 driver will not be able to synthesize a Unicode */ - /* charmap out of the glyphs found in the fonts. */ - /* */ - /* You would normally undefine this configuration macro when building */ - /* a version of FreeType that doesn't contain a Type 1 or CFF driver. */ - /* */ -#define FT_CONFIG_OPTION_POSTSCRIPT_NAMES - - - /*************************************************************************/ - /* */ - /* Postscript Names to Unicode Values support */ - /* */ - /* By default, FreeType 2 is built with the `PSNames' module compiled */ - /* in. Among other things, the module is used to convert a glyph name */ - /* into a Unicode value. This is especially useful in order to */ - /* synthesize on the fly a Unicode charmap from the CFF/Type 1 driver */ - /* through a big table named the `Adobe Glyph List' (AGL). */ - /* */ - /* Undefine this macro if you do not want the Adobe Glyph List */ - /* compiled in your `PSNames' module. The Type 1 driver will not be */ - /* able to synthesize a Unicode charmap out of the glyphs found in the */ - /* fonts. */ - /* */ -#define FT_CONFIG_OPTION_ADOBE_GLYPH_LIST - - - /*************************************************************************/ - /* */ - /* Support for Mac fonts */ - /* */ - /* Define this macro if you want support for outline fonts in Mac */ - /* format (mac dfont, mac resource, macbinary containing a mac */ - /* resource) on non-Mac platforms. */ - /* */ - /* Note that the `FOND' resource isn't checked. */ - /* */ -#define FT_CONFIG_OPTION_MAC_FONTS - - - /*************************************************************************/ - /* */ - /* Guessing methods to access embedded resource forks */ - /* */ - /* Enable extra Mac fonts support on non-Mac platforms (e.g. */ - /* GNU/Linux). */ - /* */ - /* Resource forks which include fonts data are stored sometimes in */ - /* locations which users or developers don't expected. In some cases, */ - /* resource forks start with some offset from the head of a file. In */ - /* other cases, the actual resource fork is stored in file different */ - /* from what the user specifies. If this option is activated, */ - /* FreeType tries to guess whether such offsets or different file */ - /* names must be used. */ - /* */ - /* Note that normal, direct access of resource forks is controlled via */ - /* the FT_CONFIG_OPTION_MAC_FONTS option. */ - /* */ -#ifdef FT_CONFIG_OPTION_MAC_FONTS -#define FT_CONFIG_OPTION_GUESSING_EMBEDDED_RFORK -#endif - - - /*************************************************************************/ - /* */ - /* Allow the use of FT_Incremental_Interface to load typefaces that */ - /* contain no glyph data, but supply it via a callback function. */ - /* This is required by clients supporting document formats which */ - /* supply font data incrementally as the document is parsed, such */ - /* as the Ghostscript interpreter for the PostScript language. */ - /* */ -#define FT_CONFIG_OPTION_INCREMENTAL - - - /*************************************************************************/ - /* */ - /* The size in bytes of the render pool used by the scan-line converter */ - /* to do all of its work. */ - /* */ -#define FT_RENDER_POOL_SIZE 16384L - - - /*************************************************************************/ - /* */ - /* FT_MAX_MODULES */ - /* */ - /* The maximum number of modules that can be registered in a single */ - /* FreeType library object. 32 is the default. */ - /* */ -#define FT_MAX_MODULES 32 - - - /*************************************************************************/ - /* */ - /* Debug level */ - /* */ - /* FreeType can be compiled in debug or trace mode. In debug mode, */ - /* errors are reported through the `ftdebug' component. In trace */ - /* mode, additional messages are sent to the standard output during */ - /* execution. */ - /* */ - /* Define FT_DEBUG_LEVEL_ERROR to build the library in debug mode. */ - /* Define FT_DEBUG_LEVEL_TRACE to build it in trace mode. */ - /* */ - /* Don't define any of these macros to compile in `release' mode! */ - /* */ - /* Do not #undef these macros here since the build system might define */ - /* them for certain configurations only. */ - /* */ -/* #define FT_DEBUG_LEVEL_ERROR */ -/* #define FT_DEBUG_LEVEL_TRACE */ - - - /*************************************************************************/ - /* */ - /* Autofitter debugging */ - /* */ - /* If FT_DEBUG_AUTOFIT is defined, FreeType provides some means to */ - /* control the autofitter behaviour for debugging purposes with global */ - /* boolean variables (consequently, you should *never* enable this */ - /* while compiling in `release' mode): */ - /* */ - /* _af_debug_disable_horz_hints */ - /* _af_debug_disable_vert_hints */ - /* _af_debug_disable_blue_hints */ - /* */ - /* Additionally, the following functions provide dumps of various */ - /* internal autofit structures to stdout (using `printf'): */ - /* */ - /* af_glyph_hints_dump_points */ - /* af_glyph_hints_dump_segments */ - /* af_glyph_hints_dump_edges */ - /* af_glyph_hints_get_num_segments */ - /* af_glyph_hints_get_segment_offset */ - /* */ - /* As an argument, they use another global variable: */ - /* */ - /* _af_debug_hints */ - /* */ - /* Please have a look at the `ftgrid' demo program to see how those */ - /* variables and macros should be used. */ - /* */ - /* Do not #undef these macros here since the build system might define */ - /* them for certain configurations only. */ - /* */ -/* #define FT_DEBUG_AUTOFIT */ - - - /*************************************************************************/ - /* */ - /* Memory Debugging */ - /* */ - /* FreeType now comes with an integrated memory debugger that is */ - /* capable of detecting simple errors like memory leaks or double */ - /* deletes. To compile it within your build of the library, you */ - /* should define FT_DEBUG_MEMORY here. */ - /* */ - /* Note that the memory debugger is only activated at runtime when */ - /* when the _environment_ variable `FT2_DEBUG_MEMORY' is defined also! */ - /* */ - /* Do not #undef this macro here since the build system might define */ - /* it for certain configurations only. */ - /* */ -/* #define FT_DEBUG_MEMORY */ - - - /*************************************************************************/ - /* */ - /* Module errors */ - /* */ - /* If this macro is set (which is _not_ the default), the higher byte */ - /* of an error code gives the module in which the error has occurred, */ - /* while the lower byte is the real error code. */ - /* */ - /* Setting this macro makes sense for debugging purposes only, since */ - /* it would break source compatibility of certain programs that use */ - /* FreeType 2. */ - /* */ - /* More details can be found in the files ftmoderr.h and fterrors.h. */ - /* */ -#undef FT_CONFIG_OPTION_USE_MODULE_ERRORS - - - /*************************************************************************/ - /* */ - /* Position Independent Code */ - /* */ - /* If this macro is set (which is _not_ the default), FreeType2 will */ - /* avoid creating constants that require address fixups. Instead the */ - /* constants will be moved into a struct and additional intialization */ - /* code will be used. */ - /* */ - /* Setting this macro is needed for systems that prohibit address */ - /* fixups, such as BREW. */ - /* */ -/* #define FT_CONFIG_OPTION_PIC */ - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** S F N T D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_EMBEDDED_BITMAPS if you want to support */ - /* embedded bitmaps in all formats using the SFNT module (namely */ - /* TrueType & OpenType). */ - /* */ -#define TT_CONFIG_OPTION_EMBEDDED_BITMAPS - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_POSTSCRIPT_NAMES if you want to be able to */ - /* load and enumerate the glyph Postscript names in a TrueType or */ - /* OpenType file. */ - /* */ - /* Note that when you do not compile the `PSNames' module by undefining */ - /* the above FT_CONFIG_OPTION_POSTSCRIPT_NAMES, the `sfnt' module will */ - /* contain additional code used to read the PS Names table from a font. */ - /* */ - /* (By default, the module uses `PSNames' to extract glyph names.) */ - /* */ -#define TT_CONFIG_OPTION_POSTSCRIPT_NAMES - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_SFNT_NAMES if your applications need to */ - /* access the internal name table in a SFNT-based format like TrueType */ - /* or OpenType. The name table contains various strings used to */ - /* describe the font, like family name, copyright, version, etc. It */ - /* does not contain any glyph name though. */ - /* */ - /* Accessing SFNT names is done through the functions declared in */ - /* `ftsnames.h'. */ - /* */ -#define TT_CONFIG_OPTION_SFNT_NAMES - - - /*************************************************************************/ - /* */ - /* TrueType CMap support */ - /* */ - /* Here you can fine-tune which TrueType CMap table format shall be */ - /* supported. */ -#define TT_CONFIG_CMAP_FORMAT_0 -#define TT_CONFIG_CMAP_FORMAT_2 -#define TT_CONFIG_CMAP_FORMAT_4 -#define TT_CONFIG_CMAP_FORMAT_6 -#define TT_CONFIG_CMAP_FORMAT_8 -#define TT_CONFIG_CMAP_FORMAT_10 -#define TT_CONFIG_CMAP_FORMAT_12 -#define TT_CONFIG_CMAP_FORMAT_13 -#define TT_CONFIG_CMAP_FORMAT_14 - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** T R U E T Y P E D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_BYTECODE_INTERPRETER if you want to compile */ - /* a bytecode interpreter in the TrueType driver. */ - /* */ - /* By undefining this, you will only compile the code necessary to load */ - /* TrueType glyphs without hinting. */ - /* */ - /* Do not #undef this macro here, since the build system might */ - /* define it for certain configurations only. */ - /* */ -#define TT_CONFIG_OPTION_BYTECODE_INTERPRETER - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_SUBPIXEL_HINTING if you want to compile */ - /* EXPERIMENTAL subpixel hinting support into the TrueType driver. This */ - /* replaces the native TrueType hinting mechanism when anything but */ - /* FT_RENDER_MODE_MONO is requested. */ - /* */ - /* Enabling this causes the TrueType driver to ignore instructions under */ - /* certain conditions. This is done in accordance with the guide here, */ - /* with some minor differences: */ - /* */ - /* http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx */ - /* */ - /* By undefining this, you only compile the code necessary to hint */ - /* TrueType glyphs with native TT hinting. */ - /* */ - /* This option requires TT_CONFIG_OPTION_BYTECODE_INTERPRETER to be */ - /* defined. */ - /* */ -/* #define TT_CONFIG_OPTION_SUBPIXEL_HINTING */ - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED to compile the */ - /* TrueType glyph loader to use Apple's definition of how to handle */ - /* component offsets in composite glyphs. */ - /* */ - /* Apple and MS disagree on the default behavior of component offsets */ - /* in composites. Apple says that they should be scaled by the scaling */ - /* factors in the transformation matrix (roughly, it's more complex) */ - /* while MS says they should not. OpenType defines two bits in the */ - /* composite flags array which can be used to disambiguate, but old */ - /* fonts will not have them. */ - /* */ - /* http://www.microsoft.com/typography/otspec/glyf.htm */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6glyf.html */ - /* */ -#undef TT_CONFIG_OPTION_COMPONENT_OFFSET_SCALED - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_GX_VAR_SUPPORT if you want to include */ - /* support for Apple's distortable font technology (fvar, gvar, cvar, */ - /* and avar tables). This has many similarities to Type 1 Multiple */ - /* Masters support. */ - /* */ -#define TT_CONFIG_OPTION_GX_VAR_SUPPORT - - - /*************************************************************************/ - /* */ - /* Define TT_CONFIG_OPTION_BDF if you want to include support for */ - /* an embedded `BDF ' table within SFNT-based bitmap formats. */ - /* */ -#define TT_CONFIG_OPTION_BDF - - - /*************************************************************************/ - /* */ - /* Option TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES controls the maximum */ - /* number of bytecode instructions executed for a single run of the */ - /* bytecode interpreter, needed to prevent infinite loops. You don't */ - /* want to change this except for very special situations (e.g., making */ - /* a library fuzzer spend less time to handle broken fonts). */ - /* */ - /* It is not expected that this value is ever modified by a configuring */ - /* script; instead, it gets surrounded with #ifndef ... #endif so that */ - /* the value can be set as a preprocessor option on the compiler's */ - /* command line. */ - /* */ -#ifndef TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES -#define TT_CONFIG_OPTION_MAX_RUNNABLE_OPCODES 1000000L -#endif - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** T Y P E 1 D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* T1_MAX_DICT_DEPTH is the maximum depth of nest dictionaries and */ - /* arrays in the Type 1 stream (see t1load.c). A minimum of 4 is */ - /* required. */ - /* */ -#define T1_MAX_DICT_DEPTH 5 - - - /*************************************************************************/ - /* */ - /* T1_MAX_SUBRS_CALLS details the maximum number of nested sub-routine */ - /* calls during glyph loading. */ - /* */ -#define T1_MAX_SUBRS_CALLS 16 - - - /*************************************************************************/ - /* */ - /* T1_MAX_CHARSTRING_OPERANDS is the charstring stack's capacity. A */ - /* minimum of 16 is required. */ - /* */ - /* The Chinese font MingTiEG-Medium (CNS 11643 character set) needs 256. */ - /* */ -#define T1_MAX_CHARSTRINGS_OPERANDS 256 - - - /*************************************************************************/ - /* */ - /* Define this configuration macro if you want to prevent the */ - /* compilation of `t1afm', which is in charge of reading Type 1 AFM */ - /* files into an existing face. Note that if set, the T1 driver will be */ - /* unable to produce kerning distances. */ - /* */ -#undef T1_CONFIG_OPTION_NO_AFM - - - /*************************************************************************/ - /* */ - /* Define this configuration macro if you want to prevent the */ - /* compilation of the Multiple Masters font support in the Type 1 */ - /* driver. */ - /* */ -#undef T1_CONFIG_OPTION_NO_MM_SUPPORT - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** C F F D R I V E R C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Using CFF_CONFIG_OPTION_DARKENING_PARAMETER_{X,Y}{1,2,3,4} it is */ - /* possible to set up the default values of the four control points that */ - /* define the stem darkening behaviour of the (new) CFF engine. For */ - /* more details please read the documentation of the */ - /* `darkening-parameters' property of the cff driver module (file */ - /* `ftcffdrv.h'), which allows the control at run-time. */ - /* */ - /* Do *not* undefine these macros! */ - /* */ -#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 500 -#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 400 - -#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 1000 -#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 275 - -#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 1667 -#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 275 - -#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 2333 -#define CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 0 - - - /*************************************************************************/ - /* */ - /* CFF_CONFIG_OPTION_OLD_ENGINE controls whether the pre-Adobe CFF */ - /* engine gets compiled into FreeType. If defined, it is possible to */ - /* switch between the two engines using the `hinting-engine' property of */ - /* the cff driver module. */ - /* */ -/* #define CFF_CONFIG_OPTION_OLD_ENGINE */ - - - /*************************************************************************/ - /*************************************************************************/ - /**** ****/ - /**** A U T O F I T M O D U L E C O N F I G U R A T I O N ****/ - /**** ****/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Compile autofit module with CJK (Chinese, Japanese, Korean) script */ - /* support. */ - /* */ -#define AF_CONFIG_OPTION_CJK - - /*************************************************************************/ - /* */ - /* Compile autofit module with Indic script support. */ - /* */ -#define AF_CONFIG_OPTION_INDIC - - /*************************************************************************/ - /* */ - /* Compile autofit module with warp hinting. The idea of the warping */ - /* code is to slightly scale and shift a glyph within a single dimension */ - /* so that as much of its segments are aligned (more or less) on the */ - /* grid. To find out the optimal scaling and shifting value, various */ - /* parameter combinations are tried and scored. */ - /* */ - /* This experimental option is active only if the rendering mode is */ - /* FT_RENDER_MODE_LIGHT; you can switch warping on and off with the */ - /* `warping' property of the auto-hinter (see file `ftautoh.h' for more */ - /* information; by default it is switched off). */ - /* */ -#define AF_CONFIG_OPTION_USE_WARPER - - /* */ - - - /* - * This macro is obsolete. Support has been removed in FreeType - * version 2.5. - */ -/* #define FT_CONFIG_OPTION_OLD_INTERNALS */ - - - /* - * This macro is defined if native TrueType hinting is requested by the - * definitions above. - */ -#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER -#define TT_USE_BYTECODE_INTERPRETER -#endif - - - /* - * Check CFF darkening parameters. The checks are the same as in function - * `cff_property_set' in file `cffdrivr.c'. - */ -#if CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 < 0 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 < 0 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 < 0 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 < 0 || \ - \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 < 0 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 < 0 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 < 0 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 < 0 || \ - \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_X1 > \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_X2 > \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_X3 > \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_X4 || \ - \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y1 > 500 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y2 > 500 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y3 > 500 || \ - CFF_CONFIG_OPTION_DARKENING_PARAMETER_Y4 > 500 -#error "Invalid CFF darkening parameters!" -#endif - -FT_END_HEADER - - -#endif /* FTOPTION_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/config/ftstdlib.h b/android/armeabi/include/freetype/config/ftstdlib.h deleted file mode 100644 index 9daea56f..00000000 --- a/android/armeabi/include/freetype/config/ftstdlib.h +++ /dev/null @@ -1,173 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftstdlib.h */ -/* */ -/* ANSI-specific library and header configuration file (specification */ -/* only). */ -/* */ -/* Copyright 2002-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to group all #includes to the ANSI C library that */ - /* FreeType normally requires. It also defines macros to rename the */ - /* standard functions within the FreeType source code. */ - /* */ - /* Load a file which defines FTSTDLIB_H_ before this one to override it. */ - /* */ - /*************************************************************************/ - - -#ifndef FTSTDLIB_H_ -#define FTSTDLIB_H_ - - -#include <stddef.h> - -#define ft_ptrdiff_t ptrdiff_t - - - /**********************************************************************/ - /* */ - /* integer limits */ - /* */ - /* UINT_MAX and ULONG_MAX are used to automatically compute the size */ - /* of `int' and `long' in bytes at compile-time. So far, this works */ - /* for all platforms the library has been tested on. */ - /* */ - /* Note that on the extremely rare platforms that do not provide */ - /* integer types that are _exactly_ 16 and 32 bits wide (e.g. some */ - /* old Crays where `int' is 36 bits), we do not make any guarantee */ - /* about the correct behaviour of FT2 with all fonts. */ - /* */ - /* In these case, `ftconfig.h' will refuse to compile anyway with a */ - /* message like `couldn't find 32-bit type' or something similar. */ - /* */ - /**********************************************************************/ - - -#include <limits.h> - -#define FT_CHAR_BIT CHAR_BIT -#define FT_USHORT_MAX USHRT_MAX -#define FT_INT_MAX INT_MAX -#define FT_INT_MIN INT_MIN -#define FT_UINT_MAX UINT_MAX -#define FT_LONG_MAX LONG_MAX -#define FT_ULONG_MAX ULONG_MAX - - - /**********************************************************************/ - /* */ - /* character and string processing */ - /* */ - /**********************************************************************/ - - -#include <string.h> - -#define ft_memchr memchr -#define ft_memcmp memcmp -#define ft_memcpy memcpy -#define ft_memmove memmove -#define ft_memset memset -#define ft_strcat strcat -#define ft_strcmp strcmp -#define ft_strcpy strcpy -#define ft_strlen strlen -#define ft_strncmp strncmp -#define ft_strncpy strncpy -#define ft_strrchr strrchr -#define ft_strstr strstr - - - /**********************************************************************/ - /* */ - /* file handling */ - /* */ - /**********************************************************************/ - - -#include <stdio.h> - -#define FT_FILE FILE -#define ft_fclose fclose -#define ft_fopen fopen -#define ft_fread fread -#define ft_fseek fseek -#define ft_ftell ftell -#define ft_sprintf sprintf - - - /**********************************************************************/ - /* */ - /* sorting */ - /* */ - /**********************************************************************/ - - -#include <stdlib.h> - -#define ft_qsort qsort - - - /**********************************************************************/ - /* */ - /* memory allocation */ - /* */ - /**********************************************************************/ - - -#define ft_scalloc calloc -#define ft_sfree free -#define ft_smalloc malloc -#define ft_srealloc realloc - - - /**********************************************************************/ - /* */ - /* miscellaneous */ - /* */ - /**********************************************************************/ - - -#define ft_atol atol - - - /**********************************************************************/ - /* */ - /* execution control */ - /* */ - /**********************************************************************/ - - -#include <setjmp.h> - -#define ft_jmp_buf jmp_buf /* note: this cannot be a typedef since */ - /* jmp_buf is defined as a macro */ - /* on certain platforms */ - -#define ft_longjmp longjmp -#define ft_setjmp( b ) setjmp( *(ft_jmp_buf*) &(b) ) /* same thing here */ - - - /* the following is only used for debugging purposes, i.e., if */ - /* FT_DEBUG_LEVEL_ERROR or FT_DEBUG_LEVEL_TRACE are defined */ - -#include <stdarg.h> - - -#endif /* FTSTDLIB_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/freetype.h b/android/armeabi/include/freetype/freetype.h deleted file mode 100644 index 4666d489..00000000 --- a/android/armeabi/include/freetype/freetype.h +++ /dev/null @@ -1,4272 +0,0 @@ -/***************************************************************************/ -/* */ -/* freetype.h */ -/* */ -/* FreeType high-level API and common types (specification only). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FREETYPE_H_ -#define FREETYPE_H_ - - -#ifndef FT_FREETYPE_H -#error "`ft2build.h' hasn't been included yet!" -#error "Please always use macros to include FreeType header files." -#error "Example:" -#error " #include <ft2build.h>" -#error " #include FT_FREETYPE_H" -#endif - - -#include <ft2build.h> -#include FT_CONFIG_CONFIG_H -#include FT_TYPES_H -#include FT_ERRORS_H - - -FT_BEGIN_HEADER - - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* header_inclusion */ - /* */ - /* <Title> */ - /* FreeType's header inclusion scheme */ - /* */ - /* <Abstract> */ - /* How client applications should include FreeType header files. */ - /* */ - /* <Description> */ - /* To be as flexible as possible (and for historical reasons), */ - /* FreeType uses a very special inclusion scheme to load header */ - /* files, for example */ - /* */ - /* { */ - /* #include <ft2build.h> */ - /* */ - /* #include FT_FREETYPE_H */ - /* #include FT_OUTLINE_H */ - /* } */ - /* */ - /* A compiler and its preprocessor only needs an include path to find */ - /* the file `ft2build.h'; the exact locations and names of the other */ - /* FreeType header files are hidden by preprocessor macro names, */ - /* loaded by `ft2build.h'. The API documentation always gives the */ - /* header macro name needed for a particular function. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* user_allocation */ - /* */ - /* <Title> */ - /* User allocation */ - /* */ - /* <Abstract> */ - /* How client applications should allocate FreeType data structures. */ - /* */ - /* <Description> */ - /* FreeType assumes that structures allocated by the user and passed */ - /* as arguments are zeroed out except for the actual data. In other */ - /* words, it is recommended to use `calloc' (or variants of it) */ - /* instead of `malloc' for allocation. */ - /* */ - /*************************************************************************/ - - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* B A S I C T Y P E S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* base_interface */ - /* */ - /* <Title> */ - /* Base Interface */ - /* */ - /* <Abstract> */ - /* The FreeType~2 base font interface. */ - /* */ - /* <Description> */ - /* This section describes the most important public high-level API */ - /* functions of FreeType~2. */ - /* */ - /* <Order> */ - /* FT_Library */ - /* FT_Face */ - /* FT_Size */ - /* FT_GlyphSlot */ - /* FT_CharMap */ - /* FT_Encoding */ - /* FT_ENC_TAG */ - /* */ - /* FT_FaceRec */ - /* */ - /* FT_FACE_FLAG_SCALABLE */ - /* FT_FACE_FLAG_FIXED_SIZES */ - /* FT_FACE_FLAG_FIXED_WIDTH */ - /* FT_FACE_FLAG_HORIZONTAL */ - /* FT_FACE_FLAG_VERTICAL */ - /* FT_FACE_FLAG_COLOR */ - /* FT_FACE_FLAG_SFNT */ - /* FT_FACE_FLAG_CID_KEYED */ - /* FT_FACE_FLAG_TRICKY */ - /* FT_FACE_FLAG_KERNING */ - /* FT_FACE_FLAG_MULTIPLE_MASTERS */ - /* FT_FACE_FLAG_GLYPH_NAMES */ - /* FT_FACE_FLAG_EXTERNAL_STREAM */ - /* FT_FACE_FLAG_HINTER */ - /* */ - /* FT_HAS_HORIZONTAL */ - /* FT_HAS_VERTICAL */ - /* FT_HAS_KERNING */ - /* FT_HAS_FIXED_SIZES */ - /* FT_HAS_GLYPH_NAMES */ - /* FT_HAS_MULTIPLE_MASTERS */ - /* FT_HAS_COLOR */ - /* */ - /* FT_IS_SFNT */ - /* FT_IS_SCALABLE */ - /* FT_IS_FIXED_WIDTH */ - /* FT_IS_CID_KEYED */ - /* FT_IS_TRICKY */ - /* */ - /* FT_STYLE_FLAG_BOLD */ - /* FT_STYLE_FLAG_ITALIC */ - /* */ - /* FT_SizeRec */ - /* FT_Size_Metrics */ - /* */ - /* FT_GlyphSlotRec */ - /* FT_Glyph_Metrics */ - /* FT_SubGlyph */ - /* */ - /* FT_Bitmap_Size */ - /* */ - /* FT_Init_FreeType */ - /* FT_Done_FreeType */ - /* */ - /* FT_New_Face */ - /* FT_Done_Face */ - /* FT_Reference_Face */ - /* FT_New_Memory_Face */ - /* FT_Open_Face */ - /* FT_Open_Args */ - /* FT_Parameter */ - /* FT_Attach_File */ - /* FT_Attach_Stream */ - /* */ - /* FT_Set_Char_Size */ - /* FT_Set_Pixel_Sizes */ - /* FT_Request_Size */ - /* FT_Select_Size */ - /* FT_Size_Request_Type */ - /* FT_Size_RequestRec */ - /* FT_Size_Request */ - /* FT_Set_Transform */ - /* FT_Load_Glyph */ - /* FT_Get_Char_Index */ - /* FT_Get_First_Char */ - /* FT_Get_Next_Char */ - /* FT_Get_Name_Index */ - /* FT_Load_Char */ - /* */ - /* FT_OPEN_MEMORY */ - /* FT_OPEN_STREAM */ - /* FT_OPEN_PATHNAME */ - /* FT_OPEN_DRIVER */ - /* FT_OPEN_PARAMS */ - /* */ - /* FT_LOAD_DEFAULT */ - /* FT_LOAD_RENDER */ - /* FT_LOAD_MONOCHROME */ - /* FT_LOAD_LINEAR_DESIGN */ - /* FT_LOAD_NO_SCALE */ - /* FT_LOAD_NO_HINTING */ - /* FT_LOAD_NO_BITMAP */ - /* FT_LOAD_NO_AUTOHINT */ - /* FT_LOAD_COLOR */ - /* */ - /* FT_LOAD_VERTICAL_LAYOUT */ - /* FT_LOAD_IGNORE_TRANSFORM */ - /* FT_LOAD_FORCE_AUTOHINT */ - /* FT_LOAD_NO_RECURSE */ - /* FT_LOAD_PEDANTIC */ - /* */ - /* FT_LOAD_TARGET_NORMAL */ - /* FT_LOAD_TARGET_LIGHT */ - /* FT_LOAD_TARGET_MONO */ - /* FT_LOAD_TARGET_LCD */ - /* FT_LOAD_TARGET_LCD_V */ - /* */ - /* FT_LOAD_TARGET_MODE */ - /* */ - /* FT_Render_Glyph */ - /* FT_Render_Mode */ - /* FT_Get_Kerning */ - /* FT_Kerning_Mode */ - /* FT_Get_Track_Kerning */ - /* FT_Get_Glyph_Name */ - /* FT_Get_Postscript_Name */ - /* */ - /* FT_CharMapRec */ - /* FT_Select_Charmap */ - /* FT_Set_Charmap */ - /* FT_Get_Charmap_Index */ - /* */ - /* FT_Get_FSType_Flags */ - /* FT_Get_SubGlyph_Info */ - /* */ - /* FT_Face_Internal */ - /* FT_Size_Internal */ - /* FT_Slot_Internal */ - /* */ - /* FT_FACE_FLAG_XXX */ - /* FT_STYLE_FLAG_XXX */ - /* FT_OPEN_XXX */ - /* FT_LOAD_XXX */ - /* FT_LOAD_TARGET_XXX */ - /* FT_SUBGLYPH_FLAG_XXX */ - /* FT_FSTYPE_XXX */ - /* */ - /* FT_HAS_FAST_GLYPHS */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Glyph_Metrics */ - /* */ - /* <Description> */ - /* A structure used to model the metrics of a single glyph. The */ - /* values are expressed in 26.6 fractional pixel format; if the flag */ - /* @FT_LOAD_NO_SCALE has been used while loading the glyph, values */ - /* are expressed in font units instead. */ - /* */ - /* <Fields> */ - /* width :: */ - /* The glyph's width. */ - /* */ - /* height :: */ - /* The glyph's height. */ - /* */ - /* horiBearingX :: */ - /* Left side bearing for horizontal layout. */ - /* */ - /* horiBearingY :: */ - /* Top side bearing for horizontal layout. */ - /* */ - /* horiAdvance :: */ - /* Advance width for horizontal layout. */ - /* */ - /* vertBearingX :: */ - /* Left side bearing for vertical layout. */ - /* */ - /* vertBearingY :: */ - /* Top side bearing for vertical layout. Larger positive values */ - /* mean further below the vertical glyph origin. */ - /* */ - /* vertAdvance :: */ - /* Advance height for vertical layout. Positive values mean the */ - /* glyph has a positive advance downward. */ - /* */ - /* <Note> */ - /* If not disabled with @FT_LOAD_NO_HINTING, the values represent */ - /* dimensions of the hinted glyph (in case hinting is applicable). */ - /* */ - /* Stroking a glyph with an outside border does not increase */ - /* `horiAdvance' or `vertAdvance'; you have to manually adjust these */ - /* values to account for the added width and height. */ - /* */ - typedef struct FT_Glyph_Metrics_ - { - FT_Pos width; - FT_Pos height; - - FT_Pos horiBearingX; - FT_Pos horiBearingY; - FT_Pos horiAdvance; - - FT_Pos vertBearingX; - FT_Pos vertBearingY; - FT_Pos vertAdvance; - - } FT_Glyph_Metrics; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Bitmap_Size */ - /* */ - /* <Description> */ - /* This structure models the metrics of a bitmap strike (i.e., a set */ - /* of glyphs for a given point size and resolution) in a bitmap font. */ - /* It is used for the `available_sizes' field of @FT_Face. */ - /* */ - /* <Fields> */ - /* height :: The vertical distance, in pixels, between two */ - /* consecutive baselines. It is always positive. */ - /* */ - /* width :: The average width, in pixels, of all glyphs in the */ - /* strike. */ - /* */ - /* size :: The nominal size of the strike in 26.6 fractional */ - /* points. This field is not very useful. */ - /* */ - /* x_ppem :: The horizontal ppem (nominal width) in 26.6 fractional */ - /* pixels. */ - /* */ - /* y_ppem :: The vertical ppem (nominal height) in 26.6 fractional */ - /* pixels. */ - /* */ - /* <Note> */ - /* Windows FNT: */ - /* The nominal size given in a FNT font is not reliable. Thus when */ - /* the driver finds it incorrect, it sets `size' to some calculated */ - /* values and sets `x_ppem' and `y_ppem' to the pixel width and */ - /* height given in the font, respectively. */ - /* */ - /* TrueType embedded bitmaps: */ - /* `size', `width', and `height' values are not contained in the */ - /* bitmap strike itself. They are computed from the global font */ - /* parameters. */ - /* */ - typedef struct FT_Bitmap_Size_ - { - FT_Short height; - FT_Short width; - - FT_Pos size; - - FT_Pos x_ppem; - FT_Pos y_ppem; - - } FT_Bitmap_Size; - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* O B J E C T C L A S S E S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Library */ - /* */ - /* <Description> */ - /* A handle to a FreeType library instance. Each `library' is */ - /* completely independent from the others; it is the `root' of a set */ - /* of objects like fonts, faces, sizes, etc. */ - /* */ - /* It also embeds a memory manager (see @FT_Memory), as well as a */ - /* scan-line converter object (see @FT_Raster). */ - /* */ - /* In multi-threaded applications it is easiest to use one */ - /* `FT_Library' object per thread. In case this is too cumbersome, */ - /* a single `FT_Library' object across threads is possible also */ - /* (since FreeType version 2.5.6), as long as a mutex lock is used */ - /* around @FT_New_Face and @FT_Done_Face. */ - /* */ - /* <Note> */ - /* Library objects are normally created by @FT_Init_FreeType, and */ - /* destroyed with @FT_Done_FreeType. If you need reference-counting */ - /* (cf. @FT_Reference_Library), use @FT_New_Library and */ - /* @FT_Done_Library. */ - /* */ - typedef struct FT_LibraryRec_ *FT_Library; - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Module */ - /* */ - /* <Description> */ - /* A handle to a given FreeType module object. Each module can be a */ - /* font driver, a renderer, or anything else that provides services */ - /* to the formers. */ - /* */ - typedef struct FT_ModuleRec_* FT_Module; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Driver */ - /* */ - /* <Description> */ - /* A handle to a given FreeType font driver object. Each font driver */ - /* is a special module capable of creating faces from font files. */ - /* */ - typedef struct FT_DriverRec_* FT_Driver; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Renderer */ - /* */ - /* <Description> */ - /* A handle to a given FreeType renderer. A renderer is a special */ - /* module in charge of converting a glyph image to a bitmap, when */ - /* necessary. Each renderer supports a given glyph image format, and */ - /* one or more target surface depths. */ - /* */ - typedef struct FT_RendererRec_* FT_Renderer; - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* base_interface */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Face */ - /* */ - /* <Description> */ - /* A handle to a given typographic face object. A face object models */ - /* a given typeface, in a given style. */ - /* */ - /* <Note> */ - /* Each face object also owns a single @FT_GlyphSlot object, as well */ - /* as one or more @FT_Size objects. */ - /* */ - /* Use @FT_New_Face or @FT_Open_Face to create a new face object from */ - /* a given filepathname or a custom input stream. */ - /* */ - /* Use @FT_Done_Face to destroy it (along with its slot and sizes). */ - /* */ - /* An `FT_Face' object can only be safely used from one thread at a */ - /* time. Similarly, creation and destruction of `FT_Face' with the */ - /* same @FT_Library object can only be done from one thread at a */ - /* time. On the other hand, functions like @FT_Load_Glyph and its */ - /* siblings are thread-safe and do not need the lock to be held as */ - /* long as the same `FT_Face' object is not used from multiple */ - /* threads at the same time. */ - /* */ - /* <Also> */ - /* See @FT_FaceRec for the publicly accessible fields of a given face */ - /* object. */ - /* */ - typedef struct FT_FaceRec_* FT_Face; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Size */ - /* */ - /* <Description> */ - /* A handle to an object used to model a face scaled to a given */ - /* character size. */ - /* */ - /* <Note> */ - /* Each @FT_Face has an _active_ @FT_Size object that is used by */ - /* functions like @FT_Load_Glyph to determine the scaling */ - /* transformation that in turn is used to load and hint glyphs and */ - /* metrics. */ - /* */ - /* You can use @FT_Set_Char_Size, @FT_Set_Pixel_Sizes, */ - /* @FT_Request_Size or even @FT_Select_Size to change the content */ - /* (i.e., the scaling values) of the active @FT_Size. */ - /* */ - /* You can use @FT_New_Size to create additional size objects for a */ - /* given @FT_Face, but they won't be used by other functions until */ - /* you activate it through @FT_Activate_Size. Only one size can be */ - /* activated at any given time per face. */ - /* */ - /* <Also> */ - /* See @FT_SizeRec for the publicly accessible fields of a given size */ - /* object. */ - /* */ - typedef struct FT_SizeRec_* FT_Size; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_GlyphSlot */ - /* */ - /* <Description> */ - /* A handle to a given `glyph slot'. A slot is a container where it */ - /* is possible to load any of the glyphs contained in its parent */ - /* face. */ - /* */ - /* In other words, each time you call @FT_Load_Glyph or */ - /* @FT_Load_Char, the slot's content is erased by the new glyph data, */ - /* i.e., the glyph's metrics, its image (bitmap or outline), and */ - /* other control information. */ - /* */ - /* <Also> */ - /* See @FT_GlyphSlotRec for the publicly accessible glyph fields. */ - /* */ - typedef struct FT_GlyphSlotRec_* FT_GlyphSlot; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_CharMap */ - /* */ - /* <Description> */ - /* A handle to a given character map. A charmap is used to translate */ - /* character codes in a given encoding into glyph indexes for its */ - /* parent's face. Some font formats may provide several charmaps per */ - /* font. */ - /* */ - /* Each face object owns zero or more charmaps, but only one of them */ - /* can be `active' and used by @FT_Get_Char_Index or @FT_Load_Char. */ - /* */ - /* The list of available charmaps in a face is available through the */ - /* `face->num_charmaps' and `face->charmaps' fields of @FT_FaceRec. */ - /* */ - /* The currently active charmap is available as `face->charmap'. */ - /* You should call @FT_Set_Charmap to change it. */ - /* */ - /* <Note> */ - /* When a new face is created (either through @FT_New_Face or */ - /* @FT_Open_Face), the library looks for a Unicode charmap within */ - /* the list and automatically activates it. */ - /* */ - /* <Also> */ - /* See @FT_CharMapRec for the publicly accessible fields of a given */ - /* character map. */ - /* */ - typedef struct FT_CharMapRec_* FT_CharMap; - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_ENC_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags into an unsigned long. It is */ - /* used to define `encoding' identifiers (see @FT_Encoding). */ - /* */ - /* <Note> */ - /* Since many 16-bit compilers don't like 32-bit enumerations, you */ - /* should redefine this macro in case of problems to something like */ - /* this: */ - /* */ - /* { */ - /* #define FT_ENC_TAG( value, a, b, c, d ) value */ - /* } */ - /* */ - /* to get a simple enumeration without assigning special numbers. */ - /* */ - -#ifndef FT_ENC_TAG -#define FT_ENC_TAG( value, a, b, c, d ) \ - value = ( ( (FT_UInt32)(a) << 24 ) | \ - ( (FT_UInt32)(b) << 16 ) | \ - ( (FT_UInt32)(c) << 8 ) | \ - (FT_UInt32)(d) ) - -#endif /* FT_ENC_TAG */ - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Encoding */ - /* */ - /* <Description> */ - /* An enumeration used to specify character sets supported by */ - /* charmaps. Used in the @FT_Select_Charmap API function. */ - /* */ - /* <Note> */ - /* Despite the name, this enumeration lists specific character */ - /* repertories (i.e., charsets), and not text encoding methods (e.g., */ - /* UTF-8, UTF-16, etc.). */ - /* */ - /* Other encodings might be defined in the future. */ - /* */ - /* <Values> */ - /* FT_ENCODING_NONE :: */ - /* The encoding value~0 is reserved. */ - /* */ - /* FT_ENCODING_UNICODE :: */ - /* Corresponds to the Unicode character set. This value covers */ - /* all versions of the Unicode repertoire, including ASCII and */ - /* Latin-1. Most fonts include a Unicode charmap, but not all */ - /* of them. */ - /* */ - /* For example, if you want to access Unicode value U+1F028 (and */ - /* the font contains it), use value 0x1F028 as the input value for */ - /* @FT_Get_Char_Index. */ - /* */ - /* FT_ENCODING_MS_SYMBOL :: */ - /* Corresponds to the Microsoft Symbol encoding, used to encode */ - /* mathematical symbols and wingdings. For more information, see */ - /* `http://www.microsoft.com/typography/otspec/recom.htm', */ - /* `http://www.kostis.net/charsets/symbol.htm', and */ - /* `http://www.kostis.net/charsets/wingding.htm'. */ - /* */ - /* This encoding uses character codes from the PUA (Private Unicode */ - /* Area) in the range U+F020-U+F0FF. */ - /* */ - /* FT_ENCODING_SJIS :: */ - /* Corresponds to Japanese SJIS encoding. More info at */ - /* at `http://en.wikipedia.org/wiki/Shift_JIS'. */ - /* See note on multi-byte encodings below. */ - /* */ - /* FT_ENCODING_GB2312 :: */ - /* Corresponds to an encoding system for Simplified Chinese as used */ - /* used in mainland China. */ - /* */ - /* FT_ENCODING_BIG5 :: */ - /* Corresponds to an encoding system for Traditional Chinese as */ - /* used in Taiwan and Hong Kong. */ - /* */ - /* FT_ENCODING_WANSUNG :: */ - /* Corresponds to the Korean encoding system known as Wansung. */ - /* For more information see */ - /* `https://msdn.microsoft.com/en-US/goglobal/cc305154'. */ - /* */ - /* FT_ENCODING_JOHAB :: */ - /* The Korean standard character set (KS~C 5601-1992), which */ - /* corresponds to MS Windows code page 1361. This character set */ - /* includes all possible Hangeul character combinations. */ - /* */ - /* FT_ENCODING_ADOBE_LATIN_1 :: */ - /* Corresponds to a Latin-1 encoding as defined in a Type~1 */ - /* PostScript font. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_ADOBE_STANDARD :: */ - /* Corresponds to the Adobe Standard encoding, as found in Type~1, */ - /* CFF, and OpenType/CFF fonts. It is limited to 256 character */ - /* codes. */ - /* */ - /* FT_ENCODING_ADOBE_EXPERT :: */ - /* Corresponds to the Adobe Expert encoding, as found in Type~1, */ - /* CFF, and OpenType/CFF fonts. It is limited to 256 character */ - /* codes. */ - /* */ - /* FT_ENCODING_ADOBE_CUSTOM :: */ - /* Corresponds to a custom encoding, as found in Type~1, CFF, and */ - /* OpenType/CFF fonts. It is limited to 256 character codes. */ - /* */ - /* FT_ENCODING_APPLE_ROMAN :: */ - /* Corresponds to the 8-bit Apple roman encoding. Many TrueType */ - /* and OpenType fonts contain a charmap for this encoding, since */ - /* older versions of Mac OS are able to use it. */ - /* */ - /* FT_ENCODING_OLD_LATIN_2 :: */ - /* This value is deprecated and was never used nor reported by */ - /* FreeType. Don't use or test for it. */ - /* */ - /* FT_ENCODING_MS_SJIS :: */ - /* Same as FT_ENCODING_SJIS. Deprecated. */ - /* */ - /* FT_ENCODING_MS_GB2312 :: */ - /* Same as FT_ENCODING_GB2312. Deprecated. */ - /* */ - /* FT_ENCODING_MS_BIG5 :: */ - /* Same as FT_ENCODING_BIG5. Deprecated. */ - /* */ - /* FT_ENCODING_MS_WANSUNG :: */ - /* Same as FT_ENCODING_WANSUNG. Deprecated. */ - /* */ - /* FT_ENCODING_MS_JOHAB :: */ - /* Same as FT_ENCODING_JOHAB. Deprecated. */ - /* */ - /* <Note> */ - /* By default, FreeType automatically synthesizes a Unicode charmap */ - /* for PostScript fonts, using their glyph names dictionaries. */ - /* However, it also reports the encodings defined explicitly in the */ - /* font file, for the cases when they are needed, with the Adobe */ - /* values as well. */ - /* */ - /* FT_ENCODING_NONE is set by the BDF and PCF drivers if the charmap */ - /* is neither Unicode nor ISO-8859-1 (otherwise it is set to */ - /* FT_ENCODING_UNICODE). Use @FT_Get_BDF_Charset_ID to find out */ - /* which encoding is really present. If, for example, the */ - /* `cs_registry' field is `KOI8' and the `cs_encoding' field is `R', */ - /* the font is encoded in KOI8-R. */ - /* */ - /* FT_ENCODING_NONE is always set (with a single exception) by the */ - /* winfonts driver. Use @FT_Get_WinFNT_Header and examine the */ - /* `charset' field of the @FT_WinFNT_HeaderRec structure to find out */ - /* which encoding is really present. For example, */ - /* @FT_WinFNT_ID_CP1251 (204) means Windows code page 1251 (for */ - /* Russian). */ - /* */ - /* FT_ENCODING_NONE is set if `platform_id' is @TT_PLATFORM_MACINTOSH */ - /* and `encoding_id' is not @TT_MAC_ID_ROMAN (otherwise it is set to */ - /* FT_ENCODING_APPLE_ROMAN). */ - /* */ - /* If `platform_id' is @TT_PLATFORM_MACINTOSH, use the function */ - /* @FT_Get_CMap_Language_ID to query the Mac language ID that may */ - /* be needed to be able to distinguish Apple encoding variants. See */ - /* */ - /* http://www.unicode.org/Public/MAPPINGS/VENDORS/APPLE/Readme.txt */ - /* */ - /* to get an idea how to do that. Basically, if the language ID */ - /* is~0, don't use it, otherwise subtract 1 from the language ID. */ - /* Then examine `encoding_id'. If, for example, `encoding_id' is */ - /* @TT_MAC_ID_ROMAN and the language ID (minus~1) is */ - /* `TT_MAC_LANGID_GREEK', it is the Greek encoding, not Roman. */ - /* @TT_MAC_ID_ARABIC with `TT_MAC_LANGID_FARSI' means the Farsi */ - /* variant the Arabic encoding. */ - /* */ - typedef enum FT_Encoding_ - { - FT_ENC_TAG( FT_ENCODING_NONE, 0, 0, 0, 0 ), - - FT_ENC_TAG( FT_ENCODING_MS_SYMBOL, 's', 'y', 'm', 'b' ), - FT_ENC_TAG( FT_ENCODING_UNICODE, 'u', 'n', 'i', 'c' ), - - FT_ENC_TAG( FT_ENCODING_SJIS, 's', 'j', 'i', 's' ), - FT_ENC_TAG( FT_ENCODING_GB2312, 'g', 'b', ' ', ' ' ), - FT_ENC_TAG( FT_ENCODING_BIG5, 'b', 'i', 'g', '5' ), - FT_ENC_TAG( FT_ENCODING_WANSUNG, 'w', 'a', 'n', 's' ), - FT_ENC_TAG( FT_ENCODING_JOHAB, 'j', 'o', 'h', 'a' ), - - /* for backwards compatibility */ - FT_ENCODING_MS_SJIS = FT_ENCODING_SJIS, - FT_ENCODING_MS_GB2312 = FT_ENCODING_GB2312, - FT_ENCODING_MS_BIG5 = FT_ENCODING_BIG5, - FT_ENCODING_MS_WANSUNG = FT_ENCODING_WANSUNG, - FT_ENCODING_MS_JOHAB = FT_ENCODING_JOHAB, - - FT_ENC_TAG( FT_ENCODING_ADOBE_STANDARD, 'A', 'D', 'O', 'B' ), - FT_ENC_TAG( FT_ENCODING_ADOBE_EXPERT, 'A', 'D', 'B', 'E' ), - FT_ENC_TAG( FT_ENCODING_ADOBE_CUSTOM, 'A', 'D', 'B', 'C' ), - FT_ENC_TAG( FT_ENCODING_ADOBE_LATIN_1, 'l', 'a', 't', '1' ), - - FT_ENC_TAG( FT_ENCODING_OLD_LATIN_2, 'l', 'a', 't', '2' ), - - FT_ENC_TAG( FT_ENCODING_APPLE_ROMAN, 'a', 'r', 'm', 'n' ) - - } FT_Encoding; - - - /* these constants are deprecated; use the corresponding `FT_Encoding' */ - /* values instead */ -#define ft_encoding_none FT_ENCODING_NONE -#define ft_encoding_unicode FT_ENCODING_UNICODE -#define ft_encoding_symbol FT_ENCODING_MS_SYMBOL -#define ft_encoding_latin_1 FT_ENCODING_ADOBE_LATIN_1 -#define ft_encoding_latin_2 FT_ENCODING_OLD_LATIN_2 -#define ft_encoding_sjis FT_ENCODING_SJIS -#define ft_encoding_gb2312 FT_ENCODING_GB2312 -#define ft_encoding_big5 FT_ENCODING_BIG5 -#define ft_encoding_wansung FT_ENCODING_WANSUNG -#define ft_encoding_johab FT_ENCODING_JOHAB - -#define ft_encoding_adobe_standard FT_ENCODING_ADOBE_STANDARD -#define ft_encoding_adobe_expert FT_ENCODING_ADOBE_EXPERT -#define ft_encoding_adobe_custom FT_ENCODING_ADOBE_CUSTOM -#define ft_encoding_apple_roman FT_ENCODING_APPLE_ROMAN - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_CharMapRec */ - /* */ - /* <Description> */ - /* The base charmap structure. */ - /* */ - /* <Fields> */ - /* face :: A handle to the parent face object. */ - /* */ - /* encoding :: An @FT_Encoding tag identifying the charmap. Use */ - /* this with @FT_Select_Charmap. */ - /* */ - /* platform_id :: An ID number describing the platform for the */ - /* following encoding ID. This comes directly from */ - /* the TrueType specification and should be emulated */ - /* for other formats. */ - /* */ - /* encoding_id :: A platform specific encoding number. This also */ - /* comes from the TrueType specification and should be */ - /* emulated similarly. */ - /* */ - typedef struct FT_CharMapRec_ - { - FT_Face face; - FT_Encoding encoding; - FT_UShort platform_id; - FT_UShort encoding_id; - - } FT_CharMapRec; - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* B A S E O B J E C T C L A S S E S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Face_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Face_InternalRec' structure, used to */ - /* model private data of a given @FT_Face object. */ - /* */ - /* This structure might change between releases of FreeType~2 and is */ - /* not generally available to client applications. */ - /* */ - typedef struct FT_Face_InternalRec_* FT_Face_Internal; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_FaceRec */ - /* */ - /* <Description> */ - /* FreeType root face class structure. A face object models a */ - /* typeface in a font file. */ - /* */ - /* <Fields> */ - /* num_faces :: The number of faces in the font file. Some */ - /* font formats can have multiple faces in */ - /* a font file. */ - /* */ - /* face_index :: This field holds two different values. */ - /* Bits 0-15 are the index of the face in the */ - /* font file (starting with value~0). They */ - /* are set to~0 if there is only one face in */ - /* the font file. */ - /* */ - /* Bits 16-30 are relevant to GX variation */ - /* fonts only, holding the named instance */ - /* index for the current face index (starting */ - /* with value~1; value~0 indicates font access */ - /* without GX variation data). For non-GX */ - /* fonts, bits 16-30 are ignored. If we have */ - /* the third named instance of face~4, say, */ - /* `face_index' is set to 0x00030004. */ - /* */ - /* Bit 31 is always zero (this is, */ - /* `face_index' is always a positive value). */ - /* */ - /* face_flags :: A set of bit flags that give important */ - /* information about the face; see */ - /* @FT_FACE_FLAG_XXX for the details. */ - /* */ - /* style_flags :: The lower 16~bits contain a set of bit */ - /* flags indicating the style of the face; see */ - /* @FT_STYLE_FLAG_XXX for the details. Bits */ - /* 16-30 hold the number of named instances */ - /* available for the current face if we have a */ - /* GX variation (sub)font. Bit 31 is always */ - /* zero (this is, `style_flags' is always a */ - /* positive value). */ - /* */ - /* num_glyphs :: The number of glyphs in the face. If the */ - /* face is scalable and has sbits (see */ - /* `num_fixed_sizes'), it is set to the number */ - /* of outline glyphs. */ - /* */ - /* For CID-keyed fonts, this value gives the */ - /* highest CID used in the font. */ - /* */ - /* family_name :: The face's family name. This is an ASCII */ - /* string, usually in English, that describes */ - /* the typeface's family (like `Times New */ - /* Roman', `Bodoni', `Garamond', etc). This */ - /* is a least common denominator used to list */ - /* fonts. Some formats (TrueType & OpenType) */ - /* provide localized and Unicode versions of */ - /* this string. Applications should use the */ - /* format specific interface to access them. */ - /* Can be NULL (e.g., in fonts embedded in a */ - /* PDF file). */ - /* */ - /* In case the font doesn't provide a specific */ - /* family name entry, FreeType tries to */ - /* synthesize one, deriving it from other name */ - /* entries. */ - /* */ - /* style_name :: The face's style name. This is an ASCII */ - /* string, usually in English, that describes */ - /* the typeface's style (like `Italic', */ - /* `Bold', `Condensed', etc). Not all font */ - /* formats provide a style name, so this field */ - /* is optional, and can be set to NULL. As */ - /* for `family_name', some formats provide */ - /* localized and Unicode versions of this */ - /* string. Applications should use the format */ - /* specific interface to access them. */ - /* */ - /* num_fixed_sizes :: The number of bitmap strikes in the face. */ - /* Even if the face is scalable, there might */ - /* still be bitmap strikes, which are called */ - /* `sbits' in that case. */ - /* */ - /* available_sizes :: An array of @FT_Bitmap_Size for all bitmap */ - /* strikes in the face. It is set to NULL if */ - /* there is no bitmap strike. */ - /* */ - /* num_charmaps :: The number of charmaps in the face. */ - /* */ - /* charmaps :: An array of the charmaps of the face. */ - /* */ - /* generic :: A field reserved for client uses. See the */ - /* @FT_Generic type description. */ - /* */ - /* bbox :: The font bounding box. Coordinates are */ - /* expressed in font units (see */ - /* `units_per_EM'). The box is large enough */ - /* to contain any glyph from the font. Thus, */ - /* `bbox.yMax' can be seen as the `maximum */ - /* ascender', and `bbox.yMin' as the `minimum */ - /* descender'. Only relevant for scalable */ - /* formats. */ - /* */ - /* Note that the bounding box might be off by */ - /* (at least) one pixel for hinted fonts. See */ - /* @FT_Size_Metrics for further discussion. */ - /* */ - /* units_per_EM :: The number of font units per EM square for */ - /* this face. This is typically 2048 for */ - /* TrueType fonts, and 1000 for Type~1 fonts. */ - /* Only relevant for scalable formats. */ - /* */ - /* ascender :: The typographic ascender of the face, */ - /* expressed in font units. For font formats */ - /* not having this information, it is set to */ - /* `bbox.yMax'. Only relevant for scalable */ - /* formats. */ - /* */ - /* descender :: The typographic descender of the face, */ - /* expressed in font units. For font formats */ - /* not having this information, it is set to */ - /* `bbox.yMin'. Note that this field is */ - /* usually negative. Only relevant for */ - /* scalable formats. */ - /* */ - /* height :: This value is the vertical distance */ - /* between two consecutive baselines, */ - /* expressed in font units. It is always */ - /* positive. Only relevant for scalable */ - /* formats. */ - /* */ - /* If you want the global glyph height, use */ - /* `ascender - descender'. */ - /* */ - /* max_advance_width :: The maximum advance width, in font units, */ - /* for all glyphs in this face. This can be */ - /* used to make word wrapping computations */ - /* faster. Only relevant for scalable */ - /* formats. */ - /* */ - /* max_advance_height :: The maximum advance height, in font units, */ - /* for all glyphs in this face. This is only */ - /* relevant for vertical layouts, and is set */ - /* to `height' for fonts that do not provide */ - /* vertical metrics. Only relevant for */ - /* scalable formats. */ - /* */ - /* underline_position :: The position, in font units, of the */ - /* underline line for this face. It is the */ - /* center of the underlining stem. Only */ - /* relevant for scalable formats. */ - /* */ - /* underline_thickness :: The thickness, in font units, of the */ - /* underline for this face. Only relevant for */ - /* scalable formats. */ - /* */ - /* glyph :: The face's associated glyph slot(s). */ - /* */ - /* size :: The current active size for this face. */ - /* */ - /* charmap :: The current active charmap for this face. */ - /* */ - /* <Note> */ - /* Fields may be changed after a call to @FT_Attach_File or */ - /* @FT_Attach_Stream. */ - /* */ - typedef struct FT_FaceRec_ - { - FT_Long num_faces; - FT_Long face_index; - - FT_Long face_flags; - FT_Long style_flags; - - FT_Long num_glyphs; - - FT_String* family_name; - FT_String* style_name; - - FT_Int num_fixed_sizes; - FT_Bitmap_Size* available_sizes; - - FT_Int num_charmaps; - FT_CharMap* charmaps; - - FT_Generic generic; - - /*# The following member variables (down to `underline_thickness') */ - /*# are only relevant to scalable outlines; cf. @FT_Bitmap_Size */ - /*# for bitmap fonts. */ - FT_BBox bbox; - - FT_UShort units_per_EM; - FT_Short ascender; - FT_Short descender; - FT_Short height; - - FT_Short max_advance_width; - FT_Short max_advance_height; - - FT_Short underline_position; - FT_Short underline_thickness; - - FT_GlyphSlot glyph; - FT_Size size; - FT_CharMap charmap; - - /*@private begin */ - - FT_Driver driver; - FT_Memory memory; - FT_Stream stream; - - FT_ListRec sizes_list; - - FT_Generic autohint; /* face-specific auto-hinter data */ - void* extensions; /* unused */ - - FT_Face_Internal internal; - - /*@private end */ - - } FT_FaceRec; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_FACE_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used in the `face_flags' field of the */ - /* @FT_FaceRec structure. They inform client applications of */ - /* properties of the corresponding face. */ - /* */ - /* <Values> */ - /* FT_FACE_FLAG_SCALABLE :: */ - /* Indicates that the face contains outline glyphs. This doesn't */ - /* prevent bitmap strikes, i.e., a face can have both this and */ - /* and @FT_FACE_FLAG_FIXED_SIZES set. */ - /* */ - /* FT_FACE_FLAG_FIXED_SIZES :: */ - /* Indicates that the face contains bitmap strikes. See also the */ - /* `num_fixed_sizes' and `available_sizes' fields of @FT_FaceRec. */ - /* */ - /* FT_FACE_FLAG_FIXED_WIDTH :: */ - /* Indicates that the face contains fixed-width characters (like */ - /* Courier, Lucido, MonoType, etc.). */ - /* */ - /* FT_FACE_FLAG_SFNT :: */ - /* Indicates that the face uses the `sfnt' storage scheme. For */ - /* now, this means TrueType and OpenType. */ - /* */ - /* FT_FACE_FLAG_HORIZONTAL :: */ - /* Indicates that the face contains horizontal glyph metrics. This */ - /* should be set for all common formats. */ - /* */ - /* FT_FACE_FLAG_VERTICAL :: */ - /* Indicates that the face contains vertical glyph metrics. This */ - /* is only available in some formats, not all of them. */ - /* */ - /* FT_FACE_FLAG_KERNING :: */ - /* Indicates that the face contains kerning information. If set, */ - /* the kerning distance can be retrieved through the function */ - /* @FT_Get_Kerning. Otherwise the function always return the */ - /* vector (0,0). Note that FreeType doesn't handle kerning data */ - /* from the `GPOS' table (as present in some OpenType fonts). */ - /* */ - /* FT_FACE_FLAG_FAST_GLYPHS :: */ - /* THIS FLAG IS DEPRECATED. DO NOT USE OR TEST IT. */ - /* */ - /* FT_FACE_FLAG_MULTIPLE_MASTERS :: */ - /* Indicates that the font contains multiple masters and is capable */ - /* of interpolating between them. See the multiple-masters */ - /* specific API for details. */ - /* */ - /* FT_FACE_FLAG_GLYPH_NAMES :: */ - /* Indicates that the font contains glyph names that can be */ - /* retrieved through @FT_Get_Glyph_Name. Note that some TrueType */ - /* fonts contain broken glyph name tables. Use the function */ - /* @FT_Has_PS_Glyph_Names when needed. */ - /* */ - /* FT_FACE_FLAG_EXTERNAL_STREAM :: */ - /* Used internally by FreeType to indicate that a face's stream was */ - /* provided by the client application and should not be destroyed */ - /* when @FT_Done_Face is called. Don't read or test this flag. */ - /* */ - /* FT_FACE_FLAG_HINTER :: */ - /* Set if the font driver has a hinting machine of its own. For */ - /* example, with TrueType fonts, it makes sense to use data from */ - /* the SFNT `gasp' table only if the native TrueType hinting engine */ - /* (with the bytecode interpreter) is available and active. */ - /* */ - /* FT_FACE_FLAG_CID_KEYED :: */ - /* Set if the font is CID-keyed. In that case, the font is not */ - /* accessed by glyph indices but by CID values. For subsetted */ - /* CID-keyed fonts this has the consequence that not all index */ - /* values are a valid argument to FT_Load_Glyph. Only the CID */ - /* values for which corresponding glyphs in the subsetted font */ - /* exist make FT_Load_Glyph return successfully; in all other cases */ - /* you get an `FT_Err_Invalid_Argument' error. */ - /* */ - /* Note that CID-keyed fonts that are in an SFNT wrapper don't */ - /* have this flag set since the glyphs are accessed in the normal */ - /* way (using contiguous indices); the `CID-ness' isn't visible to */ - /* the application. */ - /* */ - /* FT_FACE_FLAG_TRICKY :: */ - /* Set if the font is `tricky', this is, it always needs the */ - /* font format's native hinting engine to get a reasonable result. */ - /* A typical example is the Chinese font `mingli.ttf' that uses */ - /* TrueType bytecode instructions to move and scale all of its */ - /* subglyphs. */ - /* */ - /* It is not possible to auto-hint such fonts using */ - /* @FT_LOAD_FORCE_AUTOHINT; it will also ignore */ - /* @FT_LOAD_NO_HINTING. You have to set both @FT_LOAD_NO_HINTING */ - /* and @FT_LOAD_NO_AUTOHINT to really disable hinting; however, you */ - /* probably never want this except for demonstration purposes. */ - /* */ - /* Currently, there are about a dozen TrueType fonts in the list of */ - /* tricky fonts; they are hard-coded in file `ttobjs.c'. */ - /* */ - /* FT_FACE_FLAG_COLOR :: */ - /* Set if the font has color glyph tables. To access color glyphs */ - /* use @FT_LOAD_COLOR. */ - /* */ -#define FT_FACE_FLAG_SCALABLE ( 1L << 0 ) -#define FT_FACE_FLAG_FIXED_SIZES ( 1L << 1 ) -#define FT_FACE_FLAG_FIXED_WIDTH ( 1L << 2 ) -#define FT_FACE_FLAG_SFNT ( 1L << 3 ) -#define FT_FACE_FLAG_HORIZONTAL ( 1L << 4 ) -#define FT_FACE_FLAG_VERTICAL ( 1L << 5 ) -#define FT_FACE_FLAG_KERNING ( 1L << 6 ) -#define FT_FACE_FLAG_FAST_GLYPHS ( 1L << 7 ) -#define FT_FACE_FLAG_MULTIPLE_MASTERS ( 1L << 8 ) -#define FT_FACE_FLAG_GLYPH_NAMES ( 1L << 9 ) -#define FT_FACE_FLAG_EXTERNAL_STREAM ( 1L << 10 ) -#define FT_FACE_FLAG_HINTER ( 1L << 11 ) -#define FT_FACE_FLAG_CID_KEYED ( 1L << 12 ) -#define FT_FACE_FLAG_TRICKY ( 1L << 13 ) -#define FT_FACE_FLAG_COLOR ( 1L << 14 ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_HORIZONTAL( face ) - * - * @description: - * A macro that returns true whenever a face object contains - * horizontal metrics (this is true for all font formats though). - * - * @also: - * @FT_HAS_VERTICAL can be used to check for vertical metrics. - * - */ -#define FT_HAS_HORIZONTAL( face ) \ - ( face->face_flags & FT_FACE_FLAG_HORIZONTAL ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_VERTICAL( face ) - * - * @description: - * A macro that returns true whenever a face object contains real - * vertical metrics (and not only synthesized ones). - * - */ -#define FT_HAS_VERTICAL( face ) \ - ( face->face_flags & FT_FACE_FLAG_VERTICAL ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_KERNING( face ) - * - * @description: - * A macro that returns true whenever a face object contains kerning - * data that can be accessed with @FT_Get_Kerning. - * - */ -#define FT_HAS_KERNING( face ) \ - ( face->face_flags & FT_FACE_FLAG_KERNING ) - - - /************************************************************************* - * - * @macro: - * FT_IS_SCALABLE( face ) - * - * @description: - * A macro that returns true whenever a face object contains a scalable - * font face (true for TrueType, Type~1, Type~42, CID, OpenType/CFF, - * and PFR font formats. - * - */ -#define FT_IS_SCALABLE( face ) \ - ( face->face_flags & FT_FACE_FLAG_SCALABLE ) - - - /************************************************************************* - * - * @macro: - * FT_IS_SFNT( face ) - * - * @description: - * A macro that returns true whenever a face object contains a font - * whose format is based on the SFNT storage scheme. This usually - * means: TrueType fonts, OpenType fonts, as well as SFNT-based embedded - * bitmap fonts. - * - * If this macro is true, all functions defined in @FT_SFNT_NAMES_H and - * @FT_TRUETYPE_TABLES_H are available. - * - */ -#define FT_IS_SFNT( face ) \ - ( face->face_flags & FT_FACE_FLAG_SFNT ) - - - /************************************************************************* - * - * @macro: - * FT_IS_FIXED_WIDTH( face ) - * - * @description: - * A macro that returns true whenever a face object contains a font face - * that contains fixed-width (or `monospace', `fixed-pitch', etc.) - * glyphs. - * - */ -#define FT_IS_FIXED_WIDTH( face ) \ - ( face->face_flags & FT_FACE_FLAG_FIXED_WIDTH ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_FIXED_SIZES( face ) - * - * @description: - * A macro that returns true whenever a face object contains some - * embedded bitmaps. See the `available_sizes' field of the - * @FT_FaceRec structure. - * - */ -#define FT_HAS_FIXED_SIZES( face ) \ - ( face->face_flags & FT_FACE_FLAG_FIXED_SIZES ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_FAST_GLYPHS( face ) - * - * @description: - * Deprecated. - * - */ -#define FT_HAS_FAST_GLYPHS( face ) 0 - - - /************************************************************************* - * - * @macro: - * FT_HAS_GLYPH_NAMES( face ) - * - * @description: - * A macro that returns true whenever a face object contains some glyph - * names that can be accessed through @FT_Get_Glyph_Name. - * - */ -#define FT_HAS_GLYPH_NAMES( face ) \ - ( face->face_flags & FT_FACE_FLAG_GLYPH_NAMES ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_MULTIPLE_MASTERS( face ) - * - * @description: - * A macro that returns true whenever a face object contains some - * multiple masters. The functions provided by @FT_MULTIPLE_MASTERS_H - * are then available to choose the exact design you want. - * - */ -#define FT_HAS_MULTIPLE_MASTERS( face ) \ - ( face->face_flags & FT_FACE_FLAG_MULTIPLE_MASTERS ) - - - /************************************************************************* - * - * @macro: - * FT_IS_CID_KEYED( face ) - * - * @description: - * A macro that returns true whenever a face object contains a CID-keyed - * font. See the discussion of @FT_FACE_FLAG_CID_KEYED for more - * details. - * - * If this macro is true, all functions defined in @FT_CID_H are - * available. - * - */ -#define FT_IS_CID_KEYED( face ) \ - ( face->face_flags & FT_FACE_FLAG_CID_KEYED ) - - - /************************************************************************* - * - * @macro: - * FT_IS_TRICKY( face ) - * - * @description: - * A macro that returns true whenever a face represents a `tricky' font. - * See the discussion of @FT_FACE_FLAG_TRICKY for more details. - * - */ -#define FT_IS_TRICKY( face ) \ - ( face->face_flags & FT_FACE_FLAG_TRICKY ) - - - /************************************************************************* - * - * @macro: - * FT_HAS_COLOR( face ) - * - * @description: - * A macro that returns true whenever a face object contains - * tables for color glyphs. - * - */ -#define FT_HAS_COLOR( face ) \ - ( face->face_flags & FT_FACE_FLAG_COLOR ) - - - /*************************************************************************/ - /* */ - /* <Const> */ - /* FT_STYLE_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used to indicate the style of a given face. */ - /* These are used in the `style_flags' field of @FT_FaceRec. */ - /* */ - /* <Values> */ - /* FT_STYLE_FLAG_ITALIC :: */ - /* Indicates that a given face style is italic or oblique. */ - /* */ - /* FT_STYLE_FLAG_BOLD :: */ - /* Indicates that a given face is bold. */ - /* */ - /* <Note> */ - /* The style information as provided by FreeType is very basic. More */ - /* details are beyond the scope and should be done on a higher level */ - /* (for example, by analyzing various fields of the `OS/2' table in */ - /* SFNT based fonts). */ - /* */ -#define FT_STYLE_FLAG_ITALIC ( 1 << 0 ) -#define FT_STYLE_FLAG_BOLD ( 1 << 1 ) - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Size_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Size_InternalRec' structure, used to */ - /* model private data of a given @FT_Size object. */ - /* */ - typedef struct FT_Size_InternalRec_* FT_Size_Internal; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_Metrics */ - /* */ - /* <Description> */ - /* The size metrics structure gives the metrics of a size object. */ - /* */ - /* <Fields> */ - /* x_ppem :: The width of the scaled EM square in pixels, hence */ - /* the term `ppem' (pixels per EM). It is also */ - /* referred to as `nominal width'. */ - /* */ - /* y_ppem :: The height of the scaled EM square in pixels, */ - /* hence the term `ppem' (pixels per EM). It is also */ - /* referred to as `nominal height'. */ - /* */ - /* x_scale :: A 16.16 fractional scaling value used to convert */ - /* horizontal metrics from font units to 26.6 */ - /* fractional pixels. Only relevant for scalable */ - /* font formats. */ - /* */ - /* y_scale :: A 16.16 fractional scaling value used to convert */ - /* vertical metrics from font units to 26.6 */ - /* fractional pixels. Only relevant for scalable */ - /* font formats. */ - /* */ - /* ascender :: The ascender in 26.6 fractional pixels. See */ - /* @FT_FaceRec for the details. */ - /* */ - /* descender :: The descender in 26.6 fractional pixels. See */ - /* @FT_FaceRec for the details. */ - /* */ - /* height :: The height in 26.6 fractional pixels. See */ - /* @FT_FaceRec for the details. */ - /* */ - /* max_advance :: The maximum advance width in 26.6 fractional */ - /* pixels. See @FT_FaceRec for the details. */ - /* */ - /* <Note> */ - /* The scaling values, if relevant, are determined first during a */ - /* size changing operation. The remaining fields are then set by the */ - /* driver. For scalable formats, they are usually set to scaled */ - /* values of the corresponding fields in @FT_FaceRec. */ - /* */ - /* Note that due to glyph hinting, these values might not be exact */ - /* for certain fonts. Thus they must be treated as unreliable */ - /* with an error margin of at least one pixel! */ - /* */ - /* Indeed, the only way to get the exact metrics is to render _all_ */ - /* glyphs. As this would be a definite performance hit, it is up to */ - /* client applications to perform such computations. */ - /* */ - /* The FT_Size_Metrics structure is valid for bitmap fonts also. */ - /* */ - typedef struct FT_Size_Metrics_ - { - FT_UShort x_ppem; /* horizontal pixels per EM */ - FT_UShort y_ppem; /* vertical pixels per EM */ - - FT_Fixed x_scale; /* scaling values used to convert font */ - FT_Fixed y_scale; /* units to 26.6 fractional pixels */ - - FT_Pos ascender; /* ascender in 26.6 frac. pixels */ - FT_Pos descender; /* descender in 26.6 frac. pixels */ - FT_Pos height; /* text height in 26.6 frac. pixels */ - FT_Pos max_advance; /* max horizontal advance, in 26.6 pixels */ - - } FT_Size_Metrics; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SizeRec */ - /* */ - /* <Description> */ - /* FreeType root size class structure. A size object models a face */ - /* object at a given size. */ - /* */ - /* <Fields> */ - /* face :: Handle to the parent face object. */ - /* */ - /* generic :: A typeless pointer, unused by the FreeType library or */ - /* any of its drivers. It can be used by client */ - /* applications to link their own data to each size */ - /* object. */ - /* */ - /* metrics :: Metrics for this size object. This field is read-only. */ - /* */ - typedef struct FT_SizeRec_ - { - FT_Face face; /* parent face object */ - FT_Generic generic; /* generic pointer for client uses */ - FT_Size_Metrics metrics; /* size metrics */ - FT_Size_Internal internal; - - } FT_SizeRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SubGlyph */ - /* */ - /* <Description> */ - /* The subglyph structure is an internal object used to describe */ - /* subglyphs (for example, in the case of composites). */ - /* */ - /* <Note> */ - /* The subglyph implementation is not part of the high-level API, */ - /* hence the forward structure declaration. */ - /* */ - /* You can however retrieve subglyph information with */ - /* @FT_Get_SubGlyph_Info. */ - /* */ - typedef struct FT_SubGlyphRec_* FT_SubGlyph; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Slot_Internal */ - /* */ - /* <Description> */ - /* An opaque handle to an `FT_Slot_InternalRec' structure, used to */ - /* model private data of a given @FT_GlyphSlot object. */ - /* */ - typedef struct FT_Slot_InternalRec_* FT_Slot_Internal; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphSlotRec */ - /* */ - /* <Description> */ - /* FreeType root glyph slot class structure. A glyph slot is a */ - /* container where individual glyphs can be loaded, be they in */ - /* outline or bitmap format. */ - /* */ - /* <Fields> */ - /* library :: A handle to the FreeType library instance */ - /* this slot belongs to. */ - /* */ - /* face :: A handle to the parent face object. */ - /* */ - /* next :: In some cases (like some font tools), several */ - /* glyph slots per face object can be a good */ - /* thing. As this is rare, the glyph slots are */ - /* listed through a direct, single-linked list */ - /* using its `next' field. */ - /* */ - /* generic :: A typeless pointer unused by the FreeType */ - /* library or any of its drivers. It can be */ - /* used by client applications to link their own */ - /* data to each glyph slot object. */ - /* */ - /* metrics :: The metrics of the last loaded glyph in the */ - /* slot. The returned values depend on the last */ - /* load flags (see the @FT_Load_Glyph API */ - /* function) and can be expressed either in 26.6 */ - /* fractional pixels or font units. */ - /* */ - /* Note that even when the glyph image is */ - /* transformed, the metrics are not. */ - /* */ - /* linearHoriAdvance :: The advance width of the unhinted glyph. */ - /* Its value is expressed in 16.16 fractional */ - /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ - /* when loading the glyph. This field can be */ - /* important to perform correct WYSIWYG layout. */ - /* Only relevant for outline glyphs. */ - /* */ - /* linearVertAdvance :: The advance height of the unhinted glyph. */ - /* Its value is expressed in 16.16 fractional */ - /* pixels, unless @FT_LOAD_LINEAR_DESIGN is set */ - /* when loading the glyph. This field can be */ - /* important to perform correct WYSIWYG layout. */ - /* Only relevant for outline glyphs. */ - /* */ - /* advance :: This shorthand is, depending on */ - /* @FT_LOAD_IGNORE_TRANSFORM, the transformed */ - /* (hinted) advance width for the glyph, in 26.6 */ - /* fractional pixel format. As specified with */ - /* @FT_LOAD_VERTICAL_LAYOUT, it uses either the */ - /* `horiAdvance' or the `vertAdvance' value of */ - /* `metrics' field. */ - /* */ - /* format :: This field indicates the format of the image */ - /* contained in the glyph slot. Typically */ - /* @FT_GLYPH_FORMAT_BITMAP, */ - /* @FT_GLYPH_FORMAT_OUTLINE, or */ - /* @FT_GLYPH_FORMAT_COMPOSITE, but others are */ - /* possible. */ - /* */ - /* bitmap :: This field is used as a bitmap descriptor */ - /* when the slot format is */ - /* @FT_GLYPH_FORMAT_BITMAP. Note that the */ - /* address and content of the bitmap buffer can */ - /* change between calls of @FT_Load_Glyph and a */ - /* few other functions. */ - /* */ - /* bitmap_left :: The bitmap's left bearing expressed in */ - /* integer pixels. Only valid if the format is */ - /* @FT_GLYPH_FORMAT_BITMAP, this is, if the */ - /* glyph slot contains a bitmap. */ - /* */ - /* bitmap_top :: The bitmap's top bearing expressed in integer */ - /* pixels. Remember that this is the distance */ - /* from the baseline to the top-most glyph */ - /* scanline, upwards y~coordinates being */ - /* *positive*. */ - /* */ - /* outline :: The outline descriptor for the current glyph */ - /* image if its format is */ - /* @FT_GLYPH_FORMAT_OUTLINE. Once a glyph is */ - /* loaded, `outline' can be transformed, */ - /* distorted, embolded, etc. However, it must */ - /* not be freed. */ - /* */ - /* num_subglyphs :: The number of subglyphs in a composite glyph. */ - /* This field is only valid for the composite */ - /* glyph format that should normally only be */ - /* loaded with the @FT_LOAD_NO_RECURSE flag. */ - /* */ - /* subglyphs :: An array of subglyph descriptors for */ - /* composite glyphs. There are `num_subglyphs' */ - /* elements in there. Currently internal to */ - /* FreeType. */ - /* */ - /* control_data :: Certain font drivers can also return the */ - /* control data for a given glyph image (e.g. */ - /* TrueType bytecode, Type~1 charstrings, etc.). */ - /* This field is a pointer to such data. */ - /* */ - /* control_len :: This is the length in bytes of the control */ - /* data. */ - /* */ - /* other :: Really wicked formats can use this pointer to */ - /* present their own glyph image to client */ - /* applications. Note that the application */ - /* needs to know about the image format. */ - /* */ - /* lsb_delta :: The difference between hinted and unhinted */ - /* left side bearing while auto-hinting is */ - /* active. Zero otherwise. */ - /* */ - /* rsb_delta :: The difference between hinted and unhinted */ - /* right side bearing while auto-hinting is */ - /* active. Zero otherwise. */ - /* */ - /* <Note> */ - /* If @FT_Load_Glyph is called with default flags (see */ - /* @FT_LOAD_DEFAULT) the glyph image is loaded in the glyph slot in */ - /* its native format (e.g., an outline glyph for TrueType and Type~1 */ - /* formats). */ - /* */ - /* This image can later be converted into a bitmap by calling */ - /* @FT_Render_Glyph. This function finds the current renderer for */ - /* the native image's format, then invokes it. */ - /* */ - /* The renderer is in charge of transforming the native image through */ - /* the slot's face transformation fields, then converting it into a */ - /* bitmap that is returned in `slot->bitmap'. */ - /* */ - /* Note that `slot->bitmap_left' and `slot->bitmap_top' are also used */ - /* to specify the position of the bitmap relative to the current pen */ - /* position (e.g., coordinates (0,0) on the baseline). Of course, */ - /* `slot->format' is also changed to @FT_GLYPH_FORMAT_BITMAP. */ - /* */ - /* <Note> */ - /* Here is a small pseudo code fragment that shows how to use */ - /* `lsb_delta' and `rsb_delta': */ - /* */ - /* { */ - /* FT_Pos origin_x = 0; */ - /* FT_Pos prev_rsb_delta = 0; */ - /* */ - /* */ - /* for all glyphs do */ - /* <compute kern between current and previous glyph and add it to */ - /* `origin_x'> */ - /* */ - /* <load glyph with `FT_Load_Glyph'> */ - /* */ - /* if ( prev_rsb_delta - face->glyph->lsb_delta >= 32 ) */ - /* origin_x -= 64; */ - /* else if ( prev_rsb_delta - face->glyph->lsb_delta < -32 ) */ - /* origin_x += 64; */ - /* */ - /* prev_rsb_delta = face->glyph->rsb_delta; */ - /* */ - /* <save glyph image, or render glyph, or ...> */ - /* */ - /* origin_x += face->glyph->advance.x; */ - /* endfor */ - /* } */ - /* */ - typedef struct FT_GlyphSlotRec_ - { - FT_Library library; - FT_Face face; - FT_GlyphSlot next; - FT_UInt reserved; /* retained for binary compatibility */ - FT_Generic generic; - - FT_Glyph_Metrics metrics; - FT_Fixed linearHoriAdvance; - FT_Fixed linearVertAdvance; - FT_Vector advance; - - FT_Glyph_Format format; - - FT_Bitmap bitmap; - FT_Int bitmap_left; - FT_Int bitmap_top; - - FT_Outline outline; - - FT_UInt num_subglyphs; - FT_SubGlyph subglyphs; - - void* control_data; - long control_len; - - FT_Pos lsb_delta; - FT_Pos rsb_delta; - - void* other; - - FT_Slot_Internal internal; - - } FT_GlyphSlotRec; - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* F U N C T I O N S */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Init_FreeType */ - /* */ - /* <Description> */ - /* Initialize a new FreeType library object. The set of modules */ - /* that are registered by this function is determined at build time. */ - /* */ - /* <Output> */ - /* alibrary :: A handle to a new library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* In case you want to provide your own memory allocating routines, */ - /* use @FT_New_Library instead, followed by a call to */ - /* @FT_Add_Default_Modules (or a series of calls to @FT_Add_Module). */ - /* */ - /* See the documentation of @FT_Library and @FT_Face for */ - /* multi-threading issues. */ - /* */ - /* If you need reference-counting (cf. @FT_Reference_Library), use */ - /* @FT_New_Library and @FT_Done_Library. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Init_FreeType( FT_Library *alibrary ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_FreeType */ - /* */ - /* <Description> */ - /* Destroy a given FreeType library object and all of its children, */ - /* including resources, drivers, faces, sizes, etc. */ - /* */ - /* <Input> */ - /* library :: A handle to the target library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Done_FreeType( FT_Library library ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_OPEN_XXX */ - /* */ - /* <Description> */ - /* A list of bit field constants used within the `flags' field of the */ - /* @FT_Open_Args structure. */ - /* */ - /* <Values> */ - /* FT_OPEN_MEMORY :: This is a memory-based stream. */ - /* */ - /* FT_OPEN_STREAM :: Copy the stream from the `stream' field. */ - /* */ - /* FT_OPEN_PATHNAME :: Create a new input stream from a C~path */ - /* name. */ - /* */ - /* FT_OPEN_DRIVER :: Use the `driver' field. */ - /* */ - /* FT_OPEN_PARAMS :: Use the `num_params' and `params' fields. */ - /* */ - /* <Note> */ - /* The `FT_OPEN_MEMORY', `FT_OPEN_STREAM', and `FT_OPEN_PATHNAME' */ - /* flags are mutually exclusive. */ - /* */ -#define FT_OPEN_MEMORY 0x1 -#define FT_OPEN_STREAM 0x2 -#define FT_OPEN_PATHNAME 0x4 -#define FT_OPEN_DRIVER 0x8 -#define FT_OPEN_PARAMS 0x10 - - - /* these constants are deprecated; use the corresponding `FT_OPEN_XXX' */ - /* values instead */ -#define ft_open_memory FT_OPEN_MEMORY -#define ft_open_stream FT_OPEN_STREAM -#define ft_open_pathname FT_OPEN_PATHNAME -#define ft_open_driver FT_OPEN_DRIVER -#define ft_open_params FT_OPEN_PARAMS - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Parameter */ - /* */ - /* <Description> */ - /* A simple structure used to pass more or less generic parameters to */ - /* @FT_Open_Face. */ - /* */ - /* <Fields> */ - /* tag :: A four-byte identification tag. */ - /* */ - /* data :: A pointer to the parameter data. */ - /* */ - /* <Note> */ - /* The ID and function of parameters are driver-specific. See the */ - /* various FT_PARAM_TAG_XXX flags for more information. */ - /* */ - typedef struct FT_Parameter_ - { - FT_ULong tag; - FT_Pointer data; - - } FT_Parameter; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Open_Args */ - /* */ - /* <Description> */ - /* A structure used to indicate how to open a new font file or */ - /* stream. A pointer to such a structure can be used as a parameter */ - /* for the functions @FT_Open_Face and @FT_Attach_Stream. */ - /* */ - /* <Fields> */ - /* flags :: A set of bit flags indicating how to use the */ - /* structure. */ - /* */ - /* memory_base :: The first byte of the file in memory. */ - /* */ - /* memory_size :: The size in bytes of the file in memory. */ - /* */ - /* pathname :: A pointer to an 8-bit file pathname. */ - /* */ - /* stream :: A handle to a source stream object. */ - /* */ - /* driver :: This field is exclusively used by @FT_Open_Face; */ - /* it simply specifies the font driver to use to open */ - /* the face. If set to~0, FreeType tries to load the */ - /* face with each one of the drivers in its list. */ - /* */ - /* num_params :: The number of extra parameters. */ - /* */ - /* params :: Extra parameters passed to the font driver when */ - /* opening a new face. */ - /* */ - /* <Note> */ - /* The stream type is determined by the contents of `flags' that */ - /* are tested in the following order by @FT_Open_Face: */ - /* */ - /* If the @FT_OPEN_MEMORY bit is set, assume that this is a */ - /* memory file of `memory_size' bytes, located at `memory_address'. */ - /* The data are are not copied, and the client is responsible for */ - /* releasing and destroying them _after_ the corresponding call to */ - /* @FT_Done_Face. */ - /* */ - /* Otherwise, if the @FT_OPEN_STREAM bit is set, assume that a */ - /* custom input stream `stream' is used. */ - /* */ - /* Otherwise, if the @FT_OPEN_PATHNAME bit is set, assume that this */ - /* is a normal file and use `pathname' to open it. */ - /* */ - /* If the @FT_OPEN_DRIVER bit is set, @FT_Open_Face only tries to */ - /* open the file with the driver whose handler is in `driver'. */ - /* */ - /* If the @FT_OPEN_PARAMS bit is set, the parameters given by */ - /* `num_params' and `params' is used. They are ignored otherwise. */ - /* */ - /* Ideally, both the `pathname' and `params' fields should be tagged */ - /* as `const'; this is missing for API backwards compatibility. In */ - /* other words, applications should treat them as read-only. */ - /* */ - typedef struct FT_Open_Args_ - { - FT_UInt flags; - const FT_Byte* memory_base; - FT_Long memory_size; - FT_String* pathname; - FT_Stream stream; - FT_Module driver; - FT_Int num_params; - FT_Parameter* params; - - } FT_Open_Args; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face */ - /* */ - /* <Description> */ - /* This function calls @FT_Open_Face to open a font by its pathname. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* pathname :: A path to the font file. */ - /* */ - /* face_index :: See @FT_Open_Face for a detailed description of this */ - /* parameter. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Use @FT_Done_Face to destroy the created @FT_Face object (along */ - /* with its slot and sizes). */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Face( FT_Library library, - const char* filepathname, - FT_Long face_index, - FT_Face *aface ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Memory_Face */ - /* */ - /* <Description> */ - /* This function calls @FT_Open_Face to open a font that has been */ - /* loaded into memory. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* file_base :: A pointer to the beginning of the font data. */ - /* */ - /* file_size :: The size of the memory chunk used by the font data. */ - /* */ - /* face_index :: See @FT_Open_Face for a detailed description of this */ - /* parameter. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You must not deallocate the memory before calling @FT_Done_Face. */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Memory_Face( FT_Library library, - const FT_Byte* file_base, - FT_Long file_size, - FT_Long face_index, - FT_Face *aface ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Open_Face */ - /* */ - /* <Description> */ - /* Create a face object from a given resource described by */ - /* @FT_Open_Args. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* args :: A pointer to an `FT_Open_Args' structure that must */ - /* be filled by the caller. */ - /* */ - /* face_index :: This field holds two different values. Bits 0-15 */ - /* are the index of the face in the font file (starting */ - /* with value~0). Set it to~0 if there is only one */ - /* face in the font file. */ - /* */ - /* Bits 16-30 are relevant to GX variation fonts only, */ - /* specifying the named instance index for the current */ - /* face index (starting with value~1; value~0 makes */ - /* FreeType ignore named instances). For non-GX fonts, */ - /* bits 16-30 are ignored. Assuming that you want to */ - /* access the third named instance in face~4, */ - /* `face_index' should be set to 0x00030004. If you */ - /* want to access face~4 without GX variation handling, */ - /* simply set `face_index' to value~4. */ - /* */ - /* FT_Open_Face and its siblings can be used to quickly */ - /* check whether the font format of a given font */ - /* resource is supported by FreeType. In general, if */ - /* the `face_index' argument is negative, the */ - /* function's return value is~0 if the font format is */ - /* recognized, or non-zero otherwise. The function */ - /* allocates a more or less empty face handle in */ - /* `*aface' (if `aface' isn't NULL); the only two */ - /* useful fields in this special case are */ - /* `face->num_faces' and `face->style_flags'. For any */ - /* negative value of `face_index', `face->num_faces' */ - /* gives the number of faces within the font file. For */ - /* the negative value `-(N+1)' (with `N' a 16-bit */ - /* value), bits 16-30 in `face->style_flags' give the */ - /* number of named instances in face `N' if we have a */ - /* GX variation font (or zero otherwise). After */ - /* examination, the returned @FT_Face structure should */ - /* be deallocated with a call to @FT_Done_Face. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. If `face_index' is */ - /* greater than or equal to zero, it must be non-NULL. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Unlike FreeType 1.x, this function automatically creates a glyph */ - /* slot for the face object that can be accessed directly through */ - /* `face->glyph'. */ - /* */ - /* Each new face object created with this function also owns a */ - /* default @FT_Size object, accessible as `face->size'. */ - /* */ - /* One @FT_Library instance can have multiple face objects, this is, */ - /* @FT_Open_Face and its siblings can be called multiple times using */ - /* the same `library' argument. */ - /* */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Face. */ - /* */ - /* To loop over all faces, use code similar to the following snippet */ - /* (omitting the error handling). */ - /* */ - /* { */ - /* ... */ - /* FT_Face face; */ - /* FT_Long i, num_faces; */ - /* */ - /* */ - /* error = FT_Open_Face( library, args, -1, &face ); */ - /* if ( error ) { ... } */ - /* */ - /* num_faces = face->num_faces; */ - /* FT_Done_Face( face ); */ - /* */ - /* for ( i = 0; i < num_faces; i++ ) */ - /* { */ - /* ... */ - /* error = FT_Open_Face( library, args, i, &face ); */ - /* ... */ - /* FT_Done_Face( face ); */ - /* ... */ - /* } */ - /* } */ - /* */ - /* To loop over all valid values for `face_index', use something */ - /* similar to the following snippet, again without error handling. */ - /* The code accesses all faces immediately (thus only a single call */ - /* of `FT_Open_Face' within the do-loop), with and without named */ - /* instances. */ - /* */ - /* { */ - /* ... */ - /* FT_Face face; */ - /* */ - /* FT_Long num_faces = 0; */ - /* FT_Long num_instances = 0; */ - /* */ - /* FT_Long face_idx = 0; */ - /* FT_Long instance_idx = 0; */ - /* */ - /* */ - /* do */ - /* { */ - /* FT_Long id = ( instance_idx << 16 ) + face_idx; */ - /* */ - /* */ - /* error = FT_Open_Face( library, args, id, &face ); */ - /* if ( error ) { ... } */ - /* */ - /* num_faces = face->num_faces; */ - /* num_instances = face->style_flags >> 16; */ - /* */ - /* ... */ - /* */ - /* FT_Done_Face( face ); */ - /* */ - /* if ( instance_idx < num_instances ) */ - /* instance_idx++; */ - /* else */ - /* { */ - /* face_idx++; */ - /* instance_idx = 0; */ - /* } */ - /* */ - /* } while ( face_idx < num_faces ) */ - /* } */ - /* */ - FT_EXPORT( FT_Error ) - FT_Open_Face( FT_Library library, - const FT_Open_Args* args, - FT_Long face_index, - FT_Face *aface ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Attach_File */ - /* */ - /* <Description> */ - /* This function calls @FT_Attach_Stream to attach a file. */ - /* */ - /* <InOut> */ - /* face :: The target face object. */ - /* */ - /* <Input> */ - /* filepathname :: The pathname. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Attach_File( FT_Face face, - const char* filepathname ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Attach_Stream */ - /* */ - /* <Description> */ - /* `Attach' data to a face object. Normally, this is used to read */ - /* additional information for the face object. For example, you can */ - /* attach an AFM file that comes with a Type~1 font to get the */ - /* kerning values and other metrics. */ - /* */ - /* <InOut> */ - /* face :: The target face object. */ - /* */ - /* <Input> */ - /* parameters :: A pointer to @FT_Open_Args that must be filled by */ - /* the caller. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The meaning of the `attach' (i.e., what really happens when the */ - /* new file is read) is not fixed by FreeType itself. It really */ - /* depends on the font format (and thus the font driver). */ - /* */ - /* Client applications are expected to know what they are doing */ - /* when invoking this function. Most drivers simply do not implement */ - /* file attachments. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Attach_Stream( FT_Face face, - FT_Open_Args* parameters ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Reference_Face */ - /* */ - /* <Description> */ - /* A counter gets initialized to~1 at the time an @FT_Face structure */ - /* is created. This function increments the counter. @FT_Done_Face */ - /* then only destroys a face if the counter is~1, otherwise it simply */ - /* decrements the counter. */ - /* */ - /* This function helps in managing life-cycles of structures that */ - /* reference @FT_Face objects. */ - /* */ - /* <Input> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.4.2 */ - /* */ - FT_EXPORT( FT_Error ) - FT_Reference_Face( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Face */ - /* */ - /* <Description> */ - /* Discard a given face object, as well as all of its child slots and */ - /* sizes. */ - /* */ - /* <Input> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Face. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Done_Face( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Select_Size */ - /* */ - /* <Description> */ - /* Select a bitmap strike. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* strike_index :: The index of the bitmap strike in the */ - /* `available_sizes' field of @FT_FaceRec structure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Select_Size( FT_Face face, - FT_Int strike_index ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Size_Request_Type */ - /* */ - /* <Description> */ - /* An enumeration type that lists the supported size request types. */ - /* */ - /* <Values> */ - /* FT_SIZE_REQUEST_TYPE_NOMINAL :: */ - /* The nominal size. The `units_per_EM' field of @FT_FaceRec is */ - /* used to determine both scaling values. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_REAL_DIM :: */ - /* The real dimension. The sum of the the `ascender' and (minus */ - /* of) the `descender' fields of @FT_FaceRec are used to determine */ - /* both scaling values. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_BBOX :: */ - /* The font bounding box. The width and height of the `bbox' field */ - /* of @FT_FaceRec are used to determine the horizontal and vertical */ - /* scaling value, respectively. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_CELL :: */ - /* The `max_advance_width' field of @FT_FaceRec is used to */ - /* determine the horizontal scaling value; the vertical scaling */ - /* value is determined the same way as */ - /* @FT_SIZE_REQUEST_TYPE_REAL_DIM does. Finally, both scaling */ - /* values are set to the smaller one. This type is useful if you */ - /* want to specify the font size for, say, a window of a given */ - /* dimension and 80x24 cells. */ - /* */ - /* FT_SIZE_REQUEST_TYPE_SCALES :: */ - /* Specify the scaling values directly. */ - /* */ - /* <Note> */ - /* The above descriptions only apply to scalable formats. For bitmap */ - /* formats, the behaviour is up to the driver. */ - /* */ - /* See the note section of @FT_Size_Metrics if you wonder how size */ - /* requesting relates to scaling values. */ - /* */ - typedef enum FT_Size_Request_Type_ - { - FT_SIZE_REQUEST_TYPE_NOMINAL, - FT_SIZE_REQUEST_TYPE_REAL_DIM, - FT_SIZE_REQUEST_TYPE_BBOX, - FT_SIZE_REQUEST_TYPE_CELL, - FT_SIZE_REQUEST_TYPE_SCALES, - - FT_SIZE_REQUEST_TYPE_MAX - - } FT_Size_Request_Type; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_RequestRec */ - /* */ - /* <Description> */ - /* A structure used to model a size request. */ - /* */ - /* <Fields> */ - /* type :: See @FT_Size_Request_Type. */ - /* */ - /* width :: The desired width. */ - /* */ - /* height :: The desired height. */ - /* */ - /* horiResolution :: The horizontal resolution. If set to zero, */ - /* `width' is treated as a 26.6 fractional pixel */ - /* value. */ - /* */ - /* vertResolution :: The vertical resolution. If set to zero, */ - /* `height' is treated as a 26.6 fractional pixel */ - /* value. */ - /* */ - /* <Note> */ - /* If `width' is zero, then the horizontal scaling value is set equal */ - /* to the vertical scaling value, and vice versa. */ - /* */ - typedef struct FT_Size_RequestRec_ - { - FT_Size_Request_Type type; - FT_Long width; - FT_Long height; - FT_UInt horiResolution; - FT_UInt vertResolution; - - } FT_Size_RequestRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Size_Request */ - /* */ - /* <Description> */ - /* A handle to a size request structure. */ - /* */ - typedef struct FT_Size_RequestRec_ *FT_Size_Request; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Request_Size */ - /* */ - /* <Description> */ - /* Resize the scale of the active @FT_Size object in a face. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* req :: A pointer to a @FT_Size_RequestRec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Although drivers may select the bitmap strike matching the */ - /* request, you should not rely on this if you intend to select a */ - /* particular bitmap strike. Use @FT_Select_Size instead in that */ - /* case. */ - /* */ - /* The relation between the requested size and the resulting glyph */ - /* size is dependent entirely on how the size is defined in the */ - /* source face. The font designer chooses the final size of each */ - /* glyph relative to this size. For more information refer to */ - /* `http://www.freetype.org/freetype2/docs/glyphs/glyphs-2.html' */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Request_Size( FT_Face face, - FT_Size_Request req ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Char_Size */ - /* */ - /* <Description> */ - /* This function calls @FT_Request_Size to request the nominal size */ - /* (in points). */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object. */ - /* */ - /* <Input> */ - /* char_width :: The nominal width, in 26.6 fractional points. */ - /* */ - /* char_height :: The nominal height, in 26.6 fractional points. */ - /* */ - /* horz_resolution :: The horizontal resolution in dpi. */ - /* */ - /* vert_resolution :: The vertical resolution in dpi. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If either the character width or height is zero, it is set equal */ - /* to the other value. */ - /* */ - /* If either the horizontal or vertical resolution is zero, it is set */ - /* equal to the other value. */ - /* */ - /* A character width or height smaller than 1pt is set to 1pt; if */ - /* both resolution values are zero, they are set to 72dpi. */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Char_Size( FT_Face face, - FT_F26Dot6 char_width, - FT_F26Dot6 char_height, - FT_UInt horz_resolution, - FT_UInt vert_resolution ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Pixel_Sizes */ - /* */ - /* <Description> */ - /* This function calls @FT_Request_Size to request the nominal size */ - /* (in pixels). */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object. */ - /* */ - /* <Input> */ - /* pixel_width :: The nominal width, in pixels. */ - /* */ - /* pixel_height :: The nominal height, in pixels. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You should not rely on the resulting glyphs matching, or being */ - /* constrained, to this pixel size. Refer to @FT_Request_Size to */ - /* understand how requested sizes relate to actual sizes. */ - /* */ - /* Don't use this function if you are using the FreeType cache API. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Pixel_Sizes( FT_Face face, - FT_UInt pixel_width, - FT_UInt pixel_height ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Load_Glyph */ - /* */ - /* <Description> */ - /* A function used to load a single glyph into the glyph slot of a */ - /* face object. */ - /* */ - /* <InOut> */ - /* face :: A handle to the target face object where the glyph */ - /* is loaded. */ - /* */ - /* <Input> */ - /* glyph_index :: The index of the glyph in the font file. For */ - /* CID-keyed fonts (either in PS or in CFF format) */ - /* this argument specifies the CID value. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* @FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The loaded glyph may be transformed. See @FT_Set_Transform for */ - /* the details. */ - /* */ - /* For subsetted CID-keyed fonts, `FT_Err_Invalid_Argument' is */ - /* returned for invalid CID values (this is, for CID values that */ - /* don't have a corresponding glyph in the font). See the discussion */ - /* of the @FT_FACE_FLAG_CID_KEYED flag for more details. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Load_Glyph( FT_Face face, - FT_UInt glyph_index, - FT_Int32 load_flags ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Load_Char */ - /* */ - /* <Description> */ - /* A function used to load a single glyph into the glyph slot of a */ - /* face object, according to its character code. */ - /* */ - /* <InOut> */ - /* face :: A handle to a target face object where the glyph */ - /* is loaded. */ - /* */ - /* <Input> */ - /* char_code :: The glyph's character code, according to the */ - /* current charmap used in the face. */ - /* */ - /* load_flags :: A flag indicating what to load for this glyph. The */ - /* @FT_LOAD_XXX constants can be used to control the */ - /* glyph loading process (e.g., whether the outline */ - /* should be scaled, whether to load bitmaps or not, */ - /* whether to hint the outline, etc). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function simply calls @FT_Get_Char_Index and @FT_Load_Glyph. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Load_Char( FT_Face face, - FT_ULong char_code, - FT_Int32 load_flags ); - - - /************************************************************************* - * - * @enum: - * FT_LOAD_XXX - * - * @description: - * A list of bit field constants used with @FT_Load_Glyph to indicate - * what kind of operations to perform during glyph loading. - * - * @values: - * FT_LOAD_DEFAULT :: - * Corresponding to~0, this value is used as the default glyph load - * operation. In this case, the following happens: - * - * 1. FreeType looks for a bitmap for the glyph corresponding to the - * face's current size. If one is found, the function returns. - * The bitmap data can be accessed from the glyph slot (see note - * below). - * - * 2. If no embedded bitmap is searched or found, FreeType looks for a - * scalable outline. If one is found, it is loaded from the font - * file, scaled to device pixels, then `hinted' to the pixel grid - * in order to optimize it. The outline data can be accessed from - * the glyph slot (see note below). - * - * Note that by default, the glyph loader doesn't render outlines into - * bitmaps. The following flags are used to modify this default - * behaviour to more specific and useful cases. - * - * FT_LOAD_NO_SCALE :: - * Don't scale the loaded outline glyph but keep it in font units. - * - * This flag implies @FT_LOAD_NO_HINTING and @FT_LOAD_NO_BITMAP, and - * unsets @FT_LOAD_RENDER. - * - * If the font is `tricky' (see @FT_FACE_FLAG_TRICKY for more), using - * FT_LOAD_NO_SCALE usually yields meaningless outlines because the - * subglyphs must be scaled and positioned with hinting instructions. - * This can be solved by loading the font without FT_LOAD_NO_SCALE and - * setting the character size to `font->units_per_EM'. - * - * FT_LOAD_NO_HINTING :: - * Disable hinting. This generally generates `blurrier' bitmap glyphs - * when the glyph are rendered in any of the anti-aliased modes. See - * also the note below. - * - * This flag is implied by @FT_LOAD_NO_SCALE. - * - * FT_LOAD_RENDER :: - * Call @FT_Render_Glyph after the glyph is loaded. By default, the - * glyph is rendered in @FT_RENDER_MODE_NORMAL mode. This can be - * overridden by @FT_LOAD_TARGET_XXX or @FT_LOAD_MONOCHROME. - * - * This flag is unset by @FT_LOAD_NO_SCALE. - * - * FT_LOAD_NO_BITMAP :: - * Ignore bitmap strikes when loading. Bitmap-only fonts ignore this - * flag. - * - * @FT_LOAD_NO_SCALE always sets this flag. - * - * FT_LOAD_VERTICAL_LAYOUT :: - * Load the glyph for vertical text layout. In particular, the - * `advance' value in the @FT_GlyphSlotRec structure is set to the - * `vertAdvance' value of the `metrics' field. - * - * In case @FT_HAS_VERTICAL doesn't return true, you shouldn't use - * this flag currently. Reason is that in this case vertical metrics - * get synthesized, and those values are not always consistent across - * various font formats. - * - * FT_LOAD_FORCE_AUTOHINT :: - * Indicates that the auto-hinter is preferred over the font's native - * hinter. See also the note below. - * - * FT_LOAD_PEDANTIC :: - * Indicates that the font driver should perform pedantic verifications - * during glyph loading. This is mostly used to detect broken glyphs - * in fonts. By default, FreeType tries to handle broken fonts also. - * - * In particular, errors from the TrueType bytecode engine are not - * passed to the application if this flag is not set; this might - * result in partially hinted or distorted glyphs in case a glyph's - * bytecode is buggy. - * - * FT_LOAD_NO_RECURSE :: - * Indicate that the font driver should not load composite glyphs - * recursively. Instead, it should set the `num_subglyph' and - * `subglyphs' values of the glyph slot accordingly, and set - * `glyph->format' to @FT_GLYPH_FORMAT_COMPOSITE. The description of - * subglyphs can then be accessed with @FT_Get_SubGlyph_Info. - * - * This flag implies @FT_LOAD_NO_SCALE and @FT_LOAD_IGNORE_TRANSFORM. - * - * FT_LOAD_IGNORE_TRANSFORM :: - * Indicates that the transform matrix set by @FT_Set_Transform should - * be ignored. - * - * FT_LOAD_MONOCHROME :: - * This flag is used with @FT_LOAD_RENDER to indicate that you want to - * render an outline glyph to a 1-bit monochrome bitmap glyph, with - * 8~pixels packed into each byte of the bitmap data. - * - * Note that this has no effect on the hinting algorithm used. You - * should rather use @FT_LOAD_TARGET_MONO so that the - * monochrome-optimized hinting algorithm is used. - * - * FT_LOAD_LINEAR_DESIGN :: - * Indicates that the `linearHoriAdvance' and `linearVertAdvance' - * fields of @FT_GlyphSlotRec should be kept in font units. See - * @FT_GlyphSlotRec for details. - * - * FT_LOAD_NO_AUTOHINT :: - * Disable auto-hinter. See also the note below. - * - * FT_LOAD_COLOR :: - * This flag is used to request loading of color embedded-bitmap - * images. The resulting color bitmaps, if available, will have the - * @FT_PIXEL_MODE_BGRA format. When the flag is not used and color - * bitmaps are found, they will be converted to 256-level gray - * bitmaps transparently. Those bitmaps will be in the - * @FT_PIXEL_MODE_GRAY format. - * - * FT_LOAD_COMPUTE_METRICS :: - * This flag sets computing glyph metrics without the use of bundled - * metrics tables (for example, the `hdmx' table in TrueType fonts). - * Well-behaving fonts have optimized bundled metrics and these should - * be used. This flag is mainly used by font validating or font - * editing applications, which need to ignore, verify, or edit those - * tables. - * - * Currently, this flag is only implemented for TrueType fonts. - * - * FT_LOAD_CROP_BITMAP :: - * Ignored. Deprecated. - * - * FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH :: - * Ignored. Deprecated. - * - * @note: - * By default, hinting is enabled and the font's native hinter (see - * @FT_FACE_FLAG_HINTER) is preferred over the auto-hinter. You can - * disable hinting by setting @FT_LOAD_NO_HINTING or change the - * precedence by setting @FT_LOAD_FORCE_AUTOHINT. You can also set - * @FT_LOAD_NO_AUTOHINT in case you don't want the auto-hinter to be - * used at all. - * - * See the description of @FT_FACE_FLAG_TRICKY for a special exception - * (affecting only a handful of Asian fonts). - * - * Besides deciding which hinter to use, you can also decide which - * hinting algorithm to use. See @FT_LOAD_TARGET_XXX for details. - * - * Note that the auto-hinter needs a valid Unicode cmap (either a native - * one or synthesized by FreeType) for producing correct results. If a - * font provides an incorrect mapping (for example, assigning the - * character code U+005A, LATIN CAPITAL LETTER Z, to a glyph depicting a - * mathematical integral sign), the auto-hinter might produce useless - * results. - * - */ -#define FT_LOAD_DEFAULT 0x0 -#define FT_LOAD_NO_SCALE ( 1L << 0 ) -#define FT_LOAD_NO_HINTING ( 1L << 1 ) -#define FT_LOAD_RENDER ( 1L << 2 ) -#define FT_LOAD_NO_BITMAP ( 1L << 3 ) -#define FT_LOAD_VERTICAL_LAYOUT ( 1L << 4 ) -#define FT_LOAD_FORCE_AUTOHINT ( 1L << 5 ) -#define FT_LOAD_CROP_BITMAP ( 1L << 6 ) -#define FT_LOAD_PEDANTIC ( 1L << 7 ) -#define FT_LOAD_IGNORE_GLOBAL_ADVANCE_WIDTH ( 1L << 9 ) -#define FT_LOAD_NO_RECURSE ( 1L << 10 ) -#define FT_LOAD_IGNORE_TRANSFORM ( 1L << 11 ) -#define FT_LOAD_MONOCHROME ( 1L << 12 ) -#define FT_LOAD_LINEAR_DESIGN ( 1L << 13 ) -#define FT_LOAD_NO_AUTOHINT ( 1L << 15 ) - /* Bits 16..19 are used by `FT_LOAD_TARGET_' */ -#define FT_LOAD_COLOR ( 1L << 20 ) -#define FT_LOAD_COMPUTE_METRICS ( 1L << 21 ) - - /* */ - - /* used internally only by certain font drivers! */ -#define FT_LOAD_ADVANCE_ONLY ( 1L << 8 ) -#define FT_LOAD_SBITS_ONLY ( 1L << 14 ) - - - /************************************************************************** - * - * @enum: - * FT_LOAD_TARGET_XXX - * - * @description: - * A list of values that are used to select a specific hinting algorithm - * to use by the hinter. You should OR one of these values to your - * `load_flags' when calling @FT_Load_Glyph. - * - * Note that font's native hinters may ignore the hinting algorithm you - * have specified (e.g., the TrueType bytecode interpreter). You can set - * @FT_LOAD_FORCE_AUTOHINT to ensure that the auto-hinter is used. - * - * @values: - * FT_LOAD_TARGET_NORMAL :: - * This corresponds to the default hinting algorithm, optimized for - * standard gray-level rendering. For monochrome output, use - * @FT_LOAD_TARGET_MONO instead. - * - * FT_LOAD_TARGET_LIGHT :: - * A lighter hinting algorithm for gray-level modes. Many generated - * glyphs are fuzzier but better resemble their original shape. This - * is achieved by snapping glyphs to the pixel grid only vertically - * (Y-axis), as is done by Microsoft's ClearType and Adobe's - * proprietary font renderer. This preserves inter-glyph spacing in - * horizontal text. The snapping is done either by the native font - * driver if the driver itself and the font support it or by the - * auto-hinter. - * - * FT_LOAD_TARGET_MONO :: - * Strong hinting algorithm that should only be used for monochrome - * output. The result is probably unpleasant if the glyph is rendered - * in non-monochrome modes. - * - * FT_LOAD_TARGET_LCD :: - * A variant of @FT_LOAD_TARGET_NORMAL optimized for horizontally - * decimated LCD displays. - * - * FT_LOAD_TARGET_LCD_V :: - * A variant of @FT_LOAD_TARGET_NORMAL optimized for vertically - * decimated LCD displays. - * - * @note: - * You should use only _one_ of the FT_LOAD_TARGET_XXX values in your - * `load_flags'. They can't be ORed. - * - * If @FT_LOAD_RENDER is also set, the glyph is rendered in the - * corresponding mode (i.e., the mode that matches the used algorithm - * best). An exeption is FT_LOAD_TARGET_MONO since it implies - * @FT_LOAD_MONOCHROME. - * - * You can use a hinting algorithm that doesn't correspond to the same - * rendering mode. As an example, it is possible to use the `light' - * hinting algorithm and have the results rendered in horizontal LCD - * pixel mode, with code like - * - * { - * FT_Load_Glyph( face, glyph_index, - * load_flags | FT_LOAD_TARGET_LIGHT ); - * - * FT_Render_Glyph( face->glyph, FT_RENDER_MODE_LCD ); - * } - * - */ -#define FT_LOAD_TARGET_( x ) ( (FT_Int32)( (x) & 15 ) << 16 ) - -#define FT_LOAD_TARGET_NORMAL FT_LOAD_TARGET_( FT_RENDER_MODE_NORMAL ) -#define FT_LOAD_TARGET_LIGHT FT_LOAD_TARGET_( FT_RENDER_MODE_LIGHT ) -#define FT_LOAD_TARGET_MONO FT_LOAD_TARGET_( FT_RENDER_MODE_MONO ) -#define FT_LOAD_TARGET_LCD FT_LOAD_TARGET_( FT_RENDER_MODE_LCD ) -#define FT_LOAD_TARGET_LCD_V FT_LOAD_TARGET_( FT_RENDER_MODE_LCD_V ) - - - /************************************************************************** - * - * @macro: - * FT_LOAD_TARGET_MODE - * - * @description: - * Return the @FT_Render_Mode corresponding to a given - * @FT_LOAD_TARGET_XXX value. - * - */ -#define FT_LOAD_TARGET_MODE( x ) ( (FT_Render_Mode)( ( (x) >> 16 ) & 15 ) ) - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Transform */ - /* */ - /* <Description> */ - /* A function used to set the transformation that is applied to glyph */ - /* images when they are loaded into a glyph slot through */ - /* @FT_Load_Glyph. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the transformation's 2x2 matrix. Use~0 for */ - /* the identity matrix. */ - /* delta :: A pointer to the translation vector. Use~0 for the null */ - /* vector. */ - /* */ - /* <Note> */ - /* The transformation is only applied to scalable image formats after */ - /* the glyph has been loaded. It means that hinting is unaltered by */ - /* the transformation and is performed on the character size given in */ - /* the last call to @FT_Set_Char_Size or @FT_Set_Pixel_Sizes. */ - /* */ - /* Note that this also transforms the `face.glyph.advance' field, but */ - /* *not* the values in `face.glyph.metrics'. */ - /* */ - FT_EXPORT( void ) - FT_Set_Transform( FT_Face face, - FT_Matrix* matrix, - FT_Vector* delta ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Render_Mode */ - /* */ - /* <Description> */ - /* An enumeration type that lists the render modes supported by */ - /* FreeType~2. Each mode corresponds to a specific type of scanline */ - /* conversion performed on the outline. */ - /* */ - /* For bitmap fonts and embedded bitmaps the `bitmap->pixel_mode' */ - /* field in the @FT_GlyphSlotRec structure gives the format of the */ - /* returned bitmap. */ - /* */ - /* All modes except @FT_RENDER_MODE_MONO use 256 levels of opacity, */ - /* indicating pixel coverage. Use linear alpha blending and gamma */ - /* correction to correctly render non-monochrome glyph bitmaps onto a */ - /* surface; see @FT_Render_Glyph. */ - /* */ - /* <Values> */ - /* FT_RENDER_MODE_NORMAL :: */ - /* This is the default render mode; it corresponds to 8-bit */ - /* anti-aliased bitmaps. */ - /* */ - /* FT_RENDER_MODE_LIGHT :: */ - /* This is equivalent to @FT_RENDER_MODE_NORMAL. It is only */ - /* defined as a separate value because render modes are also used */ - /* indirectly to define hinting algorithm selectors. See */ - /* @FT_LOAD_TARGET_XXX for details. */ - /* */ - /* FT_RENDER_MODE_MONO :: */ - /* This mode corresponds to 1-bit bitmaps (with 2~levels of */ - /* opacity). */ - /* */ - /* FT_RENDER_MODE_LCD :: */ - /* This mode corresponds to horizontal RGB and BGR sub-pixel */ - /* displays like LCD screens. It produces 8-bit bitmaps that are */ - /* 3~times the width of the original glyph outline in pixels, and */ - /* which use the @FT_PIXEL_MODE_LCD mode. */ - /* */ - /* FT_RENDER_MODE_LCD_V :: */ - /* This mode corresponds to vertical RGB and BGR sub-pixel displays */ - /* (like PDA screens, rotated LCD displays, etc.). It produces */ - /* 8-bit bitmaps that are 3~times the height of the original */ - /* glyph outline in pixels and use the @FT_PIXEL_MODE_LCD_V mode. */ - /* */ - /* <Note> */ - /* The LCD-optimized glyph bitmaps produced by FT_Render_Glyph can be */ - /* filtered to reduce color-fringes by using @FT_Library_SetLcdFilter */ - /* (not active in the default builds). It is up to the caller to */ - /* either call @FT_Library_SetLcdFilter (if available) or do the */ - /* filtering itself. */ - /* */ - /* The selected render mode only affects vector glyphs of a font. */ - /* Embedded bitmaps often have a different pixel mode like */ - /* @FT_PIXEL_MODE_MONO. You can use @FT_Bitmap_Convert to transform */ - /* them into 8-bit pixmaps. */ - /* */ - typedef enum FT_Render_Mode_ - { - FT_RENDER_MODE_NORMAL = 0, - FT_RENDER_MODE_LIGHT, - FT_RENDER_MODE_MONO, - FT_RENDER_MODE_LCD, - FT_RENDER_MODE_LCD_V, - - FT_RENDER_MODE_MAX - - } FT_Render_Mode; - - - /* these constants are deprecated; use the corresponding */ - /* `FT_Render_Mode' values instead */ -#define ft_render_mode_normal FT_RENDER_MODE_NORMAL -#define ft_render_mode_mono FT_RENDER_MODE_MONO - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Render_Glyph */ - /* */ - /* <Description> */ - /* Convert a given glyph image to a bitmap. It does so by inspecting */ - /* the glyph image format, finding the relevant renderer, and */ - /* invoking it. */ - /* */ - /* <InOut> */ - /* slot :: A handle to the glyph slot containing the image to */ - /* convert. */ - /* */ - /* <Input> */ - /* render_mode :: This is the render mode used to render the glyph */ - /* image into a bitmap. See @FT_Render_Mode for a */ - /* list of possible values. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* To get meaningful results, font scaling values must be set with */ - /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */ - /* */ - /* When FreeType outputs a bitmap of a glyph, it really outputs an */ - /* alpha coverage map. If a pixel is completely covered by a */ - /* filled-in outline, the bitmap contains 0xFF at that pixel, meaning */ - /* that 0xFF/0xFF fraction of that pixel is covered, meaning the */ - /* pixel is 100% black (or 0% bright). If a pixel is only 50% */ - /* covered (value 0x80), the pixel is made 50% black (50% bright or a */ - /* middle shade of grey). 0% covered means 0% black (100% bright or */ - /* white). */ - /* */ - /* On high-DPI screens like on smartphones and tablets, the pixels */ - /* are so small that their chance of being completely covered and */ - /* therefore completely black are fairly good. On the low-DPI */ - /* screens, however, the situation is different. The pixels are too */ - /* large for most of the details of a glyph and shades of gray are */ - /* the norm rather than the exception. */ - /* */ - /* This is relevant because all our screens have a second problem: */ - /* they are not linear. 1~+~1 is not~2. Twice the value does not */ - /* result in twice the brightness. When a pixel is only 50% covered, */ - /* the coverage map says 50% black, and this translates to a pixel */ - /* value of 128 when you use 8~bits per channel (0-255). However, */ - /* this does not translate to 50% brightness for that pixel on our */ - /* sRGB and gamma~2.2 screens. Due to their non-linearity, they */ - /* dwell longer in the darks and only a pixel value of about 186 */ - /* results in 50% brightness – 128 ends up too dark on both bright */ - /* and dark backgrounds. The net result is that dark text looks */ - /* burnt-out, pixely and blotchy on bright background, bright text */ - /* too frail on dark backgrounds, and colored text on colored */ - /* background (for example, red on green) seems to have dark halos or */ - /* `dirt' around it. The situation is especially ugly for diagonal */ - /* stems like in `w' glyph shapes where the quality of FreeType's */ - /* anti-aliasing depends on the correct display of grays. On */ - /* high-DPI screens where smaller, fully black pixels reign supreme, */ - /* this doesn't matter, but on our low-DPI screens with all the gray */ - /* shades, it does. 0% and 100% brightness are the same things in */ - /* linear and non-linear space, just all the shades in-between */ - /* aren't. */ - /* */ - /* The blending function for placing text over a background is */ - /* */ - /* { */ - /* dst = alpha * src + (1 - alpha) * dst , */ - /* } */ - /* */ - /* which is known as the OVER operator. */ - /* */ - /* To correctly composite an antialiased pixel of a glyph onto a */ - /* surface, */ - /* */ - /* 1. take the foreground and background colors (e.g., in sRGB space) */ - /* and apply gamma to get them in a linear space, */ - /* */ - /* 2. use OVER to blend the two linear colors using the glyph pixel */ - /* as the alpha value (remember, the glyph bitmap is an alpha */ - /* coverage bitmap), and */ - /* */ - /* 3. apply inverse gamma to the blended pixel and write it back to */ - /* the image. */ - /* */ - /* Internal testing at Adobe found that a target inverse gamma of~1.8 */ - /* for step~3 gives good results across a wide range of displays with */ - /* an sRGB gamma curve or a similar one. */ - /* */ - /* This process can cost performance. There is an approximation that */ - /* does not need to know about the background color; see */ - /* https://bel.fi/alankila/lcd/ and */ - /* https://bel.fi/alankila/lcd/alpcor.html for details. */ - /* */ - /* *ATTENTION*: Linear blending is even more important when dealing */ - /* with subpixel-rendered glyphs to prevent color-fringing! A */ - /* subpixel-rendered glyph must first be filtered with a filter that */ - /* gives equal weight to the three color primaries and does not */ - /* exceed a sum of 0x100, see section @lcd_filtering. Then the */ - /* only difference to gray linear blending is that subpixel-rendered */ - /* linear blending is done 3~times per pixel: red foreground subpixel */ - /* to red background subpixel and so on for green and blue. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Render_Glyph( FT_GlyphSlot slot, - FT_Render_Mode render_mode ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Kerning_Mode */ - /* */ - /* <Description> */ - /* An enumeration used to specify which kerning values to return in */ - /* @FT_Get_Kerning. */ - /* */ - /* <Values> */ - /* FT_KERNING_DEFAULT :: Return grid-fitted kerning distances in */ - /* pixels (value is~0). Whether they are */ - /* scaled depends on @FT_LOAD_NO_SCALE. */ - /* */ - /* FT_KERNING_UNFITTED :: Return un-grid-fitted kerning distances in */ - /* 26.6 fractional pixels. Whether they are */ - /* scaled depends on @FT_LOAD_NO_SCALE. */ - /* */ - /* FT_KERNING_UNSCALED :: Return the kerning vector in original font */ - /* units. */ - /* */ - /* <Note> */ - /* FT_KERNING_DEFAULT returns full pixel values; it also makes */ - /* FreeType heuristically scale down kerning distances at small ppem */ - /* values so that they don't become too big. */ - /* */ - typedef enum FT_Kerning_Mode_ - { - FT_KERNING_DEFAULT = 0, - FT_KERNING_UNFITTED, - FT_KERNING_UNSCALED - - } FT_Kerning_Mode; - - - /* these constants are deprecated; use the corresponding */ - /* `FT_Kerning_Mode' values instead */ -#define ft_kerning_default FT_KERNING_DEFAULT -#define ft_kerning_unfitted FT_KERNING_UNFITTED -#define ft_kerning_unscaled FT_KERNING_UNSCALED - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Kerning */ - /* */ - /* <Description> */ - /* Return the kerning vector between two glyphs of a same face. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* left_glyph :: The index of the left glyph in the kern pair. */ - /* */ - /* right_glyph :: The index of the right glyph in the kern pair. */ - /* */ - /* kern_mode :: See @FT_Kerning_Mode for more information. */ - /* Determines the scale and dimension of the returned */ - /* kerning vector. */ - /* */ - /* <Output> */ - /* akerning :: The kerning vector. This is either in font units, */ - /* fractional pixels (26.6 format), or pixels for */ - /* scalable formats, and in pixels for fixed-sizes */ - /* formats. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Only horizontal layouts (left-to-right & right-to-left) are */ - /* supported by this method. Other layouts, or more sophisticated */ - /* kernings, are out of the scope of this API function -- they can be */ - /* implemented through format-specific interfaces. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Kerning( FT_Face face, - FT_UInt left_glyph, - FT_UInt right_glyph, - FT_UInt kern_mode, - FT_Vector *akerning ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Track_Kerning */ - /* */ - /* <Description> */ - /* Return the track kerning for a given face object at a given size. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* point_size :: The point size in 16.16 fractional points. */ - /* */ - /* degree :: The degree of tightness. Increasingly negative */ - /* values represent tighter track kerning, while */ - /* increasingly positive values represent looser track */ - /* kerning. Value zero means no track kerning. */ - /* */ - /* <Output> */ - /* akerning :: The kerning in 16.16 fractional points, to be */ - /* uniformly applied between all glyphs. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* Currently, only the Type~1 font driver supports track kerning, */ - /* using data from AFM files (if attached with @FT_Attach_File or */ - /* @FT_Attach_Stream). */ - /* */ - /* Only very few AFM files come with track kerning data; please refer */ - /* to the Adobe's AFM specification for more details. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Track_Kerning( FT_Face face, - FT_Fixed point_size, - FT_Int degree, - FT_Fixed* akerning ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Glyph_Name */ - /* */ - /* <Description> */ - /* Retrieve the ASCII name of a given glyph in a face. This only */ - /* works for those faces where @FT_HAS_GLYPH_NAMES(face) returns~1. */ - /* */ - /* <Input> */ - /* face :: A handle to a source face object. */ - /* */ - /* glyph_index :: The glyph index. */ - /* */ - /* buffer_max :: The maximum number of bytes available in the */ - /* buffer. */ - /* */ - /* <Output> */ - /* buffer :: A pointer to a target buffer where the name is */ - /* copied to. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* An error is returned if the face doesn't provide glyph names or if */ - /* the glyph index is invalid. In all cases of failure, the first */ - /* byte of `buffer' is set to~0 to indicate an empty name. */ - /* */ - /* The glyph name is truncated to fit within the buffer if it is too */ - /* long. The returned string is always zero-terminated. */ - /* */ - /* Be aware that FreeType reorders glyph indices internally so that */ - /* glyph index~0 always corresponds to the `missing glyph' (called */ - /* `.notdef'). */ - /* */ - /* This function always returns an error if the config macro */ - /* `FT_CONFIG_OPTION_NO_GLYPH_NAMES' is not defined in `ftoptions.h'. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Glyph_Name( FT_Face face, - FT_UInt glyph_index, - FT_Pointer buffer, - FT_UInt buffer_max ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Postscript_Name */ - /* */ - /* <Description> */ - /* Retrieve the ASCII PostScript name of a given face, if available. */ - /* This only works with PostScript and TrueType fonts. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Return> */ - /* A pointer to the face's PostScript name. NULL if unavailable. */ - /* */ - /* <Note> */ - /* The returned pointer is owned by the face and is destroyed with */ - /* it. */ - /* */ - FT_EXPORT( const char* ) - FT_Get_Postscript_Name( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Select_Charmap */ - /* */ - /* <Description> */ - /* Select a given charmap by its encoding tag (as listed in */ - /* `freetype.h'). */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* encoding :: A handle to the selected encoding. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function returns an error if no charmap in the face */ - /* corresponds to the encoding queried here. */ - /* */ - /* Because many fonts contain more than a single cmap for Unicode */ - /* encoding, this function has some special code to select the one */ - /* that covers Unicode best (`best' in the sense that a UCS-4 cmap is */ - /* preferred to a UCS-2 cmap). It is thus preferable to */ - /* @FT_Set_Charmap in this case. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Select_Charmap( FT_Face face, - FT_Encoding encoding ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Charmap */ - /* */ - /* <Description> */ - /* Select a given charmap for character code to glyph index mapping. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Input> */ - /* charmap :: A handle to the selected charmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function returns an error if the charmap is not part of */ - /* the face (i.e., if it is not listed in the `face->charmaps' */ - /* table). */ - /* */ - /* It also fails if a type~14 charmap is selected. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Charmap( FT_Face face, - FT_CharMap charmap ); - - - /************************************************************************* - * - * @function: - * FT_Get_Charmap_Index - * - * @description: - * Retrieve index of a given charmap. - * - * @input: - * charmap :: - * A handle to a charmap. - * - * @return: - * The index into the array of character maps within the face to which - * `charmap' belongs. If an error occurs, -1 is returned. - * - */ - FT_EXPORT( FT_Int ) - FT_Get_Charmap_Index( FT_CharMap charmap ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Char_Index */ - /* */ - /* <Description> */ - /* Return the glyph index of a given character code. This function */ - /* uses a charmap object to do the mapping. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* charcode :: The character code. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means `undefined character code'. */ - /* */ - /* <Note> */ - /* If you use FreeType to manipulate the contents of font files */ - /* directly, be aware that the glyph index returned by this function */ - /* doesn't always correspond to the internal indices used within the */ - /* file. This is done to ensure that value~0 always corresponds to */ - /* the `missing glyph'. If the first glyph is not named `.notdef', */ - /* then for Type~1 and Type~42 fonts, `.notdef' will be moved into */ - /* the glyph ID~0 position, and whatever was there will be moved to */ - /* the position `.notdef' had. For Type~1 fonts, if there is no */ - /* `.notdef' glyph at all, then one will be created at index~0 and */ - /* whatever was there will be moved to the last index -- Type~42 */ - /* fonts are considered invalid under this condition. */ - /* */ - FT_EXPORT( FT_UInt ) - FT_Get_Char_Index( FT_Face face, - FT_ULong charcode ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_First_Char */ - /* */ - /* <Description> */ - /* This function is used to return the first character code in the */ - /* current charmap of a given face. It also returns the */ - /* corresponding glyph index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Output> */ - /* agindex :: Glyph index of first character code. 0~if charmap is */ - /* empty. */ - /* */ - /* <Return> */ - /* The charmap's first character code. */ - /* */ - /* <Note> */ - /* You should use this function with @FT_Get_Next_Char to be able to */ - /* parse all character codes available in a given charmap. The code */ - /* should look like this: */ - /* */ - /* { */ - /* FT_ULong charcode; */ - /* FT_UInt gindex; */ - /* */ - /* */ - /* charcode = FT_Get_First_Char( face, &gindex ); */ - /* while ( gindex != 0 ) */ - /* { */ - /* ... do something with (charcode,gindex) pair ... */ - /* */ - /* charcode = FT_Get_Next_Char( face, charcode, &gindex ); */ - /* } */ - /* } */ - /* */ - /* Be aware that character codes can have values up to 0xFFFFFFFF; */ - /* this might happen for non-Unicode or malformed cmaps. However, */ - /* even with regular Unicode encoding, so-called `last resort fonts' */ - /* (using SFNT cmap format 13, see function @FT_Get_CMap_Format) */ - /* normally have entries for all Unicode characters up to 0x1FFFFF, */ - /* which can cause *a lot* of iterations. */ - /* */ - /* Note that `*agindex' is set to~0 if the charmap is empty. The */ - /* result itself can be~0 in two cases: if the charmap is empty or */ - /* if the value~0 is the first valid character code. */ - /* */ - FT_EXPORT( FT_ULong ) - FT_Get_First_Char( FT_Face face, - FT_UInt *agindex ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Next_Char */ - /* */ - /* <Description> */ - /* This function is used to return the next character code in the */ - /* current charmap of a given face following the value `char_code', */ - /* as well as the corresponding glyph index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* char_code :: The starting character code. */ - /* */ - /* <Output> */ - /* agindex :: Glyph index of next character code. 0~if charmap */ - /* is empty. */ - /* */ - /* <Return> */ - /* The charmap's next character code. */ - /* */ - /* <Note> */ - /* You should use this function with @FT_Get_First_Char to walk */ - /* over all character codes available in a given charmap. See the */ - /* note for this function for a simple code example. */ - /* */ - /* Note that `*agindex' is set to~0 when there are no more codes in */ - /* the charmap. */ - /* */ - FT_EXPORT( FT_ULong ) - FT_Get_Next_Char( FT_Face face, - FT_ULong char_code, - FT_UInt *agindex ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Name_Index */ - /* */ - /* <Description> */ - /* Return the glyph index of a given glyph name. This function uses */ - /* driver specific objects to do the translation. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* glyph_name :: The glyph name. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means `undefined character code'. */ - /* */ - FT_EXPORT( FT_UInt ) - FT_Get_Name_Index( FT_Face face, - FT_String* glyph_name ); - - - /************************************************************************* - * - * @macro: - * FT_SUBGLYPH_FLAG_XXX - * - * @description: - * A list of constants used to describe subglyphs. Please refer to the - * TrueType specification for the meaning of the various flags. - * - * @values: - * FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS :: - * FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES :: - * FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID :: - * FT_SUBGLYPH_FLAG_SCALE :: - * FT_SUBGLYPH_FLAG_XY_SCALE :: - * FT_SUBGLYPH_FLAG_2X2 :: - * FT_SUBGLYPH_FLAG_USE_MY_METRICS :: - * - */ -#define FT_SUBGLYPH_FLAG_ARGS_ARE_WORDS 1 -#define FT_SUBGLYPH_FLAG_ARGS_ARE_XY_VALUES 2 -#define FT_SUBGLYPH_FLAG_ROUND_XY_TO_GRID 4 -#define FT_SUBGLYPH_FLAG_SCALE 8 -#define FT_SUBGLYPH_FLAG_XY_SCALE 0x40 -#define FT_SUBGLYPH_FLAG_2X2 0x80 -#define FT_SUBGLYPH_FLAG_USE_MY_METRICS 0x200 - - - /************************************************************************* - * - * @func: - * FT_Get_SubGlyph_Info - * - * @description: - * Retrieve a description of a given subglyph. Only use it if - * `glyph->format' is @FT_GLYPH_FORMAT_COMPOSITE; an error is - * returned otherwise. - * - * @input: - * glyph :: - * The source glyph slot. - * - * sub_index :: - * The index of the subglyph. Must be less than - * `glyph->num_subglyphs'. - * - * @output: - * p_index :: - * The glyph index of the subglyph. - * - * p_flags :: - * The subglyph flags, see @FT_SUBGLYPH_FLAG_XXX. - * - * p_arg1 :: - * The subglyph's first argument (if any). - * - * p_arg2 :: - * The subglyph's second argument (if any). - * - * p_transform :: - * The subglyph transformation (if any). - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The values of `*p_arg1', `*p_arg2', and `*p_transform' must be - * interpreted depending on the flags returned in `*p_flags'. See the - * TrueType specification for details. - * - */ - FT_EXPORT( FT_Error ) - FT_Get_SubGlyph_Info( FT_GlyphSlot glyph, - FT_UInt sub_index, - FT_Int *p_index, - FT_UInt *p_flags, - FT_Int *p_arg1, - FT_Int *p_arg2, - FT_Matrix *p_transform ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_FSTYPE_XXX */ - /* */ - /* <Description> */ - /* A list of bit flags used in the `fsType' field of the OS/2 table */ - /* in a TrueType or OpenType font and the `FSType' entry in a */ - /* PostScript font. These bit flags are returned by */ - /* @FT_Get_FSType_Flags; they inform client applications of embedding */ - /* and subsetting restrictions associated with a font. */ - /* */ - /* See */ - /* http://www.adobe.com/content/dam/Adobe/en/devnet/acrobat/pdfs/FontPolicies.pdf */ - /* for more details. */ - /* */ - /* <Values> */ - /* FT_FSTYPE_INSTALLABLE_EMBEDDING :: */ - /* Fonts with no fsType bit set may be embedded and permanently */ - /* installed on the remote system by an application. */ - /* */ - /* FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING :: */ - /* Fonts that have only this bit set must not be modified, embedded */ - /* or exchanged in any manner without first obtaining permission of */ - /* the font software copyright owner. */ - /* */ - /* FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING :: */ - /* If this bit is set, the font may be embedded and temporarily */ - /* loaded on the remote system. Documents containing Preview & */ - /* Print fonts must be opened `read-only'; no edits can be applied */ - /* to the document. */ - /* */ - /* FT_FSTYPE_EDITABLE_EMBEDDING :: */ - /* If this bit is set, the font may be embedded but must only be */ - /* installed temporarily on other systems. In contrast to Preview */ - /* & Print fonts, documents containing editable fonts may be opened */ - /* for reading, editing is permitted, and changes may be saved. */ - /* */ - /* FT_FSTYPE_NO_SUBSETTING :: */ - /* If this bit is set, the font may not be subsetted prior to */ - /* embedding. */ - /* */ - /* FT_FSTYPE_BITMAP_EMBEDDING_ONLY :: */ - /* If this bit is set, only bitmaps contained in the font may be */ - /* embedded; no outline data may be embedded. If there are no */ - /* bitmaps available in the font, then the font is unembeddable. */ - /* */ - /* <Note> */ - /* The flags are ORed together, thus more than a single value can be */ - /* returned. */ - /* */ - /* While the fsType flags can indicate that a font may be embedded, a */ - /* license with the font vendor may be separately required to use the */ - /* font in this way. */ - /* */ -#define FT_FSTYPE_INSTALLABLE_EMBEDDING 0x0000 -#define FT_FSTYPE_RESTRICTED_LICENSE_EMBEDDING 0x0002 -#define FT_FSTYPE_PREVIEW_AND_PRINT_EMBEDDING 0x0004 -#define FT_FSTYPE_EDITABLE_EMBEDDING 0x0008 -#define FT_FSTYPE_NO_SUBSETTING 0x0100 -#define FT_FSTYPE_BITMAP_EMBEDDING_ONLY 0x0200 - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_FSType_Flags */ - /* */ - /* <Description> */ - /* Return the fsType flags for a font. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face object. */ - /* */ - /* <Return> */ - /* The fsType flags, @FT_FSTYPE_XXX. */ - /* */ - /* <Note> */ - /* Use this function rather than directly reading the `fs_type' field */ - /* in the @PS_FontInfoRec structure, which is only guaranteed to */ - /* return the correct results for Type~1 fonts. */ - /* */ - /* <Since> */ - /* 2.3.8 */ - /* */ - FT_EXPORT( FT_UShort ) - FT_Get_FSType_Flags( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* glyph_variants */ - /* */ - /* <Title> */ - /* Glyph Variants */ - /* */ - /* <Abstract> */ - /* The FreeType~2 interface to Unicode Ideographic Variation */ - /* Sequences (IVS), using the SFNT cmap format~14. */ - /* */ - /* <Description> */ - /* Many CJK characters have variant forms. They are a sort of grey */ - /* area somewhere between being totally irrelevant and semantically */ - /* distinct; for this reason, the Unicode consortium decided to */ - /* introduce Ideographic Variation Sequences (IVS), consisting of a */ - /* Unicode base character and one of 240 variant selectors */ - /* (U+E0100-U+E01EF), instead of further extending the already huge */ - /* code range for CJK characters. */ - /* */ - /* An IVS is registered and unique; for further details please refer */ - /* to Unicode Technical Standard #37, the Ideographic Variation */ - /* Database: */ - /* */ - /* http://www.unicode.org/reports/tr37/ */ - /* */ - /* To date (November 2014), the character with the most variants is */ - /* U+9089, having 32 such IVS. */ - /* */ - /* Adobe and MS decided to support IVS with a new cmap subtable */ - /* (format~14). It is an odd subtable because it is not a mapping of */ - /* input code points to glyphs, but contains lists of all variants */ - /* supported by the font. */ - /* */ - /* A variant may be either `default' or `non-default'. A default */ - /* variant is the one you will get for that code point if you look it */ - /* up in the standard Unicode cmap. A non-default variant is a */ - /* different glyph. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharVariantIndex */ - /* */ - /* <Description> */ - /* Return the glyph index of a given character code as modified by */ - /* the variation selector. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character code point in Unicode. */ - /* */ - /* variantSelector :: */ - /* The Unicode code point of the variation selector. */ - /* */ - /* <Return> */ - /* The glyph index. 0~means either `undefined character code', or */ - /* `undefined selector code', or `no variation selector cmap */ - /* subtable', or `current CharMap is not Unicode'. */ - /* */ - /* <Note> */ - /* If you use FreeType to manipulate the contents of font files */ - /* directly, be aware that the glyph index returned by this function */ - /* doesn't always correspond to the internal indices used within */ - /* the file. This is done to ensure that value~0 always corresponds */ - /* to the `missing glyph'. */ - /* */ - /* This function is only meaningful if */ - /* a) the font has a variation selector cmap sub table, */ - /* and */ - /* b) the current charmap has a Unicode encoding. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ - FT_EXPORT( FT_UInt ) - FT_Face_GetCharVariantIndex( FT_Face face, - FT_ULong charcode, - FT_ULong variantSelector ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharVariantIsDefault */ - /* */ - /* <Description> */ - /* Check whether this variant of this Unicode character is the one to */ - /* be found in the `cmap'. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character codepoint in Unicode. */ - /* */ - /* variantSelector :: */ - /* The Unicode codepoint of the variation selector. */ - /* */ - /* <Return> */ - /* 1~if found in the standard (Unicode) cmap, 0~if found in the */ - /* variation selector cmap, or -1 if it is not a variant. */ - /* */ - /* <Note> */ - /* This function is only meaningful if the font has a variation */ - /* selector cmap subtable. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ - FT_EXPORT( FT_Int ) - FT_Face_GetCharVariantIsDefault( FT_Face face, - FT_ULong charcode, - FT_ULong variantSelector ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetVariantSelectors */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode variant selectors found */ - /* in the font. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* <Return> */ - /* A pointer to an array of selector code points, or NULL if there is */ - /* no valid variant selector cmap subtable. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ - FT_EXPORT( FT_UInt32* ) - FT_Face_GetVariantSelectors( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetVariantsOfChar */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode variant selectors found */ - /* for the specified character code. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* charcode :: */ - /* The character codepoint in Unicode. */ - /* */ - /* <Return> */ - /* A pointer to an array of variant selector code points that are */ - /* active for the given character, or NULL if the corresponding list */ - /* is empty. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ - FT_EXPORT( FT_UInt32* ) - FT_Face_GetVariantsOfChar( FT_Face face, - FT_ULong charcode ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_GetCharsOfVariant */ - /* */ - /* <Description> */ - /* Return a zero-terminated list of Unicode character codes found for */ - /* the specified variant selector. */ - /* */ - /* <Input> */ - /* face :: */ - /* A handle to the source face object. */ - /* */ - /* variantSelector :: */ - /* The variant selector code point in Unicode. */ - /* */ - /* <Return> */ - /* A list of all the code points that are specified by this selector */ - /* (both default and non-default codes are returned) or NULL if there */ - /* is no valid cmap or the variant selector is invalid. */ - /* */ - /* <Note> */ - /* The last item in the array is~0; the array is owned by the */ - /* @FT_Face object but can be overwritten or released on the next */ - /* call to a FreeType function. */ - /* */ - /* <Since> */ - /* 2.3.6 */ - /* */ - FT_EXPORT( FT_UInt32* ) - FT_Face_GetCharsOfVariant( FT_Face face, - FT_ULong variantSelector ); - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /* <Title> */ - /* Computations */ - /* */ - /* <Abstract> */ - /* Crunching fixed numbers and vectors. */ - /* */ - /* <Description> */ - /* This section contains various functions used to perform */ - /* computations on 16.16 fixed-float numbers or 2d vectors. */ - /* */ - /* <Order> */ - /* FT_MulDiv */ - /* FT_MulFix */ - /* FT_DivFix */ - /* FT_RoundFix */ - /* FT_CeilFix */ - /* FT_FloorFix */ - /* FT_Vector_Transform */ - /* FT_Matrix_Multiply */ - /* FT_Matrix_Invert */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulDiv */ - /* */ - /* <Description> */ - /* A very simple function used to perform the computation `(a*b)/c' */ - /* with maximum accuracy (it uses a 64-bit intermediate integer */ - /* whenever necessary). */ - /* */ - /* This function isn't necessarily as fast as some processor specific */ - /* operations, but is at least completely portable. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. */ - /* c :: The divisor. */ - /* */ - /* <Return> */ - /* The result of `(a*b)/c'. This function never traps when trying to */ - /* divide by zero; it simply returns `MaxInt' or `MinInt' depending */ - /* on the signs of `a' and `b'. */ - /* */ - FT_EXPORT( FT_Long ) - FT_MulDiv( FT_Long a, - FT_Long b, - FT_Long c ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_MulFix */ - /* */ - /* <Description> */ - /* A very simple function used to perform the computation */ - /* `(a*b)/0x10000' with maximum accuracy. Most of the time this is */ - /* used to multiply a given value by a 16.16 fixed-point factor. */ - /* */ - /* <Input> */ - /* a :: The first multiplier. */ - /* b :: The second multiplier. Use a 16.16 factor here whenever */ - /* possible (see note below). */ - /* */ - /* <Return> */ - /* The result of `(a*b)/0x10000'. */ - /* */ - /* <Note> */ - /* This function has been optimized for the case where the absolute */ - /* value of `a' is less than 2048, and `b' is a 16.16 scaling factor. */ - /* As this happens mainly when scaling from notional units to */ - /* fractional pixels in FreeType, it resulted in noticeable speed */ - /* improvements between versions 2.x and 1.x. */ - /* */ - /* As a conclusion, always try to place a 16.16 factor as the */ - /* _second_ argument of this function; this can make a great */ - /* difference. */ - /* */ - FT_EXPORT( FT_Long ) - FT_MulFix( FT_Long a, - FT_Long b ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_DivFix */ - /* */ - /* <Description> */ - /* A very simple function used to perform the computation */ - /* `(a*0x10000)/b' with maximum accuracy. Most of the time, this is */ - /* used to divide a given value by a 16.16 fixed-point factor. */ - /* */ - /* <Input> */ - /* a :: The numerator. */ - /* b :: The denominator. Use a 16.16 factor here. */ - /* */ - /* <Return> */ - /* The result of `(a*0x10000)/b'. */ - /* */ - FT_EXPORT( FT_Long ) - FT_DivFix( FT_Long a, - FT_Long b ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_RoundFix */ - /* */ - /* <Description> */ - /* A very simple function used to round a 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number to be rounded. */ - /* */ - /* <Return> */ - /* `a' rounded to nearest 16.16 fixed integer, halfway cases away */ - /* from zero. */ - /* */ - FT_EXPORT( FT_Fixed ) - FT_RoundFix( FT_Fixed a ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_CeilFix */ - /* */ - /* <Description> */ - /* A very simple function used to compute the ceiling function of a */ - /* 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number for which the ceiling function is to be computed. */ - /* */ - /* <Return> */ - /* `a' rounded towards plus infinity. */ - /* */ - FT_EXPORT( FT_Fixed ) - FT_CeilFix( FT_Fixed a ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_FloorFix */ - /* */ - /* <Description> */ - /* A very simple function used to compute the floor function of a */ - /* 16.16 fixed number. */ - /* */ - /* <Input> */ - /* a :: The number for which the floor function is to be computed. */ - /* */ - /* <Return> */ - /* `a' rounded towards minus infinity. */ - /* */ - FT_EXPORT( FT_Fixed ) - FT_FloorFix( FT_Fixed a ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Vector_Transform */ - /* */ - /* <Description> */ - /* Transform a single vector through a 2x2 matrix. */ - /* */ - /* <InOut> */ - /* vector :: The target vector to transform. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the source 2x2 matrix. */ - /* */ - /* <Note> */ - /* The result is undefined if either `vector' or `matrix' is invalid. */ - /* */ - FT_EXPORT( void ) - FT_Vector_Transform( FT_Vector* vec, - const FT_Matrix* matrix ); - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* version */ - /* */ - /* <Title> */ - /* FreeType Version */ - /* */ - /* <Abstract> */ - /* Functions and macros related to FreeType versions. */ - /* */ - /* <Description> */ - /* Note that those functions and macros are of limited use because */ - /* even a new release of FreeType with only documentation changes */ - /* increases the version number. */ - /* */ - /* <Order> */ - /* FT_Library_Version */ - /* */ - /* FREETYPE_MAJOR */ - /* FREETYPE_MINOR */ - /* FREETYPE_PATCH */ - /* */ - /* FT_Face_CheckTrueTypePatents */ - /* FT_Face_SetUnpatentedHinting */ - /* */ - /* FREETYPE_XXX */ - /* */ - /*************************************************************************/ - - - /************************************************************************* - * - * @enum: - * FREETYPE_XXX - * - * @description: - * These three macros identify the FreeType source code version. - * Use @FT_Library_Version to access them at runtime. - * - * @values: - * FREETYPE_MAJOR :: The major version number. - * FREETYPE_MINOR :: The minor version number. - * FREETYPE_PATCH :: The patch level. - * - * @note: - * The version number of FreeType if built as a dynamic link library - * with the `libtool' package is _not_ controlled by these three - * macros. - * - */ -#define FREETYPE_MAJOR 2 -#define FREETYPE_MINOR 6 -#define FREETYPE_PATCH 3 - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Library_Version */ - /* */ - /* <Description> */ - /* Return the version of the FreeType library being used. This is */ - /* useful when dynamically linking to the library, since one cannot */ - /* use the macros @FREETYPE_MAJOR, @FREETYPE_MINOR, and */ - /* @FREETYPE_PATCH. */ - /* */ - /* <Input> */ - /* library :: A source library handle. */ - /* */ - /* <Output> */ - /* amajor :: The major version number. */ - /* */ - /* aminor :: The minor version number. */ - /* */ - /* apatch :: The patch version number. */ - /* */ - /* <Note> */ - /* The reason why this function takes a `library' argument is because */ - /* certain programs implement library initialization in a custom way */ - /* that doesn't use @FT_Init_FreeType. */ - /* */ - /* In such cases, the library version might not be available before */ - /* the library object has been created. */ - /* */ - FT_EXPORT( void ) - FT_Library_Version( FT_Library library, - FT_Int *amajor, - FT_Int *aminor, - FT_Int *apatch ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_CheckTrueTypePatents */ - /* */ - /* <Description> */ - /* Deprecated, does nothing. */ - /* */ - /* <Input> */ - /* face :: A face handle. */ - /* */ - /* <Return> */ - /* Always returns false. */ - /* */ - /* <Note> */ - /* Since May 2010, TrueType hinting is no longer patented. */ - /* */ - /* <Since> */ - /* 2.3.5 */ - /* */ - FT_EXPORT( FT_Bool ) - FT_Face_CheckTrueTypePatents( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Face_SetUnpatentedHinting */ - /* */ - /* <Description> */ - /* Deprecated, does nothing. */ - /* */ - /* <Input> */ - /* face :: A face handle. */ - /* */ - /* value :: New boolean setting. */ - /* */ - /* <Return> */ - /* Always returns false. */ - /* */ - /* <Note> */ - /* Since May 2010, TrueType hinting is no longer patented. */ - /* */ - /* <Since> */ - /* 2.3.5 */ - /* */ - FT_EXPORT( FT_Bool ) - FT_Face_SetUnpatentedHinting( FT_Face face, - FT_Bool value ); - - /* */ - - -FT_END_HEADER - -#endif /* FREETYPE_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ft2build.h b/android/armeabi/include/freetype/ft2build.h deleted file mode 100644 index b22bb27a..00000000 --- a/android/armeabi/include/freetype/ft2build.h +++ /dev/null @@ -1,42 +0,0 @@ -/***************************************************************************/ -/* */ -/* ft2build.h */ -/* */ -/* FreeType 2 build and setup macros. */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This is the `entry point' for FreeType header file inclusions. It is */ - /* the only header file which should be included directly; all other */ - /* FreeType header files should be accessed with macro names (after */ - /* including `ft2build.h'). */ - /* */ - /* A typical example is */ - /* */ - /* #include <ft2build.h> */ - /* #include FT_FREETYPE_H */ - /* */ - /*************************************************************************/ - - -#ifndef FT2BUILD_H_ -#define FT2BUILD_H_ - -#include "config/ftheader.h" - -#endif /* FT2BUILD_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftadvanc.h b/android/armeabi/include/freetype/ftadvanc.h deleted file mode 100644 index 023dd84b..00000000 --- a/android/armeabi/include/freetype/ftadvanc.h +++ /dev/null @@ -1,187 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftadvanc.h */ -/* */ -/* Quick computation of advance widths (specification only). */ -/* */ -/* Copyright 2008-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTADVANC_H_ -#define FTADVANC_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /************************************************************************** - * - * @section: - * quick_advance - * - * @title: - * Quick retrieval of advance values - * - * @abstract: - * Retrieve horizontal and vertical advance values without processing - * glyph outlines, if possible. - * - * @description: - * This section contains functions to quickly extract advance values - * without handling glyph outlines, if possible. - * - * @order: - * FT_Get_Advance - * FT_Get_Advances - * - */ - - - /*************************************************************************/ - /* */ - /* <Const> */ - /* FT_ADVANCE_FLAG_FAST_ONLY */ - /* */ - /* <Description> */ - /* A bit-flag to be OR-ed with the `flags' parameter of the */ - /* @FT_Get_Advance and @FT_Get_Advances functions. */ - /* */ - /* If set, it indicates that you want these functions to fail if the */ - /* corresponding hinting mode or font driver doesn't allow for very */ - /* quick advance computation. */ - /* */ - /* Typically, glyphs that are either unscaled, unhinted, bitmapped, */ - /* or light-hinted can have their advance width computed very */ - /* quickly. */ - /* */ - /* Normal and bytecode hinted modes that require loading, scaling, */ - /* and hinting of the glyph outline, are extremely slow by */ - /* comparison. */ - /* */ -#define FT_ADVANCE_FLAG_FAST_ONLY 0x20000000L - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Advance */ - /* */ - /* <Description> */ - /* Retrieve the advance value of a given glyph outline in an */ - /* @FT_Face. */ - /* */ - /* <Input> */ - /* face :: The source @FT_Face handle. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* load_flags :: A set of bit flags similar to those used when */ - /* calling @FT_Load_Glyph, used to determine what kind */ - /* of advances you need. */ - /* <Output> */ - /* padvance :: The advance value. If scaling is performed (based on */ - /* the value of `load_flags'), the advance value is in */ - /* 16.16 format. Otherwise, it is in font units. */ - /* */ - /* If @FT_LOAD_VERTICAL_LAYOUT is set, this is the */ - /* vertical advance corresponding to a vertical layout. */ - /* Otherwise, it is the horizontal advance in a */ - /* horizontal layout. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ - /* if the corresponding font backend doesn't have a quick way to */ - /* retrieve the advances. */ - /* */ - /* A scaled advance is returned in 16.16 format but isn't transformed */ - /* by the affine transformation specified by @FT_Set_Transform. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Advance( FT_Face face, - FT_UInt gindex, - FT_Int32 load_flags, - FT_Fixed *padvance ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Advances */ - /* */ - /* <Description> */ - /* Retrieve the advance values of several glyph outlines in an */ - /* @FT_Face. */ - /* */ - /* <Input> */ - /* face :: The source @FT_Face handle. */ - /* */ - /* start :: The first glyph index. */ - /* */ - /* count :: The number of advance values you want to retrieve. */ - /* */ - /* load_flags :: A set of bit flags similar to those used when */ - /* calling @FT_Load_Glyph. */ - /* */ - /* <Output> */ - /* padvance :: The advance values. This array, to be provided by the */ - /* caller, must contain at least `count' elements. */ - /* */ - /* If scaling is performed (based on the value of */ - /* `load_flags'), the advance values are in 16.16 format. */ - /* Otherwise, they are in font units. */ - /* */ - /* If @FT_LOAD_VERTICAL_LAYOUT is set, these are the */ - /* vertical advances corresponding to a vertical layout. */ - /* Otherwise, they are the horizontal advances in a */ - /* horizontal layout. */ - /* */ - /* <Return> */ - /* FreeType error code. 0 means success. */ - /* */ - /* <Note> */ - /* This function may fail if you use @FT_ADVANCE_FLAG_FAST_ONLY and */ - /* if the corresponding font backend doesn't have a quick way to */ - /* retrieve the advances. */ - /* */ - /* Scaled advances are returned in 16.16 format but aren't */ - /* transformed by the affine transformation specified by */ - /* @FT_Set_Transform. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Advances( FT_Face face, - FT_UInt start, - FT_UInt count, - FT_Int32 load_flags, - FT_Fixed *padvances ); - - /* */ - - -FT_END_HEADER - -#endif /* FTADVANC_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftautoh.h b/android/armeabi/include/freetype/ftautoh.h deleted file mode 100644 index 8052dd23..00000000 --- a/android/armeabi/include/freetype/ftautoh.h +++ /dev/null @@ -1,503 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftautoh.h */ -/* */ -/* FreeType API for controlling the auto-hinter (specification only). */ -/* */ -/* Copyright 2012-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTAUTOH_H_ -#define FTAUTOH_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /************************************************************************** - * - * @section: - * auto_hinter - * - * @title: - * The auto-hinter - * - * @abstract: - * Controlling the auto-hinting module. - * - * @description: - * While FreeType's auto-hinter doesn't expose API functions by itself, - * it is possible to control its behaviour with @FT_Property_Set and - * @FT_Property_Get. The following lists the available properties - * together with the necessary macros and structures. - * - * Note that the auto-hinter's module name is `autofitter' for - * historical reasons. - * - */ - - - /************************************************************************** - * - * @property: - * glyph-to-script-map - * - * @description: - * *Experimental* *only* - * - * The auto-hinter provides various script modules to hint glyphs. - * Examples of supported scripts are Latin or CJK. Before a glyph is - * auto-hinted, the Unicode character map of the font gets examined, and - * the script is then determined based on Unicode character ranges, see - * below. - * - * OpenType fonts, however, often provide much more glyphs than - * character codes (small caps, superscripts, ligatures, swashes, etc.), - * to be controlled by so-called `features'. Handling OpenType features - * can be quite complicated and thus needs a separate library on top of - * FreeType. - * - * The mapping between glyph indices and scripts (in the auto-hinter - * sense, see the @FT_AUTOHINTER_SCRIPT_XXX values) is stored as an - * array with `num_glyphs' elements, as found in the font's @FT_Face - * structure. The `glyph-to-script-map' property returns a pointer to - * this array, which can be modified as needed. Note that the - * modification should happen before the first glyph gets processed by - * the auto-hinter so that the global analysis of the font shapes - * actually uses the modified mapping. - * - * The following example code demonstrates how to access it (omitting - * the error handling). - * - * { - * FT_Library library; - * FT_Face face; - * FT_Prop_GlyphToScriptMap prop; - * - * - * FT_Init_FreeType( &library ); - * FT_New_Face( library, "foo.ttf", 0, &face ); - * - * prop.face = face; - * - * FT_Property_Get( library, "autofitter", - * "glyph-to-script-map", &prop ); - * - * // adjust `prop.map' as needed right here - * - * FT_Load_Glyph( face, ..., FT_LOAD_FORCE_AUTOHINT ); - * } - * - */ - - - /************************************************************************** - * - * @enum: - * FT_AUTOHINTER_SCRIPT_XXX - * - * @description: - * *Experimental* *only* - * - * A list of constants used for the @glyph-to-script-map property to - * specify the script submodule the auto-hinter should use for hinting a - * particular glyph. - * - * @values: - * FT_AUTOHINTER_SCRIPT_NONE :: - * Don't auto-hint this glyph. - * - * FT_AUTOHINTER_SCRIPT_LATIN :: - * Apply the latin auto-hinter. For the auto-hinter, `latin' is a - * very broad term, including Cyrillic and Greek also since characters - * from those scripts share the same design constraints. - * - * By default, characters from the following Unicode ranges are - * assigned to this submodule. - * - * { - * U+0020 - U+007F // Basic Latin (no control characters) - * U+00A0 - U+00FF // Latin-1 Supplement (no control characters) - * U+0100 - U+017F // Latin Extended-A - * U+0180 - U+024F // Latin Extended-B - * U+0250 - U+02AF // IPA Extensions - * U+02B0 - U+02FF // Spacing Modifier Letters - * U+0300 - U+036F // Combining Diacritical Marks - * U+0370 - U+03FF // Greek and Coptic - * U+0400 - U+04FF // Cyrillic - * U+0500 - U+052F // Cyrillic Supplement - * U+1D00 - U+1D7F // Phonetic Extensions - * U+1D80 - U+1DBF // Phonetic Extensions Supplement - * U+1DC0 - U+1DFF // Combining Diacritical Marks Supplement - * U+1E00 - U+1EFF // Latin Extended Additional - * U+1F00 - U+1FFF // Greek Extended - * U+2000 - U+206F // General Punctuation - * U+2070 - U+209F // Superscripts and Subscripts - * U+20A0 - U+20CF // Currency Symbols - * U+2150 - U+218F // Number Forms - * U+2460 - U+24FF // Enclosed Alphanumerics - * U+2C60 - U+2C7F // Latin Extended-C - * U+2DE0 - U+2DFF // Cyrillic Extended-A - * U+2E00 - U+2E7F // Supplemental Punctuation - * U+A640 - U+A69F // Cyrillic Extended-B - * U+A720 - U+A7FF // Latin Extended-D - * U+FB00 - U+FB06 // Alphab. Present. Forms (Latin Ligatures) - * U+1D400 - U+1D7FF // Mathematical Alphanumeric Symbols - * U+1F100 - U+1F1FF // Enclosed Alphanumeric Supplement - * } - * - * FT_AUTOHINTER_SCRIPT_CJK :: - * Apply the CJK auto-hinter, covering Chinese, Japanese, Korean, old - * Vietnamese, and some other scripts. - * - * By default, characters from the following Unicode ranges are - * assigned to this submodule. - * - * { - * U+1100 - U+11FF // Hangul Jamo - * U+2E80 - U+2EFF // CJK Radicals Supplement - * U+2F00 - U+2FDF // Kangxi Radicals - * U+2FF0 - U+2FFF // Ideographic Description Characters - * U+3000 - U+303F // CJK Symbols and Punctuation - * U+3040 - U+309F // Hiragana - * U+30A0 - U+30FF // Katakana - * U+3100 - U+312F // Bopomofo - * U+3130 - U+318F // Hangul Compatibility Jamo - * U+3190 - U+319F // Kanbun - * U+31A0 - U+31BF // Bopomofo Extended - * U+31C0 - U+31EF // CJK Strokes - * U+31F0 - U+31FF // Katakana Phonetic Extensions - * U+3200 - U+32FF // Enclosed CJK Letters and Months - * U+3300 - U+33FF // CJK Compatibility - * U+3400 - U+4DBF // CJK Unified Ideographs Extension A - * U+4DC0 - U+4DFF // Yijing Hexagram Symbols - * U+4E00 - U+9FFF // CJK Unified Ideographs - * U+A960 - U+A97F // Hangul Jamo Extended-A - * U+AC00 - U+D7AF // Hangul Syllables - * U+D7B0 - U+D7FF // Hangul Jamo Extended-B - * U+F900 - U+FAFF // CJK Compatibility Ideographs - * U+FE10 - U+FE1F // Vertical forms - * U+FE30 - U+FE4F // CJK Compatibility Forms - * U+FF00 - U+FFEF // Halfwidth and Fullwidth Forms - * U+1B000 - U+1B0FF // Kana Supplement - * U+1D300 - U+1D35F // Tai Xuan Hing Symbols - * U+1F200 - U+1F2FF // Enclosed Ideographic Supplement - * U+20000 - U+2A6DF // CJK Unified Ideographs Extension B - * U+2A700 - U+2B73F // CJK Unified Ideographs Extension C - * U+2B740 - U+2B81F // CJK Unified Ideographs Extension D - * U+2F800 - U+2FA1F // CJK Compatibility Ideographs Supplement - * } - * - * FT_AUTOHINTER_SCRIPT_INDIC :: - * Apply the indic auto-hinter, covering all major scripts from the - * Indian sub-continent and some other related scripts like Thai, Lao, - * or Tibetan. - * - * By default, characters from the following Unicode ranges are - * assigned to this submodule. - * - * { - * U+0900 - U+0DFF // Indic Range - * U+0F00 - U+0FFF // Tibetan - * U+1900 - U+194F // Limbu - * U+1B80 - U+1BBF // Sundanese - * U+1C80 - U+1CDF // Meetei Mayak - * U+A800 - U+A82F // Syloti Nagri - * U+11800 - U+118DF // Sharada - * } - * - * Note that currently Indic support is rudimentary only, missing blue - * zone support. - * - */ -#define FT_AUTOHINTER_SCRIPT_NONE 0 -#define FT_AUTOHINTER_SCRIPT_LATIN 1 -#define FT_AUTOHINTER_SCRIPT_CJK 2 -#define FT_AUTOHINTER_SCRIPT_INDIC 3 - - - /************************************************************************** - * - * @struct: - * FT_Prop_GlyphToScriptMap - * - * @description: - * *Experimental* *only* - * - * The data exchange structure for the @glyph-to-script-map property. - * - */ - typedef struct FT_Prop_GlyphToScriptMap_ - { - FT_Face face; - FT_UShort* map; - - } FT_Prop_GlyphToScriptMap; - - - /************************************************************************** - * - * @property: - * fallback-script - * - * @description: - * *Experimental* *only* - * - * If no auto-hinter script module can be assigned to a glyph, a - * fallback script gets assigned to it (see also the - * @glyph-to-script-map property). By default, this is - * @FT_AUTOHINTER_SCRIPT_CJK. Using the `fallback-script' property, - * this fallback value can be changed. - * - * { - * FT_Library library; - * FT_UInt fallback_script = FT_AUTOHINTER_SCRIPT_NONE; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "autofitter", - * "fallback-script", &fallback_script ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * It's important to use the right timing for changing this value: The - * creation of the glyph-to-script map that eventually uses the - * fallback script value gets triggered either by setting or reading a - * face-specific property like @glyph-to-script-map, or by auto-hinting - * any glyph from that face. In particular, if you have already created - * an @FT_Face structure but not loaded any glyph (using the - * auto-hinter), a change of the fallback script will affect this face. - * - */ - - - /************************************************************************** - * - * @property: - * default-script - * - * @description: - * *Experimental* *only* - * - * If FreeType gets compiled with FT_CONFIG_OPTION_USE_HARFBUZZ to make - * the HarfBuzz library access OpenType features for getting better - * glyph coverages, this property sets the (auto-fitter) script to be - * used for the default (OpenType) script data of a font's GSUB table. - * Features for the default script are intended for all scripts not - * explicitly handled in GSUB; an example is a `dlig' feature, - * containing the combination of the characters `T', `E', and `L' to - * form a `TEL' ligature. - * - * By default, this is @FT_AUTOHINTER_SCRIPT_LATIN. Using the - * `default-script' property, this default value can be changed. - * - * { - * FT_Library library; - * FT_UInt default_script = FT_AUTOHINTER_SCRIPT_NONE; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "autofitter", - * "default-script", &default_script ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * It's important to use the right timing for changing this value: The - * creation of the glyph-to-script map that eventually uses the - * default script value gets triggered either by setting or reading a - * face-specific property like @glyph-to-script-map, or by auto-hinting - * any glyph from that face. In particular, if you have already created - * an @FT_Face structure but not loaded any glyph (using the - * auto-hinter), a change of the default script will affect this face. - * - */ - - - /************************************************************************** - * - * @property: - * increase-x-height - * - * @description: - * For ppem values in the range 6~<= ppem <= `increase-x-height', round - * up the font's x~height much more often than normally. If the value - * is set to~0, which is the default, this feature is switched off. Use - * this property to improve the legibility of small font sizes if - * necessary. - * - * { - * FT_Library library; - * FT_Face face; - * FT_Prop_IncreaseXHeight prop; - * - * - * FT_Init_FreeType( &library ); - * FT_New_Face( library, "foo.ttf", 0, &face ); - * FT_Set_Char_Size( face, 10 * 64, 0, 72, 0 ); - * - * prop.face = face; - * prop.limit = 14; - * - * FT_Property_Set( library, "autofitter", - * "increase-x-height", &prop ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * Set this value right after calling @FT_Set_Char_Size, but before - * loading any glyph (using the auto-hinter). - * - */ - - - /************************************************************************** - * - * @struct: - * FT_Prop_IncreaseXHeight - * - * @description: - * The data exchange structure for the @increase-x-height property. - * - */ - typedef struct FT_Prop_IncreaseXHeight_ - { - FT_Face face; - FT_UInt limit; - - } FT_Prop_IncreaseXHeight; - - - /************************************************************************** - * - * @property: - * warping - * - * @description: - * *Experimental* *only* - * - * If FreeType gets compiled with option AF_CONFIG_OPTION_USE_WARPER to - * activate the warp hinting code in the auto-hinter, this property - * switches warping on and off. - * - * Warping only works in `light' auto-hinting mode. The idea of the - * code is to slightly scale and shift a glyph along the non-hinted - * dimension (which is usually the horizontal axis) so that as much of - * its segments are aligned (more or less) to the grid. To find out a - * glyph's optimal scaling and shifting value, various parameter - * combinations are tried and scored. - * - * By default, warping is off. The example below shows how to switch on - * warping (omitting the error handling). - * - * { - * FT_Library library; - * FT_Bool warping = 1; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "autofitter", - * "warping", &warping ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - * The warping code can also change advance widths. Have a look at the - * `lsb_delta' and `rsb_delta' fields in the @FT_GlyphSlotRec structure - * for details on improving inter-glyph distances while rendering. - * - * Since warping is a global property of the auto-hinter it is best to - * change its value before rendering any face. Otherwise, you should - * reload all faces that get auto-hinted in `light' hinting mode. - * - */ - - - /************************************************************************** - * - * @property: - * no-stem-darkening[autofit] - * - * @description: - * *Experimental* *only,* *requires* *linear* *alpha* *blending* *and* - * *gamma* *correction* - * - * Stem darkening emboldens glyphs at smaller sizes to make them more - * readable on common low-DPI screens when using linear alpha blending - * and gamma correction, see @FT_Render_Glyph. When not using linear - * alpha blending and gamma correction, glyphs will appear heavy and - * fuzzy! - * - * Gamma correction essentially lightens fonts since shades of grey are - * shifted to higher pixel values (=~higher brightness) to match the - * original intention to the reality of our screens. The side-effect is - * that glyphs `thin out'. Mac OS~X and Adobe's proprietary font - * rendering library implement a counter-measure: stem darkening at - * smaller sizes where shades of gray dominate. By emboldening a glyph - * slightly in relation to its pixel size, individual pixels get higher - * coverage of filled-in outlines and are therefore `blacker'. This - * counteracts the `thinning out' of glyphs, making text remain readable - * at smaller sizes. All glyphs that pass through the auto-hinter will - * be emboldened unless this property is set to TRUE. - * - * See the description of the CFF driver for algorithmic details. Total - * consistency with the CFF driver is currently not achieved because the - * emboldening method differs and glyphs must be scaled down on the - * Y-axis to keep outline points inside their precomputed blue zones. - * The smaller the size (especially 9ppem and down), the higher the loss - * of emboldening versus the CFF driver. - * - */ - - - /************************************************************************** - * - * @property: - * darkening-parameters[autofit] - * - * @description: - * *Experimental* *only* - * - * See the description of the CFF driver for details. This - * implementation appropriates the - * CFF_CONFIG_OPTION_DARKENING_PARAMETER_* #defines for consistency. - * Note the differences described in @no-stem-darkening[autofit]. - * - */ - - - /* */ - - -FT_END_HEADER - -#endif /* FTAUTOH_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftbbox.h b/android/armeabi/include/freetype/ftbbox.h deleted file mode 100644 index 2a4d2144..00000000 --- a/android/armeabi/include/freetype/ftbbox.h +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftbbox.h */ -/* */ -/* FreeType exact bbox computation (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This component has a _single_ role: to compute exact outline bounding */ - /* boxes. */ - /* */ - /* It is separated from the rest of the engine for various technical */ - /* reasons. It may well be integrated in `ftoutln' later. */ - /* */ - /*************************************************************************/ - - -#ifndef FTBBOX_H_ -#define FTBBOX_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_BBox */ - /* */ - /* <Description> */ - /* Compute the exact bounding box of an outline. This is slower */ - /* than computing the control box. However, it uses an advanced */ - /* algorithm that returns _very_ quickly when the two boxes */ - /* coincide. Otherwise, the outline Bézier arcs are traversed to */ - /* extract their extrema. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source outline. */ - /* */ - /* <Output> */ - /* abbox :: The outline's exact bounding box. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If the font is tricky and the glyph has been loaded with */ - /* @FT_LOAD_NO_SCALE, the resulting BBox is meaningless. To get */ - /* reasonable values for the BBox it is necessary to load the glyph */ - /* at a large ppem value (so that the hinting instructions can */ - /* properly shift and scale the subglyphs), then extracting the BBox, */ - /* which can be eventually converted back to font units. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Get_BBox( FT_Outline* outline, - FT_BBox *abbox ); - - /* */ - - -FT_END_HEADER - -#endif /* FTBBOX_H_ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/android/armeabi/include/freetype/ftbdf.h b/android/armeabi/include/freetype/ftbdf.h deleted file mode 100644 index 016dba08..00000000 --- a/android/armeabi/include/freetype/ftbdf.h +++ /dev/null @@ -1,210 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftbdf.h */ -/* */ -/* FreeType API for accessing BDF-specific strings (specification). */ -/* */ -/* Copyright 2002-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTBDF_H_ -#define FTBDF_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* bdf_fonts */ - /* */ - /* <Title> */ - /* BDF and PCF Files */ - /* */ - /* <Abstract> */ - /* BDF and PCF specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of functions specific to BDF */ - /* and PCF fonts. */ - /* */ - /*************************************************************************/ - - - /********************************************************************** - * - * @enum: - * BDF_PropertyType - * - * @description: - * A list of BDF property types. - * - * @values: - * BDF_PROPERTY_TYPE_NONE :: - * Value~0 is used to indicate a missing property. - * - * BDF_PROPERTY_TYPE_ATOM :: - * Property is a string atom. - * - * BDF_PROPERTY_TYPE_INTEGER :: - * Property is a 32-bit signed integer. - * - * BDF_PROPERTY_TYPE_CARDINAL :: - * Property is a 32-bit unsigned integer. - */ - typedef enum BDF_PropertyType_ - { - BDF_PROPERTY_TYPE_NONE = 0, - BDF_PROPERTY_TYPE_ATOM = 1, - BDF_PROPERTY_TYPE_INTEGER = 2, - BDF_PROPERTY_TYPE_CARDINAL = 3 - - } BDF_PropertyType; - - - /********************************************************************** - * - * @type: - * BDF_Property - * - * @description: - * A handle to a @BDF_PropertyRec structure to model a given - * BDF/PCF property. - */ - typedef struct BDF_PropertyRec_* BDF_Property; - - - /********************************************************************** - * - * @struct: - * BDF_PropertyRec - * - * @description: - * This structure models a given BDF/PCF property. - * - * @fields: - * type :: - * The property type. - * - * u.atom :: - * The atom string, if type is @BDF_PROPERTY_TYPE_ATOM. May be - * NULL, indicating an empty string. - * - * u.integer :: - * A signed integer, if type is @BDF_PROPERTY_TYPE_INTEGER. - * - * u.cardinal :: - * An unsigned integer, if type is @BDF_PROPERTY_TYPE_CARDINAL. - */ - typedef struct BDF_PropertyRec_ - { - BDF_PropertyType type; - union { - const char* atom; - FT_Int32 integer; - FT_UInt32 cardinal; - - } u; - - } BDF_PropertyRec; - - - /********************************************************************** - * - * @function: - * FT_Get_BDF_Charset_ID - * - * @description: - * Retrieve a BDF font character set identity, according to - * the BDF specification. - * - * @input: - * face :: - * A handle to the input face. - * - * @output: - * acharset_encoding :: - * Charset encoding, as a C~string, owned by the face. - * - * acharset_registry :: - * Charset registry, as a C~string, owned by the face. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with BDF faces, returning an error otherwise. - */ - FT_EXPORT( FT_Error ) - FT_Get_BDF_Charset_ID( FT_Face face, - const char* *acharset_encoding, - const char* *acharset_registry ); - - - /********************************************************************** - * - * @function: - * FT_Get_BDF_Property - * - * @description: - * Retrieve a BDF property from a BDF or PCF font file. - * - * @input: - * face :: A handle to the input face. - * - * name :: The property name. - * - * @output: - * aproperty :: The property. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function works with BDF _and_ PCF fonts. It returns an error - * otherwise. It also returns an error if the property is not in the - * font. - * - * A `property' is a either key-value pair within the STARTPROPERTIES - * ... ENDPROPERTIES block of a BDF font or a key-value pair from the - * `info->props' array within a `FontRec' structure of a PCF font. - * - * Integer properties are always stored as `signed' within PCF fonts; - * consequently, @BDF_PROPERTY_TYPE_CARDINAL is a possible return value - * for BDF fonts only. - * - * In case of error, `aproperty->type' is always set to - * @BDF_PROPERTY_TYPE_NONE. - */ - FT_EXPORT( FT_Error ) - FT_Get_BDF_Property( FT_Face face, - const char* prop_name, - BDF_PropertyRec *aproperty ); - - /* */ - -FT_END_HEADER - -#endif /* FTBDF_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftbitmap.h b/android/armeabi/include/freetype/ftbitmap.h deleted file mode 100644 index 0eac7b9d..00000000 --- a/android/armeabi/include/freetype/ftbitmap.h +++ /dev/null @@ -1,240 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftbitmap.h */ -/* */ -/* FreeType utility functions for bitmaps (specification). */ -/* */ -/* Copyright 2004-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTBITMAP_H_ -#define FTBITMAP_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* bitmap_handling */ - /* */ - /* <Title> */ - /* Bitmap Handling */ - /* */ - /* <Abstract> */ - /* Handling FT_Bitmap objects. */ - /* */ - /* <Description> */ - /* This section contains functions for handling @FT_Bitmap objects. */ - /* Note that none of the functions changes the bitmap's `flow' (as */ - /* indicated by the sign of the `pitch' field in `FT_Bitmap'). */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Init */ - /* */ - /* <Description> */ - /* Initialize a pointer to an @FT_Bitmap structure. */ - /* */ - /* <InOut> */ - /* abitmap :: A pointer to the bitmap structure. */ - /* */ - /* <Note> */ - /* A deprecated name for the same function is `FT_Bitmap_New'. */ - /* */ - FT_EXPORT( void ) - FT_Bitmap_Init( FT_Bitmap *abitmap ); - - - /* deprecated */ - FT_EXPORT( void ) - FT_Bitmap_New( FT_Bitmap *abitmap ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Copy */ - /* */ - /* <Description> */ - /* Copy a bitmap into another one. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* source :: A handle to the source bitmap. */ - /* */ - /* <Output> */ - /* target :: A handle to the target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Copy( FT_Library library, - const FT_Bitmap *source, - FT_Bitmap *target); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Embolden */ - /* */ - /* <Description> */ - /* Embolden a bitmap. The new bitmap will be about `xStrength' */ - /* pixels wider and `yStrength' pixels higher. The left and bottom */ - /* borders are kept unchanged. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* xStrength :: How strong the glyph is emboldened horizontally. */ - /* Expressed in 26.6 pixel format. */ - /* */ - /* yStrength :: How strong the glyph is emboldened vertically. */ - /* Expressed in 26.6 pixel format. */ - /* */ - /* <InOut> */ - /* bitmap :: A handle to the target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The current implementation restricts `xStrength' to be less than */ - /* or equal to~8 if bitmap is of pixel_mode @FT_PIXEL_MODE_MONO. */ - /* */ - /* If you want to embolden the bitmap owned by a @FT_GlyphSlotRec, */ - /* you should call @FT_GlyphSlot_Own_Bitmap on the slot first. */ - /* */ - /* Bitmaps in @FT_PIXEL_MODE_GRAY2 and @FT_PIXEL_MODE_GRAY@ format */ - /* are converted to @FT_PIXEL_MODE_GRAY format (i.e., 8bpp). */ - /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Embolden( FT_Library library, - FT_Bitmap* bitmap, - FT_Pos xStrength, - FT_Pos yStrength ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Convert */ - /* */ - /* <Description> */ - /* Convert a bitmap object with depth 1bpp, 2bpp, 4bpp, 8bpp or 32bpp */ - /* to a bitmap object with depth 8bpp, making the number of used */ - /* bytes line (a.k.a. the `pitch') a multiple of `alignment'. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* source :: The source bitmap. */ - /* */ - /* alignment :: The pitch of the bitmap is a multiple of this */ - /* parameter. Common values are 1, 2, or 4. */ - /* */ - /* <Output> */ - /* target :: The target bitmap. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* It is possible to call @FT_Bitmap_Convert multiple times without */ - /* calling @FT_Bitmap_Done (the memory is simply reallocated). */ - /* */ - /* Use @FT_Bitmap_Done to finally remove the bitmap object. */ - /* */ - /* The `library' argument is taken to have access to FreeType's */ - /* memory handling functions. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Convert( FT_Library library, - const FT_Bitmap *source, - FT_Bitmap *target, - FT_Int alignment ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GlyphSlot_Own_Bitmap */ - /* */ - /* <Description> */ - /* Make sure that a glyph slot owns `slot->bitmap'. */ - /* */ - /* <Input> */ - /* slot :: The glyph slot. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function is to be used in combination with */ - /* @FT_Bitmap_Embolden. */ - /* */ - FT_EXPORT( FT_Error ) - FT_GlyphSlot_Own_Bitmap( FT_GlyphSlot slot ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Bitmap_Done */ - /* */ - /* <Description> */ - /* Destroy a bitmap object initialized with @FT_Bitmap_Init. */ - /* */ - /* <Input> */ - /* library :: A handle to a library object. */ - /* */ - /* bitmap :: The bitmap object to be freed. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `library' argument is taken to have access to FreeType's */ - /* memory handling functions. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Bitmap_Done( FT_Library library, - FT_Bitmap *bitmap ); - - - /* */ - - -FT_END_HEADER - -#endif /* FTBITMAP_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftbzip2.h b/android/armeabi/include/freetype/ftbzip2.h deleted file mode 100644 index b7f2eee8..00000000 --- a/android/armeabi/include/freetype/ftbzip2.h +++ /dev/null @@ -1,102 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftbzip2.h */ -/* */ -/* Bzip2-compressed stream support. */ -/* */ -/* Copyright 2010-2016 by */ -/* Joel Klinghed. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTBZIP2_H_ -#define FTBZIP2_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************/ - /* */ - /* <Section> */ - /* bzip2 */ - /* */ - /* <Title> */ - /* BZIP2 Streams */ - /* */ - /* <Abstract> */ - /* Using bzip2-compressed font files. */ - /* */ - /* <Description> */ - /* This section contains the declaration of Bzip2-specific functions. */ - /* */ - /*************************************************************************/ - - - /************************************************************************ - * - * @function: - * FT_Stream_OpenBzip2 - * - * @description: - * Open a new stream to parse bzip2-compressed font files. This is - * mainly used to support the compressed `*.pcf.bz2' fonts that come - * with XFree86. - * - * @input: - * stream :: - * The target embedding stream. - * - * source :: - * The source stream. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source stream must be opened _before_ calling this function. - * - * Calling the internal function `FT_Stream_Close' on the new stream will - * *not* call `FT_Stream_Close' on the source stream. None of the stream - * objects will be released to the heap. - * - * The stream implementation is very basic and resets the decompression - * process each time seeking backwards is needed within the stream. - * - * In certain builds of the library, bzip2 compression recognition is - * automatically handled when calling @FT_New_Face or @FT_Open_Face. - * This means that if no font driver is capable of handling the raw - * compressed file, the library will try to open a bzip2 compressed stream - * from it and re-open the face with it. - * - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with bzip2 support. - */ - FT_EXPORT( FT_Error ) - FT_Stream_OpenBzip2( FT_Stream stream, - FT_Stream source ); - - /* */ - - -FT_END_HEADER - -#endif /* FTBZIP2_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftcache.h b/android/armeabi/include/freetype/ftcache.h deleted file mode 100644 index 6c9f2c42..00000000 --- a/android/armeabi/include/freetype/ftcache.h +++ /dev/null @@ -1,1057 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftcache.h */ -/* */ -/* FreeType Cache subsystem (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTCACHE_H_ -#define FTCACHE_H_ - - -#include <ft2build.h> -#include FT_GLYPH_H - - -FT_BEGIN_HEADER - - - /************************************************************************* - * - * <Section> - * cache_subsystem - * - * <Title> - * Cache Sub-System - * - * <Abstract> - * How to cache face, size, and glyph data with FreeType~2. - * - * <Description> - * This section describes the FreeType~2 cache sub-system, which is used - * to limit the number of concurrently opened @FT_Face and @FT_Size - * objects, as well as caching information like character maps and glyph - * images while limiting their maximum memory usage. - * - * Note that all types and functions begin with the `FTC_' prefix. - * - * The cache is highly portable and thus doesn't know anything about the - * fonts installed on your system, or how to access them. This implies - * the following scheme: - * - * First, available or installed font faces are uniquely identified by - * @FTC_FaceID values, provided to the cache by the client. Note that - * the cache only stores and compares these values, and doesn't try to - * interpret them in any way. - * - * Second, the cache calls, only when needed, a client-provided function - * to convert an @FTC_FaceID into a new @FT_Face object. The latter is - * then completely managed by the cache, including its termination - * through @FT_Done_Face. To monitor termination of face objects, the - * finalizer callback in the `generic' field of the @FT_Face object can - * be used, which might also be used to store the @FTC_FaceID of the - * face. - * - * Clients are free to map face IDs to anything else. The most simple - * usage is to associate them to a (pathname,face_index) pair that is - * used to call @FT_New_Face. However, more complex schemes are also - * possible. - * - * Note that for the cache to work correctly, the face ID values must be - * *persistent*, which means that the contents they point to should not - * change at runtime, or that their value should not become invalid. - * - * If this is unavoidable (e.g., when a font is uninstalled at runtime), - * you should call @FTC_Manager_RemoveFaceID as soon as possible, to let - * the cache get rid of any references to the old @FTC_FaceID it may - * keep internally. Failure to do so will lead to incorrect behaviour - * or even crashes. - * - * To use the cache, start with calling @FTC_Manager_New to create a new - * @FTC_Manager object, which models a single cache instance. You can - * then look up @FT_Face and @FT_Size objects with - * @FTC_Manager_LookupFace and @FTC_Manager_LookupSize, respectively. - * - * If you want to use the charmap caching, call @FTC_CMapCache_New, then - * later use @FTC_CMapCache_Lookup to perform the equivalent of - * @FT_Get_Char_Index, only much faster. - * - * If you want to use the @FT_Glyph caching, call @FTC_ImageCache, then - * later use @FTC_ImageCache_Lookup to retrieve the corresponding - * @FT_Glyph objects from the cache. - * - * If you need lots of small bitmaps, it is much more memory efficient - * to call @FTC_SBitCache_New followed by @FTC_SBitCache_Lookup. This - * returns @FTC_SBitRec structures, which are used to store small - * bitmaps directly. (A small bitmap is one whose metrics and - * dimensions all fit into 8-bit integers). - * - * We hope to also provide a kerning cache in the near future. - * - * - * <Order> - * FTC_Manager - * FTC_FaceID - * FTC_Face_Requester - * - * FTC_Manager_New - * FTC_Manager_Reset - * FTC_Manager_Done - * FTC_Manager_LookupFace - * FTC_Manager_LookupSize - * FTC_Manager_RemoveFaceID - * - * FTC_Node - * FTC_Node_Unref - * - * FTC_ImageCache - * FTC_ImageCache_New - * FTC_ImageCache_Lookup - * - * FTC_SBit - * FTC_SBitCache - * FTC_SBitCache_New - * FTC_SBitCache_Lookup - * - * FTC_CMapCache - * FTC_CMapCache_New - * FTC_CMapCache_Lookup - * - *************************************************************************/ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** BASIC TYPE DEFINITIONS *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /************************************************************************* - * - * @type: FTC_FaceID - * - * @description: - * An opaque pointer type that is used to identity face objects. The - * contents of such objects is application-dependent. - * - * These pointers are typically used to point to a user-defined - * structure containing a font file path, and face index. - * - * @note: - * Never use NULL as a valid @FTC_FaceID. - * - * Face IDs are passed by the client to the cache manager that calls, - * when needed, the @FTC_Face_Requester to translate them into new - * @FT_Face objects. - * - * If the content of a given face ID changes at runtime, or if the value - * becomes invalid (e.g., when uninstalling a font), you should - * immediately call @FTC_Manager_RemoveFaceID before any other cache - * function. - * - * Failure to do so will result in incorrect behaviour or even - * memory leaks and crashes. - */ - typedef FT_Pointer FTC_FaceID; - - - /************************************************************************ - * - * @functype: - * FTC_Face_Requester - * - * @description: - * A callback function provided by client applications. It is used by - * the cache manager to translate a given @FTC_FaceID into a new valid - * @FT_Face object, on demand. - * - * <Input> - * face_id :: - * The face ID to resolve. - * - * library :: - * A handle to a FreeType library object. - * - * req_data :: - * Application-provided request data (see note below). - * - * <Output> - * aface :: - * A new @FT_Face handle. - * - * <Return> - * FreeType error code. 0~means success. - * - * <Note> - * The third parameter `req_data' is the same as the one passed by the - * client when @FTC_Manager_New is called. - * - * The face requester should not perform funny things on the returned - * face object, like creating a new @FT_Size for it, or setting a - * transformation through @FT_Set_Transform! - */ - typedef FT_Error - (*FTC_Face_Requester)( FTC_FaceID face_id, - FT_Library library, - FT_Pointer req_data, - FT_Face* aface ); - - /* */ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** CACHE MANAGER OBJECT *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_Manager */ - /* */ - /* <Description> */ - /* This object corresponds to one instance of the cache-subsystem. */ - /* It is used to cache one or more @FT_Face objects, along with */ - /* corresponding @FT_Size objects. */ - /* */ - /* The manager intentionally limits the total number of opened */ - /* @FT_Face and @FT_Size objects to control memory usage. See the */ - /* `max_faces' and `max_sizes' parameters of @FTC_Manager_New. */ - /* */ - /* The manager is also used to cache `nodes' of various types while */ - /* limiting their total memory usage. */ - /* */ - /* All limitations are enforced by keeping lists of managed objects */ - /* in most-recently-used order, and flushing old nodes to make room */ - /* for new ones. */ - /* */ - typedef struct FTC_ManagerRec_* FTC_Manager; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_Node */ - /* */ - /* <Description> */ - /* An opaque handle to a cache node object. Each cache node is */ - /* reference-counted. A node with a count of~0 might be flushed */ - /* out of a full cache whenever a lookup request is performed. */ - /* */ - /* If you look up nodes, you have the ability to `acquire' them, */ - /* i.e., to increment their reference count. This will prevent the */ - /* node from being flushed out of the cache until you explicitly */ - /* `release' it (see @FTC_Node_Unref). */ - /* */ - /* See also @FTC_SBitCache_Lookup and @FTC_ImageCache_Lookup. */ - /* */ - typedef struct FTC_NodeRec_* FTC_Node; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_New */ - /* */ - /* <Description> */ - /* Create a new cache manager. */ - /* */ - /* <Input> */ - /* library :: The parent FreeType library handle to use. */ - /* */ - /* max_faces :: Maximum number of opened @FT_Face objects managed by */ - /* this cache instance. Use~0 for defaults. */ - /* */ - /* max_sizes :: Maximum number of opened @FT_Size objects managed by */ - /* this cache instance. Use~0 for defaults. */ - /* */ - /* max_bytes :: Maximum number of bytes to use for cached data nodes. */ - /* Use~0 for defaults. Note that this value does not */ - /* account for managed @FT_Face and @FT_Size objects. */ - /* */ - /* requester :: An application-provided callback used to translate */ - /* face IDs into real @FT_Face objects. */ - /* */ - /* req_data :: A generic pointer that is passed to the requester */ - /* each time it is called (see @FTC_Face_Requester). */ - /* */ - /* <Output> */ - /* amanager :: A handle to a new manager object. 0~in case of */ - /* failure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_Manager_New( FT_Library library, - FT_UInt max_faces, - FT_UInt max_sizes, - FT_ULong max_bytes, - FTC_Face_Requester requester, - FT_Pointer req_data, - FTC_Manager *amanager ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_Reset */ - /* */ - /* <Description> */ - /* Empty a given cache manager. This simply gets rid of all the */ - /* currently cached @FT_Face and @FT_Size objects within the manager. */ - /* */ - /* <InOut> */ - /* manager :: A handle to the manager. */ - /* */ - FT_EXPORT( void ) - FTC_Manager_Reset( FTC_Manager manager ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_Done */ - /* */ - /* <Description> */ - /* Destroy a given manager after emptying it. */ - /* */ - /* <Input> */ - /* manager :: A handle to the target cache manager object. */ - /* */ - FT_EXPORT( void ) - FTC_Manager_Done( FTC_Manager manager ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_LookupFace */ - /* */ - /* <Description> */ - /* Retrieve the @FT_Face object that corresponds to a given face ID */ - /* through a cache manager. */ - /* */ - /* <Input> */ - /* manager :: A handle to the cache manager. */ - /* */ - /* face_id :: The ID of the face object. */ - /* */ - /* <Output> */ - /* aface :: A handle to the face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned @FT_Face object is always owned by the manager. You */ - /* should never try to discard it yourself. */ - /* */ - /* The @FT_Face object doesn't necessarily have a current size object */ - /* (i.e., face->size can be~0). If you need a specific `font size', */ - /* use @FTC_Manager_LookupSize instead. */ - /* */ - /* Never change the face's transformation matrix (i.e., never call */ - /* the @FT_Set_Transform function) on a returned face! If you need */ - /* to transform glyphs, do it yourself after glyph loading. */ - /* */ - /* When you perform a lookup, out-of-memory errors are detected */ - /* _within_ the lookup and force incremental flushes of the cache */ - /* until enough memory is released for the lookup to succeed. */ - /* */ - /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ - /* already been completely flushed, and still no memory was available */ - /* for the operation. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_Manager_LookupFace( FTC_Manager manager, - FTC_FaceID face_id, - FT_Face *aface ); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FTC_ScalerRec */ - /* */ - /* <Description> */ - /* A structure used to describe a given character size in either */ - /* pixels or points to the cache manager. See */ - /* @FTC_Manager_LookupSize. */ - /* */ - /* <Fields> */ - /* face_id :: The source face ID. */ - /* */ - /* width :: The character width. */ - /* */ - /* height :: The character height. */ - /* */ - /* pixel :: A Boolean. If 1, the `width' and `height' fields are */ - /* interpreted as integer pixel character sizes. */ - /* Otherwise, they are expressed as 1/64th of points. */ - /* */ - /* x_res :: Only used when `pixel' is value~0 to indicate the */ - /* horizontal resolution in dpi. */ - /* */ - /* y_res :: Only used when `pixel' is value~0 to indicate the */ - /* vertical resolution in dpi. */ - /* */ - /* <Note> */ - /* This type is mainly used to retrieve @FT_Size objects through the */ - /* cache manager. */ - /* */ - typedef struct FTC_ScalerRec_ - { - FTC_FaceID face_id; - FT_UInt width; - FT_UInt height; - FT_Int pixel; - FT_UInt x_res; - FT_UInt y_res; - - } FTC_ScalerRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FTC_Scaler */ - /* */ - /* <Description> */ - /* A handle to an @FTC_ScalerRec structure. */ - /* */ - typedef struct FTC_ScalerRec_* FTC_Scaler; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Manager_LookupSize */ - /* */ - /* <Description> */ - /* Retrieve the @FT_Size object that corresponds to a given */ - /* @FTC_ScalerRec pointer through a cache manager. */ - /* */ - /* <Input> */ - /* manager :: A handle to the cache manager. */ - /* */ - /* scaler :: A scaler handle. */ - /* */ - /* <Output> */ - /* asize :: A handle to the size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned @FT_Size object is always owned by the manager. You */ - /* should never try to discard it by yourself. */ - /* */ - /* You can access the parent @FT_Face object simply as `size->face' */ - /* if you need it. Note that this object is also owned by the */ - /* manager. */ - /* */ - /* <Note> */ - /* When you perform a lookup, out-of-memory errors are detected */ - /* _within_ the lookup and force incremental flushes of the cache */ - /* until enough memory is released for the lookup to succeed. */ - /* */ - /* If a lookup fails with `FT_Err_Out_Of_Memory' the cache has */ - /* already been completely flushed, and still no memory is available */ - /* for the operation. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_Manager_LookupSize( FTC_Manager manager, - FTC_Scaler scaler, - FT_Size *asize ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_Node_Unref */ - /* */ - /* <Description> */ - /* Decrement a cache node's internal reference count. When the count */ - /* reaches 0, it is not destroyed but becomes eligible for subsequent */ - /* cache flushes. */ - /* */ - /* <Input> */ - /* node :: The cache node handle. */ - /* */ - /* manager :: The cache manager handle. */ - /* */ - FT_EXPORT( void ) - FTC_Node_Unref( FTC_Node node, - FTC_Manager manager ); - - - /************************************************************************* - * - * @function: - * FTC_Manager_RemoveFaceID - * - * @description: - * A special function used to indicate to the cache manager that - * a given @FTC_FaceID is no longer valid, either because its - * content changed, or because it was deallocated or uninstalled. - * - * @input: - * manager :: - * The cache manager handle. - * - * face_id :: - * The @FTC_FaceID to be removed. - * - * @note: - * This function flushes all nodes from the cache corresponding to this - * `face_id', with the exception of nodes with a non-null reference - * count. - * - * Such nodes are however modified internally so as to never appear - * in later lookups with the same `face_id' value, and to be immediately - * destroyed when released by all their users. - * - */ - FT_EXPORT( void ) - FTC_Manager_RemoveFaceID( FTC_Manager manager, - FTC_FaceID face_id ); - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* cache_subsystem */ - /* */ - /*************************************************************************/ - - /************************************************************************* - * - * @type: - * FTC_CMapCache - * - * @description: - * An opaque handle used to model a charmap cache. This cache is to - * hold character codes -> glyph indices mappings. - * - */ - typedef struct FTC_CMapCacheRec_* FTC_CMapCache; - - - /************************************************************************* - * - * @function: - * FTC_CMapCache_New - * - * @description: - * Create a new charmap cache. - * - * @input: - * manager :: - * A handle to the cache manager. - * - * @output: - * acache :: - * A new cache handle. NULL in case of error. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * Like all other caches, this one will be destroyed with the cache - * manager. - * - */ - FT_EXPORT( FT_Error ) - FTC_CMapCache_New( FTC_Manager manager, - FTC_CMapCache *acache ); - - - /************************************************************************ - * - * @function: - * FTC_CMapCache_Lookup - * - * @description: - * Translate a character code into a glyph index, using the charmap - * cache. - * - * @input: - * cache :: - * A charmap cache handle. - * - * face_id :: - * The source face ID. - * - * cmap_index :: - * The index of the charmap in the source face. Any negative value - * means to use the cache @FT_Face's default charmap. - * - * char_code :: - * The character code (in the corresponding charmap). - * - * @return: - * Glyph index. 0~means `no glyph'. - * - */ - FT_EXPORT( FT_UInt ) - FTC_CMapCache_Lookup( FTC_CMapCache cache, - FTC_FaceID face_id, - FT_Int cmap_index, - FT_UInt32 char_code ); - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* cache_subsystem */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** IMAGE CACHE OBJECT *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /************************************************************************* - * - * @struct: - * FTC_ImageTypeRec - * - * @description: - * A structure used to model the type of images in a glyph cache. - * - * @fields: - * face_id :: - * The face ID. - * - * width :: - * The width in pixels. - * - * height :: - * The height in pixels. - * - * flags :: - * The load flags, as in @FT_Load_Glyph. - * - */ - typedef struct FTC_ImageTypeRec_ - { - FTC_FaceID face_id; - FT_UInt width; - FT_UInt height; - FT_Int32 flags; - - } FTC_ImageTypeRec; - - - /************************************************************************* - * - * @type: - * FTC_ImageType - * - * @description: - * A handle to an @FTC_ImageTypeRec structure. - * - */ - typedef struct FTC_ImageTypeRec_* FTC_ImageType; - - - /* */ - - -#define FTC_IMAGE_TYPE_COMPARE( d1, d2 ) \ - ( (d1)->face_id == (d2)->face_id && \ - (d1)->width == (d2)->width && \ - (d1)->flags == (d2)->flags ) - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_ImageCache */ - /* */ - /* <Description> */ - /* A handle to a glyph image cache object. They are designed to */ - /* hold many distinct glyph images while not exceeding a certain */ - /* memory threshold. */ - /* */ - typedef struct FTC_ImageCacheRec_* FTC_ImageCache; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_ImageCache_New */ - /* */ - /* <Description> */ - /* Create a new glyph image cache. */ - /* */ - /* <Input> */ - /* manager :: The parent manager for the image cache. */ - /* */ - /* <Output> */ - /* acache :: A handle to the new glyph image cache object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_ImageCache_New( FTC_Manager manager, - FTC_ImageCache *acache ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_ImageCache_Lookup */ - /* */ - /* <Description> */ - /* Retrieve a given glyph image from a glyph image cache. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source glyph image cache. */ - /* */ - /* type :: A pointer to a glyph image type descriptor. */ - /* */ - /* gindex :: The glyph index to retrieve. */ - /* */ - /* <Output> */ - /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */ - /* failure. */ - /* */ - /* anode :: Used to return the address of of the corresponding cache */ - /* node after incrementing its reference count (see note */ - /* below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned glyph is owned and managed by the glyph image cache. */ - /* Never try to transform or discard it manually! You can however */ - /* create a copy with @FT_Glyph_Copy and modify the new one. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the glyph image, after increasing its reference */ - /* count. This ensures that the node (as well as the @FT_Glyph) will */ - /* always be kept in the cache until you call @FTC_Node_Unref to */ - /* `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the @FT_Glyph could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ - FT_EXPORT( FT_Error ) - FTC_ImageCache_Lookup( FTC_ImageCache cache, - FTC_ImageType type, - FT_UInt gindex, - FT_Glyph *aglyph, - FTC_Node *anode ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_ImageCache_LookupScaler */ - /* */ - /* <Description> */ - /* A variant of @FTC_ImageCache_Lookup that uses an @FTC_ScalerRec */ - /* to specify the face ID and its size. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source glyph image cache. */ - /* */ - /* scaler :: A pointer to a scaler descriptor. */ - /* */ - /* load_flags :: The corresponding load flags. */ - /* */ - /* gindex :: The glyph index to retrieve. */ - /* */ - /* <Output> */ - /* aglyph :: The corresponding @FT_Glyph object. 0~in case of */ - /* failure. */ - /* */ - /* anode :: Used to return the address of of the corresponding */ - /* cache node after incrementing its reference count */ - /* (see note below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The returned glyph is owned and managed by the glyph image cache. */ - /* Never try to transform or discard it manually! You can however */ - /* create a copy with @FT_Glyph_Copy and modify the new one. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the glyph image, after increasing its reference */ - /* count. This ensures that the node (as well as the @FT_Glyph) will */ - /* always be kept in the cache until you call @FTC_Node_Unref to */ - /* `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the @FT_Glyph could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ - /* Calls to @FT_Set_Char_Size and friends have no effect on cached */ - /* glyphs; you should always use the FreeType cache API instead. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_ImageCache_LookupScaler( FTC_ImageCache cache, - FTC_Scaler scaler, - FT_ULong load_flags, - FT_UInt gindex, - FT_Glyph *aglyph, - FTC_Node *anode ); - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_SBit */ - /* */ - /* <Description> */ - /* A handle to a small bitmap descriptor. See the @FTC_SBitRec */ - /* structure for details. */ - /* */ - typedef struct FTC_SBitRec_* FTC_SBit; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FTC_SBitRec */ - /* */ - /* <Description> */ - /* A very compact structure used to describe a small glyph bitmap. */ - /* */ - /* <Fields> */ - /* width :: The bitmap width in pixels. */ - /* */ - /* height :: The bitmap height in pixels. */ - /* */ - /* left :: The horizontal distance from the pen position to the */ - /* left bitmap border (a.k.a. `left side bearing', or */ - /* `lsb'). */ - /* */ - /* top :: The vertical distance from the pen position (on the */ - /* baseline) to the upper bitmap border (a.k.a. `top */ - /* side bearing'). The distance is positive for upwards */ - /* y~coordinates. */ - /* */ - /* format :: The format of the glyph bitmap (monochrome or gray). */ - /* */ - /* max_grays :: Maximum gray level value (in the range 1 to~255). */ - /* */ - /* pitch :: The number of bytes per bitmap line. May be positive */ - /* or negative. */ - /* */ - /* xadvance :: The horizontal advance width in pixels. */ - /* */ - /* yadvance :: The vertical advance height in pixels. */ - /* */ - /* buffer :: A pointer to the bitmap pixels. */ - /* */ - typedef struct FTC_SBitRec_ - { - FT_Byte width; - FT_Byte height; - FT_Char left; - FT_Char top; - - FT_Byte format; - FT_Byte max_grays; - FT_Short pitch; - FT_Char xadvance; - FT_Char yadvance; - - FT_Byte* buffer; - - } FTC_SBitRec; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FTC_SBitCache */ - /* */ - /* <Description> */ - /* A handle to a small bitmap cache. These are special cache objects */ - /* used to store small glyph bitmaps (and anti-aliased pixmaps) in a */ - /* much more efficient way than the traditional glyph image cache */ - /* implemented by @FTC_ImageCache. */ - /* */ - typedef struct FTC_SBitCacheRec_* FTC_SBitCache; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_SBitCache_New */ - /* */ - /* <Description> */ - /* Create a new cache to store small glyph bitmaps. */ - /* */ - /* <Input> */ - /* manager :: A handle to the source cache manager. */ - /* */ - /* <Output> */ - /* acache :: A handle to the new sbit cache. NULL in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FTC_SBitCache_New( FTC_Manager manager, - FTC_SBitCache *acache ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_SBitCache_Lookup */ - /* */ - /* <Description> */ - /* Look up a given small glyph bitmap in a given sbit cache and */ - /* `lock' it to prevent its flushing from the cache until needed. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source sbit cache. */ - /* */ - /* type :: A pointer to the glyph image type descriptor. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* <Output> */ - /* sbit :: A handle to a small bitmap descriptor. */ - /* */ - /* anode :: Used to return the address of of the corresponding cache */ - /* node after incrementing its reference count (see note */ - /* below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The small bitmap descriptor and its bit buffer are owned by the */ - /* cache and should never be freed by the application. They might */ - /* as well disappear from memory on the next cache lookup, so don't */ - /* treat them as persistent data. */ - /* */ - /* The descriptor's `buffer' field is set to~0 to indicate a missing */ - /* glyph bitmap. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the bitmap, after increasing its reference count. */ - /* This ensures that the node (as well as the image) will always be */ - /* kept in the cache until you call @FTC_Node_Unref to `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the bitmap could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ - FT_EXPORT( FT_Error ) - FTC_SBitCache_Lookup( FTC_SBitCache cache, - FTC_ImageType type, - FT_UInt gindex, - FTC_SBit *sbit, - FTC_Node *anode ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FTC_SBitCache_LookupScaler */ - /* */ - /* <Description> */ - /* A variant of @FTC_SBitCache_Lookup that uses an @FTC_ScalerRec */ - /* to specify the face ID and its size. */ - /* */ - /* <Input> */ - /* cache :: A handle to the source sbit cache. */ - /* */ - /* scaler :: A pointer to the scaler descriptor. */ - /* */ - /* load_flags :: The corresponding load flags. */ - /* */ - /* gindex :: The glyph index. */ - /* */ - /* <Output> */ - /* sbit :: A handle to a small bitmap descriptor. */ - /* */ - /* anode :: Used to return the address of of the corresponding */ - /* cache node after incrementing its reference count */ - /* (see note below). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The small bitmap descriptor and its bit buffer are owned by the */ - /* cache and should never be freed by the application. They might */ - /* as well disappear from memory on the next cache lookup, so don't */ - /* treat them as persistent data. */ - /* */ - /* The descriptor's `buffer' field is set to~0 to indicate a missing */ - /* glyph bitmap. */ - /* */ - /* If `anode' is _not_ NULL, it receives the address of the cache */ - /* node containing the bitmap, after increasing its reference count. */ - /* This ensures that the node (as well as the image) will always be */ - /* kept in the cache until you call @FTC_Node_Unref to `release' it. */ - /* */ - /* If `anode' is NULL, the cache node is left unchanged, which means */ - /* that the bitmap could be flushed out of the cache on the next */ - /* call to one of the caching sub-system APIs. Don't assume that it */ - /* is persistent! */ - /* */ - FT_EXPORT( FT_Error ) - FTC_SBitCache_LookupScaler( FTC_SBitCache cache, - FTC_Scaler scaler, - FT_ULong load_flags, - FT_UInt gindex, - FTC_SBit *sbit, - FTC_Node *anode ); - - /* */ - - -FT_END_HEADER - -#endif /* FTCACHE_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftcffdrv.h b/android/armeabi/include/freetype/ftcffdrv.h deleted file mode 100644 index 9dea980a..00000000 --- a/android/armeabi/include/freetype/ftcffdrv.h +++ /dev/null @@ -1,262 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftcffdrv.h */ -/* */ -/* FreeType API for controlling the CFF driver (specification only). */ -/* */ -/* Copyright 2013-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTCFFDRV_H_ -#define FTCFFDRV_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /************************************************************************** - * - * @section: - * cff_driver - * - * @title: - * The CFF driver - * - * @abstract: - * Controlling the CFF driver module. - * - * @description: - * While FreeType's CFF driver doesn't expose API functions by itself, - * it is possible to control its behaviour with @FT_Property_Set and - * @FT_Property_Get. The list below gives the available properties - * together with the necessary macros and structures. - * - * The CFF driver's module name is `cff'. - * - * *Hinting* *and* *antialiasing* *principles* *of* *the* *new* *engine* - * - * The rasterizer is positioning horizontal features (e.g., ascender - * height & x-height, or crossbars) on the pixel grid and minimizing the - * amount of antialiasing applied to them, while placing vertical - * features (vertical stems) on the pixel grid without hinting, thus - * representing the stem position and weight accurately. Sometimes the - * vertical stems may be only partially black. In this context, - * `antialiasing' means that stems are not positioned exactly on pixel - * borders, causing a fuzzy appearance. - * - * There are two principles behind this approach. - * - * 1) No hinting in the horizontal direction: Unlike `superhinted' - * TrueType, which changes glyph widths to accommodate regular - * inter-glyph spacing, Adobe's approach is `faithful to the design' in - * representing both the glyph width and the inter-glyph spacing - * designed for the font. This makes the screen display as close as it - * can be to the result one would get with infinite resolution, while - * preserving what is considered the key characteristics of each glyph. - * Note that the distances between unhinted and grid-fitted positions at - * small sizes are comparable to kerning values and thus would be - * noticeable (and distracting) while reading if hinting were applied. - * - * One of the reasons to not hint horizontally is antialiasing for LCD - * screens: The pixel geometry of modern displays supplies three - * vertical sub-pixels as the eye moves horizontally across each visible - * pixel. On devices where we can be certain this characteristic is - * present a rasterizer can take advantage of the sub-pixels to add - * increments of weight. In Western writing systems this turns out to - * be the more critical direction anyway; the weights and spacing of - * vertical stems (see above) are central to Armenian, Cyrillic, Greek, - * and Latin type designs. Even when the rasterizer uses greyscale - * antialiasing instead of color (a necessary compromise when one - * doesn't know the screen characteristics), the unhinted vertical - * features preserve the design's weight and spacing much better than - * aliased type would. - * - * 2) Aligment in the vertical direction: Weights and spacing along the - * y~axis are less critical; what is much more important is the visual - * alignment of related features (like cap-height and x-height). The - * sense of alignment for these is enhanced by the sharpness of grid-fit - * edges, while the cruder vertical resolution (full pixels instead of - * 1/3 pixels) is less of a problem. - * - * On the technical side, horizontal alignment zones for ascender, - * x-height, and other important height values (traditionally called - * `blue zones') as defined in the font are positioned independently, - * each being rounded to the nearest pixel edge, taking care of - * overshoot suppression at small sizes, stem darkening, and scaling. - * - * Hstems (this is, hint values defined in the font to help align - * horizontal features) that fall within a blue zone are said to be - * `captured' and are aligned to that zone. Uncaptured stems are moved - * in one of four ways, top edge up or down, bottom edge up or down. - * Unless there are conflicting hstems, the smallest movement is taken - * to minimize distortion. - * - * @order: - * hinting-engine - * no-stem-darkening[cff] - * darkening-parameters[cff] - * - */ - - - /************************************************************************** - * - * @property: - * hinting-engine - * - * @description: - * Thanks to Adobe, which contributed a new hinting (and parsing) - * engine, an application can select between `freetype' and `adobe' if - * compiled with CFF_CONFIG_OPTION_OLD_ENGINE. If this configuration - * macro isn't defined, `hinting-engine' does nothing. - * - * The default engine is `freetype' if CFF_CONFIG_OPTION_OLD_ENGINE is - * defined, and `adobe' otherwise. - * - * The following example code demonstrates how to select Adobe's hinting - * engine (omitting the error handling). - * - * { - * FT_Library library; - * FT_UInt hinting_engine = FT_CFF_HINTING_ADOBE; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "cff", - * "hinting-engine", &hinting_engine ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - */ - - - /************************************************************************** - * - * @enum: - * FT_CFF_HINTING_XXX - * - * @description: - * A list of constants used for the @hinting-engine property to select - * the hinting engine for CFF fonts. - * - * @values: - * FT_CFF_HINTING_FREETYPE :: - * Use the old FreeType hinting engine. - * - * FT_CFF_HINTING_ADOBE :: - * Use the hinting engine contributed by Adobe. - * - */ -#define FT_CFF_HINTING_FREETYPE 0 -#define FT_CFF_HINTING_ADOBE 1 - - - /************************************************************************** - * - * @property: - * no-stem-darkening[cff] - * - * @description: - * By default, the Adobe CFF engine darkens stems at smaller sizes, - * regardless of hinting, to enhance contrast. This feature requires - * a rendering system with proper gamma correction. Setting this - * property, stem darkening gets switched off. - * - * Note that stem darkening is never applied if @FT_LOAD_NO_SCALE is set. - * - * { - * FT_Library library; - * FT_Bool no_stem_darkening = TRUE; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "cff", - * "no-stem-darkening", &no_stem_darkening ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - */ - - - /************************************************************************** - * - * @property: - * darkening-parameters[cff] - * - * @description: - * By default, the Adobe CFF engine darkens stems as follows (if the - * `no-stem-darkening' property isn't set): - * - * { - * stem width <= 0.5px: darkening amount = 0.4px - * stem width = 1px: darkening amount = 0.275px - * stem width = 1.667px: darkening amount = 0.275px - * stem width >= 2.333px: darkening amount = 0px - * } - * - * and piecewise linear in-between. At configuration time, these four - * control points can be set with the macro - * `CFF_CONFIG_OPTION_DARKENING_PARAMETERS'. At runtime, the control - * points can be changed using the `darkening-parameters' property, as - * the following example demonstrates. - * - * { - * FT_Library library; - * FT_Int darken_params[8] = { 500, 300, // x1, y1 - * 1000, 200, // x2, y2 - * 1500, 100, // x3, y3 - * 2000, 0 }; // x4, y4 - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "cff", - * "darkening-parameters", darken_params ); - * } - * - * The x~values give the stem width, and the y~values the darkening - * amount. The unit is 1000th of pixels. All coordinate values must be - * positive; the x~values must be monotonically increasing; the - * y~values must be monotonically decreasing and smaller than or - * equal to 500 (corresponding to half a pixel); the slope of each - * linear piece must be shallower than -1 (e.g., -.4). - * - * @note: - * This property can be used with @FT_Property_Get also. - * - */ - - /* */ - - -FT_END_HEADER - - -#endif /* FTCFFDRV_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftchapters.h b/android/armeabi/include/freetype/ftchapters.h deleted file mode 100644 index ab438953..00000000 --- a/android/armeabi/include/freetype/ftchapters.h +++ /dev/null @@ -1,135 +0,0 @@ -/***************************************************************************/ -/* */ -/* This file defines the structure of the FreeType reference. */ -/* It is used by the python script that generates the HTML files. */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* general_remarks */ -/* */ -/* <Title> */ -/* General Remarks */ -/* */ -/* <Sections> */ -/* header_inclusion */ -/* user_allocation */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* core_api */ -/* */ -/* <Title> */ -/* Core API */ -/* */ -/* <Sections> */ -/* version */ -/* basic_types */ -/* base_interface */ -/* glyph_variants */ -/* glyph_management */ -/* mac_specific */ -/* sizes_management */ -/* header_file_macros */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* format_specific */ -/* */ -/* <Title> */ -/* Format-Specific API */ -/* */ -/* <Sections> */ -/* multiple_masters */ -/* truetype_tables */ -/* type1_tables */ -/* sfnt_names */ -/* bdf_fonts */ -/* cid_fonts */ -/* pfr_fonts */ -/* winfnt_fonts */ -/* font_formats */ -/* gasp_table */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* module_specific */ -/* */ -/* <Title> */ -/* Controlling FreeType Modules */ -/* */ -/* <Sections> */ -/* auto_hinter */ -/* cff_driver */ -/* tt_driver */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* cache_subsystem */ -/* */ -/* <Title> */ -/* Cache Sub-System */ -/* */ -/* <Sections> */ -/* cache_subsystem */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* support_api */ -/* */ -/* <Title> */ -/* Support API */ -/* */ -/* <Sections> */ -/* computations */ -/* list_processing */ -/* outline_processing */ -/* quick_advance */ -/* bitmap_handling */ -/* raster */ -/* glyph_stroker */ -/* system_interface */ -/* module_management */ -/* gzip */ -/* lzw */ -/* bzip2 */ -/* lcd_filtering */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* <Chapter> */ -/* error_codes */ -/* */ -/* <Title> */ -/* Error Codes */ -/* */ -/* <Sections> */ -/* error_enumerations */ -/* error_code_values */ -/* */ -/***************************************************************************/ diff --git a/android/armeabi/include/freetype/ftcid.h b/android/armeabi/include/freetype/ftcid.h deleted file mode 100644 index 140f2f87..00000000 --- a/android/armeabi/include/freetype/ftcid.h +++ /dev/null @@ -1,168 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftcid.h */ -/* */ -/* FreeType API for accessing CID font information (specification). */ -/* */ -/* Copyright 2007-2016 by */ -/* Dereg Clegg and Michael Toftdal. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTCID_H_ -#define FTCID_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* cid_fonts */ - /* */ - /* <Title> */ - /* CID Fonts */ - /* */ - /* <Abstract> */ - /* CID-keyed font specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of CID-keyed font specific */ - /* functions. */ - /* */ - /*************************************************************************/ - - - /********************************************************************** - * - * @function: - * FT_Get_CID_Registry_Ordering_Supplement - * - * @description: - * Retrieve the Registry/Ordering/Supplement triple (also known as the - * "R/O/S") from a CID-keyed font. - * - * @input: - * face :: - * A handle to the input face. - * - * @output: - * registry :: - * The registry, as a C~string, owned by the face. - * - * ordering :: - * The ordering, as a C~string, owned by the face. - * - * supplement :: - * The supplement. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with CID faces, returning an error - * otherwise. - * - * @since: - * 2.3.6 - */ - FT_EXPORT( FT_Error ) - FT_Get_CID_Registry_Ordering_Supplement( FT_Face face, - const char* *registry, - const char* *ordering, - FT_Int *supplement); - - - /********************************************************************** - * - * @function: - * FT_Get_CID_Is_Internally_CID_Keyed - * - * @description: - * Retrieve the type of the input face, CID keyed or not. In - * constrast to the @FT_IS_CID_KEYED macro this function returns - * successfully also for CID-keyed fonts in an SNFT wrapper. - * - * @input: - * face :: - * A handle to the input face. - * - * @output: - * is_cid :: - * The type of the face as an @FT_Bool. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with CID faces and OpenType fonts, - * returning an error otherwise. - * - * @since: - * 2.3.9 - */ - FT_EXPORT( FT_Error ) - FT_Get_CID_Is_Internally_CID_Keyed( FT_Face face, - FT_Bool *is_cid ); - - - /********************************************************************** - * - * @function: - * FT_Get_CID_From_Glyph_Index - * - * @description: - * Retrieve the CID of the input glyph index. - * - * @input: - * face :: - * A handle to the input face. - * - * glyph_index :: - * The input glyph index. - * - * @output: - * cid :: - * The CID as an @FT_UInt. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with CID faces and OpenType fonts, - * returning an error otherwise. - * - * @since: - * 2.3.9 - */ - FT_EXPORT( FT_Error ) - FT_Get_CID_From_Glyph_Index( FT_Face face, - FT_UInt glyph_index, - FT_UInt *cid ); - - /* */ - - -FT_END_HEADER - -#endif /* FTCID_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/fterrdef.h b/android/armeabi/include/freetype/fterrdef.h deleted file mode 100644 index 3f53dd58..00000000 --- a/android/armeabi/include/freetype/fterrdef.h +++ /dev/null @@ -1,276 +0,0 @@ -/***************************************************************************/ -/* */ -/* fterrdef.h */ -/* */ -/* FreeType error codes (specification). */ -/* */ -/* Copyright 2002-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* error_code_values */ - /* */ - /* <Title> */ - /* Error Code Values */ - /* */ - /* <Abstract> */ - /* All possible error codes returned by FreeType functions. */ - /* */ - /* <Description> */ - /* The list below is taken verbatim from the file `fterrdef.h' */ - /* (loaded automatically by including `FT_FREETYPE_H'). The first */ - /* argument of the `FT_ERROR_DEF_' macro is the error label; by */ - /* default, the prefix `FT_Err_' gets added so that you get error */ - /* names like `FT_Err_Cannot_Open_Resource'. The second argument is */ - /* the error code, and the last argument an error string, which is not */ - /* used by FreeType. */ - /* */ - /* Within your application you should *only* use error names and */ - /* *never* its numeric values! The latter might (and actually do) */ - /* change in forthcoming FreeType versions. */ - /* */ - /* Macro `FT_NOERRORDEF_' defines `FT_Err_Ok', which is always zero. */ - /* See the `Error Enumerations' subsection how to automatically */ - /* generate a list of error strings. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Err_XXX */ - /* */ - /*************************************************************************/ - - /* generic errors */ - - FT_NOERRORDEF_( Ok, 0x00, - "no error" ) - - FT_ERRORDEF_( Cannot_Open_Resource, 0x01, - "cannot open resource" ) - FT_ERRORDEF_( Unknown_File_Format, 0x02, - "unknown file format" ) - FT_ERRORDEF_( Invalid_File_Format, 0x03, - "broken file" ) - FT_ERRORDEF_( Invalid_Version, 0x04, - "invalid FreeType version" ) - FT_ERRORDEF_( Lower_Module_Version, 0x05, - "module version is too low" ) - FT_ERRORDEF_( Invalid_Argument, 0x06, - "invalid argument" ) - FT_ERRORDEF_( Unimplemented_Feature, 0x07, - "unimplemented feature" ) - FT_ERRORDEF_( Invalid_Table, 0x08, - "broken table" ) - FT_ERRORDEF_( Invalid_Offset, 0x09, - "broken offset within table" ) - FT_ERRORDEF_( Array_Too_Large, 0x0A, - "array allocation size too large" ) - FT_ERRORDEF_( Missing_Module, 0x0B, - "missing module" ) - FT_ERRORDEF_( Missing_Property, 0x0C, - "missing property" ) - - /* glyph/character errors */ - - FT_ERRORDEF_( Invalid_Glyph_Index, 0x10, - "invalid glyph index" ) - FT_ERRORDEF_( Invalid_Character_Code, 0x11, - "invalid character code" ) - FT_ERRORDEF_( Invalid_Glyph_Format, 0x12, - "unsupported glyph image format" ) - FT_ERRORDEF_( Cannot_Render_Glyph, 0x13, - "cannot render this glyph format" ) - FT_ERRORDEF_( Invalid_Outline, 0x14, - "invalid outline" ) - FT_ERRORDEF_( Invalid_Composite, 0x15, - "invalid composite glyph" ) - FT_ERRORDEF_( Too_Many_Hints, 0x16, - "too many hints" ) - FT_ERRORDEF_( Invalid_Pixel_Size, 0x17, - "invalid pixel size" ) - - /* handle errors */ - - FT_ERRORDEF_( Invalid_Handle, 0x20, - "invalid object handle" ) - FT_ERRORDEF_( Invalid_Library_Handle, 0x21, - "invalid library handle" ) - FT_ERRORDEF_( Invalid_Driver_Handle, 0x22, - "invalid module handle" ) - FT_ERRORDEF_( Invalid_Face_Handle, 0x23, - "invalid face handle" ) - FT_ERRORDEF_( Invalid_Size_Handle, 0x24, - "invalid size handle" ) - FT_ERRORDEF_( Invalid_Slot_Handle, 0x25, - "invalid glyph slot handle" ) - FT_ERRORDEF_( Invalid_CharMap_Handle, 0x26, - "invalid charmap handle" ) - FT_ERRORDEF_( Invalid_Cache_Handle, 0x27, - "invalid cache manager handle" ) - FT_ERRORDEF_( Invalid_Stream_Handle, 0x28, - "invalid stream handle" ) - - /* driver errors */ - - FT_ERRORDEF_( Too_Many_Drivers, 0x30, - "too many modules" ) - FT_ERRORDEF_( Too_Many_Extensions, 0x31, - "too many extensions" ) - - /* memory errors */ - - FT_ERRORDEF_( Out_Of_Memory, 0x40, - "out of memory" ) - FT_ERRORDEF_( Unlisted_Object, 0x41, - "unlisted object" ) - - /* stream errors */ - - FT_ERRORDEF_( Cannot_Open_Stream, 0x51, - "cannot open stream" ) - FT_ERRORDEF_( Invalid_Stream_Seek, 0x52, - "invalid stream seek" ) - FT_ERRORDEF_( Invalid_Stream_Skip, 0x53, - "invalid stream skip" ) - FT_ERRORDEF_( Invalid_Stream_Read, 0x54, - "invalid stream read" ) - FT_ERRORDEF_( Invalid_Stream_Operation, 0x55, - "invalid stream operation" ) - FT_ERRORDEF_( Invalid_Frame_Operation, 0x56, - "invalid frame operation" ) - FT_ERRORDEF_( Nested_Frame_Access, 0x57, - "nested frame access" ) - FT_ERRORDEF_( Invalid_Frame_Read, 0x58, - "invalid frame read" ) - - /* raster errors */ - - FT_ERRORDEF_( Raster_Uninitialized, 0x60, - "raster uninitialized" ) - FT_ERRORDEF_( Raster_Corrupted, 0x61, - "raster corrupted" ) - FT_ERRORDEF_( Raster_Overflow, 0x62, - "raster overflow" ) - FT_ERRORDEF_( Raster_Negative_Height, 0x63, - "negative height while rastering" ) - - /* cache errors */ - - FT_ERRORDEF_( Too_Many_Caches, 0x70, - "too many registered caches" ) - - /* TrueType and SFNT errors */ - - FT_ERRORDEF_( Invalid_Opcode, 0x80, - "invalid opcode" ) - FT_ERRORDEF_( Too_Few_Arguments, 0x81, - "too few arguments" ) - FT_ERRORDEF_( Stack_Overflow, 0x82, - "stack overflow" ) - FT_ERRORDEF_( Code_Overflow, 0x83, - "code overflow" ) - FT_ERRORDEF_( Bad_Argument, 0x84, - "bad argument" ) - FT_ERRORDEF_( Divide_By_Zero, 0x85, - "division by zero" ) - FT_ERRORDEF_( Invalid_Reference, 0x86, - "invalid reference" ) - FT_ERRORDEF_( Debug_OpCode, 0x87, - "found debug opcode" ) - FT_ERRORDEF_( ENDF_In_Exec_Stream, 0x88, - "found ENDF opcode in execution stream" ) - FT_ERRORDEF_( Nested_DEFS, 0x89, - "nested DEFS" ) - FT_ERRORDEF_( Invalid_CodeRange, 0x8A, - "invalid code range" ) - FT_ERRORDEF_( Execution_Too_Long, 0x8B, - "execution context too long" ) - FT_ERRORDEF_( Too_Many_Function_Defs, 0x8C, - "too many function definitions" ) - FT_ERRORDEF_( Too_Many_Instruction_Defs, 0x8D, - "too many instruction definitions" ) - FT_ERRORDEF_( Table_Missing, 0x8E, - "SFNT font table missing" ) - FT_ERRORDEF_( Horiz_Header_Missing, 0x8F, - "horizontal header (hhea) table missing" ) - FT_ERRORDEF_( Locations_Missing, 0x90, - "locations (loca) table missing" ) - FT_ERRORDEF_( Name_Table_Missing, 0x91, - "name table missing" ) - FT_ERRORDEF_( CMap_Table_Missing, 0x92, - "character map (cmap) table missing" ) - FT_ERRORDEF_( Hmtx_Table_Missing, 0x93, - "horizontal metrics (hmtx) table missing" ) - FT_ERRORDEF_( Post_Table_Missing, 0x94, - "PostScript (post) table missing" ) - FT_ERRORDEF_( Invalid_Horiz_Metrics, 0x95, - "invalid horizontal metrics" ) - FT_ERRORDEF_( Invalid_CharMap_Format, 0x96, - "invalid character map (cmap) format" ) - FT_ERRORDEF_( Invalid_PPem, 0x97, - "invalid ppem value" ) - FT_ERRORDEF_( Invalid_Vert_Metrics, 0x98, - "invalid vertical metrics" ) - FT_ERRORDEF_( Could_Not_Find_Context, 0x99, - "could not find context" ) - FT_ERRORDEF_( Invalid_Post_Table_Format, 0x9A, - "invalid PostScript (post) table format" ) - FT_ERRORDEF_( Invalid_Post_Table, 0x9B, - "invalid PostScript (post) table" ) - - /* CFF, CID, and Type 1 errors */ - - FT_ERRORDEF_( Syntax_Error, 0xA0, - "opcode syntax error" ) - FT_ERRORDEF_( Stack_Underflow, 0xA1, - "argument stack underflow" ) - FT_ERRORDEF_( Ignore, 0xA2, - "ignore" ) - FT_ERRORDEF_( No_Unicode_Glyph_Name, 0xA3, - "no Unicode glyph name found" ) - FT_ERRORDEF_( Glyph_Too_Big, 0xA4, - "glyph too big for hinting" ) - - /* BDF errors */ - - FT_ERRORDEF_( Missing_Startfont_Field, 0xB0, - "`STARTFONT' field missing" ) - FT_ERRORDEF_( Missing_Font_Field, 0xB1, - "`FONT' field missing" ) - FT_ERRORDEF_( Missing_Size_Field, 0xB2, - "`SIZE' field missing" ) - FT_ERRORDEF_( Missing_Fontboundingbox_Field, 0xB3, - "`FONTBOUNDINGBOX' field missing" ) - FT_ERRORDEF_( Missing_Chars_Field, 0xB4, - "`CHARS' field missing" ) - FT_ERRORDEF_( Missing_Startchar_Field, 0xB5, - "`STARTCHAR' field missing" ) - FT_ERRORDEF_( Missing_Encoding_Field, 0xB6, - "`ENCODING' field missing" ) - FT_ERRORDEF_( Missing_Bbx_Field, 0xB7, - "`BBX' field missing" ) - FT_ERRORDEF_( Bbx_Too_Big, 0xB8, - "`BBX' too big" ) - FT_ERRORDEF_( Corrupted_Font_Header, 0xB9, - "Font header corrupted or missing fields" ) - FT_ERRORDEF_( Corrupted_Font_Glyphs, 0xBA, - "Font glyphs corrupted or missing fields" ) - - /* */ - - -/* END */ diff --git a/android/armeabi/include/freetype/fterrors.h b/android/armeabi/include/freetype/fterrors.h deleted file mode 100644 index e15bfb00..00000000 --- a/android/armeabi/include/freetype/fterrors.h +++ /dev/null @@ -1,226 +0,0 @@ -/***************************************************************************/ -/* */ -/* fterrors.h */ -/* */ -/* FreeType error code handling (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* error_enumerations */ - /* */ - /* <Title> */ - /* Error Enumerations */ - /* */ - /* <Abstract> */ - /* How to handle errors and error strings. */ - /* */ - /* <Description> */ - /* The header file `fterrors.h' (which is automatically included by */ - /* `freetype.h' defines the handling of FreeType's enumeration */ - /* constants. It can also be used to generate error message strings */ - /* with a small macro trick explained below. */ - /* */ - /* *Error* *Formats* */ - /* */ - /* The configuration macro FT_CONFIG_OPTION_USE_MODULE_ERRORS can be */ - /* defined in `ftoption.h' in order to make the higher byte indicate */ - /* the module where the error has happened (this is not compatible */ - /* with standard builds of FreeType 2, however). See the file */ - /* `ftmoderr.h' for more details. */ - /* */ - /* *Error* *Message* *Strings* */ - /* */ - /* Error definitions are set up with special macros that allow client */ - /* applications to build a table of error message strings. The */ - /* strings are not included in a normal build of FreeType 2 to */ - /* save space (most client applications do not use them). */ - /* */ - /* To do so, you have to define the following macros before including */ - /* this file. */ - /* */ - /* { */ - /* FT_ERROR_START_LIST */ - /* } */ - /* */ - /* This macro is called before anything else to define the start of */ - /* the error list. It is followed by several FT_ERROR_DEF calls. */ - /* */ - /* { */ - /* FT_ERROR_DEF( e, v, s ) */ - /* } */ - /* */ - /* This macro is called to define one single error. `e' is the error */ - /* code identifier (e.g., `Invalid_Argument'), `v' is the error's */ - /* numerical value, and `s' is the corresponding error string. */ - /* */ - /* { */ - /* FT_ERROR_END_LIST */ - /* } */ - /* */ - /* This macro ends the list. */ - /* */ - /* Additionally, you have to undefine `FTERRORS_H_' before #including */ - /* this file. */ - /* */ - /* Here is a simple example. */ - /* */ - /* { */ - /* #undef FTERRORS_H_ */ - /* #define FT_ERRORDEF( e, v, s ) { e, s }, */ - /* #define FT_ERROR_START_LIST { */ - /* #define FT_ERROR_END_LIST { 0, NULL } }; */ - /* */ - /* const struct */ - /* { */ - /* int err_code; */ - /* const char* err_msg; */ - /* } ft_errors[] = */ - /* */ - /* #include FT_ERRORS_H */ - /* } */ - /* */ - /* Note that `FT_Err_Ok' is _not_ defined with `FT_ERRORDEF' but with */ - /* `FT_NOERRORDEF'; it is always zero. */ - /* */ - /*************************************************************************/ - - /* */ - - /* In previous FreeType versions we used `__FTERRORS_H__'. However, */ - /* using two successive underscores in a non-system symbol name */ - /* violates the C (and C++) standard, so it was changed to the */ - /* current form. In spite of this, we have to make */ - /* */ - /* #undefine __FTERRORS_H__ */ - /* */ - /* work for backwards compatibility. */ - /* */ -#if !( defined( FTERRORS_H_ ) && defined ( __FTERRORS_H__ ) ) -#define FTERRORS_H_ -#define __FTERRORS_H__ - - - /* include module base error codes */ -#include FT_MODULE_ERRORS_H - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** SETUP MACROS *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - - -#undef FT_NEED_EXTERN_C - - - /* FT_ERR_PREFIX is used as a prefix for error identifiers. */ - /* By default, we use `FT_Err_'. */ - /* */ -#ifndef FT_ERR_PREFIX -#define FT_ERR_PREFIX FT_Err_ -#endif - - - /* FT_ERR_BASE is used as the base for module-specific errors. */ - /* */ -#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS - -#ifndef FT_ERR_BASE -#define FT_ERR_BASE FT_Mod_Err_Base -#endif - -#else - -#undef FT_ERR_BASE -#define FT_ERR_BASE 0 - -#endif /* FT_CONFIG_OPTION_USE_MODULE_ERRORS */ - - - /* If FT_ERRORDEF is not defined, we need to define a simple */ - /* enumeration type. */ - /* */ -#ifndef FT_ERRORDEF - -#define FT_ERRORDEF( e, v, s ) e = v, -#define FT_ERROR_START_LIST enum { -#define FT_ERROR_END_LIST FT_ERR_CAT( FT_ERR_PREFIX, Max ) }; - -#ifdef __cplusplus -#define FT_NEED_EXTERN_C - extern "C" { -#endif - -#endif /* !FT_ERRORDEF */ - - - /* this macro is used to define an error */ -#define FT_ERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v + FT_ERR_BASE, s ) - - /* this is only used for <module>_Err_Ok, which must be 0! */ -#define FT_NOERRORDEF_( e, v, s ) \ - FT_ERRORDEF( FT_ERR_CAT( FT_ERR_PREFIX, e ), v, s ) - - -#ifdef FT_ERROR_START_LIST - FT_ERROR_START_LIST -#endif - - - /* now include the error codes */ -#include FT_ERROR_DEFINITIONS_H - - -#ifdef FT_ERROR_END_LIST - FT_ERROR_END_LIST -#endif - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** SIMPLE CLEANUP *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - -#ifdef FT_NEED_EXTERN_C - } -#endif - -#undef FT_ERROR_START_LIST -#undef FT_ERROR_END_LIST - -#undef FT_ERRORDEF -#undef FT_ERRORDEF_ -#undef FT_NOERRORDEF_ - -#undef FT_NEED_EXTERN_C -#undef FT_ERR_BASE - - /* FT_ERR_PREFIX is needed internally */ -#ifndef FT2_BUILD_LIBRARY -#undef FT_ERR_PREFIX -#endif - -#endif /* !(FTERRORS_H_ && __FTERRORS_H__) */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftfntfmt.h b/android/armeabi/include/freetype/ftfntfmt.h deleted file mode 100644 index bd423247..00000000 --- a/android/armeabi/include/freetype/ftfntfmt.h +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftfntfmt.h */ -/* */ -/* Support functions for font formats. */ -/* */ -/* Copyright 2002-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTFNTFMT_H_ -#define FTFNTFMT_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* font_formats */ - /* */ - /* <Title> */ - /* Font Formats */ - /* */ - /* <Abstract> */ - /* Getting the font format. */ - /* */ - /* <Description> */ - /* The single function in this section can be used to get the font */ - /* format. Note that this information is not needed normally; */ - /* however, there are special cases (like in PDF devices) where it is */ - /* important to differentiate, in spite of FreeType's uniform API. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Font_Format */ - /* */ - /* <Description> */ - /* Return a string describing the format of a given face. Possible */ - /* values are `TrueType', `Type~1', `BDF', `PCF', `Type~42', */ - /* `CID~Type~1', `CFF', `PFR', and `Windows~FNT'. */ - /* */ - /* The return value is suitable to be used as an X11 FONT_PROPERTY. */ - /* */ - /* <Input> */ - /* face :: */ - /* Input face handle. */ - /* */ - /* <Return> */ - /* Font format string. NULL in case of error. */ - /* */ - /* <Note> */ - /* A deprecated name for the same function is */ - /* `FT_Get_X11_Font_Format'. */ - /* */ - FT_EXPORT( const char* ) - FT_Get_Font_Format( FT_Face face ); - - - /* deprecated */ - FT_EXPORT( const char* ) - FT_Get_X11_Font_Format( FT_Face face ); - - - /* */ - - -FT_END_HEADER - -#endif /* FTFNTFMT_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftgasp.h b/android/armeabi/include/freetype/ftgasp.h deleted file mode 100644 index 3f5b3bc6..00000000 --- a/android/armeabi/include/freetype/ftgasp.h +++ /dev/null @@ -1,129 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftgasp.h */ -/* */ -/* Access of TrueType's `gasp' table (specification). */ -/* */ -/* Copyright 2007-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTGASP_H_ -#define FTGASP_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - - /*************************************************************************** - * - * @section: - * gasp_table - * - * @title: - * Gasp Table - * - * @abstract: - * Retrieving TrueType `gasp' table entries. - * - * @description: - * The function @FT_Get_Gasp can be used to query a TrueType or OpenType - * font for specific entries in its `gasp' table, if any. This is - * mainly useful when implementing native TrueType hinting with the - * bytecode interpreter to duplicate the Windows text rendering results. - */ - - /************************************************************************* - * - * @enum: - * FT_GASP_XXX - * - * @description: - * A list of values and/or bit-flags returned by the @FT_Get_Gasp - * function. - * - * @values: - * FT_GASP_NO_TABLE :: - * This special value means that there is no GASP table in this face. - * It is up to the client to decide what to do. - * - * FT_GASP_DO_GRIDFIT :: - * Grid-fitting and hinting should be performed at the specified ppem. - * This *really* means TrueType bytecode interpretation. If this bit - * is not set, no hinting gets applied. - * - * FT_GASP_DO_GRAY :: - * Anti-aliased rendering should be performed at the specified ppem. - * If not set, do monochrome rendering. - * - * FT_GASP_SYMMETRIC_SMOOTHING :: - * If set, smoothing along multiple axes must be used with ClearType. - * - * FT_GASP_SYMMETRIC_GRIDFIT :: - * Grid-fitting must be used with ClearType's symmetric smoothing. - * - * @note: - * The bit-flags `FT_GASP_DO_GRIDFIT' and `FT_GASP_DO_GRAY' are to be - * used for standard font rasterization only. Independently of that, - * `FT_GASP_SYMMETRIC_SMOOTHING' and `FT_GASP_SYMMETRIC_GRIDFIT' are to - * be used if ClearType is enabled (and `FT_GASP_DO_GRIDFIT' and - * `FT_GASP_DO_GRAY' are consequently ignored). - * - * `ClearType' is Microsoft's implementation of LCD rendering, partly - * protected by patents. - * - * @since: - * 2.3.0 - */ -#define FT_GASP_NO_TABLE -1 -#define FT_GASP_DO_GRIDFIT 0x01 -#define FT_GASP_DO_GRAY 0x02 -#define FT_GASP_SYMMETRIC_SMOOTHING 0x08 -#define FT_GASP_SYMMETRIC_GRIDFIT 0x10 - - - /************************************************************************* - * - * @func: - * FT_Get_Gasp - * - * @description: - * Read the `gasp' table from a TrueType or OpenType font file and - * return the entry corresponding to a given character pixel size. - * - * @input: - * face :: The source face handle. - * ppem :: The vertical character pixel size. - * - * @return: - * Bit flags (see @FT_GASP_XXX), or @FT_GASP_NO_TABLE if there is no - * `gasp' table in the face. - * - * @since: - * 2.3.0 - */ - FT_EXPORT( FT_Int ) - FT_Get_Gasp( FT_Face face, - FT_UInt ppem ); - - /* */ - - -#endif /* FTGASP_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftglyph.h b/android/armeabi/include/freetype/ftglyph.h deleted file mode 100644 index d9840a81..00000000 --- a/android/armeabi/include/freetype/ftglyph.h +++ /dev/null @@ -1,605 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftglyph.h */ -/* */ -/* FreeType convenience functions to handle glyphs (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file contains the definition of several convenience functions */ - /* that can be used by client applications to easily retrieve glyph */ - /* bitmaps and outlines from a given face. */ - /* */ - /* These functions should be optional if you are writing a font server */ - /* or text layout engine on top of FreeType. However, they are pretty */ - /* handy for many other simple uses of the library. */ - /* */ - /*************************************************************************/ - - -#ifndef FTGLYPH_H_ -#define FTGLYPH_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* glyph_management */ - /* */ - /* <Title> */ - /* Glyph Management */ - /* */ - /* <Abstract> */ - /* Generic interface to manage individual glyph data. */ - /* */ - /* <Description> */ - /* This section contains definitions used to manage glyph data */ - /* through generic FT_Glyph objects. Each of them can contain a */ - /* bitmap, a vector outline, or even images in other formats. */ - /* */ - /*************************************************************************/ - - - /* forward declaration to a private type */ - typedef struct FT_Glyph_Class_ FT_Glyph_Class; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Glyph */ - /* */ - /* <Description> */ - /* Handle to an object used to model generic glyph images. It is a */ - /* pointer to the @FT_GlyphRec structure and can contain a glyph */ - /* bitmap or pointer. */ - /* */ - /* <Note> */ - /* Glyph objects are not owned by the library. You must thus release */ - /* them manually (through @FT_Done_Glyph) _before_ calling */ - /* @FT_Done_FreeType. */ - /* */ - typedef struct FT_GlyphRec_* FT_Glyph; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_GlyphRec */ - /* */ - /* <Description> */ - /* The root glyph structure contains a given glyph image plus its */ - /* advance width in 16.16 fixed-point format. */ - /* */ - /* <Fields> */ - /* library :: A handle to the FreeType library object. */ - /* */ - /* clazz :: A pointer to the glyph's class. Private. */ - /* */ - /* format :: The format of the glyph's image. */ - /* */ - /* advance :: A 16.16 vector that gives the glyph's advance width. */ - /* */ - typedef struct FT_GlyphRec_ - { - FT_Library library; - const FT_Glyph_Class* clazz; - FT_Glyph_Format format; - FT_Vector advance; - - } FT_GlyphRec; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_BitmapGlyph */ - /* */ - /* <Description> */ - /* A handle to an object used to model a bitmap glyph image. This is */ - /* a sub-class of @FT_Glyph, and a pointer to @FT_BitmapGlyphRec. */ - /* */ - typedef struct FT_BitmapGlyphRec_* FT_BitmapGlyph; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_BitmapGlyphRec */ - /* */ - /* <Description> */ - /* A structure used for bitmap glyph images. This really is a */ - /* `sub-class' of @FT_GlyphRec. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Glyph fields. */ - /* */ - /* left :: The left-side bearing, i.e., the horizontal distance */ - /* from the current pen position to the left border of the */ - /* glyph bitmap. */ - /* */ - /* top :: The top-side bearing, i.e., the vertical distance from */ - /* the current pen position to the top border of the glyph */ - /* bitmap. This distance is positive for upwards~y! */ - /* */ - /* bitmap :: A descriptor for the bitmap. */ - /* */ - /* <Note> */ - /* You can typecast an @FT_Glyph to @FT_BitmapGlyph if you have */ - /* `glyph->format == FT_GLYPH_FORMAT_BITMAP'. This lets you access */ - /* the bitmap's contents easily. */ - /* */ - /* The corresponding pixel buffer is always owned by @FT_BitmapGlyph */ - /* and is thus created and destroyed with it. */ - /* */ - typedef struct FT_BitmapGlyphRec_ - { - FT_GlyphRec root; - FT_Int left; - FT_Int top; - FT_Bitmap bitmap; - - } FT_BitmapGlyphRec; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_OutlineGlyph */ - /* */ - /* <Description> */ - /* A handle to an object used to model an outline glyph image. This */ - /* is a sub-class of @FT_Glyph, and a pointer to @FT_OutlineGlyphRec. */ - /* */ - typedef struct FT_OutlineGlyphRec_* FT_OutlineGlyph; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_OutlineGlyphRec */ - /* */ - /* <Description> */ - /* A structure used for outline (vectorial) glyph images. This */ - /* really is a `sub-class' of @FT_GlyphRec. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Glyph fields. */ - /* */ - /* outline :: A descriptor for the outline. */ - /* */ - /* <Note> */ - /* You can typecast an @FT_Glyph to @FT_OutlineGlyph if you have */ - /* `glyph->format == FT_GLYPH_FORMAT_OUTLINE'. This lets you access */ - /* the outline's content easily. */ - /* */ - /* As the outline is extracted from a glyph slot, its coordinates are */ - /* expressed normally in 26.6 pixels, unless the flag */ - /* @FT_LOAD_NO_SCALE was used in @FT_Load_Glyph() or @FT_Load_Char(). */ - /* */ - /* The outline's tables are always owned by the object and are */ - /* destroyed with it. */ - /* */ - typedef struct FT_OutlineGlyphRec_ - { - FT_GlyphRec root; - FT_Outline outline; - - } FT_OutlineGlyphRec; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Glyph */ - /* */ - /* <Description> */ - /* A function used to extract a glyph image from a slot. Note that */ - /* the created @FT_Glyph object must be released with @FT_Done_Glyph. */ - /* */ - /* <Input> */ - /* slot :: A handle to the source glyph slot. */ - /* */ - /* <Output> */ - /* aglyph :: A handle to the glyph object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Glyph( FT_GlyphSlot slot, - FT_Glyph *aglyph ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Copy */ - /* */ - /* <Description> */ - /* A function used to copy a glyph image. Note that the created */ - /* @FT_Glyph object must be released with @FT_Done_Glyph. */ - /* */ - /* <Input> */ - /* source :: A handle to the source glyph object. */ - /* */ - /* <Output> */ - /* target :: A handle to the target glyph object. 0~in case of */ - /* error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Glyph_Copy( FT_Glyph source, - FT_Glyph *target ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Transform */ - /* */ - /* <Description> */ - /* Transform a glyph image if its format is scalable. */ - /* */ - /* <InOut> */ - /* glyph :: A handle to the target glyph object. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to a 2x2 matrix to apply. */ - /* */ - /* delta :: A pointer to a 2d vector to apply. Coordinates are */ - /* expressed in 1/64th of a pixel. */ - /* */ - /* <Return> */ - /* FreeType error code (if not 0, the glyph format is not scalable). */ - /* */ - /* <Note> */ - /* The 2x2 transformation matrix is also applied to the glyph's */ - /* advance vector. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Glyph_Transform( FT_Glyph glyph, - FT_Matrix* matrix, - FT_Vector* delta ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Glyph_BBox_Mode */ - /* */ - /* <Description> */ - /* The mode how the values of @FT_Glyph_Get_CBox are returned. */ - /* */ - /* <Values> */ - /* FT_GLYPH_BBOX_UNSCALED :: */ - /* Return unscaled font units. */ - /* */ - /* FT_GLYPH_BBOX_SUBPIXELS :: */ - /* Return unfitted 26.6 coordinates. */ - /* */ - /* FT_GLYPH_BBOX_GRIDFIT :: */ - /* Return grid-fitted 26.6 coordinates. */ - /* */ - /* FT_GLYPH_BBOX_TRUNCATE :: */ - /* Return coordinates in integer pixels. */ - /* */ - /* FT_GLYPH_BBOX_PIXELS :: */ - /* Return grid-fitted pixel coordinates. */ - /* */ - typedef enum FT_Glyph_BBox_Mode_ - { - FT_GLYPH_BBOX_UNSCALED = 0, - FT_GLYPH_BBOX_SUBPIXELS = 0, - FT_GLYPH_BBOX_GRIDFIT = 1, - FT_GLYPH_BBOX_TRUNCATE = 2, - FT_GLYPH_BBOX_PIXELS = 3 - - } FT_Glyph_BBox_Mode; - - - /* these constants are deprecated; use the corresponding */ - /* `FT_Glyph_BBox_Mode' values instead */ -#define ft_glyph_bbox_unscaled FT_GLYPH_BBOX_UNSCALED -#define ft_glyph_bbox_subpixels FT_GLYPH_BBOX_SUBPIXELS -#define ft_glyph_bbox_gridfit FT_GLYPH_BBOX_GRIDFIT -#define ft_glyph_bbox_truncate FT_GLYPH_BBOX_TRUNCATE -#define ft_glyph_bbox_pixels FT_GLYPH_BBOX_PIXELS - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_Get_CBox */ - /* */ - /* <Description> */ - /* Return a glyph's `control box'. The control box encloses all the */ - /* outline's points, including Bézier control points. Though it */ - /* coincides with the exact bounding box for most glyphs, it can be */ - /* slightly larger in some situations (like when rotating an outline */ - /* that contains Bézier outside arcs). */ - /* */ - /* Computing the control box is very fast, while getting the bounding */ - /* box can take much more time as it needs to walk over all segments */ - /* and arcs in the outline. To get the latter, you can use the */ - /* `ftbbox' component, which is dedicated to this single task. */ - /* */ - /* <Input> */ - /* glyph :: A handle to the source glyph object. */ - /* */ - /* mode :: The mode that indicates how to interpret the returned */ - /* bounding box values. */ - /* */ - /* <Output> */ - /* acbox :: The glyph coordinate bounding box. Coordinates are */ - /* expressed in 1/64th of pixels if it is grid-fitted. */ - /* */ - /* <Note> */ - /* Coordinates are relative to the glyph origin, using the y~upwards */ - /* convention. */ - /* */ - /* If the glyph has been loaded with @FT_LOAD_NO_SCALE, `bbox_mode' */ - /* must be set to @FT_GLYPH_BBOX_UNSCALED to get unscaled font */ - /* units in 26.6 pixel format. The value @FT_GLYPH_BBOX_SUBPIXELS */ - /* is another name for this constant. */ - /* */ - /* If the font is tricky and the glyph has been loaded with */ - /* @FT_LOAD_NO_SCALE, the resulting CBox is meaningless. To get */ - /* reasonable values for the CBox it is necessary to load the glyph */ - /* at a large ppem value (so that the hinting instructions can */ - /* properly shift and scale the subglyphs), then extracting the CBox, */ - /* which can be eventually converted back to font units. */ - /* */ - /* Note that the maximum coordinates are exclusive, which means that */ - /* one can compute the width and height of the glyph image (be it in */ - /* integer or 26.6 pixels) as: */ - /* */ - /* { */ - /* width = bbox.xMax - bbox.xMin; */ - /* height = bbox.yMax - bbox.yMin; */ - /* } */ - /* */ - /* Note also that for 26.6 coordinates, if `bbox_mode' is set to */ - /* @FT_GLYPH_BBOX_GRIDFIT, the coordinates will also be grid-fitted, */ - /* which corresponds to: */ - /* */ - /* { */ - /* bbox.xMin = FLOOR(bbox.xMin); */ - /* bbox.yMin = FLOOR(bbox.yMin); */ - /* bbox.xMax = CEILING(bbox.xMax); */ - /* bbox.yMax = CEILING(bbox.yMax); */ - /* } */ - /* */ - /* To get the bbox in pixel coordinates, set `bbox_mode' to */ - /* @FT_GLYPH_BBOX_TRUNCATE. */ - /* */ - /* To get the bbox in grid-fitted pixel coordinates, set `bbox_mode' */ - /* to @FT_GLYPH_BBOX_PIXELS. */ - /* */ - FT_EXPORT( void ) - FT_Glyph_Get_CBox( FT_Glyph glyph, - FT_UInt bbox_mode, - FT_BBox *acbox ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Glyph_To_Bitmap */ - /* */ - /* <Description> */ - /* Convert a given glyph object to a bitmap glyph object. */ - /* */ - /* <InOut> */ - /* the_glyph :: A pointer to a handle to the target glyph. */ - /* */ - /* <Input> */ - /* render_mode :: An enumeration that describes how the data is */ - /* rendered. */ - /* */ - /* origin :: A pointer to a vector used to translate the glyph */ - /* image before rendering. Can be~0 (if no */ - /* translation). The origin is expressed in */ - /* 26.6 pixels. */ - /* */ - /* destroy :: A boolean that indicates that the original glyph */ - /* image should be destroyed by this function. It is */ - /* never destroyed in case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function does nothing if the glyph format isn't scalable. */ - /* */ - /* The glyph image is translated with the `origin' vector before */ - /* rendering. */ - /* */ - /* The first parameter is a pointer to an @FT_Glyph handle, that will */ - /* be _replaced_ by this function (with newly allocated data). */ - /* Typically, you would use (omitting error handling): */ - /* */ - /* */ - /* { */ - /* FT_Glyph glyph; */ - /* FT_BitmapGlyph glyph_bitmap; */ - /* */ - /* */ - /* // load glyph */ - /* error = FT_Load_Char( face, glyph_index, FT_LOAD_DEFAUT ); */ - /* */ - /* // extract glyph image */ - /* error = FT_Get_Glyph( face->glyph, &glyph ); */ - /* */ - /* // convert to a bitmap (default render mode + destroying old) */ - /* if ( glyph->format != FT_GLYPH_FORMAT_BITMAP ) */ - /* { */ - /* error = FT_Glyph_To_Bitmap( &glyph, FT_RENDER_MODE_NORMAL, */ - /* 0, 1 ); */ - /* if ( error ) // `glyph' unchanged */ - /* ... */ - /* } */ - /* */ - /* // access bitmap content by typecasting */ - /* glyph_bitmap = (FT_BitmapGlyph)glyph; */ - /* */ - /* // do funny stuff with it, like blitting/drawing */ - /* ... */ - /* */ - /* // discard glyph image (bitmap or not) */ - /* FT_Done_Glyph( glyph ); */ - /* } */ - /* */ - /* */ - /* Here another example, again without error handling: */ - /* */ - /* */ - /* { */ - /* FT_Glyph glyphs[MAX_GLYPHS] */ - /* */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* error = FT_Load_Glyph( face, idx, FT_LOAD_DEFAULT ) || */ - /* FT_Get_Glyph ( face->glyph, &glyph[idx] ); */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* { */ - /* FT_Glyph bitmap = glyphs[idx]; */ - /* */ - /* */ - /* ... */ - /* */ - /* // after this call, `bitmap' no longer points into */ - /* // the `glyphs' array (and the old value isn't destroyed) */ - /* FT_Glyph_To_Bitmap( &bitmap, FT_RENDER_MODE_MONO, 0, 0 ); */ - /* */ - /* ... */ - /* */ - /* FT_Done_Glyph( bitmap ); */ - /* } */ - /* */ - /* ... */ - /* */ - /* for ( idx = 0; i < MAX_GLYPHS; i++ ) */ - /* FT_Done_Glyph( glyphs[idx] ); */ - /* } */ - /* */ - FT_EXPORT( FT_Error ) - FT_Glyph_To_Bitmap( FT_Glyph* the_glyph, - FT_Render_Mode render_mode, - FT_Vector* origin, - FT_Bool destroy ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Glyph */ - /* */ - /* <Description> */ - /* Destroy a given glyph. */ - /* */ - /* <Input> */ - /* glyph :: A handle to the target glyph object. */ - /* */ - FT_EXPORT( void ) - FT_Done_Glyph( FT_Glyph glyph ); - - /* */ - - - /* other helpful functions */ - - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Matrix_Multiply */ - /* */ - /* <Description> */ - /* Perform the matrix operation `b = a*b'. */ - /* */ - /* <Input> */ - /* a :: A pointer to matrix `a'. */ - /* */ - /* <InOut> */ - /* b :: A pointer to matrix `b'. */ - /* */ - /* <Note> */ - /* The result is undefined if either `a' or `b' is zero. */ - /* */ - FT_EXPORT( void ) - FT_Matrix_Multiply( const FT_Matrix* a, - FT_Matrix* b ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Matrix_Invert */ - /* */ - /* <Description> */ - /* Invert a 2x2 matrix. Return an error if it can't be inverted. */ - /* */ - /* <InOut> */ - /* matrix :: A pointer to the target matrix. Remains untouched in */ - /* case of error. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Matrix_Invert( FT_Matrix* matrix ); - - /* */ - - -FT_END_HEADER - -#endif /* FTGLYPH_H_ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/android/armeabi/include/freetype/ftgxval.h b/android/armeabi/include/freetype/ftgxval.h deleted file mode 100644 index a58e86a0..00000000 --- a/android/armeabi/include/freetype/ftgxval.h +++ /dev/null @@ -1,357 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftgxval.h */ -/* */ -/* FreeType API for validating TrueTypeGX/AAT tables (specification). */ -/* */ -/* Copyright 2004-2016 by */ -/* Masatake YAMATO, Redhat K.K, */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - -/***************************************************************************/ -/* */ -/* gxvalid is derived from both gxlayout module and otvalid module. */ -/* Development of gxlayout is supported by the Information-technology */ -/* Promotion Agency(IPA), Japan. */ -/* */ -/***************************************************************************/ - - -#ifndef FTGXVAL_H_ -#define FTGXVAL_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* gx_validation */ - /* */ - /* <Title> */ - /* TrueTypeGX/AAT Validation */ - /* */ - /* <Abstract> */ - /* An API to validate TrueTypeGX/AAT tables. */ - /* */ - /* <Description> */ - /* This section contains the declaration of functions to validate */ - /* some TrueTypeGX tables (feat, mort, morx, bsln, just, kern, opbd, */ - /* trak, prop, lcar). */ - /* */ - /* <Order> */ - /* FT_TrueTypeGX_Validate */ - /* FT_TrueTypeGX_Free */ - /* */ - /* FT_ClassicKern_Validate */ - /* FT_ClassicKern_Free */ - /* */ - /* FT_VALIDATE_GX_LENGTH */ - /* FT_VALIDATE_GXXXX */ - /* FT_VALIDATE_CKERNXXX */ - /* */ - /*************************************************************************/ - - /*************************************************************************/ - /* */ - /* */ - /* Warning: Use FT_VALIDATE_XXX to validate a table. */ - /* Following definitions are for gxvalid developers. */ - /* */ - /* */ - /*************************************************************************/ - -#define FT_VALIDATE_feat_INDEX 0 -#define FT_VALIDATE_mort_INDEX 1 -#define FT_VALIDATE_morx_INDEX 2 -#define FT_VALIDATE_bsln_INDEX 3 -#define FT_VALIDATE_just_INDEX 4 -#define FT_VALIDATE_kern_INDEX 5 -#define FT_VALIDATE_opbd_INDEX 6 -#define FT_VALIDATE_trak_INDEX 7 -#define FT_VALIDATE_prop_INDEX 8 -#define FT_VALIDATE_lcar_INDEX 9 -#define FT_VALIDATE_GX_LAST_INDEX FT_VALIDATE_lcar_INDEX - - - /************************************************************************* - * - * @macro: - * FT_VALIDATE_GX_LENGTH - * - * @description: - * The number of tables checked in this module. Use it as a parameter - * for the `table-length' argument of function @FT_TrueTypeGX_Validate. - */ -#define FT_VALIDATE_GX_LENGTH (FT_VALIDATE_GX_LAST_INDEX + 1) - - /* */ - - /* Up to 0x1000 is used by otvalid. - Ox2xxx is reserved for feature OT extension. */ -#define FT_VALIDATE_GX_START 0x4000 -#define FT_VALIDATE_GX_BITFIELD( tag ) \ - ( FT_VALIDATE_GX_START << FT_VALIDATE_##tag##_INDEX ) - - - /********************************************************************** - * - * @enum: - * FT_VALIDATE_GXXXX - * - * @description: - * A list of bit-field constants used with @FT_TrueTypeGX_Validate to - * indicate which TrueTypeGX/AAT Type tables should be validated. - * - * @values: - * FT_VALIDATE_feat :: - * Validate `feat' table. - * - * FT_VALIDATE_mort :: - * Validate `mort' table. - * - * FT_VALIDATE_morx :: - * Validate `morx' table. - * - * FT_VALIDATE_bsln :: - * Validate `bsln' table. - * - * FT_VALIDATE_just :: - * Validate `just' table. - * - * FT_VALIDATE_kern :: - * Validate `kern' table. - * - * FT_VALIDATE_opbd :: - * Validate `opbd' table. - * - * FT_VALIDATE_trak :: - * Validate `trak' table. - * - * FT_VALIDATE_prop :: - * Validate `prop' table. - * - * FT_VALIDATE_lcar :: - * Validate `lcar' table. - * - * FT_VALIDATE_GX :: - * Validate all TrueTypeGX tables (feat, mort, morx, bsln, just, kern, - * opbd, trak, prop and lcar). - * - */ - -#define FT_VALIDATE_feat FT_VALIDATE_GX_BITFIELD( feat ) -#define FT_VALIDATE_mort FT_VALIDATE_GX_BITFIELD( mort ) -#define FT_VALIDATE_morx FT_VALIDATE_GX_BITFIELD( morx ) -#define FT_VALIDATE_bsln FT_VALIDATE_GX_BITFIELD( bsln ) -#define FT_VALIDATE_just FT_VALIDATE_GX_BITFIELD( just ) -#define FT_VALIDATE_kern FT_VALIDATE_GX_BITFIELD( kern ) -#define FT_VALIDATE_opbd FT_VALIDATE_GX_BITFIELD( opbd ) -#define FT_VALIDATE_trak FT_VALIDATE_GX_BITFIELD( trak ) -#define FT_VALIDATE_prop FT_VALIDATE_GX_BITFIELD( prop ) -#define FT_VALIDATE_lcar FT_VALIDATE_GX_BITFIELD( lcar ) - -#define FT_VALIDATE_GX ( FT_VALIDATE_feat | \ - FT_VALIDATE_mort | \ - FT_VALIDATE_morx | \ - FT_VALIDATE_bsln | \ - FT_VALIDATE_just | \ - FT_VALIDATE_kern | \ - FT_VALIDATE_opbd | \ - FT_VALIDATE_trak | \ - FT_VALIDATE_prop | \ - FT_VALIDATE_lcar ) - - - /********************************************************************** - * - * @function: - * FT_TrueTypeGX_Validate - * - * @description: - * Validate various TrueTypeGX tables to assure that all offsets and - * indices are valid. The idea is that a higher-level library that - * actually does the text layout can access those tables without - * error checking (which can be quite time consuming). - * - * @input: - * face :: - * A handle to the input face. - * - * validation_flags :: - * A bit field that specifies the tables to be validated. See - * @FT_VALIDATE_GXXXX for possible values. - * - * table_length :: - * The size of the `tables' array. Normally, @FT_VALIDATE_GX_LENGTH - * should be passed. - * - * @output: - * tables :: - * The array where all validated sfnt tables are stored. - * The array itself must be allocated by a client. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with TrueTypeGX fonts, returning an error - * otherwise. - * - * After use, the application should deallocate the buffers pointed to by - * each `tables' element, by calling @FT_TrueTypeGX_Free. A NULL value - * indicates that the table either doesn't exist in the font, the - * application hasn't asked for validation, or the validator doesn't have - * the ability to validate the sfnt table. - */ - FT_EXPORT( FT_Error ) - FT_TrueTypeGX_Validate( FT_Face face, - FT_UInt validation_flags, - FT_Bytes tables[FT_VALIDATE_GX_LENGTH], - FT_UInt table_length ); - - - /********************************************************************** - * - * @function: - * FT_TrueTypeGX_Free - * - * @description: - * Free the buffer allocated by TrueTypeGX validator. - * - * @input: - * face :: - * A handle to the input face. - * - * table :: - * The pointer to the buffer allocated by - * @FT_TrueTypeGX_Validate. - * - * @note: - * This function must be used to free the buffer allocated by - * @FT_TrueTypeGX_Validate only. - */ - FT_EXPORT( void ) - FT_TrueTypeGX_Free( FT_Face face, - FT_Bytes table ); - - - /********************************************************************** - * - * @enum: - * FT_VALIDATE_CKERNXXX - * - * @description: - * A list of bit-field constants used with @FT_ClassicKern_Validate - * to indicate the classic kern dialect or dialects. If the selected - * type doesn't fit, @FT_ClassicKern_Validate regards the table as - * invalid. - * - * @values: - * FT_VALIDATE_MS :: - * Handle the `kern' table as a classic Microsoft kern table. - * - * FT_VALIDATE_APPLE :: - * Handle the `kern' table as a classic Apple kern table. - * - * FT_VALIDATE_CKERN :: - * Handle the `kern' as either classic Apple or Microsoft kern table. - */ -#define FT_VALIDATE_MS ( FT_VALIDATE_GX_START << 0 ) -#define FT_VALIDATE_APPLE ( FT_VALIDATE_GX_START << 1 ) - -#define FT_VALIDATE_CKERN ( FT_VALIDATE_MS | FT_VALIDATE_APPLE ) - - - /********************************************************************** - * - * @function: - * FT_ClassicKern_Validate - * - * @description: - * Validate classic (16-bit format) kern table to assure that the offsets - * and indices are valid. The idea is that a higher-level library that - * actually does the text layout can access those tables without error - * checking (which can be quite time consuming). - * - * The `kern' table validator in @FT_TrueTypeGX_Validate deals with both - * the new 32-bit format and the classic 16-bit format, while - * FT_ClassicKern_Validate only supports the classic 16-bit format. - * - * @input: - * face :: - * A handle to the input face. - * - * validation_flags :: - * A bit field that specifies the dialect to be validated. See - * @FT_VALIDATE_CKERNXXX for possible values. - * - * @output: - * ckern_table :: - * A pointer to the kern table. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * After use, the application should deallocate the buffers pointed to by - * `ckern_table', by calling @FT_ClassicKern_Free. A NULL value - * indicates that the table doesn't exist in the font. - */ - FT_EXPORT( FT_Error ) - FT_ClassicKern_Validate( FT_Face face, - FT_UInt validation_flags, - FT_Bytes *ckern_table ); - - - /********************************************************************** - * - * @function: - * FT_ClassicKern_Free - * - * @description: - * Free the buffer allocated by classic Kern validator. - * - * @input: - * face :: - * A handle to the input face. - * - * table :: - * The pointer to the buffer that is allocated by - * @FT_ClassicKern_Validate. - * - * @note: - * This function must be used to free the buffer allocated by - * @FT_ClassicKern_Validate only. - */ - FT_EXPORT( void ) - FT_ClassicKern_Free( FT_Face face, - FT_Bytes table ); - - /* */ - - -FT_END_HEADER - -#endif /* FTGXVAL_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftgzip.h b/android/armeabi/include/freetype/ftgzip.h deleted file mode 100644 index 9e658b0d..00000000 --- a/android/armeabi/include/freetype/ftgzip.h +++ /dev/null @@ -1,148 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftgzip.h */ -/* */ -/* Gzip-compressed stream support. */ -/* */ -/* Copyright 2002-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTGZIP_H_ -#define FTGZIP_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************/ - /* */ - /* <Section> */ - /* gzip */ - /* */ - /* <Title> */ - /* GZIP Streams */ - /* */ - /* <Abstract> */ - /* Using gzip-compressed font files. */ - /* */ - /* <Description> */ - /* This section contains the declaration of Gzip-specific functions. */ - /* */ - /*************************************************************************/ - - - /************************************************************************ - * - * @function: - * FT_Stream_OpenGzip - * - * @description: - * Open a new stream to parse gzip-compressed font files. This is - * mainly used to support the compressed `*.pcf.gz' fonts that come - * with XFree86. - * - * @input: - * stream :: - * The target embedding stream. - * - * source :: - * The source stream. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source stream must be opened _before_ calling this function. - * - * Calling the internal function `FT_Stream_Close' on the new stream will - * *not* call `FT_Stream_Close' on the source stream. None of the stream - * objects will be released to the heap. - * - * The stream implementation is very basic and resets the decompression - * process each time seeking backwards is needed within the stream. - * - * In certain builds of the library, gzip compression recognition is - * automatically handled when calling @FT_New_Face or @FT_Open_Face. - * This means that if no font driver is capable of handling the raw - * compressed file, the library will try to open a gzipped stream from - * it and re-open the face with it. - * - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with zlib support. - */ - FT_EXPORT( FT_Error ) - FT_Stream_OpenGzip( FT_Stream stream, - FT_Stream source ); - - - /************************************************************************ - * - * @function: - * FT_Gzip_Uncompress - * - * @description: - * Decompress a zipped input buffer into an output buffer. This function - * is modeled after zlib's `uncompress' function. - * - * @input: - * memory :: - * A FreeType memory handle. - * - * input :: - * The input buffer. - * - * input_len :: - * The length of the input buffer. - * - * @output: - * output:: - * The output buffer. - * - * @inout: - * output_len :: - * Before calling the function, this is the the total size of the - * output buffer, which must be large enough to hold the entire - * uncompressed data (so the size of the uncompressed data must be - * known in advance). After calling the function, `output_len' is the - * size of the used data in `output'. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with zlib support. - */ - FT_EXPORT( FT_Error ) - FT_Gzip_Uncompress( FT_Memory memory, - FT_Byte* output, - FT_ULong* output_len, - const FT_Byte* input, - FT_ULong input_len ); - - /* */ - - -FT_END_HEADER - -#endif /* FTGZIP_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftimage.h b/android/armeabi/include/freetype/ftimage.h deleted file mode 100644 index 1d557c93..00000000 --- a/android/armeabi/include/freetype/ftimage.h +++ /dev/null @@ -1,1214 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftimage.h */ -/* */ -/* FreeType glyph image formats and default raster interface */ -/* (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - /*************************************************************************/ - /* */ - /* Note: A `raster' is simply a scan-line converter, used to render */ - /* FT_Outlines into FT_Bitmaps. */ - /* */ - /*************************************************************************/ - - -#ifndef FTIMAGE_H_ -#define FTIMAGE_H_ - - - /* STANDALONE_ is from ftgrays.c */ -#ifndef STANDALONE_ -#include <ft2build.h> -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Pos */ - /* */ - /* <Description> */ - /* The type FT_Pos is used to store vectorial coordinates. Depending */ - /* on the context, these can represent distances in integer font */ - /* units, or 16.16, or 26.6 fixed-point pixel coordinates. */ - /* */ - typedef signed long FT_Pos; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Vector */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2D vector; coordinates are of */ - /* the FT_Pos type. */ - /* */ - /* <Fields> */ - /* x :: The horizontal coordinate. */ - /* y :: The vertical coordinate. */ - /* */ - typedef struct FT_Vector_ - { - FT_Pos x; - FT_Pos y; - - } FT_Vector; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_BBox */ - /* */ - /* <Description> */ - /* A structure used to hold an outline's bounding box, i.e., the */ - /* coordinates of its extrema in the horizontal and vertical */ - /* directions. */ - /* */ - /* <Fields> */ - /* xMin :: The horizontal minimum (left-most). */ - /* */ - /* yMin :: The vertical minimum (bottom-most). */ - /* */ - /* xMax :: The horizontal maximum (right-most). */ - /* */ - /* yMax :: The vertical maximum (top-most). */ - /* */ - /* <Note> */ - /* The bounding box is specified with the coordinates of the lower */ - /* left and the upper right corner. In PostScript, those values are */ - /* often called (llx,lly) and (urx,ury), respectively. */ - /* */ - /* If `yMin' is negative, this value gives the glyph's descender. */ - /* Otherwise, the glyph doesn't descend below the baseline. */ - /* Similarly, if `ymax' is positive, this value gives the glyph's */ - /* ascender. */ - /* */ - /* `xMin' gives the horizontal distance from the glyph's origin to */ - /* the left edge of the glyph's bounding box. If `xMin' is negative, */ - /* the glyph extends to the left of the origin. */ - /* */ - typedef struct FT_BBox_ - { - FT_Pos xMin, yMin; - FT_Pos xMax, yMax; - - } FT_BBox; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Pixel_Mode */ - /* */ - /* <Description> */ - /* An enumeration type used to describe the format of pixels in a */ - /* given bitmap. Note that additional formats may be added in the */ - /* future. */ - /* */ - /* <Values> */ - /* FT_PIXEL_MODE_NONE :: */ - /* Value~0 is reserved. */ - /* */ - /* FT_PIXEL_MODE_MONO :: */ - /* A monochrome bitmap, using 1~bit per pixel. Note that pixels */ - /* are stored in most-significant order (MSB), which means that */ - /* the left-most pixel in a byte has value 128. */ - /* */ - /* FT_PIXEL_MODE_GRAY :: */ - /* An 8-bit bitmap, generally used to represent anti-aliased glyph */ - /* images. Each pixel is stored in one byte. Note that the number */ - /* of `gray' levels is stored in the `num_grays' field of the */ - /* @FT_Bitmap structure (it generally is 256). */ - /* */ - /* FT_PIXEL_MODE_GRAY2 :: */ - /* A 2-bit per pixel bitmap, used to represent embedded */ - /* anti-aliased bitmaps in font files according to the OpenType */ - /* specification. We haven't found a single font using this */ - /* format, however. */ - /* */ - /* FT_PIXEL_MODE_GRAY4 :: */ - /* A 4-bit per pixel bitmap, representing embedded anti-aliased */ - /* bitmaps in font files according to the OpenType specification. */ - /* We haven't found a single font using this format, however. */ - /* */ - /* FT_PIXEL_MODE_LCD :: */ - /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ - /* used for display on LCD displays; the bitmap is three times */ - /* wider than the original glyph image. See also */ - /* @FT_RENDER_MODE_LCD. */ - /* */ - /* FT_PIXEL_MODE_LCD_V :: */ - /* An 8-bit bitmap, representing RGB or BGR decimated glyph images */ - /* used for display on rotated LCD displays; the bitmap is three */ - /* times taller than the original glyph image. See also */ - /* @FT_RENDER_MODE_LCD_V. */ - /* */ - /* FT_PIXEL_MODE_BGRA :: */ - /* An image with four 8-bit channels per pixel, representing a */ - /* color image (such as emoticons) with alpha channel. For each */ - /* pixel, the format is BGRA, which means, the blue channel comes */ - /* first in memory. The color channels are pre-multiplied and in */ - /* the sRGB colorspace. For example, full red at half-translucent */ - /* opacity will be represented as `00,00,80,80', not `00,00,FF,80'. */ - /* See also @FT_LOAD_COLOR. */ - /* */ - typedef enum FT_Pixel_Mode_ - { - FT_PIXEL_MODE_NONE = 0, - FT_PIXEL_MODE_MONO, - FT_PIXEL_MODE_GRAY, - FT_PIXEL_MODE_GRAY2, - FT_PIXEL_MODE_GRAY4, - FT_PIXEL_MODE_LCD, - FT_PIXEL_MODE_LCD_V, - FT_PIXEL_MODE_BGRA, - - FT_PIXEL_MODE_MAX /* do not remove */ - - } FT_Pixel_Mode; - - - /* these constants are deprecated; use the corresponding `FT_Pixel_Mode' */ - /* values instead. */ -#define ft_pixel_mode_none FT_PIXEL_MODE_NONE -#define ft_pixel_mode_mono FT_PIXEL_MODE_MONO -#define ft_pixel_mode_grays FT_PIXEL_MODE_GRAY -#define ft_pixel_mode_pal2 FT_PIXEL_MODE_GRAY2 -#define ft_pixel_mode_pal4 FT_PIXEL_MODE_GRAY4 - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Bitmap */ - /* */ - /* <Description> */ - /* A structure used to describe a bitmap or pixmap to the raster. */ - /* Note that we now manage pixmaps of various depths through the */ - /* `pixel_mode' field. */ - /* */ - /* <Fields> */ - /* rows :: The number of bitmap rows. */ - /* */ - /* width :: The number of pixels in bitmap row. */ - /* */ - /* pitch :: The pitch's absolute value is the number of bytes */ - /* taken by one bitmap row, including padding. */ - /* However, the pitch is positive when the bitmap has */ - /* a `down' flow, and negative when it has an `up' */ - /* flow. In all cases, the pitch is an offset to add */ - /* to a bitmap pointer in order to go down one row. */ - /* */ - /* Note that `padding' means the alignment of a */ - /* bitmap to a byte border, and FreeType functions */ - /* normally align to the smallest possible integer */ - /* value. */ - /* */ - /* For the B/W rasterizer, `pitch' is always an even */ - /* number. */ - /* */ - /* To change the pitch of a bitmap (say, to make it a */ - /* multiple of 4), use @FT_Bitmap_Convert. */ - /* Alternatively, you might use callback functions to */ - /* directly render to the application's surface; see */ - /* the file `example2.cpp' in the tutorial for a */ - /* demonstration. */ - /* */ - /* buffer :: A typeless pointer to the bitmap buffer. This */ - /* value should be aligned on 32-bit boundaries in */ - /* most cases. */ - /* */ - /* num_grays :: This field is only used with */ - /* @FT_PIXEL_MODE_GRAY; it gives the number of gray */ - /* levels used in the bitmap. */ - /* */ - /* pixel_mode :: The pixel mode, i.e., how pixel bits are stored. */ - /* See @FT_Pixel_Mode for possible values. */ - /* */ - /* palette_mode :: This field is intended for paletted pixel modes; */ - /* it indicates how the palette is stored. Not */ - /* used currently. */ - /* */ - /* palette :: A typeless pointer to the bitmap palette; this */ - /* field is intended for paletted pixel modes. Not */ - /* used currently. */ - /* */ - typedef struct FT_Bitmap_ - { - unsigned int rows; - unsigned int width; - int pitch; - unsigned char* buffer; - unsigned short num_grays; - unsigned char pixel_mode; - unsigned char palette_mode; - void* palette; - - } FT_Bitmap; - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Outline */ - /* */ - /* <Description> */ - /* This structure is used to describe an outline to the scan-line */ - /* converter. */ - /* */ - /* <Fields> */ - /* n_contours :: The number of contours in the outline. */ - /* */ - /* n_points :: The number of points in the outline. */ - /* */ - /* points :: A pointer to an array of `n_points' @FT_Vector */ - /* elements, giving the outline's point coordinates. */ - /* */ - /* tags :: A pointer to an array of `n_points' chars, giving */ - /* each outline point's type. */ - /* */ - /* If bit~0 is unset, the point is `off' the curve, */ - /* i.e., a Bézier control point, while it is `on' if */ - /* set. */ - /* */ - /* Bit~1 is meaningful for `off' points only. If set, */ - /* it indicates a third-order Bézier arc control point; */ - /* and a second-order control point if unset. */ - /* */ - /* If bit~2 is set, bits 5-7 contain the drop-out mode */ - /* (as defined in the OpenType specification; the value */ - /* is the same as the argument to the SCANMODE */ - /* instruction). */ - /* */ - /* Bits 3 and~4 are reserved for internal purposes. */ - /* */ - /* contours :: An array of `n_contours' shorts, giving the end */ - /* point of each contour within the outline. For */ - /* example, the first contour is defined by the points */ - /* `0' to `contours[0]', the second one is defined by */ - /* the points `contours[0]+1' to `contours[1]', etc. */ - /* */ - /* flags :: A set of bit flags used to characterize the outline */ - /* and give hints to the scan-converter and hinter on */ - /* how to convert/grid-fit it. See @FT_OUTLINE_XXX. */ - /* */ - /* <Note> */ - /* The B/W rasterizer only checks bit~2 in the `tags' array for the */ - /* first point of each contour. The drop-out mode as given with */ - /* @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, and */ - /* @FT_OUTLINE_INCLUDE_STUBS in `flags' is then overridden. */ - /* */ - typedef struct FT_Outline_ - { - short n_contours; /* number of contours in glyph */ - short n_points; /* number of points in the glyph */ - - FT_Vector* points; /* the outline's points */ - char* tags; /* the points flags */ - short* contours; /* the contour end points */ - - int flags; /* outline masks */ - - } FT_Outline; - - /* */ - - /* Following limits must be consistent with */ - /* FT_Outline.{n_contours,n_points} */ -#define FT_OUTLINE_CONTOURS_MAX SHRT_MAX -#define FT_OUTLINE_POINTS_MAX SHRT_MAX - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_OUTLINE_XXX */ - /* */ - /* <Description> */ - /* A list of bit-field constants use for the flags in an outline's */ - /* `flags' field. */ - /* */ - /* <Values> */ - /* FT_OUTLINE_NONE :: */ - /* Value~0 is reserved. */ - /* */ - /* FT_OUTLINE_OWNER :: */ - /* If set, this flag indicates that the outline's field arrays */ - /* (i.e., `points', `flags', and `contours') are `owned' by the */ - /* outline object, and should thus be freed when it is destroyed. */ - /* */ - /* FT_OUTLINE_EVEN_ODD_FILL :: */ - /* By default, outlines are filled using the non-zero winding rule. */ - /* If set to 1, the outline will be filled using the even-odd fill */ - /* rule (only works with the smooth rasterizer). */ - /* */ - /* FT_OUTLINE_REVERSE_FILL :: */ - /* By default, outside contours of an outline are oriented in */ - /* clock-wise direction, as defined in the TrueType specification. */ - /* This flag is set if the outline uses the opposite direction */ - /* (typically for Type~1 fonts). This flag is ignored by the scan */ - /* converter. */ - /* */ - /* FT_OUTLINE_IGNORE_DROPOUTS :: */ - /* By default, the scan converter will try to detect drop-outs in */ - /* an outline and correct the glyph bitmap to ensure consistent */ - /* shape continuity. If set, this flag hints the scan-line */ - /* converter to ignore such cases. See below for more information. */ - /* */ - /* FT_OUTLINE_SMART_DROPOUTS :: */ - /* Select smart dropout control. If unset, use simple dropout */ - /* control. Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See */ - /* below for more information. */ - /* */ - /* FT_OUTLINE_INCLUDE_STUBS :: */ - /* If set, turn pixels on for `stubs', otherwise exclude them. */ - /* Ignored if @FT_OUTLINE_IGNORE_DROPOUTS is set. See below for */ - /* more information. */ - /* */ - /* FT_OUTLINE_HIGH_PRECISION :: */ - /* This flag indicates that the scan-line converter should try to */ - /* convert this outline to bitmaps with the highest possible */ - /* quality. It is typically set for small character sizes. Note */ - /* that this is only a hint that might be completely ignored by a */ - /* given scan-converter. */ - /* */ - /* FT_OUTLINE_SINGLE_PASS :: */ - /* This flag is set to force a given scan-converter to only use a */ - /* single pass over the outline to render a bitmap glyph image. */ - /* Normally, it is set for very large character sizes. It is only */ - /* a hint that might be completely ignored by a given */ - /* scan-converter. */ - /* */ - /* <Note> */ - /* The flags @FT_OUTLINE_IGNORE_DROPOUTS, @FT_OUTLINE_SMART_DROPOUTS, */ - /* and @FT_OUTLINE_INCLUDE_STUBS are ignored by the smooth */ - /* rasterizer. */ - /* */ - /* There exists a second mechanism to pass the drop-out mode to the */ - /* B/W rasterizer; see the `tags' field in @FT_Outline. */ - /* */ - /* Please refer to the description of the `SCANTYPE' instruction in */ - /* the OpenType specification (in file `ttinst1.doc') how simple */ - /* drop-outs, smart drop-outs, and stubs are defined. */ - /* */ -#define FT_OUTLINE_NONE 0x0 -#define FT_OUTLINE_OWNER 0x1 -#define FT_OUTLINE_EVEN_ODD_FILL 0x2 -#define FT_OUTLINE_REVERSE_FILL 0x4 -#define FT_OUTLINE_IGNORE_DROPOUTS 0x8 -#define FT_OUTLINE_SMART_DROPOUTS 0x10 -#define FT_OUTLINE_INCLUDE_STUBS 0x20 - -#define FT_OUTLINE_HIGH_PRECISION 0x100 -#define FT_OUTLINE_SINGLE_PASS 0x200 - - - /* these constants are deprecated; use the corresponding */ - /* `FT_OUTLINE_XXX' values instead */ -#define ft_outline_none FT_OUTLINE_NONE -#define ft_outline_owner FT_OUTLINE_OWNER -#define ft_outline_even_odd_fill FT_OUTLINE_EVEN_ODD_FILL -#define ft_outline_reverse_fill FT_OUTLINE_REVERSE_FILL -#define ft_outline_ignore_dropouts FT_OUTLINE_IGNORE_DROPOUTS -#define ft_outline_high_precision FT_OUTLINE_HIGH_PRECISION -#define ft_outline_single_pass FT_OUTLINE_SINGLE_PASS - - /* */ - -#define FT_CURVE_TAG( flag ) ( flag & 3 ) - -#define FT_CURVE_TAG_ON 1 -#define FT_CURVE_TAG_CONIC 0 -#define FT_CURVE_TAG_CUBIC 2 - -#define FT_CURVE_TAG_HAS_SCANMODE 4 - -#define FT_CURVE_TAG_TOUCH_X 8 /* reserved for the TrueType hinter */ -#define FT_CURVE_TAG_TOUCH_Y 16 /* reserved for the TrueType hinter */ - -#define FT_CURVE_TAG_TOUCH_BOTH ( FT_CURVE_TAG_TOUCH_X | \ - FT_CURVE_TAG_TOUCH_Y ) - -#define FT_Curve_Tag_On FT_CURVE_TAG_ON -#define FT_Curve_Tag_Conic FT_CURVE_TAG_CONIC -#define FT_Curve_Tag_Cubic FT_CURVE_TAG_CUBIC -#define FT_Curve_Tag_Touch_X FT_CURVE_TAG_TOUCH_X -#define FT_Curve_Tag_Touch_Y FT_CURVE_TAG_TOUCH_Y - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_MoveToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `move */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `move to' is emitted to start a new contour in an outline. */ - /* */ - /* <Input> */ - /* to :: A pointer to the target point of the `move to'. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of the */ - /* decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - typedef int - (*FT_Outline_MoveToFunc)( const FT_Vector* to, - void* user ); - -#define FT_Outline_MoveTo_Func FT_Outline_MoveToFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_LineToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `line */ - /* to' function during outline walking/decomposition. */ - /* */ - /* A `line to' is emitted to indicate a segment in the outline. */ - /* */ - /* <Input> */ - /* to :: A pointer to the target point of the `line to'. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of the */ - /* decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - typedef int - (*FT_Outline_LineToFunc)( const FT_Vector* to, - void* user ); - -#define FT_Outline_LineTo_Func FT_Outline_LineToFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_ConicToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `conic */ - /* to' function during outline walking or decomposition. */ - /* */ - /* A `conic to' is emitted to indicate a second-order Bézier arc in */ - /* the outline. */ - /* */ - /* <Input> */ - /* control :: An intermediate control point between the last position */ - /* and the new target in `to'. */ - /* */ - /* to :: A pointer to the target end point of the conic arc. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of */ - /* the decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - typedef int - (*FT_Outline_ConicToFunc)( const FT_Vector* control, - const FT_Vector* to, - void* user ); - -#define FT_Outline_ConicTo_Func FT_Outline_ConicToFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Outline_CubicToFunc */ - /* */ - /* <Description> */ - /* A function pointer type used to describe the signature of a `cubic */ - /* to' function during outline walking or decomposition. */ - /* */ - /* A `cubic to' is emitted to indicate a third-order Bézier arc. */ - /* */ - /* <Input> */ - /* control1 :: A pointer to the first Bézier control point. */ - /* */ - /* control2 :: A pointer to the second Bézier control point. */ - /* */ - /* to :: A pointer to the target end point. */ - /* */ - /* user :: A typeless pointer, which is passed from the caller of */ - /* the decomposition function. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - typedef int - (*FT_Outline_CubicToFunc)( const FT_Vector* control1, - const FT_Vector* control2, - const FT_Vector* to, - void* user ); - -#define FT_Outline_CubicTo_Func FT_Outline_CubicToFunc - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Outline_Funcs */ - /* */ - /* <Description> */ - /* A structure to hold various function pointers used during outline */ - /* decomposition in order to emit segments, conic, and cubic Béziers. */ - /* */ - /* <Fields> */ - /* move_to :: The `move to' emitter. */ - /* */ - /* line_to :: The segment emitter. */ - /* */ - /* conic_to :: The second-order Bézier arc emitter. */ - /* */ - /* cubic_to :: The third-order Bézier arc emitter. */ - /* */ - /* shift :: The shift that is applied to coordinates before they */ - /* are sent to the emitter. */ - /* */ - /* delta :: The delta that is applied to coordinates before they */ - /* are sent to the emitter, but after the shift. */ - /* */ - /* <Note> */ - /* The point coordinates sent to the emitters are the transformed */ - /* version of the original coordinates (this is important for high */ - /* accuracy during scan-conversion). The transformation is simple: */ - /* */ - /* { */ - /* x' = (x << shift) - delta */ - /* y' = (x << shift) - delta */ - /* } */ - /* */ - /* Set the values of `shift' and `delta' to~0 to get the original */ - /* point coordinates. */ - /* */ - typedef struct FT_Outline_Funcs_ - { - FT_Outline_MoveToFunc move_to; - FT_Outline_LineToFunc line_to; - FT_Outline_ConicToFunc conic_to; - FT_Outline_CubicToFunc cubic_to; - - int shift; - FT_Pos delta; - - } FT_Outline_Funcs; - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_IMAGE_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags to an unsigned long type. */ - /* */ - /* <Note> */ - /* Since many 16-bit compilers don't like 32-bit enumerations, you */ - /* should redefine this macro in case of problems to something like */ - /* this: */ - /* */ - /* { */ - /* #define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) value */ - /* } */ - /* */ - /* to get a simple enumeration without assigning special numbers. */ - /* */ -#ifndef FT_IMAGE_TAG -#define FT_IMAGE_TAG( value, _x1, _x2, _x3, _x4 ) \ - value = ( ( (unsigned long)_x1 << 24 ) | \ - ( (unsigned long)_x2 << 16 ) | \ - ( (unsigned long)_x3 << 8 ) | \ - (unsigned long)_x4 ) -#endif /* FT_IMAGE_TAG */ - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Glyph_Format */ - /* */ - /* <Description> */ - /* An enumeration type used to describe the format of a given glyph */ - /* image. Note that this version of FreeType only supports two image */ - /* formats, even though future font drivers will be able to register */ - /* their own format. */ - /* */ - /* <Values> */ - /* FT_GLYPH_FORMAT_NONE :: */ - /* The value~0 is reserved. */ - /* */ - /* FT_GLYPH_FORMAT_COMPOSITE :: */ - /* The glyph image is a composite of several other images. This */ - /* format is _only_ used with @FT_LOAD_NO_RECURSE, and is used to */ - /* report compound glyphs (like accented characters). */ - /* */ - /* FT_GLYPH_FORMAT_BITMAP :: */ - /* The glyph image is a bitmap, and can be described as an */ - /* @FT_Bitmap. You generally need to access the `bitmap' field of */ - /* the @FT_GlyphSlotRec structure to read it. */ - /* */ - /* FT_GLYPH_FORMAT_OUTLINE :: */ - /* The glyph image is a vectorial outline made of line segments */ - /* and Bézier arcs; it can be described as an @FT_Outline; you */ - /* generally want to access the `outline' field of the */ - /* @FT_GlyphSlotRec structure to read it. */ - /* */ - /* FT_GLYPH_FORMAT_PLOTTER :: */ - /* The glyph image is a vectorial path with no inside and outside */ - /* contours. Some Type~1 fonts, like those in the Hershey family, */ - /* contain glyphs in this format. These are described as */ - /* @FT_Outline, but FreeType isn't currently capable of rendering */ - /* them correctly. */ - /* */ - typedef enum FT_Glyph_Format_ - { - FT_IMAGE_TAG( FT_GLYPH_FORMAT_NONE, 0, 0, 0, 0 ), - - FT_IMAGE_TAG( FT_GLYPH_FORMAT_COMPOSITE, 'c', 'o', 'm', 'p' ), - FT_IMAGE_TAG( FT_GLYPH_FORMAT_BITMAP, 'b', 'i', 't', 's' ), - FT_IMAGE_TAG( FT_GLYPH_FORMAT_OUTLINE, 'o', 'u', 't', 'l' ), - FT_IMAGE_TAG( FT_GLYPH_FORMAT_PLOTTER, 'p', 'l', 'o', 't' ) - - } FT_Glyph_Format; - - - /* these constants are deprecated; use the corresponding */ - /* `FT_Glyph_Format' values instead. */ -#define ft_glyph_format_none FT_GLYPH_FORMAT_NONE -#define ft_glyph_format_composite FT_GLYPH_FORMAT_COMPOSITE -#define ft_glyph_format_bitmap FT_GLYPH_FORMAT_BITMAP -#define ft_glyph_format_outline FT_GLYPH_FORMAT_OUTLINE -#define ft_glyph_format_plotter FT_GLYPH_FORMAT_PLOTTER - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /***** *****/ - /***** R A S T E R D E F I N I T I O N S *****/ - /***** *****/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* A raster is a scan converter, in charge of rendering an outline into */ - /* a a bitmap. This section contains the public API for rasters. */ - /* */ - /* Note that in FreeType 2, all rasters are now encapsulated within */ - /* specific modules called `renderers'. See `ftrender.h' for more */ - /* details on renderers. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* raster */ - /* */ - /* <Title> */ - /* Scanline Converter */ - /* */ - /* <Abstract> */ - /* How vectorial outlines are converted into bitmaps and pixmaps. */ - /* */ - /* <Description> */ - /* This section contains technical definitions. */ - /* */ - /* <Order> */ - /* FT_Raster */ - /* FT_Span */ - /* FT_SpanFunc */ - /* */ - /* FT_Raster_Params */ - /* FT_RASTER_FLAG_XXX */ - /* */ - /* FT_Raster_NewFunc */ - /* FT_Raster_DoneFunc */ - /* FT_Raster_ResetFunc */ - /* FT_Raster_SetModeFunc */ - /* FT_Raster_RenderFunc */ - /* FT_Raster_Funcs */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Raster */ - /* */ - /* <Description> */ - /* An opaque handle (pointer) to a raster object. Each object can be */ - /* used independently to convert an outline into a bitmap or pixmap. */ - /* */ - typedef struct FT_RasterRec_* FT_Raster; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Span */ - /* */ - /* <Description> */ - /* A structure used to model a single span of gray pixels when */ - /* rendering an anti-aliased bitmap. */ - /* */ - /* <Fields> */ - /* x :: The span's horizontal start position. */ - /* */ - /* len :: The span's length in pixels. */ - /* */ - /* coverage :: The span color/coverage, ranging from 0 (background) */ - /* to 255 (foreground). */ - /* */ - /* <Note> */ - /* This structure is used by the span drawing callback type named */ - /* @FT_SpanFunc that takes the y~coordinate of the span as a */ - /* parameter. */ - /* */ - /* The coverage value is always between 0 and 255. If you want less */ - /* gray values, the callback function has to reduce them. */ - /* */ - typedef struct FT_Span_ - { - short x; - unsigned short len; - unsigned char coverage; - - } FT_Span; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_SpanFunc */ - /* */ - /* <Description> */ - /* A function used as a call-back by the anti-aliased renderer in */ - /* order to let client applications draw themselves the gray pixel */ - /* spans on each scan line. */ - /* */ - /* <Input> */ - /* y :: The scanline's y~coordinate. */ - /* */ - /* count :: The number of spans to draw on this scanline. */ - /* */ - /* spans :: A table of `count' spans to draw on the scanline. */ - /* */ - /* user :: User-supplied data that is passed to the callback. */ - /* */ - /* <Note> */ - /* This callback allows client applications to directly render the */ - /* gray spans of the anti-aliased bitmap to any kind of surfaces. */ - /* */ - /* This can be used to write anti-aliased outlines directly to a */ - /* given background bitmap, and even perform translucency. */ - /* */ - /* Note that the `count' field cannot be greater than a fixed value */ - /* defined by the `FT_MAX_GRAY_SPANS' configuration macro in */ - /* `ftoption.h'. By default, this value is set to~32, which means */ - /* that if there are more than 32~spans on a given scanline, the */ - /* callback is called several times with the same `y' parameter in */ - /* order to draw all callbacks. */ - /* */ - /* Otherwise, the callback is only called once per scan-line, and */ - /* only for those scanlines that do have `gray' pixels on them. */ - /* */ - typedef void - (*FT_SpanFunc)( int y, - int count, - const FT_Span* spans, - void* user ); - -#define FT_Raster_Span_Func FT_SpanFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_BitTest_Func */ - /* */ - /* <Description> */ - /* Deprecated, unimplemented. */ - /* */ - typedef int - (*FT_Raster_BitTest_Func)( int y, - int x, - void* user ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_BitSet_Func */ - /* */ - /* <Description> */ - /* Deprecated, unimplemented. */ - /* */ - typedef void - (*FT_Raster_BitSet_Func)( int y, - int x, - void* user ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_RASTER_FLAG_XXX */ - /* */ - /* <Description> */ - /* A list of bit flag constants as used in the `flags' field of a */ - /* @FT_Raster_Params structure. */ - /* */ - /* <Values> */ - /* FT_RASTER_FLAG_DEFAULT :: This value is 0. */ - /* */ - /* FT_RASTER_FLAG_AA :: This flag is set to indicate that an */ - /* anti-aliased glyph image should be */ - /* generated. Otherwise, it will be */ - /* monochrome (1-bit). */ - /* */ - /* FT_RASTER_FLAG_DIRECT :: This flag is set to indicate direct */ - /* rendering. In this mode, client */ - /* applications must provide their own span */ - /* callback. This lets them directly */ - /* draw or compose over an existing bitmap. */ - /* If this bit is not set, the target */ - /* pixmap's buffer _must_ be zeroed before */ - /* rendering. */ - /* */ - /* Direct rendering is only possible with */ - /* anti-aliased glyphs. */ - /* */ - /* FT_RASTER_FLAG_CLIP :: This flag is only used in direct */ - /* rendering mode. If set, the output will */ - /* be clipped to a box specified in the */ - /* `clip_box' field of the */ - /* @FT_Raster_Params structure. */ - /* */ - /* Note that by default, the glyph bitmap */ - /* is clipped to the target pixmap, except */ - /* in direct rendering mode where all spans */ - /* are generated if no clipping box is set. */ - /* */ -#define FT_RASTER_FLAG_DEFAULT 0x0 -#define FT_RASTER_FLAG_AA 0x1 -#define FT_RASTER_FLAG_DIRECT 0x2 -#define FT_RASTER_FLAG_CLIP 0x4 - - /* these constants are deprecated; use the corresponding */ - /* `FT_RASTER_FLAG_XXX' values instead */ -#define ft_raster_flag_default FT_RASTER_FLAG_DEFAULT -#define ft_raster_flag_aa FT_RASTER_FLAG_AA -#define ft_raster_flag_direct FT_RASTER_FLAG_DIRECT -#define ft_raster_flag_clip FT_RASTER_FLAG_CLIP - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Raster_Params */ - /* */ - /* <Description> */ - /* A structure to hold the arguments used by a raster's render */ - /* function. */ - /* */ - /* <Fields> */ - /* target :: The target bitmap. */ - /* */ - /* source :: A pointer to the source glyph image (e.g., an */ - /* @FT_Outline). */ - /* */ - /* flags :: The rendering flags. */ - /* */ - /* gray_spans :: The gray span drawing callback. */ - /* */ - /* black_spans :: Unused. */ - /* */ - /* bit_test :: Unused. */ - /* */ - /* bit_set :: Unused. */ - /* */ - /* user :: User-supplied data that is passed to each drawing */ - /* callback. */ - /* */ - /* clip_box :: An optional clipping box. It is only used in */ - /* direct rendering mode. Note that coordinates here */ - /* should be expressed in _integer_ pixels (and not in */ - /* 26.6 fixed-point units). */ - /* */ - /* <Note> */ - /* An anti-aliased glyph bitmap is drawn if the @FT_RASTER_FLAG_AA */ - /* bit flag is set in the `flags' field, otherwise a monochrome */ - /* bitmap is generated. */ - /* */ - /* If the @FT_RASTER_FLAG_DIRECT bit flag is set in `flags', the */ - /* raster will call the `gray_spans' callback to draw gray pixel */ - /* spans. This allows direct composition over a pre-existing bitmap */ - /* through user-provided callbacks to perform the span drawing and */ - /* composition. Not supported by the monochrome rasterizer. */ - /* */ - typedef struct FT_Raster_Params_ - { - const FT_Bitmap* target; - const void* source; - int flags; - FT_SpanFunc gray_spans; - FT_SpanFunc black_spans; /* unused */ - FT_Raster_BitTest_Func bit_test; /* unused */ - FT_Raster_BitSet_Func bit_set; /* unused */ - void* user; - FT_BBox clip_box; - - } FT_Raster_Params; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_NewFunc */ - /* */ - /* <Description> */ - /* A function used to create a new raster object. */ - /* */ - /* <Input> */ - /* memory :: A handle to the memory allocator. */ - /* */ - /* <Output> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `memory' parameter is a typeless pointer in order to avoid */ - /* un-wanted dependencies on the rest of the FreeType code. In */ - /* practice, it is an @FT_Memory object, i.e., a handle to the */ - /* standard FreeType memory allocator. However, this field can be */ - /* completely ignored by a given raster implementation. */ - /* */ - typedef int - (*FT_Raster_NewFunc)( void* memory, - FT_Raster* raster ); - -#define FT_Raster_New_Func FT_Raster_NewFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_DoneFunc */ - /* */ - /* <Description> */ - /* A function used to destroy a given raster object. */ - /* */ - /* <Input> */ - /* raster :: A handle to the raster object. */ - /* */ - typedef void - (*FT_Raster_DoneFunc)( FT_Raster raster ); - -#define FT_Raster_Done_Func FT_Raster_DoneFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_ResetFunc */ - /* */ - /* <Description> */ - /* FreeType used to provide an area of memory called the `render */ - /* pool' available to all registered rasters. This was not thread */ - /* safe however and now FreeType never allocates this pool. NULL */ - /* is always passed in as pool_base. */ - /* */ - /* This function is called each time the render pool changes, or just */ - /* after a new raster object is created. */ - /* */ - /* <Input> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* pool_base :: The address in memory of the render pool. */ - /* */ - /* pool_size :: The size in bytes of the render pool. */ - /* */ - /* <Note> */ - /* Rasters should ignore the render pool and rely on dynamic or stack */ - /* allocation if they want to (a handle to the memory allocator is */ - /* passed to the raster constructor). */ - /* */ - typedef void - (*FT_Raster_ResetFunc)( FT_Raster raster, - unsigned char* pool_base, - unsigned long pool_size ); - -#define FT_Raster_Reset_Func FT_Raster_ResetFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_SetModeFunc */ - /* */ - /* <Description> */ - /* This function is a generic facility to change modes or attributes */ - /* in a given raster. This can be used for debugging purposes, or */ - /* simply to allow implementation-specific `features' in a given */ - /* raster module. */ - /* */ - /* <Input> */ - /* raster :: A handle to the new raster object. */ - /* */ - /* mode :: A 4-byte tag used to name the mode or property. */ - /* */ - /* args :: A pointer to the new mode/property to use. */ - /* */ - typedef int - (*FT_Raster_SetModeFunc)( FT_Raster raster, - unsigned long mode, - void* args ); - -#define FT_Raster_Set_Mode_Func FT_Raster_SetModeFunc - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Raster_RenderFunc */ - /* */ - /* <Description> */ - /* Invoke a given raster to scan-convert a given glyph image into a */ - /* target bitmap. */ - /* */ - /* <Input> */ - /* raster :: A handle to the raster object. */ - /* */ - /* params :: A pointer to an @FT_Raster_Params structure used to */ - /* store the rendering parameters. */ - /* */ - /* <Return> */ - /* Error code. 0~means success. */ - /* */ - /* <Note> */ - /* The exact format of the source image depends on the raster's glyph */ - /* format defined in its @FT_Raster_Funcs structure. It can be an */ - /* @FT_Outline or anything else in order to support a large array of */ - /* glyph formats. */ - /* */ - /* Note also that the render function can fail and return a */ - /* `FT_Err_Unimplemented_Feature' error code if the raster used does */ - /* not support direct composition. */ - /* */ - /* XXX: For now, the standard raster doesn't support direct */ - /* composition but this should change for the final release (see */ - /* the files `demos/src/ftgrays.c' and `demos/src/ftgrays2.c' */ - /* for examples of distinct implementations that support direct */ - /* composition). */ - /* */ - typedef int - (*FT_Raster_RenderFunc)( FT_Raster raster, - const FT_Raster_Params* params ); - -#define FT_Raster_Render_Func FT_Raster_RenderFunc - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Raster_Funcs */ - /* */ - /* <Description> */ - /* A structure used to describe a given raster class to the library. */ - /* */ - /* <Fields> */ - /* glyph_format :: The supported glyph format for this raster. */ - /* */ - /* raster_new :: The raster constructor. */ - /* */ - /* raster_reset :: Used to reset the render pool within the raster. */ - /* */ - /* raster_render :: A function to render a glyph into a given bitmap. */ - /* */ - /* raster_done :: The raster destructor. */ - /* */ - typedef struct FT_Raster_Funcs_ - { - FT_Glyph_Format glyph_format; - FT_Raster_NewFunc raster_new; - FT_Raster_ResetFunc raster_reset; - FT_Raster_SetModeFunc raster_set_mode; - FT_Raster_RenderFunc raster_render; - FT_Raster_DoneFunc raster_done; - - } FT_Raster_Funcs; - - /* */ - - -FT_END_HEADER - -#endif /* FTIMAGE_H_ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/android/armeabi/include/freetype/ftincrem.h b/android/armeabi/include/freetype/ftincrem.h deleted file mode 100644 index 46b58b79..00000000 --- a/android/armeabi/include/freetype/ftincrem.h +++ /dev/null @@ -1,354 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftincrem.h */ -/* */ -/* FreeType incremental loading (specification). */ -/* */ -/* Copyright 2002-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTINCREM_H_ -#define FTINCREM_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************** - * - * @section: - * incremental - * - * @title: - * Incremental Loading - * - * @abstract: - * Custom Glyph Loading. - * - * @description: - * This section contains various functions used to perform so-called - * `incremental' glyph loading. This is a mode where all glyphs loaded - * from a given @FT_Face are provided by the client application. - * - * Apart from that, all other tables are loaded normally from the font - * file. This mode is useful when FreeType is used within another - * engine, e.g., a PostScript Imaging Processor. - * - * To enable this mode, you must use @FT_Open_Face, passing an - * @FT_Parameter with the @FT_PARAM_TAG_INCREMENTAL tag and an - * @FT_Incremental_Interface value. See the comments for - * @FT_Incremental_InterfaceRec for an example. - * - */ - - - /*************************************************************************** - * - * @type: - * FT_Incremental - * - * @description: - * An opaque type describing a user-provided object used to implement - * `incremental' glyph loading within FreeType. This is used to support - * embedded fonts in certain environments (e.g., PostScript interpreters), - * where the glyph data isn't in the font file, or must be overridden by - * different values. - * - * @note: - * It is up to client applications to create and implement @FT_Incremental - * objects, as long as they provide implementations for the methods - * @FT_Incremental_GetGlyphDataFunc, @FT_Incremental_FreeGlyphDataFunc - * and @FT_Incremental_GetGlyphMetricsFunc. - * - * See the description of @FT_Incremental_InterfaceRec to understand how - * to use incremental objects with FreeType. - * - */ - typedef struct FT_IncrementalRec_* FT_Incremental; - - - /*************************************************************************** - * - * @struct: - * FT_Incremental_MetricsRec - * - * @description: - * A small structure used to contain the basic glyph metrics returned - * by the @FT_Incremental_GetGlyphMetricsFunc method. - * - * @fields: - * bearing_x :: - * Left bearing, in font units. - * - * bearing_y :: - * Top bearing, in font units. - * - * advance :: - * Horizontal component of glyph advance, in font units. - * - * advance_v :: - * Vertical component of glyph advance, in font units. - * - * @note: - * These correspond to horizontal or vertical metrics depending on the - * value of the `vertical' argument to the function - * @FT_Incremental_GetGlyphMetricsFunc. - * - */ - typedef struct FT_Incremental_MetricsRec_ - { - FT_Long bearing_x; - FT_Long bearing_y; - FT_Long advance; - FT_Long advance_v; /* since 2.3.12 */ - - } FT_Incremental_MetricsRec; - - - /*************************************************************************** - * - * @struct: - * FT_Incremental_Metrics - * - * @description: - * A handle to an @FT_Incremental_MetricsRec structure. - * - */ - typedef struct FT_Incremental_MetricsRec_* FT_Incremental_Metrics; - - - /*************************************************************************** - * - * @type: - * FT_Incremental_GetGlyphDataFunc - * - * @description: - * A function called by FreeType to access a given glyph's data bytes - * during @FT_Load_Glyph or @FT_Load_Char if incremental loading is - * enabled. - * - * Note that the format of the glyph's data bytes depends on the font - * file format. For TrueType, it must correspond to the raw bytes within - * the `glyf' table. For PostScript formats, it must correspond to the - * *unencrypted* charstring bytes, without any `lenIV' header. It is - * undefined for any other format. - * - * @input: - * incremental :: - * Handle to an opaque @FT_Incremental handle provided by the client - * application. - * - * glyph_index :: - * Index of relevant glyph. - * - * @output: - * adata :: - * A structure describing the returned glyph data bytes (which will be - * accessed as a read-only byte block). - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If this function returns successfully the method - * @FT_Incremental_FreeGlyphDataFunc will be called later to release - * the data bytes. - * - * Nested calls to @FT_Incremental_GetGlyphDataFunc can happen for - * compound glyphs. - * - */ - typedef FT_Error - (*FT_Incremental_GetGlyphDataFunc)( FT_Incremental incremental, - FT_UInt glyph_index, - FT_Data* adata ); - - - /*************************************************************************** - * - * @type: - * FT_Incremental_FreeGlyphDataFunc - * - * @description: - * A function used to release the glyph data bytes returned by a - * successful call to @FT_Incremental_GetGlyphDataFunc. - * - * @input: - * incremental :: - * A handle to an opaque @FT_Incremental handle provided by the client - * application. - * - * data :: - * A structure describing the glyph data bytes (which will be accessed - * as a read-only byte block). - * - */ - typedef void - (*FT_Incremental_FreeGlyphDataFunc)( FT_Incremental incremental, - FT_Data* data ); - - - /*************************************************************************** - * - * @type: - * FT_Incremental_GetGlyphMetricsFunc - * - * @description: - * A function used to retrieve the basic metrics of a given glyph index - * before accessing its data. This is necessary because, in certain - * formats like TrueType, the metrics are stored in a different place from - * the glyph images proper. - * - * @input: - * incremental :: - * A handle to an opaque @FT_Incremental handle provided by the client - * application. - * - * glyph_index :: - * Index of relevant glyph. - * - * vertical :: - * If true, return vertical metrics. - * - * ametrics :: - * This parameter is used for both input and output. - * The original glyph metrics, if any, in font units. If metrics are - * not available all the values must be set to zero. - * - * @output: - * ametrics :: - * The replacement glyph metrics in font units. - * - */ - typedef FT_Error - (*FT_Incremental_GetGlyphMetricsFunc) - ( FT_Incremental incremental, - FT_UInt glyph_index, - FT_Bool vertical, - FT_Incremental_MetricsRec *ametrics ); - - - /************************************************************************** - * - * @struct: - * FT_Incremental_FuncsRec - * - * @description: - * A table of functions for accessing fonts that load data - * incrementally. Used in @FT_Incremental_InterfaceRec. - * - * @fields: - * get_glyph_data :: - * The function to get glyph data. Must not be null. - * - * free_glyph_data :: - * The function to release glyph data. Must not be null. - * - * get_glyph_metrics :: - * The function to get glyph metrics. May be null if the font does - * not provide overriding glyph metrics. - * - */ - typedef struct FT_Incremental_FuncsRec_ - { - FT_Incremental_GetGlyphDataFunc get_glyph_data; - FT_Incremental_FreeGlyphDataFunc free_glyph_data; - FT_Incremental_GetGlyphMetricsFunc get_glyph_metrics; - - } FT_Incremental_FuncsRec; - - - /*************************************************************************** - * - * @struct: - * FT_Incremental_InterfaceRec - * - * @description: - * A structure to be used with @FT_Open_Face to indicate that the user - * wants to support incremental glyph loading. You should use it with - * @FT_PARAM_TAG_INCREMENTAL as in the following example: - * - * { - * FT_Incremental_InterfaceRec inc_int; - * FT_Parameter parameter; - * FT_Open_Args open_args; - * - * - * // set up incremental descriptor - * inc_int.funcs = my_funcs; - * inc_int.object = my_object; - * - * // set up optional parameter - * parameter.tag = FT_PARAM_TAG_INCREMENTAL; - * parameter.data = &inc_int; - * - * // set up FT_Open_Args structure - * open_args.flags = FT_OPEN_PATHNAME | FT_OPEN_PARAMS; - * open_args.pathname = my_font_pathname; - * open_args.num_params = 1; - * open_args.params = ¶meter; // we use one optional argument - * - * // open the font - * error = FT_Open_Face( library, &open_args, index, &face ); - * ... - * } - * - */ - typedef struct FT_Incremental_InterfaceRec_ - { - const FT_Incremental_FuncsRec* funcs; - FT_Incremental object; - - } FT_Incremental_InterfaceRec; - - - /*************************************************************************** - * - * @type: - * FT_Incremental_Interface - * - * @description: - * A pointer to an @FT_Incremental_InterfaceRec structure. - * - */ - typedef FT_Incremental_InterfaceRec* FT_Incremental_Interface; - - - /*************************************************************************** - * - * @constant: - * FT_PARAM_TAG_INCREMENTAL - * - * @description: - * A constant used as the tag of @FT_Parameter structures to indicate - * an incremental loading object to be used by FreeType. - * - */ -#define FT_PARAM_TAG_INCREMENTAL FT_MAKE_TAG( 'i', 'n', 'c', 'r' ) - - /* */ - - -FT_END_HEADER - -#endif /* FTINCREM_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftlcdfil.h b/android/armeabi/include/freetype/ftlcdfil.h deleted file mode 100644 index e06a8957..00000000 --- a/android/armeabi/include/freetype/ftlcdfil.h +++ /dev/null @@ -1,286 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftlcdfil.h */ -/* */ -/* FreeType API for color filtering of subpixel bitmap glyphs */ -/* (specification). */ -/* */ -/* Copyright 2006-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTLCDFIL_H_ -#define FTLCDFIL_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************** - * - * @section: - * lcd_filtering - * - * @title: - * LCD Filtering - * - * @abstract: - * Reduce color fringes of subpixel-rendered bitmaps. - * - * @description: - * Subpixel rendering exploits the color-striped structure of LCD - * pixels, increasing the available resolution in the direction of the - * stripe (usually horizontal RGB) by a factor of~3. Since these - * subpixels are color pixels, using them unfiltered creates severe - * color fringes. Use the @FT_Library_SetLcdFilter API to specify a - * low-pass filter, which is then applied to subpixel-rendered bitmaps - * generated through @FT_Render_Glyph. The filter sacrifices some of - * the higher resolution to reduce color fringes, making the glyph image - * slightly blurrier. Positional improvements will remain. - * - * Note that no filter is active by default, and that this function is - * *not* implemented in default builds of the library. You need to - * #define FT_CONFIG_OPTION_SUBPIXEL_RENDERING in your `ftoption.h' file - * in order to activate it and explicitly call @FT_Library_SetLcdFilter - * to enable it. - * - * A filter should have two properties: - * - * 1) It should be normalized, meaning the sum of the 5~components - * should be 256 (0x100). It is possible to go above or under this - * target sum, however: going under means tossing out contrast, going - * over means invoking clamping and thereby non-linearities that - * increase contrast somewhat at the expense of greater distortion - * and color-fringing. Contrast is better enhanced through stem - * darkening. - * - * 2) It should be color-balanced, meaning a filter `{~a, b, c, b, a~}' - * where a~+ b~=~c. It distributes the computed coverage for one - * subpixel to all subpixels equally, sacrificing some won resolution - * but drastically reducing color-fringing. Positioning improvements - * remain! Note that color-fringing can only really be minimized - * when using a color-balanced filter and alpha-blending the glyph - * onto a surface in linear space; see @FT_Render_Glyph. - * - * Regarding the form, a filter can be a `boxy' filter or a `beveled' - * filter. Boxy filters are sharper but are less forgiving of non-ideal - * gamma curves of a screen (viewing angles!), beveled filters are - * fuzzier but more tolerant. - * - * Examples: - * - * - [0x10 0x40 0x70 0x40 0x10] is beveled and neither balanced nor - * normalized. - * - * - [0x1A 0x33 0x4D 0x33 0x1A] is beveled and balanced but not - * normalized. - * - * - [0x19 0x33 0x66 0x4c 0x19] is beveled and normalized but not - * balanced. - * - * - [0x00 0x4c 0x66 0x4c 0x00] is boxily beveled and normalized but not - * balanced. - * - * - [0x00 0x55 0x56 0x55 0x00] is boxy, normalized, and almost - * balanced. - * - * - [0x08 0x4D 0x56 0x4D 0x08] is beveled, normalized and, almost - * balanced. - * - * The filter affects glyph bitmaps rendered through @FT_Render_Glyph, - * @FT_Load_Glyph, and @FT_Load_Char. It does _not_ affect the output - * of @FT_Outline_Render and @FT_Outline_Get_Bitmap. - * - * If this feature is activated, the dimensions of LCD glyph bitmaps are - * either wider or taller than the dimensions of the corresponding - * outline with regard to the pixel grid. For example, for - * @FT_RENDER_MODE_LCD, the filter adds 3~subpixels to the left, and - * 3~subpixels to the right. The bitmap offset values are adjusted - * accordingly, so clients shouldn't need to modify their layout and - * glyph positioning code when enabling the filter. - * - * It is important to understand that linear alpha blending and gamma - * correction is critical for correctly rendering glyphs onto surfaces - * without artifacts and even more critical when subpixel rendering is - * involved. - * - * Each of the 3~alpha values (subpixels) is independently used to blend - * one color channel. That is, red alpha blends the red channel of the - * text color with the red channel of the background pixel. The - * distribution of density values by the color-balanced filter assumes - * alpha blending is done in linear space; only then color artifacts - * cancel out. - */ - - - /**************************************************************************** - * - * @enum: - * FT_LcdFilter - * - * @description: - * A list of values to identify various types of LCD filters. - * - * @values: - * FT_LCD_FILTER_NONE :: - * Do not perform filtering. When used with subpixel rendering, this - * results in sometimes severe color fringes. - * - * FT_LCD_FILTER_DEFAULT :: - * The default filter reduces color fringes considerably, at the cost - * of a slight blurriness in the output. - * - * It is a beveled, normalized, and color-balanced five-tap filter - * that is more forgiving to screens with non-ideal gamma curves and - * viewing angles. Note that while color-fringing is reduced, it can - * only be minimized by using linear alpha blending and gamma - * correction to render glyphs onto surfaces. The default filter - * weights are [0x08 0x4D 0x56 0x4D 0x08]. - * - * FT_LCD_FILTER_LIGHT :: - * The light filter is a variant that is sharper at the cost of - * slightly more color fringes than the default one. - * - * It is a boxy, normalized, and color-balanced three-tap filter that - * is less forgiving to screens with non-ideal gamma curves and - * viewing angles. This filter works best when the rendering system - * uses linear alpha blending and gamma correction to render glyphs - * onto surfaces. The light filter weights are - * [0x00 0x55 0x56 0x55 0x00]. - * - * FT_LCD_FILTER_LEGACY :: - * This filter corresponds to the original libXft color filter. It - * provides high contrast output but can exhibit really bad color - * fringes if glyphs are not extremely well hinted to the pixel grid. - * In other words, it only works well if the TrueType bytecode - * interpreter is enabled *and* high-quality hinted fonts are used. - * - * This filter is only provided for comparison purposes, and might be - * disabled or stay unsupported in the future. - * - * FT_LCD_FILTER_LEGACY1 :: - * For historical reasons, the FontConfig library returns a different - * enumeration value for legacy LCD filtering. To make code work that - * (incorrectly) forwards FontConfig's enumeration value to - * @FT_Library_SetLcdFilter without proper mapping, it is thus easiest - * to have another enumeration value, which is completely equal to - * `FT_LCD_FILTER_LEGACY'. - * - * @since: - * 2.3.0 (`FT_LCD_FILTER_LEGACY1' since 2.6.2) - */ - typedef enum FT_LcdFilter_ - { - FT_LCD_FILTER_NONE = 0, - FT_LCD_FILTER_DEFAULT = 1, - FT_LCD_FILTER_LIGHT = 2, - FT_LCD_FILTER_LEGACY1 = 3, - FT_LCD_FILTER_LEGACY = 16, - - FT_LCD_FILTER_MAX /* do not remove */ - - } FT_LcdFilter; - - - /************************************************************************** - * - * @func: - * FT_Library_SetLcdFilter - * - * @description: - * This function is used to apply color filtering to LCD decimated - * bitmaps, like the ones used when calling @FT_Render_Glyph with - * @FT_RENDER_MODE_LCD or @FT_RENDER_MODE_LCD_V. - * - * @input: - * library :: - * A handle to the target library instance. - * - * filter :: - * The filter type. - * - * You can use @FT_LCD_FILTER_NONE here to disable this feature, or - * @FT_LCD_FILTER_DEFAULT to use a default filter that should work - * well on most LCD screens. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This feature is always disabled by default. Clients must make an - * explicit call to this function with a `filter' value other than - * @FT_LCD_FILTER_NONE in order to enable it. - * - * Due to *PATENTS* covering subpixel rendering, this function doesn't - * do anything except returning `FT_Err_Unimplemented_Feature' if the - * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not - * defined in your build of the library, which should correspond to all - * default builds of FreeType. - * - * @since: - * 2.3.0 - */ - FT_EXPORT( FT_Error ) - FT_Library_SetLcdFilter( FT_Library library, - FT_LcdFilter filter ); - - - /************************************************************************** - * - * @func: - * FT_Library_SetLcdFilterWeights - * - * @description: - * This function can be used to enable LCD filter with custom weights, - * instead of using presets in @FT_Library_SetLcdFilter. - * - * @input: - * library :: - * A handle to the target library instance. - * - * weights :: - * A pointer to an array; the function copies the first five bytes and - * uses them to specify the filter weights. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * Due to *PATENTS* covering subpixel rendering, this function doesn't - * do anything except returning `FT_Err_Unimplemented_Feature' if the - * configuration macro FT_CONFIG_OPTION_SUBPIXEL_RENDERING is not - * defined in your build of the library, which should correspond to all - * default builds of FreeType. - * - * @since: - * 2.4.0 - */ - FT_EXPORT( FT_Error ) - FT_Library_SetLcdFilterWeights( FT_Library library, - unsigned char *weights ); - - /* */ - - -FT_END_HEADER - -#endif /* FTLCDFIL_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftlist.h b/android/armeabi/include/freetype/ftlist.h deleted file mode 100644 index 82f437ac..00000000 --- a/android/armeabi/include/freetype/ftlist.h +++ /dev/null @@ -1,276 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftlist.h */ -/* */ -/* Generic list support for FreeType (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file implements functions relative to list processing. Its */ - /* data structures are defined in `freetype.h'. */ - /* */ - /*************************************************************************/ - - -#ifndef FTLIST_H_ -#define FTLIST_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* list_processing */ - /* */ - /* <Title> */ - /* List Processing */ - /* */ - /* <Abstract> */ - /* Simple management of lists. */ - /* */ - /* <Description> */ - /* This section contains various definitions related to list */ - /* processing using doubly-linked nodes. */ - /* */ - /* <Order> */ - /* FT_List */ - /* FT_ListNode */ - /* FT_ListRec */ - /* FT_ListNodeRec */ - /* */ - /* FT_List_Add */ - /* FT_List_Insert */ - /* FT_List_Find */ - /* FT_List_Remove */ - /* FT_List_Up */ - /* FT_List_Iterate */ - /* FT_List_Iterator */ - /* FT_List_Finalize */ - /* FT_List_Destructor */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Find */ - /* */ - /* <Description> */ - /* Find the list node for a given listed object. */ - /* */ - /* <Input> */ - /* list :: A pointer to the parent list. */ - /* data :: The address of the listed object. */ - /* */ - /* <Return> */ - /* List node. NULL if it wasn't found. */ - /* */ - FT_EXPORT( FT_ListNode ) - FT_List_Find( FT_List list, - void* data ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Add */ - /* */ - /* <Description> */ - /* Append an element to the end of a list. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* node :: The node to append. */ - /* */ - FT_EXPORT( void ) - FT_List_Add( FT_List list, - FT_ListNode node ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Insert */ - /* */ - /* <Description> */ - /* Insert an element at the head of a list. */ - /* */ - /* <InOut> */ - /* list :: A pointer to parent list. */ - /* node :: The node to insert. */ - /* */ - FT_EXPORT( void ) - FT_List_Insert( FT_List list, - FT_ListNode node ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Remove */ - /* */ - /* <Description> */ - /* Remove a node from a list. This function doesn't check whether */ - /* the node is in the list! */ - /* */ - /* <Input> */ - /* node :: The node to remove. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* */ - FT_EXPORT( void ) - FT_List_Remove( FT_List list, - FT_ListNode node ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Up */ - /* */ - /* <Description> */ - /* Move a node to the head/top of a list. Used to maintain LRU */ - /* lists. */ - /* */ - /* <InOut> */ - /* list :: A pointer to the parent list. */ - /* node :: The node to move. */ - /* */ - FT_EXPORT( void ) - FT_List_Up( FT_List list, - FT_ListNode node ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_List_Iterator */ - /* */ - /* <Description> */ - /* An FT_List iterator function that is called during a list parse */ - /* by @FT_List_Iterate. */ - /* */ - /* <Input> */ - /* node :: The current iteration list node. */ - /* */ - /* user :: A typeless pointer passed to @FT_List_Iterate. */ - /* Can be used to point to the iteration's state. */ - /* */ - typedef FT_Error - (*FT_List_Iterator)( FT_ListNode node, - void* user ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Iterate */ - /* */ - /* <Description> */ - /* Parse a list and calls a given iterator function on each element. */ - /* Note that parsing is stopped as soon as one of the iterator calls */ - /* returns a non-zero value. */ - /* */ - /* <Input> */ - /* list :: A handle to the list. */ - /* iterator :: An iterator function, called on each node of the list. */ - /* user :: A user-supplied field that is passed as the second */ - /* argument to the iterator. */ - /* */ - /* <Return> */ - /* The result (a FreeType error code) of the last iterator call. */ - /* */ - FT_EXPORT( FT_Error ) - FT_List_Iterate( FT_List list, - FT_List_Iterator iterator, - void* user ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_List_Destructor */ - /* */ - /* <Description> */ - /* An @FT_List iterator function that is called during a list */ - /* finalization by @FT_List_Finalize to destroy all elements in a */ - /* given list. */ - /* */ - /* <Input> */ - /* system :: The current system object. */ - /* */ - /* data :: The current object to destroy. */ - /* */ - /* user :: A typeless pointer passed to @FT_List_Iterate. It can */ - /* be used to point to the iteration's state. */ - /* */ - typedef void - (*FT_List_Destructor)( FT_Memory memory, - void* data, - void* user ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_List_Finalize */ - /* */ - /* <Description> */ - /* Destroy all elements in the list as well as the list itself. */ - /* */ - /* <Input> */ - /* list :: A handle to the list. */ - /* */ - /* destroy :: A list destructor that will be applied to each element */ - /* of the list. Set this to NULL if not needed. */ - /* */ - /* memory :: The current memory object that handles deallocation. */ - /* */ - /* user :: A user-supplied field that is passed as the last */ - /* argument to the destructor. */ - /* */ - /* <Note> */ - /* This function expects that all nodes added by @FT_List_Add or */ - /* @FT_List_Insert have been dynamically allocated. */ - /* */ - FT_EXPORT( void ) - FT_List_Finalize( FT_List list, - FT_List_Destructor destroy, - FT_Memory memory, - void* user ); - - /* */ - - -FT_END_HEADER - -#endif /* FTLIST_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftlzw.h b/android/armeabi/include/freetype/ftlzw.h deleted file mode 100644 index 582e2c14..00000000 --- a/android/armeabi/include/freetype/ftlzw.h +++ /dev/null @@ -1,99 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftlzw.h */ -/* */ -/* LZW-compressed stream support. */ -/* */ -/* Copyright 2004-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTLZW_H_ -#define FTLZW_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************/ - /* */ - /* <Section> */ - /* lzw */ - /* */ - /* <Title> */ - /* LZW Streams */ - /* */ - /* <Abstract> */ - /* Using LZW-compressed font files. */ - /* */ - /* <Description> */ - /* This section contains the declaration of LZW-specific functions. */ - /* */ - /*************************************************************************/ - - /************************************************************************ - * - * @function: - * FT_Stream_OpenLZW - * - * @description: - * Open a new stream to parse LZW-compressed font files. This is - * mainly used to support the compressed `*.pcf.Z' fonts that come - * with XFree86. - * - * @input: - * stream :: The target embedding stream. - * - * source :: The source stream. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source stream must be opened _before_ calling this function. - * - * Calling the internal function `FT_Stream_Close' on the new stream will - * *not* call `FT_Stream_Close' on the source stream. None of the stream - * objects will be released to the heap. - * - * The stream implementation is very basic and resets the decompression - * process each time seeking backwards is needed within the stream - * - * In certain builds of the library, LZW compression recognition is - * automatically handled when calling @FT_New_Face or @FT_Open_Face. - * This means that if no font driver is capable of handling the raw - * compressed file, the library will try to open a LZW stream from it - * and re-open the face with it. - * - * This function may return `FT_Err_Unimplemented_Feature' if your build - * of FreeType was not compiled with LZW support. - */ - FT_EXPORT( FT_Error ) - FT_Stream_OpenLZW( FT_Stream stream, - FT_Stream source ); - - /* */ - - -FT_END_HEADER - -#endif /* FTLZW_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftmac.h b/android/armeabi/include/freetype/ftmac.h deleted file mode 100644 index adb15cad..00000000 --- a/android/armeabi/include/freetype/ftmac.h +++ /dev/null @@ -1,274 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmac.h */ -/* */ -/* Additional Mac-specific API. */ -/* */ -/* Copyright 1996-2016 by */ -/* Just van Rossum, David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* NOTE: Include this file after FT_FREETYPE_H and after any */ -/* Mac-specific headers (because this header uses Mac types such as */ -/* Handle, FSSpec, FSRef, etc.) */ -/* */ -/***************************************************************************/ - - -#ifndef FTMAC_H_ -#define FTMAC_H_ - - -#include <ft2build.h> - - -FT_BEGIN_HEADER - - -/* gcc-3.4.1 and later can warn about functions tagged as deprecated */ -#ifndef FT_DEPRECATED_ATTRIBUTE -#if defined(__GNUC__) && \ - ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1))) -#define FT_DEPRECATED_ATTRIBUTE __attribute__((deprecated)) -#else -#define FT_DEPRECATED_ATTRIBUTE -#endif -#endif - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* mac_specific */ - /* */ - /* <Title> */ - /* Mac Specific Interface */ - /* */ - /* <Abstract> */ - /* Only available on the Macintosh. */ - /* */ - /* <Description> */ - /* The following definitions are only available if FreeType is */ - /* compiled on a Macintosh. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FOND */ - /* */ - /* <Description> */ - /* Create a new face object from a FOND resource. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* fond :: A FOND resource. */ - /* */ - /* face_index :: Only supported for the -1 `sanity check' special */ - /* case. */ - /* */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Notes> */ - /* This function can be used to create @FT_Face objects from fonts */ - /* that are installed in the system as follows. */ - /* */ - /* { */ - /* fond = GetResource( 'FOND', fontName ); */ - /* error = FT_New_Face_From_FOND( library, fond, 0, &face ); */ - /* } */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Face_From_FOND( FT_Library library, - Handle fond, - FT_Long face_index, - FT_Face *aface ) - FT_DEPRECATED_ATTRIBUTE; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFile_From_Mac_Name */ - /* */ - /* <Description> */ - /* Return an FSSpec for the disk file containing the named font. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font (e.g., Times New Roman */ - /* Bold). */ - /* */ - /* <Output> */ - /* pathSpec :: FSSpec to the file. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* face_index :: Index of the face. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_GetFile_From_Mac_Name( const char* fontName, - FSSpec* pathSpec, - FT_Long* face_index ) - FT_DEPRECATED_ATTRIBUTE; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFile_From_Mac_ATS_Name */ - /* */ - /* <Description> */ - /* Return an FSSpec for the disk file containing the named font. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font in ATS framework. */ - /* */ - /* <Output> */ - /* pathSpec :: FSSpec to the file. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* face_index :: Index of the face. For passing to */ - /* @FT_New_Face_From_FSSpec. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_GetFile_From_Mac_ATS_Name( const char* fontName, - FSSpec* pathSpec, - FT_Long* face_index ) - FT_DEPRECATED_ATTRIBUTE; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_GetFilePath_From_Mac_ATS_Name */ - /* */ - /* <Description> */ - /* Return a pathname of the disk file and face index for given font */ - /* name that is handled by ATS framework. */ - /* */ - /* <Input> */ - /* fontName :: Mac OS name of the font in ATS framework. */ - /* */ - /* <Output> */ - /* path :: Buffer to store pathname of the file. For passing */ - /* to @FT_New_Face. The client must allocate this */ - /* buffer before calling this function. */ - /* */ - /* maxPathSize :: Lengths of the buffer `path' that client allocated. */ - /* */ - /* face_index :: Index of the face. For passing to @FT_New_Face. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_GetFilePath_From_Mac_ATS_Name( const char* fontName, - UInt8* path, - UInt32 maxPathSize, - FT_Long* face_index ) - FT_DEPRECATED_ATTRIBUTE; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSSpec */ - /* */ - /* <Description> */ - /* Create a new face object from a given resource and typeface index */ - /* using an FSSpec to the font file. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* spec :: FSSpec to the font file. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index~0. */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* @FT_New_Face_From_FSSpec is identical to @FT_New_Face except */ - /* it accepts an FSSpec instead of a path. */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Face_From_FSSpec( FT_Library library, - const FSSpec *spec, - FT_Long face_index, - FT_Face *aface ) - FT_DEPRECATED_ATTRIBUTE; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Face_From_FSRef */ - /* */ - /* <Description> */ - /* Create a new face object from a given resource and typeface index */ - /* using an FSRef to the font file. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library resource. */ - /* */ - /* <Input> */ - /* spec :: FSRef to the font file. */ - /* */ - /* face_index :: The index of the face within the resource. The */ - /* first face has index~0. */ - /* <Output> */ - /* aface :: A handle to a new face object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* @FT_New_Face_From_FSRef is identical to @FT_New_Face except */ - /* it accepts an FSRef instead of a path. */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Face_From_FSRef( FT_Library library, - const FSRef *ref, - FT_Long face_index, - FT_Face *aface ) - FT_DEPRECATED_ATTRIBUTE; - - /* */ - - -FT_END_HEADER - - -#endif /* FTMAC_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftmm.h b/android/armeabi/include/freetype/ftmm.h deleted file mode 100644 index 6c05f0c3..00000000 --- a/android/armeabi/include/freetype/ftmm.h +++ /dev/null @@ -1,384 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmm.h */ -/* */ -/* FreeType Multiple Master font interface (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTMM_H_ -#define FTMM_H_ - - -#include <ft2build.h> -#include FT_TYPE1_TABLES_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* multiple_masters */ - /* */ - /* <Title> */ - /* Multiple Masters */ - /* */ - /* <Abstract> */ - /* How to manage Multiple Masters fonts. */ - /* */ - /* <Description> */ - /* The following types and functions are used to manage Multiple */ - /* Master fonts, i.e., the selection of specific design instances by */ - /* setting design axis coordinates. */ - /* */ - /* George Williams has extended this interface to make it work with */ - /* both Type~1 Multiple Masters fonts and GX distortable (var) */ - /* fonts. Some of these routines only work with MM fonts, others */ - /* will work with both types. They are similar enough that a */ - /* consistent interface makes sense. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_MM_Axis */ - /* */ - /* <Description> */ - /* A simple structure used to model a given axis in design space for */ - /* Multiple Masters fonts. */ - /* */ - /* This structure can't be used for GX var fonts. */ - /* */ - /* <Fields> */ - /* name :: The axis's name. */ - /* */ - /* minimum :: The axis's minimum design coordinate. */ - /* */ - /* maximum :: The axis's maximum design coordinate. */ - /* */ - typedef struct FT_MM_Axis_ - { - FT_String* name; - FT_Long minimum; - FT_Long maximum; - - } FT_MM_Axis; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Multi_Master */ - /* */ - /* <Description> */ - /* A structure used to model the axes and space of a Multiple Masters */ - /* font. */ - /* */ - /* This structure can't be used for GX var fonts. */ - /* */ - /* <Fields> */ - /* num_axis :: Number of axes. Cannot exceed~4. */ - /* */ - /* num_designs :: Number of designs; should be normally 2^num_axis */ - /* even though the Type~1 specification strangely */ - /* allows for intermediate designs to be present. */ - /* This number cannot exceed~16. */ - /* */ - /* axis :: A table of axis descriptors. */ - /* */ - typedef struct FT_Multi_Master_ - { - FT_UInt num_axis; - FT_UInt num_designs; - FT_MM_Axis axis[T1_MAX_MM_AXIS]; - - } FT_Multi_Master; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Var_Axis */ - /* */ - /* <Description> */ - /* A simple structure used to model a given axis in design space for */ - /* Multiple Masters and GX var fonts. */ - /* */ - /* <Fields> */ - /* name :: The axis's name. */ - /* Not always meaningful for GX. */ - /* */ - /* minimum :: The axis's minimum design coordinate. */ - /* */ - /* def :: The axis's default design coordinate. */ - /* FreeType computes meaningful default values for MM; it */ - /* is then an integer value, not in 16.16 format. */ - /* */ - /* maximum :: The axis's maximum design coordinate. */ - /* */ - /* tag :: The axis's tag (the GX equivalent to `name'). */ - /* FreeType provides default values for MM if possible. */ - /* */ - /* strid :: The entry in `name' table (another GX version of */ - /* `name'). */ - /* Not meaningful for MM. */ - /* */ - typedef struct FT_Var_Axis_ - { - FT_String* name; - - FT_Fixed minimum; - FT_Fixed def; - FT_Fixed maximum; - - FT_ULong tag; - FT_UInt strid; - - } FT_Var_Axis; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Var_Named_Style */ - /* */ - /* <Description> */ - /* A simple structure used to model a named style in a GX var font. */ - /* */ - /* This structure can't be used for MM fonts. */ - /* */ - /* <Fields> */ - /* coords :: The design coordinates for this style. */ - /* This is an array with one entry for each axis. */ - /* */ - /* strid :: The entry in `name' table identifying this style. */ - /* */ - typedef struct FT_Var_Named_Style_ - { - FT_Fixed* coords; - FT_UInt strid; - - } FT_Var_Named_Style; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_MM_Var */ - /* */ - /* <Description> */ - /* A structure used to model the axes and space of a Multiple Masters */ - /* or GX var distortable font. */ - /* */ - /* Some fields are specific to one format and not to the other. */ - /* */ - /* <Fields> */ - /* num_axis :: The number of axes. The maximum value is~4 for */ - /* MM; no limit in GX. */ - /* */ - /* num_designs :: The number of designs; should be normally */ - /* 2^num_axis for MM fonts. Not meaningful for GX */ - /* (where every glyph could have a different */ - /* number of designs). */ - /* */ - /* num_namedstyles :: The number of named styles; only meaningful for */ - /* GX that allows certain design coordinates to */ - /* have a string ID (in the `name' table) */ - /* associated with them. The font can tell the */ - /* user that, for example, Weight=1.5 is `Bold'. */ - /* */ - /* axis :: An axis descriptor table. */ - /* GX fonts contain slightly more data than MM. */ - /* Memory management of this pointer is done */ - /* internally by FreeType. */ - /* */ - /* namedstyle :: A named style table. */ - /* Only meaningful with GX. */ - /* Memory management of this pointer is done */ - /* internally by FreeType. */ - /* */ - typedef struct FT_MM_Var_ - { - FT_UInt num_axis; - FT_UInt num_designs; - FT_UInt num_namedstyles; - FT_Var_Axis* axis; - FT_Var_Named_Style* namedstyle; - - } FT_MM_Var; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Multi_Master */ - /* */ - /* <Description> */ - /* Retrieve the Multiple Master descriptor of a given font. */ - /* */ - /* This function can't be used with GX fonts. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Output> */ - /* amaster :: The Multiple Masters descriptor. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Multi_Master( FT_Face face, - FT_Multi_Master *amaster ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_MM_Var */ - /* */ - /* <Description> */ - /* Retrieve the Multiple Master/GX var descriptor of a given font. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Output> */ - /* amaster :: The Multiple Masters/GX var descriptor. */ - /* Allocates a data structure, which the user must */ - /* deallocate with `free' after use. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_MM_Var( FT_Face face, - FT_MM_Var* *amaster ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_MM_Design_Coordinates */ - /* */ - /* <Description> */ - /* For Multiple Masters fonts, choose an interpolated font design */ - /* through design coordinates. */ - /* */ - /* This function can't be used with GX fonts. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available design coordinates. If it */ - /* is larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use default values for the remaining axes. */ - /* */ - /* coords :: An array of design coordinates. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_MM_Design_Coordinates( FT_Face face, - FT_UInt num_coords, - FT_Long* coords ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Var_Design_Coordinates */ - /* */ - /* <Description> */ - /* For Multiple Master or GX Var fonts, choose an interpolated font */ - /* design through design coordinates. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available design coordinates. If it */ - /* is larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use default values for the remaining axes. */ - /* */ - /* coords :: An array of design coordinates. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Var_Design_Coordinates( FT_Face face, - FT_UInt num_coords, - FT_Fixed* coords ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_MM_Blend_Coordinates */ - /* */ - /* <Description> */ - /* For Multiple Masters and GX var fonts, choose an interpolated font */ - /* design through normalized blend coordinates. */ - /* */ - /* <InOut> */ - /* face :: A handle to the source face. */ - /* */ - /* <Input> */ - /* num_coords :: The number of available design coordinates. If it */ - /* is larger than the number of axes, ignore the excess */ - /* values. If it is smaller than the number of axes, */ - /* use default values for the remaining axes. */ - /* */ - /* coords :: The design coordinates array (each element must be */ - /* between 0 and 1.0). */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_MM_Blend_Coordinates( FT_Face face, - FT_UInt num_coords, - FT_Fixed* coords ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Var_Blend_Coordinates */ - /* */ - /* <Description> */ - /* This is another name of @FT_Set_MM_Blend_Coordinates. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Var_Blend_Coordinates( FT_Face face, - FT_UInt num_coords, - FT_Fixed* coords ); - - /* */ - - -FT_END_HEADER - -#endif /* FTMM_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftmodapi.h b/android/armeabi/include/freetype/ftmodapi.h deleted file mode 100644 index b4d2758e..00000000 --- a/android/armeabi/include/freetype/ftmodapi.h +++ /dev/null @@ -1,667 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmodapi.h */ -/* */ -/* FreeType modules public interface (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTMODAPI_H_ -#define FTMODAPI_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /* <Title> */ - /* Module Management */ - /* */ - /* <Abstract> */ - /* How to add, upgrade, remove, and control modules from FreeType. */ - /* */ - /* <Description> */ - /* The definitions below are used to manage modules within FreeType. */ - /* Modules can be added, upgraded, and removed at runtime. */ - /* Additionally, some module properties can be controlled also. */ - /* */ - /* Here is a list of possible values of the `module_name' field in */ - /* the @FT_Module_Class structure. */ - /* */ - /* { */ - /* autofitter */ - /* bdf */ - /* cff */ - /* gxvalid */ - /* otvalid */ - /* pcf */ - /* pfr */ - /* psaux */ - /* pshinter */ - /* psnames */ - /* raster1 */ - /* sfnt */ - /* smooth, smooth-lcd, smooth-lcdv */ - /* truetype */ - /* type1 */ - /* type42 */ - /* t1cid */ - /* winfonts */ - /* } */ - /* */ - /* Note that the FreeType Cache sub-system is not a FreeType module. */ - /* */ - /* <Order> */ - /* FT_Module */ - /* FT_Module_Constructor */ - /* FT_Module_Destructor */ - /* FT_Module_Requester */ - /* FT_Module_Class */ - /* */ - /* FT_Add_Module */ - /* FT_Get_Module */ - /* FT_Remove_Module */ - /* FT_Add_Default_Modules */ - /* */ - /* FT_Property_Set */ - /* FT_Property_Get */ - /* */ - /* FT_New_Library */ - /* FT_Done_Library */ - /* FT_Reference_Library */ - /* */ - /* FT_Renderer */ - /* FT_Renderer_Class */ - /* */ - /* FT_Get_Renderer */ - /* FT_Set_Renderer */ - /* */ - /* FT_Set_Debug_Hook */ - /* */ - /*************************************************************************/ - - - /* module bit flags */ -#define FT_MODULE_FONT_DRIVER 1 /* this module is a font driver */ -#define FT_MODULE_RENDERER 2 /* this module is a renderer */ -#define FT_MODULE_HINTER 4 /* this module is a glyph hinter */ -#define FT_MODULE_STYLER 8 /* this module is a styler */ - -#define FT_MODULE_DRIVER_SCALABLE 0x100 /* the driver supports */ - /* scalable fonts */ -#define FT_MODULE_DRIVER_NO_OUTLINES 0x200 /* the driver does not */ - /* support vector outlines */ -#define FT_MODULE_DRIVER_HAS_HINTER 0x400 /* the driver provides its */ - /* own hinter */ -#define FT_MODULE_DRIVER_HINTS_LIGHTLY 0x800 /* the driver's hinter */ - /* produces LIGHT hints */ - - - /* deprecated values */ -#define ft_module_font_driver FT_MODULE_FONT_DRIVER -#define ft_module_renderer FT_MODULE_RENDERER -#define ft_module_hinter FT_MODULE_HINTER -#define ft_module_styler FT_MODULE_STYLER - -#define ft_module_driver_scalable FT_MODULE_DRIVER_SCALABLE -#define ft_module_driver_no_outlines FT_MODULE_DRIVER_NO_OUTLINES -#define ft_module_driver_has_hinter FT_MODULE_DRIVER_HAS_HINTER -#define ft_module_driver_hints_lightly FT_MODULE_DRIVER_HINTS_LIGHTLY - - - typedef FT_Pointer FT_Module_Interface; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Constructor */ - /* */ - /* <Description> */ - /* A function used to initialize (not create) a new module object. */ - /* */ - /* <Input> */ - /* module :: The module to initialize. */ - /* */ - typedef FT_Error - (*FT_Module_Constructor)( FT_Module module ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Destructor */ - /* */ - /* <Description> */ - /* A function used to finalize (not destroy) a given module object. */ - /* */ - /* <Input> */ - /* module :: The module to finalize. */ - /* */ - typedef void - (*FT_Module_Destructor)( FT_Module module ); - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Module_Requester */ - /* */ - /* <Description> */ - /* A function used to query a given module for a specific interface. */ - /* */ - /* <Input> */ - /* module :: The module to be searched. */ - /* */ - /* name :: The name of the interface in the module. */ - /* */ - typedef FT_Module_Interface - (*FT_Module_Requester)( FT_Module module, - const char* name ); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Module_Class */ - /* */ - /* <Description> */ - /* The module class descriptor. */ - /* */ - /* <Fields> */ - /* module_flags :: Bit flags describing the module. */ - /* */ - /* module_size :: The size of one module object/instance in */ - /* bytes. */ - /* */ - /* module_name :: The name of the module. */ - /* */ - /* module_version :: The version, as a 16.16 fixed number */ - /* (major.minor). */ - /* */ - /* module_requires :: The version of FreeType this module requires, */ - /* as a 16.16 fixed number (major.minor). Starts */ - /* at version 2.0, i.e., 0x20000. */ - /* */ - /* module_init :: The initializing function. */ - /* */ - /* module_done :: The finalizing function. */ - /* */ - /* get_interface :: The interface requesting function. */ - /* */ - typedef struct FT_Module_Class_ - { - FT_ULong module_flags; - FT_Long module_size; - const FT_String* module_name; - FT_Fixed module_version; - FT_Fixed module_requires; - - const void* module_interface; - - FT_Module_Constructor module_init; - FT_Module_Destructor module_done; - FT_Module_Requester get_interface; - - } FT_Module_Class; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Add_Module */ - /* */ - /* <Description> */ - /* Add a new module to a given library instance. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* clazz :: A pointer to class descriptor for the module. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Add_Module( FT_Library library, - const FT_Module_Class* clazz ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Module */ - /* */ - /* <Description> */ - /* Find a module by its name. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* module_name :: The module's name (as an ASCII string). */ - /* */ - /* <Return> */ - /* A module handle. 0~if none was found. */ - /* */ - /* <Note> */ - /* FreeType's internal modules aren't documented very well, and you */ - /* should look up the source code for details. */ - /* */ - FT_EXPORT( FT_Module ) - FT_Get_Module( FT_Library library, - const char* module_name ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Remove_Module */ - /* */ - /* <Description> */ - /* Remove a given module from a library instance. */ - /* */ - /* <InOut> */ - /* library :: A handle to a library object. */ - /* */ - /* <Input> */ - /* module :: A handle to a module object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The module object is destroyed by the function in case of success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Remove_Module( FT_Library library, - FT_Module module ); - - - /********************************************************************** - * - * @function: - * FT_Property_Set - * - * @description: - * Set a property for a given module. - * - * @input: - * library :: - * A handle to the library the module is part of. - * - * module_name :: - * The module name. - * - * property_name :: - * The property name. Properties are described in the `Synopsis' - * subsection of the module's documentation. - * - * Note that only a few modules have properties. - * - * value :: - * A generic pointer to a variable or structure that gives the new - * value of the property. The exact definition of `value' is - * dependent on the property; see the `Synopsis' subsection of the - * module's documentation. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If `module_name' isn't a valid module name, or `property_name' - * doesn't specify a valid property, or if `value' doesn't represent a - * valid value for the given property, an error is returned. - * - * The following example sets property `bar' (a simple integer) in - * module `foo' to value~1. - * - * { - * FT_UInt bar; - * - * - * bar = 1; - * FT_Property_Set( library, "foo", "bar", &bar ); - * } - * - * Note that the FreeType Cache sub-system doesn't recognize module - * property changes. To avoid glyph lookup confusion within the cache - * you should call @FTC_Manager_Reset to completely flush the cache if - * a module property gets changed after @FTC_Manager_New has been - * called. - * - * It is not possible to set properties of the FreeType Cache - * sub-system itself with FT_Property_Set; use @FTC_Property_Set - * instead. - * - * @since: - * 2.4.11 - * - */ - FT_EXPORT( FT_Error ) - FT_Property_Set( FT_Library library, - const FT_String* module_name, - const FT_String* property_name, - const void* value ); - - - /********************************************************************** - * - * @function: - * FT_Property_Get - * - * @description: - * Get a module's property value. - * - * @input: - * library :: - * A handle to the library the module is part of. - * - * module_name :: - * The module name. - * - * property_name :: - * The property name. Properties are described in the `Synopsis' - * subsection of the module's documentation. - * - * @inout: - * value :: - * A generic pointer to a variable or structure that gives the - * value of the property. The exact definition of `value' is - * dependent on the property; see the `Synopsis' subsection of the - * module's documentation. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If `module_name' isn't a valid module name, or `property_name' - * doesn't specify a valid property, or if `value' doesn't represent a - * valid value for the given property, an error is returned. - * - * The following example gets property `baz' (a range) in module `foo'. - * - * { - * typedef range_ - * { - * FT_Int32 min; - * FT_Int32 max; - * - * } range; - * - * range baz; - * - * - * FT_Property_Get( library, "foo", "baz", &baz ); - * } - * - * It is not possible to retrieve properties of the FreeType Cache - * sub-system with FT_Property_Get; use @FTC_Property_Get instead. - * - * @since: - * 2.4.11 - * - */ - FT_EXPORT( FT_Error ) - FT_Property_Get( FT_Library library, - const FT_String* module_name, - const FT_String* property_name, - void* value ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Reference_Library */ - /* */ - /* <Description> */ - /* A counter gets initialized to~1 at the time an @FT_Library */ - /* structure is created. This function increments the counter. */ - /* @FT_Done_Library then only destroys a library if the counter is~1, */ - /* otherwise it simply decrements the counter. */ - /* */ - /* This function helps in managing life-cycles of structures that */ - /* reference @FT_Library objects. */ - /* */ - /* <Input> */ - /* library :: A handle to a target library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Since> */ - /* 2.4.2 */ - /* */ - FT_EXPORT( FT_Error ) - FT_Reference_Library( FT_Library library ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Library */ - /* */ - /* <Description> */ - /* This function is used to create a new FreeType library instance */ - /* from a given memory object. It is thus possible to use libraries */ - /* with distinct memory allocators within the same program. Note, */ - /* however, that the used @FT_Memory structure is expected to remain */ - /* valid for the life of the @FT_Library object. */ - /* */ - /* Normally, you would call this function (followed by a call to */ - /* @FT_Add_Default_Modules or a series of calls to @FT_Add_Module) */ - /* instead of @FT_Init_FreeType to initialize the FreeType library. */ - /* */ - /* Don't use @FT_Done_FreeType but @FT_Done_Library to destroy a */ - /* library instance. */ - /* */ - /* <Input> */ - /* memory :: A handle to the original memory object. */ - /* */ - /* <Output> */ - /* alibrary :: A pointer to handle of a new library object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Library. */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Library( FT_Memory memory, - FT_Library *alibrary ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Library */ - /* */ - /* <Description> */ - /* Discard a given library object. This closes all drivers and */ - /* discards all resource objects. */ - /* */ - /* <Input> */ - /* library :: A handle to the target library. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* See the discussion of reference counters in the description of */ - /* @FT_Reference_Library. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Done_Library( FT_Library library ); - - /* */ - - typedef void - (*FT_DebugHook_Func)( void* arg ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Debug_Hook */ - /* */ - /* <Description> */ - /* Set a debug hook function for debugging the interpreter of a font */ - /* format. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* hook_index :: The index of the debug hook. You should use the */ - /* values defined in `ftobjs.h', e.g., */ - /* `FT_DEBUG_HOOK_TRUETYPE'. */ - /* */ - /* debug_hook :: The function used to debug the interpreter. */ - /* */ - /* <Note> */ - /* Currently, four debug hook slots are available, but only two (for */ - /* the TrueType and the Type~1 interpreter) are defined. */ - /* */ - /* Since the internal headers of FreeType are no longer installed, */ - /* the symbol `FT_DEBUG_HOOK_TRUETYPE' isn't available publicly. */ - /* This is a bug and will be fixed in a forthcoming release. */ - /* */ - FT_EXPORT( void ) - FT_Set_Debug_Hook( FT_Library library, - FT_UInt hook_index, - FT_DebugHook_Func debug_hook ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Add_Default_Modules */ - /* */ - /* <Description> */ - /* Add the set of default drivers to a given library object. */ - /* This is only useful when you create a library object with */ - /* @FT_New_Library (usually to plug a custom memory manager). */ - /* */ - /* <InOut> */ - /* library :: A handle to a new library object. */ - /* */ - FT_EXPORT( void ) - FT_Add_Default_Modules( FT_Library library ); - - - - /************************************************************************** - * - * @section: - * truetype_engine - * - * @title: - * The TrueType Engine - * - * @abstract: - * TrueType bytecode support. - * - * @description: - * This section contains a function used to query the level of TrueType - * bytecode support compiled in this version of the library. - * - */ - - - /************************************************************************** - * - * @enum: - * FT_TrueTypeEngineType - * - * @description: - * A list of values describing which kind of TrueType bytecode - * engine is implemented in a given FT_Library instance. It is used - * by the @FT_Get_TrueType_Engine_Type function. - * - * @values: - * FT_TRUETYPE_ENGINE_TYPE_NONE :: - * The library doesn't implement any kind of bytecode interpreter. - * - * FT_TRUETYPE_ENGINE_TYPE_UNPATENTED :: - * Deprecated and removed. - * - * FT_TRUETYPE_ENGINE_TYPE_PATENTED :: - * The library implements a bytecode interpreter that covers - * the full instruction set of the TrueType virtual machine (this - * was governed by patents until May 2010, hence the name). - * - * @since: - * 2.2 - * - */ - typedef enum FT_TrueTypeEngineType_ - { - FT_TRUETYPE_ENGINE_TYPE_NONE = 0, - FT_TRUETYPE_ENGINE_TYPE_UNPATENTED, - FT_TRUETYPE_ENGINE_TYPE_PATENTED - - } FT_TrueTypeEngineType; - - - /************************************************************************** - * - * @func: - * FT_Get_TrueType_Engine_Type - * - * @description: - * Return an @FT_TrueTypeEngineType value to indicate which level of - * the TrueType virtual machine a given library instance supports. - * - * @input: - * library :: - * A library instance. - * - * @return: - * A value indicating which level is supported. - * - * @since: - * 2.2 - * - */ - FT_EXPORT( FT_TrueTypeEngineType ) - FT_Get_TrueType_Engine_Type( FT_Library library ); - - /* */ - - -FT_END_HEADER - -#endif /* FTMODAPI_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftmoderr.h b/android/armeabi/include/freetype/ftmoderr.h deleted file mode 100644 index 2a7671c8..00000000 --- a/android/armeabi/include/freetype/ftmoderr.h +++ /dev/null @@ -1,194 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftmoderr.h */ -/* */ -/* FreeType module error offsets (specification). */ -/* */ -/* Copyright 2001-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* This file is used to define the FreeType module error codes. */ - /* */ - /* If the macro FT_CONFIG_OPTION_USE_MODULE_ERRORS in `ftoption.h' is */ - /* set, the lower byte of an error value identifies the error code as */ - /* usual. In addition, the higher byte identifies the module. For */ - /* example, the error `FT_Err_Invalid_File_Format' has value 0x0003, the */ - /* error `TT_Err_Invalid_File_Format' has value 0x1303, the error */ - /* `T1_Err_Invalid_File_Format' has value 0x1403, etc. */ - /* */ - /* Note that `FT_Err_Ok', `TT_Err_Ok', etc. are always equal to zero, */ - /* including the high byte. */ - /* */ - /* If FT_CONFIG_OPTION_USE_MODULE_ERRORS isn't set, the higher byte of */ - /* an error value is set to zero. */ - /* */ - /* To hide the various `XXX_Err_' prefixes in the source code, FreeType */ - /* provides some macros in `fttypes.h'. */ - /* */ - /* FT_ERR( err ) */ - /* Add current error module prefix (as defined with the */ - /* `FT_ERR_PREFIX' macro) to `err'. For example, in the BDF module */ - /* the line */ - /* */ - /* error = FT_ERR( Invalid_Outline ); */ - /* */ - /* expands to */ - /* */ - /* error = BDF_Err_Invalid_Outline; */ - /* */ - /* For simplicity, you can always use `FT_Err_Ok' directly instead */ - /* of `FT_ERR( Ok )'. */ - /* */ - /* FT_ERR_EQ( errcode, err ) */ - /* FT_ERR_NEQ( errcode, err ) */ - /* Compare error code `errcode' with the error `err' for equality */ - /* and inequality, respectively. Example: */ - /* */ - /* if ( FT_ERR_EQ( error, Invalid_Outline ) ) */ - /* ... */ - /* */ - /* Using this macro you don't have to think about error prefixes. */ - /* Of course, if module errors are not active, the above example is */ - /* the same as */ - /* */ - /* if ( error == FT_Err_Invalid_Outline ) */ - /* ... */ - /* */ - /* FT_ERROR_BASE( errcode ) */ - /* FT_ERROR_MODULE( errcode ) */ - /* Get base error and module error code, respectively. */ - /* */ - /* */ - /* It can also be used to create a module error message table easily */ - /* with something like */ - /* */ - /* { */ - /* #undef FTMODERR_H_ */ - /* #define FT_MODERRDEF( e, v, s ) { FT_Mod_Err_ ## e, s }, */ - /* #define FT_MODERR_START_LIST { */ - /* #define FT_MODERR_END_LIST { 0, 0 } }; */ - /* */ - /* const struct */ - /* { */ - /* int mod_err_offset; */ - /* const char* mod_err_msg */ - /* } ft_mod_errors[] = */ - /* */ - /* #include FT_MODULE_ERRORS_H */ - /* } */ - /* */ - /*************************************************************************/ - - -#ifndef FTMODERR_H_ -#define FTMODERR_H_ - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** SETUP MACROS *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - - -#undef FT_NEED_EXTERN_C - -#ifndef FT_MODERRDEF - -#ifdef FT_CONFIG_OPTION_USE_MODULE_ERRORS -#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = v, -#else -#define FT_MODERRDEF( e, v, s ) FT_Mod_Err_ ## e = 0, -#endif - -#define FT_MODERR_START_LIST enum { -#define FT_MODERR_END_LIST FT_Mod_Err_Max }; - -#ifdef __cplusplus -#define FT_NEED_EXTERN_C - extern "C" { -#endif - -#endif /* !FT_MODERRDEF */ - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** LIST MODULE ERROR BASES *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - - -#ifdef FT_MODERR_START_LIST - FT_MODERR_START_LIST -#endif - - - FT_MODERRDEF( Base, 0x000, "base module" ) - FT_MODERRDEF( Autofit, 0x100, "autofitter module" ) - FT_MODERRDEF( BDF, 0x200, "BDF module" ) - FT_MODERRDEF( Bzip2, 0x300, "Bzip2 module" ) - FT_MODERRDEF( Cache, 0x400, "cache module" ) - FT_MODERRDEF( CFF, 0x500, "CFF module" ) - FT_MODERRDEF( CID, 0x600, "CID module" ) - FT_MODERRDEF( Gzip, 0x700, "Gzip module" ) - FT_MODERRDEF( LZW, 0x800, "LZW module" ) - FT_MODERRDEF( OTvalid, 0x900, "OpenType validation module" ) - FT_MODERRDEF( PCF, 0xA00, "PCF module" ) - FT_MODERRDEF( PFR, 0xB00, "PFR module" ) - FT_MODERRDEF( PSaux, 0xC00, "PS auxiliary module" ) - FT_MODERRDEF( PShinter, 0xD00, "PS hinter module" ) - FT_MODERRDEF( PSnames, 0xE00, "PS names module" ) - FT_MODERRDEF( Raster, 0xF00, "raster module" ) - FT_MODERRDEF( SFNT, 0x1000, "SFNT module" ) - FT_MODERRDEF( Smooth, 0x1100, "smooth raster module" ) - FT_MODERRDEF( TrueType, 0x1200, "TrueType module" ) - FT_MODERRDEF( Type1, 0x1300, "Type 1 module" ) - FT_MODERRDEF( Type42, 0x1400, "Type 42 module" ) - FT_MODERRDEF( Winfonts, 0x1500, "Windows FON/FNT module" ) - FT_MODERRDEF( GXvalid, 0x1600, "GX validation module" ) - - -#ifdef FT_MODERR_END_LIST - FT_MODERR_END_LIST -#endif - - - /*******************************************************************/ - /*******************************************************************/ - /***** *****/ - /***** CLEANUP *****/ - /***** *****/ - /*******************************************************************/ - /*******************************************************************/ - - -#ifdef FT_NEED_EXTERN_C - } -#endif - -#undef FT_MODERR_START_LIST -#undef FT_MODERR_END_LIST -#undef FT_MODERRDEF -#undef FT_NEED_EXTERN_C - - -#endif /* FTMODERR_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftotval.h b/android/armeabi/include/freetype/ftotval.h deleted file mode 100644 index c678ef34..00000000 --- a/android/armeabi/include/freetype/ftotval.h +++ /dev/null @@ -1,204 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftotval.h */ -/* */ -/* FreeType API for validating OpenType tables (specification). */ -/* */ -/* Copyright 2004-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -/***************************************************************************/ -/* */ -/* */ -/* Warning: This module might be moved to a different library in the */ -/* future to avoid a tight dependency between FreeType and the */ -/* OpenType specification. */ -/* */ -/* */ -/***************************************************************************/ - - -#ifndef FTOTVAL_H_ -#define FTOTVAL_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* ot_validation */ - /* */ - /* <Title> */ - /* OpenType Validation */ - /* */ - /* <Abstract> */ - /* An API to validate OpenType tables. */ - /* */ - /* <Description> */ - /* This section contains the declaration of functions to validate */ - /* some OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). */ - /* */ - /* <Order> */ - /* FT_OpenType_Validate */ - /* FT_OpenType_Free */ - /* */ - /* FT_VALIDATE_OTXXX */ - /* */ - /*************************************************************************/ - - - /********************************************************************** - * - * @enum: - * FT_VALIDATE_OTXXX - * - * @description: - * A list of bit-field constants used with @FT_OpenType_Validate to - * indicate which OpenType tables should be validated. - * - * @values: - * FT_VALIDATE_BASE :: - * Validate BASE table. - * - * FT_VALIDATE_GDEF :: - * Validate GDEF table. - * - * FT_VALIDATE_GPOS :: - * Validate GPOS table. - * - * FT_VALIDATE_GSUB :: - * Validate GSUB table. - * - * FT_VALIDATE_JSTF :: - * Validate JSTF table. - * - * FT_VALIDATE_MATH :: - * Validate MATH table. - * - * FT_VALIDATE_OT :: - * Validate all OpenType tables (BASE, GDEF, GPOS, GSUB, JSTF, MATH). - * - */ -#define FT_VALIDATE_BASE 0x0100 -#define FT_VALIDATE_GDEF 0x0200 -#define FT_VALIDATE_GPOS 0x0400 -#define FT_VALIDATE_GSUB 0x0800 -#define FT_VALIDATE_JSTF 0x1000 -#define FT_VALIDATE_MATH 0x2000 - -#define FT_VALIDATE_OT FT_VALIDATE_BASE | \ - FT_VALIDATE_GDEF | \ - FT_VALIDATE_GPOS | \ - FT_VALIDATE_GSUB | \ - FT_VALIDATE_JSTF | \ - FT_VALIDATE_MATH - - /********************************************************************** - * - * @function: - * FT_OpenType_Validate - * - * @description: - * Validate various OpenType tables to assure that all offsets and - * indices are valid. The idea is that a higher-level library that - * actually does the text layout can access those tables without - * error checking (which can be quite time consuming). - * - * @input: - * face :: - * A handle to the input face. - * - * validation_flags :: - * A bit field that specifies the tables to be validated. See - * @FT_VALIDATE_OTXXX for possible values. - * - * @output: - * BASE_table :: - * A pointer to the BASE table. - * - * GDEF_table :: - * A pointer to the GDEF table. - * - * GPOS_table :: - * A pointer to the GPOS table. - * - * GSUB_table :: - * A pointer to the GSUB table. - * - * JSTF_table :: - * A pointer to the JSTF table. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with OpenType fonts, returning an error - * otherwise. - * - * After use, the application should deallocate the five tables with - * @FT_OpenType_Free. A NULL value indicates that the table either - * doesn't exist in the font, or the application hasn't asked for - * validation. - */ - FT_EXPORT( FT_Error ) - FT_OpenType_Validate( FT_Face face, - FT_UInt validation_flags, - FT_Bytes *BASE_table, - FT_Bytes *GDEF_table, - FT_Bytes *GPOS_table, - FT_Bytes *GSUB_table, - FT_Bytes *JSTF_table ); - - /********************************************************************** - * - * @function: - * FT_OpenType_Free - * - * @description: - * Free the buffer allocated by OpenType validator. - * - * @input: - * face :: - * A handle to the input face. - * - * table :: - * The pointer to the buffer that is allocated by - * @FT_OpenType_Validate. - * - * @note: - * This function must be used to free the buffer allocated by - * @FT_OpenType_Validate only. - */ - FT_EXPORT( void ) - FT_OpenType_Free( FT_Face face, - FT_Bytes table ); - - /* */ - - -FT_END_HEADER - -#endif /* FTOTVAL_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftoutln.h b/android/armeabi/include/freetype/ftoutln.h deleted file mode 100644 index 6a645120..00000000 --- a/android/armeabi/include/freetype/ftoutln.h +++ /dev/null @@ -1,574 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftoutln.h */ -/* */ -/* Support for the FT_Outline type used to store glyph shapes of */ -/* most scalable font formats (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTOUTLN_H_ -#define FTOUTLN_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* outline_processing */ - /* */ - /* <Title> */ - /* Outline Processing */ - /* */ - /* <Abstract> */ - /* Functions to create, transform, and render vectorial glyph images. */ - /* */ - /* <Description> */ - /* This section contains routines used to create and destroy scalable */ - /* glyph images known as `outlines'. These can also be measured, */ - /* transformed, and converted into bitmaps and pixmaps. */ - /* */ - /* <Order> */ - /* FT_Outline */ - /* FT_Outline_New */ - /* FT_Outline_Done */ - /* FT_Outline_Copy */ - /* FT_Outline_Translate */ - /* FT_Outline_Transform */ - /* FT_Outline_Embolden */ - /* FT_Outline_EmboldenXY */ - /* FT_Outline_Reverse */ - /* FT_Outline_Check */ - /* */ - /* FT_Outline_Get_CBox */ - /* FT_Outline_Get_BBox */ - /* */ - /* FT_Outline_Get_Bitmap */ - /* FT_Outline_Render */ - /* FT_Outline_Decompose */ - /* FT_Outline_Funcs */ - /* FT_Outline_MoveToFunc */ - /* FT_Outline_LineToFunc */ - /* FT_Outline_ConicToFunc */ - /* FT_Outline_CubicToFunc */ - /* */ - /* FT_Orientation */ - /* FT_Outline_Get_Orientation */ - /* */ - /* FT_OUTLINE_XXX */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Decompose */ - /* */ - /* <Description> */ - /* Walk over an outline's structure to decompose it into individual */ - /* segments and Bézier arcs. This function also emits `move to' */ - /* operations to indicate the start of new contours in the outline. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source target. */ - /* */ - /* func_interface :: A table of `emitters', i.e., function pointers */ - /* called during decomposition to indicate path */ - /* operations. */ - /* */ - /* <InOut> */ - /* user :: A typeless pointer that is passed to each */ - /* emitter during the decomposition. It can be */ - /* used to store the state during the */ - /* decomposition. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* A contour that contains a single point only is represented by a */ - /* `move to' operation followed by `line to' to the same point. In */ - /* most cases, it is best to filter this out before using the */ - /* outline for stroking purposes (otherwise it would result in a */ - /* visible dot when round caps are used). */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Decompose( FT_Outline* outline, - const FT_Outline_Funcs* func_interface, - void* user ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_New */ - /* */ - /* <Description> */ - /* Create a new outline of a given size. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object from where the */ - /* outline is allocated. Note however that the new */ - /* outline will *not* necessarily be *freed*, when */ - /* destroying the library, by @FT_Done_FreeType. */ - /* */ - /* numPoints :: The maximum number of points within the outline. */ - /* Must be smaller than or equal to 0xFFFF (65535). */ - /* */ - /* numContours :: The maximum number of contours within the outline. */ - /* This value must be in the range 0 to `numPoints'. */ - /* */ - /* <Output> */ - /* anoutline :: A handle to the new outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The reason why this function takes a `library' parameter is simply */ - /* to use the library's memory allocator. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_New( FT_Library library, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline *anoutline ); - - - FT_EXPORT( FT_Error ) - FT_Outline_New_Internal( FT_Memory memory, - FT_UInt numPoints, - FT_Int numContours, - FT_Outline *anoutline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Done */ - /* */ - /* <Description> */ - /* Destroy an outline created with @FT_Outline_New. */ - /* */ - /* <Input> */ - /* library :: A handle of the library object used to allocate the */ - /* outline. */ - /* */ - /* outline :: A pointer to the outline object to be discarded. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If the outline's `owner' field is not set, only the outline */ - /* descriptor will be released. */ - /* */ - /* The reason why this function takes an `library' parameter is */ - /* simply to use ft_mem_free(). */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Done( FT_Library library, - FT_Outline* outline ); - - - FT_EXPORT( FT_Error ) - FT_Outline_Done_Internal( FT_Memory memory, - FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Check */ - /* */ - /* <Description> */ - /* Check the contents of an outline descriptor. */ - /* */ - /* <Input> */ - /* outline :: A handle to a source outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Check( FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_CBox */ - /* */ - /* <Description> */ - /* Return an outline's `control box'. The control box encloses all */ - /* the outline's points, including Bézier control points. Though it */ - /* coincides with the exact bounding box for most glyphs, it can be */ - /* slightly larger in some situations (like when rotating an outline */ - /* that contains Bézier outside arcs). */ - /* */ - /* Computing the control box is very fast, while getting the bounding */ - /* box can take much more time as it needs to walk over all segments */ - /* and arcs in the outline. To get the latter, you can use the */ - /* `ftbbox' component, which is dedicated to this single task. */ - /* */ - /* <Input> */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <Output> */ - /* acbox :: The outline's control box. */ - /* */ - /* <Note> */ - /* See @FT_Glyph_Get_CBox for a discussion of tricky fonts. */ - /* */ - FT_EXPORT( void ) - FT_Outline_Get_CBox( const FT_Outline* outline, - FT_BBox *acbox ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Translate */ - /* */ - /* <Description> */ - /* Apply a simple translation to the points of an outline. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Input> */ - /* xOffset :: The horizontal offset. */ - /* */ - /* yOffset :: The vertical offset. */ - /* */ - FT_EXPORT( void ) - FT_Outline_Translate( const FT_Outline* outline, - FT_Pos xOffset, - FT_Pos yOffset ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Copy */ - /* */ - /* <Description> */ - /* Copy an outline into another one. Both objects must have the */ - /* same sizes (number of points & number of contours) when this */ - /* function is called. */ - /* */ - /* <Input> */ - /* source :: A handle to the source outline. */ - /* */ - /* <Output> */ - /* target :: A handle to the target outline. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Copy( const FT_Outline* source, - FT_Outline *target ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Transform */ - /* */ - /* <Description> */ - /* Apply a simple 2x2 matrix to all of an outline's points. Useful */ - /* for applying rotations, slanting, flipping, etc. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Input> */ - /* matrix :: A pointer to the transformation matrix. */ - /* */ - /* <Note> */ - /* You can use @FT_Outline_Translate if you need to translate the */ - /* outline's points. */ - /* */ - FT_EXPORT( void ) - FT_Outline_Transform( const FT_Outline* outline, - const FT_Matrix* matrix ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Embolden */ - /* */ - /* <Description> */ - /* Embolden an outline. The new outline will be at most 4~times */ - /* `strength' pixels wider and higher. You may think of the left and */ - /* bottom borders as unchanged. */ - /* */ - /* Negative `strength' values to reduce the outline thickness are */ - /* possible also. */ - /* */ - /* <InOut> */ - /* outline :: A handle to the target outline. */ - /* */ - /* <Input> */ - /* strength :: How strong the glyph is emboldened. Expressed in */ - /* 26.6 pixel format. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The used algorithm to increase or decrease the thickness of the */ - /* glyph doesn't change the number of points; this means that certain */ - /* situations like acute angles or intersections are sometimes */ - /* handled incorrectly. */ - /* */ - /* If you need `better' metrics values you should call */ - /* @FT_Outline_Get_CBox or @FT_Outline_Get_BBox. */ - /* */ - /* Example call: */ - /* */ - /* { */ - /* FT_Load_Glyph( face, index, FT_LOAD_DEFAULT ); */ - /* if ( face->glyph->format == FT_GLYPH_FORMAT_OUTLINE ) */ - /* FT_Outline_Embolden( &face->glyph->outline, strength ); */ - /* } */ - /* */ - /* To get meaningful results, font scaling values must be set with */ - /* functions like @FT_Set_Char_Size before calling FT_Render_Glyph. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Embolden( FT_Outline* outline, - FT_Pos strength ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_EmboldenXY */ - /* */ - /* <Description> */ - /* Embolden an outline. The new outline will be `xstrength' pixels */ - /* wider and `ystrength' pixels higher. Otherwise, it is similar to */ - /* @FT_Outline_Embolden, which uses the same strength in both */ - /* directions. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_EmboldenXY( FT_Outline* outline, - FT_Pos xstrength, - FT_Pos ystrength ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Reverse */ - /* */ - /* <Description> */ - /* Reverse the drawing direction of an outline. This is used to */ - /* ensure consistent fill conventions for mirrored glyphs. */ - /* */ - /* <InOut> */ - /* outline :: A pointer to the target outline descriptor. */ - /* */ - /* <Note> */ - /* This function toggles the bit flag @FT_OUTLINE_REVERSE_FILL in */ - /* the outline's `flags' field. */ - /* */ - /* It shouldn't be used by a normal client application, unless it */ - /* knows what it is doing. */ - /* */ - FT_EXPORT( void ) - FT_Outline_Reverse( FT_Outline* outline ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Get_Bitmap */ - /* */ - /* <Description> */ - /* Render an outline within a bitmap. The outline's image is simply */ - /* OR-ed to the target bitmap. */ - /* */ - /* <Input> */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <InOut> */ - /* abitmap :: A pointer to the target bitmap descriptor. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* This function does NOT CREATE the bitmap, it only renders an */ - /* outline image within the one you pass to it! Consequently, the */ - /* various fields in `abitmap' should be set accordingly. */ - /* */ - /* It will use the raster corresponding to the default glyph format. */ - /* */ - /* The value of the `num_grays' field in `abitmap' is ignored. If */ - /* you select the gray-level rasterizer, and you want less than 256 */ - /* gray levels, you have to use @FT_Outline_Render directly. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Get_Bitmap( FT_Library library, - FT_Outline* outline, - const FT_Bitmap *abitmap ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Outline_Render */ - /* */ - /* <Description> */ - /* Render an outline within a bitmap using the current scan-convert. */ - /* This function uses an @FT_Raster_Params structure as an argument, */ - /* allowing advanced features like direct composition, translucency, */ - /* etc. */ - /* */ - /* <Input> */ - /* library :: A handle to a FreeType library object. */ - /* */ - /* outline :: A pointer to the source outline descriptor. */ - /* */ - /* <InOut> */ - /* params :: A pointer to an @FT_Raster_Params structure used to */ - /* describe the rendering operation. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You should know what you are doing and how @FT_Raster_Params works */ - /* to use this function. */ - /* */ - /* The field `params.source' will be set to `outline' before the scan */ - /* converter is called, which means that the value you give to it is */ - /* actually ignored. */ - /* */ - /* The gray-level rasterizer always uses 256 gray levels. If you */ - /* want less gray levels, you have to provide your own span callback. */ - /* See the @FT_RASTER_FLAG_DIRECT value of the `flags' field in the */ - /* @FT_Raster_Params structure for more details. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Outline_Render( FT_Library library, - FT_Outline* outline, - FT_Raster_Params* params ); - - - /************************************************************************** - * - * @enum: - * FT_Orientation - * - * @description: - * A list of values used to describe an outline's contour orientation. - * - * The TrueType and PostScript specifications use different conventions - * to determine whether outline contours should be filled or unfilled. - * - * @values: - * FT_ORIENTATION_TRUETYPE :: - * According to the TrueType specification, clockwise contours must - * be filled, and counter-clockwise ones must be unfilled. - * - * FT_ORIENTATION_POSTSCRIPT :: - * According to the PostScript specification, counter-clockwise contours - * must be filled, and clockwise ones must be unfilled. - * - * FT_ORIENTATION_FILL_RIGHT :: - * This is identical to @FT_ORIENTATION_TRUETYPE, but is used to - * remember that in TrueType, everything that is to the right of - * the drawing direction of a contour must be filled. - * - * FT_ORIENTATION_FILL_LEFT :: - * This is identical to @FT_ORIENTATION_POSTSCRIPT, but is used to - * remember that in PostScript, everything that is to the left of - * the drawing direction of a contour must be filled. - * - * FT_ORIENTATION_NONE :: - * The orientation cannot be determined. That is, different parts of - * the glyph have different orientation. - * - */ - typedef enum FT_Orientation_ - { - FT_ORIENTATION_TRUETYPE = 0, - FT_ORIENTATION_POSTSCRIPT = 1, - FT_ORIENTATION_FILL_RIGHT = FT_ORIENTATION_TRUETYPE, - FT_ORIENTATION_FILL_LEFT = FT_ORIENTATION_POSTSCRIPT, - FT_ORIENTATION_NONE - - } FT_Orientation; - - - /************************************************************************** - * - * @function: - * FT_Outline_Get_Orientation - * - * @description: - * This function analyzes a glyph outline and tries to compute its - * fill orientation (see @FT_Orientation). This is done by integrating - * the total area covered by the outline. The positive integral - * corresponds to the clockwise orientation and @FT_ORIENTATION_POSTSCRIPT - * is returned. The negative integral corresponds to the counter-clockwise - * orientation and @FT_ORIENTATION_TRUETYPE is returned. - * - * Note that this will return @FT_ORIENTATION_TRUETYPE for empty - * outlines. - * - * @input: - * outline :: - * A handle to the source outline. - * - * @return: - * The orientation. - * - */ - FT_EXPORT( FT_Orientation ) - FT_Outline_Get_Orientation( FT_Outline* outline ); - - /* */ - - -FT_END_HEADER - -#endif /* FTOUTLN_H_ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/android/armeabi/include/freetype/ftpfr.h b/android/armeabi/include/freetype/ftpfr.h deleted file mode 100644 index 2e1bff2f..00000000 --- a/android/armeabi/include/freetype/ftpfr.h +++ /dev/null @@ -1,172 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftpfr.h */ -/* */ -/* FreeType API for accessing PFR-specific data (specification only). */ -/* */ -/* Copyright 2002-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTPFR_H_ -#define FTPFR_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* pfr_fonts */ - /* */ - /* <Title> */ - /* PFR Fonts */ - /* */ - /* <Abstract> */ - /* PFR/TrueDoc specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of PFR-specific functions. */ - /* */ - /*************************************************************************/ - - - /********************************************************************** - * - * @function: - * FT_Get_PFR_Metrics - * - * @description: - * Return the outline and metrics resolutions of a given PFR face. - * - * @input: - * face :: Handle to the input face. It can be a non-PFR face. - * - * @output: - * aoutline_resolution :: - * Outline resolution. This is equivalent to `face->units_per_EM' - * for non-PFR fonts. Optional (parameter can be NULL). - * - * ametrics_resolution :: - * Metrics resolution. This is equivalent to `outline_resolution' - * for non-PFR fonts. Optional (parameter can be NULL). - * - * ametrics_x_scale :: - * A 16.16 fixed-point number used to scale distance expressed - * in metrics units to device sub-pixels. This is equivalent to - * `face->size->x_scale', but for metrics only. Optional (parameter - * can be NULL). - * - * ametrics_y_scale :: - * Same as `ametrics_x_scale' but for the vertical direction. - * optional (parameter can be NULL). - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If the input face is not a PFR, this function will return an error. - * However, in all cases, it will return valid values. - */ - FT_EXPORT( FT_Error ) - FT_Get_PFR_Metrics( FT_Face face, - FT_UInt *aoutline_resolution, - FT_UInt *ametrics_resolution, - FT_Fixed *ametrics_x_scale, - FT_Fixed *ametrics_y_scale ); - - - /********************************************************************** - * - * @function: - * FT_Get_PFR_Kerning - * - * @description: - * Return the kerning pair corresponding to two glyphs in a PFR face. - * The distance is expressed in metrics units, unlike the result of - * @FT_Get_Kerning. - * - * @input: - * face :: A handle to the input face. - * - * left :: Index of the left glyph. - * - * right :: Index of the right glyph. - * - * @output: - * avector :: A kerning vector. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function always return distances in original PFR metrics - * units. This is unlike @FT_Get_Kerning with the @FT_KERNING_UNSCALED - * mode, which always returns distances converted to outline units. - * - * You can use the value of the `x_scale' and `y_scale' parameters - * returned by @FT_Get_PFR_Metrics to scale these to device sub-pixels. - */ - FT_EXPORT( FT_Error ) - FT_Get_PFR_Kerning( FT_Face face, - FT_UInt left, - FT_UInt right, - FT_Vector *avector ); - - - /********************************************************************** - * - * @function: - * FT_Get_PFR_Advance - * - * @description: - * Return a given glyph advance, expressed in original metrics units, - * from a PFR font. - * - * @input: - * face :: A handle to the input face. - * - * gindex :: The glyph index. - * - * @output: - * aadvance :: The glyph advance in metrics units. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You can use the `x_scale' or `y_scale' results of @FT_Get_PFR_Metrics - * to convert the advance to device sub-pixels (i.e., 1/64th of pixels). - */ - FT_EXPORT( FT_Error ) - FT_Get_PFR_Advance( FT_Face face, - FT_UInt gindex, - FT_Pos *aadvance ); - - /* */ - - -FT_END_HEADER - -#endif /* FTPFR_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftrender.h b/android/armeabi/include/freetype/ftrender.h deleted file mode 100644 index 9f7ed9e9..00000000 --- a/android/armeabi/include/freetype/ftrender.h +++ /dev/null @@ -1,232 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftrender.h */ -/* */ -/* FreeType renderer modules public interface (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTRENDER_H_ -#define FTRENDER_H_ - - -#include <ft2build.h> -#include FT_MODULE_H -#include FT_GLYPH_H - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* module_management */ - /* */ - /*************************************************************************/ - - - /* create a new glyph object */ - typedef FT_Error - (*FT_Glyph_InitFunc)( FT_Glyph glyph, - FT_GlyphSlot slot ); - - /* destroys a given glyph object */ - typedef void - (*FT_Glyph_DoneFunc)( FT_Glyph glyph ); - - typedef void - (*FT_Glyph_TransformFunc)( FT_Glyph glyph, - const FT_Matrix* matrix, - const FT_Vector* delta ); - - typedef void - (*FT_Glyph_GetBBoxFunc)( FT_Glyph glyph, - FT_BBox* abbox ); - - typedef FT_Error - (*FT_Glyph_CopyFunc)( FT_Glyph source, - FT_Glyph target ); - - typedef FT_Error - (*FT_Glyph_PrepareFunc)( FT_Glyph glyph, - FT_GlyphSlot slot ); - -/* deprecated */ -#define FT_Glyph_Init_Func FT_Glyph_InitFunc -#define FT_Glyph_Done_Func FT_Glyph_DoneFunc -#define FT_Glyph_Transform_Func FT_Glyph_TransformFunc -#define FT_Glyph_BBox_Func FT_Glyph_GetBBoxFunc -#define FT_Glyph_Copy_Func FT_Glyph_CopyFunc -#define FT_Glyph_Prepare_Func FT_Glyph_PrepareFunc - - - struct FT_Glyph_Class_ - { - FT_Long glyph_size; - FT_Glyph_Format glyph_format; - FT_Glyph_InitFunc glyph_init; - FT_Glyph_DoneFunc glyph_done; - FT_Glyph_CopyFunc glyph_copy; - FT_Glyph_TransformFunc glyph_transform; - FT_Glyph_GetBBoxFunc glyph_bbox; - FT_Glyph_PrepareFunc glyph_prepare; - }; - - - typedef FT_Error - (*FT_Renderer_RenderFunc)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_UInt mode, - const FT_Vector* origin ); - - typedef FT_Error - (*FT_Renderer_TransformFunc)( FT_Renderer renderer, - FT_GlyphSlot slot, - const FT_Matrix* matrix, - const FT_Vector* delta ); - - - typedef void - (*FT_Renderer_GetCBoxFunc)( FT_Renderer renderer, - FT_GlyphSlot slot, - FT_BBox* cbox ); - - - typedef FT_Error - (*FT_Renderer_SetModeFunc)( FT_Renderer renderer, - FT_ULong mode_tag, - FT_Pointer mode_ptr ); - -/* deprecated identifiers */ -#define FTRenderer_render FT_Renderer_RenderFunc -#define FTRenderer_transform FT_Renderer_TransformFunc -#define FTRenderer_getCBox FT_Renderer_GetCBoxFunc -#define FTRenderer_setMode FT_Renderer_SetModeFunc - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Renderer_Class */ - /* */ - /* <Description> */ - /* The renderer module class descriptor. */ - /* */ - /* <Fields> */ - /* root :: The root @FT_Module_Class fields. */ - /* */ - /* glyph_format :: The glyph image format this renderer handles. */ - /* */ - /* render_glyph :: A method used to render the image that is in a */ - /* given glyph slot into a bitmap. */ - /* */ - /* transform_glyph :: A method used to transform the image that is in */ - /* a given glyph slot. */ - /* */ - /* get_glyph_cbox :: A method used to access the glyph's cbox. */ - /* */ - /* set_mode :: A method used to pass additional parameters. */ - /* */ - /* raster_class :: For @FT_GLYPH_FORMAT_OUTLINE renderers only. */ - /* This is a pointer to its raster's class. */ - /* */ - typedef struct FT_Renderer_Class_ - { - FT_Module_Class root; - - FT_Glyph_Format glyph_format; - - FT_Renderer_RenderFunc render_glyph; - FT_Renderer_TransformFunc transform_glyph; - FT_Renderer_GetCBoxFunc get_glyph_cbox; - FT_Renderer_SetModeFunc set_mode; - - FT_Raster_Funcs* raster_class; - - } FT_Renderer_Class; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Renderer */ - /* */ - /* <Description> */ - /* Retrieve the current renderer for a given glyph format. */ - /* */ - /* <Input> */ - /* library :: A handle to the library object. */ - /* */ - /* format :: The glyph format. */ - /* */ - /* <Return> */ - /* A renderer handle. 0~if none found. */ - /* */ - /* <Note> */ - /* An error will be returned if a module already exists by that name, */ - /* or if the module requires a version of FreeType that is too great. */ - /* */ - /* To add a new renderer, simply use @FT_Add_Module. To retrieve a */ - /* renderer by its name, use @FT_Get_Module. */ - /* */ - FT_EXPORT( FT_Renderer ) - FT_Get_Renderer( FT_Library library, - FT_Glyph_Format format ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Set_Renderer */ - /* */ - /* <Description> */ - /* Set the current renderer to use, and set additional mode. */ - /* */ - /* <InOut> */ - /* library :: A handle to the library object. */ - /* */ - /* <Input> */ - /* renderer :: A handle to the renderer object. */ - /* */ - /* num_params :: The number of additional parameters. */ - /* */ - /* parameters :: Additional parameters. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* In case of success, the renderer will be used to convert glyph */ - /* images in the renderer's known format into bitmaps. */ - /* */ - /* This doesn't change the current renderer for other formats. */ - /* */ - /* Currently, no FreeType renderer module uses `parameters'; you */ - /* should thus always pass NULL as the value. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Set_Renderer( FT_Library library, - FT_Renderer renderer, - FT_UInt num_params, - FT_Parameter* parameters ); - - /* */ - - -FT_END_HEADER - -#endif /* FTRENDER_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftsizes.h b/android/armeabi/include/freetype/ftsizes.h deleted file mode 100644 index 55e0d5cc..00000000 --- a/android/armeabi/include/freetype/ftsizes.h +++ /dev/null @@ -1,159 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftsizes.h */ -/* */ -/* FreeType size objects management (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /* */ - /* Typical application would normally not need to use these functions. */ - /* However, they have been placed in a public API for the rare cases */ - /* where they are needed. */ - /* */ - /*************************************************************************/ - - -#ifndef FTSIZES_H_ -#define FTSIZES_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* sizes_management */ - /* */ - /* <Title> */ - /* Size Management */ - /* */ - /* <Abstract> */ - /* Managing multiple sizes per face. */ - /* */ - /* <Description> */ - /* When creating a new face object (e.g., with @FT_New_Face), an */ - /* @FT_Size object is automatically created and used to store all */ - /* pixel-size dependent information, available in the `face->size' */ - /* field. */ - /* */ - /* It is however possible to create more sizes for a given face, */ - /* mostly in order to manage several character pixel sizes of the */ - /* same font family and style. See @FT_New_Size and @FT_Done_Size. */ - /* */ - /* Note that @FT_Set_Pixel_Sizes and @FT_Set_Char_Size only */ - /* modify the contents of the current `active' size; you thus need */ - /* to use @FT_Activate_Size to change it. */ - /* */ - /* 99% of applications won't need the functions provided here, */ - /* especially if they use the caching sub-system, so be cautious */ - /* when using these. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_New_Size */ - /* */ - /* <Description> */ - /* Create a new size object from a given face object. */ - /* */ - /* <Input> */ - /* face :: A handle to a parent face object. */ - /* */ - /* <Output> */ - /* asize :: A handle to a new size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* You need to call @FT_Activate_Size in order to select the new size */ - /* for upcoming calls to @FT_Set_Pixel_Sizes, @FT_Set_Char_Size, */ - /* @FT_Load_Glyph, @FT_Load_Char, etc. */ - /* */ - FT_EXPORT( FT_Error ) - FT_New_Size( FT_Face face, - FT_Size* size ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Done_Size */ - /* */ - /* <Description> */ - /* Discard a given size object. Note that @FT_Done_Face */ - /* automatically discards all size objects allocated with */ - /* @FT_New_Size. */ - /* */ - /* <Input> */ - /* size :: A handle to a target size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Done_Size( FT_Size size ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Activate_Size */ - /* */ - /* <Description> */ - /* Even though it is possible to create several size objects for a */ - /* given face (see @FT_New_Size for details), functions like */ - /* @FT_Load_Glyph or @FT_Load_Char only use the one that has been */ - /* activated last to determine the `current character pixel size'. */ - /* */ - /* This function can be used to `activate' a previously created size */ - /* object. */ - /* */ - /* <Input> */ - /* size :: A handle to a target size object. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* If `face' is the size's parent face object, this function changes */ - /* the value of `face->size' to the input size handle. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Activate_Size( FT_Size size ); - - /* */ - - -FT_END_HEADER - -#endif /* FTSIZES_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftsnames.h b/android/armeabi/include/freetype/ftsnames.h deleted file mode 100644 index a7b51c2c..00000000 --- a/android/armeabi/include/freetype/ftsnames.h +++ /dev/null @@ -1,200 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftsnames.h */ -/* */ -/* Simple interface to access SFNT name tables (which are used */ -/* to hold font names, copyright info, notices, etc.) (specification). */ -/* */ -/* This is _not_ used to retrieve glyph names! */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTSNAMES_H_ -#define FTSNAMES_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* sfnt_names */ - /* */ - /* <Title> */ - /* SFNT Names */ - /* */ - /* <Abstract> */ - /* Access the names embedded in TrueType and OpenType files. */ - /* */ - /* <Description> */ - /* The TrueType and OpenType specifications allow the inclusion of */ - /* a special `names table' in font files. This table contains */ - /* textual (and internationalized) information regarding the font, */ - /* like family name, copyright, version, etc. */ - /* */ - /* The definitions below are used to access them if available. */ - /* */ - /* Note that this has nothing to do with glyph names! */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_SfntName */ - /* */ - /* <Description> */ - /* A structure used to model an SFNT `name' table entry. */ - /* */ - /* <Fields> */ - /* platform_id :: The platform ID for `string'. */ - /* */ - /* encoding_id :: The encoding ID for `string'. */ - /* */ - /* language_id :: The language ID for `string'. */ - /* */ - /* name_id :: An identifier for `string'. */ - /* */ - /* string :: The `name' string. Note that its format differs */ - /* depending on the (platform,encoding) pair. It can */ - /* be a Pascal String, a UTF-16 one, etc. */ - /* */ - /* Generally speaking, the string is not */ - /* zero-terminated. Please refer to the TrueType */ - /* specification for details. */ - /* */ - /* string_len :: The length of `string' in bytes. */ - /* */ - /* <Note> */ - /* Possible values for `platform_id', `encoding_id', `language_id', */ - /* and `name_id' are given in the file `ttnameid.h'. For details */ - /* please refer to the TrueType or OpenType specification. */ - /* */ - /* See also @TT_PLATFORM_XXX, @TT_APPLE_ID_XXX, @TT_MAC_ID_XXX, */ - /* @TT_ISO_ID_XXX, and @TT_MS_ID_XXX. */ - /* */ - typedef struct FT_SfntName_ - { - FT_UShort platform_id; - FT_UShort encoding_id; - FT_UShort language_id; - FT_UShort name_id; - - FT_Byte* string; /* this string is *not* null-terminated! */ - FT_UInt string_len; /* in bytes */ - - } FT_SfntName; - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Name_Count */ - /* */ - /* <Description> */ - /* Retrieve the number of name strings in the SFNT `name' table. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* <Return> */ - /* The number of strings in the `name' table. */ - /* */ - FT_EXPORT( FT_UInt ) - FT_Get_Sfnt_Name_Count( FT_Face face ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Name */ - /* */ - /* <Description> */ - /* Retrieve a string of the SFNT `name' table for a given index. */ - /* */ - /* <Input> */ - /* face :: A handle to the source face. */ - /* */ - /* idx :: The index of the `name' string. */ - /* */ - /* <Output> */ - /* aname :: The indexed @FT_SfntName structure. */ - /* */ - /* <Return> */ - /* FreeType error code. 0~means success. */ - /* */ - /* <Note> */ - /* The `string' array returned in the `aname' structure is not */ - /* null-terminated. The application should deallocate it if it is no */ - /* longer in use. */ - /* */ - /* Use @FT_Get_Sfnt_Name_Count to get the total number of available */ - /* `name' table entries, then do a loop until you get the right */ - /* platform, encoding, and name ID. */ - /* */ - FT_EXPORT( FT_Error ) - FT_Get_Sfnt_Name( FT_Face face, - FT_UInt idx, - FT_SfntName *aname ); - - - /*************************************************************************** - * - * @constant: - * FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY - * - * @description: - * A constant used as the tag of @FT_Parameter structures to make - * FT_Open_Face() ignore preferred family subfamily names in `name' - * table since OpenType version 1.4. For backwards compatibility with - * legacy systems that have a 4-face-per-family restriction. - * - */ -#define FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY FT_MAKE_TAG( 'i', 'g', 'p', 'f' ) - - - /*************************************************************************** - * - * @constant: - * FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY - * - * @description: - * A constant used as the tag of @FT_Parameter structures to make - * FT_Open_Face() ignore preferred subfamily names in `name' table since - * OpenType version 1.4. For backwards compatibility with legacy - * systems that have a 4-face-per-family restriction. - * - */ -#define FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY FT_MAKE_TAG( 'i', 'g', 'p', 's' ) - - /* */ - - -FT_END_HEADER - -#endif /* FTSNAMES_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftstroke.h b/android/armeabi/include/freetype/ftstroke.h deleted file mode 100644 index b3b9922d..00000000 --- a/android/armeabi/include/freetype/ftstroke.h +++ /dev/null @@ -1,785 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftstroke.h */ -/* */ -/* FreeType path stroker (specification). */ -/* */ -/* Copyright 2002-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTSTROKE_H_ -#define FTSTROKE_H_ - -#include <ft2build.h> -#include FT_OUTLINE_H -#include FT_GLYPH_H - - -FT_BEGIN_HEADER - - - /************************************************************************ - * - * @section: - * glyph_stroker - * - * @title: - * Glyph Stroker - * - * @abstract: - * Generating bordered and stroked glyphs. - * - * @description: - * This component generates stroked outlines of a given vectorial - * glyph. It also allows you to retrieve the `outside' and/or the - * `inside' borders of the stroke. - * - * This can be useful to generate `bordered' glyph, i.e., glyphs - * displayed with a coloured (and anti-aliased) border around their - * shape. - * - * @order: - * FT_Stroker - * - * FT_Stroker_LineJoin - * FT_Stroker_LineCap - * FT_StrokerBorder - * - * FT_Outline_GetInsideBorder - * FT_Outline_GetOutsideBorder - * - * FT_Glyph_Stroke - * FT_Glyph_StrokeBorder - * - * FT_Stroker_New - * FT_Stroker_Set - * FT_Stroker_Rewind - * FT_Stroker_ParseOutline - * FT_Stroker_Done - * - * FT_Stroker_BeginSubPath - * FT_Stroker_EndSubPath - * - * FT_Stroker_LineTo - * FT_Stroker_ConicTo - * FT_Stroker_CubicTo - * - * FT_Stroker_GetBorderCounts - * FT_Stroker_ExportBorder - * FT_Stroker_GetCounts - * FT_Stroker_Export - * - */ - - - /************************************************************** - * - * @type: - * FT_Stroker - * - * @description: - * Opaque handle to a path stroker object. - */ - typedef struct FT_StrokerRec_* FT_Stroker; - - - /************************************************************** - * - * @enum: - * FT_Stroker_LineJoin - * - * @description: - * These values determine how two joining lines are rendered - * in a stroker. - * - * @values: - * FT_STROKER_LINEJOIN_ROUND :: - * Used to render rounded line joins. Circular arcs are used - * to join two lines smoothly. - * - * FT_STROKER_LINEJOIN_BEVEL :: - * Used to render beveled line joins. The outer corner of - * the joined lines is filled by enclosing the triangular - * region of the corner with a straight line between the - * outer corners of each stroke. - * - * FT_STROKER_LINEJOIN_MITER_FIXED :: - * Used to render mitered line joins, with fixed bevels if the - * miter limit is exceeded. The outer edges of the strokes - * for the two segments are extended until they meet at an - * angle. If the segments meet at too sharp an angle (such - * that the miter would extend from the intersection of the - * segments a distance greater than the product of the miter - * limit value and the border radius), then a bevel join (see - * above) is used instead. This prevents long spikes being - * created. FT_STROKER_LINEJOIN_MITER_FIXED generates a miter - * line join as used in PostScript and PDF. - * - * FT_STROKER_LINEJOIN_MITER_VARIABLE :: - * FT_STROKER_LINEJOIN_MITER :: - * Used to render mitered line joins, with variable bevels if - * the miter limit is exceeded. The intersection of the - * strokes is clipped at a line perpendicular to the bisector - * of the angle between the strokes, at the distance from the - * intersection of the segments equal to the product of the - * miter limit value and the border radius. This prevents - * long spikes being created. - * FT_STROKER_LINEJOIN_MITER_VARIABLE generates a mitered line - * join as used in XPS. FT_STROKER_LINEJOIN_MITER is an alias - * for FT_STROKER_LINEJOIN_MITER_VARIABLE, retained for - * backwards compatibility. - */ - typedef enum FT_Stroker_LineJoin_ - { - FT_STROKER_LINEJOIN_ROUND = 0, - FT_STROKER_LINEJOIN_BEVEL = 1, - FT_STROKER_LINEJOIN_MITER_VARIABLE = 2, - FT_STROKER_LINEJOIN_MITER = FT_STROKER_LINEJOIN_MITER_VARIABLE, - FT_STROKER_LINEJOIN_MITER_FIXED = 3 - - } FT_Stroker_LineJoin; - - - /************************************************************** - * - * @enum: - * FT_Stroker_LineCap - * - * @description: - * These values determine how the end of opened sub-paths are - * rendered in a stroke. - * - * @values: - * FT_STROKER_LINECAP_BUTT :: - * The end of lines is rendered as a full stop on the last - * point itself. - * - * FT_STROKER_LINECAP_ROUND :: - * The end of lines is rendered as a half-circle around the - * last point. - * - * FT_STROKER_LINECAP_SQUARE :: - * The end of lines is rendered as a square around the - * last point. - */ - typedef enum FT_Stroker_LineCap_ - { - FT_STROKER_LINECAP_BUTT = 0, - FT_STROKER_LINECAP_ROUND, - FT_STROKER_LINECAP_SQUARE - - } FT_Stroker_LineCap; - - - /************************************************************** - * - * @enum: - * FT_StrokerBorder - * - * @description: - * These values are used to select a given stroke border - * in @FT_Stroker_GetBorderCounts and @FT_Stroker_ExportBorder. - * - * @values: - * FT_STROKER_BORDER_LEFT :: - * Select the left border, relative to the drawing direction. - * - * FT_STROKER_BORDER_RIGHT :: - * Select the right border, relative to the drawing direction. - * - * @note: - * Applications are generally interested in the `inside' and `outside' - * borders. However, there is no direct mapping between these and the - * `left' and `right' ones, since this really depends on the glyph's - * drawing orientation, which varies between font formats. - * - * You can however use @FT_Outline_GetInsideBorder and - * @FT_Outline_GetOutsideBorder to get these. - */ - typedef enum FT_StrokerBorder_ - { - FT_STROKER_BORDER_LEFT = 0, - FT_STROKER_BORDER_RIGHT - - } FT_StrokerBorder; - - - /************************************************************** - * - * @function: - * FT_Outline_GetInsideBorder - * - * @description: - * Retrieve the @FT_StrokerBorder value corresponding to the - * `inside' borders of a given outline. - * - * @input: - * outline :: - * The source outline handle. - * - * @return: - * The border index. @FT_STROKER_BORDER_RIGHT for empty or invalid - * outlines. - */ - FT_EXPORT( FT_StrokerBorder ) - FT_Outline_GetInsideBorder( FT_Outline* outline ); - - - /************************************************************** - * - * @function: - * FT_Outline_GetOutsideBorder - * - * @description: - * Retrieve the @FT_StrokerBorder value corresponding to the - * `outside' borders of a given outline. - * - * @input: - * outline :: - * The source outline handle. - * - * @return: - * The border index. @FT_STROKER_BORDER_LEFT for empty or invalid - * outlines. - */ - FT_EXPORT( FT_StrokerBorder ) - FT_Outline_GetOutsideBorder( FT_Outline* outline ); - - - /************************************************************** - * - * @function: - * FT_Stroker_New - * - * @description: - * Create a new stroker object. - * - * @input: - * library :: - * FreeType library handle. - * - * @output: - * astroker :: - * A new stroker object handle. NULL in case of error. - * - * @return: - * FreeType error code. 0~means success. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_New( FT_Library library, - FT_Stroker *astroker ); - - - /************************************************************** - * - * @function: - * FT_Stroker_Set - * - * @description: - * Reset a stroker object's attributes. - * - * @input: - * stroker :: - * The target stroker handle. - * - * radius :: - * The border radius. - * - * line_cap :: - * The line cap style. - * - * line_join :: - * The line join style. - * - * miter_limit :: - * The miter limit for the FT_STROKER_LINEJOIN_MITER_FIXED and - * FT_STROKER_LINEJOIN_MITER_VARIABLE line join styles, - * expressed as 16.16 fixed-point value. - * - * @note: - * The radius is expressed in the same units as the outline - * coordinates. - * - * This function calls @FT_Stroker_Rewind automatically. - */ - FT_EXPORT( void ) - FT_Stroker_Set( FT_Stroker stroker, - FT_Fixed radius, - FT_Stroker_LineCap line_cap, - FT_Stroker_LineJoin line_join, - FT_Fixed miter_limit ); - - - /************************************************************** - * - * @function: - * FT_Stroker_Rewind - * - * @description: - * Reset a stroker object without changing its attributes. - * You should call this function before beginning a new - * series of calls to @FT_Stroker_BeginSubPath or - * @FT_Stroker_EndSubPath. - * - * @input: - * stroker :: - * The target stroker handle. - */ - FT_EXPORT( void ) - FT_Stroker_Rewind( FT_Stroker stroker ); - - - /************************************************************** - * - * @function: - * FT_Stroker_ParseOutline - * - * @description: - * A convenience function used to parse a whole outline with - * the stroker. The resulting outline(s) can be retrieved - * later by functions like @FT_Stroker_GetCounts and @FT_Stroker_Export. - * - * @input: - * stroker :: - * The target stroker handle. - * - * outline :: - * The source outline. - * - * opened :: - * A boolean. If~1, the outline is treated as an open path instead - * of a closed one. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If `opened' is~0 (the default), the outline is treated as a closed - * path, and the stroker generates two distinct `border' outlines. - * - * If `opened' is~1, the outline is processed as an open path, and the - * stroker generates a single `stroke' outline. - * - * This function calls @FT_Stroker_Rewind automatically. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_ParseOutline( FT_Stroker stroker, - FT_Outline* outline, - FT_Bool opened ); - - - /************************************************************** - * - * @function: - * FT_Stroker_BeginSubPath - * - * @description: - * Start a new sub-path in the stroker. - * - * @input: - * stroker :: - * The target stroker handle. - * - * to :: - * A pointer to the start vector. - * - * open :: - * A boolean. If~1, the sub-path is treated as an open one. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function is useful when you need to stroke a path that is - * not stored as an @FT_Outline object. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_BeginSubPath( FT_Stroker stroker, - FT_Vector* to, - FT_Bool open ); - - - /************************************************************** - * - * @function: - * FT_Stroker_EndSubPath - * - * @description: - * Close the current sub-path in the stroker. - * - * @input: - * stroker :: - * The target stroker handle. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You should call this function after @FT_Stroker_BeginSubPath. - * If the subpath was not `opened', this function `draws' a - * single line segment to the start position when needed. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_EndSubPath( FT_Stroker stroker ); - - - /************************************************************** - * - * @function: - * FT_Stroker_LineTo - * - * @description: - * `Draw' a single line segment in the stroker's current sub-path, - * from the last position. - * - * @input: - * stroker :: - * The target stroker handle. - * - * to :: - * A pointer to the destination point. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You should call this function between @FT_Stroker_BeginSubPath and - * @FT_Stroker_EndSubPath. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_LineTo( FT_Stroker stroker, - FT_Vector* to ); - - - /************************************************************** - * - * @function: - * FT_Stroker_ConicTo - * - * @description: - * `Draw' a single quadratic Bézier in the stroker's current sub-path, - * from the last position. - * - * @input: - * stroker :: - * The target stroker handle. - * - * control :: - * A pointer to a Bézier control point. - * - * to :: - * A pointer to the destination point. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You should call this function between @FT_Stroker_BeginSubPath and - * @FT_Stroker_EndSubPath. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_ConicTo( FT_Stroker stroker, - FT_Vector* control, - FT_Vector* to ); - - - /************************************************************** - * - * @function: - * FT_Stroker_CubicTo - * - * @description: - * `Draw' a single cubic Bézier in the stroker's current sub-path, - * from the last position. - * - * @input: - * stroker :: - * The target stroker handle. - * - * control1 :: - * A pointer to the first Bézier control point. - * - * control2 :: - * A pointer to second Bézier control point. - * - * to :: - * A pointer to the destination point. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * You should call this function between @FT_Stroker_BeginSubPath and - * @FT_Stroker_EndSubPath. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_CubicTo( FT_Stroker stroker, - FT_Vector* control1, - FT_Vector* control2, - FT_Vector* to ); - - - /************************************************************** - * - * @function: - * FT_Stroker_GetBorderCounts - * - * @description: - * Call this function once you have finished parsing your paths - * with the stroker. It returns the number of points and - * contours necessary to export one of the `border' or `stroke' - * outlines generated by the stroker. - * - * @input: - * stroker :: - * The target stroker handle. - * - * border :: - * The border index. - * - * @output: - * anum_points :: - * The number of points. - * - * anum_contours :: - * The number of contours. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * When an outline, or a sub-path, is `closed', the stroker generates - * two independent `border' outlines, named `left' and `right'. - * - * When the outline, or a sub-path, is `opened', the stroker merges - * the `border' outlines with caps. The `left' border receives all - * points, while the `right' border becomes empty. - * - * Use the function @FT_Stroker_GetCounts instead if you want to - * retrieve the counts associated to both borders. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_GetBorderCounts( FT_Stroker stroker, - FT_StrokerBorder border, - FT_UInt *anum_points, - FT_UInt *anum_contours ); - - - /************************************************************** - * - * @function: - * FT_Stroker_ExportBorder - * - * @description: - * Call this function after @FT_Stroker_GetBorderCounts to - * export the corresponding border to your own @FT_Outline - * structure. - * - * Note that this function appends the border points and - * contours to your outline, but does not try to resize its - * arrays. - * - * @input: - * stroker :: - * The target stroker handle. - * - * border :: - * The border index. - * - * outline :: - * The target outline handle. - * - * @note: - * Always call this function after @FT_Stroker_GetBorderCounts to - * get sure that there is enough room in your @FT_Outline object to - * receive all new data. - * - * When an outline, or a sub-path, is `closed', the stroker generates - * two independent `border' outlines, named `left' and `right'. - * - * When the outline, or a sub-path, is `opened', the stroker merges - * the `border' outlines with caps. The `left' border receives all - * points, while the `right' border becomes empty. - * - * Use the function @FT_Stroker_Export instead if you want to - * retrieve all borders at once. - */ - FT_EXPORT( void ) - FT_Stroker_ExportBorder( FT_Stroker stroker, - FT_StrokerBorder border, - FT_Outline* outline ); - - - /************************************************************** - * - * @function: - * FT_Stroker_GetCounts - * - * @description: - * Call this function once you have finished parsing your paths - * with the stroker. It returns the number of points and - * contours necessary to export all points/borders from the stroked - * outline/path. - * - * @input: - * stroker :: - * The target stroker handle. - * - * @output: - * anum_points :: - * The number of points. - * - * anum_contours :: - * The number of contours. - * - * @return: - * FreeType error code. 0~means success. - */ - FT_EXPORT( FT_Error ) - FT_Stroker_GetCounts( FT_Stroker stroker, - FT_UInt *anum_points, - FT_UInt *anum_contours ); - - - /************************************************************** - * - * @function: - * FT_Stroker_Export - * - * @description: - * Call this function after @FT_Stroker_GetBorderCounts to - * export all borders to your own @FT_Outline structure. - * - * Note that this function appends the border points and - * contours to your outline, but does not try to resize its - * arrays. - * - * @input: - * stroker :: - * The target stroker handle. - * - * outline :: - * The target outline handle. - */ - FT_EXPORT( void ) - FT_Stroker_Export( FT_Stroker stroker, - FT_Outline* outline ); - - - /************************************************************** - * - * @function: - * FT_Stroker_Done - * - * @description: - * Destroy a stroker object. - * - * @input: - * stroker :: - * A stroker handle. Can be NULL. - */ - FT_EXPORT( void ) - FT_Stroker_Done( FT_Stroker stroker ); - - - /************************************************************** - * - * @function: - * FT_Glyph_Stroke - * - * @description: - * Stroke a given outline glyph object with a given stroker. - * - * @inout: - * pglyph :: - * Source glyph handle on input, new glyph handle on output. - * - * @input: - * stroker :: - * A stroker handle. - * - * destroy :: - * A Boolean. If~1, the source glyph object is destroyed - * on success. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source glyph is untouched in case of error. - * - * Adding stroke may yield a significantly wider and taller glyph - * depending on how large of a radius was used to stroke the glyph. You - * may need to manually adjust horizontal and vertical advance amounts - * to account for this added size. - */ - FT_EXPORT( FT_Error ) - FT_Glyph_Stroke( FT_Glyph *pglyph, - FT_Stroker stroker, - FT_Bool destroy ); - - - /************************************************************** - * - * @function: - * FT_Glyph_StrokeBorder - * - * @description: - * Stroke a given outline glyph object with a given stroker, but - * only return either its inside or outside border. - * - * @inout: - * pglyph :: - * Source glyph handle on input, new glyph handle on output. - * - * @input: - * stroker :: - * A stroker handle. - * - * inside :: - * A Boolean. If~1, return the inside border, otherwise - * the outside border. - * - * destroy :: - * A Boolean. If~1, the source glyph object is destroyed - * on success. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The source glyph is untouched in case of error. - * - * Adding stroke may yield a significantly wider and taller glyph - * depending on how large of a radius was used to stroke the glyph. You - * may need to manually adjust horizontal and vertical advance amounts - * to account for this added size. - */ - FT_EXPORT( FT_Error ) - FT_Glyph_StrokeBorder( FT_Glyph *pglyph, - FT_Stroker stroker, - FT_Bool inside, - FT_Bool destroy ); - - /* */ - -FT_END_HEADER - -#endif /* FTSTROKE_H_ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/android/armeabi/include/freetype/ftsynth.h b/android/armeabi/include/freetype/ftsynth.h deleted file mode 100644 index fdfcb691..00000000 --- a/android/armeabi/include/freetype/ftsynth.h +++ /dev/null @@ -1,84 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftsynth.h */ -/* */ -/* FreeType synthesizing code for emboldening and slanting */ -/* (specification). */ -/* */ -/* Copyright 2000-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /********* *********/ - /********* WARNING, THIS IS ALPHA CODE! THIS API *********/ - /********* IS DUE TO CHANGE UNTIL STRICTLY NOTIFIED BY THE *********/ - /********* FREETYPE DEVELOPMENT TEAM *********/ - /********* *********/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - /*************************************************************************/ - - - /* Main reason for not lifting the functions in this module to a */ - /* `standard' API is that the used parameters for emboldening and */ - /* slanting are not configurable. Consider the functions as a */ - /* code resource that should be copied into the application and */ - /* adapted to the particular needs. */ - - -#ifndef FTSYNTH_H_ -#define FTSYNTH_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /* Embolden a glyph by a `reasonable' value (which is highly a matter of */ - /* taste). This function is actually a convenience function, providing */ - /* a wrapper for @FT_Outline_Embolden and @FT_Bitmap_Embolden. */ - /* */ - /* For emboldened outlines the height, width, and advance metrics are */ - /* increased by the strength of the emboldening -- this even affects */ - /* mono-width fonts! */ - /* */ - /* You can also call @FT_Outline_Get_CBox to get precise values. */ - FT_EXPORT( void ) - FT_GlyphSlot_Embolden( FT_GlyphSlot slot ); - - /* Slant an outline glyph to the right by about 12 degrees. */ - FT_EXPORT( void ) - FT_GlyphSlot_Oblique( FT_GlyphSlot slot ); - - /* */ - - -FT_END_HEADER - -#endif /* FTSYNTH_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftsystem.h b/android/armeabi/include/freetype/ftsystem.h deleted file mode 100644 index 908ae07f..00000000 --- a/android/armeabi/include/freetype/ftsystem.h +++ /dev/null @@ -1,355 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftsystem.h */ -/* */ -/* FreeType low-level system interface definition (specification). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTSYSTEM_H_ -#define FTSYSTEM_H_ - - -#include <ft2build.h> - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* system_interface */ - /* */ - /* <Title> */ - /* System Interface */ - /* */ - /* <Abstract> */ - /* How FreeType manages memory and i/o. */ - /* */ - /* <Description> */ - /* This section contains various definitions related to memory */ - /* management and i/o access. You need to understand this */ - /* information if you want to use a custom memory manager or you own */ - /* i/o streams. */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* M E M O R Y M A N A G E M E N T */ - /* */ - /*************************************************************************/ - - - /************************************************************************* - * - * @type: - * FT_Memory - * - * @description: - * A handle to a given memory manager object, defined with an - * @FT_MemoryRec structure. - * - */ - typedef struct FT_MemoryRec_* FT_Memory; - - - /************************************************************************* - * - * @functype: - * FT_Alloc_Func - * - * @description: - * A function used to allocate `size' bytes from `memory'. - * - * @input: - * memory :: - * A handle to the source memory manager. - * - * size :: - * The size in bytes to allocate. - * - * @return: - * Address of new memory block. 0~in case of failure. - * - */ - typedef void* - (*FT_Alloc_Func)( FT_Memory memory, - long size ); - - - /************************************************************************* - * - * @functype: - * FT_Free_Func - * - * @description: - * A function used to release a given block of memory. - * - * @input: - * memory :: - * A handle to the source memory manager. - * - * block :: - * The address of the target memory block. - * - */ - typedef void - (*FT_Free_Func)( FT_Memory memory, - void* block ); - - - /************************************************************************* - * - * @functype: - * FT_Realloc_Func - * - * @description: - * A function used to re-allocate a given block of memory. - * - * @input: - * memory :: - * A handle to the source memory manager. - * - * cur_size :: - * The block's current size in bytes. - * - * new_size :: - * The block's requested new size. - * - * block :: - * The block's current address. - * - * @return: - * New block address. 0~in case of memory shortage. - * - * @note: - * In case of error, the old block must still be available. - * - */ - typedef void* - (*FT_Realloc_Func)( FT_Memory memory, - long cur_size, - long new_size, - void* block ); - - - /************************************************************************* - * - * @struct: - * FT_MemoryRec - * - * @description: - * A structure used to describe a given memory manager to FreeType~2. - * - * @fields: - * user :: - * A generic typeless pointer for user data. - * - * alloc :: - * A pointer type to an allocation function. - * - * free :: - * A pointer type to an memory freeing function. - * - * realloc :: - * A pointer type to a reallocation function. - * - */ - struct FT_MemoryRec_ - { - void* user; - FT_Alloc_Func alloc; - FT_Free_Func free; - FT_Realloc_Func realloc; - }; - - - /*************************************************************************/ - /* */ - /* I / O M A N A G E M E N T */ - /* */ - /*************************************************************************/ - - - /************************************************************************* - * - * @type: - * FT_Stream - * - * @description: - * A handle to an input stream. - * - * @also: - * See @FT_StreamRec for the publicly accessible fields of a given - * stream object. - * - */ - typedef struct FT_StreamRec_* FT_Stream; - - - /************************************************************************* - * - * @struct: - * FT_StreamDesc - * - * @description: - * A union type used to store either a long or a pointer. This is used - * to store a file descriptor or a `FILE*' in an input stream. - * - */ - typedef union FT_StreamDesc_ - { - long value; - void* pointer; - - } FT_StreamDesc; - - - /************************************************************************* - * - * @functype: - * FT_Stream_IoFunc - * - * @description: - * A function used to seek and read data from a given input stream. - * - * @input: - * stream :: - * A handle to the source stream. - * - * offset :: - * The offset of read in stream (always from start). - * - * buffer :: - * The address of the read buffer. - * - * count :: - * The number of bytes to read from the stream. - * - * @return: - * The number of bytes effectively read by the stream. - * - * @note: - * This function might be called to perform a seek or skip operation - * with a `count' of~0. A non-zero return value then indicates an - * error. - * - */ - typedef unsigned long - (*FT_Stream_IoFunc)( FT_Stream stream, - unsigned long offset, - unsigned char* buffer, - unsigned long count ); - - - /************************************************************************* - * - * @functype: - * FT_Stream_CloseFunc - * - * @description: - * A function used to close a given input stream. - * - * @input: - * stream :: - * A handle to the target stream. - * - */ - typedef void - (*FT_Stream_CloseFunc)( FT_Stream stream ); - - - /************************************************************************* - * - * @struct: - * FT_StreamRec - * - * @description: - * A structure used to describe an input stream. - * - * @input: - * base :: - * For memory-based streams, this is the address of the first stream - * byte in memory. This field should always be set to NULL for - * disk-based streams. - * - * size :: - * The stream size in bytes. - * - * In case of compressed streams where the size is unknown before - * actually doing the decompression, the value is set to 0x7FFFFFFF. - * (Note that this size value can occur for normal streams also; it is - * thus just a hint.) - * - * pos :: - * The current position within the stream. - * - * descriptor :: - * This field is a union that can hold an integer or a pointer. It is - * used by stream implementations to store file descriptors or `FILE*' - * pointers. - * - * pathname :: - * This field is completely ignored by FreeType. However, it is often - * useful during debugging to use it to store the stream's filename - * (where available). - * - * read :: - * The stream's input function. - * - * close :: - * The stream's close function. - * - * memory :: - * The memory manager to use to preload frames. This is set - * internally by FreeType and shouldn't be touched by stream - * implementations. - * - * cursor :: - * This field is set and used internally by FreeType when parsing - * frames. - * - * limit :: - * This field is set and used internally by FreeType when parsing - * frames. - * - */ - typedef struct FT_StreamRec_ - { - unsigned char* base; - unsigned long size; - unsigned long pos; - - FT_StreamDesc descriptor; - FT_StreamDesc pathname; - FT_Stream_IoFunc read; - FT_Stream_CloseFunc close; - - FT_Memory memory; - unsigned char* cursor; - unsigned char* limit; - - } FT_StreamRec; - - /* */ - - -FT_END_HEADER - -#endif /* FTSYSTEM_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/fttrigon.h b/android/armeabi/include/freetype/fttrigon.h deleted file mode 100644 index f789b524..00000000 --- a/android/armeabi/include/freetype/fttrigon.h +++ /dev/null @@ -1,350 +0,0 @@ -/***************************************************************************/ -/* */ -/* fttrigon.h */ -/* */ -/* FreeType trigonometric functions (specification). */ -/* */ -/* Copyright 2001-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTTRIGON_H_ -#define FTTRIGON_H_ - -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* computations */ - /* */ - /*************************************************************************/ - - - /************************************************************************* - * - * @type: - * FT_Angle - * - * @description: - * This type is used to model angle values in FreeType. Note that the - * angle is a 16.16 fixed-point value expressed in degrees. - * - */ - typedef FT_Fixed FT_Angle; - - - /************************************************************************* - * - * @macro: - * FT_ANGLE_PI - * - * @description: - * The angle pi expressed in @FT_Angle units. - * - */ -#define FT_ANGLE_PI ( 180L << 16 ) - - - /************************************************************************* - * - * @macro: - * FT_ANGLE_2PI - * - * @description: - * The angle 2*pi expressed in @FT_Angle units. - * - */ -#define FT_ANGLE_2PI ( FT_ANGLE_PI * 2 ) - - - /************************************************************************* - * - * @macro: - * FT_ANGLE_PI2 - * - * @description: - * The angle pi/2 expressed in @FT_Angle units. - * - */ -#define FT_ANGLE_PI2 ( FT_ANGLE_PI / 2 ) - - - /************************************************************************* - * - * @macro: - * FT_ANGLE_PI4 - * - * @description: - * The angle pi/4 expressed in @FT_Angle units. - * - */ -#define FT_ANGLE_PI4 ( FT_ANGLE_PI / 4 ) - - - /************************************************************************* - * - * @function: - * FT_Sin - * - * @description: - * Return the sinus of a given angle in fixed-point format. - * - * @input: - * angle :: - * The input angle. - * - * @return: - * The sinus value. - * - * @note: - * If you need both the sinus and cosinus for a given angle, use the - * function @FT_Vector_Unit. - * - */ - FT_EXPORT( FT_Fixed ) - FT_Sin( FT_Angle angle ); - - - /************************************************************************* - * - * @function: - * FT_Cos - * - * @description: - * Return the cosinus of a given angle in fixed-point format. - * - * @input: - * angle :: - * The input angle. - * - * @return: - * The cosinus value. - * - * @note: - * If you need both the sinus and cosinus for a given angle, use the - * function @FT_Vector_Unit. - * - */ - FT_EXPORT( FT_Fixed ) - FT_Cos( FT_Angle angle ); - - - /************************************************************************* - * - * @function: - * FT_Tan - * - * @description: - * Return the tangent of a given angle in fixed-point format. - * - * @input: - * angle :: - * The input angle. - * - * @return: - * The tangent value. - * - */ - FT_EXPORT( FT_Fixed ) - FT_Tan( FT_Angle angle ); - - - /************************************************************************* - * - * @function: - * FT_Atan2 - * - * @description: - * Return the arc-tangent corresponding to a given vector (x,y) in - * the 2d plane. - * - * @input: - * x :: - * The horizontal vector coordinate. - * - * y :: - * The vertical vector coordinate. - * - * @return: - * The arc-tangent value (i.e. angle). - * - */ - FT_EXPORT( FT_Angle ) - FT_Atan2( FT_Fixed x, - FT_Fixed y ); - - - /************************************************************************* - * - * @function: - * FT_Angle_Diff - * - * @description: - * Return the difference between two angles. The result is always - * constrained to the ]-PI..PI] interval. - * - * @input: - * angle1 :: - * First angle. - * - * angle2 :: - * Second angle. - * - * @return: - * Constrained value of `value2-value1'. - * - */ - FT_EXPORT( FT_Angle ) - FT_Angle_Diff( FT_Angle angle1, - FT_Angle angle2 ); - - - /************************************************************************* - * - * @function: - * FT_Vector_Unit - * - * @description: - * Return the unit vector corresponding to a given angle. After the - * call, the value of `vec.x' will be `cos(angle)', and the value of - * `vec.y' will be `sin(angle)'. - * - * This function is useful to retrieve both the sinus and cosinus of a - * given angle quickly. - * - * @output: - * vec :: - * The address of target vector. - * - * @input: - * angle :: - * The input angle. - * - */ - FT_EXPORT( void ) - FT_Vector_Unit( FT_Vector* vec, - FT_Angle angle ); - - - /************************************************************************* - * - * @function: - * FT_Vector_Rotate - * - * @description: - * Rotate a vector by a given angle. - * - * @inout: - * vec :: - * The address of target vector. - * - * @input: - * angle :: - * The input angle. - * - */ - FT_EXPORT( void ) - FT_Vector_Rotate( FT_Vector* vec, - FT_Angle angle ); - - - /************************************************************************* - * - * @function: - * FT_Vector_Length - * - * @description: - * Return the length of a given vector. - * - * @input: - * vec :: - * The address of target vector. - * - * @return: - * The vector length, expressed in the same units that the original - * vector coordinates. - * - */ - FT_EXPORT( FT_Fixed ) - FT_Vector_Length( FT_Vector* vec ); - - - /************************************************************************* - * - * @function: - * FT_Vector_Polarize - * - * @description: - * Compute both the length and angle of a given vector. - * - * @input: - * vec :: - * The address of source vector. - * - * @output: - * length :: - * The vector length. - * - * angle :: - * The vector angle. - * - */ - FT_EXPORT( void ) - FT_Vector_Polarize( FT_Vector* vec, - FT_Fixed *length, - FT_Angle *angle ); - - - /************************************************************************* - * - * @function: - * FT_Vector_From_Polar - * - * @description: - * Compute vector coordinates from a length and angle. - * - * @output: - * vec :: - * The address of source vector. - * - * @input: - * length :: - * The vector length. - * - * angle :: - * The vector angle. - * - */ - FT_EXPORT( void ) - FT_Vector_From_Polar( FT_Vector* vec, - FT_Fixed length, - FT_Angle angle ); - - /* */ - - -FT_END_HEADER - -#endif /* FTTRIGON_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftttdrv.h b/android/armeabi/include/freetype/ftttdrv.h deleted file mode 100644 index 6c02e657..00000000 --- a/android/armeabi/include/freetype/ftttdrv.h +++ /dev/null @@ -1,310 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftttdrv.h */ -/* */ -/* FreeType API for controlling the TrueType driver */ -/* (specification only). */ -/* */ -/* Copyright 2013-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTTTDRV_H_ -#define FTTTDRV_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /************************************************************************** - * - * @section: - * tt_driver - * - * @title: - * The TrueType driver - * - * @abstract: - * Controlling the TrueType driver module. - * - * @description: - * While FreeType's TrueType driver doesn't expose API functions by - * itself, it is possible to control its behaviour with @FT_Property_Set - * and @FT_Property_Get. The following lists the available properties - * together with the necessary macros and structures. - * - * The TrueType driver's module name is `truetype'. - * - * We start with a list of definitions, kindly provided by Greg - * Hitchcock. - * - * _Bi-Level_ _Rendering_ - * - * Monochromatic rendering, exclusively used in the early days of - * TrueType by both Apple and Microsoft. Microsoft's GDI interface - * supported hinting of the right-side bearing point, such that the - * advance width could be non-linear. Most often this was done to - * achieve some level of glyph symmetry. To enable reasonable - * performance (e.g., not having to run hinting on all glyphs just to - * get the widths) there was a bit in the head table indicating if the - * side bearing was hinted, and additional tables, `hdmx' and `LTSH', to - * cache hinting widths across multiple sizes and device aspect ratios. - * - * _Font_ _Smoothing_ - * - * Microsoft's GDI implementation of anti-aliasing. Not traditional - * anti-aliasing as the outlines were hinted before the sampling. The - * widths matched the bi-level rendering. - * - * _ClearType_ _Rendering_ - * - * Technique that uses physical subpixels to improve rendering on LCD - * (and other) displays. Because of the higher resolution, many methods - * of improving symmetry in glyphs through hinting the right-side - * bearing were no longer necessary. This lead to what GDI calls - * `natural widths' ClearType, see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec21. Since hinting - * has extra resolution, most non-linearity went away, but it is still - * possible for hints to change the advance widths in this mode. - * - * _ClearType_ _Compatible_ _Widths_ - * - * One of the earliest challenges with ClearType was allowing the - * implementation in GDI to be selected without requiring all UI and - * documents to reflow. To address this, a compatible method of - * rendering ClearType was added where the font hints are executed once - * to determine the width in bi-level rendering, and then re-run in - * ClearType, with the difference in widths being absorbed in the font - * hints for ClearType (mostly in the white space of hints); see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec20. Somewhat by - * definition, compatible width ClearType allows for non-linear widths, - * but only when the bi-level version has non-linear widths. - * - * _ClearType_ _Subpixel_ _Positioning_ - * - * One of the nice benefits of ClearType is the ability to more crisply - * display fractional widths; unfortunately, the GDI model of integer - * bitmaps did not support this. However, the WPF and Direct Write - * frameworks do support fractional widths. DWrite calls this `natural - * mode', not to be confused with GDI's `natural widths'. Subpixel - * positioning, in the current implementation of Direct Write, - * unfortunately does not support hinted advance widths, see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec22. Note that the - * TrueType interpreter fully allows the advance width to be adjusted in - * this mode, just the DWrite client will ignore those changes. - * - * _ClearType_ _Backwards_ _Compatibility_ - * - * This is a set of exceptions made in the TrueType interpreter to - * minimize hinting techniques that were problematic with the extra - * resolution of ClearType; see - * http://www.beatstamm.com/typography/RTRCh4.htm#Sec1 and - * http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx. - * This technique is not to be confused with ClearType compatible - * widths. ClearType backwards compatibility has no direct impact on - * changing advance widths, but there might be an indirect impact on - * disabling some deltas. This could be worked around in backwards - * compatibility mode. - * - * _Native_ _ClearType_ _Mode_ - * - * (Not to be confused with `natural widths'.) This mode removes all - * the exceptions in the TrueType interpreter when running with - * ClearType. Any issues on widths would still apply, though. - * - */ - - - /************************************************************************** - * - * @property: - * interpreter-version - * - * @description: - * Currently, two versions are available, representing the bytecode - * interpreter with and without subpixel hinting support, - * respectively. The default is subpixel support if - * TT_CONFIG_OPTION_SUBPIXEL_HINTING is defined, and no subpixel - * support otherwise (since it isn't available then). - * - * If subpixel hinting is on, many TrueType bytecode instructions behave - * differently compared to B/W or grayscale rendering (except if `native - * ClearType' is selected by the font). The main idea is to render at a - * much increased horizontal resolution, then sampling down the created - * output to subpixel precision. However, many older fonts are not - * suited to this and must be specially taken care of by applying - * (hardcoded) font-specific tweaks. - * - * Details on subpixel hinting and some of the necessary tweaks can be - * found in Greg Hitchcock's whitepaper at - * `http://www.microsoft.com/typography/cleartype/truetypecleartype.aspx'. - * - * The following example code demonstrates how to activate subpixel - * hinting (omitting the error handling). - * - * { - * FT_Library library; - * FT_Face face; - * FT_UInt interpreter_version = TT_INTERPRETER_VERSION_38; - * - * - * FT_Init_FreeType( &library ); - * - * FT_Property_Set( library, "truetype", - * "interpreter-version", - * &interpreter_version ); - * } - * - * @note: - * This property can be used with @FT_Property_Get also. - * - */ - - - /************************************************************************** - * - * @enum: - * TT_INTERPRETER_VERSION_XXX - * - * @description: - * A list of constants used for the @interpreter-version property to - * select the hinting engine for Truetype fonts. - * - * The numeric value in the constant names represents the version - * number as returned by the `GETINFO' bytecode instruction. - * - * @values: - * TT_INTERPRETER_VERSION_35 :: - * Version~35 corresponds to MS rasterizer v.1.7 as used e.g. in - * Windows~98; only grayscale and B/W rasterizing is supported. - * - * TT_INTERPRETER_VERSION_38 :: - * Version~38 corresponds to MS rasterizer v.1.9; it is roughly - * equivalent to the hinting provided by DirectWrite ClearType (as - * can be found, for example, in the Internet Explorer~9 running on - * Windows~7). - * - * @note: - * This property controls the behaviour of the bytecode interpreter - * and thus how outlines get hinted. It does *not* control how glyph - * get rasterized! In particular, it does not control subpixel color - * filtering. - * - * If FreeType has not been compiled with configuration option - * FT_CONFIG_OPTION_SUBPIXEL_HINTING, selecting version~38 causes an - * `FT_Err_Unimplemented_Feature' error. - * - * Depending on the graphics framework, Microsoft uses different - * bytecode and rendering engines. As a consequence, the version - * numbers returned by a call to the `GETINFO' bytecode instruction are - * more convoluted than desired. - * - * Here are two tables that try to shed some light on the possible - * values for the MS rasterizer engine, together with the additional - * features introduced by it. - * - * { - * GETINFO framework version feature - * ------------------------------------------------------------------- - * 3 GDI (Win 3.1), v1.0 16-bit, first version - * TrueImage - * 33 GDI (Win NT 3.1), v1.5 32-bit - * HP Laserjet - * 34 GDI (Win 95) v1.6 font smoothing, - * new SCANTYPE opcode - * 35 GDI (Win 98/2000) v1.7 (UN)SCALED_COMPONENT_OFFSET - * bits in composite glyphs - * 36 MGDI (Win CE 2) v1.6+ classic ClearType - * 37 GDI (XP and later), v1.8 ClearType - * GDI+ old (before Vista) - * 38 GDI+ old (Vista, Win 7), v1.9 subpixel ClearType, - * WPF Y-direction ClearType, - * additional error checking - * 39 DWrite (before Win 8) v2.0 subpixel ClearType flags - * in GETINFO opcode, - * bug fixes - * 40 GDI+ (after Win 7), v2.1 Y-direction ClearType flag - * DWrite (Win 8) in GETINFO opcode, - * Gray ClearType - * } - * - * The `version' field gives a rough orientation only, since some - * applications provided certain features much earlier (as an example, - * Microsoft Reader used subpixel and Y-direction ClearType already in - * Windows 2000). Similarly, updates to a given framework might include - * improved hinting support. - * - * { - * version sampling rendering comment - * x y x y - * -------------------------------------------------------------- - * v1.0 normal normal B/W B/W bi-level - * v1.6 high high gray gray grayscale - * v1.8 high normal color-filter B/W (GDI) ClearType - * v1.9 high high color-filter gray Color ClearType - * v2.1 high normal gray B/W Gray ClearType - * v2.1 high high gray gray Gray ClearType - * } - * - * Color and Gray ClearType are the two available variants of - * `Y-direction ClearType', meaning grayscale rasterization along the - * Y-direction; the name used in the TrueType specification for this - * feature is `symmetric smoothing'. `Classic ClearType' is the - * original algorithm used before introducing a modified version in - * Win~XP. Another name for v1.6's grayscale rendering is `font - * smoothing', and `Color ClearType' is sometimes also called `DWrite - * ClearType'. To differentiate between today's Color ClearType and the - * earlier ClearType variant with B/W rendering along the vertical axis, - * the latter is sometimes called `GDI ClearType'. - * - * `Normal' and `high' sampling describe the (virtual) resolution to - * access the rasterized outline after the hinting process. `Normal' - * means 1 sample per grid line (i.e., B/W). In the current Microsoft - * implementation, `high' means an extra virtual resolution of 16x16 (or - * 16x1) grid lines per pixel for bytecode instructions like `MIRP'. - * After hinting, these 16 grid lines are mapped to 6x5 (or 6x1) grid - * lines for color filtering if Color ClearType is activated. - * - * Note that `Gray ClearType' is essentially the same as v1.6's - * grayscale rendering. However, the GETINFO instruction handles it - * differently: v1.6 returns bit~12 (hinting for grayscale), while v2.1 - * returns bits~13 (hinting for ClearType), 18 (symmetrical smoothing), - * and~19 (Gray ClearType). Also, this mode respects bits 2 and~3 for - * the version~1 gasp table exclusively (like Color ClearType), while - * v1.6 only respects the values of version~0 (bits 0 and~1). - * - * FreeType doesn't provide all capabilities of the most recent - * ClearType incarnation, thus we identify our subpixel support as - * version~38. - * - */ -#define TT_INTERPRETER_VERSION_35 35 -#define TT_INTERPRETER_VERSION_38 38 - - /* */ - - -FT_END_HEADER - - -#endif /* FTTTDRV_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/fttypes.h b/android/armeabi/include/freetype/fttypes.h deleted file mode 100644 index 2673e79c..00000000 --- a/android/armeabi/include/freetype/fttypes.h +++ /dev/null @@ -1,602 +0,0 @@ -/***************************************************************************/ -/* */ -/* fttypes.h */ -/* */ -/* FreeType simple types definitions (specification only). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTTYPES_H_ -#define FTTYPES_H_ - - -#include <ft2build.h> -#include FT_CONFIG_CONFIG_H -#include FT_SYSTEM_H -#include FT_IMAGE_H - -#include <stddef.h> - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* basic_types */ - /* */ - /* <Title> */ - /* Basic Data Types */ - /* */ - /* <Abstract> */ - /* The basic data types defined by the library. */ - /* */ - /* <Description> */ - /* This section contains the basic data types defined by FreeType~2, */ - /* ranging from simple scalar types to bitmap descriptors. More */ - /* font-specific structures are defined in a different section. */ - /* */ - /* <Order> */ - /* FT_Byte */ - /* FT_Bytes */ - /* FT_Char */ - /* FT_Int */ - /* FT_UInt */ - /* FT_Int16 */ - /* FT_UInt16 */ - /* FT_Int32 */ - /* FT_UInt32 */ - /* FT_Int64 */ - /* FT_UInt64 */ - /* FT_Short */ - /* FT_UShort */ - /* FT_Long */ - /* FT_ULong */ - /* FT_Bool */ - /* FT_Offset */ - /* FT_PtrDist */ - /* FT_String */ - /* FT_Tag */ - /* FT_Error */ - /* FT_Fixed */ - /* FT_Pointer */ - /* FT_Pos */ - /* FT_Vector */ - /* FT_BBox */ - /* FT_Matrix */ - /* FT_FWord */ - /* FT_UFWord */ - /* FT_F2Dot14 */ - /* FT_UnitVector */ - /* FT_F26Dot6 */ - /* FT_Data */ - /* */ - /* FT_MAKE_TAG */ - /* */ - /* FT_Generic */ - /* FT_Generic_Finalizer */ - /* */ - /* FT_Bitmap */ - /* FT_Pixel_Mode */ - /* FT_Palette_Mode */ - /* FT_Glyph_Format */ - /* FT_IMAGE_TAG */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Bool */ - /* */ - /* <Description> */ - /* A typedef of unsigned char, used for simple booleans. As usual, */ - /* values 1 and~0 represent true and false, respectively. */ - /* */ - typedef unsigned char FT_Bool; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_FWord */ - /* */ - /* <Description> */ - /* A signed 16-bit integer used to store a distance in original font */ - /* units. */ - /* */ - typedef signed short FT_FWord; /* distance in FUnits */ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UFWord */ - /* */ - /* <Description> */ - /* An unsigned 16-bit integer used to store a distance in original */ - /* font units. */ - /* */ - typedef unsigned short FT_UFWord; /* unsigned distance */ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Char */ - /* */ - /* <Description> */ - /* A simple typedef for the _signed_ char type. */ - /* */ - typedef signed char FT_Char; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Byte */ - /* */ - /* <Description> */ - /* A simple typedef for the _unsigned_ char type. */ - /* */ - typedef unsigned char FT_Byte; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Bytes */ - /* */ - /* <Description> */ - /* A typedef for constant memory areas. */ - /* */ - typedef const FT_Byte* FT_Bytes; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Tag */ - /* */ - /* <Description> */ - /* A typedef for 32-bit tags (as used in the SFNT format). */ - /* */ - typedef FT_UInt32 FT_Tag; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_String */ - /* */ - /* <Description> */ - /* A simple typedef for the char type, usually used for strings. */ - /* */ - typedef char FT_String; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Short */ - /* */ - /* <Description> */ - /* A typedef for signed short. */ - /* */ - typedef signed short FT_Short; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UShort */ - /* */ - /* <Description> */ - /* A typedef for unsigned short. */ - /* */ - typedef unsigned short FT_UShort; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Int */ - /* */ - /* <Description> */ - /* A typedef for the int type. */ - /* */ - typedef signed int FT_Int; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_UInt */ - /* */ - /* <Description> */ - /* A typedef for the unsigned int type. */ - /* */ - typedef unsigned int FT_UInt; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Long */ - /* */ - /* <Description> */ - /* A typedef for signed long. */ - /* */ - typedef signed long FT_Long; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_ULong */ - /* */ - /* <Description> */ - /* A typedef for unsigned long. */ - /* */ - typedef unsigned long FT_ULong; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_F2Dot14 */ - /* */ - /* <Description> */ - /* A signed 2.14 fixed-point type used for unit vectors. */ - /* */ - typedef signed short FT_F2Dot14; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_F26Dot6 */ - /* */ - /* <Description> */ - /* A signed 26.6 fixed-point type used for vectorial pixel */ - /* coordinates. */ - /* */ - typedef signed long FT_F26Dot6; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Fixed */ - /* */ - /* <Description> */ - /* This type is used to store 16.16 fixed-point values, like scaling */ - /* values or matrix coefficients. */ - /* */ - typedef signed long FT_Fixed; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Error */ - /* */ - /* <Description> */ - /* The FreeType error code type. A value of~0 is always interpreted */ - /* as a successful operation. */ - /* */ - typedef int FT_Error; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Pointer */ - /* */ - /* <Description> */ - /* A simple typedef for a typeless pointer. */ - /* */ - typedef void* FT_Pointer; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_Offset */ - /* */ - /* <Description> */ - /* This is equivalent to the ANSI~C `size_t' type, i.e., the largest */ - /* _unsigned_ integer type used to express a file size or position, */ - /* or a memory block size. */ - /* */ - typedef size_t FT_Offset; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_PtrDist */ - /* */ - /* <Description> */ - /* This is equivalent to the ANSI~C `ptrdiff_t' type, i.e., the */ - /* largest _signed_ integer type used to express the distance */ - /* between two pointers. */ - /* */ - typedef ft_ptrdiff_t FT_PtrDist; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_UnitVector */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2D vector unit vector. Uses */ - /* FT_F2Dot14 types. */ - /* */ - /* <Fields> */ - /* x :: Horizontal coordinate. */ - /* */ - /* y :: Vertical coordinate. */ - /* */ - typedef struct FT_UnitVector_ - { - FT_F2Dot14 x; - FT_F2Dot14 y; - - } FT_UnitVector; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Matrix */ - /* */ - /* <Description> */ - /* A simple structure used to store a 2x2 matrix. Coefficients are */ - /* in 16.16 fixed-point format. The computation performed is: */ - /* */ - /* { */ - /* x' = x*xx + y*xy */ - /* y' = x*yx + y*yy */ - /* } */ - /* */ - /* <Fields> */ - /* xx :: Matrix coefficient. */ - /* */ - /* xy :: Matrix coefficient. */ - /* */ - /* yx :: Matrix coefficient. */ - /* */ - /* yy :: Matrix coefficient. */ - /* */ - typedef struct FT_Matrix_ - { - FT_Fixed xx, xy; - FT_Fixed yx, yy; - - } FT_Matrix; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Data */ - /* */ - /* <Description> */ - /* Read-only binary data represented as a pointer and a length. */ - /* */ - /* <Fields> */ - /* pointer :: The data. */ - /* */ - /* length :: The length of the data in bytes. */ - /* */ - typedef struct FT_Data_ - { - const FT_Byte* pointer; - FT_Int length; - - } FT_Data; - - - /*************************************************************************/ - /* */ - /* <FuncType> */ - /* FT_Generic_Finalizer */ - /* */ - /* <Description> */ - /* Describe a function used to destroy the `client' data of any */ - /* FreeType object. See the description of the @FT_Generic type for */ - /* details of usage. */ - /* */ - /* <Input> */ - /* The address of the FreeType object that is under finalization. */ - /* Its client data is accessed through its `generic' field. */ - /* */ - typedef void (*FT_Generic_Finalizer)(void* object); - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_Generic */ - /* */ - /* <Description> */ - /* Client applications often need to associate their own data to a */ - /* variety of FreeType core objects. For example, a text layout API */ - /* might want to associate a glyph cache to a given size object. */ - /* */ - /* Some FreeType object contains a `generic' field, of type */ - /* FT_Generic, which usage is left to client applications and font */ - /* servers. */ - /* */ - /* It can be used to store a pointer to client-specific data, as well */ - /* as the address of a `finalizer' function, which will be called by */ - /* FreeType when the object is destroyed (for example, the previous */ - /* client example would put the address of the glyph cache destructor */ - /* in the `finalizer' field). */ - /* */ - /* <Fields> */ - /* data :: A typeless pointer to any client-specified data. This */ - /* field is completely ignored by the FreeType library. */ - /* */ - /* finalizer :: A pointer to a `generic finalizer' function, which */ - /* will be called when the object is destroyed. If this */ - /* field is set to NULL, no code will be called. */ - /* */ - typedef struct FT_Generic_ - { - void* data; - FT_Generic_Finalizer finalizer; - - } FT_Generic; - - - /*************************************************************************/ - /* */ - /* <Macro> */ - /* FT_MAKE_TAG */ - /* */ - /* <Description> */ - /* This macro converts four-letter tags that are used to label */ - /* TrueType tables into an unsigned long, to be used within FreeType. */ - /* */ - /* <Note> */ - /* The produced values *must* be 32-bit integers. Don't redefine */ - /* this macro. */ - /* */ -#define FT_MAKE_TAG( _x1, _x2, _x3, _x4 ) \ - (FT_Tag) \ - ( ( (FT_ULong)_x1 << 24 ) | \ - ( (FT_ULong)_x2 << 16 ) | \ - ( (FT_ULong)_x3 << 8 ) | \ - (FT_ULong)_x4 ) - - - /*************************************************************************/ - /*************************************************************************/ - /* */ - /* L I S T M A N A G E M E N T */ - /* */ - /*************************************************************************/ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* list_processing */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_ListNode */ - /* */ - /* <Description> */ - /* Many elements and objects in FreeType are listed through an */ - /* @FT_List record (see @FT_ListRec). As its name suggests, an */ - /* FT_ListNode is a handle to a single list element. */ - /* */ - typedef struct FT_ListNodeRec_* FT_ListNode; - - - /*************************************************************************/ - /* */ - /* <Type> */ - /* FT_List */ - /* */ - /* <Description> */ - /* A handle to a list record (see @FT_ListRec). */ - /* */ - typedef struct FT_ListRec_* FT_List; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ListNodeRec */ - /* */ - /* <Description> */ - /* A structure used to hold a single list element. */ - /* */ - /* <Fields> */ - /* prev :: The previous element in the list. NULL if first. */ - /* */ - /* next :: The next element in the list. NULL if last. */ - /* */ - /* data :: A typeless pointer to the listed object. */ - /* */ - typedef struct FT_ListNodeRec_ - { - FT_ListNode prev; - FT_ListNode next; - void* data; - - } FT_ListNodeRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_ListRec */ - /* */ - /* <Description> */ - /* A structure used to hold a simple doubly-linked list. These are */ - /* used in many parts of FreeType. */ - /* */ - /* <Fields> */ - /* head :: The head (first element) of doubly-linked list. */ - /* */ - /* tail :: The tail (last element) of doubly-linked list. */ - /* */ - typedef struct FT_ListRec_ - { - FT_ListNode head; - FT_ListNode tail; - - } FT_ListRec; - - /* */ - - -#define FT_IS_EMPTY( list ) ( (list).head == 0 ) -#define FT_BOOL( x ) ( (FT_Bool)( x ) ) - - /* concatenate C tokens */ -#define FT_ERR_XCAT( x, y ) x ## y -#define FT_ERR_CAT( x, y ) FT_ERR_XCAT( x, y ) - - /* see `ftmoderr.h' for descriptions of the following macros */ - -#define FT_ERR( e ) FT_ERR_CAT( FT_ERR_PREFIX, e ) - -#define FT_ERROR_BASE( x ) ( (x) & 0xFF ) -#define FT_ERROR_MODULE( x ) ( (x) & 0xFF00U ) - -#define FT_ERR_EQ( x, e ) \ - ( FT_ERROR_BASE( x ) == FT_ERROR_BASE( FT_ERR( e ) ) ) -#define FT_ERR_NEQ( x, e ) \ - ( FT_ERROR_BASE( x ) != FT_ERROR_BASE( FT_ERR( e ) ) ) - - -FT_END_HEADER - -#endif /* FTTYPES_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ftwinfnt.h b/android/armeabi/include/freetype/ftwinfnt.h deleted file mode 100644 index a1a715ba..00000000 --- a/android/armeabi/include/freetype/ftwinfnt.h +++ /dev/null @@ -1,275 +0,0 @@ -/***************************************************************************/ -/* */ -/* ftwinfnt.h */ -/* */ -/* FreeType API for accessing Windows fnt-specific data. */ -/* */ -/* Copyright 2003-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef FTWINFNT_H_ -#define FTWINFNT_H_ - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* winfnt_fonts */ - /* */ - /* <Title> */ - /* Window FNT Files */ - /* */ - /* <Abstract> */ - /* Windows FNT specific API. */ - /* */ - /* <Description> */ - /* This section contains the declaration of Windows FNT specific */ - /* functions. */ - /* */ - /*************************************************************************/ - - - /************************************************************************* - * - * @enum: - * FT_WinFNT_ID_XXX - * - * @description: - * A list of valid values for the `charset' byte in - * @FT_WinFNT_HeaderRec. Exact mapping tables for the various cpXXXX - * encodings (except for cp1361) can be found at - * ftp://ftp.unicode.org/Public in the MAPPINGS/VENDORS/MICSFT/WINDOWS - * subdirectory. cp1361 is roughly a superset of - * MAPPINGS/OBSOLETE/EASTASIA/KSC/JOHAB.TXT. - * - * @values: - * FT_WinFNT_ID_DEFAULT :: - * This is used for font enumeration and font creation as a - * `don't care' value. Valid font files don't contain this value. - * When querying for information about the character set of the font - * that is currently selected into a specified device context, this - * return value (of the related Windows API) simply denotes failure. - * - * FT_WinFNT_ID_SYMBOL :: - * There is no known mapping table available. - * - * FT_WinFNT_ID_MAC :: - * Mac Roman encoding. - * - * FT_WinFNT_ID_OEM :: - * From Michael Pöttgen <michael@poettgen.de>: - * - * The `Windows Font Mapping' article says that FT_WinFNT_ID_OEM - * is used for the charset of vector fonts, like `modern.fon', - * `roman.fon', and `script.fon' on Windows. - * - * The `CreateFont' documentation says: The FT_WinFNT_ID_OEM value - * specifies a character set that is operating-system dependent. - * - * The `IFIMETRICS' documentation from the `Windows Driver - * Development Kit' says: This font supports an OEM-specific - * character set. The OEM character set is system dependent. - * - * In general OEM, as opposed to ANSI (i.e., cp1252), denotes the - * second default codepage that most international versions of - * Windows have. It is one of the OEM codepages from - * - * https://msdn.microsoft.com/en-us/goglobal/bb964655, - * - * and is used for the `DOS boxes', to support legacy applications. - * A German Windows version for example usually uses ANSI codepage - * 1252 and OEM codepage 850. - * - * FT_WinFNT_ID_CP874 :: - * A superset of Thai TIS 620 and ISO 8859-11. - * - * FT_WinFNT_ID_CP932 :: - * A superset of Japanese Shift-JIS (with minor deviations). - * - * FT_WinFNT_ID_CP936 :: - * A superset of simplified Chinese GB 2312-1980 (with different - * ordering and minor deviations). - * - * FT_WinFNT_ID_CP949 :: - * A superset of Korean Hangul KS~C 5601-1987 (with different - * ordering and minor deviations). - * - * FT_WinFNT_ID_CP950 :: - * A superset of traditional Chinese Big~5 ETen (with different - * ordering and minor deviations). - * - * FT_WinFNT_ID_CP1250 :: - * A superset of East European ISO 8859-2 (with slightly different - * ordering). - * - * FT_WinFNT_ID_CP1251 :: - * A superset of Russian ISO 8859-5 (with different ordering). - * - * FT_WinFNT_ID_CP1252 :: - * ANSI encoding. A superset of ISO 8859-1. - * - * FT_WinFNT_ID_CP1253 :: - * A superset of Greek ISO 8859-7 (with minor modifications). - * - * FT_WinFNT_ID_CP1254 :: - * A superset of Turkish ISO 8859-9. - * - * FT_WinFNT_ID_CP1255 :: - * A superset of Hebrew ISO 8859-8 (with some modifications). - * - * FT_WinFNT_ID_CP1256 :: - * A superset of Arabic ISO 8859-6 (with different ordering). - * - * FT_WinFNT_ID_CP1257 :: - * A superset of Baltic ISO 8859-13 (with some deviations). - * - * FT_WinFNT_ID_CP1258 :: - * For Vietnamese. This encoding doesn't cover all necessary - * characters. - * - * FT_WinFNT_ID_CP1361 :: - * Korean (Johab). - */ - -#define FT_WinFNT_ID_CP1252 0 -#define FT_WinFNT_ID_DEFAULT 1 -#define FT_WinFNT_ID_SYMBOL 2 -#define FT_WinFNT_ID_MAC 77 -#define FT_WinFNT_ID_CP932 128 -#define FT_WinFNT_ID_CP949 129 -#define FT_WinFNT_ID_CP1361 130 -#define FT_WinFNT_ID_CP936 134 -#define FT_WinFNT_ID_CP950 136 -#define FT_WinFNT_ID_CP1253 161 -#define FT_WinFNT_ID_CP1254 162 -#define FT_WinFNT_ID_CP1258 163 -#define FT_WinFNT_ID_CP1255 177 -#define FT_WinFNT_ID_CP1256 178 -#define FT_WinFNT_ID_CP1257 186 -#define FT_WinFNT_ID_CP1251 204 -#define FT_WinFNT_ID_CP874 222 -#define FT_WinFNT_ID_CP1250 238 -#define FT_WinFNT_ID_OEM 255 - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_WinFNT_HeaderRec */ - /* */ - /* <Description> */ - /* Windows FNT Header info. */ - /* */ - typedef struct FT_WinFNT_HeaderRec_ - { - FT_UShort version; - FT_ULong file_size; - FT_Byte copyright[60]; - FT_UShort file_type; - FT_UShort nominal_point_size; - FT_UShort vertical_resolution; - FT_UShort horizontal_resolution; - FT_UShort ascent; - FT_UShort internal_leading; - FT_UShort external_leading; - FT_Byte italic; - FT_Byte underline; - FT_Byte strike_out; - FT_UShort weight; - FT_Byte charset; - FT_UShort pixel_width; - FT_UShort pixel_height; - FT_Byte pitch_and_family; - FT_UShort avg_width; - FT_UShort max_width; - FT_Byte first_char; - FT_Byte last_char; - FT_Byte default_char; - FT_Byte break_char; - FT_UShort bytes_per_row; - FT_ULong device_offset; - FT_ULong face_name_offset; - FT_ULong bits_pointer; - FT_ULong bits_offset; - FT_Byte reserved; - FT_ULong flags; - FT_UShort A_space; - FT_UShort B_space; - FT_UShort C_space; - FT_UShort color_table_offset; - FT_ULong reserved1[4]; - - } FT_WinFNT_HeaderRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* FT_WinFNT_Header */ - /* */ - /* <Description> */ - /* A handle to an @FT_WinFNT_HeaderRec structure. */ - /* */ - typedef struct FT_WinFNT_HeaderRec_* FT_WinFNT_Header; - - - /********************************************************************** - * - * @function: - * FT_Get_WinFNT_Header - * - * @description: - * Retrieve a Windows FNT font info header. - * - * @input: - * face :: A handle to the input face. - * - * @output: - * aheader :: The WinFNT header. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * This function only works with Windows FNT faces, returning an error - * otherwise. - */ - FT_EXPORT( FT_Error ) - FT_Get_WinFNT_Header( FT_Face face, - FT_WinFNT_HeaderRec *aheader ); - - /* */ - - -FT_END_HEADER - -#endif /* FTWINFNT_H_ */ - - -/* END */ - - -/* Local Variables: */ -/* coding: utf-8 */ -/* End: */ diff --git a/android/armeabi/include/freetype/t1tables.h b/android/armeabi/include/freetype/t1tables.h deleted file mode 100644 index e272324b..00000000 --- a/android/armeabi/include/freetype/t1tables.h +++ /dev/null @@ -1,761 +0,0 @@ -/***************************************************************************/ -/* */ -/* t1tables.h */ -/* */ -/* Basic Type 1/Type 2 tables definitions and interface (specification */ -/* only). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef T1TABLES_H_ -#define T1TABLES_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* type1_tables */ - /* */ - /* <Title> */ - /* Type 1 Tables */ - /* */ - /* <Abstract> */ - /* Type~1 (PostScript) specific font tables. */ - /* */ - /* <Description> */ - /* This section contains the definition of Type 1-specific tables, */ - /* including structures related to other PostScript font formats. */ - /* */ - /* <Order> */ - /* PS_FontInfoRec */ - /* PS_FontInfo */ - /* PS_PrivateRec */ - /* PS_Private */ - /* */ - /* CID_FaceDictRec */ - /* CID_FaceDict */ - /* CID_FaceInfoRec */ - /* CID_FaceInfo */ - /* */ - /* FT_Has_PS_Glyph_Names */ - /* FT_Get_PS_Font_Info */ - /* FT_Get_PS_Font_Private */ - /* FT_Get_PS_Font_Value */ - /* */ - /* T1_Blend_Flags */ - /* T1_EncodingType */ - /* PS_Dict_Keys */ - /* */ - /*************************************************************************/ - - - /* Note that we separate font data in PS_FontInfoRec and PS_PrivateRec */ - /* structures in order to support Multiple Master fonts. */ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_FontInfoRec */ - /* */ - /* <Description> */ - /* A structure used to model a Type~1 or Type~2 FontInfo dictionary. */ - /* Note that for Multiple Master fonts, each instance has its own */ - /* FontInfo dictionary. */ - /* */ - typedef struct PS_FontInfoRec_ - { - FT_String* version; - FT_String* notice; - FT_String* full_name; - FT_String* family_name; - FT_String* weight; - FT_Long italic_angle; - FT_Bool is_fixed_pitch; - FT_Short underline_position; - FT_UShort underline_thickness; - - } PS_FontInfoRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_FontInfo */ - /* */ - /* <Description> */ - /* A handle to a @PS_FontInfoRec structure. */ - /* */ - typedef struct PS_FontInfoRec_* PS_FontInfo; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_FontInfo */ - /* */ - /* <Description> */ - /* This type is equivalent to @PS_FontInfoRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ - typedef PS_FontInfoRec T1_FontInfo; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_PrivateRec */ - /* */ - /* <Description> */ - /* A structure used to model a Type~1 or Type~2 private dictionary. */ - /* Note that for Multiple Master fonts, each instance has its own */ - /* Private dictionary. */ - /* */ - typedef struct PS_PrivateRec_ - { - FT_Int unique_id; - FT_Int lenIV; - - FT_Byte num_blue_values; - FT_Byte num_other_blues; - FT_Byte num_family_blues; - FT_Byte num_family_other_blues; - - FT_Short blue_values[14]; - FT_Short other_blues[10]; - - FT_Short family_blues [14]; - FT_Short family_other_blues[10]; - - FT_Fixed blue_scale; - FT_Int blue_shift; - FT_Int blue_fuzz; - - FT_UShort standard_width[1]; - FT_UShort standard_height[1]; - - FT_Byte num_snap_widths; - FT_Byte num_snap_heights; - FT_Bool force_bold; - FT_Bool round_stem_up; - - FT_Short snap_widths [13]; /* including std width */ - FT_Short snap_heights[13]; /* including std height */ - - FT_Fixed expansion_factor; - - FT_Long language_group; - FT_Long password; - - FT_Short min_feature[2]; - - } PS_PrivateRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* PS_Private */ - /* */ - /* <Description> */ - /* A handle to a @PS_PrivateRec structure. */ - /* */ - typedef struct PS_PrivateRec_* PS_Private; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* T1_Private */ - /* */ - /* <Description> */ - /* This type is equivalent to @PS_PrivateRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ - typedef PS_PrivateRec T1_Private; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* T1_Blend_Flags */ - /* */ - /* <Description> */ - /* A set of flags used to indicate which fields are present in a */ - /* given blend dictionary (font info or private). Used to support */ - /* Multiple Masters fonts. */ - /* */ - /* <Values> */ - /* T1_BLEND_UNDERLINE_POSITION :: */ - /* T1_BLEND_UNDERLINE_THICKNESS :: */ - /* T1_BLEND_ITALIC_ANGLE :: */ - /* T1_BLEND_BLUE_VALUES :: */ - /* T1_BLEND_OTHER_BLUES :: */ - /* T1_BLEND_STANDARD_WIDTH :: */ - /* T1_BLEND_STANDARD_HEIGHT :: */ - /* T1_BLEND_STEM_SNAP_WIDTHS :: */ - /* T1_BLEND_STEM_SNAP_HEIGHTS :: */ - /* T1_BLEND_BLUE_SCALE :: */ - /* T1_BLEND_BLUE_SHIFT :: */ - /* T1_BLEND_FAMILY_BLUES :: */ - /* T1_BLEND_FAMILY_OTHER_BLUES :: */ - /* T1_BLEND_FORCE_BOLD :: */ - /* */ - typedef enum T1_Blend_Flags_ - { - /* required fields in a FontInfo blend dictionary */ - T1_BLEND_UNDERLINE_POSITION = 0, - T1_BLEND_UNDERLINE_THICKNESS, - T1_BLEND_ITALIC_ANGLE, - - /* required fields in a Private blend dictionary */ - T1_BLEND_BLUE_VALUES, - T1_BLEND_OTHER_BLUES, - T1_BLEND_STANDARD_WIDTH, - T1_BLEND_STANDARD_HEIGHT, - T1_BLEND_STEM_SNAP_WIDTHS, - T1_BLEND_STEM_SNAP_HEIGHTS, - T1_BLEND_BLUE_SCALE, - T1_BLEND_BLUE_SHIFT, - T1_BLEND_FAMILY_BLUES, - T1_BLEND_FAMILY_OTHER_BLUES, - T1_BLEND_FORCE_BOLD, - - T1_BLEND_MAX /* do not remove */ - - } T1_Blend_Flags; - - - /* these constants are deprecated; use the corresponding */ - /* `T1_Blend_Flags' values instead */ -#define t1_blend_underline_position T1_BLEND_UNDERLINE_POSITION -#define t1_blend_underline_thickness T1_BLEND_UNDERLINE_THICKNESS -#define t1_blend_italic_angle T1_BLEND_ITALIC_ANGLE -#define t1_blend_blue_values T1_BLEND_BLUE_VALUES -#define t1_blend_other_blues T1_BLEND_OTHER_BLUES -#define t1_blend_standard_widths T1_BLEND_STANDARD_WIDTH -#define t1_blend_standard_height T1_BLEND_STANDARD_HEIGHT -#define t1_blend_stem_snap_widths T1_BLEND_STEM_SNAP_WIDTHS -#define t1_blend_stem_snap_heights T1_BLEND_STEM_SNAP_HEIGHTS -#define t1_blend_blue_scale T1_BLEND_BLUE_SCALE -#define t1_blend_blue_shift T1_BLEND_BLUE_SHIFT -#define t1_blend_family_blues T1_BLEND_FAMILY_BLUES -#define t1_blend_family_other_blues T1_BLEND_FAMILY_OTHER_BLUES -#define t1_blend_force_bold T1_BLEND_FORCE_BOLD -#define t1_blend_max T1_BLEND_MAX - - /* */ - - - /* maximum number of Multiple Masters designs, as defined in the spec */ -#define T1_MAX_MM_DESIGNS 16 - - /* maximum number of Multiple Masters axes, as defined in the spec */ -#define T1_MAX_MM_AXIS 4 - - /* maximum number of elements in a design map */ -#define T1_MAX_MM_MAP_POINTS 20 - - - /* this structure is used to store the BlendDesignMap entry for an axis */ - typedef struct PS_DesignMap_ - { - FT_Byte num_points; - FT_Long* design_points; - FT_Fixed* blend_points; - - } PS_DesignMapRec, *PS_DesignMap; - - /* backwards-compatible definition */ - typedef PS_DesignMapRec T1_DesignMap; - - - typedef struct PS_BlendRec_ - { - FT_UInt num_designs; - FT_UInt num_axis; - - FT_String* axis_names[T1_MAX_MM_AXIS]; - FT_Fixed* design_pos[T1_MAX_MM_DESIGNS]; - PS_DesignMapRec design_map[T1_MAX_MM_AXIS]; - - FT_Fixed* weight_vector; - FT_Fixed* default_weight_vector; - - PS_FontInfo font_infos[T1_MAX_MM_DESIGNS + 1]; - PS_Private privates [T1_MAX_MM_DESIGNS + 1]; - - FT_ULong blend_bitflags; - - FT_BBox* bboxes [T1_MAX_MM_DESIGNS + 1]; - - /* since 2.3.0 */ - - /* undocumented, optional: the default design instance; */ - /* corresponds to default_weight_vector -- */ - /* num_default_design_vector == 0 means it is not present */ - /* in the font and associated metrics files */ - FT_UInt default_design_vector[T1_MAX_MM_DESIGNS]; - FT_UInt num_default_design_vector; - - } PS_BlendRec, *PS_Blend; - - - /* backwards-compatible definition */ - typedef PS_BlendRec T1_Blend; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceDictRec */ - /* */ - /* <Description> */ - /* A structure used to represent data in a CID top-level dictionary. */ - /* */ - typedef struct CID_FaceDictRec_ - { - PS_PrivateRec private_dict; - - FT_UInt len_buildchar; - FT_Fixed forcebold_threshold; - FT_Pos stroke_width; - FT_Fixed expansion_factor; - - FT_Byte paint_type; - FT_Byte font_type; - FT_Matrix font_matrix; - FT_Vector font_offset; - - FT_UInt num_subrs; - FT_ULong subrmap_offset; - FT_Int sd_bytes; - - } CID_FaceDictRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceDict */ - /* */ - /* <Description> */ - /* A handle to a @CID_FaceDictRec structure. */ - /* */ - typedef struct CID_FaceDictRec_* CID_FaceDict; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FontDict */ - /* */ - /* <Description> */ - /* This type is equivalent to @CID_FaceDictRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ - typedef CID_FaceDictRec CID_FontDict; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceInfoRec */ - /* */ - /* <Description> */ - /* A structure used to represent CID Face information. */ - /* */ - typedef struct CID_FaceInfoRec_ - { - FT_String* cid_font_name; - FT_Fixed cid_version; - FT_Int cid_font_type; - - FT_String* registry; - FT_String* ordering; - FT_Int supplement; - - PS_FontInfoRec font_info; - FT_BBox font_bbox; - FT_ULong uid_base; - - FT_Int num_xuid; - FT_ULong xuid[16]; - - FT_ULong cidmap_offset; - FT_Int fd_bytes; - FT_Int gd_bytes; - FT_ULong cid_count; - - FT_Int num_dicts; - CID_FaceDict font_dicts; - - FT_ULong data_offset; - - } CID_FaceInfoRec; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_FaceInfo */ - /* */ - /* <Description> */ - /* A handle to a @CID_FaceInfoRec structure. */ - /* */ - typedef struct CID_FaceInfoRec_* CID_FaceInfo; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* CID_Info */ - /* */ - /* <Description> */ - /* This type is equivalent to @CID_FaceInfoRec. It is deprecated but */ - /* kept to maintain source compatibility between various versions of */ - /* FreeType. */ - /* */ - typedef CID_FaceInfoRec CID_Info; - - - /************************************************************************ - * - * @function: - * FT_Has_PS_Glyph_Names - * - * @description: - * Return true if a given face provides reliable PostScript glyph - * names. This is similar to using the @FT_HAS_GLYPH_NAMES macro, - * except that certain fonts (mostly TrueType) contain incorrect - * glyph name tables. - * - * When this function returns true, the caller is sure that the glyph - * names returned by @FT_Get_Glyph_Name are reliable. - * - * @input: - * face :: - * face handle - * - * @return: - * Boolean. True if glyph names are reliable. - * - */ - FT_EXPORT( FT_Int ) - FT_Has_PS_Glyph_Names( FT_Face face ); - - - /************************************************************************ - * - * @function: - * FT_Get_PS_Font_Info - * - * @description: - * Retrieve the @PS_FontInfoRec structure corresponding to a given - * PostScript font. - * - * @input: - * face :: - * PostScript face handle. - * - * @output: - * afont_info :: - * Output font info structure pointer. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * String pointers within the @PS_FontInfoRec structure are owned by - * the face and don't need to be freed by the caller. Missing entries - * in the font's FontInfo dictionary are represented by NULL pointers. - * - * If the font's format is not PostScript-based, this function will - * return the `FT_Err_Invalid_Argument' error code. - * - */ - FT_EXPORT( FT_Error ) - FT_Get_PS_Font_Info( FT_Face face, - PS_FontInfo afont_info ); - - - /************************************************************************ - * - * @function: - * FT_Get_PS_Font_Private - * - * @description: - * Retrieve the @PS_PrivateRec structure corresponding to a given - * PostScript font. - * - * @input: - * face :: - * PostScript face handle. - * - * @output: - * afont_private :: - * Output private dictionary structure pointer. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * The string pointers within the @PS_PrivateRec structure are owned by - * the face and don't need to be freed by the caller. - * - * If the font's format is not PostScript-based, this function returns - * the `FT_Err_Invalid_Argument' error code. - * - */ - FT_EXPORT( FT_Error ) - FT_Get_PS_Font_Private( FT_Face face, - PS_Private afont_private ); - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* T1_EncodingType */ - /* */ - /* <Description> */ - /* An enumeration describing the `Encoding' entry in a Type 1 */ - /* dictionary. */ - /* */ - /* <Values> */ - /* T1_ENCODING_TYPE_NONE :: */ - /* T1_ENCODING_TYPE_ARRAY :: */ - /* T1_ENCODING_TYPE_STANDARD :: */ - /* T1_ENCODING_TYPE_ISOLATIN1 :: */ - /* T1_ENCODING_TYPE_EXPERT :: */ - /* */ - typedef enum T1_EncodingType_ - { - T1_ENCODING_TYPE_NONE = 0, - T1_ENCODING_TYPE_ARRAY, - T1_ENCODING_TYPE_STANDARD, - T1_ENCODING_TYPE_ISOLATIN1, - T1_ENCODING_TYPE_EXPERT - - } T1_EncodingType; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* PS_Dict_Keys */ - /* */ - /* <Description> */ - /* An enumeration used in calls to @FT_Get_PS_Font_Value to identify */ - /* the Type~1 dictionary entry to retrieve. */ - /* */ - /* <Values> */ - /* PS_DICT_FONT_TYPE :: */ - /* PS_DICT_FONT_MATRIX :: */ - /* PS_DICT_FONT_BBOX :: */ - /* PS_DICT_PAINT_TYPE :: */ - /* PS_DICT_FONT_NAME :: */ - /* PS_DICT_UNIQUE_ID :: */ - /* PS_DICT_NUM_CHAR_STRINGS :: */ - /* PS_DICT_CHAR_STRING_KEY :: */ - /* PS_DICT_CHAR_STRING :: */ - /* PS_DICT_ENCODING_TYPE :: */ - /* PS_DICT_ENCODING_ENTRY :: */ - /* PS_DICT_NUM_SUBRS :: */ - /* PS_DICT_SUBR :: */ - /* PS_DICT_STD_HW :: */ - /* PS_DICT_STD_VW :: */ - /* PS_DICT_NUM_BLUE_VALUES :: */ - /* PS_DICT_BLUE_VALUE :: */ - /* PS_DICT_BLUE_FUZZ :: */ - /* PS_DICT_NUM_OTHER_BLUES :: */ - /* PS_DICT_OTHER_BLUE :: */ - /* PS_DICT_NUM_FAMILY_BLUES :: */ - /* PS_DICT_FAMILY_BLUE :: */ - /* PS_DICT_NUM_FAMILY_OTHER_BLUES :: */ - /* PS_DICT_FAMILY_OTHER_BLUE :: */ - /* PS_DICT_BLUE_SCALE :: */ - /* PS_DICT_BLUE_SHIFT :: */ - /* PS_DICT_NUM_STEM_SNAP_H :: */ - /* PS_DICT_STEM_SNAP_H :: */ - /* PS_DICT_NUM_STEM_SNAP_V :: */ - /* PS_DICT_STEM_SNAP_V :: */ - /* PS_DICT_FORCE_BOLD :: */ - /* PS_DICT_RND_STEM_UP :: */ - /* PS_DICT_MIN_FEATURE :: */ - /* PS_DICT_LEN_IV :: */ - /* PS_DICT_PASSWORD :: */ - /* PS_DICT_LANGUAGE_GROUP :: */ - /* PS_DICT_VERSION :: */ - /* PS_DICT_NOTICE :: */ - /* PS_DICT_FULL_NAME :: */ - /* PS_DICT_FAMILY_NAME :: */ - /* PS_DICT_WEIGHT :: */ - /* PS_DICT_IS_FIXED_PITCH :: */ - /* PS_DICT_UNDERLINE_POSITION :: */ - /* PS_DICT_UNDERLINE_THICKNESS :: */ - /* PS_DICT_FS_TYPE :: */ - /* PS_DICT_ITALIC_ANGLE :: */ - /* */ - typedef enum PS_Dict_Keys_ - { - /* conventionally in the font dictionary */ - PS_DICT_FONT_TYPE, /* FT_Byte */ - PS_DICT_FONT_MATRIX, /* FT_Fixed */ - PS_DICT_FONT_BBOX, /* FT_Fixed */ - PS_DICT_PAINT_TYPE, /* FT_Byte */ - PS_DICT_FONT_NAME, /* FT_String* */ - PS_DICT_UNIQUE_ID, /* FT_Int */ - PS_DICT_NUM_CHAR_STRINGS, /* FT_Int */ - PS_DICT_CHAR_STRING_KEY, /* FT_String* */ - PS_DICT_CHAR_STRING, /* FT_String* */ - PS_DICT_ENCODING_TYPE, /* T1_EncodingType */ - PS_DICT_ENCODING_ENTRY, /* FT_String* */ - - /* conventionally in the font Private dictionary */ - PS_DICT_NUM_SUBRS, /* FT_Int */ - PS_DICT_SUBR, /* FT_String* */ - PS_DICT_STD_HW, /* FT_UShort */ - PS_DICT_STD_VW, /* FT_UShort */ - PS_DICT_NUM_BLUE_VALUES, /* FT_Byte */ - PS_DICT_BLUE_VALUE, /* FT_Short */ - PS_DICT_BLUE_FUZZ, /* FT_Int */ - PS_DICT_NUM_OTHER_BLUES, /* FT_Byte */ - PS_DICT_OTHER_BLUE, /* FT_Short */ - PS_DICT_NUM_FAMILY_BLUES, /* FT_Byte */ - PS_DICT_FAMILY_BLUE, /* FT_Short */ - PS_DICT_NUM_FAMILY_OTHER_BLUES, /* FT_Byte */ - PS_DICT_FAMILY_OTHER_BLUE, /* FT_Short */ - PS_DICT_BLUE_SCALE, /* FT_Fixed */ - PS_DICT_BLUE_SHIFT, /* FT_Int */ - PS_DICT_NUM_STEM_SNAP_H, /* FT_Byte */ - PS_DICT_STEM_SNAP_H, /* FT_Short */ - PS_DICT_NUM_STEM_SNAP_V, /* FT_Byte */ - PS_DICT_STEM_SNAP_V, /* FT_Short */ - PS_DICT_FORCE_BOLD, /* FT_Bool */ - PS_DICT_RND_STEM_UP, /* FT_Bool */ - PS_DICT_MIN_FEATURE, /* FT_Short */ - PS_DICT_LEN_IV, /* FT_Int */ - PS_DICT_PASSWORD, /* FT_Long */ - PS_DICT_LANGUAGE_GROUP, /* FT_Long */ - - /* conventionally in the font FontInfo dictionary */ - PS_DICT_VERSION, /* FT_String* */ - PS_DICT_NOTICE, /* FT_String* */ - PS_DICT_FULL_NAME, /* FT_String* */ - PS_DICT_FAMILY_NAME, /* FT_String* */ - PS_DICT_WEIGHT, /* FT_String* */ - PS_DICT_IS_FIXED_PITCH, /* FT_Bool */ - PS_DICT_UNDERLINE_POSITION, /* FT_Short */ - PS_DICT_UNDERLINE_THICKNESS, /* FT_UShort */ - PS_DICT_FS_TYPE, /* FT_UShort */ - PS_DICT_ITALIC_ANGLE, /* FT_Long */ - - PS_DICT_MAX = PS_DICT_ITALIC_ANGLE - - } PS_Dict_Keys; - - - /************************************************************************ - * - * @function: - * FT_Get_PS_Font_Value - * - * @description: - * Retrieve the value for the supplied key from a PostScript font. - * - * @input: - * face :: - * PostScript face handle. - * - * key :: - * An enumeration value representing the dictionary key to retrieve. - * - * idx :: - * For array values, this specifies the index to be returned. - * - * value :: - * A pointer to memory into which to write the value. - * - * valen_len :: - * The size, in bytes, of the memory supplied for the value. - * - * @output: - * value :: - * The value matching the above key, if it exists. - * - * @return: - * The amount of memory (in bytes) required to hold the requested - * value (if it exists, -1 otherwise). - * - * @note: - * The values returned are not pointers into the internal structures of - * the face, but are `fresh' copies, so that the memory containing them - * belongs to the calling application. This also enforces the - * `read-only' nature of these values, i.e., this function cannot be - * used to manipulate the face. - * - * `value' is a void pointer because the values returned can be of - * various types. - * - * If either `value' is NULL or `value_len' is too small, just the - * required memory size for the requested entry is returned. - * - * The `idx' parameter is used, not only to retrieve elements of, for - * example, the FontMatrix or FontBBox, but also to retrieve name keys - * from the CharStrings dictionary, and the charstrings themselves. It - * is ignored for atomic values. - * - * PS_DICT_BLUE_SCALE returns a value that is scaled up by 1000. To - * get the value as in the font stream, you need to divide by - * 65536000.0 (to remove the FT_Fixed scale, and the x1000 scale). - * - * IMPORTANT: Only key/value pairs read by the FreeType interpreter can - * be retrieved. So, for example, PostScript procedures such as NP, - * ND, and RD are not available. Arbitrary keys are, obviously, not be - * available either. - * - * If the font's format is not PostScript-based, this function returns - * the `FT_Err_Invalid_Argument' error code. - * - */ - FT_EXPORT( FT_Long ) - FT_Get_PS_Font_Value( FT_Face face, - PS_Dict_Keys key, - FT_UInt idx, - void *value, - FT_Long value_len ); - - /* */ - -FT_END_HEADER - -#endif /* T1TABLES_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ttnameid.h b/android/armeabi/include/freetype/ttnameid.h deleted file mode 100644 index ce707f16..00000000 --- a/android/armeabi/include/freetype/ttnameid.h +++ /dev/null @@ -1,1237 +0,0 @@ -/***************************************************************************/ -/* */ -/* ttnameid.h */ -/* */ -/* TrueType name ID definitions (specification only). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef TTNAMEID_H_ -#define TTNAMEID_H_ - - -#include <ft2build.h> - - -FT_BEGIN_HEADER - - - /*************************************************************************/ - /* */ - /* <Section> */ - /* truetype_tables */ - /* */ - - - /*************************************************************************/ - /* */ - /* Possible values for the `platform' identifier code in the name */ - /* records of the TTF `name' table. */ - /* */ - /*************************************************************************/ - - - /*********************************************************************** - * - * @enum: - * TT_PLATFORM_XXX - * - * @description: - * A list of valid values for the `platform_id' identifier code in - * @FT_CharMapRec and @FT_SfntName structures. - * - * @values: - * TT_PLATFORM_APPLE_UNICODE :: - * Used by Apple to indicate a Unicode character map and/or name entry. - * See @TT_APPLE_ID_XXX for corresponding `encoding_id' values. Note - * that name entries in this format are coded as big-endian UCS-2 - * character codes _only_. - * - * TT_PLATFORM_MACINTOSH :: - * Used by Apple to indicate a MacOS-specific charmap and/or name entry. - * See @TT_MAC_ID_XXX for corresponding `encoding_id' values. Note that - * most TrueType fonts contain an Apple roman charmap to be usable on - * MacOS systems (even if they contain a Microsoft charmap as well). - * - * TT_PLATFORM_ISO :: - * This value was used to specify ISO/IEC 10646 charmaps. It is however - * now deprecated. See @TT_ISO_ID_XXX for a list of corresponding - * `encoding_id' values. - * - * TT_PLATFORM_MICROSOFT :: - * Used by Microsoft to indicate Windows-specific charmaps. See - * @TT_MS_ID_XXX for a list of corresponding `encoding_id' values. - * Note that most fonts contain a Unicode charmap using - * (TT_PLATFORM_MICROSOFT, @TT_MS_ID_UNICODE_CS). - * - * TT_PLATFORM_CUSTOM :: - * Used to indicate application-specific charmaps. - * - * TT_PLATFORM_ADOBE :: - * This value isn't part of any font format specification, but is used - * by FreeType to report Adobe-specific charmaps in an @FT_CharMapRec - * structure. See @TT_ADOBE_ID_XXX. - */ - -#define TT_PLATFORM_APPLE_UNICODE 0 -#define TT_PLATFORM_MACINTOSH 1 -#define TT_PLATFORM_ISO 2 /* deprecated */ -#define TT_PLATFORM_MICROSOFT 3 -#define TT_PLATFORM_CUSTOM 4 -#define TT_PLATFORM_ADOBE 7 /* artificial */ - - - /*********************************************************************** - * - * @enum: - * TT_APPLE_ID_XXX - * - * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_APPLE_UNICODE charmaps and name entries. - * - * @values: - * TT_APPLE_ID_DEFAULT :: - * Unicode version 1.0. - * - * TT_APPLE_ID_UNICODE_1_1 :: - * Unicode 1.1; specifies Hangul characters starting at U+34xx. - * - * TT_APPLE_ID_ISO_10646 :: - * Deprecated (identical to preceding). - * - * TT_APPLE_ID_UNICODE_2_0 :: - * Unicode 2.0 and beyond (UTF-16 BMP only). - * - * TT_APPLE_ID_UNICODE_32 :: - * Unicode 3.1 and beyond, using UTF-32. - * - * TT_APPLE_ID_VARIANT_SELECTOR :: - * From Adobe, not Apple. Not a normal cmap. Specifies variations - * on a real cmap. - */ - -#define TT_APPLE_ID_DEFAULT 0 /* Unicode 1.0 */ -#define TT_APPLE_ID_UNICODE_1_1 1 /* specify Hangul at U+34xx */ -#define TT_APPLE_ID_ISO_10646 2 /* deprecated */ -#define TT_APPLE_ID_UNICODE_2_0 3 /* or later */ -#define TT_APPLE_ID_UNICODE_32 4 /* 2.0 or later, full repertoire */ -#define TT_APPLE_ID_VARIANT_SELECTOR 5 /* variation selector data */ - - - /*********************************************************************** - * - * @enum: - * TT_MAC_ID_XXX - * - * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_MACINTOSH charmaps and name entries. - * - * @values: - * TT_MAC_ID_ROMAN :: - * TT_MAC_ID_JAPANESE :: - * TT_MAC_ID_TRADITIONAL_CHINESE :: - * TT_MAC_ID_KOREAN :: - * TT_MAC_ID_ARABIC :: - * TT_MAC_ID_HEBREW :: - * TT_MAC_ID_GREEK :: - * TT_MAC_ID_RUSSIAN :: - * TT_MAC_ID_RSYMBOL :: - * TT_MAC_ID_DEVANAGARI :: - * TT_MAC_ID_GURMUKHI :: - * TT_MAC_ID_GUJARATI :: - * TT_MAC_ID_ORIYA :: - * TT_MAC_ID_BENGALI :: - * TT_MAC_ID_TAMIL :: - * TT_MAC_ID_TELUGU :: - * TT_MAC_ID_KANNADA :: - * TT_MAC_ID_MALAYALAM :: - * TT_MAC_ID_SINHALESE :: - * TT_MAC_ID_BURMESE :: - * TT_MAC_ID_KHMER :: - * TT_MAC_ID_THAI :: - * TT_MAC_ID_LAOTIAN :: - * TT_MAC_ID_GEORGIAN :: - * TT_MAC_ID_ARMENIAN :: - * TT_MAC_ID_MALDIVIAN :: - * TT_MAC_ID_SIMPLIFIED_CHINESE :: - * TT_MAC_ID_TIBETAN :: - * TT_MAC_ID_MONGOLIAN :: - * TT_MAC_ID_GEEZ :: - * TT_MAC_ID_SLAVIC :: - * TT_MAC_ID_VIETNAMESE :: - * TT_MAC_ID_SINDHI :: - * TT_MAC_ID_UNINTERP :: - */ - -#define TT_MAC_ID_ROMAN 0 -#define TT_MAC_ID_JAPANESE 1 -#define TT_MAC_ID_TRADITIONAL_CHINESE 2 -#define TT_MAC_ID_KOREAN 3 -#define TT_MAC_ID_ARABIC 4 -#define TT_MAC_ID_HEBREW 5 -#define TT_MAC_ID_GREEK 6 -#define TT_MAC_ID_RUSSIAN 7 -#define TT_MAC_ID_RSYMBOL 8 -#define TT_MAC_ID_DEVANAGARI 9 -#define TT_MAC_ID_GURMUKHI 10 -#define TT_MAC_ID_GUJARATI 11 -#define TT_MAC_ID_ORIYA 12 -#define TT_MAC_ID_BENGALI 13 -#define TT_MAC_ID_TAMIL 14 -#define TT_MAC_ID_TELUGU 15 -#define TT_MAC_ID_KANNADA 16 -#define TT_MAC_ID_MALAYALAM 17 -#define TT_MAC_ID_SINHALESE 18 -#define TT_MAC_ID_BURMESE 19 -#define TT_MAC_ID_KHMER 20 -#define TT_MAC_ID_THAI 21 -#define TT_MAC_ID_LAOTIAN 22 -#define TT_MAC_ID_GEORGIAN 23 -#define TT_MAC_ID_ARMENIAN 24 -#define TT_MAC_ID_MALDIVIAN 25 -#define TT_MAC_ID_SIMPLIFIED_CHINESE 25 -#define TT_MAC_ID_TIBETAN 26 -#define TT_MAC_ID_MONGOLIAN 27 -#define TT_MAC_ID_GEEZ 28 -#define TT_MAC_ID_SLAVIC 29 -#define TT_MAC_ID_VIETNAMESE 30 -#define TT_MAC_ID_SINDHI 31 -#define TT_MAC_ID_UNINTERP 32 - - - /*********************************************************************** - * - * @enum: - * TT_ISO_ID_XXX - * - * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_ISO charmaps and name entries. - * - * Their use is now deprecated. - * - * @values: - * TT_ISO_ID_7BIT_ASCII :: - * ASCII. - * TT_ISO_ID_10646 :: - * ISO/10646. - * TT_ISO_ID_8859_1 :: - * Also known as Latin-1. - */ - -#define TT_ISO_ID_7BIT_ASCII 0 -#define TT_ISO_ID_10646 1 -#define TT_ISO_ID_8859_1 2 - - - /*********************************************************************** - * - * @enum: - * TT_MS_ID_XXX - * - * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_MICROSOFT charmaps and name entries. - * - * @values: - * TT_MS_ID_SYMBOL_CS :: - * Corresponds to Microsoft symbol encoding. See - * @FT_ENCODING_MS_SYMBOL. - * - * TT_MS_ID_UNICODE_CS :: - * Corresponds to a Microsoft WGL4 charmap, matching Unicode. See - * @FT_ENCODING_UNICODE. - * - * TT_MS_ID_SJIS :: - * Corresponds to SJIS Japanese encoding. See @FT_ENCODING_SJIS. - * - * TT_MS_ID_GB2312 :: - * Corresponds to Simplified Chinese as used in Mainland China. See - * @FT_ENCODING_GB2312. - * - * TT_MS_ID_BIG_5 :: - * Corresponds to Traditional Chinese as used in Taiwan and Hong Kong. - * See @FT_ENCODING_BIG5. - * - * TT_MS_ID_WANSUNG :: - * Corresponds to Korean Wansung encoding. See @FT_ENCODING_WANSUNG. - * - * TT_MS_ID_JOHAB :: - * Corresponds to Johab encoding. See @FT_ENCODING_JOHAB. - * - * TT_MS_ID_UCS_4 :: - * Corresponds to UCS-4 or UTF-32 charmaps. This has been added to - * the OpenType specification version 1.4 (mid-2001.) - */ - -#define TT_MS_ID_SYMBOL_CS 0 -#define TT_MS_ID_UNICODE_CS 1 -#define TT_MS_ID_SJIS 2 -#define TT_MS_ID_GB2312 3 -#define TT_MS_ID_BIG_5 4 -#define TT_MS_ID_WANSUNG 5 -#define TT_MS_ID_JOHAB 6 -#define TT_MS_ID_UCS_4 10 - - - /*********************************************************************** - * - * @enum: - * TT_ADOBE_ID_XXX - * - * @description: - * A list of valid values for the `encoding_id' for - * @TT_PLATFORM_ADOBE charmaps. This is a FreeType-specific extension! - * - * @values: - * TT_ADOBE_ID_STANDARD :: - * Adobe standard encoding. - * TT_ADOBE_ID_EXPERT :: - * Adobe expert encoding. - * TT_ADOBE_ID_CUSTOM :: - * Adobe custom encoding. - * TT_ADOBE_ID_LATIN_1 :: - * Adobe Latin~1 encoding. - */ - -#define TT_ADOBE_ID_STANDARD 0 -#define TT_ADOBE_ID_EXPERT 1 -#define TT_ADOBE_ID_CUSTOM 2 -#define TT_ADOBE_ID_LATIN_1 3 - - - /*************************************************************************/ - /* */ - /* Possible values of the language identifier field in the name records */ - /* of the TTF `name' table if the `platform' identifier code is */ - /* TT_PLATFORM_MACINTOSH. These values are also used as return values */ - /* for function @FT_Get_CMap_Language_ID. */ - /* */ - /* The canonical source for the Apple assigned Language ID's is at */ - /* */ - /* https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6name.html */ - /* */ -#define TT_MAC_LANGID_ENGLISH 0 -#define TT_MAC_LANGID_FRENCH 1 -#define TT_MAC_LANGID_GERMAN 2 -#define TT_MAC_LANGID_ITALIAN 3 -#define TT_MAC_LANGID_DUTCH 4 -#define TT_MAC_LANGID_SWEDISH 5 -#define TT_MAC_LANGID_SPANISH 6 -#define TT_MAC_LANGID_DANISH 7 -#define TT_MAC_LANGID_PORTUGUESE 8 -#define TT_MAC_LANGID_NORWEGIAN 9 -#define TT_MAC_LANGID_HEBREW 10 -#define TT_MAC_LANGID_JAPANESE 11 -#define TT_MAC_LANGID_ARABIC 12 -#define TT_MAC_LANGID_FINNISH 13 -#define TT_MAC_LANGID_GREEK 14 -#define TT_MAC_LANGID_ICELANDIC 15 -#define TT_MAC_LANGID_MALTESE 16 -#define TT_MAC_LANGID_TURKISH 17 -#define TT_MAC_LANGID_CROATIAN 18 -#define TT_MAC_LANGID_CHINESE_TRADITIONAL 19 -#define TT_MAC_LANGID_URDU 20 -#define TT_MAC_LANGID_HINDI 21 -#define TT_MAC_LANGID_THAI 22 -#define TT_MAC_LANGID_KOREAN 23 -#define TT_MAC_LANGID_LITHUANIAN 24 -#define TT_MAC_LANGID_POLISH 25 -#define TT_MAC_LANGID_HUNGARIAN 26 -#define TT_MAC_LANGID_ESTONIAN 27 -#define TT_MAC_LANGID_LETTISH 28 -#define TT_MAC_LANGID_SAAMISK 29 -#define TT_MAC_LANGID_FAEROESE 30 -#define TT_MAC_LANGID_FARSI 31 -#define TT_MAC_LANGID_RUSSIAN 32 -#define TT_MAC_LANGID_CHINESE_SIMPLIFIED 33 -#define TT_MAC_LANGID_FLEMISH 34 -#define TT_MAC_LANGID_IRISH 35 -#define TT_MAC_LANGID_ALBANIAN 36 -#define TT_MAC_LANGID_ROMANIAN 37 -#define TT_MAC_LANGID_CZECH 38 -#define TT_MAC_LANGID_SLOVAK 39 -#define TT_MAC_LANGID_SLOVENIAN 40 -#define TT_MAC_LANGID_YIDDISH 41 -#define TT_MAC_LANGID_SERBIAN 42 -#define TT_MAC_LANGID_MACEDONIAN 43 -#define TT_MAC_LANGID_BULGARIAN 44 -#define TT_MAC_LANGID_UKRAINIAN 45 -#define TT_MAC_LANGID_BYELORUSSIAN 46 -#define TT_MAC_LANGID_UZBEK 47 -#define TT_MAC_LANGID_KAZAKH 48 -#define TT_MAC_LANGID_AZERBAIJANI 49 -#define TT_MAC_LANGID_AZERBAIJANI_CYRILLIC_SCRIPT 49 -#define TT_MAC_LANGID_AZERBAIJANI_ARABIC_SCRIPT 50 -#define TT_MAC_LANGID_ARMENIAN 51 -#define TT_MAC_LANGID_GEORGIAN 52 -#define TT_MAC_LANGID_MOLDAVIAN 53 -#define TT_MAC_LANGID_KIRGHIZ 54 -#define TT_MAC_LANGID_TAJIKI 55 -#define TT_MAC_LANGID_TURKMEN 56 -#define TT_MAC_LANGID_MONGOLIAN 57 -#define TT_MAC_LANGID_MONGOLIAN_MONGOLIAN_SCRIPT 57 -#define TT_MAC_LANGID_MONGOLIAN_CYRILLIC_SCRIPT 58 -#define TT_MAC_LANGID_PASHTO 59 -#define TT_MAC_LANGID_KURDISH 60 -#define TT_MAC_LANGID_KASHMIRI 61 -#define TT_MAC_LANGID_SINDHI 62 -#define TT_MAC_LANGID_TIBETAN 63 -#define TT_MAC_LANGID_NEPALI 64 -#define TT_MAC_LANGID_SANSKRIT 65 -#define TT_MAC_LANGID_MARATHI 66 -#define TT_MAC_LANGID_BENGALI 67 -#define TT_MAC_LANGID_ASSAMESE 68 -#define TT_MAC_LANGID_GUJARATI 69 -#define TT_MAC_LANGID_PUNJABI 70 -#define TT_MAC_LANGID_ORIYA 71 -#define TT_MAC_LANGID_MALAYALAM 72 -#define TT_MAC_LANGID_KANNADA 73 -#define TT_MAC_LANGID_TAMIL 74 -#define TT_MAC_LANGID_TELUGU 75 -#define TT_MAC_LANGID_SINHALESE 76 -#define TT_MAC_LANGID_BURMESE 77 -#define TT_MAC_LANGID_KHMER 78 -#define TT_MAC_LANGID_LAO 79 -#define TT_MAC_LANGID_VIETNAMESE 80 -#define TT_MAC_LANGID_INDONESIAN 81 -#define TT_MAC_LANGID_TAGALOG 82 -#define TT_MAC_LANGID_MALAY_ROMAN_SCRIPT 83 -#define TT_MAC_LANGID_MALAY_ARABIC_SCRIPT 84 -#define TT_MAC_LANGID_AMHARIC 85 -#define TT_MAC_LANGID_TIGRINYA 86 -#define TT_MAC_LANGID_GALLA 87 -#define TT_MAC_LANGID_SOMALI 88 -#define TT_MAC_LANGID_SWAHILI 89 -#define TT_MAC_LANGID_RUANDA 90 -#define TT_MAC_LANGID_RUNDI 91 -#define TT_MAC_LANGID_CHEWA 92 -#define TT_MAC_LANGID_MALAGASY 93 -#define TT_MAC_LANGID_ESPERANTO 94 -#define TT_MAC_LANGID_WELSH 128 -#define TT_MAC_LANGID_BASQUE 129 -#define TT_MAC_LANGID_CATALAN 130 -#define TT_MAC_LANGID_LATIN 131 -#define TT_MAC_LANGID_QUECHUA 132 -#define TT_MAC_LANGID_GUARANI 133 -#define TT_MAC_LANGID_AYMARA 134 -#define TT_MAC_LANGID_TATAR 135 -#define TT_MAC_LANGID_UIGHUR 136 -#define TT_MAC_LANGID_DZONGKHA 137 -#define TT_MAC_LANGID_JAVANESE 138 -#define TT_MAC_LANGID_SUNDANESE 139 - - -#if 0 /* these seem to be errors that have been dropped */ - -#define TT_MAC_LANGID_SCOTTISH_GAELIC 140 -#define TT_MAC_LANGID_IRISH_GAELIC 141 - -#endif - - - /* The following codes are new as of 2000-03-10 */ -#define TT_MAC_LANGID_GALICIAN 140 -#define TT_MAC_LANGID_AFRIKAANS 141 -#define TT_MAC_LANGID_BRETON 142 -#define TT_MAC_LANGID_INUKTITUT 143 -#define TT_MAC_LANGID_SCOTTISH_GAELIC 144 -#define TT_MAC_LANGID_MANX_GAELIC 145 -#define TT_MAC_LANGID_IRISH_GAELIC 146 -#define TT_MAC_LANGID_TONGAN 147 -#define TT_MAC_LANGID_GREEK_POLYTONIC 148 -#define TT_MAC_LANGID_GREELANDIC 149 -#define TT_MAC_LANGID_AZERBAIJANI_ROMAN_SCRIPT 150 - - - /*************************************************************************/ - /* */ - /* Possible values of the language identifier field in the name records */ - /* of the TTF `name' table if the `platform' identifier code is */ - /* TT_PLATFORM_MICROSOFT. */ - /* */ - /* The canonical source for the MS assigned LCIDs is */ - /* */ - /* http://www.microsoft.com/globaldev/reference/lcid-all.mspx */ - /* */ - -#define TT_MS_LANGID_ARABIC_GENERAL 0x0001 -#define TT_MS_LANGID_ARABIC_SAUDI_ARABIA 0x0401 -#define TT_MS_LANGID_ARABIC_IRAQ 0x0801 -#define TT_MS_LANGID_ARABIC_EGYPT 0x0C01 -#define TT_MS_LANGID_ARABIC_LIBYA 0x1001 -#define TT_MS_LANGID_ARABIC_ALGERIA 0x1401 -#define TT_MS_LANGID_ARABIC_MOROCCO 0x1801 -#define TT_MS_LANGID_ARABIC_TUNISIA 0x1C01 -#define TT_MS_LANGID_ARABIC_OMAN 0x2001 -#define TT_MS_LANGID_ARABIC_YEMEN 0x2401 -#define TT_MS_LANGID_ARABIC_SYRIA 0x2801 -#define TT_MS_LANGID_ARABIC_JORDAN 0x2C01 -#define TT_MS_LANGID_ARABIC_LEBANON 0x3001 -#define TT_MS_LANGID_ARABIC_KUWAIT 0x3401 -#define TT_MS_LANGID_ARABIC_UAE 0x3801 -#define TT_MS_LANGID_ARABIC_BAHRAIN 0x3C01 -#define TT_MS_LANGID_ARABIC_QATAR 0x4001 -#define TT_MS_LANGID_BULGARIAN_BULGARIA 0x0402 -#define TT_MS_LANGID_CATALAN_SPAIN 0x0403 -#define TT_MS_LANGID_CHINESE_GENERAL 0x0004 -#define TT_MS_LANGID_CHINESE_TAIWAN 0x0404 -#define TT_MS_LANGID_CHINESE_PRC 0x0804 -#define TT_MS_LANGID_CHINESE_HONG_KONG 0x0C04 -#define TT_MS_LANGID_CHINESE_SINGAPORE 0x1004 - -#if 1 /* this looks like the correct value */ -#define TT_MS_LANGID_CHINESE_MACAU 0x1404 -#else /* but beware, Microsoft may change its mind... - the most recent Word reference has the following: */ -#define TT_MS_LANGID_CHINESE_MACAU TT_MS_LANGID_CHINESE_HONG_KONG -#endif - -#if 0 /* used only with .NET `cultures'; commented out */ -#define TT_MS_LANGID_CHINESE_TRADITIONAL 0x7C04 -#endif - -#define TT_MS_LANGID_CZECH_CZECH_REPUBLIC 0x0405 -#define TT_MS_LANGID_DANISH_DENMARK 0x0406 -#define TT_MS_LANGID_GERMAN_GERMANY 0x0407 -#define TT_MS_LANGID_GERMAN_SWITZERLAND 0x0807 -#define TT_MS_LANGID_GERMAN_AUSTRIA 0x0C07 -#define TT_MS_LANGID_GERMAN_LUXEMBOURG 0x1007 -#define TT_MS_LANGID_GERMAN_LIECHTENSTEI 0x1407 -#define TT_MS_LANGID_GREEK_GREECE 0x0408 - - /* don't ask what this one means... It is commented out currently. */ -#if 0 -#define TT_MS_LANGID_GREEK_GREECE2 0x2008 -#endif - -#define TT_MS_LANGID_ENGLISH_GENERAL 0x0009 -#define TT_MS_LANGID_ENGLISH_UNITED_STATES 0x0409 -#define TT_MS_LANGID_ENGLISH_UNITED_KINGDOM 0x0809 -#define TT_MS_LANGID_ENGLISH_AUSTRALIA 0x0C09 -#define TT_MS_LANGID_ENGLISH_CANADA 0x1009 -#define TT_MS_LANGID_ENGLISH_NEW_ZEALAND 0x1409 -#define TT_MS_LANGID_ENGLISH_IRELAND 0x1809 -#define TT_MS_LANGID_ENGLISH_SOUTH_AFRICA 0x1C09 -#define TT_MS_LANGID_ENGLISH_JAMAICA 0x2009 -#define TT_MS_LANGID_ENGLISH_CARIBBEAN 0x2409 -#define TT_MS_LANGID_ENGLISH_BELIZE 0x2809 -#define TT_MS_LANGID_ENGLISH_TRINIDAD 0x2C09 -#define TT_MS_LANGID_ENGLISH_ZIMBABWE 0x3009 -#define TT_MS_LANGID_ENGLISH_PHILIPPINES 0x3409 -#define TT_MS_LANGID_ENGLISH_INDONESIA 0x3809 -#define TT_MS_LANGID_ENGLISH_HONG_KONG 0x3C09 -#define TT_MS_LANGID_ENGLISH_INDIA 0x4009 -#define TT_MS_LANGID_ENGLISH_MALAYSIA 0x4409 -#define TT_MS_LANGID_ENGLISH_SINGAPORE 0x4809 -#define TT_MS_LANGID_SPANISH_SPAIN_TRADITIONAL_SORT 0x040A -#define TT_MS_LANGID_SPANISH_MEXICO 0x080A -#define TT_MS_LANGID_SPANISH_SPAIN_INTERNATIONAL_SORT 0x0C0A -#define TT_MS_LANGID_SPANISH_GUATEMALA 0x100A -#define TT_MS_LANGID_SPANISH_COSTA_RICA 0x140A -#define TT_MS_LANGID_SPANISH_PANAMA 0x180A -#define TT_MS_LANGID_SPANISH_DOMINICAN_REPUBLIC 0x1C0A -#define TT_MS_LANGID_SPANISH_VENEZUELA 0x200A -#define TT_MS_LANGID_SPANISH_COLOMBIA 0x240A -#define TT_MS_LANGID_SPANISH_PERU 0x280A -#define TT_MS_LANGID_SPANISH_ARGENTINA 0x2C0A -#define TT_MS_LANGID_SPANISH_ECUADOR 0x300A -#define TT_MS_LANGID_SPANISH_CHILE 0x340A -#define TT_MS_LANGID_SPANISH_URUGUAY 0x380A -#define TT_MS_LANGID_SPANISH_PARAGUAY 0x3C0A -#define TT_MS_LANGID_SPANISH_BOLIVIA 0x400A -#define TT_MS_LANGID_SPANISH_EL_SALVADOR 0x440A -#define TT_MS_LANGID_SPANISH_HONDURAS 0x480A -#define TT_MS_LANGID_SPANISH_NICARAGUA 0x4C0A -#define TT_MS_LANGID_SPANISH_PUERTO_RICO 0x500A -#define TT_MS_LANGID_SPANISH_UNITED_STATES 0x540A - /* The following ID blatantly violate MS specs by using a */ - /* sublanguage > 0x1F. */ -#define TT_MS_LANGID_SPANISH_LATIN_AMERICA 0xE40AU -#define TT_MS_LANGID_FINNISH_FINLAND 0x040B -#define TT_MS_LANGID_FRENCH_FRANCE 0x040C -#define TT_MS_LANGID_FRENCH_BELGIUM 0x080C -#define TT_MS_LANGID_FRENCH_CANADA 0x0C0C -#define TT_MS_LANGID_FRENCH_SWITZERLAND 0x100C -#define TT_MS_LANGID_FRENCH_LUXEMBOURG 0x140C -#define TT_MS_LANGID_FRENCH_MONACO 0x180C -#define TT_MS_LANGID_FRENCH_WEST_INDIES 0x1C0C -#define TT_MS_LANGID_FRENCH_REUNION 0x200C -#define TT_MS_LANGID_FRENCH_CONGO 0x240C - /* which was formerly: */ -#define TT_MS_LANGID_FRENCH_ZAIRE TT_MS_LANGID_FRENCH_CONGO -#define TT_MS_LANGID_FRENCH_SENEGAL 0x280C -#define TT_MS_LANGID_FRENCH_CAMEROON 0x2C0C -#define TT_MS_LANGID_FRENCH_COTE_D_IVOIRE 0x300C -#define TT_MS_LANGID_FRENCH_MALI 0x340C -#define TT_MS_LANGID_FRENCH_MOROCCO 0x380C -#define TT_MS_LANGID_FRENCH_HAITI 0x3C0C - /* and another violation of the spec (see 0xE40AU) */ -#define TT_MS_LANGID_FRENCH_NORTH_AFRICA 0xE40CU -#define TT_MS_LANGID_HEBREW_ISRAEL 0x040D -#define TT_MS_LANGID_HUNGARIAN_HUNGARY 0x040E -#define TT_MS_LANGID_ICELANDIC_ICELAND 0x040F -#define TT_MS_LANGID_ITALIAN_ITALY 0x0410 -#define TT_MS_LANGID_ITALIAN_SWITZERLAND 0x0810 -#define TT_MS_LANGID_JAPANESE_JAPAN 0x0411 -#define TT_MS_LANGID_KOREAN_EXTENDED_WANSUNG_KOREA 0x0412 -#define TT_MS_LANGID_KOREAN_JOHAB_KOREA 0x0812 -#define TT_MS_LANGID_DUTCH_NETHERLANDS 0x0413 -#define TT_MS_LANGID_DUTCH_BELGIUM 0x0813 -#define TT_MS_LANGID_NORWEGIAN_NORWAY_BOKMAL 0x0414 -#define TT_MS_LANGID_NORWEGIAN_NORWAY_NYNORSK 0x0814 -#define TT_MS_LANGID_POLISH_POLAND 0x0415 -#define TT_MS_LANGID_PORTUGUESE_BRAZIL 0x0416 -#define TT_MS_LANGID_PORTUGUESE_PORTUGAL 0x0816 -#define TT_MS_LANGID_RHAETO_ROMANIC_SWITZERLAND 0x0417 -#define TT_MS_LANGID_ROMANIAN_ROMANIA 0x0418 -#define TT_MS_LANGID_MOLDAVIAN_MOLDAVIA 0x0818 -#define TT_MS_LANGID_RUSSIAN_RUSSIA 0x0419 -#define TT_MS_LANGID_RUSSIAN_MOLDAVIA 0x0819 -#define TT_MS_LANGID_CROATIAN_CROATIA 0x041A -#define TT_MS_LANGID_SERBIAN_SERBIA_LATIN 0x081A -#define TT_MS_LANGID_SERBIAN_SERBIA_CYRILLIC 0x0C1A - -#if 0 /* this used to be this value, but it looks like we were wrong */ -#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x101A -#else /* current sources say */ -#define TT_MS_LANGID_CROATIAN_BOSNIA_HERZEGOVINA 0x101A -#define TT_MS_LANGID_BOSNIAN_BOSNIA_HERZEGOVINA 0x141A - /* and XPsp2 Platform SDK added (2004-07-26) */ - /* Names are shortened to be significant within 40 chars. */ -#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_LATIN 0x181A -#define TT_MS_LANGID_SERBIAN_BOSNIA_HERZ_CYRILLIC 0x181A -#endif - -#define TT_MS_LANGID_SLOVAK_SLOVAKIA 0x041B -#define TT_MS_LANGID_ALBANIAN_ALBANIA 0x041C -#define TT_MS_LANGID_SWEDISH_SWEDEN 0x041D -#define TT_MS_LANGID_SWEDISH_FINLAND 0x081D -#define TT_MS_LANGID_THAI_THAILAND 0x041E -#define TT_MS_LANGID_TURKISH_TURKEY 0x041F -#define TT_MS_LANGID_URDU_PAKISTAN 0x0420 -#define TT_MS_LANGID_URDU_INDIA 0x0820 -#define TT_MS_LANGID_INDONESIAN_INDONESIA 0x0421 -#define TT_MS_LANGID_UKRAINIAN_UKRAINE 0x0422 -#define TT_MS_LANGID_BELARUSIAN_BELARUS 0x0423 -#define TT_MS_LANGID_SLOVENE_SLOVENIA 0x0424 -#define TT_MS_LANGID_ESTONIAN_ESTONIA 0x0425 -#define TT_MS_LANGID_LATVIAN_LATVIA 0x0426 -#define TT_MS_LANGID_LITHUANIAN_LITHUANIA 0x0427 -#define TT_MS_LANGID_CLASSIC_LITHUANIAN_LITHUANIA 0x0827 -#define TT_MS_LANGID_TAJIK_TAJIKISTAN 0x0428 -#define TT_MS_LANGID_FARSI_IRAN 0x0429 -#define TT_MS_LANGID_VIETNAMESE_VIET_NAM 0x042A -#define TT_MS_LANGID_ARMENIAN_ARMENIA 0x042B -#define TT_MS_LANGID_AZERI_AZERBAIJAN_LATIN 0x042C -#define TT_MS_LANGID_AZERI_AZERBAIJAN_CYRILLIC 0x082C -#define TT_MS_LANGID_BASQUE_SPAIN 0x042D -#define TT_MS_LANGID_SORBIAN_GERMANY 0x042E -#define TT_MS_LANGID_MACEDONIAN_MACEDONIA 0x042F -#define TT_MS_LANGID_SUTU_SOUTH_AFRICA 0x0430 -#define TT_MS_LANGID_TSONGA_SOUTH_AFRICA 0x0431 -#define TT_MS_LANGID_TSWANA_SOUTH_AFRICA 0x0432 -#define TT_MS_LANGID_VENDA_SOUTH_AFRICA 0x0433 -#define TT_MS_LANGID_XHOSA_SOUTH_AFRICA 0x0434 -#define TT_MS_LANGID_ZULU_SOUTH_AFRICA 0x0435 -#define TT_MS_LANGID_AFRIKAANS_SOUTH_AFRICA 0x0436 -#define TT_MS_LANGID_GEORGIAN_GEORGIA 0x0437 -#define TT_MS_LANGID_FAEROESE_FAEROE_ISLANDS 0x0438 -#define TT_MS_LANGID_HINDI_INDIA 0x0439 -#define TT_MS_LANGID_MALTESE_MALTA 0x043A - /* Added by XPsp2 Platform SDK (2004-07-26) */ -#define TT_MS_LANGID_SAMI_NORTHERN_NORWAY 0x043B -#define TT_MS_LANGID_SAMI_NORTHERN_SWEDEN 0x083B -#define TT_MS_LANGID_SAMI_NORTHERN_FINLAND 0x0C3B -#define TT_MS_LANGID_SAMI_LULE_NORWAY 0x103B -#define TT_MS_LANGID_SAMI_LULE_SWEDEN 0x143B -#define TT_MS_LANGID_SAMI_SOUTHERN_NORWAY 0x183B -#define TT_MS_LANGID_SAMI_SOUTHERN_SWEDEN 0x1C3B -#define TT_MS_LANGID_SAMI_SKOLT_FINLAND 0x203B -#define TT_MS_LANGID_SAMI_INARI_FINLAND 0x243B - /* ... and we also keep our old identifier... */ -#define TT_MS_LANGID_SAAMI_LAPONIA 0x043B - -#if 0 /* this seems to be a previous inversion */ -#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C -#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C -#else -#define TT_MS_LANGID_SCOTTISH_GAELIC_UNITED_KINGDOM 0x083C -#define TT_MS_LANGID_IRISH_GAELIC_IRELAND 0x043C -#endif - -#define TT_MS_LANGID_YIDDISH_GERMANY 0x043D -#define TT_MS_LANGID_MALAY_MALAYSIA 0x043E -#define TT_MS_LANGID_MALAY_BRUNEI_DARUSSALAM 0x083E -#define TT_MS_LANGID_KAZAK_KAZAKSTAN 0x043F -#define TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN /* Cyrillic*/ 0x0440 - /* alias declared in Windows 2000 */ -#define TT_MS_LANGID_KIRGHIZ_KIRGHIZ_REPUBLIC \ - TT_MS_LANGID_KIRGHIZ_KIRGHIZSTAN - -#define TT_MS_LANGID_SWAHILI_KENYA 0x0441 -#define TT_MS_LANGID_TURKMEN_TURKMENISTAN 0x0442 -#define TT_MS_LANGID_UZBEK_UZBEKISTAN_LATIN 0x0443 -#define TT_MS_LANGID_UZBEK_UZBEKISTAN_CYRILLIC 0x0843 -#define TT_MS_LANGID_TATAR_TATARSTAN 0x0444 -#define TT_MS_LANGID_BENGALI_INDIA 0x0445 -#define TT_MS_LANGID_BENGALI_BANGLADESH 0x0845 -#define TT_MS_LANGID_PUNJABI_INDIA 0x0446 -#define TT_MS_LANGID_PUNJABI_ARABIC_PAKISTAN 0x0846 -#define TT_MS_LANGID_GUJARATI_INDIA 0x0447 -#define TT_MS_LANGID_ORIYA_INDIA 0x0448 -#define TT_MS_LANGID_TAMIL_INDIA 0x0449 -#define TT_MS_LANGID_TELUGU_INDIA 0x044A -#define TT_MS_LANGID_KANNADA_INDIA 0x044B -#define TT_MS_LANGID_MALAYALAM_INDIA 0x044C -#define TT_MS_LANGID_ASSAMESE_INDIA 0x044D -#define TT_MS_LANGID_MARATHI_INDIA 0x044E -#define TT_MS_LANGID_SANSKRIT_INDIA 0x044F -#define TT_MS_LANGID_MONGOLIAN_MONGOLIA /* Cyrillic */ 0x0450 -#define TT_MS_LANGID_MONGOLIAN_MONGOLIA_MONGOLIAN 0x0850 -#define TT_MS_LANGID_TIBETAN_CHINA 0x0451 - /* Don't use the next constant! It has */ - /* (1) the wrong spelling (Dzonghka) */ - /* (2) Microsoft doesn't officially define it -- */ - /* at least it is not in the List of Local */ - /* ID Values. */ - /* (3) Dzongkha is not the same language as */ - /* Tibetan, so merging it is wrong anyway. */ - /* */ - /* TT_MS_LANGID_TIBETAN_BHUTAN is correct, BTW. */ -#define TT_MS_LANGID_DZONGHKA_BHUTAN 0x0851 - -#if 0 - /* the following used to be defined */ -#define TT_MS_LANGID_TIBETAN_BHUTAN 0x0451 - /* ... but it was changed; */ -#else - /* So we will continue to #define it, but with the correct value */ -#define TT_MS_LANGID_TIBETAN_BHUTAN TT_MS_LANGID_DZONGHKA_BHUTAN -#endif - -#define TT_MS_LANGID_WELSH_WALES 0x0452 -#define TT_MS_LANGID_KHMER_CAMBODIA 0x0453 -#define TT_MS_LANGID_LAO_LAOS 0x0454 -#define TT_MS_LANGID_BURMESE_MYANMAR 0x0455 -#define TT_MS_LANGID_GALICIAN_SPAIN 0x0456 -#define TT_MS_LANGID_KONKANI_INDIA 0x0457 -#define TT_MS_LANGID_MANIPURI_INDIA /* Bengali */ 0x0458 -#define TT_MS_LANGID_SINDHI_INDIA /* Arabic */ 0x0459 -#define TT_MS_LANGID_SINDHI_PAKISTAN 0x0859 - /* Missing a LCID for Sindhi in Devanagari script */ -#define TT_MS_LANGID_SYRIAC_SYRIA 0x045A -#define TT_MS_LANGID_SINHALESE_SRI_LANKA 0x045B -#define TT_MS_LANGID_CHEROKEE_UNITED_STATES 0x045C -#define TT_MS_LANGID_INUKTITUT_CANADA 0x045D -#define TT_MS_LANGID_AMHARIC_ETHIOPIA 0x045E -#define TT_MS_LANGID_TAMAZIGHT_MOROCCO /* Arabic */ 0x045F -#define TT_MS_LANGID_TAMAZIGHT_MOROCCO_LATIN 0x085F - /* Missing a LCID for Tifinagh script */ -#define TT_MS_LANGID_KASHMIRI_PAKISTAN /* Arabic */ 0x0460 - /* Spelled this way by XPsp2 Platform SDK (2004-07-26) */ - /* script is yet unclear... might be Arabic, Nagari or Sharada */ -#define TT_MS_LANGID_KASHMIRI_SASIA 0x0860 - /* ... and aliased (by MS) for compatibility reasons. */ -#define TT_MS_LANGID_KASHMIRI_INDIA TT_MS_LANGID_KASHMIRI_SASIA -#define TT_MS_LANGID_NEPALI_NEPAL 0x0461 -#define TT_MS_LANGID_NEPALI_INDIA 0x0861 -#define TT_MS_LANGID_FRISIAN_NETHERLANDS 0x0462 -#define TT_MS_LANGID_PASHTO_AFGHANISTAN 0x0463 -#define TT_MS_LANGID_FILIPINO_PHILIPPINES 0x0464 -#define TT_MS_LANGID_DHIVEHI_MALDIVES 0x0465 - /* alias declared in Windows 2000 */ -#define TT_MS_LANGID_DIVEHI_MALDIVES TT_MS_LANGID_DHIVEHI_MALDIVES -#define TT_MS_LANGID_EDO_NIGERIA 0x0466 -#define TT_MS_LANGID_FULFULDE_NIGERIA 0x0467 -#define TT_MS_LANGID_HAUSA_NIGERIA 0x0468 -#define TT_MS_LANGID_IBIBIO_NIGERIA 0x0469 -#define TT_MS_LANGID_YORUBA_NIGERIA 0x046A -#define TT_MS_LANGID_QUECHUA_BOLIVIA 0x046B -#define TT_MS_LANGID_QUECHUA_ECUADOR 0x086B -#define TT_MS_LANGID_QUECHUA_PERU 0x0C6B -#define TT_MS_LANGID_SEPEDI_SOUTH_AFRICA 0x046C - /* Also spelled by XPsp2 Platform SDK (2004-07-26) */ -#define TT_MS_LANGID_SOTHO_SOUTHERN_SOUTH_AFRICA \ - TT_MS_LANGID_SEPEDI_SOUTH_AFRICA - /* language codes 0x046D, 0x046E and 0x046F are (still) unknown. */ -#define TT_MS_LANGID_IGBO_NIGERIA 0x0470 -#define TT_MS_LANGID_KANURI_NIGERIA 0x0471 -#define TT_MS_LANGID_OROMO_ETHIOPIA 0x0472 -#define TT_MS_LANGID_TIGRIGNA_ETHIOPIA 0x0473 -#define TT_MS_LANGID_TIGRIGNA_ERYTHREA 0x0873 - /* also spelled in the `Passport SDK' list as: */ -#define TT_MS_LANGID_TIGRIGNA_ERYTREA TT_MS_LANGID_TIGRIGNA_ERYTHREA -#define TT_MS_LANGID_GUARANI_PARAGUAY 0x0474 -#define TT_MS_LANGID_HAWAIIAN_UNITED_STATES 0x0475 -#define TT_MS_LANGID_LATIN 0x0476 -#define TT_MS_LANGID_SOMALI_SOMALIA 0x0477 - /* Note: Yi does not have a (proper) ISO 639-2 code, since it is mostly */ - /* not written (but OTOH the peculiar writing system is worth */ - /* studying). */ -#define TT_MS_LANGID_YI_CHINA 0x0478 -#define TT_MS_LANGID_PAPIAMENTU_NETHERLANDS_ANTILLES 0x0479 - /* language codes from 0x047A to 0x047F are (still) unknown. */ -#define TT_MS_LANGID_UIGHUR_CHINA 0x0480 -#define TT_MS_LANGID_MAORI_NEW_ZEALAND 0x0481 - -#if 0 /* not deemed useful for fonts */ -#define TT_MS_LANGID_HUMAN_INTERFACE_DEVICE 0x04FF -#endif - - - /*************************************************************************/ - /* */ - /* Possible values of the `name' identifier field in the name records of */ - /* the TTF `name' table. These values are platform independent. */ - /* */ -#define TT_NAME_ID_COPYRIGHT 0 -#define TT_NAME_ID_FONT_FAMILY 1 -#define TT_NAME_ID_FONT_SUBFAMILY 2 -#define TT_NAME_ID_UNIQUE_ID 3 -#define TT_NAME_ID_FULL_NAME 4 -#define TT_NAME_ID_VERSION_STRING 5 -#define TT_NAME_ID_PS_NAME 6 -#define TT_NAME_ID_TRADEMARK 7 - - /* the following values are from the OpenType spec */ -#define TT_NAME_ID_MANUFACTURER 8 -#define TT_NAME_ID_DESIGNER 9 -#define TT_NAME_ID_DESCRIPTION 10 -#define TT_NAME_ID_VENDOR_URL 11 -#define TT_NAME_ID_DESIGNER_URL 12 -#define TT_NAME_ID_LICENSE 13 -#define TT_NAME_ID_LICENSE_URL 14 - /* number 15 is reserved */ -#define TT_NAME_ID_PREFERRED_FAMILY 16 -#define TT_NAME_ID_PREFERRED_SUBFAMILY 17 -#define TT_NAME_ID_MAC_FULL_NAME 18 - - /* The following code is new as of 2000-01-21 */ -#define TT_NAME_ID_SAMPLE_TEXT 19 - - /* This is new in OpenType 1.3 */ -#define TT_NAME_ID_CID_FINDFONT_NAME 20 - - /* This is new in OpenType 1.5 */ -#define TT_NAME_ID_WWS_FAMILY 21 -#define TT_NAME_ID_WWS_SUBFAMILY 22 - - - /*************************************************************************/ - /* */ - /* Bit mask values for the Unicode Ranges from the TTF `OS2 ' table. */ - /* */ - /* Updated 08-Nov-2008. */ - /* */ - - /* Bit 0 Basic Latin */ -#define TT_UCR_BASIC_LATIN (1L << 0) /* U+0020-U+007E */ - /* Bit 1 C1 Controls and Latin-1 Supplement */ -#define TT_UCR_LATIN1_SUPPLEMENT (1L << 1) /* U+0080-U+00FF */ - /* Bit 2 Latin Extended-A */ -#define TT_UCR_LATIN_EXTENDED_A (1L << 2) /* U+0100-U+017F */ - /* Bit 3 Latin Extended-B */ -#define TT_UCR_LATIN_EXTENDED_B (1L << 3) /* U+0180-U+024F */ - /* Bit 4 IPA Extensions */ - /* Phonetic Extensions */ - /* Phonetic Extensions Supplement */ -#define TT_UCR_IPA_EXTENSIONS (1L << 4) /* U+0250-U+02AF */ - /* U+1D00-U+1D7F */ - /* U+1D80-U+1DBF */ - /* Bit 5 Spacing Modifier Letters */ - /* Modifier Tone Letters */ -#define TT_UCR_SPACING_MODIFIER (1L << 5) /* U+02B0-U+02FF */ - /* U+A700-U+A71F */ - /* Bit 6 Combining Diacritical Marks */ - /* Combining Diacritical Marks Supplement */ -#define TT_UCR_COMBINING_DIACRITICS (1L << 6) /* U+0300-U+036F */ - /* U+1DC0-U+1DFF */ - /* Bit 7 Greek and Coptic */ -#define TT_UCR_GREEK (1L << 7) /* U+0370-U+03FF */ - /* Bit 8 Coptic */ -#define TT_UCR_COPTIC (1L << 8) /* U+2C80-U+2CFF */ - /* Bit 9 Cyrillic */ - /* Cyrillic Supplement */ - /* Cyrillic Extended-A */ - /* Cyrillic Extended-B */ -#define TT_UCR_CYRILLIC (1L << 9) /* U+0400-U+04FF */ - /* U+0500-U+052F */ - /* U+2DE0-U+2DFF */ - /* U+A640-U+A69F */ - /* Bit 10 Armenian */ -#define TT_UCR_ARMENIAN (1L << 10) /* U+0530-U+058F */ - /* Bit 11 Hebrew */ -#define TT_UCR_HEBREW (1L << 11) /* U+0590-U+05FF */ - /* Bit 12 Vai */ -#define TT_UCR_VAI (1L << 12) /* U+A500-U+A63F */ - /* Bit 13 Arabic */ - /* Arabic Supplement */ -#define TT_UCR_ARABIC (1L << 13) /* U+0600-U+06FF */ - /* U+0750-U+077F */ - /* Bit 14 NKo */ -#define TT_UCR_NKO (1L << 14) /* U+07C0-U+07FF */ - /* Bit 15 Devanagari */ -#define TT_UCR_DEVANAGARI (1L << 15) /* U+0900-U+097F */ - /* Bit 16 Bengali */ -#define TT_UCR_BENGALI (1L << 16) /* U+0980-U+09FF */ - /* Bit 17 Gurmukhi */ -#define TT_UCR_GURMUKHI (1L << 17) /* U+0A00-U+0A7F */ - /* Bit 18 Gujarati */ -#define TT_UCR_GUJARATI (1L << 18) /* U+0A80-U+0AFF */ - /* Bit 19 Oriya */ -#define TT_UCR_ORIYA (1L << 19) /* U+0B00-U+0B7F */ - /* Bit 20 Tamil */ -#define TT_UCR_TAMIL (1L << 20) /* U+0B80-U+0BFF */ - /* Bit 21 Telugu */ -#define TT_UCR_TELUGU (1L << 21) /* U+0C00-U+0C7F */ - /* Bit 22 Kannada */ -#define TT_UCR_KANNADA (1L << 22) /* U+0C80-U+0CFF */ - /* Bit 23 Malayalam */ -#define TT_UCR_MALAYALAM (1L << 23) /* U+0D00-U+0D7F */ - /* Bit 24 Thai */ -#define TT_UCR_THAI (1L << 24) /* U+0E00-U+0E7F */ - /* Bit 25 Lao */ -#define TT_UCR_LAO (1L << 25) /* U+0E80-U+0EFF */ - /* Bit 26 Georgian */ - /* Georgian Supplement */ -#define TT_UCR_GEORGIAN (1L << 26) /* U+10A0-U+10FF */ - /* U+2D00-U+2D2F */ - /* Bit 27 Balinese */ -#define TT_UCR_BALINESE (1L << 27) /* U+1B00-U+1B7F */ - /* Bit 28 Hangul Jamo */ -#define TT_UCR_HANGUL_JAMO (1L << 28) /* U+1100-U+11FF */ - /* Bit 29 Latin Extended Additional */ - /* Latin Extended-C */ - /* Latin Extended-D */ -#define TT_UCR_LATIN_EXTENDED_ADDITIONAL (1L << 29) /* U+1E00-U+1EFF */ - /* U+2C60-U+2C7F */ - /* U+A720-U+A7FF */ - /* Bit 30 Greek Extended */ -#define TT_UCR_GREEK_EXTENDED (1L << 30) /* U+1F00-U+1FFF */ - /* Bit 31 General Punctuation */ - /* Supplemental Punctuation */ -#define TT_UCR_GENERAL_PUNCTUATION (1L << 31) /* U+2000-U+206F */ - /* U+2E00-U+2E7F */ - /* Bit 32 Superscripts And Subscripts */ -#define TT_UCR_SUPERSCRIPTS_SUBSCRIPTS (1L << 0) /* U+2070-U+209F */ - /* Bit 33 Currency Symbols */ -#define TT_UCR_CURRENCY_SYMBOLS (1L << 1) /* U+20A0-U+20CF */ - /* Bit 34 Combining Diacritical Marks For Symbols */ -#define TT_UCR_COMBINING_DIACRITICS_SYMB (1L << 2) /* U+20D0-U+20FF */ - /* Bit 35 Letterlike Symbols */ -#define TT_UCR_LETTERLIKE_SYMBOLS (1L << 3) /* U+2100-U+214F */ - /* Bit 36 Number Forms */ -#define TT_UCR_NUMBER_FORMS (1L << 4) /* U+2150-U+218F */ - /* Bit 37 Arrows */ - /* Supplemental Arrows-A */ - /* Supplemental Arrows-B */ - /* Miscellaneous Symbols and Arrows */ -#define TT_UCR_ARROWS (1L << 5) /* U+2190-U+21FF */ - /* U+27F0-U+27FF */ - /* U+2900-U+297F */ - /* U+2B00-U+2BFF */ - /* Bit 38 Mathematical Operators */ - /* Supplemental Mathematical Operators */ - /* Miscellaneous Mathematical Symbols-A */ - /* Miscellaneous Mathematical Symbols-B */ -#define TT_UCR_MATHEMATICAL_OPERATORS (1L << 6) /* U+2200-U+22FF */ - /* U+2A00-U+2AFF */ - /* U+27C0-U+27EF */ - /* U+2980-U+29FF */ - /* Bit 39 Miscellaneous Technical */ -#define TT_UCR_MISCELLANEOUS_TECHNICAL (1L << 7) /* U+2300-U+23FF */ - /* Bit 40 Control Pictures */ -#define TT_UCR_CONTROL_PICTURES (1L << 8) /* U+2400-U+243F */ - /* Bit 41 Optical Character Recognition */ -#define TT_UCR_OCR (1L << 9) /* U+2440-U+245F */ - /* Bit 42 Enclosed Alphanumerics */ -#define TT_UCR_ENCLOSED_ALPHANUMERICS (1L << 10) /* U+2460-U+24FF */ - /* Bit 43 Box Drawing */ -#define TT_UCR_BOX_DRAWING (1L << 11) /* U+2500-U+257F */ - /* Bit 44 Block Elements */ -#define TT_UCR_BLOCK_ELEMENTS (1L << 12) /* U+2580-U+259F */ - /* Bit 45 Geometric Shapes */ -#define TT_UCR_GEOMETRIC_SHAPES (1L << 13) /* U+25A0-U+25FF */ - /* Bit 46 Miscellaneous Symbols */ -#define TT_UCR_MISCELLANEOUS_SYMBOLS (1L << 14) /* U+2600-U+26FF */ - /* Bit 47 Dingbats */ -#define TT_UCR_DINGBATS (1L << 15) /* U+2700-U+27BF */ - /* Bit 48 CJK Symbols and Punctuation */ -#define TT_UCR_CJK_SYMBOLS (1L << 16) /* U+3000-U+303F */ - /* Bit 49 Hiragana */ -#define TT_UCR_HIRAGANA (1L << 17) /* U+3040-U+309F */ - /* Bit 50 Katakana */ - /* Katakana Phonetic Extensions */ -#define TT_UCR_KATAKANA (1L << 18) /* U+30A0-U+30FF */ - /* U+31F0-U+31FF */ - /* Bit 51 Bopomofo */ - /* Bopomofo Extended */ -#define TT_UCR_BOPOMOFO (1L << 19) /* U+3100-U+312F */ - /* U+31A0-U+31BF */ - /* Bit 52 Hangul Compatibility Jamo */ -#define TT_UCR_HANGUL_COMPATIBILITY_JAMO (1L << 20) /* U+3130-U+318F */ - /* Bit 53 Phags-Pa */ -#define TT_UCR_CJK_MISC (1L << 21) /* U+A840-U+A87F */ -#define TT_UCR_KANBUN TT_UCR_CJK_MISC /* deprecated */ -#define TT_UCR_PHAGSPA - /* Bit 54 Enclosed CJK Letters and Months */ -#define TT_UCR_ENCLOSED_CJK_LETTERS_MONTHS (1L << 22) /* U+3200-U+32FF */ - /* Bit 55 CJK Compatibility */ -#define TT_UCR_CJK_COMPATIBILITY (1L << 23) /* U+3300-U+33FF */ - /* Bit 56 Hangul Syllables */ -#define TT_UCR_HANGUL (1L << 24) /* U+AC00-U+D7A3 */ - /* Bit 57 High Surrogates */ - /* High Private Use Surrogates */ - /* Low Surrogates */ - /* */ - /* According to OpenType specs v.1.3+, */ - /* setting bit 57 implies that there is */ - /* at least one codepoint beyond the */ - /* Basic Multilingual Plane that is */ - /* supported by this font. So it really */ - /* means >= U+10000 */ -#define TT_UCR_SURROGATES (1L << 25) /* U+D800-U+DB7F */ - /* U+DB80-U+DBFF */ - /* U+DC00-U+DFFF */ -#define TT_UCR_NON_PLANE_0 TT_UCR_SURROGATES - /* Bit 58 Phoenician */ -#define TT_UCR_PHOENICIAN (1L << 26) /*U+10900-U+1091F*/ - /* Bit 59 CJK Unified Ideographs */ - /* CJK Radicals Supplement */ - /* Kangxi Radicals */ - /* Ideographic Description Characters */ - /* CJK Unified Ideographs Extension A */ - /* CJK Unified Ideographs Extension B */ - /* Kanbun */ -#define TT_UCR_CJK_UNIFIED_IDEOGRAPHS (1L << 27) /* U+4E00-U+9FFF */ - /* U+2E80-U+2EFF */ - /* U+2F00-U+2FDF */ - /* U+2FF0-U+2FFF */ - /* U+3400-U+4DB5 */ - /*U+20000-U+2A6DF*/ - /* U+3190-U+319F */ - /* Bit 60 Private Use */ -#define TT_UCR_PRIVATE_USE (1L << 28) /* U+E000-U+F8FF */ - /* Bit 61 CJK Strokes */ - /* CJK Compatibility Ideographs */ - /* CJK Compatibility Ideographs Supplement */ -#define TT_UCR_CJK_COMPATIBILITY_IDEOGRAPHS (1L << 29) /* U+31C0-U+31EF */ - /* U+F900-U+FAFF */ - /*U+2F800-U+2FA1F*/ - /* Bit 62 Alphabetic Presentation Forms */ -#define TT_UCR_ALPHABETIC_PRESENTATION_FORMS (1L << 30) /* U+FB00-U+FB4F */ - /* Bit 63 Arabic Presentation Forms-A */ -#define TT_UCR_ARABIC_PRESENTATIONS_A (1L << 31) /* U+FB50-U+FDFF */ - /* Bit 64 Combining Half Marks */ -#define TT_UCR_COMBINING_HALF_MARKS (1L << 0) /* U+FE20-U+FE2F */ - /* Bit 65 Vertical forms */ - /* CJK Compatibility Forms */ -#define TT_UCR_CJK_COMPATIBILITY_FORMS (1L << 1) /* U+FE10-U+FE1F */ - /* U+FE30-U+FE4F */ - /* Bit 66 Small Form Variants */ -#define TT_UCR_SMALL_FORM_VARIANTS (1L << 2) /* U+FE50-U+FE6F */ - /* Bit 67 Arabic Presentation Forms-B */ -#define TT_UCR_ARABIC_PRESENTATIONS_B (1L << 3) /* U+FE70-U+FEFE */ - /* Bit 68 Halfwidth and Fullwidth Forms */ -#define TT_UCR_HALFWIDTH_FULLWIDTH_FORMS (1L << 4) /* U+FF00-U+FFEF */ - /* Bit 69 Specials */ -#define TT_UCR_SPECIALS (1L << 5) /* U+FFF0-U+FFFD */ - /* Bit 70 Tibetan */ -#define TT_UCR_TIBETAN (1L << 6) /* U+0F00-U+0FFF */ - /* Bit 71 Syriac */ -#define TT_UCR_SYRIAC (1L << 7) /* U+0700-U+074F */ - /* Bit 72 Thaana */ -#define TT_UCR_THAANA (1L << 8) /* U+0780-U+07BF */ - /* Bit 73 Sinhala */ -#define TT_UCR_SINHALA (1L << 9) /* U+0D80-U+0DFF */ - /* Bit 74 Myanmar */ -#define TT_UCR_MYANMAR (1L << 10) /* U+1000-U+109F */ - /* Bit 75 Ethiopic */ - /* Ethiopic Supplement */ - /* Ethiopic Extended */ -#define TT_UCR_ETHIOPIC (1L << 11) /* U+1200-U+137F */ - /* U+1380-U+139F */ - /* U+2D80-U+2DDF */ - /* Bit 76 Cherokee */ -#define TT_UCR_CHEROKEE (1L << 12) /* U+13A0-U+13FF */ - /* Bit 77 Unified Canadian Aboriginal Syllabics */ -#define TT_UCR_CANADIAN_ABORIGINAL_SYLLABICS (1L << 13) /* U+1400-U+167F */ - /* Bit 78 Ogham */ -#define TT_UCR_OGHAM (1L << 14) /* U+1680-U+169F */ - /* Bit 79 Runic */ -#define TT_UCR_RUNIC (1L << 15) /* U+16A0-U+16FF */ - /* Bit 80 Khmer */ - /* Khmer Symbols */ -#define TT_UCR_KHMER (1L << 16) /* U+1780-U+17FF */ - /* U+19E0-U+19FF */ - /* Bit 81 Mongolian */ -#define TT_UCR_MONGOLIAN (1L << 17) /* U+1800-U+18AF */ - /* Bit 82 Braille Patterns */ -#define TT_UCR_BRAILLE (1L << 18) /* U+2800-U+28FF */ - /* Bit 83 Yi Syllables */ - /* Yi Radicals */ -#define TT_UCR_YI (1L << 19) /* U+A000-U+A48F */ - /* U+A490-U+A4CF */ - /* Bit 84 Tagalog */ - /* Hanunoo */ - /* Buhid */ - /* Tagbanwa */ -#define TT_UCR_PHILIPPINE (1L << 20) /* U+1700-U+171F */ - /* U+1720-U+173F */ - /* U+1740-U+175F */ - /* U+1760-U+177F */ - /* Bit 85 Old Italic */ -#define TT_UCR_OLD_ITALIC (1L << 21) /*U+10300-U+1032F*/ - /* Bit 86 Gothic */ -#define TT_UCR_GOTHIC (1L << 22) /*U+10330-U+1034F*/ - /* Bit 87 Deseret */ -#define TT_UCR_DESERET (1L << 23) /*U+10400-U+1044F*/ - /* Bit 88 Byzantine Musical Symbols */ - /* Musical Symbols */ - /* Ancient Greek Musical Notation */ -#define TT_UCR_MUSICAL_SYMBOLS (1L << 24) /*U+1D000-U+1D0FF*/ - /*U+1D100-U+1D1FF*/ - /*U+1D200-U+1D24F*/ - /* Bit 89 Mathematical Alphanumeric Symbols */ -#define TT_UCR_MATH_ALPHANUMERIC_SYMBOLS (1L << 25) /*U+1D400-U+1D7FF*/ - /* Bit 90 Private Use (plane 15) */ - /* Private Use (plane 16) */ -#define TT_UCR_PRIVATE_USE_SUPPLEMENTARY (1L << 26) /*U+F0000-U+FFFFD*/ - /*U+100000-U+10FFFD*/ - /* Bit 91 Variation Selectors */ - /* Variation Selectors Supplement */ -#define TT_UCR_VARIATION_SELECTORS (1L << 27) /* U+FE00-U+FE0F */ - /*U+E0100-U+E01EF*/ - /* Bit 92 Tags */ -#define TT_UCR_TAGS (1L << 28) /*U+E0000-U+E007F*/ - /* Bit 93 Limbu */ -#define TT_UCR_LIMBU (1L << 29) /* U+1900-U+194F */ - /* Bit 94 Tai Le */ -#define TT_UCR_TAI_LE (1L << 30) /* U+1950-U+197F */ - /* Bit 95 New Tai Lue */ -#define TT_UCR_NEW_TAI_LUE (1L << 31) /* U+1980-U+19DF */ - /* Bit 96 Buginese */ -#define TT_UCR_BUGINESE (1L << 0) /* U+1A00-U+1A1F */ - /* Bit 97 Glagolitic */ -#define TT_UCR_GLAGOLITIC (1L << 1) /* U+2C00-U+2C5F */ - /* Bit 98 Tifinagh */ -#define TT_UCR_TIFINAGH (1L << 2) /* U+2D30-U+2D7F */ - /* Bit 99 Yijing Hexagram Symbols */ -#define TT_UCR_YIJING (1L << 3) /* U+4DC0-U+4DFF */ - /* Bit 100 Syloti Nagri */ -#define TT_UCR_SYLOTI_NAGRI (1L << 4) /* U+A800-U+A82F */ - /* Bit 101 Linear B Syllabary */ - /* Linear B Ideograms */ - /* Aegean Numbers */ -#define TT_UCR_LINEAR_B (1L << 5) /*U+10000-U+1007F*/ - /*U+10080-U+100FF*/ - /*U+10100-U+1013F*/ - /* Bit 102 Ancient Greek Numbers */ -#define TT_UCR_ANCIENT_GREEK_NUMBERS (1L << 6) /*U+10140-U+1018F*/ - /* Bit 103 Ugaritic */ -#define TT_UCR_UGARITIC (1L << 7) /*U+10380-U+1039F*/ - /* Bit 104 Old Persian */ -#define TT_UCR_OLD_PERSIAN (1L << 8) /*U+103A0-U+103DF*/ - /* Bit 105 Shavian */ -#define TT_UCR_SHAVIAN (1L << 9) /*U+10450-U+1047F*/ - /* Bit 106 Osmanya */ -#define TT_UCR_OSMANYA (1L << 10) /*U+10480-U+104AF*/ - /* Bit 107 Cypriot Syllabary */ -#define TT_UCR_CYPRIOT_SYLLABARY (1L << 11) /*U+10800-U+1083F*/ - /* Bit 108 Kharoshthi */ -#define TT_UCR_KHAROSHTHI (1L << 12) /*U+10A00-U+10A5F*/ - /* Bit 109 Tai Xuan Jing Symbols */ -#define TT_UCR_TAI_XUAN_JING (1L << 13) /*U+1D300-U+1D35F*/ - /* Bit 110 Cuneiform */ - /* Cuneiform Numbers and Punctuation */ -#define TT_UCR_CUNEIFORM (1L << 14) /*U+12000-U+123FF*/ - /*U+12400-U+1247F*/ - /* Bit 111 Counting Rod Numerals */ -#define TT_UCR_COUNTING_ROD_NUMERALS (1L << 15) /*U+1D360-U+1D37F*/ - /* Bit 112 Sundanese */ -#define TT_UCR_SUNDANESE (1L << 16) /* U+1B80-U+1BBF */ - /* Bit 113 Lepcha */ -#define TT_UCR_LEPCHA (1L << 17) /* U+1C00-U+1C4F */ - /* Bit 114 Ol Chiki */ -#define TT_UCR_OL_CHIKI (1L << 18) /* U+1C50-U+1C7F */ - /* Bit 115 Saurashtra */ -#define TT_UCR_SAURASHTRA (1L << 19) /* U+A880-U+A8DF */ - /* Bit 116 Kayah Li */ -#define TT_UCR_KAYAH_LI (1L << 20) /* U+A900-U+A92F */ - /* Bit 117 Rejang */ -#define TT_UCR_REJANG (1L << 21) /* U+A930-U+A95F */ - /* Bit 118 Cham */ -#define TT_UCR_CHAM (1L << 22) /* U+AA00-U+AA5F */ - /* Bit 119 Ancient Symbols */ -#define TT_UCR_ANCIENT_SYMBOLS (1L << 23) /*U+10190-U+101CF*/ - /* Bit 120 Phaistos Disc */ -#define TT_UCR_PHAISTOS_DISC (1L << 24) /*U+101D0-U+101FF*/ - /* Bit 121 Carian */ - /* Lycian */ - /* Lydian */ -#define TT_UCR_OLD_ANATOLIAN (1L << 25) /*U+102A0-U+102DF*/ - /*U+10280-U+1029F*/ - /*U+10920-U+1093F*/ - /* Bit 122 Domino Tiles */ - /* Mahjong Tiles */ -#define TT_UCR_GAME_TILES (1L << 26) /*U+1F030-U+1F09F*/ - /*U+1F000-U+1F02F*/ - /* Bit 123-127 Reserved for process-internal usage */ - - - /*************************************************************************/ - /* */ - /* Some compilers have a very limited length of identifiers. */ - /* */ -#if defined( __TURBOC__ ) && __TURBOC__ < 0x0410 || defined( __PACIFIC__ ) -#define HAVE_LIMIT_ON_IDENTS -#endif - - -#ifndef HAVE_LIMIT_ON_IDENTS - - - /*************************************************************************/ - /* */ - /* Here some alias #defines in order to be clearer. */ - /* */ - /* These are not always #defined to stay within the 31~character limit, */ - /* which some compilers have. */ - /* */ - /* Credits go to Dave Hoo <dhoo@flash.net> for pointing out that modern */ - /* Borland compilers (read: from BC++ 3.1 on) can increase this limit. */ - /* If you get a warning with such a compiler, use the -i40 switch. */ - /* */ -#define TT_UCR_ARABIC_PRESENTATION_FORMS_A \ - TT_UCR_ARABIC_PRESENTATIONS_A -#define TT_UCR_ARABIC_PRESENTATION_FORMS_B \ - TT_UCR_ARABIC_PRESENTATIONS_B - -#define TT_UCR_COMBINING_DIACRITICAL_MARKS \ - TT_UCR_COMBINING_DIACRITICS -#define TT_UCR_COMBINING_DIACRITICAL_MARKS_SYMB \ - TT_UCR_COMBINING_DIACRITICS_SYMB - - -#endif /* !HAVE_LIMIT_ON_IDENTS */ - - -FT_END_HEADER - -#endif /* TTNAMEID_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/tttables.h b/android/armeabi/include/freetype/tttables.h deleted file mode 100644 index dfe3bcb1..00000000 --- a/android/armeabi/include/freetype/tttables.h +++ /dev/null @@ -1,829 +0,0 @@ -/***************************************************************************/ -/* */ -/* tttables.h */ -/* */ -/* Basic SFNT/TrueType tables definitions and interface */ -/* (specification only). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef TTTABLES_H_ -#define TTTABLES_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - /*************************************************************************/ - /* */ - /* <Section> */ - /* truetype_tables */ - /* */ - /* <Title> */ - /* TrueType Tables */ - /* */ - /* <Abstract> */ - /* TrueType specific table types and functions. */ - /* */ - /* <Description> */ - /* This section contains the definition of TrueType-specific tables */ - /* as well as some routines used to access and process them. */ - /* */ - /* <Order> */ - /* TT_Header */ - /* TT_HoriHeader */ - /* TT_VertHeader */ - /* TT_OS2 */ - /* TT_Postscript */ - /* TT_PCLT */ - /* TT_MaxProfile */ - /* */ - /* FT_Sfnt_Tag */ - /* FT_Get_Sfnt_Table */ - /* FT_Load_Sfnt_Table */ - /* FT_Sfnt_Table_Info */ - /* */ - /* FT_Get_CMap_Language_ID */ - /* FT_Get_CMap_Format */ - /* */ - /* FT_PARAM_TAG_UNPATENTED_HINTING */ - /* */ - /*************************************************************************/ - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Header */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType font header table. All */ - /* fields follow the TrueType specification. */ - /* */ - typedef struct TT_Header_ - { - FT_Fixed Table_Version; - FT_Fixed Font_Revision; - - FT_Long CheckSum_Adjust; - FT_Long Magic_Number; - - FT_UShort Flags; - FT_UShort Units_Per_EM; - - FT_Long Created [2]; - FT_Long Modified[2]; - - FT_Short xMin; - FT_Short yMin; - FT_Short xMax; - FT_Short yMax; - - FT_UShort Mac_Style; - FT_UShort Lowest_Rec_PPEM; - - FT_Short Font_Direction; - FT_Short Index_To_Loc_Format; - FT_Short Glyph_Data_Format; - - } TT_Header; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_HoriHeader */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType horizontal header, the `hhea' */ - /* table, as well as the corresponding horizontal metrics table, */ - /* i.e., the `hmtx' table. */ - /* */ - /* <Fields> */ - /* Version :: The table version. */ - /* */ - /* Ascender :: The font's ascender, i.e., the distance */ - /* from the baseline to the top-most of all */ - /* glyph points found in the font. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of the */ - /* glyphs found in the font (maybe ASCII). */ - /* */ - /* You should use the `sTypoAscender' field */ - /* of the OS/2 table instead if you want */ - /* the correct one. */ - /* */ - /* Descender :: The font's descender, i.e., the distance */ - /* from the baseline to the bottom-most of */ - /* all glyph points found in the font. It */ - /* is negative. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of the */ - /* glyphs found in the font (maybe ASCII). */ - /* */ - /* You should use the `sTypoDescender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ - /* */ - /* Line_Gap :: The font's line gap, i.e., the distance */ - /* to add to the ascender and descender to */ - /* get the BTB, i.e., the */ - /* baseline-to-baseline distance for the */ - /* font. */ - /* */ - /* advance_Width_Max :: This field is the maximum of all advance */ - /* widths found in the font. It can be */ - /* used to compute the maximum width of an */ - /* arbitrary string of text. */ - /* */ - /* min_Left_Side_Bearing :: The minimum left side bearing of all */ - /* glyphs within the font. */ - /* */ - /* min_Right_Side_Bearing :: The minimum right side bearing of all */ - /* glyphs within the font. */ - /* */ - /* xMax_Extent :: The maximum horizontal extent (i.e., the */ - /* `width' of a glyph's bounding box) for */ - /* all glyphs in the font. */ - /* */ - /* caret_Slope_Rise :: The rise coefficient of the cursor's */ - /* slope of the cursor (slope=rise/run). */ - /* */ - /* caret_Slope_Run :: The run coefficient of the cursor's */ - /* slope. */ - /* */ - /* Reserved :: 8~reserved bytes. */ - /* */ - /* metric_Data_Format :: Always~0. */ - /* */ - /* number_Of_HMetrics :: Number of HMetrics entries in the `hmtx' */ - /* table -- this value can be smaller than */ - /* the total number of glyphs in the font. */ - /* */ - /* long_metrics :: A pointer into the `hmtx' table. */ - /* */ - /* short_metrics :: A pointer into the `hmtx' table. */ - /* */ - /* <Note> */ - /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ - /* be identical except for the names of their fields, */ - /* which are different. */ - /* */ - /* This ensures that a single function in the `ttload' */ - /* module is able to read both the horizontal and vertical */ - /* headers. */ - /* */ - typedef struct TT_HoriHeader_ - { - FT_Fixed Version; - FT_Short Ascender; - FT_Short Descender; - FT_Short Line_Gap; - - FT_UShort advance_Width_Max; /* advance width maximum */ - - FT_Short min_Left_Side_Bearing; /* minimum left-sb */ - FT_Short min_Right_Side_Bearing; /* minimum right-sb */ - FT_Short xMax_Extent; /* xmax extents */ - FT_Short caret_Slope_Rise; - FT_Short caret_Slope_Run; - FT_Short caret_Offset; - - FT_Short Reserved[4]; - - FT_Short metric_Data_Format; - FT_UShort number_Of_HMetrics; - - /* The following fields are not defined by the TrueType specification */ - /* but they are used to connect the metrics header to the relevant */ - /* `HMTX' table. */ - - void* long_metrics; - void* short_metrics; - - } TT_HoriHeader; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_VertHeader */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType vertical header, the `vhea' */ - /* table, as well as the corresponding vertical metrics table, i.e., */ - /* the `vmtx' table. */ - /* */ - /* <Fields> */ - /* Version :: The table version. */ - /* */ - /* Ascender :: The font's ascender, i.e., the distance */ - /* from the baseline to the top-most of */ - /* all glyph points found in the font. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of */ - /* the glyphs found in the font (maybe */ - /* ASCII). */ - /* */ - /* You should use the `sTypoAscender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ - /* */ - /* Descender :: The font's descender, i.e., the */ - /* distance from the baseline to the */ - /* bottom-most of all glyph points found */ - /* in the font. It is negative. */ - /* */ - /* This value is invalid in many fonts, as */ - /* it is usually set by the font designer, */ - /* and often reflects only a portion of */ - /* the glyphs found in the font (maybe */ - /* ASCII). */ - /* */ - /* You should use the `sTypoDescender' */ - /* field of the OS/2 table instead if you */ - /* want the correct one. */ - /* */ - /* Line_Gap :: The font's line gap, i.e., the distance */ - /* to add to the ascender and descender to */ - /* get the BTB, i.e., the */ - /* baseline-to-baseline distance for the */ - /* font. */ - /* */ - /* advance_Height_Max :: This field is the maximum of all */ - /* advance heights found in the font. It */ - /* can be used to compute the maximum */ - /* height of an arbitrary string of text. */ - /* */ - /* min_Top_Side_Bearing :: The minimum top side bearing of all */ - /* glyphs within the font. */ - /* */ - /* min_Bottom_Side_Bearing :: The minimum bottom side bearing of all */ - /* glyphs within the font. */ - /* */ - /* yMax_Extent :: The maximum vertical extent (i.e., the */ - /* `height' of a glyph's bounding box) for */ - /* all glyphs in the font. */ - /* */ - /* caret_Slope_Rise :: The rise coefficient of the cursor's */ - /* slope of the cursor (slope=rise/run). */ - /* */ - /* caret_Slope_Run :: The run coefficient of the cursor's */ - /* slope. */ - /* */ - /* caret_Offset :: The cursor's offset for slanted fonts. */ - /* This value is `reserved' in vmtx */ - /* version 1.0. */ - /* */ - /* Reserved :: 8~reserved bytes. */ - /* */ - /* metric_Data_Format :: Always~0. */ - /* */ - /* number_Of_HMetrics :: Number of VMetrics entries in the */ - /* `vmtx' table -- this value can be */ - /* smaller than the total number of glyphs */ - /* in the font. */ - /* */ - /* long_metrics :: A pointer into the `vmtx' table. */ - /* */ - /* short_metrics :: A pointer into the `vmtx' table. */ - /* */ - /* <Note> */ - /* IMPORTANT: The TT_HoriHeader and TT_VertHeader structures should */ - /* be identical except for the names of their fields, */ - /* which are different. */ - /* */ - /* This ensures that a single function in the `ttload' */ - /* module is able to read both the horizontal and vertical */ - /* headers. */ - /* */ - typedef struct TT_VertHeader_ - { - FT_Fixed Version; - FT_Short Ascender; - FT_Short Descender; - FT_Short Line_Gap; - - FT_UShort advance_Height_Max; /* advance height maximum */ - - FT_Short min_Top_Side_Bearing; /* minimum left-sb or top-sb */ - FT_Short min_Bottom_Side_Bearing; /* minimum right-sb or bottom-sb */ - FT_Short yMax_Extent; /* xmax or ymax extents */ - FT_Short caret_Slope_Rise; - FT_Short caret_Slope_Run; - FT_Short caret_Offset; - - FT_Short Reserved[4]; - - FT_Short metric_Data_Format; - FT_UShort number_Of_VMetrics; - - /* The following fields are not defined by the TrueType specification */ - /* but they're used to connect the metrics header to the relevant */ - /* `HMTX' or `VMTX' table. */ - - void* long_metrics; - void* short_metrics; - - } TT_VertHeader; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_OS2 */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType OS/2 table. All fields */ - /* comply to the OpenType specification. */ - /* */ - /* Note that we now support old Mac fonts that do not include an OS/2 */ - /* table. In this case, the `version' field is always set to 0xFFFF. */ - /* */ - typedef struct TT_OS2_ - { - FT_UShort version; /* 0x0001 - more or 0xFFFF */ - FT_Short xAvgCharWidth; - FT_UShort usWeightClass; - FT_UShort usWidthClass; - FT_UShort fsType; - FT_Short ySubscriptXSize; - FT_Short ySubscriptYSize; - FT_Short ySubscriptXOffset; - FT_Short ySubscriptYOffset; - FT_Short ySuperscriptXSize; - FT_Short ySuperscriptYSize; - FT_Short ySuperscriptXOffset; - FT_Short ySuperscriptYOffset; - FT_Short yStrikeoutSize; - FT_Short yStrikeoutPosition; - FT_Short sFamilyClass; - - FT_Byte panose[10]; - - FT_ULong ulUnicodeRange1; /* Bits 0-31 */ - FT_ULong ulUnicodeRange2; /* Bits 32-63 */ - FT_ULong ulUnicodeRange3; /* Bits 64-95 */ - FT_ULong ulUnicodeRange4; /* Bits 96-127 */ - - FT_Char achVendID[4]; - - FT_UShort fsSelection; - FT_UShort usFirstCharIndex; - FT_UShort usLastCharIndex; - FT_Short sTypoAscender; - FT_Short sTypoDescender; - FT_Short sTypoLineGap; - FT_UShort usWinAscent; - FT_UShort usWinDescent; - - /* only version 1 and higher: */ - - FT_ULong ulCodePageRange1; /* Bits 0-31 */ - FT_ULong ulCodePageRange2; /* Bits 32-63 */ - - /* only version 2 and higher: */ - - FT_Short sxHeight; - FT_Short sCapHeight; - FT_UShort usDefaultChar; - FT_UShort usBreakChar; - FT_UShort usMaxContext; - - /* only version 5 and higher: */ - - FT_UShort usLowerOpticalPointSize; /* in twips (1/20th points) */ - FT_UShort usUpperOpticalPointSize; /* in twips (1/20th points) */ - - } TT_OS2; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_Postscript */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType PostScript table. All fields */ - /* comply to the TrueType specification. This structure does not */ - /* reference the PostScript glyph names, which can be nevertheless */ - /* accessed with the `ttpost' module. */ - /* */ - typedef struct TT_Postscript_ - { - FT_Fixed FormatType; - FT_Fixed italicAngle; - FT_Short underlinePosition; - FT_Short underlineThickness; - FT_ULong isFixedPitch; - FT_ULong minMemType42; - FT_ULong maxMemType42; - FT_ULong minMemType1; - FT_ULong maxMemType1; - - /* Glyph names follow in the file, but we don't */ - /* load them by default. See the ttpost.c file. */ - - } TT_Postscript; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_PCLT */ - /* */ - /* <Description> */ - /* A structure used to model a TrueType PCLT table. All fields */ - /* comply to the TrueType specification. */ - /* */ - typedef struct TT_PCLT_ - { - FT_Fixed Version; - FT_ULong FontNumber; - FT_UShort Pitch; - FT_UShort xHeight; - FT_UShort Style; - FT_UShort TypeFamily; - FT_UShort CapHeight; - FT_UShort SymbolSet; - FT_Char TypeFace[16]; - FT_Char CharacterComplement[8]; - FT_Char FileName[6]; - FT_Char StrokeWeight; - FT_Char WidthType; - FT_Byte SerifStyle; - FT_Byte Reserved; - - } TT_PCLT; - - - /*************************************************************************/ - /* */ - /* <Struct> */ - /* TT_MaxProfile */ - /* */ - /* <Description> */ - /* The maximum profile is a table containing many max values, which */ - /* can be used to pre-allocate arrays. This ensures that no memory */ - /* allocation occurs during a glyph load. */ - /* */ - /* <Fields> */ - /* version :: The version number. */ - /* */ - /* numGlyphs :: The number of glyphs in this TrueType */ - /* font. */ - /* */ - /* maxPoints :: The maximum number of points in a */ - /* non-composite TrueType glyph. See also */ - /* the structure element */ - /* `maxCompositePoints'. */ - /* */ - /* maxContours :: The maximum number of contours in a */ - /* non-composite TrueType glyph. See also */ - /* the structure element */ - /* `maxCompositeContours'. */ - /* */ - /* maxCompositePoints :: The maximum number of points in a */ - /* composite TrueType glyph. See also the */ - /* structure element `maxPoints'. */ - /* */ - /* maxCompositeContours :: The maximum number of contours in a */ - /* composite TrueType glyph. See also the */ - /* structure element `maxContours'. */ - /* */ - /* maxZones :: The maximum number of zones used for */ - /* glyph hinting. */ - /* */ - /* maxTwilightPoints :: The maximum number of points in the */ - /* twilight zone used for glyph hinting. */ - /* */ - /* maxStorage :: The maximum number of elements in the */ - /* storage area used for glyph hinting. */ - /* */ - /* maxFunctionDefs :: The maximum number of function */ - /* definitions in the TrueType bytecode for */ - /* this font. */ - /* */ - /* maxInstructionDefs :: The maximum number of instruction */ - /* definitions in the TrueType bytecode for */ - /* this font. */ - /* */ - /* maxStackElements :: The maximum number of stack elements used */ - /* during bytecode interpretation. */ - /* */ - /* maxSizeOfInstructions :: The maximum number of TrueType opcodes */ - /* used for glyph hinting. */ - /* */ - /* maxComponentElements :: The maximum number of simple (i.e., non- */ - /* composite) glyphs in a composite glyph. */ - /* */ - /* maxComponentDepth :: The maximum nesting depth of composite */ - /* glyphs. */ - /* */ - /* <Note> */ - /* This structure is only used during font loading. */ - /* */ - typedef struct TT_MaxProfile_ - { - FT_Fixed version; - FT_UShort numGlyphs; - FT_UShort maxPoints; - FT_UShort maxContours; - FT_UShort maxCompositePoints; - FT_UShort maxCompositeContours; - FT_UShort maxZones; - FT_UShort maxTwilightPoints; - FT_UShort maxStorage; - FT_UShort maxFunctionDefs; - FT_UShort maxInstructionDefs; - FT_UShort maxStackElements; - FT_UShort maxSizeOfInstructions; - FT_UShort maxComponentElements; - FT_UShort maxComponentDepth; - - } TT_MaxProfile; - - - /*************************************************************************/ - /* */ - /* <Enum> */ - /* FT_Sfnt_Tag */ - /* */ - /* <Description> */ - /* An enumeration used to specify the index of an SFNT table. */ - /* Used in the @FT_Get_Sfnt_Table API function. */ - /* */ - /* <Values> */ - /* FT_SFNT_HEAD :: To access the font's @TT_Header structure. */ - /* */ - /* FT_SFNT_MAXP :: To access the font's @TT_MaxProfile structure. */ - /* */ - /* FT_SFNT_OS2 :: To access the font's @TT_OS2 structure. */ - /* */ - /* FT_SFNT_HHEA :: To access the font's @TT_HoriHeader structure. */ - /* */ - /* FT_SFNT_VHEA :: To access the font's @TT_VertHeader struture. */ - /* */ - /* FT_SFNT_POST :: To access the font's @TT_Postscript structure. */ - /* */ - /* FT_SFNT_PCLT :: To access the font's @TT_PCLT structure. */ - /* */ - typedef enum FT_Sfnt_Tag_ - { - FT_SFNT_HEAD, - FT_SFNT_MAXP, - FT_SFNT_OS2, - FT_SFNT_HHEA, - FT_SFNT_VHEA, - FT_SFNT_POST, - FT_SFNT_PCLT, - - FT_SFNT_MAX - - } FT_Sfnt_Tag; - - /* these constants are deprecated; use the corresponding `FT_Sfnt_Tag' */ - /* values instead */ -#define ft_sfnt_head FT_SFNT_HEAD -#define ft_sfnt_maxp FT_SFNT_MAXP -#define ft_sfnt_os2 FT_SFNT_OS2 -#define ft_sfnt_hhea FT_SFNT_HHEA -#define ft_sfnt_vhea FT_SFNT_VHEA -#define ft_sfnt_post FT_SFNT_POST -#define ft_sfnt_pclt FT_SFNT_PCLT - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_Sfnt_Table */ - /* */ - /* <Description> */ - /* Return a pointer to a given SFNT table within a face. */ - /* */ - /* <Input> */ - /* face :: A handle to the source. */ - /* */ - /* tag :: The index of the SFNT table. */ - /* */ - /* <Return> */ - /* A type-less pointer to the table. This will be~0 in case of */ - /* error, or if the corresponding table was not found *OR* loaded */ - /* from the file. */ - /* */ - /* Use a typecast according to `tag' to access the structure */ - /* elements. */ - /* */ - /* <Note> */ - /* The table is owned by the face object and disappears with it. */ - /* */ - /* This function is only useful to access SFNT tables that are loaded */ - /* by the sfnt, truetype, and opentype drivers. See @FT_Sfnt_Tag for */ - /* a list. */ - /* */ - /* Here an example how to access the `vhea' table: */ - /* */ - /* { */ - /* TT_VertHeader* vert_header; */ - /* */ - /* */ - /* vert_header = */ - /* (TT_VertHeader*)FT_Get_Sfnt_Table( face, FT_SFNT_VHEA ); */ - /* } */ - /* */ - FT_EXPORT( void* ) - FT_Get_Sfnt_Table( FT_Face face, - FT_Sfnt_Tag tag ); - - - /************************************************************************** - * - * @function: - * FT_Load_Sfnt_Table - * - * @description: - * Load any font table into client memory. - * - * @input: - * face :: - * A handle to the source face. - * - * tag :: - * The four-byte tag of the table to load. Use the value~0 if you want - * to access the whole font file. Otherwise, you can use one of the - * definitions found in the @FT_TRUETYPE_TAGS_H file, or forge a new - * one with @FT_MAKE_TAG. - * - * offset :: - * The starting offset in the table (or file if tag == 0). - * - * @output: - * buffer :: - * The target buffer address. The client must ensure that the memory - * array is big enough to hold the data. - * - * @inout: - * length :: - * If the `length' parameter is NULL, then try to load the whole table. - * Return an error code if it fails. - * - * Else, if `*length' is~0, exit immediately while returning the - * table's (or file) full size in it. - * - * Else the number of bytes to read from the table or file, from the - * starting offset. - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * If you need to determine the table's length you should first call this - * function with `*length' set to~0, as in the following example: - * - * { - * FT_ULong length = 0; - * - * - * error = FT_Load_Sfnt_Table( face, tag, 0, NULL, &length ); - * if ( error ) { ... table does not exist ... } - * - * buffer = malloc( length ); - * if ( buffer == NULL ) { ... not enough memory ... } - * - * error = FT_Load_Sfnt_Table( face, tag, 0, buffer, &length ); - * if ( error ) { ... could not load table ... } - * } - * - * Note that structures like @TT_Header or @TT_OS2 can't be used with - * this function; they are limited to @FT_Get_Sfnt_Table. Reason is that - * those structures depend on the processor architecture, with varying - * size (e.g. 32bit vs. 64bit) or order (big endian vs. little endian). - * - */ - FT_EXPORT( FT_Error ) - FT_Load_Sfnt_Table( FT_Face face, - FT_ULong tag, - FT_Long offset, - FT_Byte* buffer, - FT_ULong* length ); - - - /************************************************************************** - * - * @function: - * FT_Sfnt_Table_Info - * - * @description: - * Return information on an SFNT table. - * - * @input: - * face :: - * A handle to the source face. - * - * table_index :: - * The index of an SFNT table. The function returns - * FT_Err_Table_Missing for an invalid value. - * - * @inout: - * tag :: - * The name tag of the SFNT table. If the value is NULL, `table_index' - * is ignored, and `length' returns the number of SFNT tables in the - * font. - * - * @output: - * length :: - * The length of the SFNT table (or the number of SFNT tables, depending - * on `tag'). - * - * @return: - * FreeType error code. 0~means success. - * - * @note: - * While parsing fonts, FreeType handles SFNT tables with length zero as - * missing. - * - */ - FT_EXPORT( FT_Error ) - FT_Sfnt_Table_Info( FT_Face face, - FT_UInt table_index, - FT_ULong *tag, - FT_ULong *length ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_CMap_Language_ID */ - /* */ - /* <Description> */ - /* Return TrueType/sfnt specific cmap language ID. Definitions of */ - /* language ID values are in `ttnameid.h'. */ - /* */ - /* <Input> */ - /* charmap :: */ - /* The target charmap. */ - /* */ - /* <Return> */ - /* The language ID of `charmap'. If `charmap' doesn't belong to a */ - /* TrueType/sfnt face, just return~0 as the default value. */ - /* */ - /* For a format~14 cmap (to access Unicode IVS), the return value is */ - /* 0xFFFFFFFF. */ - /* */ - FT_EXPORT( FT_ULong ) - FT_Get_CMap_Language_ID( FT_CharMap charmap ); - - - /*************************************************************************/ - /* */ - /* <Function> */ - /* FT_Get_CMap_Format */ - /* */ - /* <Description> */ - /* Return TrueType/sfnt specific cmap format. */ - /* */ - /* <Input> */ - /* charmap :: */ - /* The target charmap. */ - /* */ - /* <Return> */ - /* The format of `charmap'. If `charmap' doesn't belong to a */ - /* TrueType/sfnt face, return -1. */ - /* */ - FT_EXPORT( FT_Long ) - FT_Get_CMap_Format( FT_CharMap charmap ); - - /* */ - - -FT_END_HEADER - -#endif /* TTTABLES_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/tttags.h b/android/armeabi/include/freetype/tttags.h deleted file mode 100644 index f3c9aa5f..00000000 --- a/android/armeabi/include/freetype/tttags.h +++ /dev/null @@ -1,111 +0,0 @@ -/***************************************************************************/ -/* */ -/* tttags.h */ -/* */ -/* Tags for TrueType and OpenType tables (specification only). */ -/* */ -/* Copyright 1996-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef TTAGS_H_ -#define TTAGS_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - -#define TTAG_avar FT_MAKE_TAG( 'a', 'v', 'a', 'r' ) -#define TTAG_BASE FT_MAKE_TAG( 'B', 'A', 'S', 'E' ) -#define TTAG_bdat FT_MAKE_TAG( 'b', 'd', 'a', 't' ) -#define TTAG_BDF FT_MAKE_TAG( 'B', 'D', 'F', ' ' ) -#define TTAG_bhed FT_MAKE_TAG( 'b', 'h', 'e', 'd' ) -#define TTAG_bloc FT_MAKE_TAG( 'b', 'l', 'o', 'c' ) -#define TTAG_bsln FT_MAKE_TAG( 'b', 's', 'l', 'n' ) -#define TTAG_CBDT FT_MAKE_TAG( 'C', 'B', 'D', 'T' ) -#define TTAG_CBLC FT_MAKE_TAG( 'C', 'B', 'L', 'C' ) -#define TTAG_CFF FT_MAKE_TAG( 'C', 'F', 'F', ' ' ) -#define TTAG_CID FT_MAKE_TAG( 'C', 'I', 'D', ' ' ) -#define TTAG_cmap FT_MAKE_TAG( 'c', 'm', 'a', 'p' ) -#define TTAG_cvar FT_MAKE_TAG( 'c', 'v', 'a', 'r' ) -#define TTAG_cvt FT_MAKE_TAG( 'c', 'v', 't', ' ' ) -#define TTAG_DSIG FT_MAKE_TAG( 'D', 'S', 'I', 'G' ) -#define TTAG_EBDT FT_MAKE_TAG( 'E', 'B', 'D', 'T' ) -#define TTAG_EBLC FT_MAKE_TAG( 'E', 'B', 'L', 'C' ) -#define TTAG_EBSC FT_MAKE_TAG( 'E', 'B', 'S', 'C' ) -#define TTAG_feat FT_MAKE_TAG( 'f', 'e', 'a', 't' ) -#define TTAG_FOND FT_MAKE_TAG( 'F', 'O', 'N', 'D' ) -#define TTAG_fpgm FT_MAKE_TAG( 'f', 'p', 'g', 'm' ) -#define TTAG_fvar FT_MAKE_TAG( 'f', 'v', 'a', 'r' ) -#define TTAG_gasp FT_MAKE_TAG( 'g', 'a', 's', 'p' ) -#define TTAG_GDEF FT_MAKE_TAG( 'G', 'D', 'E', 'F' ) -#define TTAG_glyf FT_MAKE_TAG( 'g', 'l', 'y', 'f' ) -#define TTAG_GPOS FT_MAKE_TAG( 'G', 'P', 'O', 'S' ) -#define TTAG_GSUB FT_MAKE_TAG( 'G', 'S', 'U', 'B' ) -#define TTAG_gvar FT_MAKE_TAG( 'g', 'v', 'a', 'r' ) -#define TTAG_hdmx FT_MAKE_TAG( 'h', 'd', 'm', 'x' ) -#define TTAG_head FT_MAKE_TAG( 'h', 'e', 'a', 'd' ) -#define TTAG_hhea FT_MAKE_TAG( 'h', 'h', 'e', 'a' ) -#define TTAG_hmtx FT_MAKE_TAG( 'h', 'm', 't', 'x' ) -#define TTAG_JSTF FT_MAKE_TAG( 'J', 'S', 'T', 'F' ) -#define TTAG_just FT_MAKE_TAG( 'j', 'u', 's', 't' ) -#define TTAG_kern FT_MAKE_TAG( 'k', 'e', 'r', 'n' ) -#define TTAG_lcar FT_MAKE_TAG( 'l', 'c', 'a', 'r' ) -#define TTAG_loca FT_MAKE_TAG( 'l', 'o', 'c', 'a' ) -#define TTAG_LTSH FT_MAKE_TAG( 'L', 'T', 'S', 'H' ) -#define TTAG_LWFN FT_MAKE_TAG( 'L', 'W', 'F', 'N' ) -#define TTAG_MATH FT_MAKE_TAG( 'M', 'A', 'T', 'H' ) -#define TTAG_maxp FT_MAKE_TAG( 'm', 'a', 'x', 'p' ) -#define TTAG_META FT_MAKE_TAG( 'M', 'E', 'T', 'A' ) -#define TTAG_MMFX FT_MAKE_TAG( 'M', 'M', 'F', 'X' ) -#define TTAG_MMSD FT_MAKE_TAG( 'M', 'M', 'S', 'D' ) -#define TTAG_mort FT_MAKE_TAG( 'm', 'o', 'r', 't' ) -#define TTAG_morx FT_MAKE_TAG( 'm', 'o', 'r', 'x' ) -#define TTAG_name FT_MAKE_TAG( 'n', 'a', 'm', 'e' ) -#define TTAG_opbd FT_MAKE_TAG( 'o', 'p', 'b', 'd' ) -#define TTAG_OS2 FT_MAKE_TAG( 'O', 'S', '/', '2' ) -#define TTAG_OTTO FT_MAKE_TAG( 'O', 'T', 'T', 'O' ) -#define TTAG_PCLT FT_MAKE_TAG( 'P', 'C', 'L', 'T' ) -#define TTAG_POST FT_MAKE_TAG( 'P', 'O', 'S', 'T' ) -#define TTAG_post FT_MAKE_TAG( 'p', 'o', 's', 't' ) -#define TTAG_prep FT_MAKE_TAG( 'p', 'r', 'e', 'p' ) -#define TTAG_prop FT_MAKE_TAG( 'p', 'r', 'o', 'p' ) -#define TTAG_sbix FT_MAKE_TAG( 's', 'b', 'i', 'x' ) -#define TTAG_sfnt FT_MAKE_TAG( 's', 'f', 'n', 't' ) -#define TTAG_SING FT_MAKE_TAG( 'S', 'I', 'N', 'G' ) -#define TTAG_trak FT_MAKE_TAG( 't', 'r', 'a', 'k' ) -#define TTAG_true FT_MAKE_TAG( 't', 'r', 'u', 'e' ) -#define TTAG_ttc FT_MAKE_TAG( 't', 't', 'c', ' ' ) -#define TTAG_ttcf FT_MAKE_TAG( 't', 't', 'c', 'f' ) -#define TTAG_TYP1 FT_MAKE_TAG( 'T', 'Y', 'P', '1' ) -#define TTAG_typ1 FT_MAKE_TAG( 't', 'y', 'p', '1' ) -#define TTAG_VDMX FT_MAKE_TAG( 'V', 'D', 'M', 'X' ) -#define TTAG_vhea FT_MAKE_TAG( 'v', 'h', 'e', 'a' ) -#define TTAG_vmtx FT_MAKE_TAG( 'v', 'm', 't', 'x' ) -#define TTAG_wOFF FT_MAKE_TAG( 'w', 'O', 'F', 'F' ) - - -FT_END_HEADER - -#endif /* TTAGS_H_ */ - - -/* END */ diff --git a/android/armeabi/include/freetype/ttunpat.h b/android/armeabi/include/freetype/ttunpat.h deleted file mode 100644 index ca4676ba..00000000 --- a/android/armeabi/include/freetype/ttunpat.h +++ /dev/null @@ -1,63 +0,0 @@ -/***************************************************************************/ -/* */ -/* ttunpat.h */ -/* */ -/* Definitions for the unpatented TrueType hinting system. */ -/* Obsolete, retained for backwards compatibility. */ -/* */ -/* Copyright 2003-2016 by */ -/* David Turner, Robert Wilhelm, and Werner Lemberg. */ -/* */ -/* Written by Graham Asher <graham.asher@btinternet.com> */ -/* */ -/* This file is part of the FreeType project, and may only be used, */ -/* modified, and distributed under the terms of the FreeType project */ -/* license, LICENSE.TXT. By continuing to use, modify, or distribute */ -/* this file you indicate that you have read the license and */ -/* understand and accept it fully. */ -/* */ -/***************************************************************************/ - - -#ifndef TTUNPAT_H_ -#define TTUNPAT_H_ - - -#include <ft2build.h> -#include FT_FREETYPE_H - -#ifdef FREETYPE_H -#error "freetype.h of FreeType 1 has been loaded!" -#error "Please fix the directory search order for header files" -#error "so that freetype.h of FreeType 2 is found first." -#endif - - -FT_BEGIN_HEADER - - - /*************************************************************************** - * - * @constant: - * FT_PARAM_TAG_UNPATENTED_HINTING - * - * @description: - * Deprecated. - * - * Previously: A constant used as the tag of an @FT_Parameter structure to - * indicate that unpatented methods only should be used by the TrueType - * bytecode interpreter for a typeface opened by @FT_Open_Face. - * - */ -#define FT_PARAM_TAG_UNPATENTED_HINTING FT_MAKE_TAG( 'u', 'n', 'p', 'a' ) - - /* */ - - -FT_END_HEADER - - -#endif /* TTUNPAT_H_ */ - - -/* END */ diff --git a/android/armeabi/include/jpeg/jconfig.h b/android/armeabi/include/jpeg/jconfig.h deleted file mode 100644 index 966b1d51..00000000 --- a/android/armeabi/include/jpeg/jconfig.h +++ /dev/null @@ -1,54 +0,0 @@ -/* jconfig.h. Generated from jconfig.cfg by configure. */ -/* jconfig.cfg --- source file edited by configure script */ -/* see jconfig.txt for explanations */ - -#define HAVE_PROTOTYPES 1 -#define HAVE_UNSIGNED_CHAR 1 -#define HAVE_UNSIGNED_SHORT 1 -/* #undef void */ -/* #undef const */ -/* #undef CHAR_IS_UNSIGNED */ -#define HAVE_STDDEF_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_LOCALE_H 1 -/* #undef NEED_BSD_STRINGS */ -/* #undef NEED_SYS_TYPES_H */ -/* #undef NEED_FAR_POINTERS */ -/* #undef NEED_SHORT_EXTERNAL_NAMES */ -/* Define this if you get warnings about undefined structures. */ -/* #undef INCOMPLETE_TYPES_BROKEN */ - -/* Define "boolean" as unsigned char, not int, on Windows systems. */ -#ifdef _WIN32 -#ifndef __RPCNDR_H__ /* don't conflict if rpcndr.h already read */ -typedef unsigned char boolean; -#endif -#define HAVE_BOOLEAN /* prevent jmorecfg.h from redefining it */ -#endif - -#ifdef JPEG_INTERNALS - -/* #undef RIGHT_SHIFT_IS_UNSIGNED */ -#define INLINE __inline__ -/* These are for configuring the JPEG memory manager. */ -/* #undef DEFAULT_MAX_MEM */ -/* #undef NO_MKTEMP */ - -#endif /* JPEG_INTERNALS */ - -#ifdef JPEG_CJPEG_DJPEG - -#define BMP_SUPPORTED /* BMP image file format */ -#define GIF_SUPPORTED /* GIF image file format */ -#define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ -/* #undef RLE_SUPPORTED */ -#define TARGA_SUPPORTED /* Targa image file format */ - -/* #undef TWO_FILE_COMMANDLINE */ -/* #undef NEED_SIGNAL_CATCHER */ -/* #undef DONT_USE_B_MODE */ - -/* Define this if you want percent-done progress reports from cjpeg/djpeg. */ -/* #undef PROGRESS_REPORT */ - -#endif /* JPEG_CJPEG_DJPEG */ diff --git a/android/armeabi/include/jpeg/jerror.h b/android/armeabi/include/jpeg/jerror.h deleted file mode 100644 index a4b661f7..00000000 --- a/android/armeabi/include/jpeg/jerror.h +++ /dev/null @@ -1,304 +0,0 @@ -/* - * jerror.h - * - * Copyright (C) 1994-1997, Thomas G. Lane. - * Modified 1997-2012 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the error and message codes for the JPEG library. - * Edit this file to add new codes, or to translate the message strings to - * some other language. - * A set of error-reporting macros are defined too. Some applications using - * the JPEG library may wish to include this file to get the error codes - * and/or the macros. - */ - -/* - * To define the enum list of message codes, include this file without - * defining macro JMESSAGE. To create a message string table, include it - * again with a suitable JMESSAGE definition (see jerror.c for an example). - */ -#ifndef JMESSAGE -#ifndef JERROR_H -/* First time through, define the enum list */ -#define JMAKE_ENUM_LIST -#else -/* Repeated inclusions of this file are no-ops unless JMESSAGE is defined */ -#define JMESSAGE(code,string) -#endif /* JERROR_H */ -#endif /* JMESSAGE */ - -#ifdef JMAKE_ENUM_LIST - -typedef enum { - -#define JMESSAGE(code,string) code , - -#endif /* JMAKE_ENUM_LIST */ - -JMESSAGE(JMSG_NOMESSAGE, "Bogus message code %d") /* Must be first entry! */ - -/* For maintenance convenience, list is alphabetical by message code name */ -JMESSAGE(JERR_BAD_ALIGN_TYPE, "ALIGN_TYPE is wrong, please fix") -JMESSAGE(JERR_BAD_ALLOC_CHUNK, "MAX_ALLOC_CHUNK is wrong, please fix") -JMESSAGE(JERR_BAD_BUFFER_MODE, "Bogus buffer control mode") -JMESSAGE(JERR_BAD_COMPONENT_ID, "Invalid component ID %d in SOS") -JMESSAGE(JERR_BAD_CROP_SPEC, "Invalid crop request") -JMESSAGE(JERR_BAD_DCT_COEF, "DCT coefficient out of range") -JMESSAGE(JERR_BAD_DCTSIZE, "DCT scaled block size %dx%d not supported") -JMESSAGE(JERR_BAD_DROP_SAMPLING, - "Component index %d: mismatching sampling ratio %d:%d, %d:%d, %c") -JMESSAGE(JERR_BAD_HUFF_TABLE, "Bogus Huffman table definition") -JMESSAGE(JERR_BAD_IN_COLORSPACE, "Bogus input colorspace") -JMESSAGE(JERR_BAD_J_COLORSPACE, "Bogus JPEG colorspace") -JMESSAGE(JERR_BAD_LENGTH, "Bogus marker length") -JMESSAGE(JERR_BAD_LIB_VERSION, - "Wrong JPEG library version: library is %d, caller expects %d") -JMESSAGE(JERR_BAD_MCU_SIZE, "Sampling factors too large for interleaved scan") -JMESSAGE(JERR_BAD_POOL_ID, "Invalid memory pool code %d") -JMESSAGE(JERR_BAD_PRECISION, "Unsupported JPEG data precision %d") -JMESSAGE(JERR_BAD_PROGRESSION, - "Invalid progressive parameters Ss=%d Se=%d Ah=%d Al=%d") -JMESSAGE(JERR_BAD_PROG_SCRIPT, - "Invalid progressive parameters at scan script entry %d") -JMESSAGE(JERR_BAD_SAMPLING, "Bogus sampling factors") -JMESSAGE(JERR_BAD_SCAN_SCRIPT, "Invalid scan script at entry %d") -JMESSAGE(JERR_BAD_STATE, "Improper call to JPEG library in state %d") -JMESSAGE(JERR_BAD_STRUCT_SIZE, - "JPEG parameter struct mismatch: library thinks size is %u, caller expects %u") -JMESSAGE(JERR_BAD_VIRTUAL_ACCESS, "Bogus virtual array access") -JMESSAGE(JERR_BUFFER_SIZE, "Buffer passed to JPEG library is too small") -JMESSAGE(JERR_CANT_SUSPEND, "Suspension not allowed here") -JMESSAGE(JERR_CCIR601_NOTIMPL, "CCIR601 sampling not implemented yet") -JMESSAGE(JERR_COMPONENT_COUNT, "Too many color components: %d, max %d") -JMESSAGE(JERR_CONVERSION_NOTIMPL, "Unsupported color conversion request") -JMESSAGE(JERR_DAC_INDEX, "Bogus DAC index %d") -JMESSAGE(JERR_DAC_VALUE, "Bogus DAC value 0x%x") -JMESSAGE(JERR_DHT_INDEX, "Bogus DHT index %d") -JMESSAGE(JERR_DQT_INDEX, "Bogus DQT index %d") -JMESSAGE(JERR_EMPTY_IMAGE, "Empty JPEG image (DNL not supported)") -JMESSAGE(JERR_EMS_READ, "Read from EMS failed") -JMESSAGE(JERR_EMS_WRITE, "Write to EMS failed") -JMESSAGE(JERR_EOI_EXPECTED, "Didn't expect more than one scan") -JMESSAGE(JERR_FILE_READ, "Input file read error") -JMESSAGE(JERR_FILE_WRITE, "Output file write error --- out of disk space?") -JMESSAGE(JERR_FRACT_SAMPLE_NOTIMPL, "Fractional sampling not implemented yet") -JMESSAGE(JERR_HUFF_CLEN_OVERFLOW, "Huffman code size table overflow") -JMESSAGE(JERR_HUFF_MISSING_CODE, "Missing Huffman code table entry") -JMESSAGE(JERR_IMAGE_TOO_BIG, "Maximum supported image dimension is %u pixels") -JMESSAGE(JERR_INPUT_EMPTY, "Empty input file") -JMESSAGE(JERR_INPUT_EOF, "Premature end of input file") -JMESSAGE(JERR_MISMATCHED_QUANT_TABLE, - "Cannot transcode due to multiple use of quantization table %d") -JMESSAGE(JERR_MISSING_DATA, "Scan script does not transmit all data") -JMESSAGE(JERR_MODE_CHANGE, "Invalid color quantization mode change") -JMESSAGE(JERR_NOTIMPL, "Not implemented yet") -JMESSAGE(JERR_NOT_COMPILED, "Requested feature was omitted at compile time") -JMESSAGE(JERR_NO_ARITH_TABLE, "Arithmetic table 0x%02x was not defined") -JMESSAGE(JERR_NO_BACKING_STORE, "Backing store not supported") -JMESSAGE(JERR_NO_HUFF_TABLE, "Huffman table 0x%02x was not defined") -JMESSAGE(JERR_NO_IMAGE, "JPEG datastream contains no image") -JMESSAGE(JERR_NO_QUANT_TABLE, "Quantization table 0x%02x was not defined") -JMESSAGE(JERR_NO_SOI, "Not a JPEG file: starts with 0x%02x 0x%02x") -JMESSAGE(JERR_OUT_OF_MEMORY, "Insufficient memory (case %d)") -JMESSAGE(JERR_QUANT_COMPONENTS, - "Cannot quantize more than %d color components") -JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors") -JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors") -JMESSAGE(JERR_SOF_BEFORE, "Invalid JPEG file structure: %s before SOF") -JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers") -JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker") -JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x") -JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers") -JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s") -JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file") -JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file") -JMESSAGE(JERR_TFILE_WRITE, - "Write failed on temporary file --- out of disk space?") -JMESSAGE(JERR_TOO_LITTLE_DATA, "Application transferred too few scanlines") -JMESSAGE(JERR_UNKNOWN_MARKER, "Unsupported marker type 0x%02x") -JMESSAGE(JERR_VIRTUAL_BUG, "Virtual array controller messed up") -JMESSAGE(JERR_WIDTH_OVERFLOW, "Image too wide for this implementation") -JMESSAGE(JERR_XMS_READ, "Read from XMS failed") -JMESSAGE(JERR_XMS_WRITE, "Write to XMS failed") -JMESSAGE(JMSG_COPYRIGHT, JCOPYRIGHT) -JMESSAGE(JMSG_VERSION, JVERSION) -JMESSAGE(JTRC_16BIT_TABLES, - "Caution: quantization tables are too coarse for baseline JPEG") -JMESSAGE(JTRC_ADOBE, - "Adobe APP14 marker: version %d, flags 0x%04x 0x%04x, transform %d") -JMESSAGE(JTRC_APP0, "Unknown APP0 marker (not JFIF), length %u") -JMESSAGE(JTRC_APP14, "Unknown APP14 marker (not Adobe), length %u") -JMESSAGE(JTRC_DAC, "Define Arithmetic Table 0x%02x: 0x%02x") -JMESSAGE(JTRC_DHT, "Define Huffman Table 0x%02x") -JMESSAGE(JTRC_DQT, "Define Quantization Table %d precision %d") -JMESSAGE(JTRC_DRI, "Define Restart Interval %u") -JMESSAGE(JTRC_EMS_CLOSE, "Freed EMS handle %u") -JMESSAGE(JTRC_EMS_OPEN, "Obtained EMS handle %u") -JMESSAGE(JTRC_EOI, "End Of Image") -JMESSAGE(JTRC_HUFFBITS, " %3d %3d %3d %3d %3d %3d %3d %3d") -JMESSAGE(JTRC_JFIF, "JFIF APP0 marker: version %d.%02d, density %dx%d %d") -JMESSAGE(JTRC_JFIF_BADTHUMBNAILSIZE, - "Warning: thumbnail image size does not match data length %u") -JMESSAGE(JTRC_JFIF_EXTENSION, - "JFIF extension marker: type 0x%02x, length %u") -JMESSAGE(JTRC_JFIF_THUMBNAIL, " with %d x %d thumbnail image") -JMESSAGE(JTRC_MISC_MARKER, "Miscellaneous marker 0x%02x, length %u") -JMESSAGE(JTRC_PARMLESS_MARKER, "Unexpected marker 0x%02x") -JMESSAGE(JTRC_QUANTVALS, " %4u %4u %4u %4u %4u %4u %4u %4u") -JMESSAGE(JTRC_QUANT_3_NCOLORS, "Quantizing to %d = %d*%d*%d colors") -JMESSAGE(JTRC_QUANT_NCOLORS, "Quantizing to %d colors") -JMESSAGE(JTRC_QUANT_SELECTED, "Selected %d colors for quantization") -JMESSAGE(JTRC_RECOVERY_ACTION, "At marker 0x%02x, recovery action %d") -JMESSAGE(JTRC_RST, "RST%d") -JMESSAGE(JTRC_SMOOTH_NOTIMPL, - "Smoothing not supported with nonstandard sampling ratios") -JMESSAGE(JTRC_SOF, "Start Of Frame 0x%02x: width=%u, height=%u, components=%d") -JMESSAGE(JTRC_SOF_COMPONENT, " Component %d: %dhx%dv q=%d") -JMESSAGE(JTRC_SOI, "Start of Image") -JMESSAGE(JTRC_SOS, "Start Of Scan: %d components") -JMESSAGE(JTRC_SOS_COMPONENT, " Component %d: dc=%d ac=%d") -JMESSAGE(JTRC_SOS_PARAMS, " Ss=%d, Se=%d, Ah=%d, Al=%d") -JMESSAGE(JTRC_TFILE_CLOSE, "Closed temporary file %s") -JMESSAGE(JTRC_TFILE_OPEN, "Opened temporary file %s") -JMESSAGE(JTRC_THUMB_JPEG, - "JFIF extension marker: JPEG-compressed thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_PALETTE, - "JFIF extension marker: palette thumbnail image, length %u") -JMESSAGE(JTRC_THUMB_RGB, - "JFIF extension marker: RGB thumbnail image, length %u") -JMESSAGE(JTRC_UNKNOWN_IDS, - "Unrecognized component IDs %d %d %d, assuming YCbCr") -JMESSAGE(JTRC_XMS_CLOSE, "Freed XMS handle %u") -JMESSAGE(JTRC_XMS_OPEN, "Obtained XMS handle %u") -JMESSAGE(JWRN_ADOBE_XFORM, "Unknown Adobe color transform code %d") -JMESSAGE(JWRN_ARITH_BAD_CODE, "Corrupt JPEG data: bad arithmetic code") -JMESSAGE(JWRN_BOGUS_PROGRESSION, - "Inconsistent progression sequence for component %d coefficient %d") -JMESSAGE(JWRN_EXTRANEOUS_DATA, - "Corrupt JPEG data: %u extraneous bytes before marker 0x%02x") -JMESSAGE(JWRN_HIT_MARKER, "Corrupt JPEG data: premature end of data segment") -JMESSAGE(JWRN_HUFF_BAD_CODE, "Corrupt JPEG data: bad Huffman code") -JMESSAGE(JWRN_JFIF_MAJOR, "Warning: unknown JFIF revision number %d.%02d") -JMESSAGE(JWRN_JPEG_EOF, "Premature end of JPEG file") -JMESSAGE(JWRN_MUST_RESYNC, - "Corrupt JPEG data: found marker 0x%02x instead of RST%d") -JMESSAGE(JWRN_NOT_SEQUENTIAL, "Invalid SOS parameters for sequential JPEG") -JMESSAGE(JWRN_TOO_MUCH_DATA, "Application transferred too many scanlines") - -#ifdef JMAKE_ENUM_LIST - - JMSG_LASTMSGCODE -} J_MESSAGE_CODE; - -#undef JMAKE_ENUM_LIST -#endif /* JMAKE_ENUM_LIST */ - -/* Zap JMESSAGE macro so that future re-inclusions do nothing by default */ -#undef JMESSAGE - - -#ifndef JERROR_H -#define JERROR_H - -/* Macros to simplify using the error and trace message stuff */ -/* The first parameter is either type of cinfo pointer */ - -/* Fatal errors (print message and exit) */ -#define ERREXIT(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT3(cinfo,code,p1,p2,p3) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT4(cinfo,code,p1,p2,p3,p4) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (cinfo)->err->msg_parm.i[3] = (p4), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXIT6(cinfo,code,p1,p2,p3,p4,p5,p6) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (cinfo)->err->msg_parm.i[2] = (p3), \ - (cinfo)->err->msg_parm.i[3] = (p4), \ - (cinfo)->err->msg_parm.i[4] = (p5), \ - (cinfo)->err->msg_parm.i[5] = (p6), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) -#define ERREXITS(cinfo,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->error_exit) ((j_common_ptr) (cinfo))) - -#define MAKESTMT(stuff) do { stuff } while (0) - -/* Nonfatal errors (we can keep going, but the data is probably corrupt) */ -#define WARNMS(cinfo,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS1(cinfo,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) -#define WARNMS2(cinfo,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), -1)) - -/* Informational/debugging messages */ -#define TRACEMS(cinfo,lvl,code) \ - ((cinfo)->err->msg_code = (code), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS1(cinfo,lvl,code,p1) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS2(cinfo,lvl,code,p1,p2) \ - ((cinfo)->err->msg_code = (code), \ - (cinfo)->err->msg_parm.i[0] = (p1), \ - (cinfo)->err->msg_parm.i[1] = (p2), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) -#define TRACEMS3(cinfo,lvl,code,p1,p2,p3) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS4(cinfo,lvl,code,p1,p2,p3,p4) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS5(cinfo,lvl,code,p1,p2,p3,p4,p5) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMS8(cinfo,lvl,code,p1,p2,p3,p4,p5,p6,p7,p8) \ - MAKESTMT(int * _mp = (cinfo)->err->msg_parm.i; \ - _mp[0] = (p1); _mp[1] = (p2); _mp[2] = (p3); _mp[3] = (p4); \ - _mp[4] = (p5); _mp[5] = (p6); _mp[6] = (p7); _mp[7] = (p8); \ - (cinfo)->err->msg_code = (code); \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl)); ) -#define TRACEMSS(cinfo,lvl,code,str) \ - ((cinfo)->err->msg_code = (code), \ - strncpy((cinfo)->err->msg_parm.s, (str), JMSG_STR_PARM_MAX), \ - (*(cinfo)->err->emit_message) ((j_common_ptr) (cinfo), (lvl))) - -#endif /* JERROR_H */ diff --git a/android/armeabi/include/jpeg/jmorecfg.h b/android/armeabi/include/jpeg/jmorecfg.h deleted file mode 100644 index 2407edbe..00000000 --- a/android/armeabi/include/jpeg/jmorecfg.h +++ /dev/null @@ -1,390 +0,0 @@ -/* - * jmorecfg.h - * - * Copyright (C) 1991-1997, Thomas G. Lane. - * Modified 1997-2012 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file contains additional configuration options that customize the - * JPEG software for special applications or support machine-dependent - * optimizations. Most users will not need to touch this file. - */ - - -/* - * Define BITS_IN_JSAMPLE as either - * 8 for 8-bit sample values (the usual setting) - * 12 for 12-bit sample values - * Only 8 and 12 are legal data precisions for lossy JPEG according to the - * JPEG standard, and the IJG code does not support anything else! - * We do not support run-time selection of data precision, sorry. - */ - -#define BITS_IN_JSAMPLE 8 /* use 8 or 12 */ - - -/* - * Maximum number of components (color channels) allowed in JPEG image. - * To meet the letter of the JPEG spec, set this to 255. However, darn - * few applications need more than 4 channels (maybe 5 for CMYK + alpha - * mask). We recommend 10 as a reasonable compromise; use 4 if you are - * really short on memory. (Each allowed component costs a hundred or so - * bytes of storage, whether actually used in an image or not.) - */ - -#define MAX_COMPONENTS 10 /* maximum number of image components */ - - -/* - * Basic data types. - * You may need to change these if you have a machine with unusual data - * type sizes; for example, "char" not 8 bits, "short" not 16 bits, - * or "long" not 32 bits. We don't care whether "int" is 16 or 32 bits, - * but it had better be at least 16. - */ - -/* Representation of a single sample (pixel element value). - * We frequently allocate large arrays of these, so it's important to keep - * them small. But if you have memory to burn and access to char or short - * arrays is very slow on your hardware, you might want to change these. - */ - -#if BITS_IN_JSAMPLE == 8 -/* JSAMPLE should be the smallest type that will hold the values 0..255. - * You can use a signed char by having GETJSAMPLE mask it with 0xFF. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JSAMPLE; -#ifdef CHAR_IS_UNSIGNED -#define GETJSAMPLE(value) ((int) (value)) -#else -#define GETJSAMPLE(value) ((int) (value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - -#define MAXJSAMPLE 255 -#define CENTERJSAMPLE 128 - -#endif /* BITS_IN_JSAMPLE == 8 */ - - -#if BITS_IN_JSAMPLE == 12 -/* JSAMPLE should be the smallest type that will hold the values 0..4095. - * On nearly all machines "short" will do nicely. - */ - -typedef short JSAMPLE; -#define GETJSAMPLE(value) ((int) (value)) - -#define MAXJSAMPLE 4095 -#define CENTERJSAMPLE 2048 - -#endif /* BITS_IN_JSAMPLE == 12 */ - - -/* Representation of a DCT frequency coefficient. - * This should be a signed value of at least 16 bits; "short" is usually OK. - * Again, we allocate large arrays of these, but you can change to int - * if you have memory to burn and "short" is really slow. - */ - -typedef short JCOEF; - - -/* Compressed datastreams are represented as arrays of JOCTET. - * These must be EXACTLY 8 bits wide, at least once they are written to - * external storage. Note that when using the stdio data source/destination - * managers, this is also the data type passed to fread/fwrite. - */ - -#ifdef HAVE_UNSIGNED_CHAR - -typedef unsigned char JOCTET; -#define GETJOCTET(value) (value) - -#else /* not HAVE_UNSIGNED_CHAR */ - -typedef char JOCTET; -#ifdef CHAR_IS_UNSIGNED -#define GETJOCTET(value) (value) -#else -#define GETJOCTET(value) ((value) & 0xFF) -#endif /* CHAR_IS_UNSIGNED */ - -#endif /* HAVE_UNSIGNED_CHAR */ - - -/* These typedefs are used for various table entries and so forth. - * They must be at least as wide as specified; but making them too big - * won't cost a huge amount of memory, so we don't provide special - * extraction code like we did for JSAMPLE. (In other words, these - * typedefs live at a different point on the speed/space tradeoff curve.) - */ - -/* UINT8 must hold at least the values 0..255. */ - -#ifdef HAVE_UNSIGNED_CHAR -typedef unsigned char UINT8; -#else /* not HAVE_UNSIGNED_CHAR */ -#ifdef CHAR_IS_UNSIGNED -typedef char UINT8; -#else /* not CHAR_IS_UNSIGNED */ -typedef short UINT8; -#endif /* CHAR_IS_UNSIGNED */ -#endif /* HAVE_UNSIGNED_CHAR */ - -/* UINT16 must hold at least the values 0..65535. */ - -#ifdef HAVE_UNSIGNED_SHORT -typedef unsigned short UINT16; -#else /* not HAVE_UNSIGNED_SHORT */ -typedef unsigned int UINT16; -#endif /* HAVE_UNSIGNED_SHORT */ - -/* INT16 must hold at least the values -32768..32767. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT16 */ -typedef short INT16; -#endif - -/* INT32 must hold at least signed 32-bit values. */ - -#ifndef XMD_H /* X11/xmd.h correctly defines INT32 */ -#ifndef _BASETSD_H_ /* Microsoft defines it in basetsd.h */ -#ifndef _BASETSD_H /* MinGW is slightly different */ -#ifndef QGLOBAL_H /* Qt defines it in qglobal.h */ -typedef long INT32; -#endif -#endif -#endif -#endif - -/* Datatype used for image dimensions. The JPEG standard only supports - * images up to 64K*64K due to 16-bit fields in SOF markers. Therefore - * "unsigned int" is sufficient on all machines. However, if you need to - * handle larger images and you don't mind deviating from the spec, you - * can change this datatype. - */ - -typedef unsigned int JDIMENSION; - -#define JPEG_MAX_DIMENSION 65500L /* a tad under 64K to prevent overflows */ - - -/* These macros are used in all function definitions and extern declarations. - * You could modify them if you need to change function linkage conventions; - * in particular, you'll need to do that to make the library a Windows DLL. - * Another application is to make all functions global for use with debuggers - * or code profilers that require it. - */ - -/* a function called through method pointers: */ -#define METHODDEF(type) static type -/* a function used only in its module: */ -#define LOCAL(type) static type -/* a function referenced thru EXTERNs: */ -#define GLOBAL(type) type -/* a reference to a GLOBAL function: */ -#define EXTERN(type) extern type - - -/* This macro is used to declare a "method", that is, a function pointer. - * We want to supply prototype parameters if the compiler can cope. - * Note that the arglist parameter must be parenthesized! - * Again, you can customize this if you need special linkage keywords. - */ - -#ifdef HAVE_PROTOTYPES -#define JMETHOD(type,methodname,arglist) type (*methodname) arglist -#else -#define JMETHOD(type,methodname,arglist) type (*methodname) () -#endif - - -/* The noreturn type identifier is used to declare functions - * which cannot return. - * Compilers can thus create more optimized code and perform - * better checks for warnings and errors. - * Static analyzer tools can make improved inferences about - * execution paths and are prevented from giving false alerts. - * - * Unfortunately, the proposed specifications of corresponding - * extensions in the Dec 2011 ISO C standard revision (C11), - * GCC, MSVC, etc. are not viable. - * Thus we introduce a user defined type to declare noreturn - * functions at least for clarity. A proper compiler would - * have a suitable noreturn type to match in place of void. - */ - -#ifndef HAVE_NORETURN_T -typedef void noreturn_t; -#endif - - -/* Here is the pseudo-keyword for declaring pointers that must be "far" - * on 80x86 machines. Most of the specialized coding for 80x86 is handled - * by just saying "FAR *" where such a pointer is needed. In a few places - * explicit coding is needed; see uses of the NEED_FAR_POINTERS symbol. - */ - -#ifndef FAR -#ifdef NEED_FAR_POINTERS -#define FAR far -#else -#define FAR -#endif -#endif - - -/* - * On a few systems, type boolean and/or its values FALSE, TRUE may appear - * in standard header files. Or you may have conflicts with application- - * specific header files that you want to include together with these files. - * Defining HAVE_BOOLEAN before including jpeglib.h should make it work. - */ - -#ifdef HAVE_BOOLEAN -#ifndef FALSE /* in case these macros already exist */ -#define FALSE 0 /* values of boolean */ -#endif -#ifndef TRUE -#define TRUE 1 -#endif -#else -typedef enum { FALSE = 0, TRUE = 1 } boolean; -#endif - - -/* - * The remaining options affect code selection within the JPEG library, - * but they don't need to be visible to most applications using the library. - * To minimize application namespace pollution, the symbols won't be - * defined unless JPEG_INTERNALS or JPEG_INTERNAL_OPTIONS has been defined. - */ - -#ifdef JPEG_INTERNALS -#define JPEG_INTERNAL_OPTIONS -#endif - -#ifdef JPEG_INTERNAL_OPTIONS - - -/* - * These defines indicate whether to include various optional functions. - * Undefining some of these symbols will produce a smaller but less capable - * library. Note that you can leave certain source files out of the - * compilation/linking process if you've #undef'd the corresponding symbols. - * (You may HAVE to do that if your compiler doesn't like null source files.) - */ - -/* Capability options common to encoder and decoder: */ - -#define DCT_ISLOW_SUPPORTED /* slow but accurate integer algorithm */ -#define DCT_IFAST_SUPPORTED /* faster, less accurate integer method */ -#define DCT_FLOAT_SUPPORTED /* floating-point: accurate, fast on fast HW */ - -/* Encoder capability options: */ - -#define C_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define C_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define C_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define DCT_SCALING_SUPPORTED /* Input rescaling via DCT? (Requires DCT_ISLOW)*/ -#define ENTROPY_OPT_SUPPORTED /* Optimization of entropy coding parms? */ -/* Note: if you selected 12-bit data precision, it is dangerous to turn off - * ENTROPY_OPT_SUPPORTED. The standard Huffman tables are only good for 8-bit - * precision, so jchuff.c normally uses entropy optimization to compute - * usable tables for higher precision. If you don't want to do optimization, - * you'll have to supply different default Huffman tables. - * The exact same statements apply for progressive JPEG: the default tables - * don't work for progressive mode. (This may get fixed, however.) - */ -#define INPUT_SMOOTHING_SUPPORTED /* Input image smoothing option? */ - -/* Decoder capability options: */ - -#define D_ARITH_CODING_SUPPORTED /* Arithmetic coding back end? */ -#define D_MULTISCAN_FILES_SUPPORTED /* Multiple-scan JPEG files? */ -#define D_PROGRESSIVE_SUPPORTED /* Progressive JPEG? (Requires MULTISCAN)*/ -#define IDCT_SCALING_SUPPORTED /* Output rescaling via IDCT? */ -#define SAVE_MARKERS_SUPPORTED /* jpeg_save_markers() needed? */ -#define BLOCK_SMOOTHING_SUPPORTED /* Block smoothing? (Progressive only) */ -#undef UPSAMPLE_SCALING_SUPPORTED /* Output rescaling at upsample stage? */ -#define UPSAMPLE_MERGING_SUPPORTED /* Fast path for sloppy upsampling? */ -#define QUANT_1PASS_SUPPORTED /* 1-pass color quantization? */ -#define QUANT_2PASS_SUPPORTED /* 2-pass color quantization? */ - -/* more capability options later, no doubt */ - - -/* - * Ordering of RGB data in scanlines passed to or from the application. - * If your application wants to deal with data in the order B,G,R, just - * change these macros. You can also deal with formats such as R,G,B,X - * (one extra byte per pixel) by changing RGB_PIXELSIZE. Note that changing - * the offsets will also change the order in which colormap data is organized. - * RESTRICTIONS: - * 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats. - * 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE - * is not 3 (they don't understand about dummy color components!). So you - * can't use color quantization if you change that value. - */ - -#define RGB_RED 0 /* Offset of Red in an RGB scanline element */ -#define RGB_GREEN 1 /* Offset of Green */ -#define RGB_BLUE 2 /* Offset of Blue */ -#define RGB_PIXELSIZE 3 /* JSAMPLEs per RGB scanline element */ - - -/* Definitions for speed-related optimizations. */ - - -/* If your compiler supports inline functions, define INLINE - * as the inline keyword; otherwise define it as empty. - */ - -#ifndef INLINE -#ifdef __GNUC__ /* for instance, GNU C knows about inline */ -#define INLINE __inline__ -#endif -#ifndef INLINE -#define INLINE /* default is to define it as empty */ -#endif -#endif - - -/* On some machines (notably 68000 series) "int" is 32 bits, but multiplying - * two 16-bit shorts is faster than multiplying two ints. Define MULTIPLIER - * as short on such a machine. MULTIPLIER must be at least 16 bits wide. - */ - -#ifndef MULTIPLIER -#define MULTIPLIER int /* type for fastest integer multiply */ -#endif - - -/* FAST_FLOAT should be either float or double, whichever is done faster - * by your compiler. (Note that this type is only used in the floating point - * DCT routines, so it only matters if you've defined DCT_FLOAT_SUPPORTED.) - * Typically, float is faster in ANSI C compilers, while double is faster in - * pre-ANSI compilers (because they insist on converting to double anyway). - * The code below therefore chooses float if we have ANSI-style prototypes. - */ - -#ifndef FAST_FLOAT -#ifdef HAVE_PROTOTYPES -#define FAST_FLOAT float -#else -#define FAST_FLOAT double -#endif -#endif - -#endif /* JPEG_INTERNAL_OPTIONS */ diff --git a/android/armeabi/include/jpeg/jpeglib.h b/android/armeabi/include/jpeg/jpeglib.h deleted file mode 100644 index 0a6dac44..00000000 --- a/android/armeabi/include/jpeg/jpeglib.h +++ /dev/null @@ -1,1173 +0,0 @@ -/* - * jpeglib.h - * - * Copyright (C) 1991-1998, Thomas G. Lane. - * Modified 2002-2012 by Guido Vollbeding. - * This file is part of the Independent JPEG Group's software. - * For conditions of distribution and use, see the accompanying README file. - * - * This file defines the application interface for the JPEG library. - * Most applications using the library need only include this file, - * and perhaps jerror.h if they want to know the exact error codes. - */ - -#ifndef JPEGLIB_H -#define JPEGLIB_H - -/* - * First we include the configuration files that record how this - * installation of the JPEG library is set up. jconfig.h can be - * generated automatically for many systems. jmorecfg.h contains - * manual configuration options that most people need not worry about. - */ - -#ifndef JCONFIG_INCLUDED /* in case jinclude.h already did */ -#include "jconfig.h" /* widely used configuration options */ -#endif -#include "jmorecfg.h" /* seldom changed options */ - - -#ifdef __cplusplus -#ifndef DONT_USE_EXTERN_C -extern "C" { -#endif -#endif - -/* Version IDs for the JPEG library. - * Might be useful for tests like "#if JPEG_LIB_VERSION >= 90". - */ - -#define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */ -#define JPEG_LIB_VERSION_MAJOR 9 -#define JPEG_LIB_VERSION_MINOR 0 - - -/* Various constants determining the sizes of things. - * All of these are specified by the JPEG standard, so don't change them - * if you want to be compatible. - */ - -#define DCTSIZE 8 /* The basic DCT block is 8x8 coefficients */ -#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */ -#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */ -#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */ -#define NUM_ARITH_TBLS 16 /* Arith-coding tables are numbered 0..15 */ -#define MAX_COMPS_IN_SCAN 4 /* JPEG limit on # of components in one scan */ -#define MAX_SAMP_FACTOR 4 /* JPEG limit on sampling factors */ -/* Unfortunately, some bozo at Adobe saw no reason to be bound by the standard; - * the PostScript DCT filter can emit files with many more than 10 blocks/MCU. - * If you happen to run across such a file, you can up D_MAX_BLOCKS_IN_MCU - * to handle it. We even let you do this from the jconfig.h file. However, - * we strongly discourage changing C_MAX_BLOCKS_IN_MCU; just because Adobe - * sometimes emits noncompliant files doesn't mean you should too. - */ -#define C_MAX_BLOCKS_IN_MCU 10 /* compressor's limit on blocks per MCU */ -#ifndef D_MAX_BLOCKS_IN_MCU -#define D_MAX_BLOCKS_IN_MCU 10 /* decompressor's limit on blocks per MCU */ -#endif - - -/* Data structures for images (arrays of samples and of DCT coefficients). - * On 80x86 machines, the image arrays are too big for near pointers, - * but the pointer arrays can fit in near memory. - */ - -typedef JSAMPLE FAR *JSAMPROW; /* ptr to one image row of pixel samples. */ -typedef JSAMPROW *JSAMPARRAY; /* ptr to some rows (a 2-D sample array) */ -typedef JSAMPARRAY *JSAMPIMAGE; /* a 3-D sample array: top index is color */ - -typedef JCOEF JBLOCK[DCTSIZE2]; /* one block of coefficients */ -typedef JBLOCK FAR *JBLOCKROW; /* pointer to one row of coefficient blocks */ -typedef JBLOCKROW *JBLOCKARRAY; /* a 2-D array of coefficient blocks */ -typedef JBLOCKARRAY *JBLOCKIMAGE; /* a 3-D array of coefficient blocks */ - -typedef JCOEF FAR *JCOEFPTR; /* useful in a couple of places */ - - -/* Types for JPEG compression parameters and working tables. */ - - -/* DCT coefficient quantization tables. */ - -typedef struct { - /* This array gives the coefficient quantizers in natural array order - * (not the zigzag order in which they are stored in a JPEG DQT marker). - * CAUTION: IJG versions prior to v6a kept this array in zigzag order. - */ - UINT16 quantval[DCTSIZE2]; /* quantization step for each coefficient */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JQUANT_TBL; - - -/* Huffman coding tables. */ - -typedef struct { - /* These two fields directly represent the contents of a JPEG DHT marker */ - UINT8 bits[17]; /* bits[k] = # of symbols with codes of */ - /* length k bits; bits[0] is unused */ - UINT8 huffval[256]; /* The symbols, in order of incr code length */ - /* This field is used only during compression. It's initialized FALSE when - * the table is created, and set TRUE when it's been output to the file. - * You could suppress output of a table by setting this to TRUE. - * (See jpeg_suppress_tables for an example.) - */ - boolean sent_table; /* TRUE when table has been output */ -} JHUFF_TBL; - - -/* Basic info about one component (color channel). */ - -typedef struct { - /* These values are fixed over the whole image. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOF marker. */ - int component_id; /* identifier for this component (0..255) */ - int component_index; /* its index in SOF or cinfo->comp_info[] */ - int h_samp_factor; /* horizontal sampling factor (1..4) */ - int v_samp_factor; /* vertical sampling factor (1..4) */ - int quant_tbl_no; /* quantization table selector (0..3) */ - /* These values may vary between scans. */ - /* For compression, they must be supplied by parameter setup; */ - /* for decompression, they are read from the SOS marker. */ - /* The decompressor output side may not use these variables. */ - int dc_tbl_no; /* DC entropy table selector (0..3) */ - int ac_tbl_no; /* AC entropy table selector (0..3) */ - - /* Remaining fields should be treated as private by applications. */ - - /* These values are computed during compression or decompression startup: */ - /* Component's size in DCT blocks. - * Any dummy blocks added to complete an MCU are not counted; therefore - * these values do not depend on whether a scan is interleaved or not. - */ - JDIMENSION width_in_blocks; - JDIMENSION height_in_blocks; - /* Size of a DCT block in samples, - * reflecting any scaling we choose to apply during the DCT step. - * Values from 1 to 16 are supported. - * Note that different components may receive different DCT scalings. - */ - int DCT_h_scaled_size; - int DCT_v_scaled_size; - /* The downsampled dimensions are the component's actual, unpadded number - * of samples at the main buffer (preprocessing/compression interface); - * DCT scaling is included, so - * downsampled_width = ceil(image_width * Hi/Hmax * DCT_h_scaled_size/DCTSIZE) - * and similarly for height. - */ - JDIMENSION downsampled_width; /* actual width in samples */ - JDIMENSION downsampled_height; /* actual height in samples */ - /* This flag is used only for decompression. In cases where some of the - * components will be ignored (eg grayscale output from YCbCr image), - * we can skip most computations for the unused components. - */ - boolean component_needed; /* do we need the value of this component? */ - - /* These values are computed before starting a scan of the component. */ - /* The decompressor output side may not use these variables. */ - int MCU_width; /* number of blocks per MCU, horizontally */ - int MCU_height; /* number of blocks per MCU, vertically */ - int MCU_blocks; /* MCU_width * MCU_height */ - int MCU_sample_width; /* MCU width in samples: MCU_width * DCT_h_scaled_size */ - int last_col_width; /* # of non-dummy blocks across in last MCU */ - int last_row_height; /* # of non-dummy blocks down in last MCU */ - - /* Saved quantization table for component; NULL if none yet saved. - * See jdinput.c comments about the need for this information. - * This field is currently used only for decompression. - */ - JQUANT_TBL * quant_table; - - /* Private per-component storage for DCT or IDCT subsystem. */ - void * dct_table; -} jpeg_component_info; - - -/* The script for encoding a multiple-scan file is an array of these: */ - -typedef struct { - int comps_in_scan; /* number of components encoded in this scan */ - int component_index[MAX_COMPS_IN_SCAN]; /* their SOF/comp_info[] indexes */ - int Ss, Se; /* progressive JPEG spectral selection parms */ - int Ah, Al; /* progressive JPEG successive approx. parms */ -} jpeg_scan_info; - -/* The decompressor can save APPn and COM markers in a list of these: */ - -typedef struct jpeg_marker_struct FAR * jpeg_saved_marker_ptr; - -struct jpeg_marker_struct { - jpeg_saved_marker_ptr next; /* next in list, or NULL */ - UINT8 marker; /* marker code: JPEG_COM, or JPEG_APP0+n */ - unsigned int original_length; /* # bytes of data in the file */ - unsigned int data_length; /* # bytes of data saved at data[] */ - JOCTET FAR * data; /* the data contained in the marker */ - /* the marker length word is not counted in data_length or original_length */ -}; - -/* Known color spaces. */ - -typedef enum { - JCS_UNKNOWN, /* error/unspecified */ - JCS_GRAYSCALE, /* monochrome */ - JCS_RGB, /* red/green/blue */ - JCS_YCbCr, /* Y/Cb/Cr (also known as YUV) */ - JCS_CMYK, /* C/M/Y/K */ - JCS_YCCK /* Y/Cb/Cr/K */ -} J_COLOR_SPACE; - -/* Supported color transforms. */ - -typedef enum { - JCT_NONE = 0, - JCT_SUBTRACT_GREEN = 1 -} J_COLOR_TRANSFORM; - -/* DCT/IDCT algorithm options. */ - -typedef enum { - JDCT_ISLOW, /* slow but accurate integer algorithm */ - JDCT_IFAST, /* faster, less accurate integer method */ - JDCT_FLOAT /* floating-point: accurate, fast on fast HW */ -} J_DCT_METHOD; - -#ifndef JDCT_DEFAULT /* may be overridden in jconfig.h */ -#define JDCT_DEFAULT JDCT_ISLOW -#endif -#ifndef JDCT_FASTEST /* may be overridden in jconfig.h */ -#define JDCT_FASTEST JDCT_IFAST -#endif - -/* Dithering options for decompression. */ - -typedef enum { - JDITHER_NONE, /* no dithering */ - JDITHER_ORDERED, /* simple ordered dither */ - JDITHER_FS /* Floyd-Steinberg error diffusion dither */ -} J_DITHER_MODE; - - -/* Common fields between JPEG compression and decompression master structs. */ - -#define jpeg_common_fields \ - struct jpeg_error_mgr * err; /* Error handler module */\ - struct jpeg_memory_mgr * mem; /* Memory manager module */\ - struct jpeg_progress_mgr * progress; /* Progress monitor, or NULL if none */\ - void * client_data; /* Available for use by application */\ - boolean is_decompressor; /* So common code can tell which is which */\ - int global_state /* For checking call sequence validity */ - -/* Routines that are to be used by both halves of the library are declared - * to receive a pointer to this structure. There are no actual instances of - * jpeg_common_struct, only of jpeg_compress_struct and jpeg_decompress_struct. - */ -struct jpeg_common_struct { - jpeg_common_fields; /* Fields common to both master struct types */ - /* Additional fields follow in an actual jpeg_compress_struct or - * jpeg_decompress_struct. All three structs must agree on these - * initial fields! (This would be a lot cleaner in C++.) - */ -}; - -typedef struct jpeg_common_struct * j_common_ptr; -typedef struct jpeg_compress_struct * j_compress_ptr; -typedef struct jpeg_decompress_struct * j_decompress_ptr; - - -/* Master record for a compression instance */ - -struct jpeg_compress_struct { - jpeg_common_fields; /* Fields shared with jpeg_decompress_struct */ - - /* Destination for compressed data */ - struct jpeg_destination_mgr * dest; - - /* Description of source image --- these fields must be filled in by - * outer application before starting compression. in_color_space must - * be correct before you can even call jpeg_set_defaults(). - */ - - JDIMENSION image_width; /* input image width */ - JDIMENSION image_height; /* input image height */ - int input_components; /* # of color components in input image */ - J_COLOR_SPACE in_color_space; /* colorspace of input image */ - - double input_gamma; /* image gamma of input image */ - - /* Compression parameters --- these fields must be set before calling - * jpeg_start_compress(). We recommend calling jpeg_set_defaults() to - * initialize everything to reasonable defaults, then changing anything - * the application specifically wants to change. That way you won't get - * burnt when new parameters are added. Also note that there are several - * helper routines to simplify changing parameters. - */ - - unsigned int scale_num, scale_denom; /* fraction by which to scale image */ - - JDIMENSION jpeg_width; /* scaled JPEG image width */ - JDIMENSION jpeg_height; /* scaled JPEG image height */ - /* Dimensions of actual JPEG image that will be written to file, - * derived from input dimensions by scaling factors above. - * These fields are computed by jpeg_start_compress(). - * You can also use jpeg_calc_jpeg_dimensions() to determine these values - * in advance of calling jpeg_start_compress(). - */ - - int data_precision; /* bits of precision in image data */ - - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - int q_scale_factor[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined, - * and corresponding scale factors (percentage, initialized 100). - */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - int num_scans; /* # of entries in scan_info array */ - const jpeg_scan_info * scan_info; /* script for multi-scan file, or NULL */ - /* The default value of scan_info is NULL, which causes a single-scan - * sequential JPEG file to be emitted. To create a multi-scan file, - * set num_scans and scan_info to point to an array of scan definitions. - */ - - boolean raw_data_in; /* TRUE=caller supplies downsampled data */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - boolean optimize_coding; /* TRUE=optimize entropy encoding parms */ - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - boolean do_fancy_downsampling; /* TRUE=apply fancy downsampling */ - int smoothing_factor; /* 1..100, or 0 for no input smoothing */ - J_DCT_METHOD dct_method; /* DCT algorithm selector */ - - /* The restart interval can be specified in absolute MCUs by setting - * restart_interval, or in MCU rows by setting restart_in_rows - * (in which case the correct restart_interval will be figured - * for each scan). - */ - unsigned int restart_interval; /* MCUs per restart, or 0 for no restart */ - int restart_in_rows; /* if > 0, MCU rows per restart interval */ - - /* Parameters controlling emission of special markers. */ - - boolean write_JFIF_header; /* should a JFIF marker be written? */ - UINT8 JFIF_major_version; /* What to write for the JFIF version number */ - UINT8 JFIF_minor_version; - /* These three values are not used by the JPEG code, merely copied */ - /* into the JFIF APP0 marker. density_unit can be 0 for unknown, */ - /* 1 for dots/inch, or 2 for dots/cm. Note that the pixel aspect */ - /* ratio is defined by X_density/Y_density even when density_unit=0. */ - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean write_Adobe_marker; /* should an Adobe marker be written? */ - - J_COLOR_TRANSFORM color_transform; - /* Color transform identifier, writes LSE marker if nonzero */ - - /* State variable: index of next scanline to be written to - * jpeg_write_scanlines(). Application may use this to control its - * processing loop, e.g., "while (next_scanline < image_height)". - */ - - JDIMENSION next_scanline; /* 0 .. image_height-1 */ - - /* Remaining fields are known throughout compressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during compression startup - */ - boolean progressive_mode; /* TRUE if scan script uses progressive mode */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */ - int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows to be input to coef ctlr */ - /* The coefficient controller receives data in units of MCU rows as defined - * for fully interleaved scans (whether the JPEG file is interleaved or not). - * There are v_samp_factor * DCTSIZE sample rows of each component in an - * "iMCU" (interleaved MCU) row. - */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[C_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - int block_size; /* the basic DCT block size: 1..16 */ - const int * natural_order; /* natural-order position array */ - int lim_Se; /* min( Se, DCTSIZE2-1 ) */ - - /* - * Links to compression subobjects (methods and private variables of modules) - */ - struct jpeg_comp_master * master; - struct jpeg_c_main_controller * main; - struct jpeg_c_prep_controller * prep; - struct jpeg_c_coef_controller * coef; - struct jpeg_marker_writer * marker; - struct jpeg_color_converter * cconvert; - struct jpeg_downsampler * downsample; - struct jpeg_forward_dct * fdct; - struct jpeg_entropy_encoder * entropy; - jpeg_scan_info * script_space; /* workspace for jpeg_simple_progression */ - int script_space_size; -}; - - -/* Master record for a decompression instance */ - -struct jpeg_decompress_struct { - jpeg_common_fields; /* Fields shared with jpeg_compress_struct */ - - /* Source of compressed data */ - struct jpeg_source_mgr * src; - - /* Basic description of image --- filled in by jpeg_read_header(). */ - /* Application may inspect these values to decide how to process image. */ - - JDIMENSION image_width; /* nominal image width (from SOF marker) */ - JDIMENSION image_height; /* nominal image height */ - int num_components; /* # of color components in JPEG image */ - J_COLOR_SPACE jpeg_color_space; /* colorspace of JPEG image */ - - /* Decompression processing parameters --- these fields must be set before - * calling jpeg_start_decompress(). Note that jpeg_read_header() initializes - * them to default values. - */ - - J_COLOR_SPACE out_color_space; /* colorspace for output */ - - unsigned int scale_num, scale_denom; /* fraction by which to scale image */ - - double output_gamma; /* image gamma wanted in output */ - - boolean buffered_image; /* TRUE=multiple output passes */ - boolean raw_data_out; /* TRUE=downsampled data wanted */ - - J_DCT_METHOD dct_method; /* IDCT algorithm selector */ - boolean do_fancy_upsampling; /* TRUE=apply fancy upsampling */ - boolean do_block_smoothing; /* TRUE=apply interblock smoothing */ - - boolean quantize_colors; /* TRUE=colormapped output wanted */ - /* the following are ignored if not quantize_colors: */ - J_DITHER_MODE dither_mode; /* type of color dithering to use */ - boolean two_pass_quantize; /* TRUE=use two-pass color quantization */ - int desired_number_of_colors; /* max # colors to use in created colormap */ - /* these are significant only in buffered-image mode: */ - boolean enable_1pass_quant; /* enable future use of 1-pass quantizer */ - boolean enable_external_quant;/* enable future use of external colormap */ - boolean enable_2pass_quant; /* enable future use of 2-pass quantizer */ - - /* Description of actual output image that will be returned to application. - * These fields are computed by jpeg_start_decompress(). - * You can also use jpeg_calc_output_dimensions() to determine these values - * in advance of calling jpeg_start_decompress(). - */ - - JDIMENSION output_width; /* scaled image width */ - JDIMENSION output_height; /* scaled image height */ - int out_color_components; /* # of color components in out_color_space */ - int output_components; /* # of color components returned */ - /* output_components is 1 (a colormap index) when quantizing colors; - * otherwise it equals out_color_components. - */ - int rec_outbuf_height; /* min recommended height of scanline buffer */ - /* If the buffer passed to jpeg_read_scanlines() is less than this many rows - * high, space and time will be wasted due to unnecessary data copying. - * Usually rec_outbuf_height will be 1 or 2, at most 4. - */ - - /* When quantizing colors, the output colormap is described by these fields. - * The application can supply a colormap by setting colormap non-NULL before - * calling jpeg_start_decompress; otherwise a colormap is created during - * jpeg_start_decompress or jpeg_start_output. - * The map has out_color_components rows and actual_number_of_colors columns. - */ - int actual_number_of_colors; /* number of entries in use */ - JSAMPARRAY colormap; /* The color map as a 2-D pixel array */ - - /* State variables: these variables indicate the progress of decompression. - * The application may examine these but must not modify them. - */ - - /* Row index of next scanline to be read from jpeg_read_scanlines(). - * Application may use this to control its processing loop, e.g., - * "while (output_scanline < output_height)". - */ - JDIMENSION output_scanline; /* 0 .. output_height-1 */ - - /* Current input scan number and number of iMCU rows completed in scan. - * These indicate the progress of the decompressor input side. - */ - int input_scan_number; /* Number of SOS markers seen so far */ - JDIMENSION input_iMCU_row; /* Number of iMCU rows completed */ - - /* The "output scan number" is the notional scan being displayed by the - * output side. The decompressor will not allow output scan/row number - * to get ahead of input scan/row, but it can fall arbitrarily far behind. - */ - int output_scan_number; /* Nominal scan number being displayed */ - JDIMENSION output_iMCU_row; /* Number of iMCU rows read */ - - /* Current progression status. coef_bits[c][i] indicates the precision - * with which component c's DCT coefficient i (in zigzag order) is known. - * It is -1 when no data has yet been received, otherwise it is the point - * transform (shift) value for the most recent scan of the coefficient - * (thus, 0 at completion of the progression). - * This pointer is NULL when reading a non-progressive file. - */ - int (*coef_bits)[DCTSIZE2]; /* -1 or current Al value for each coef */ - - /* Internal JPEG parameters --- the application usually need not look at - * these fields. Note that the decompressor output side may not use - * any parameters that can change between scans. - */ - - /* Quantization and Huffman tables are carried forward across input - * datastreams when processing abbreviated JPEG datastreams. - */ - - JQUANT_TBL * quant_tbl_ptrs[NUM_QUANT_TBLS]; - /* ptrs to coefficient quantization tables, or NULL if not defined */ - - JHUFF_TBL * dc_huff_tbl_ptrs[NUM_HUFF_TBLS]; - JHUFF_TBL * ac_huff_tbl_ptrs[NUM_HUFF_TBLS]; - /* ptrs to Huffman coding tables, or NULL if not defined */ - - /* These parameters are never carried across datastreams, since they - * are given in SOF/SOS markers or defined to be reset by SOI. - */ - - int data_precision; /* bits of precision in image data */ - - jpeg_component_info * comp_info; - /* comp_info[i] describes component that appears i'th in SOF */ - - boolean is_baseline; /* TRUE if Baseline SOF0 encountered */ - boolean progressive_mode; /* TRUE if SOFn specifies progressive mode */ - boolean arith_code; /* TRUE=arithmetic coding, FALSE=Huffman */ - - UINT8 arith_dc_L[NUM_ARITH_TBLS]; /* L values for DC arith-coding tables */ - UINT8 arith_dc_U[NUM_ARITH_TBLS]; /* U values for DC arith-coding tables */ - UINT8 arith_ac_K[NUM_ARITH_TBLS]; /* Kx values for AC arith-coding tables */ - - unsigned int restart_interval; /* MCUs per restart interval, or 0 for no restart */ - - /* These fields record data obtained from optional markers recognized by - * the JPEG library. - */ - boolean saw_JFIF_marker; /* TRUE iff a JFIF APP0 marker was found */ - /* Data copied from JFIF marker; only valid if saw_JFIF_marker is TRUE: */ - UINT8 JFIF_major_version; /* JFIF version number */ - UINT8 JFIF_minor_version; - UINT8 density_unit; /* JFIF code for pixel size units */ - UINT16 X_density; /* Horizontal pixel density */ - UINT16 Y_density; /* Vertical pixel density */ - boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */ - UINT8 Adobe_transform; /* Color transform code from Adobe marker */ - - J_COLOR_TRANSFORM color_transform; - /* Color transform identifier derived from LSE marker, otherwise zero */ - - boolean CCIR601_sampling; /* TRUE=first samples are cosited */ - - /* Aside from the specific data retained from APPn markers known to the - * library, the uninterpreted contents of any or all APPn and COM markers - * can be saved in a list for examination by the application. - */ - jpeg_saved_marker_ptr marker_list; /* Head of list of saved markers */ - - /* Remaining fields are known throughout decompressor, but generally - * should not be touched by a surrounding application. - */ - - /* - * These fields are computed during decompression startup - */ - int max_h_samp_factor; /* largest h_samp_factor */ - int max_v_samp_factor; /* largest v_samp_factor */ - - int min_DCT_h_scaled_size; /* smallest DCT_h_scaled_size of any component */ - int min_DCT_v_scaled_size; /* smallest DCT_v_scaled_size of any component */ - - JDIMENSION total_iMCU_rows; /* # of iMCU rows in image */ - /* The coefficient controller's input and output progress is measured in - * units of "iMCU" (interleaved MCU) rows. These are the same as MCU rows - * in fully interleaved JPEG scans, but are used whether the scan is - * interleaved or not. We define an iMCU row as v_samp_factor DCT block - * rows of each component. Therefore, the IDCT output contains - * v_samp_factor*DCT_v_scaled_size sample rows of a component per iMCU row. - */ - - JSAMPLE * sample_range_limit; /* table for fast range-limiting */ - - /* - * These fields are valid during any one scan. - * They describe the components and MCUs actually appearing in the scan. - * Note that the decompressor output side must not use these fields. - */ - int comps_in_scan; /* # of JPEG components in this scan */ - jpeg_component_info * cur_comp_info[MAX_COMPS_IN_SCAN]; - /* *cur_comp_info[i] describes component that appears i'th in SOS */ - - JDIMENSION MCUs_per_row; /* # of MCUs across the image */ - JDIMENSION MCU_rows_in_scan; /* # of MCU rows in the image */ - - int blocks_in_MCU; /* # of DCT blocks per MCU */ - int MCU_membership[D_MAX_BLOCKS_IN_MCU]; - /* MCU_membership[i] is index in cur_comp_info of component owning */ - /* i'th block in an MCU */ - - int Ss, Se, Ah, Al; /* progressive JPEG parameters for scan */ - - /* These fields are derived from Se of first SOS marker. - */ - int block_size; /* the basic DCT block size: 1..16 */ - const int * natural_order; /* natural-order position array for entropy decode */ - int lim_Se; /* min( Se, DCTSIZE2-1 ) for entropy decode */ - - /* This field is shared between entropy decoder and marker parser. - * It is either zero or the code of a JPEG marker that has been - * read from the data source, but has not yet been processed. - */ - int unread_marker; - - /* - * Links to decompression subobjects (methods, private variables of modules) - */ - struct jpeg_decomp_master * master; - struct jpeg_d_main_controller * main; - struct jpeg_d_coef_controller * coef; - struct jpeg_d_post_controller * post; - struct jpeg_input_controller * inputctl; - struct jpeg_marker_reader * marker; - struct jpeg_entropy_decoder * entropy; - struct jpeg_inverse_dct * idct; - struct jpeg_upsampler * upsample; - struct jpeg_color_deconverter * cconvert; - struct jpeg_color_quantizer * cquantize; -}; - - -/* "Object" declarations for JPEG modules that may be supplied or called - * directly by the surrounding application. - * As with all objects in the JPEG library, these structs only define the - * publicly visible methods and state variables of a module. Additional - * private fields may exist after the public ones. - */ - - -/* Error handler object */ - -struct jpeg_error_mgr { - /* Error exit handler: does not return to caller */ - JMETHOD(noreturn_t, error_exit, (j_common_ptr cinfo)); - /* Conditionally emit a trace or warning message */ - JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level)); - /* Routine that actually outputs a trace or error message */ - JMETHOD(void, output_message, (j_common_ptr cinfo)); - /* Format a message string for the most recent JPEG error or message */ - JMETHOD(void, format_message, (j_common_ptr cinfo, char * buffer)); -#define JMSG_LENGTH_MAX 200 /* recommended size of format_message buffer */ - /* Reset error state variables at start of a new image */ - JMETHOD(void, reset_error_mgr, (j_common_ptr cinfo)); - - /* The message ID code and any parameters are saved here. - * A message can have one string parameter or up to 8 int parameters. - */ - int msg_code; -#define JMSG_STR_PARM_MAX 80 - union { - int i[8]; - char s[JMSG_STR_PARM_MAX]; - } msg_parm; - - /* Standard state variables for error facility */ - - int trace_level; /* max msg_level that will be displayed */ - - /* For recoverable corrupt-data errors, we emit a warning message, - * but keep going unless emit_message chooses to abort. emit_message - * should count warnings in num_warnings. The surrounding application - * can check for bad data by seeing if num_warnings is nonzero at the - * end of processing. - */ - long num_warnings; /* number of corrupt-data warnings */ - - /* These fields point to the table(s) of error message strings. - * An application can change the table pointer to switch to a different - * message list (typically, to change the language in which errors are - * reported). Some applications may wish to add additional error codes - * that will be handled by the JPEG library error mechanism; the second - * table pointer is used for this purpose. - * - * First table includes all errors generated by JPEG library itself. - * Error code 0 is reserved for a "no such error string" message. - */ - const char * const * jpeg_message_table; /* Library errors */ - int last_jpeg_message; /* Table contains strings 0..last_jpeg_message */ - /* Second table can be added by application (see cjpeg/djpeg for example). - * It contains strings numbered first_addon_message..last_addon_message. - */ - const char * const * addon_message_table; /* Non-library errors */ - int first_addon_message; /* code for first string in addon table */ - int last_addon_message; /* code for last string in addon table */ -}; - - -/* Progress monitor object */ - -struct jpeg_progress_mgr { - JMETHOD(void, progress_monitor, (j_common_ptr cinfo)); - - long pass_counter; /* work units completed in this pass */ - long pass_limit; /* total number of work units in this pass */ - int completed_passes; /* passes completed so far */ - int total_passes; /* total number of passes expected */ -}; - - -/* Data destination object for compression */ - -struct jpeg_destination_mgr { - JOCTET * next_output_byte; /* => next byte to write in buffer */ - size_t free_in_buffer; /* # of byte spaces remaining in buffer */ - - JMETHOD(void, init_destination, (j_compress_ptr cinfo)); - JMETHOD(boolean, empty_output_buffer, (j_compress_ptr cinfo)); - JMETHOD(void, term_destination, (j_compress_ptr cinfo)); -}; - - -/* Data source object for decompression */ - -struct jpeg_source_mgr { - const JOCTET * next_input_byte; /* => next byte to read from buffer */ - size_t bytes_in_buffer; /* # of bytes remaining in buffer */ - - JMETHOD(void, init_source, (j_decompress_ptr cinfo)); - JMETHOD(boolean, fill_input_buffer, (j_decompress_ptr cinfo)); - JMETHOD(void, skip_input_data, (j_decompress_ptr cinfo, long num_bytes)); - JMETHOD(boolean, resync_to_restart, (j_decompress_ptr cinfo, int desired)); - JMETHOD(void, term_source, (j_decompress_ptr cinfo)); -}; - - -/* Memory manager object. - * Allocates "small" objects (a few K total), "large" objects (tens of K), - * and "really big" objects (virtual arrays with backing store if needed). - * The memory manager does not allow individual objects to be freed; rather, - * each created object is assigned to a pool, and whole pools can be freed - * at once. This is faster and more convenient than remembering exactly what - * to free, especially where malloc()/free() are not too speedy. - * NB: alloc routines never return NULL. They exit to error_exit if not - * successful. - */ - -#define JPOOL_PERMANENT 0 /* lasts until master record is destroyed */ -#define JPOOL_IMAGE 1 /* lasts until done with image/datastream */ -#define JPOOL_NUMPOOLS 2 - -typedef struct jvirt_sarray_control * jvirt_sarray_ptr; -typedef struct jvirt_barray_control * jvirt_barray_ptr; - - -struct jpeg_memory_mgr { - /* Method pointers */ - JMETHOD(void *, alloc_small, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(void FAR *, alloc_large, (j_common_ptr cinfo, int pool_id, - size_t sizeofobject)); - JMETHOD(JSAMPARRAY, alloc_sarray, (j_common_ptr cinfo, int pool_id, - JDIMENSION samplesperrow, - JDIMENSION numrows)); - JMETHOD(JBLOCKARRAY, alloc_barray, (j_common_ptr cinfo, int pool_id, - JDIMENSION blocksperrow, - JDIMENSION numrows)); - JMETHOD(jvirt_sarray_ptr, request_virt_sarray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION samplesperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(jvirt_barray_ptr, request_virt_barray, (j_common_ptr cinfo, - int pool_id, - boolean pre_zero, - JDIMENSION blocksperrow, - JDIMENSION numrows, - JDIMENSION maxaccess)); - JMETHOD(void, realize_virt_arrays, (j_common_ptr cinfo)); - JMETHOD(JSAMPARRAY, access_virt_sarray, (j_common_ptr cinfo, - jvirt_sarray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(JBLOCKARRAY, access_virt_barray, (j_common_ptr cinfo, - jvirt_barray_ptr ptr, - JDIMENSION start_row, - JDIMENSION num_rows, - boolean writable)); - JMETHOD(void, free_pool, (j_common_ptr cinfo, int pool_id)); - JMETHOD(void, self_destruct, (j_common_ptr cinfo)); - - /* Limit on memory allocation for this JPEG object. (Note that this is - * merely advisory, not a guaranteed maximum; it only affects the space - * used for virtual-array buffers.) May be changed by outer application - * after creating the JPEG object. - */ - long max_memory_to_use; - - /* Maximum allocation request accepted by alloc_large. */ - long max_alloc_chunk; -}; - - -/* Routine signature for application-supplied marker processing methods. - * Need not pass marker code since it is stored in cinfo->unread_marker. - */ -typedef JMETHOD(boolean, jpeg_marker_parser_method, (j_decompress_ptr cinfo)); - - -/* Declarations for routines called by application. - * The JPP macro hides prototype parameters from compilers that can't cope. - * Note JPP requires double parentheses. - */ - -#ifdef HAVE_PROTOTYPES -#define JPP(arglist) arglist -#else -#define JPP(arglist) () -#endif - - -/* Short forms of external names for systems with brain-damaged linkers. - * We shorten external names to be unique in the first six letters, which - * is good enough for all known systems. - * (If your compiler itself needs names to be unique in less than 15 - * characters, you are out of luck. Get a better compiler.) - */ - -#ifdef NEED_SHORT_EXTERNAL_NAMES -#define jpeg_std_error jStdError -#define jpeg_CreateCompress jCreaCompress -#define jpeg_CreateDecompress jCreaDecompress -#define jpeg_destroy_compress jDestCompress -#define jpeg_destroy_decompress jDestDecompress -#define jpeg_stdio_dest jStdDest -#define jpeg_stdio_src jStdSrc -#define jpeg_mem_dest jMemDest -#define jpeg_mem_src jMemSrc -#define jpeg_set_defaults jSetDefaults -#define jpeg_set_colorspace jSetColorspace -#define jpeg_default_colorspace jDefColorspace -#define jpeg_set_quality jSetQuality -#define jpeg_set_linear_quality jSetLQuality -#define jpeg_default_qtables jDefQTables -#define jpeg_add_quant_table jAddQuantTable -#define jpeg_quality_scaling jQualityScaling -#define jpeg_simple_progression jSimProgress -#define jpeg_suppress_tables jSuppressTables -#define jpeg_alloc_quant_table jAlcQTable -#define jpeg_alloc_huff_table jAlcHTable -#define jpeg_start_compress jStrtCompress -#define jpeg_write_scanlines jWrtScanlines -#define jpeg_finish_compress jFinCompress -#define jpeg_calc_jpeg_dimensions jCjpegDimensions -#define jpeg_write_raw_data jWrtRawData -#define jpeg_write_marker jWrtMarker -#define jpeg_write_m_header jWrtMHeader -#define jpeg_write_m_byte jWrtMByte -#define jpeg_write_tables jWrtTables -#define jpeg_read_header jReadHeader -#define jpeg_start_decompress jStrtDecompress -#define jpeg_read_scanlines jReadScanlines -#define jpeg_finish_decompress jFinDecompress -#define jpeg_read_raw_data jReadRawData -#define jpeg_has_multiple_scans jHasMultScn -#define jpeg_start_output jStrtOutput -#define jpeg_finish_output jFinOutput -#define jpeg_input_complete jInComplete -#define jpeg_new_colormap jNewCMap -#define jpeg_consume_input jConsumeInput -#define jpeg_core_output_dimensions jCoreDimensions -#define jpeg_calc_output_dimensions jCalcDimensions -#define jpeg_save_markers jSaveMarkers -#define jpeg_set_marker_processor jSetMarker -#define jpeg_read_coefficients jReadCoefs -#define jpeg_write_coefficients jWrtCoefs -#define jpeg_copy_critical_parameters jCopyCrit -#define jpeg_abort_compress jAbrtCompress -#define jpeg_abort_decompress jAbrtDecompress -#define jpeg_abort jAbort -#define jpeg_destroy jDestroy -#define jpeg_resync_to_restart jResyncRestart -#endif /* NEED_SHORT_EXTERNAL_NAMES */ - - -/* Default error-management setup */ -EXTERN(struct jpeg_error_mgr *) jpeg_std_error - JPP((struct jpeg_error_mgr * err)); - -/* Initialization of JPEG compression objects. - * jpeg_create_compress() and jpeg_create_decompress() are the exported - * names that applications should call. These expand to calls on - * jpeg_CreateCompress and jpeg_CreateDecompress with additional information - * passed for version mismatch checking. - * NB: you must set up the error-manager BEFORE calling jpeg_create_xxx. - */ -#define jpeg_create_compress(cinfo) \ - jpeg_CreateCompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_compress_struct)) -#define jpeg_create_decompress(cinfo) \ - jpeg_CreateDecompress((cinfo), JPEG_LIB_VERSION, \ - (size_t) sizeof(struct jpeg_decompress_struct)) -EXTERN(void) jpeg_CreateCompress JPP((j_compress_ptr cinfo, - int version, size_t structsize)); -EXTERN(void) jpeg_CreateDecompress JPP((j_decompress_ptr cinfo, - int version, size_t structsize)); -/* Destruction of JPEG compression objects */ -EXTERN(void) jpeg_destroy_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_destroy_decompress JPP((j_decompress_ptr cinfo)); - -/* Standard data source and destination managers: stdio streams. */ -/* Caller is responsible for opening the file before and closing after. */ -EXTERN(void) jpeg_stdio_dest JPP((j_compress_ptr cinfo, FILE * outfile)); -EXTERN(void) jpeg_stdio_src JPP((j_decompress_ptr cinfo, FILE * infile)); - -/* Data source and destination managers: memory buffers. */ -EXTERN(void) jpeg_mem_dest JPP((j_compress_ptr cinfo, - unsigned char ** outbuffer, - unsigned long * outsize)); -EXTERN(void) jpeg_mem_src JPP((j_decompress_ptr cinfo, - unsigned char * inbuffer, - unsigned long insize)); - -/* Default parameter setup for compression */ -EXTERN(void) jpeg_set_defaults JPP((j_compress_ptr cinfo)); -/* Compression parameter setup aids */ -EXTERN(void) jpeg_set_colorspace JPP((j_compress_ptr cinfo, - J_COLOR_SPACE colorspace)); -EXTERN(void) jpeg_default_colorspace JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_set_quality JPP((j_compress_ptr cinfo, int quality, - boolean force_baseline)); -EXTERN(void) jpeg_set_linear_quality JPP((j_compress_ptr cinfo, - int scale_factor, - boolean force_baseline)); -EXTERN(void) jpeg_default_qtables JPP((j_compress_ptr cinfo, - boolean force_baseline)); -EXTERN(void) jpeg_add_quant_table JPP((j_compress_ptr cinfo, int which_tbl, - const unsigned int *basic_table, - int scale_factor, - boolean force_baseline)); -EXTERN(int) jpeg_quality_scaling JPP((int quality)); -EXTERN(void) jpeg_simple_progression JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_suppress_tables JPP((j_compress_ptr cinfo, - boolean suppress)); -EXTERN(JQUANT_TBL *) jpeg_alloc_quant_table JPP((j_common_ptr cinfo)); -EXTERN(JHUFF_TBL *) jpeg_alloc_huff_table JPP((j_common_ptr cinfo)); - -/* Main entry points for compression */ -EXTERN(void) jpeg_start_compress JPP((j_compress_ptr cinfo, - boolean write_all_tables)); -EXTERN(JDIMENSION) jpeg_write_scanlines JPP((j_compress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION num_lines)); -EXTERN(void) jpeg_finish_compress JPP((j_compress_ptr cinfo)); - -/* Precalculate JPEG dimensions for current compression parameters. */ -EXTERN(void) jpeg_calc_jpeg_dimensions JPP((j_compress_ptr cinfo)); - -/* Replaces jpeg_write_scanlines when writing raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_write_raw_data JPP((j_compress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION num_lines)); - -/* Write a special marker. See libjpeg.txt concerning safe usage. */ -EXTERN(void) jpeg_write_marker - JPP((j_compress_ptr cinfo, int marker, - const JOCTET * dataptr, unsigned int datalen)); -/* Same, but piecemeal. */ -EXTERN(void) jpeg_write_m_header - JPP((j_compress_ptr cinfo, int marker, unsigned int datalen)); -EXTERN(void) jpeg_write_m_byte - JPP((j_compress_ptr cinfo, int val)); - -/* Alternate compression function: just write an abbreviated table file */ -EXTERN(void) jpeg_write_tables JPP((j_compress_ptr cinfo)); - -/* Decompression startup: read start of JPEG datastream to see what's there */ -EXTERN(int) jpeg_read_header JPP((j_decompress_ptr cinfo, - boolean require_image)); -/* Return value is one of: */ -#define JPEG_SUSPENDED 0 /* Suspended due to lack of input data */ -#define JPEG_HEADER_OK 1 /* Found valid image datastream */ -#define JPEG_HEADER_TABLES_ONLY 2 /* Found valid table-specs-only datastream */ -/* If you pass require_image = TRUE (normal case), you need not check for - * a TABLES_ONLY return code; an abbreviated file will cause an error exit. - * JPEG_SUSPENDED is only possible if you use a data source module that can - * give a suspension return (the stdio source module doesn't). - */ - -/* Main entry points for decompression */ -EXTERN(boolean) jpeg_start_decompress JPP((j_decompress_ptr cinfo)); -EXTERN(JDIMENSION) jpeg_read_scanlines JPP((j_decompress_ptr cinfo, - JSAMPARRAY scanlines, - JDIMENSION max_lines)); -EXTERN(boolean) jpeg_finish_decompress JPP((j_decompress_ptr cinfo)); - -/* Replaces jpeg_read_scanlines when reading raw downsampled data. */ -EXTERN(JDIMENSION) jpeg_read_raw_data JPP((j_decompress_ptr cinfo, - JSAMPIMAGE data, - JDIMENSION max_lines)); - -/* Additional entry points for buffered-image mode. */ -EXTERN(boolean) jpeg_has_multiple_scans JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_start_output JPP((j_decompress_ptr cinfo, - int scan_number)); -EXTERN(boolean) jpeg_finish_output JPP((j_decompress_ptr cinfo)); -EXTERN(boolean) jpeg_input_complete JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_new_colormap JPP((j_decompress_ptr cinfo)); -EXTERN(int) jpeg_consume_input JPP((j_decompress_ptr cinfo)); -/* Return value is one of: */ -/* #define JPEG_SUSPENDED 0 Suspended due to lack of input data */ -#define JPEG_REACHED_SOS 1 /* Reached start of new scan */ -#define JPEG_REACHED_EOI 2 /* Reached end of image */ -#define JPEG_ROW_COMPLETED 3 /* Completed one iMCU row */ -#define JPEG_SCAN_COMPLETED 4 /* Completed last iMCU row of a scan */ - -/* Precalculate output dimensions for current decompression parameters. */ -EXTERN(void) jpeg_core_output_dimensions JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_calc_output_dimensions JPP((j_decompress_ptr cinfo)); - -/* Control saving of COM and APPn markers into marker_list. */ -EXTERN(void) jpeg_save_markers - JPP((j_decompress_ptr cinfo, int marker_code, - unsigned int length_limit)); - -/* Install a special processing method for COM or APPn markers. */ -EXTERN(void) jpeg_set_marker_processor - JPP((j_decompress_ptr cinfo, int marker_code, - jpeg_marker_parser_method routine)); - -/* Read or write raw DCT coefficients --- useful for lossless transcoding. */ -EXTERN(jvirt_barray_ptr *) jpeg_read_coefficients JPP((j_decompress_ptr cinfo)); -EXTERN(void) jpeg_write_coefficients JPP((j_compress_ptr cinfo, - jvirt_barray_ptr * coef_arrays)); -EXTERN(void) jpeg_copy_critical_parameters JPP((j_decompress_ptr srcinfo, - j_compress_ptr dstinfo)); - -/* If you choose to abort compression or decompression before completing - * jpeg_finish_(de)compress, then you need to clean up to release memory, - * temporary files, etc. You can just call jpeg_destroy_(de)compress - * if you're done with the JPEG object, but if you want to clean it up and - * reuse it, call this: - */ -EXTERN(void) jpeg_abort_compress JPP((j_compress_ptr cinfo)); -EXTERN(void) jpeg_abort_decompress JPP((j_decompress_ptr cinfo)); - -/* Generic versions of jpeg_abort and jpeg_destroy that work on either - * flavor of JPEG object. These may be more convenient in some places. - */ -EXTERN(void) jpeg_abort JPP((j_common_ptr cinfo)); -EXTERN(void) jpeg_destroy JPP((j_common_ptr cinfo)); - -/* Default restart-marker-resync procedure for use by data source modules */ -EXTERN(boolean) jpeg_resync_to_restart JPP((j_decompress_ptr cinfo, - int desired)); - - -/* These marker codes are exported since applications and data source modules - * are likely to want to use them. - */ - -#define JPEG_RST0 0xD0 /* RST0 marker code */ -#define JPEG_EOI 0xD9 /* EOI marker code */ -#define JPEG_APP0 0xE0 /* APP0 marker code */ -#define JPEG_COM 0xFE /* COM marker code */ - - -/* If we have a brain-damaged compiler that emits warnings (or worse, errors) - * for structure definitions that are never filled in, keep it quiet by - * supplying dummy definitions for the various substructures. - */ - -#ifdef INCOMPLETE_TYPES_BROKEN -#ifndef JPEG_INTERNALS /* will be defined in jpegint.h */ -struct jvirt_sarray_control { long dummy; }; -struct jvirt_barray_control { long dummy; }; -struct jpeg_comp_master { long dummy; }; -struct jpeg_c_main_controller { long dummy; }; -struct jpeg_c_prep_controller { long dummy; }; -struct jpeg_c_coef_controller { long dummy; }; -struct jpeg_marker_writer { long dummy; }; -struct jpeg_color_converter { long dummy; }; -struct jpeg_downsampler { long dummy; }; -struct jpeg_forward_dct { long dummy; }; -struct jpeg_entropy_encoder { long dummy; }; -struct jpeg_decomp_master { long dummy; }; -struct jpeg_d_main_controller { long dummy; }; -struct jpeg_d_coef_controller { long dummy; }; -struct jpeg_d_post_controller { long dummy; }; -struct jpeg_input_controller { long dummy; }; -struct jpeg_marker_reader { long dummy; }; -struct jpeg_entropy_decoder { long dummy; }; -struct jpeg_inverse_dct { long dummy; }; -struct jpeg_upsampler { long dummy; }; -struct jpeg_color_deconverter { long dummy; }; -struct jpeg_color_quantizer { long dummy; }; -#endif /* JPEG_INTERNALS */ -#endif /* INCOMPLETE_TYPES_BROKEN */ - - -/* - * The JPEG library modules define JPEG_INTERNALS before including this file. - * The internal structure declarations are read only when that is true. - * Applications using the library should not include jpegint.h, but may wish - * to include jerror.h. - */ - -#ifdef JPEG_INTERNALS -#include "jpegint.h" /* fetch private declarations */ -#include "jerror.h" /* fetch error codes too */ -#endif - -#ifdef __cplusplus -#ifndef DONT_USE_EXTERN_C -} -#endif -#endif - -#endif /* JPEGLIB_H */ diff --git a/android/armeabi/include/openssl/aes.h b/android/armeabi/include/openssl/aes.h deleted file mode 100644 index 245c552a..00000000 --- a/android/armeabi/include/openssl/aes.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_AES_H -# define HEADER_AES_H - -# include <openssl/opensslconf.h> - -# include <stddef.h> -# ifdef __cplusplus -extern "C" { -# endif - -# define AES_ENCRYPT 1 -# define AES_DECRYPT 0 - -/* - * Because array size can't be a const in C, the following two are macros. - * Both sizes are in bytes. - */ -# define AES_MAXNR 14 -# define AES_BLOCK_SIZE 16 - -/* This should be a hidden type, but EVP requires that the size be known */ -struct aes_key_st { -# ifdef AES_LONG - unsigned long rd_key[4 * (AES_MAXNR + 1)]; -# else - unsigned int rd_key[4 * (AES_MAXNR + 1)]; -# endif - int rounds; -}; -typedef struct aes_key_st AES_KEY; - -const char *AES_options(void); - -int AES_set_encrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key); -int AES_set_decrypt_key(const unsigned char *userKey, const int bits, - AES_KEY *key); - -void AES_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); -void AES_decrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key); - -void AES_ecb_encrypt(const unsigned char *in, unsigned char *out, - const AES_KEY *key, const int enc); -void AES_cbc_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, const int enc); -void AES_cfb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, int *num, const int enc); -void AES_cfb1_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, int *num, const int enc); -void AES_cfb8_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, int *num, const int enc); -void AES_ofb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, int *num); -/* NB: the IV is _two_ blocks long */ -void AES_ige_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - unsigned char *ivec, const int enc); -/* NB: the IV is _four_ blocks long */ -void AES_bi_ige_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const AES_KEY *key, - const AES_KEY *key2, const unsigned char *ivec, - const int enc); - -int AES_wrap_key(AES_KEY *key, const unsigned char *iv, - unsigned char *out, - const unsigned char *in, unsigned int inlen); -int AES_unwrap_key(AES_KEY *key, const unsigned char *iv, - unsigned char *out, - const unsigned char *in, unsigned int inlen); - - -# ifdef __cplusplus -} -# endif - -#endif diff --git a/android/armeabi/include/openssl/asn1.h b/android/armeabi/include/openssl/asn1.h deleted file mode 100644 index 7cf61161..00000000 --- a/android/armeabi/include/openssl/asn1.h +++ /dev/null @@ -1,1096 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ASN1_H -# define HEADER_ASN1_H - -# include <time.h> -# include <openssl/e_os2.h> -# include <openssl/opensslconf.h> -# include <openssl/bio.h> -# include <openssl/stack.h> -# include <openssl/safestack.h> - -# include <openssl/symhacks.h> - -# include <openssl/ossl_typ.h> -# if OPENSSL_API_COMPAT < 0x10100000L -# include <openssl/bn.h> -# endif - -# ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -# endif - -#ifdef __cplusplus -extern "C" { -#endif - -# define V_ASN1_UNIVERSAL 0x00 -# define V_ASN1_APPLICATION 0x40 -# define V_ASN1_CONTEXT_SPECIFIC 0x80 -# define V_ASN1_PRIVATE 0xc0 - -# define V_ASN1_CONSTRUCTED 0x20 -# define V_ASN1_PRIMITIVE_TAG 0x1f -# define V_ASN1_PRIMATIVE_TAG 0x1f - -# define V_ASN1_APP_CHOOSE -2/* let the recipient choose */ -# define V_ASN1_OTHER -3/* used in ASN1_TYPE */ -# define V_ASN1_ANY -4/* used in ASN1 template code */ - -# define V_ASN1_UNDEF -1 -/* ASN.1 tag values */ -# define V_ASN1_EOC 0 -# define V_ASN1_BOOLEAN 1 /**/ -# define V_ASN1_INTEGER 2 -# define V_ASN1_BIT_STRING 3 -# define V_ASN1_OCTET_STRING 4 -# define V_ASN1_NULL 5 -# define V_ASN1_OBJECT 6 -# define V_ASN1_OBJECT_DESCRIPTOR 7 -# define V_ASN1_EXTERNAL 8 -# define V_ASN1_REAL 9 -# define V_ASN1_ENUMERATED 10 -# define V_ASN1_UTF8STRING 12 -# define V_ASN1_SEQUENCE 16 -# define V_ASN1_SET 17 -# define V_ASN1_NUMERICSTRING 18 /**/ -# define V_ASN1_PRINTABLESTRING 19 -# define V_ASN1_T61STRING 20 -# define V_ASN1_TELETEXSTRING 20/* alias */ -# define V_ASN1_VIDEOTEXSTRING 21 /**/ -# define V_ASN1_IA5STRING 22 -# define V_ASN1_UTCTIME 23 -# define V_ASN1_GENERALIZEDTIME 24 /**/ -# define V_ASN1_GRAPHICSTRING 25 /**/ -# define V_ASN1_ISO64STRING 26 /**/ -# define V_ASN1_VISIBLESTRING 26/* alias */ -# define V_ASN1_GENERALSTRING 27 /**/ -# define V_ASN1_UNIVERSALSTRING 28 /**/ -# define V_ASN1_BMPSTRING 30 - -/* - * NB the constants below are used internally by ASN1_INTEGER - * and ASN1_ENUMERATED to indicate the sign. They are *not* on - * the wire tag values. - */ - -# define V_ASN1_NEG 0x100 -# define V_ASN1_NEG_INTEGER (2 | V_ASN1_NEG) -# define V_ASN1_NEG_ENUMERATED (10 | V_ASN1_NEG) - -/* For use with d2i_ASN1_type_bytes() */ -# define B_ASN1_NUMERICSTRING 0x0001 -# define B_ASN1_PRINTABLESTRING 0x0002 -# define B_ASN1_T61STRING 0x0004 -# define B_ASN1_TELETEXSTRING 0x0004 -# define B_ASN1_VIDEOTEXSTRING 0x0008 -# define B_ASN1_IA5STRING 0x0010 -# define B_ASN1_GRAPHICSTRING 0x0020 -# define B_ASN1_ISO64STRING 0x0040 -# define B_ASN1_VISIBLESTRING 0x0040 -# define B_ASN1_GENERALSTRING 0x0080 -# define B_ASN1_UNIVERSALSTRING 0x0100 -# define B_ASN1_OCTET_STRING 0x0200 -# define B_ASN1_BIT_STRING 0x0400 -# define B_ASN1_BMPSTRING 0x0800 -# define B_ASN1_UNKNOWN 0x1000 -# define B_ASN1_UTF8STRING 0x2000 -# define B_ASN1_UTCTIME 0x4000 -# define B_ASN1_GENERALIZEDTIME 0x8000 -# define B_ASN1_SEQUENCE 0x10000 -/* For use with ASN1_mbstring_copy() */ -# define MBSTRING_FLAG 0x1000 -# define MBSTRING_UTF8 (MBSTRING_FLAG) -# define MBSTRING_ASC (MBSTRING_FLAG|1) -# define MBSTRING_BMP (MBSTRING_FLAG|2) -# define MBSTRING_UNIV (MBSTRING_FLAG|4) -# define SMIME_OLDMIME 0x400 -# define SMIME_CRLFEOL 0x800 -# define SMIME_STREAM 0x1000 - struct X509_algor_st; -DEFINE_STACK_OF(X509_ALGOR) - -# define ASN1_STRING_FLAG_BITS_LEFT 0x08/* Set if 0x07 has bits left value */ -/* - * This indicates that the ASN1_STRING is not a real value but just a place - * holder for the location where indefinite length constructed data should be - * inserted in the memory buffer - */ -# define ASN1_STRING_FLAG_NDEF 0x010 - -/* - * This flag is used by the CMS code to indicate that a string is not - * complete and is a place holder for content when it had all been accessed. - * The flag will be reset when content has been written to it. - */ - -# define ASN1_STRING_FLAG_CONT 0x020 -/* - * This flag is used by ASN1 code to indicate an ASN1_STRING is an MSTRING - * type. - */ -# define ASN1_STRING_FLAG_MSTRING 0x040 -/* String is embedded and only content should be freed */ -# define ASN1_STRING_FLAG_EMBED 0x080 -/* This is the base type that holds just about everything :-) */ -struct asn1_string_st { - int length; - int type; - unsigned char *data; - /* - * The value of the following field depends on the type being held. It - * is mostly being used for BIT_STRING so if the input data has a - * non-zero 'unused bits' value, it will be handled correctly - */ - long flags; -}; - -/* - * ASN1_ENCODING structure: this is used to save the received encoding of an - * ASN1 type. This is useful to get round problems with invalid encodings - * which can break signatures. - */ - -typedef struct ASN1_ENCODING_st { - unsigned char *enc; /* DER encoding */ - long len; /* Length of encoding */ - int modified; /* set to 1 if 'enc' is invalid */ -} ASN1_ENCODING; - -/* Used with ASN1 LONG type: if a long is set to this it is omitted */ -# define ASN1_LONG_UNDEF 0x7fffffffL - -# define STABLE_FLAGS_MALLOC 0x01 -/* - * A zero passed to ASN1_STRING_TABLE_new_add for the flags is interpreted - * as "don't change" and STABLE_FLAGS_MALLOC is always set. By setting - * STABLE_FLAGS_MALLOC only we can clear the existing value. Use the alias - * STABLE_FLAGS_CLEAR to reflect this. - */ -# define STABLE_FLAGS_CLEAR STABLE_FLAGS_MALLOC -# define STABLE_NO_MASK 0x02 -# define DIRSTRING_TYPE \ - (B_ASN1_PRINTABLESTRING|B_ASN1_T61STRING|B_ASN1_BMPSTRING|B_ASN1_UTF8STRING) -# define PKCS9STRING_TYPE (DIRSTRING_TYPE|B_ASN1_IA5STRING) - -typedef struct asn1_string_table_st { - int nid; - long minsize; - long maxsize; - unsigned long mask; - unsigned long flags; -} ASN1_STRING_TABLE; - -DEFINE_STACK_OF(ASN1_STRING_TABLE) - -/* size limits: this stuff is taken straight from RFC2459 */ - -# define ub_name 32768 -# define ub_common_name 64 -# define ub_locality_name 128 -# define ub_state_name 128 -# define ub_organization_name 64 -# define ub_organization_unit_name 64 -# define ub_title 64 -# define ub_email_address 128 - -/* - * Declarations for template structures: for full definitions see asn1t.h - */ -typedef struct ASN1_TEMPLATE_st ASN1_TEMPLATE; -typedef struct ASN1_TLC_st ASN1_TLC; -/* This is just an opaque pointer */ -typedef struct ASN1_VALUE_st ASN1_VALUE; - -/* Declare ASN1 functions: the implement macro in in asn1t.h */ - -# define DECLARE_ASN1_FUNCTIONS(type) DECLARE_ASN1_FUNCTIONS_name(type, type) - -# define DECLARE_ASN1_ALLOC_FUNCTIONS(type) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, type) - -# define DECLARE_ASN1_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS(type, name, name) - -# define DECLARE_ASN1_FUNCTIONS_fname(type, itname, name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) - -# define DECLARE_ASN1_ENCODE_FUNCTIONS(type, itname, name) \ - type *d2i_##name(type **a, const unsigned char **in, long len); \ - int i2d_##name(type *a, unsigned char **out); \ - DECLARE_ASN1_ITEM(itname) - -# define DECLARE_ASN1_ENCODE_FUNCTIONS_const(type, name) \ - type *d2i_##name(type **a, const unsigned char **in, long len); \ - int i2d_##name(const type *a, unsigned char **out); \ - DECLARE_ASN1_ITEM(name) - -# define DECLARE_ASN1_NDEF_FUNCTION(name) \ - int i2d_##name##_NDEF(name *a, unsigned char **out); - -# define DECLARE_ASN1_FUNCTIONS_const(name) \ - DECLARE_ASN1_ALLOC_FUNCTIONS(name) \ - DECLARE_ASN1_ENCODE_FUNCTIONS_const(name, name) - -# define DECLARE_ASN1_ALLOC_FUNCTIONS_name(type, name) \ - type *name##_new(void); \ - void name##_free(type *a); - -# define DECLARE_ASN1_PRINT_FUNCTION(stname) \ - DECLARE_ASN1_PRINT_FUNCTION_fname(stname, stname) - -# define DECLARE_ASN1_PRINT_FUNCTION_fname(stname, fname) \ - int fname##_print_ctx(BIO *out, stname *x, int indent, \ - const ASN1_PCTX *pctx); - -# define D2I_OF(type) type *(*)(type **,const unsigned char **,long) -# define I2D_OF(type) int (*)(type *,unsigned char **) -# define I2D_OF_const(type) int (*)(const type *,unsigned char **) - -# define CHECKED_D2I_OF(type, d2i) \ - ((d2i_of_void*) (1 ? d2i : ((D2I_OF(type))0))) -# define CHECKED_I2D_OF(type, i2d) \ - ((i2d_of_void*) (1 ? i2d : ((I2D_OF(type))0))) -# define CHECKED_NEW_OF(type, xnew) \ - ((void *(*)(void)) (1 ? xnew : ((type *(*)(void))0))) -# define CHECKED_PTR_OF(type, p) \ - ((void*) (1 ? p : (type*)0)) -# define CHECKED_PPTR_OF(type, p) \ - ((void**) (1 ? p : (type**)0)) - -# define TYPEDEF_D2I_OF(type) typedef type *d2i_of_##type(type **,const unsigned char **,long) -# define TYPEDEF_I2D_OF(type) typedef int i2d_of_##type(type *,unsigned char **) -# define TYPEDEF_D2I2D_OF(type) TYPEDEF_D2I_OF(type); TYPEDEF_I2D_OF(type) - -TYPEDEF_D2I2D_OF(void); - -/*- - * The following macros and typedefs allow an ASN1_ITEM - * to be embedded in a structure and referenced. Since - * the ASN1_ITEM pointers need to be globally accessible - * (possibly from shared libraries) they may exist in - * different forms. On platforms that support it the - * ASN1_ITEM structure itself will be globally exported. - * Other platforms will export a function that returns - * an ASN1_ITEM pointer. - * - * To handle both cases transparently the macros below - * should be used instead of hard coding an ASN1_ITEM - * pointer in a structure. - * - * The structure will look like this: - * - * typedef struct SOMETHING_st { - * ... - * ASN1_ITEM_EXP *iptr; - * ... - * } SOMETHING; - * - * It would be initialised as e.g.: - * - * SOMETHING somevar = {...,ASN1_ITEM_ref(X509),...}; - * - * and the actual pointer extracted with: - * - * const ASN1_ITEM *it = ASN1_ITEM_ptr(somevar.iptr); - * - * Finally an ASN1_ITEM pointer can be extracted from an - * appropriate reference with: ASN1_ITEM_rptr(X509). This - * would be used when a function takes an ASN1_ITEM * argument. - * - */ - -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* ASN1_ITEM pointer exported type */ -typedef const ASN1_ITEM ASN1_ITEM_EXP; - -/* Macro to obtain ASN1_ITEM pointer from exported type */ -# define ASN1_ITEM_ptr(iptr) (iptr) - -/* Macro to include ASN1_ITEM pointer from base type */ -# define ASN1_ITEM_ref(iptr) (&(iptr##_it)) - -# define ASN1_ITEM_rptr(ref) (&(ref##_it)) - -# define DECLARE_ASN1_ITEM(name) \ - OPENSSL_EXTERN const ASN1_ITEM name##_it; - -# else - -/* - * Platforms that can't easily handle shared global variables are declared as - * functions returning ASN1_ITEM pointers. - */ - -/* ASN1_ITEM pointer exported type */ -typedef const ASN1_ITEM *ASN1_ITEM_EXP (void); - -/* Macro to obtain ASN1_ITEM pointer from exported type */ -# define ASN1_ITEM_ptr(iptr) (iptr()) - -/* Macro to include ASN1_ITEM pointer from base type */ -# define ASN1_ITEM_ref(iptr) (iptr##_it) - -# define ASN1_ITEM_rptr(ref) (ref##_it()) - -# define DECLARE_ASN1_ITEM(name) \ - const ASN1_ITEM * name##_it(void); - -# endif - -/* Parameters used by ASN1_STRING_print_ex() */ - -/* - * These determine which characters to escape: RFC2253 special characters, - * control characters and MSB set characters - */ - -# define ASN1_STRFLGS_ESC_2253 1 -# define ASN1_STRFLGS_ESC_CTRL 2 -# define ASN1_STRFLGS_ESC_MSB 4 - -/* - * This flag determines how we do escaping: normally RC2253 backslash only, - * set this to use backslash and quote. - */ - -# define ASN1_STRFLGS_ESC_QUOTE 8 - -/* These three flags are internal use only. */ - -/* Character is a valid PrintableString character */ -# define CHARTYPE_PRINTABLESTRING 0x10 -/* Character needs escaping if it is the first character */ -# define CHARTYPE_FIRST_ESC_2253 0x20 -/* Character needs escaping if it is the last character */ -# define CHARTYPE_LAST_ESC_2253 0x40 - -/* - * NB the internal flags are safely reused below by flags handled at the top - * level. - */ - -/* - * If this is set we convert all character strings to UTF8 first - */ - -# define ASN1_STRFLGS_UTF8_CONVERT 0x10 - -/* - * If this is set we don't attempt to interpret content: just assume all - * strings are 1 byte per character. This will produce some pretty odd - * looking output! - */ - -# define ASN1_STRFLGS_IGNORE_TYPE 0x20 - -/* If this is set we include the string type in the output */ -# define ASN1_STRFLGS_SHOW_TYPE 0x40 - -/* - * This determines which strings to display and which to 'dump' (hex dump of - * content octets or DER encoding). We can only dump non character strings or - * everything. If we don't dump 'unknown' they are interpreted as character - * strings with 1 octet per character and are subject to the usual escaping - * options. - */ - -# define ASN1_STRFLGS_DUMP_ALL 0x80 -# define ASN1_STRFLGS_DUMP_UNKNOWN 0x100 - -/* - * These determine what 'dumping' does, we can dump the content octets or the - * DER encoding: both use the RFC2253 #XXXXX notation. - */ - -# define ASN1_STRFLGS_DUMP_DER 0x200 - -/* - * This flag specifies that RC2254 escaping shall be performed. - */ -#define ASN1_STRFLGS_ESC_2254 0x400 - -/* - * All the string flags consistent with RFC2253, escaping control characters - * isn't essential in RFC2253 but it is advisable anyway. - */ - -# define ASN1_STRFLGS_RFC2253 (ASN1_STRFLGS_ESC_2253 | \ - ASN1_STRFLGS_ESC_CTRL | \ - ASN1_STRFLGS_ESC_MSB | \ - ASN1_STRFLGS_UTF8_CONVERT | \ - ASN1_STRFLGS_DUMP_UNKNOWN | \ - ASN1_STRFLGS_DUMP_DER) - -DEFINE_STACK_OF(ASN1_INTEGER) - -DEFINE_STACK_OF(ASN1_GENERALSTRING) - -DEFINE_STACK_OF(ASN1_UTF8STRING) - -typedef struct asn1_type_st { - int type; - union { - char *ptr; - ASN1_BOOLEAN boolean; - ASN1_STRING *asn1_string; - ASN1_OBJECT *object; - ASN1_INTEGER *integer; - ASN1_ENUMERATED *enumerated; - ASN1_BIT_STRING *bit_string; - ASN1_OCTET_STRING *octet_string; - ASN1_PRINTABLESTRING *printablestring; - ASN1_T61STRING *t61string; - ASN1_IA5STRING *ia5string; - ASN1_GENERALSTRING *generalstring; - ASN1_BMPSTRING *bmpstring; - ASN1_UNIVERSALSTRING *universalstring; - ASN1_UTCTIME *utctime; - ASN1_GENERALIZEDTIME *generalizedtime; - ASN1_VISIBLESTRING *visiblestring; - ASN1_UTF8STRING *utf8string; - /* - * set and sequence are left complete and still contain the set or - * sequence bytes - */ - ASN1_STRING *set; - ASN1_STRING *sequence; - ASN1_VALUE *asn1_value; - } value; -} ASN1_TYPE; - -DEFINE_STACK_OF(ASN1_TYPE) - -typedef STACK_OF(ASN1_TYPE) ASN1_SEQUENCE_ANY; - -DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SEQUENCE_ANY) -DECLARE_ASN1_ENCODE_FUNCTIONS_const(ASN1_SEQUENCE_ANY, ASN1_SET_ANY) - -/* This is used to contain a list of bit names */ -typedef struct BIT_STRING_BITNAME_st { - int bitnum; - const char *lname; - const char *sname; -} BIT_STRING_BITNAME; - -# define B_ASN1_TIME \ - B_ASN1_UTCTIME | \ - B_ASN1_GENERALIZEDTIME - -# define B_ASN1_PRINTABLE \ - B_ASN1_NUMERICSTRING| \ - B_ASN1_PRINTABLESTRING| \ - B_ASN1_T61STRING| \ - B_ASN1_IA5STRING| \ - B_ASN1_BIT_STRING| \ - B_ASN1_UNIVERSALSTRING|\ - B_ASN1_BMPSTRING|\ - B_ASN1_UTF8STRING|\ - B_ASN1_SEQUENCE|\ - B_ASN1_UNKNOWN - -# define B_ASN1_DIRECTORYSTRING \ - B_ASN1_PRINTABLESTRING| \ - B_ASN1_TELETEXSTRING|\ - B_ASN1_BMPSTRING|\ - B_ASN1_UNIVERSALSTRING|\ - B_ASN1_UTF8STRING - -# define B_ASN1_DISPLAYTEXT \ - B_ASN1_IA5STRING| \ - B_ASN1_VISIBLESTRING| \ - B_ASN1_BMPSTRING|\ - B_ASN1_UTF8STRING - -DECLARE_ASN1_FUNCTIONS_fname(ASN1_TYPE, ASN1_ANY, ASN1_TYPE) - -int ASN1_TYPE_get(const ASN1_TYPE *a); -void ASN1_TYPE_set(ASN1_TYPE *a, int type, void *value); -int ASN1_TYPE_set1(ASN1_TYPE *a, int type, const void *value); -int ASN1_TYPE_cmp(const ASN1_TYPE *a, const ASN1_TYPE *b); - -ASN1_TYPE *ASN1_TYPE_pack_sequence(const ASN1_ITEM *it, void *s, ASN1_TYPE **t); -void *ASN1_TYPE_unpack_sequence(const ASN1_ITEM *it, const ASN1_TYPE *t); - -ASN1_OBJECT *ASN1_OBJECT_new(void); -void ASN1_OBJECT_free(ASN1_OBJECT *a); -int i2d_ASN1_OBJECT(const ASN1_OBJECT *a, unsigned char **pp); -ASN1_OBJECT *d2i_ASN1_OBJECT(ASN1_OBJECT **a, const unsigned char **pp, - long length); - -DECLARE_ASN1_ITEM(ASN1_OBJECT) - -DEFINE_STACK_OF(ASN1_OBJECT) - -ASN1_STRING *ASN1_STRING_new(void); -void ASN1_STRING_free(ASN1_STRING *a); -void ASN1_STRING_clear_free(ASN1_STRING *a); -int ASN1_STRING_copy(ASN1_STRING *dst, const ASN1_STRING *str); -ASN1_STRING *ASN1_STRING_dup(const ASN1_STRING *a); -ASN1_STRING *ASN1_STRING_type_new(int type); -int ASN1_STRING_cmp(const ASN1_STRING *a, const ASN1_STRING *b); - /* - * Since this is used to store all sorts of things, via macros, for now, - * make its data void * - */ -int ASN1_STRING_set(ASN1_STRING *str, const void *data, int len); -void ASN1_STRING_set0(ASN1_STRING *str, void *data, int len); -int ASN1_STRING_length(const ASN1_STRING *x); -void ASN1_STRING_length_set(ASN1_STRING *x, int n); -int ASN1_STRING_type(const ASN1_STRING *x); -DEPRECATEDIN_1_1_0(unsigned char *ASN1_STRING_data(ASN1_STRING *x)) -const unsigned char *ASN1_STRING_get0_data(const ASN1_STRING *x); - -DECLARE_ASN1_FUNCTIONS(ASN1_BIT_STRING) -int ASN1_BIT_STRING_set(ASN1_BIT_STRING *a, unsigned char *d, int length); -int ASN1_BIT_STRING_set_bit(ASN1_BIT_STRING *a, int n, int value); -int ASN1_BIT_STRING_get_bit(const ASN1_BIT_STRING *a, int n); -int ASN1_BIT_STRING_check(const ASN1_BIT_STRING *a, - const unsigned char *flags, int flags_len); - -int ASN1_BIT_STRING_name_print(BIO *out, ASN1_BIT_STRING *bs, - BIT_STRING_BITNAME *tbl, int indent); -int ASN1_BIT_STRING_num_asc(const char *name, BIT_STRING_BITNAME *tbl); -int ASN1_BIT_STRING_set_asc(ASN1_BIT_STRING *bs, const char *name, int value, - BIT_STRING_BITNAME *tbl); - -DECLARE_ASN1_FUNCTIONS(ASN1_INTEGER) -ASN1_INTEGER *d2i_ASN1_UINTEGER(ASN1_INTEGER **a, const unsigned char **pp, - long length); -ASN1_INTEGER *ASN1_INTEGER_dup(const ASN1_INTEGER *x); -int ASN1_INTEGER_cmp(const ASN1_INTEGER *x, const ASN1_INTEGER *y); - -DECLARE_ASN1_FUNCTIONS(ASN1_ENUMERATED) - -int ASN1_UTCTIME_check(const ASN1_UTCTIME *a); -ASN1_UTCTIME *ASN1_UTCTIME_set(ASN1_UTCTIME *s, time_t t); -ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, time_t t, - int offset_day, long offset_sec); -int ASN1_UTCTIME_set_string(ASN1_UTCTIME *s, const char *str); -int ASN1_UTCTIME_cmp_time_t(const ASN1_UTCTIME *s, time_t t); - -int ASN1_GENERALIZEDTIME_check(const ASN1_GENERALIZEDTIME *a); -ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_set(ASN1_GENERALIZEDTIME *s, - time_t t); -ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s, - time_t t, int offset_day, - long offset_sec); -int ASN1_GENERALIZEDTIME_set_string(ASN1_GENERALIZEDTIME *s, const char *str); -int ASN1_TIME_diff(int *pday, int *psec, - const ASN1_TIME *from, const ASN1_TIME *to); - -DECLARE_ASN1_FUNCTIONS(ASN1_OCTET_STRING) -ASN1_OCTET_STRING *ASN1_OCTET_STRING_dup(const ASN1_OCTET_STRING *a); -int ASN1_OCTET_STRING_cmp(const ASN1_OCTET_STRING *a, - const ASN1_OCTET_STRING *b); -int ASN1_OCTET_STRING_set(ASN1_OCTET_STRING *str, const unsigned char *data, - int len); - -DECLARE_ASN1_FUNCTIONS(ASN1_VISIBLESTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UNIVERSALSTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UTF8STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_NULL) -DECLARE_ASN1_FUNCTIONS(ASN1_BMPSTRING) - -int UTF8_getc(const unsigned char *str, int len, unsigned long *val); -int UTF8_putc(unsigned char *str, int len, unsigned long value); - -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, ASN1_PRINTABLE) - -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DIRECTORYSTRING) -DECLARE_ASN1_FUNCTIONS_name(ASN1_STRING, DISPLAYTEXT) -DECLARE_ASN1_FUNCTIONS(ASN1_PRINTABLESTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_T61STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_IA5STRING) -DECLARE_ASN1_FUNCTIONS(ASN1_GENERALSTRING) -DECLARE_ASN1_FUNCTIONS(ASN1_UTCTIME) -DECLARE_ASN1_FUNCTIONS(ASN1_GENERALIZEDTIME) -DECLARE_ASN1_FUNCTIONS(ASN1_TIME) - -DECLARE_ASN1_ITEM(ASN1_OCTET_STRING_NDEF) - -ASN1_TIME *ASN1_TIME_set(ASN1_TIME *s, time_t t); -ASN1_TIME *ASN1_TIME_adj(ASN1_TIME *s, time_t t, - int offset_day, long offset_sec); -int ASN1_TIME_check(const ASN1_TIME *t); -ASN1_GENERALIZEDTIME *ASN1_TIME_to_generalizedtime(ASN1_TIME *t, ASN1_GENERALIZEDTIME - **out); -int ASN1_TIME_set_string(ASN1_TIME *s, const char *str); - -int i2a_ASN1_INTEGER(BIO *bp, const ASN1_INTEGER *a); -int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size); -int i2a_ASN1_ENUMERATED(BIO *bp, const ASN1_ENUMERATED *a); -int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size); -int i2a_ASN1_OBJECT(BIO *bp, const ASN1_OBJECT *a); -int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size); -int i2a_ASN1_STRING(BIO *bp, const ASN1_STRING *a, int type); -int i2t_ASN1_OBJECT(char *buf, int buf_len, const ASN1_OBJECT *a); - -int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num); -ASN1_OBJECT *ASN1_OBJECT_create(int nid, unsigned char *data, int len, - const char *sn, const char *ln); - -int ASN1_INTEGER_get_int64(int64_t *pr, const ASN1_INTEGER *a); -int ASN1_INTEGER_set_int64(ASN1_INTEGER *a, int64_t r); -int ASN1_INTEGER_get_uint64(uint64_t *pr, const ASN1_INTEGER *a); -int ASN1_INTEGER_set_uint64(ASN1_INTEGER *a, uint64_t r); - -int ASN1_INTEGER_set(ASN1_INTEGER *a, long v); -long ASN1_INTEGER_get(const ASN1_INTEGER *a); -ASN1_INTEGER *BN_to_ASN1_INTEGER(const BIGNUM *bn, ASN1_INTEGER *ai); -BIGNUM *ASN1_INTEGER_to_BN(const ASN1_INTEGER *ai, BIGNUM *bn); - -int ASN1_ENUMERATED_get_int64(int64_t *pr, const ASN1_ENUMERATED *a); -int ASN1_ENUMERATED_set_int64(ASN1_ENUMERATED *a, int64_t r); - - -int ASN1_ENUMERATED_set(ASN1_ENUMERATED *a, long v); -long ASN1_ENUMERATED_get(const ASN1_ENUMERATED *a); -ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(const BIGNUM *bn, ASN1_ENUMERATED *ai); -BIGNUM *ASN1_ENUMERATED_to_BN(const ASN1_ENUMERATED *ai, BIGNUM *bn); - -/* General */ -/* given a string, return the correct type, max is the maximum length */ -int ASN1_PRINTABLE_type(const unsigned char *s, int max); - -unsigned long ASN1_tag2bit(int tag); - -/* SPECIALS */ -int ASN1_get_object(const unsigned char **pp, long *plength, int *ptag, - int *pclass, long omax); -int ASN1_check_infinite_end(unsigned char **p, long len); -int ASN1_const_check_infinite_end(const unsigned char **p, long len); -void ASN1_put_object(unsigned char **pp, int constructed, int length, - int tag, int xclass); -int ASN1_put_eoc(unsigned char **pp); -int ASN1_object_size(int constructed, int length, int tag); - -/* Used to implement other functions */ -void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, void *x); - -# define ASN1_dup_of(type,i2d,d2i,x) \ - ((type*)ASN1_dup(CHECKED_I2D_OF(type, i2d), \ - CHECKED_D2I_OF(type, d2i), \ - CHECKED_PTR_OF(type, x))) - -# define ASN1_dup_of_const(type,i2d,d2i,x) \ - ((type*)ASN1_dup(CHECKED_I2D_OF(const type, i2d), \ - CHECKED_D2I_OF(type, d2i), \ - CHECKED_PTR_OF(const type, x))) - -void *ASN1_item_dup(const ASN1_ITEM *it, void *x); - -/* ASN1 alloc/free macros for when a type is only used internally */ - -# define M_ASN1_new_of(type) (type *)ASN1_item_new(ASN1_ITEM_rptr(type)) -# define M_ASN1_free_of(x, type) \ - ASN1_item_free(CHECKED_PTR_OF(type, x), ASN1_ITEM_rptr(type)) - -# ifndef OPENSSL_NO_STDIO -void *ASN1_d2i_fp(void *(*xnew) (void), d2i_of_void *d2i, FILE *in, void **x); - -# define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \ - ((type*)ASN1_d2i_fp(CHECKED_NEW_OF(type, xnew), \ - CHECKED_D2I_OF(type, d2i), \ - in, \ - CHECKED_PPTR_OF(type, x))) - -void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x); -int ASN1_i2d_fp(i2d_of_void *i2d, FILE *out, void *x); - -# define ASN1_i2d_fp_of(type,i2d,out,x) \ - (ASN1_i2d_fp(CHECKED_I2D_OF(type, i2d), \ - out, \ - CHECKED_PTR_OF(type, x))) - -# define ASN1_i2d_fp_of_const(type,i2d,out,x) \ - (ASN1_i2d_fp(CHECKED_I2D_OF(const type, i2d), \ - out, \ - CHECKED_PTR_OF(const type, x))) - -int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x); -int ASN1_STRING_print_ex_fp(FILE *fp, const ASN1_STRING *str, unsigned long flags); -# endif - -int ASN1_STRING_to_UTF8(unsigned char **out, const ASN1_STRING *in); - -void *ASN1_d2i_bio(void *(*xnew) (void), d2i_of_void *d2i, BIO *in, void **x); - -# define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \ - ((type*)ASN1_d2i_bio( CHECKED_NEW_OF(type, xnew), \ - CHECKED_D2I_OF(type, d2i), \ - in, \ - CHECKED_PPTR_OF(type, x))) - -void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x); -int ASN1_i2d_bio(i2d_of_void *i2d, BIO *out, unsigned char *x); - -# define ASN1_i2d_bio_of(type,i2d,out,x) \ - (ASN1_i2d_bio(CHECKED_I2D_OF(type, i2d), \ - out, \ - CHECKED_PTR_OF(type, x))) - -# define ASN1_i2d_bio_of_const(type,i2d,out,x) \ - (ASN1_i2d_bio(CHECKED_I2D_OF(const type, i2d), \ - out, \ - CHECKED_PTR_OF(const type, x))) - -int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x); -int ASN1_UTCTIME_print(BIO *fp, const ASN1_UTCTIME *a); -int ASN1_GENERALIZEDTIME_print(BIO *fp, const ASN1_GENERALIZEDTIME *a); -int ASN1_TIME_print(BIO *fp, const ASN1_TIME *a); -int ASN1_STRING_print(BIO *bp, const ASN1_STRING *v); -int ASN1_STRING_print_ex(BIO *out, const ASN1_STRING *str, unsigned long flags); -int ASN1_buf_print(BIO *bp, const unsigned char *buf, size_t buflen, int off); -int ASN1_bn_print(BIO *bp, const char *number, const BIGNUM *num, - unsigned char *buf, int off); -int ASN1_parse(BIO *bp, const unsigned char *pp, long len, int indent); -int ASN1_parse_dump(BIO *bp, const unsigned char *pp, long len, int indent, - int dump); -const char *ASN1_tag2str(int tag); - -/* Used to load and write Netscape format cert */ - -int ASN1_UNIVERSALSTRING_to_string(ASN1_UNIVERSALSTRING *s); - -int ASN1_TYPE_set_octetstring(ASN1_TYPE *a, unsigned char *data, int len); -int ASN1_TYPE_get_octetstring(const ASN1_TYPE *a, unsigned char *data, int max_len); -int ASN1_TYPE_set_int_octetstring(ASN1_TYPE *a, long num, - unsigned char *data, int len); -int ASN1_TYPE_get_int_octetstring(const ASN1_TYPE *a, long *num, - unsigned char *data, int max_len); - -void *ASN1_item_unpack(const ASN1_STRING *oct, const ASN1_ITEM *it); - -ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, - ASN1_OCTET_STRING **oct); - -void ASN1_STRING_set_default_mask(unsigned long mask); -int ASN1_STRING_set_default_mask_asc(const char *p); -unsigned long ASN1_STRING_get_default_mask(void); -int ASN1_mbstring_copy(ASN1_STRING **out, const unsigned char *in, int len, - int inform, unsigned long mask); -int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, - int inform, unsigned long mask, - long minsize, long maxsize); - -ASN1_STRING *ASN1_STRING_set_by_NID(ASN1_STRING **out, - const unsigned char *in, int inlen, - int inform, int nid); -ASN1_STRING_TABLE *ASN1_STRING_TABLE_get(int nid); -int ASN1_STRING_TABLE_add(int, long, long, unsigned long, unsigned long); -void ASN1_STRING_TABLE_cleanup(void); - -/* ASN1 template functions */ - -/* Old API compatible functions */ -ASN1_VALUE *ASN1_item_new(const ASN1_ITEM *it); -void ASN1_item_free(ASN1_VALUE *val, const ASN1_ITEM *it); -ASN1_VALUE *ASN1_item_d2i(ASN1_VALUE **val, const unsigned char **in, - long len, const ASN1_ITEM *it); -int ASN1_item_i2d(ASN1_VALUE *val, unsigned char **out, const ASN1_ITEM *it); -int ASN1_item_ndef_i2d(ASN1_VALUE *val, unsigned char **out, - const ASN1_ITEM *it); - -void ASN1_add_oid_module(void); -void ASN1_add_stable_module(void); - -ASN1_TYPE *ASN1_generate_nconf(const char *str, CONF *nconf); -ASN1_TYPE *ASN1_generate_v3(const char *str, X509V3_CTX *cnf); -int ASN1_str2mask(const char *str, unsigned long *pmask); - -/* ASN1 Print flags */ - -/* Indicate missing OPTIONAL fields */ -# define ASN1_PCTX_FLAGS_SHOW_ABSENT 0x001 -/* Mark start and end of SEQUENCE */ -# define ASN1_PCTX_FLAGS_SHOW_SEQUENCE 0x002 -/* Mark start and end of SEQUENCE/SET OF */ -# define ASN1_PCTX_FLAGS_SHOW_SSOF 0x004 -/* Show the ASN1 type of primitives */ -# define ASN1_PCTX_FLAGS_SHOW_TYPE 0x008 -/* Don't show ASN1 type of ANY */ -# define ASN1_PCTX_FLAGS_NO_ANY_TYPE 0x010 -/* Don't show ASN1 type of MSTRINGs */ -# define ASN1_PCTX_FLAGS_NO_MSTRING_TYPE 0x020 -/* Don't show field names in SEQUENCE */ -# define ASN1_PCTX_FLAGS_NO_FIELD_NAME 0x040 -/* Show structure names of each SEQUENCE field */ -# define ASN1_PCTX_FLAGS_SHOW_FIELD_STRUCT_NAME 0x080 -/* Don't show structure name even at top level */ -# define ASN1_PCTX_FLAGS_NO_STRUCT_NAME 0x100 - -int ASN1_item_print(BIO *out, ASN1_VALUE *ifld, int indent, - const ASN1_ITEM *it, const ASN1_PCTX *pctx); -ASN1_PCTX *ASN1_PCTX_new(void); -void ASN1_PCTX_free(ASN1_PCTX *p); -unsigned long ASN1_PCTX_get_flags(const ASN1_PCTX *p); -void ASN1_PCTX_set_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_nm_flags(const ASN1_PCTX *p); -void ASN1_PCTX_set_nm_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_cert_flags(const ASN1_PCTX *p); -void ASN1_PCTX_set_cert_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_oid_flags(const ASN1_PCTX *p); -void ASN1_PCTX_set_oid_flags(ASN1_PCTX *p, unsigned long flags); -unsigned long ASN1_PCTX_get_str_flags(const ASN1_PCTX *p); -void ASN1_PCTX_set_str_flags(ASN1_PCTX *p, unsigned long flags); - -ASN1_SCTX *ASN1_SCTX_new(int (*scan_cb) (ASN1_SCTX *ctx)); -void ASN1_SCTX_free(ASN1_SCTX *p); -const ASN1_ITEM *ASN1_SCTX_get_item(ASN1_SCTX *p); -const ASN1_TEMPLATE *ASN1_SCTX_get_template(ASN1_SCTX *p); -unsigned long ASN1_SCTX_get_flags(ASN1_SCTX *p); -void ASN1_SCTX_set_app_data(ASN1_SCTX *p, void *data); -void *ASN1_SCTX_get_app_data(ASN1_SCTX *p); - -const BIO_METHOD *BIO_f_asn1(void); - -BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it); - -int i2d_ASN1_bio_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, - const ASN1_ITEM *it); -int PEM_write_bio_ASN1_stream(BIO *out, ASN1_VALUE *val, BIO *in, int flags, - const char *hdr, const ASN1_ITEM *it); -int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags, - int ctype_nid, int econt_nid, - STACK_OF(X509_ALGOR) *mdalgs, const ASN1_ITEM *it); -ASN1_VALUE *SMIME_read_ASN1(BIO *bio, BIO **bcont, const ASN1_ITEM *it); -int SMIME_crlf_copy(BIO *in, BIO *out, int flags); -int SMIME_text(BIO *in, BIO *out); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_ASN1_strings(void); - -/* Error codes for the ASN1 functions. */ - -/* Function codes. */ -# define ASN1_F_A2D_ASN1_OBJECT 100 -# define ASN1_F_A2I_ASN1_INTEGER 102 -# define ASN1_F_A2I_ASN1_STRING 103 -# define ASN1_F_APPEND_EXP 176 -# define ASN1_F_ASN1_BIT_STRING_SET_BIT 183 -# define ASN1_F_ASN1_CB 177 -# define ASN1_F_ASN1_CHECK_TLEN 104 -# define ASN1_F_ASN1_COLLECT 106 -# define ASN1_F_ASN1_D2I_EX_PRIMITIVE 108 -# define ASN1_F_ASN1_D2I_FP 109 -# define ASN1_F_ASN1_D2I_READ_BIO 107 -# define ASN1_F_ASN1_DIGEST 184 -# define ASN1_F_ASN1_DO_ADB 110 -# define ASN1_F_ASN1_DO_LOCK 233 -# define ASN1_F_ASN1_DUP 111 -# define ASN1_F_ASN1_EX_C2I 204 -# define ASN1_F_ASN1_FIND_END 190 -# define ASN1_F_ASN1_GENERALIZEDTIME_ADJ 216 -# define ASN1_F_ASN1_GENERATE_V3 178 -# define ASN1_F_ASN1_GET_INT64 224 -# define ASN1_F_ASN1_GET_OBJECT 114 -# define ASN1_F_ASN1_GET_UINT64 225 -# define ASN1_F_ASN1_I2D_BIO 116 -# define ASN1_F_ASN1_I2D_FP 117 -# define ASN1_F_ASN1_ITEM_D2I_FP 206 -# define ASN1_F_ASN1_ITEM_DUP 191 -# define ASN1_F_ASN1_ITEM_EMBED_D2I 120 -# define ASN1_F_ASN1_ITEM_EMBED_NEW 121 -# define ASN1_F_ASN1_ITEM_I2D_BIO 192 -# define ASN1_F_ASN1_ITEM_I2D_FP 193 -# define ASN1_F_ASN1_ITEM_PACK 198 -# define ASN1_F_ASN1_ITEM_SIGN 195 -# define ASN1_F_ASN1_ITEM_SIGN_CTX 220 -# define ASN1_F_ASN1_ITEM_UNPACK 199 -# define ASN1_F_ASN1_ITEM_VERIFY 197 -# define ASN1_F_ASN1_MBSTRING_NCOPY 122 -# define ASN1_F_ASN1_OBJECT_NEW 123 -# define ASN1_F_ASN1_OUTPUT_DATA 214 -# define ASN1_F_ASN1_PCTX_NEW 205 -# define ASN1_F_ASN1_SCTX_NEW 221 -# define ASN1_F_ASN1_SIGN 128 -# define ASN1_F_ASN1_STR2TYPE 179 -# define ASN1_F_ASN1_STRING_GET_INT64 227 -# define ASN1_F_ASN1_STRING_GET_UINT64 230 -# define ASN1_F_ASN1_STRING_SET 186 -# define ASN1_F_ASN1_STRING_TABLE_ADD 129 -# define ASN1_F_ASN1_STRING_TO_BN 228 -# define ASN1_F_ASN1_STRING_TYPE_NEW 130 -# define ASN1_F_ASN1_TEMPLATE_EX_D2I 132 -# define ASN1_F_ASN1_TEMPLATE_NEW 133 -# define ASN1_F_ASN1_TEMPLATE_NOEXP_D2I 131 -# define ASN1_F_ASN1_TIME_ADJ 217 -# define ASN1_F_ASN1_TYPE_GET_INT_OCTETSTRING 134 -# define ASN1_F_ASN1_TYPE_GET_OCTETSTRING 135 -# define ASN1_F_ASN1_UTCTIME_ADJ 218 -# define ASN1_F_ASN1_VERIFY 137 -# define ASN1_F_B64_READ_ASN1 209 -# define ASN1_F_B64_WRITE_ASN1 210 -# define ASN1_F_BIO_NEW_NDEF 208 -# define ASN1_F_BITSTR_CB 180 -# define ASN1_F_BN_TO_ASN1_STRING 229 -# define ASN1_F_C2I_ASN1_BIT_STRING 189 -# define ASN1_F_C2I_ASN1_INTEGER 194 -# define ASN1_F_C2I_ASN1_OBJECT 196 -# define ASN1_F_C2I_IBUF 226 -# define ASN1_F_COLLECT_DATA 140 -# define ASN1_F_D2I_ASN1_OBJECT 147 -# define ASN1_F_D2I_ASN1_UINTEGER 150 -# define ASN1_F_D2I_AUTOPRIVATEKEY 207 -# define ASN1_F_D2I_PRIVATEKEY 154 -# define ASN1_F_D2I_PUBLICKEY 155 -# define ASN1_F_DO_TCREATE 222 -# define ASN1_F_I2D_ASN1_BIO_STREAM 211 -# define ASN1_F_I2D_DSA_PUBKEY 161 -# define ASN1_F_I2D_EC_PUBKEY 181 -# define ASN1_F_I2D_PRIVATEKEY 163 -# define ASN1_F_I2D_PUBLICKEY 164 -# define ASN1_F_I2D_RSA_PUBKEY 165 -# define ASN1_F_LONG_C2I 166 -# define ASN1_F_OID_MODULE_INIT 174 -# define ASN1_F_PARSE_TAGGING 182 -# define ASN1_F_PKCS5_PBE2_SET_IV 167 -# define ASN1_F_PKCS5_PBE2_SET_SCRYPT 231 -# define ASN1_F_PKCS5_PBE_SET 202 -# define ASN1_F_PKCS5_PBE_SET0_ALGOR 215 -# define ASN1_F_PKCS5_PBKDF2_SET 219 -# define ASN1_F_PKCS5_SCRYPT_SET 232 -# define ASN1_F_SMIME_READ_ASN1 212 -# define ASN1_F_SMIME_TEXT 213 -# define ASN1_F_STBL_MODULE_INIT 223 -# define ASN1_F_X509_CRL_ADD0_REVOKED 169 -# define ASN1_F_X509_INFO_NEW 170 -# define ASN1_F_X509_NAME_ENCODE 203 -# define ASN1_F_X509_NAME_EX_D2I 158 -# define ASN1_F_X509_NAME_EX_NEW 171 -# define ASN1_F_X509_PKEY_NEW 173 - -/* Reason codes. */ -# define ASN1_R_ADDING_OBJECT 171 -# define ASN1_R_ASN1_PARSE_ERROR 203 -# define ASN1_R_ASN1_SIG_PARSE_ERROR 204 -# define ASN1_R_AUX_ERROR 100 -# define ASN1_R_BAD_OBJECT_HEADER 102 -# define ASN1_R_BMPSTRING_IS_WRONG_LENGTH 214 -# define ASN1_R_BN_LIB 105 -# define ASN1_R_BOOLEAN_IS_WRONG_LENGTH 106 -# define ASN1_R_BUFFER_TOO_SMALL 107 -# define ASN1_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 108 -# define ASN1_R_CONTEXT_NOT_INITIALISED 217 -# define ASN1_R_DATA_IS_WRONG 109 -# define ASN1_R_DECODE_ERROR 110 -# define ASN1_R_DEPTH_EXCEEDED 174 -# define ASN1_R_DIGEST_AND_KEY_TYPE_NOT_SUPPORTED 198 -# define ASN1_R_ENCODE_ERROR 112 -# define ASN1_R_ERROR_GETTING_TIME 173 -# define ASN1_R_ERROR_LOADING_SECTION 172 -# define ASN1_R_ERROR_SETTING_CIPHER_PARAMS 114 -# define ASN1_R_EXPECTING_AN_INTEGER 115 -# define ASN1_R_EXPECTING_AN_OBJECT 116 -# define ASN1_R_EXPLICIT_LENGTH_MISMATCH 119 -# define ASN1_R_EXPLICIT_TAG_NOT_CONSTRUCTED 120 -# define ASN1_R_FIELD_MISSING 121 -# define ASN1_R_FIRST_NUM_TOO_LARGE 122 -# define ASN1_R_HEADER_TOO_LONG 123 -# define ASN1_R_ILLEGAL_BITSTRING_FORMAT 175 -# define ASN1_R_ILLEGAL_BOOLEAN 176 -# define ASN1_R_ILLEGAL_CHARACTERS 124 -# define ASN1_R_ILLEGAL_FORMAT 177 -# define ASN1_R_ILLEGAL_HEX 178 -# define ASN1_R_ILLEGAL_IMPLICIT_TAG 179 -# define ASN1_R_ILLEGAL_INTEGER 180 -# define ASN1_R_ILLEGAL_NEGATIVE_VALUE 226 -# define ASN1_R_ILLEGAL_NESTED_TAGGING 181 -# define ASN1_R_ILLEGAL_NULL 125 -# define ASN1_R_ILLEGAL_NULL_VALUE 182 -# define ASN1_R_ILLEGAL_OBJECT 183 -# define ASN1_R_ILLEGAL_OPTIONAL_ANY 126 -# define ASN1_R_ILLEGAL_OPTIONS_ON_ITEM_TEMPLATE 170 -# define ASN1_R_ILLEGAL_PADDING 221 -# define ASN1_R_ILLEGAL_TAGGED_ANY 127 -# define ASN1_R_ILLEGAL_TIME_VALUE 184 -# define ASN1_R_ILLEGAL_ZERO_CONTENT 222 -# define ASN1_R_INTEGER_NOT_ASCII_FORMAT 185 -# define ASN1_R_INTEGER_TOO_LARGE_FOR_LONG 128 -# define ASN1_R_INVALID_BIT_STRING_BITS_LEFT 220 -# define ASN1_R_INVALID_BMPSTRING_LENGTH 129 -# define ASN1_R_INVALID_DIGIT 130 -# define ASN1_R_INVALID_MIME_TYPE 205 -# define ASN1_R_INVALID_MODIFIER 186 -# define ASN1_R_INVALID_NUMBER 187 -# define ASN1_R_INVALID_OBJECT_ENCODING 216 -# define ASN1_R_INVALID_SCRYPT_PARAMETERS 227 -# define ASN1_R_INVALID_SEPARATOR 131 -# define ASN1_R_INVALID_STRING_TABLE_VALUE 218 -# define ASN1_R_INVALID_UNIVERSALSTRING_LENGTH 133 -# define ASN1_R_INVALID_UTF8STRING 134 -# define ASN1_R_INVALID_VALUE 219 -# define ASN1_R_LIST_ERROR 188 -# define ASN1_R_MIME_NO_CONTENT_TYPE 206 -# define ASN1_R_MIME_PARSE_ERROR 207 -# define ASN1_R_MIME_SIG_PARSE_ERROR 208 -# define ASN1_R_MISSING_EOC 137 -# define ASN1_R_MISSING_SECOND_NUMBER 138 -# define ASN1_R_MISSING_VALUE 189 -# define ASN1_R_MSTRING_NOT_UNIVERSAL 139 -# define ASN1_R_MSTRING_WRONG_TAG 140 -# define ASN1_R_NESTED_ASN1_STRING 197 -# define ASN1_R_NON_HEX_CHARACTERS 141 -# define ASN1_R_NOT_ASCII_FORMAT 190 -# define ASN1_R_NOT_ENOUGH_DATA 142 -# define ASN1_R_NO_CONTENT_TYPE 209 -# define ASN1_R_NO_MATCHING_CHOICE_TYPE 143 -# define ASN1_R_NO_MULTIPART_BODY_FAILURE 210 -# define ASN1_R_NO_MULTIPART_BOUNDARY 211 -# define ASN1_R_NO_SIG_CONTENT_TYPE 212 -# define ASN1_R_NULL_IS_WRONG_LENGTH 144 -# define ASN1_R_OBJECT_NOT_ASCII_FORMAT 191 -# define ASN1_R_ODD_NUMBER_OF_CHARS 145 -# define ASN1_R_SECOND_NUMBER_TOO_LARGE 147 -# define ASN1_R_SEQUENCE_LENGTH_MISMATCH 148 -# define ASN1_R_SEQUENCE_NOT_CONSTRUCTED 149 -# define ASN1_R_SEQUENCE_OR_SET_NEEDS_CONFIG 192 -# define ASN1_R_SHORT_LINE 150 -# define ASN1_R_SIG_INVALID_MIME_TYPE 213 -# define ASN1_R_STREAMING_NOT_SUPPORTED 202 -# define ASN1_R_STRING_TOO_LONG 151 -# define ASN1_R_STRING_TOO_SHORT 152 -# define ASN1_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 154 -# define ASN1_R_TIME_NOT_ASCII_FORMAT 193 -# define ASN1_R_TOO_LARGE 223 -# define ASN1_R_TOO_LONG 155 -# define ASN1_R_TOO_SMALL 224 -# define ASN1_R_TYPE_NOT_CONSTRUCTED 156 -# define ASN1_R_TYPE_NOT_PRIMITIVE 195 -# define ASN1_R_UNEXPECTED_EOC 159 -# define ASN1_R_UNIVERSALSTRING_IS_WRONG_LENGTH 215 -# define ASN1_R_UNKNOWN_FORMAT 160 -# define ASN1_R_UNKNOWN_MESSAGE_DIGEST_ALGORITHM 161 -# define ASN1_R_UNKNOWN_OBJECT_TYPE 162 -# define ASN1_R_UNKNOWN_PUBLIC_KEY_TYPE 163 -# define ASN1_R_UNKNOWN_SIGNATURE_ALGORITHM 199 -# define ASN1_R_UNKNOWN_TAG 194 -# define ASN1_R_UNSUPPORTED_ANY_DEFINED_BY_TYPE 164 -# define ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE 167 -# define ASN1_R_UNSUPPORTED_TYPE 196 -# define ASN1_R_WRONG_INTEGER_TYPE 225 -# define ASN1_R_WRONG_PUBLIC_KEY_TYPE 200 -# define ASN1_R_WRONG_TAG 168 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/asn1_mac.h b/android/armeabi/include/openssl/asn1_mac.h deleted file mode 100644 index 7ac1782a..00000000 --- a/android/armeabi/include/openssl/asn1_mac.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#error "This file is obsolete; please update your software." diff --git a/android/armeabi/include/openssl/asn1t.h b/android/armeabi/include/openssl/asn1t.h deleted file mode 100644 index 8eedfb3f..00000000 --- a/android/armeabi/include/openssl/asn1t.h +++ /dev/null @@ -1,924 +0,0 @@ -/* - * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ASN1T_H -# define HEADER_ASN1T_H - -# include <stddef.h> -# include <openssl/e_os2.h> -# include <openssl/asn1.h> - -# ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -# endif - -/* ASN1 template defines, structures and functions */ - -#ifdef __cplusplus -extern "C" { -#endif - -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ -# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr)) - -/* Macros for start and end of ASN1_ITEM definition */ - -# define ASN1_ITEM_start(itname) \ - OPENSSL_GLOBAL const ASN1_ITEM itname##_it = { - -# define static_ASN1_ITEM_start(itname) \ - static const ASN1_ITEM itname##_it = { - -# define ASN1_ITEM_end(itname) \ - }; - -# else - -/* Macro to obtain ASN1_ADB pointer from a type (only used internally) */ -# define ASN1_ADB_ptr(iptr) ((const ASN1_ADB *)(iptr())) - -/* Macros for start and end of ASN1_ITEM definition */ - -# define ASN1_ITEM_start(itname) \ - const ASN1_ITEM * itname##_it(void) \ - { \ - static const ASN1_ITEM local_it = { - -# define static_ASN1_ITEM_start(itname) \ - static ASN1_ITEM_start(itname) - -# define ASN1_ITEM_end(itname) \ - }; \ - return &local_it; \ - } - -# endif - -/* Macros to aid ASN1 template writing */ - -# define ASN1_ITEM_TEMPLATE(tname) \ - static const ASN1_TEMPLATE tname##_item_tt - -# define ASN1_ITEM_TEMPLATE_END(tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_PRIMITIVE,\ - -1,\ - &tname##_item_tt,\ - 0,\ - NULL,\ - 0,\ - #tname \ - ASN1_ITEM_end(tname) -# define static_ASN1_ITEM_TEMPLATE_END(tname) \ - ;\ - static_ASN1_ITEM_start(tname) \ - ASN1_ITYPE_PRIMITIVE,\ - -1,\ - &tname##_item_tt,\ - 0,\ - NULL,\ - 0,\ - #tname \ - ASN1_ITEM_end(tname) - -/* This is a ASN1 type which just embeds a template */ - -/*- - * This pair helps declare a SEQUENCE. We can do: - * - * ASN1_SEQUENCE(stname) = { - * ... SEQUENCE components ... - * } ASN1_SEQUENCE_END(stname) - * - * This will produce an ASN1_ITEM called stname_it - * for a structure called stname. - * - * If you want the same structure but a different - * name then use: - * - * ASN1_SEQUENCE(itname) = { - * ... SEQUENCE components ... - * } ASN1_SEQUENCE_END_name(stname, itname) - * - * This will create an item called itname_it using - * a structure called stname. - */ - -# define ASN1_SEQUENCE(tname) \ - static const ASN1_TEMPLATE tname##_seq_tt[] - -# define ASN1_SEQUENCE_END(stname) ASN1_SEQUENCE_END_name(stname, stname) - -# define static_ASN1_SEQUENCE_END(stname) static_ASN1_SEQUENCE_END_name(stname, stname) - -# define ASN1_SEQUENCE_END_name(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -# define static_ASN1_SEQUENCE_END_name(stname, tname) \ - ;\ - static_ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -# define ASN1_NDEF_SEQUENCE(tname) \ - ASN1_SEQUENCE(tname) - -# define ASN1_NDEF_SEQUENCE_cb(tname, cb) \ - ASN1_SEQUENCE_cb(tname, cb) - -# define ASN1_SEQUENCE_cb(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ - ASN1_SEQUENCE(tname) - -# define ASN1_BROKEN_SEQUENCE(tname) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_BROKEN, 0, 0, 0, 0}; \ - ASN1_SEQUENCE(tname) - -# define ASN1_SEQUENCE_ref(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_REFCOUNT, offsetof(tname, references), offsetof(tname, lock), cb, 0}; \ - ASN1_SEQUENCE(tname) - -# define ASN1_SEQUENCE_enc(tname, enc, cb) \ - static const ASN1_AUX tname##_aux = {NULL, ASN1_AFLG_ENCODING, 0, 0, cb, offsetof(tname, enc)}; \ - ASN1_SEQUENCE(tname) - -# define ASN1_NDEF_SEQUENCE_END(tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_NDEF_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(tname),\ - #tname \ - ASN1_ITEM_end(tname) -# define static_ASN1_NDEF_SEQUENCE_END(tname) \ - ;\ - static_ASN1_ITEM_start(tname) \ - ASN1_ITYPE_NDEF_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(tname),\ - #tname \ - ASN1_ITEM_end(tname) - -# define ASN1_BROKEN_SEQUENCE_END(stname) ASN1_SEQUENCE_END_ref(stname, stname) -# define static_ASN1_BROKEN_SEQUENCE_END(stname) \ - static_ASN1_SEQUENCE_END_ref(stname, stname) - -# define ASN1_SEQUENCE_END_enc(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) - -# define ASN1_SEQUENCE_END_cb(stname, tname) ASN1_SEQUENCE_END_ref(stname, tname) -# define static_ASN1_SEQUENCE_END_cb(stname, tname) static_ASN1_SEQUENCE_END_ref(stname, tname) - -# define ASN1_SEQUENCE_END_ref(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) -# define static_ASN1_SEQUENCE_END_ref(stname, tname) \ - ;\ - static_ASN1_ITEM_start(tname) \ - ASN1_ITYPE_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -# define ASN1_NDEF_SEQUENCE_END_cb(stname, tname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_NDEF_SEQUENCE,\ - V_ASN1_SEQUENCE,\ - tname##_seq_tt,\ - sizeof(tname##_seq_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -/*- - * This pair helps declare a CHOICE type. We can do: - * - * ASN1_CHOICE(chname) = { - * ... CHOICE options ... - * ASN1_CHOICE_END(chname) - * - * This will produce an ASN1_ITEM called chname_it - * for a structure called chname. The structure - * definition must look like this: - * typedef struct { - * int type; - * union { - * ASN1_SOMETHING *opt1; - * ASN1_SOMEOTHER *opt2; - * } value; - * } chname; - * - * the name of the selector must be 'type'. - * to use an alternative selector name use the - * ASN1_CHOICE_END_selector() version. - */ - -# define ASN1_CHOICE(tname) \ - static const ASN1_TEMPLATE tname##_ch_tt[] - -# define ASN1_CHOICE_cb(tname, cb) \ - static const ASN1_AUX tname##_aux = {NULL, 0, 0, 0, cb, 0}; \ - ASN1_CHOICE(tname) - -# define ASN1_CHOICE_END(stname) ASN1_CHOICE_END_name(stname, stname) - -# define static_ASN1_CHOICE_END(stname) static_ASN1_CHOICE_END_name(stname, stname) - -# define ASN1_CHOICE_END_name(stname, tname) ASN1_CHOICE_END_selector(stname, tname, type) - -# define static_ASN1_CHOICE_END_name(stname, tname) static_ASN1_CHOICE_END_selector(stname, tname, type) - -# define ASN1_CHOICE_END_selector(stname, tname, selname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_CHOICE,\ - offsetof(stname,selname) ,\ - tname##_ch_tt,\ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -# define static_ASN1_CHOICE_END_selector(stname, tname, selname) \ - ;\ - static_ASN1_ITEM_start(tname) \ - ASN1_ITYPE_CHOICE,\ - offsetof(stname,selname) ,\ - tname##_ch_tt,\ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ - NULL,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -# define ASN1_CHOICE_END_cb(stname, tname, selname) \ - ;\ - ASN1_ITEM_start(tname) \ - ASN1_ITYPE_CHOICE,\ - offsetof(stname,selname) ,\ - tname##_ch_tt,\ - sizeof(tname##_ch_tt) / sizeof(ASN1_TEMPLATE),\ - &tname##_aux,\ - sizeof(stname),\ - #stname \ - ASN1_ITEM_end(tname) - -/* This helps with the template wrapper form of ASN1_ITEM */ - -# define ASN1_EX_TEMPLATE_TYPE(flags, tag, name, type) { \ - (flags), (tag), 0,\ - #name, ASN1_ITEM_ref(type) } - -/* These help with SEQUENCE or CHOICE components */ - -/* used to declare other types */ - -# define ASN1_EX_TYPE(flags, tag, stname, field, type) { \ - (flags), (tag), offsetof(stname, field),\ - #field, ASN1_ITEM_ref(type) } - -/* implicit and explicit helper macros */ - -# define ASN1_IMP_EX(stname, field, type, tag, ex) \ - ASN1_EX_TYPE(ASN1_TFLG_IMPLICIT | ex, tag, stname, field, type) - -# define ASN1_EXP_EX(stname, field, type, tag, ex) \ - ASN1_EX_TYPE(ASN1_TFLG_EXPLICIT | ex, tag, stname, field, type) - -/* Any defined by macros: the field used is in the table itself */ - -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION -# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } -# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, (const ASN1_ITEM *)&(tblname##_adb) } -# else -# define ASN1_ADB_OBJECT(tblname) { ASN1_TFLG_ADB_OID, -1, 0, #tblname, tblname##_adb } -# define ASN1_ADB_INTEGER(tblname) { ASN1_TFLG_ADB_INT, -1, 0, #tblname, tblname##_adb } -# endif -/* Plain simple type */ -# define ASN1_SIMPLE(stname, field, type) ASN1_EX_TYPE(0,0, stname, field, type) -/* Embedded simple type */ -# define ASN1_EMBED(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_EMBED,0, stname, field, type) - -/* OPTIONAL simple type */ -# define ASN1_OPT(stname, field, type) ASN1_EX_TYPE(ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* IMPLICIT tagged simple type */ -# define ASN1_IMP(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, 0) - -/* IMPLICIT tagged OPTIONAL simple type */ -# define ASN1_IMP_OPT(stname, field, type, tag) ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) - -/* Same as above but EXPLICIT */ - -# define ASN1_EXP(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, 0) -# define ASN1_EXP_OPT(stname, field, type, tag) ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL) - -/* SEQUENCE OF type */ -# define ASN1_SEQUENCE_OF(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF, 0, stname, field, type) - -/* OPTIONAL SEQUENCE OF */ -# define ASN1_SEQUENCE_OF_OPT(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* Same as above but for SET OF */ - -# define ASN1_SET_OF(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SET_OF, 0, stname, field, type) - -# define ASN1_SET_OF_OPT(stname, field, type) \ - ASN1_EX_TYPE(ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL, 0, stname, field, type) - -/* Finally compound types of SEQUENCE, SET, IMPLICIT, EXPLICIT and OPTIONAL */ - -# define ASN1_IMP_SET_OF(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) - -# define ASN1_EXP_SET_OF(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF) - -# define ASN1_IMP_SET_OF_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) - -# define ASN1_EXP_SET_OF_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SET_OF|ASN1_TFLG_OPTIONAL) - -# define ASN1_IMP_SEQUENCE_OF(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) - -# define ASN1_IMP_SEQUENCE_OF_OPT(stname, field, type, tag) \ - ASN1_IMP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) - -# define ASN1_EXP_SEQUENCE_OF(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF) - -# define ASN1_EXP_SEQUENCE_OF_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_SEQUENCE_OF|ASN1_TFLG_OPTIONAL) - -/* EXPLICIT using indefinite length constructed form */ -# define ASN1_NDEF_EXP(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_NDEF) - -/* EXPLICIT OPTIONAL using indefinite length constructed form */ -# define ASN1_NDEF_EXP_OPT(stname, field, type, tag) \ - ASN1_EXP_EX(stname, field, type, tag, ASN1_TFLG_OPTIONAL|ASN1_TFLG_NDEF) - -/* Macros for the ASN1_ADB structure */ - -# define ASN1_ADB(name) \ - static const ASN1_ADB_TABLE name##_adbtbl[] - -# ifndef OPENSSL_EXPORT_VAR_AS_FUNCTION - -# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ - ;\ - static const ASN1_ADB name##_adb = {\ - flags,\ - offsetof(name, field),\ - adb_cb,\ - name##_adbtbl,\ - sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ - def,\ - none\ - } - -# else - -# define ASN1_ADB_END(name, flags, field, adb_cb, def, none) \ - ;\ - static const ASN1_ITEM *name##_adb(void) \ - { \ - static const ASN1_ADB internal_adb = \ - {\ - flags,\ - offsetof(name, field),\ - adb_cb,\ - name##_adbtbl,\ - sizeof(name##_adbtbl) / sizeof(ASN1_ADB_TABLE),\ - def,\ - none\ - }; \ - return (const ASN1_ITEM *) &internal_adb; \ - } \ - void dummy_function(void) - -# endif - -# define ADB_ENTRY(val, template) {val, template} - -# define ASN1_ADB_TEMPLATE(name) \ - static const ASN1_TEMPLATE name##_tt - -/* - * This is the ASN1 template structure that defines a wrapper round the - * actual type. It determines the actual position of the field in the value - * structure, various flags such as OPTIONAL and the field name. - */ - -struct ASN1_TEMPLATE_st { - unsigned long flags; /* Various flags */ - long tag; /* tag, not used if no tagging */ - unsigned long offset; /* Offset of this field in structure */ - const char *field_name; /* Field name */ - ASN1_ITEM_EXP *item; /* Relevant ASN1_ITEM or ASN1_ADB */ -}; - -/* Macro to extract ASN1_ITEM and ASN1_ADB pointer from ASN1_TEMPLATE */ - -# define ASN1_TEMPLATE_item(t) (t->item_ptr) -# define ASN1_TEMPLATE_adb(t) (t->item_ptr) - -typedef struct ASN1_ADB_TABLE_st ASN1_ADB_TABLE; -typedef struct ASN1_ADB_st ASN1_ADB; - -struct ASN1_ADB_st { - unsigned long flags; /* Various flags */ - unsigned long offset; /* Offset of selector field */ - int (*adb_cb)(long *psel); /* Application callback */ - const ASN1_ADB_TABLE *tbl; /* Table of possible types */ - long tblcount; /* Number of entries in tbl */ - const ASN1_TEMPLATE *default_tt; /* Type to use if no match */ - const ASN1_TEMPLATE *null_tt; /* Type to use if selector is NULL */ -}; - -struct ASN1_ADB_TABLE_st { - long value; /* NID for an object or value for an int */ - const ASN1_TEMPLATE tt; /* item for this value */ -}; - -/* template flags */ - -/* Field is optional */ -# define ASN1_TFLG_OPTIONAL (0x1) - -/* Field is a SET OF */ -# define ASN1_TFLG_SET_OF (0x1 << 1) - -/* Field is a SEQUENCE OF */ -# define ASN1_TFLG_SEQUENCE_OF (0x2 << 1) - -/* - * Special case: this refers to a SET OF that will be sorted into DER order - * when encoded *and* the corresponding STACK will be modified to match the - * new order. - */ -# define ASN1_TFLG_SET_ORDER (0x3 << 1) - -/* Mask for SET OF or SEQUENCE OF */ -# define ASN1_TFLG_SK_MASK (0x3 << 1) - -/* - * These flags mean the tag should be taken from the tag field. If EXPLICIT - * then the underlying type is used for the inner tag. - */ - -/* IMPLICIT tagging */ -# define ASN1_TFLG_IMPTAG (0x1 << 3) - -/* EXPLICIT tagging, inner tag from underlying type */ -# define ASN1_TFLG_EXPTAG (0x2 << 3) - -# define ASN1_TFLG_TAG_MASK (0x3 << 3) - -/* context specific IMPLICIT */ -# define ASN1_TFLG_IMPLICIT ASN1_TFLG_IMPTAG|ASN1_TFLG_CONTEXT - -/* context specific EXPLICIT */ -# define ASN1_TFLG_EXPLICIT ASN1_TFLG_EXPTAG|ASN1_TFLG_CONTEXT - -/* - * If tagging is in force these determine the type of tag to use. Otherwise - * the tag is determined by the underlying type. These values reflect the - * actual octet format. - */ - -/* Universal tag */ -# define ASN1_TFLG_UNIVERSAL (0x0<<6) -/* Application tag */ -# define ASN1_TFLG_APPLICATION (0x1<<6) -/* Context specific tag */ -# define ASN1_TFLG_CONTEXT (0x2<<6) -/* Private tag */ -# define ASN1_TFLG_PRIVATE (0x3<<6) - -# define ASN1_TFLG_TAG_CLASS (0x3<<6) - -/* - * These are for ANY DEFINED BY type. In this case the 'item' field points to - * an ASN1_ADB structure which contains a table of values to decode the - * relevant type - */ - -# define ASN1_TFLG_ADB_MASK (0x3<<8) - -# define ASN1_TFLG_ADB_OID (0x1<<8) - -# define ASN1_TFLG_ADB_INT (0x1<<9) - -/* - * This flag when present in a SEQUENCE OF, SET OF or EXPLICIT causes - * indefinite length constructed encoding to be used if required. - */ - -# define ASN1_TFLG_NDEF (0x1<<11) - -/* Field is embedded and not a pointer */ -# define ASN1_TFLG_EMBED (0x1 << 12) - -/* This is the actual ASN1 item itself */ - -struct ASN1_ITEM_st { - char itype; /* The item type, primitive, SEQUENCE, CHOICE - * or extern */ - long utype; /* underlying type */ - const ASN1_TEMPLATE *templates; /* If SEQUENCE or CHOICE this contains - * the contents */ - long tcount; /* Number of templates if SEQUENCE or CHOICE */ - const void *funcs; /* functions that handle this type */ - long size; /* Structure size (usually) */ - const char *sname; /* Structure name */ -}; - -/*- - * These are values for the itype field and - * determine how the type is interpreted. - * - * For PRIMITIVE types the underlying type - * determines the behaviour if items is NULL. - * - * Otherwise templates must contain a single - * template and the type is treated in the - * same way as the type specified in the template. - * - * For SEQUENCE types the templates field points - * to the members, the size field is the - * structure size. - * - * For CHOICE types the templates field points - * to each possible member (typically a union) - * and the 'size' field is the offset of the - * selector. - * - * The 'funcs' field is used for application - * specific functions. - * - * The EXTERN type uses a new style d2i/i2d. - * The new style should be used where possible - * because it avoids things like the d2i IMPLICIT - * hack. - * - * MSTRING is a multiple string type, it is used - * for a CHOICE of character strings where the - * actual strings all occupy an ASN1_STRING - * structure. In this case the 'utype' field - * has a special meaning, it is used as a mask - * of acceptable types using the B_ASN1 constants. - * - * NDEF_SEQUENCE is the same as SEQUENCE except - * that it will use indefinite length constructed - * encoding if requested. - * - */ - -# define ASN1_ITYPE_PRIMITIVE 0x0 - -# define ASN1_ITYPE_SEQUENCE 0x1 - -# define ASN1_ITYPE_CHOICE 0x2 - -# define ASN1_ITYPE_EXTERN 0x4 - -# define ASN1_ITYPE_MSTRING 0x5 - -# define ASN1_ITYPE_NDEF_SEQUENCE 0x6 - -/* - * Cache for ASN1 tag and length, so we don't keep re-reading it for things - * like CHOICE - */ - -struct ASN1_TLC_st { - char valid; /* Values below are valid */ - int ret; /* return value */ - long plen; /* length */ - int ptag; /* class value */ - int pclass; /* class value */ - int hdrlen; /* header length */ -}; - -/* Typedefs for ASN1 function pointers */ -typedef int ASN1_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, - const ASN1_ITEM *it, int tag, int aclass, char opt, - ASN1_TLC *ctx); - -typedef int ASN1_ex_i2d(ASN1_VALUE **pval, unsigned char **out, - const ASN1_ITEM *it, int tag, int aclass); -typedef int ASN1_ex_new_func(ASN1_VALUE **pval, const ASN1_ITEM *it); -typedef void ASN1_ex_free_func(ASN1_VALUE **pval, const ASN1_ITEM *it); - -typedef int ASN1_ex_print_func(BIO *out, ASN1_VALUE **pval, - int indent, const char *fname, - const ASN1_PCTX *pctx); - -typedef int ASN1_primitive_i2c(ASN1_VALUE **pval, unsigned char *cont, - int *putype, const ASN1_ITEM *it); -typedef int ASN1_primitive_c2i(ASN1_VALUE **pval, const unsigned char *cont, - int len, int utype, char *free_cont, - const ASN1_ITEM *it); -typedef int ASN1_primitive_print(BIO *out, ASN1_VALUE **pval, - const ASN1_ITEM *it, int indent, - const ASN1_PCTX *pctx); - -typedef struct ASN1_EXTERN_FUNCS_st { - void *app_data; - ASN1_ex_new_func *asn1_ex_new; - ASN1_ex_free_func *asn1_ex_free; - ASN1_ex_free_func *asn1_ex_clear; - ASN1_ex_d2i *asn1_ex_d2i; - ASN1_ex_i2d *asn1_ex_i2d; - ASN1_ex_print_func *asn1_ex_print; -} ASN1_EXTERN_FUNCS; - -typedef struct ASN1_PRIMITIVE_FUNCS_st { - void *app_data; - unsigned long flags; - ASN1_ex_new_func *prim_new; - ASN1_ex_free_func *prim_free; - ASN1_ex_free_func *prim_clear; - ASN1_primitive_c2i *prim_c2i; - ASN1_primitive_i2c *prim_i2c; - ASN1_primitive_print *prim_print; -} ASN1_PRIMITIVE_FUNCS; - -/* - * This is the ASN1_AUX structure: it handles various miscellaneous - * requirements. For example the use of reference counts and an informational - * callback. The "informational callback" is called at various points during - * the ASN1 encoding and decoding. It can be used to provide minor - * customisation of the structures used. This is most useful where the - * supplied routines *almost* do the right thing but need some extra help at - * a few points. If the callback returns zero then it is assumed a fatal - * error has occurred and the main operation should be abandoned. If major - * changes in the default behaviour are required then an external type is - * more appropriate. - */ - -typedef int ASN1_aux_cb(int operation, ASN1_VALUE **in, const ASN1_ITEM *it, - void *exarg); - -typedef struct ASN1_AUX_st { - void *app_data; - int flags; - int ref_offset; /* Offset of reference value */ - int ref_lock; /* Lock type to use */ - ASN1_aux_cb *asn1_cb; - int enc_offset; /* Offset of ASN1_ENCODING structure */ -} ASN1_AUX; - -/* For print related callbacks exarg points to this structure */ -typedef struct ASN1_PRINT_ARG_st { - BIO *out; - int indent; - const ASN1_PCTX *pctx; -} ASN1_PRINT_ARG; - -/* For streaming related callbacks exarg points to this structure */ -typedef struct ASN1_STREAM_ARG_st { - /* BIO to stream through */ - BIO *out; - /* BIO with filters appended */ - BIO *ndef_bio; - /* Streaming I/O boundary */ - unsigned char **boundary; -} ASN1_STREAM_ARG; - -/* Flags in ASN1_AUX */ - -/* Use a reference count */ -# define ASN1_AFLG_REFCOUNT 1 -/* Save the encoding of structure (useful for signatures) */ -# define ASN1_AFLG_ENCODING 2 -/* The Sequence length is invalid */ -# define ASN1_AFLG_BROKEN 4 - -/* operation values for asn1_cb */ - -# define ASN1_OP_NEW_PRE 0 -# define ASN1_OP_NEW_POST 1 -# define ASN1_OP_FREE_PRE 2 -# define ASN1_OP_FREE_POST 3 -# define ASN1_OP_D2I_PRE 4 -# define ASN1_OP_D2I_POST 5 -# define ASN1_OP_I2D_PRE 6 -# define ASN1_OP_I2D_POST 7 -# define ASN1_OP_PRINT_PRE 8 -# define ASN1_OP_PRINT_POST 9 -# define ASN1_OP_STREAM_PRE 10 -# define ASN1_OP_STREAM_POST 11 -# define ASN1_OP_DETACHED_PRE 12 -# define ASN1_OP_DETACHED_POST 13 - -/* Macro to implement a primitive type */ -# define IMPLEMENT_ASN1_TYPE(stname) IMPLEMENT_ASN1_TYPE_ex(stname, stname, 0) -# define IMPLEMENT_ASN1_TYPE_ex(itname, vname, ex) \ - ASN1_ITEM_start(itname) \ - ASN1_ITYPE_PRIMITIVE, V_##vname, NULL, 0, NULL, ex, #itname \ - ASN1_ITEM_end(itname) - -/* Macro to implement a multi string type */ -# define IMPLEMENT_ASN1_MSTRING(itname, mask) \ - ASN1_ITEM_start(itname) \ - ASN1_ITYPE_MSTRING, mask, NULL, 0, NULL, sizeof(ASN1_STRING), #itname \ - ASN1_ITEM_end(itname) - -# define IMPLEMENT_EXTERN_ASN1(sname, tag, fptrs) \ - ASN1_ITEM_start(sname) \ - ASN1_ITYPE_EXTERN, \ - tag, \ - NULL, \ - 0, \ - &fptrs, \ - 0, \ - #sname \ - ASN1_ITEM_end(sname) - -/* Macro to implement standard functions in terms of ASN1_ITEM structures */ - -# define IMPLEMENT_ASN1_FUNCTIONS(stname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, stname, stname) - -# define IMPLEMENT_ASN1_FUNCTIONS_name(stname, itname) IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, itname) - -# define IMPLEMENT_ASN1_FUNCTIONS_ENCODE_name(stname, itname) \ - IMPLEMENT_ASN1_FUNCTIONS_ENCODE_fname(stname, itname, itname) - -# define IMPLEMENT_STATIC_ASN1_ALLOC_FUNCTIONS(stname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(static, stname, stname, stname) - -# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS(stname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, stname, stname) - -# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_pfname(pre, stname, itname, fname) \ - pre stname *fname##_new(void) \ - { \ - return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ - } \ - pre void fname##_free(stname *a) \ - { \ - ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ - } - -# define IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) \ - stname *fname##_new(void) \ - { \ - return (stname *)ASN1_item_new(ASN1_ITEM_rptr(itname)); \ - } \ - void fname##_free(stname *a) \ - { \ - ASN1_item_free((ASN1_VALUE *)a, ASN1_ITEM_rptr(itname)); \ - } - -# define IMPLEMENT_ASN1_FUNCTIONS_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) - -# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_fname(stname, itname, fname) \ - stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ - } \ - int i2d_##fname(stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ - } - -# define IMPLEMENT_ASN1_NDEF_FUNCTION(stname) \ - int i2d_##stname##_NDEF(stname *a, unsigned char **out) \ - { \ - return ASN1_item_ndef_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(stname));\ - } - -# define IMPLEMENT_STATIC_ASN1_ENCODE_FUNCTIONS(stname) \ - static stname *d2i_##stname(stname **a, \ - const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, \ - ASN1_ITEM_rptr(stname)); \ - } \ - static int i2d_##stname(stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((ASN1_VALUE *)a, out, \ - ASN1_ITEM_rptr(stname)); \ - } - -/* - * This includes evil casts to remove const: they will go away when full ASN1 - * constification is done. - */ -# define IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ - stname *d2i_##fname(stname **a, const unsigned char **in, long len) \ - { \ - return (stname *)ASN1_item_d2i((ASN1_VALUE **)a, in, len, ASN1_ITEM_rptr(itname));\ - } \ - int i2d_##fname(const stname *a, unsigned char **out) \ - { \ - return ASN1_item_i2d((ASN1_VALUE *)a, out, ASN1_ITEM_rptr(itname));\ - } - -# define IMPLEMENT_ASN1_DUP_FUNCTION(stname) \ - stname * stname##_dup(stname *x) \ - { \ - return ASN1_item_dup(ASN1_ITEM_rptr(stname), x); \ - } - -# define IMPLEMENT_ASN1_PRINT_FUNCTION(stname) \ - IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, stname, stname) - -# define IMPLEMENT_ASN1_PRINT_FUNCTION_fname(stname, itname, fname) \ - int fname##_print_ctx(BIO *out, stname *x, int indent, \ - const ASN1_PCTX *pctx) \ - { \ - return ASN1_item_print(out, (ASN1_VALUE *)x, indent, \ - ASN1_ITEM_rptr(itname), pctx); \ - } - -# define IMPLEMENT_ASN1_FUNCTIONS_const(name) \ - IMPLEMENT_ASN1_FUNCTIONS_const_fname(name, name, name) - -# define IMPLEMENT_ASN1_FUNCTIONS_const_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ENCODE_FUNCTIONS_const_fname(stname, itname, fname) \ - IMPLEMENT_ASN1_ALLOC_FUNCTIONS_fname(stname, itname, fname) - -/* external definitions for primitive types */ - -DECLARE_ASN1_ITEM(ASN1_BOOLEAN) -DECLARE_ASN1_ITEM(ASN1_TBOOLEAN) -DECLARE_ASN1_ITEM(ASN1_FBOOLEAN) -DECLARE_ASN1_ITEM(ASN1_SEQUENCE) -DECLARE_ASN1_ITEM(CBIGNUM) -DECLARE_ASN1_ITEM(BIGNUM) -DECLARE_ASN1_ITEM(LONG) -DECLARE_ASN1_ITEM(ZLONG) - -DEFINE_STACK_OF(ASN1_VALUE) - -/* Functions used internally by the ASN1 code */ - -int ASN1_item_ex_new(ASN1_VALUE **pval, const ASN1_ITEM *it); -void ASN1_item_ex_free(ASN1_VALUE **pval, const ASN1_ITEM *it); - -int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len, - const ASN1_ITEM *it, int tag, int aclass, char opt, - ASN1_TLC *ctx); - -int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out, - const ASN1_ITEM *it, int tag, int aclass); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/android/armeabi/include/openssl/async.h b/android/armeabi/include/openssl/async.h deleted file mode 100644 index 5b2e496d..00000000 --- a/android/armeabi/include/openssl/async.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <stdlib.h> - -#ifndef HEADER_ASYNC_H -# define HEADER_ASYNC_H - -#if defined(_WIN32) -# if defined(BASETYPES) || defined(_WINDEF_H) -/* application has to include <windows.h> to use this */ -#define OSSL_ASYNC_FD HANDLE -#define OSSL_BAD_ASYNC_FD INVALID_HANDLE_VALUE -# endif -#else -#define OSSL_ASYNC_FD int -#define OSSL_BAD_ASYNC_FD -1 -#endif - - -# ifdef __cplusplus -extern "C" { -# endif - -typedef struct async_job_st ASYNC_JOB; -typedef struct async_wait_ctx_st ASYNC_WAIT_CTX; - -#define ASYNC_ERR 0 -#define ASYNC_NO_JOBS 1 -#define ASYNC_PAUSE 2 -#define ASYNC_FINISH 3 - -int ASYNC_init_thread(size_t max_size, size_t init_size); -void ASYNC_cleanup_thread(void); - -#ifdef OSSL_ASYNC_FD -ASYNC_WAIT_CTX *ASYNC_WAIT_CTX_new(void); -void ASYNC_WAIT_CTX_free(ASYNC_WAIT_CTX *ctx); -int ASYNC_WAIT_CTX_set_wait_fd(ASYNC_WAIT_CTX *ctx, const void *key, - OSSL_ASYNC_FD fd, - void *custom_data, - void (*cleanup)(ASYNC_WAIT_CTX *, const void *, - OSSL_ASYNC_FD, void *)); -int ASYNC_WAIT_CTX_get_fd(ASYNC_WAIT_CTX *ctx, const void *key, - OSSL_ASYNC_FD *fd, void **custom_data); -int ASYNC_WAIT_CTX_get_all_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *fd, - size_t *numfds); -int ASYNC_WAIT_CTX_get_changed_fds(ASYNC_WAIT_CTX *ctx, OSSL_ASYNC_FD *addfd, - size_t *numaddfds, OSSL_ASYNC_FD *delfd, - size_t *numdelfds); -int ASYNC_WAIT_CTX_clear_fd(ASYNC_WAIT_CTX *ctx, const void *key); -#endif - -int ASYNC_is_capable(void); - -int ASYNC_start_job(ASYNC_JOB **job, ASYNC_WAIT_CTX *ctx, int *ret, - int (*func)(void *), void *args, size_t size); -int ASYNC_pause_job(void); - -ASYNC_JOB *ASYNC_get_current_job(void); -ASYNC_WAIT_CTX *ASYNC_get_wait_ctx(ASYNC_JOB *job); -void ASYNC_block_pause(void); -void ASYNC_unblock_pause(void); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_ASYNC_strings(void); - -/* Error codes for the ASYNC functions. */ - -/* Function codes. */ -# define ASYNC_F_ASYNC_CTX_NEW 100 -# define ASYNC_F_ASYNC_INIT_THREAD 101 -# define ASYNC_F_ASYNC_JOB_NEW 102 -# define ASYNC_F_ASYNC_PAUSE_JOB 103 -# define ASYNC_F_ASYNC_START_FUNC 104 -# define ASYNC_F_ASYNC_START_JOB 105 - -/* Reason codes. */ -# define ASYNC_R_FAILED_TO_SET_POOL 101 -# define ASYNC_R_FAILED_TO_SWAP_CONTEXT 102 -# define ASYNC_R_INIT_FAILED 105 -# define ASYNC_R_INVALID_POOL_SIZE 103 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/bio.h b/android/armeabi/include/openssl/bio.h deleted file mode 100644 index 9bc941b2..00000000 --- a/android/armeabi/include/openssl/bio.h +++ /dev/null @@ -1,854 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_BIO_H -# define HEADER_BIO_H - -# include <openssl/e_os2.h> - -# ifndef OPENSSL_NO_STDIO -# include <stdio.h> -# endif -# include <stdarg.h> - -# include <openssl/crypto.h> - -# ifndef OPENSSL_NO_SCTP -# ifndef OPENSSL_SYS_VMS -# include <stdint.h> -# else -# include <inttypes.h> -# endif -# endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* There are the classes of BIOs */ -# define BIO_TYPE_DESCRIPTOR 0x0100 /* socket, fd, connect or accept */ -# define BIO_TYPE_FILTER 0x0200 -# define BIO_TYPE_SOURCE_SINK 0x0400 - -/* These are the 'types' of BIOs */ -# define BIO_TYPE_NONE 0 -# define BIO_TYPE_MEM ( 1|BIO_TYPE_SOURCE_SINK) -# define BIO_TYPE_FILE ( 2|BIO_TYPE_SOURCE_SINK) - -# define BIO_TYPE_FD ( 4|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) -# define BIO_TYPE_SOCKET ( 5|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) -# define BIO_TYPE_NULL ( 6|BIO_TYPE_SOURCE_SINK) -# define BIO_TYPE_SSL ( 7|BIO_TYPE_FILTER) -# define BIO_TYPE_MD ( 8|BIO_TYPE_FILTER) -# define BIO_TYPE_BUFFER ( 9|BIO_TYPE_FILTER) -# define BIO_TYPE_CIPHER (10|BIO_TYPE_FILTER) -# define BIO_TYPE_BASE64 (11|BIO_TYPE_FILTER) -# define BIO_TYPE_CONNECT (12|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) -# define BIO_TYPE_ACCEPT (13|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) - -# define BIO_TYPE_NBIO_TEST (16|BIO_TYPE_FILTER)/* server proxy BIO */ -# define BIO_TYPE_NULL_FILTER (17|BIO_TYPE_FILTER) -# define BIO_TYPE_BIO (19|BIO_TYPE_SOURCE_SINK)/* half a BIO pair */ -# define BIO_TYPE_LINEBUFFER (20|BIO_TYPE_FILTER) -# define BIO_TYPE_DGRAM (21|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) -# define BIO_TYPE_ASN1 (22|BIO_TYPE_FILTER) -# define BIO_TYPE_COMP (23|BIO_TYPE_FILTER) -# ifndef OPENSSL_NO_SCTP -# define BIO_TYPE_DGRAM_SCTP (24|BIO_TYPE_SOURCE_SINK|BIO_TYPE_DESCRIPTOR) -# endif - -#define BIO_TYPE_START 128 - -/* - * BIO_FILENAME_READ|BIO_CLOSE to open or close on free. - * BIO_set_fp(in,stdin,BIO_NOCLOSE); - */ -# define BIO_NOCLOSE 0x00 -# define BIO_CLOSE 0x01 - -/* - * These are used in the following macros and are passed to BIO_ctrl() - */ -# define BIO_CTRL_RESET 1/* opt - rewind/zero etc */ -# define BIO_CTRL_EOF 2/* opt - are we at the eof */ -# define BIO_CTRL_INFO 3/* opt - extra tit-bits */ -# define BIO_CTRL_SET 4/* man - set the 'IO' type */ -# define BIO_CTRL_GET 5/* man - get the 'IO' type */ -# define BIO_CTRL_PUSH 6/* opt - internal, used to signify change */ -# define BIO_CTRL_POP 7/* opt - internal, used to signify change */ -# define BIO_CTRL_GET_CLOSE 8/* man - set the 'close' on free */ -# define BIO_CTRL_SET_CLOSE 9/* man - set the 'close' on free */ -# define BIO_CTRL_PENDING 10/* opt - is their more data buffered */ -# define BIO_CTRL_FLUSH 11/* opt - 'flush' buffered output */ -# define BIO_CTRL_DUP 12/* man - extra stuff for 'duped' BIO */ -# define BIO_CTRL_WPENDING 13/* opt - number of bytes still to write */ -# define BIO_CTRL_SET_CALLBACK 14/* opt - set callback function */ -# define BIO_CTRL_GET_CALLBACK 15/* opt - set callback function */ - -# define BIO_CTRL_SET_FILENAME 30/* BIO_s_file special */ - -/* dgram BIO stuff */ -# define BIO_CTRL_DGRAM_CONNECT 31/* BIO dgram special */ -# define BIO_CTRL_DGRAM_SET_CONNECTED 32/* allow for an externally connected - * socket to be passed in */ -# define BIO_CTRL_DGRAM_SET_RECV_TIMEOUT 33/* setsockopt, essentially */ -# define BIO_CTRL_DGRAM_GET_RECV_TIMEOUT 34/* getsockopt, essentially */ -# define BIO_CTRL_DGRAM_SET_SEND_TIMEOUT 35/* setsockopt, essentially */ -# define BIO_CTRL_DGRAM_GET_SEND_TIMEOUT 36/* getsockopt, essentially */ - -# define BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP 37/* flag whether the last */ -# define BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP 38/* I/O operation tiemd out */ - -/* #ifdef IP_MTU_DISCOVER */ -# define BIO_CTRL_DGRAM_MTU_DISCOVER 39/* set DF bit on egress packets */ -/* #endif */ - -# define BIO_CTRL_DGRAM_QUERY_MTU 40/* as kernel for current MTU */ -# define BIO_CTRL_DGRAM_GET_FALLBACK_MTU 47 -# define BIO_CTRL_DGRAM_GET_MTU 41/* get cached value for MTU */ -# define BIO_CTRL_DGRAM_SET_MTU 42/* set cached value for MTU. - * want to use this if asking - * the kernel fails */ - -# define BIO_CTRL_DGRAM_MTU_EXCEEDED 43/* check whether the MTU was - * exceed in the previous write - * operation */ - -# define BIO_CTRL_DGRAM_GET_PEER 46 -# define BIO_CTRL_DGRAM_SET_PEER 44/* Destination for the data */ - -# define BIO_CTRL_DGRAM_SET_NEXT_TIMEOUT 45/* Next DTLS handshake timeout - * to adjust socket timeouts */ -# define BIO_CTRL_DGRAM_SET_DONT_FRAG 48 - -# define BIO_CTRL_DGRAM_GET_MTU_OVERHEAD 49 - -# define BIO_CTRL_DGRAM_SET_PEEK_MODE 50 - -# ifndef OPENSSL_NO_SCTP -/* SCTP stuff */ -# define BIO_CTRL_DGRAM_SCTP_SET_IN_HANDSHAKE 50 -# define BIO_CTRL_DGRAM_SCTP_ADD_AUTH_KEY 51 -# define BIO_CTRL_DGRAM_SCTP_NEXT_AUTH_KEY 52 -# define BIO_CTRL_DGRAM_SCTP_AUTH_CCS_RCVD 53 -# define BIO_CTRL_DGRAM_SCTP_GET_SNDINFO 60 -# define BIO_CTRL_DGRAM_SCTP_SET_SNDINFO 61 -# define BIO_CTRL_DGRAM_SCTP_GET_RCVINFO 62 -# define BIO_CTRL_DGRAM_SCTP_SET_RCVINFO 63 -# define BIO_CTRL_DGRAM_SCTP_GET_PRINFO 64 -# define BIO_CTRL_DGRAM_SCTP_SET_PRINFO 65 -# define BIO_CTRL_DGRAM_SCTP_SAVE_SHUTDOWN 70 -# endif - -/* modifiers */ -# define BIO_FP_READ 0x02 -# define BIO_FP_WRITE 0x04 -# define BIO_FP_APPEND 0x08 -# define BIO_FP_TEXT 0x10 - -# define BIO_FLAGS_READ 0x01 -# define BIO_FLAGS_WRITE 0x02 -# define BIO_FLAGS_IO_SPECIAL 0x04 -# define BIO_FLAGS_RWS (BIO_FLAGS_READ|BIO_FLAGS_WRITE|BIO_FLAGS_IO_SPECIAL) -# define BIO_FLAGS_SHOULD_RETRY 0x08 -# ifndef BIO_FLAGS_UPLINK -/* - * "UPLINK" flag denotes file descriptors provided by application. It - * defaults to 0, as most platforms don't require UPLINK interface. - */ -# define BIO_FLAGS_UPLINK 0 -# endif - -# define BIO_FLAGS_BASE64_NO_NL 0x100 - -/* - * This is used with memory BIOs: - * BIO_FLAGS_MEM_RDONLY means we shouldn't free up or change the data in any way; - * BIO_FLAGS_NONCLEAR_RST means we should't clear data on reset. - */ -# define BIO_FLAGS_MEM_RDONLY 0x200 -# define BIO_FLAGS_NONCLEAR_RST 0x400 - -typedef union bio_addr_st BIO_ADDR; -typedef struct bio_addrinfo_st BIO_ADDRINFO; - -int BIO_get_new_index(void); -void BIO_set_flags(BIO *b, int flags); -int BIO_test_flags(const BIO *b, int flags); -void BIO_clear_flags(BIO *b, int flags); - -# define BIO_get_flags(b) BIO_test_flags(b, ~(0x0)) -# define BIO_set_retry_special(b) \ - BIO_set_flags(b, (BIO_FLAGS_IO_SPECIAL|BIO_FLAGS_SHOULD_RETRY)) -# define BIO_set_retry_read(b) \ - BIO_set_flags(b, (BIO_FLAGS_READ|BIO_FLAGS_SHOULD_RETRY)) -# define BIO_set_retry_write(b) \ - BIO_set_flags(b, (BIO_FLAGS_WRITE|BIO_FLAGS_SHOULD_RETRY)) - -/* These are normally used internally in BIOs */ -# define BIO_clear_retry_flags(b) \ - BIO_clear_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) -# define BIO_get_retry_flags(b) \ - BIO_test_flags(b, (BIO_FLAGS_RWS|BIO_FLAGS_SHOULD_RETRY)) - -/* These should be used by the application to tell why we should retry */ -# define BIO_should_read(a) BIO_test_flags(a, BIO_FLAGS_READ) -# define BIO_should_write(a) BIO_test_flags(a, BIO_FLAGS_WRITE) -# define BIO_should_io_special(a) BIO_test_flags(a, BIO_FLAGS_IO_SPECIAL) -# define BIO_retry_type(a) BIO_test_flags(a, BIO_FLAGS_RWS) -# define BIO_should_retry(a) BIO_test_flags(a, BIO_FLAGS_SHOULD_RETRY) - -/* - * The next three are used in conjunction with the BIO_should_io_special() - * condition. After this returns true, BIO *BIO_get_retry_BIO(BIO *bio, int - * *reason); will walk the BIO stack and return the 'reason' for the special - * and the offending BIO. Given a BIO, BIO_get_retry_reason(bio) will return - * the code. - */ -/* - * Returned from the SSL bio when the certificate retrieval code had an error - */ -# define BIO_RR_SSL_X509_LOOKUP 0x01 -/* Returned from the connect BIO when a connect would have blocked */ -# define BIO_RR_CONNECT 0x02 -/* Returned from the accept BIO when an accept would have blocked */ -# define BIO_RR_ACCEPT 0x03 - -/* These are passed by the BIO callback */ -# define BIO_CB_FREE 0x01 -# define BIO_CB_READ 0x02 -# define BIO_CB_WRITE 0x03 -# define BIO_CB_PUTS 0x04 -# define BIO_CB_GETS 0x05 -# define BIO_CB_CTRL 0x06 - -/* - * The callback is called before and after the underling operation, The - * BIO_CB_RETURN flag indicates if it is after the call - */ -# define BIO_CB_RETURN 0x80 -# define BIO_CB_return(a) ((a)|BIO_CB_RETURN) -# define BIO_cb_pre(a) (!((a)&BIO_CB_RETURN)) -# define BIO_cb_post(a) ((a)&BIO_CB_RETURN) - -typedef long (*BIO_callback_fn)(BIO *b, int oper, const char *argp, int argi, - long argl, long ret); -BIO_callback_fn BIO_get_callback(const BIO *b); -void BIO_set_callback(BIO *b, BIO_callback_fn callback); -char *BIO_get_callback_arg(const BIO *b); -void BIO_set_callback_arg(BIO *b, char *arg); - -typedef struct bio_method_st BIO_METHOD; - -const char *BIO_method_name(const BIO *b); -int BIO_method_type(const BIO *b); - -typedef void bio_info_cb(BIO *, int, const char *, int, long, long); - -DEFINE_STACK_OF(BIO) - -/* Prefix and suffix callback in ASN1 BIO */ -typedef int asn1_ps_func (BIO *b, unsigned char **pbuf, int *plen, - void *parg); - -# ifndef OPENSSL_NO_SCTP -/* SCTP parameter structs */ -struct bio_dgram_sctp_sndinfo { - uint16_t snd_sid; - uint16_t snd_flags; - uint32_t snd_ppid; - uint32_t snd_context; -}; - -struct bio_dgram_sctp_rcvinfo { - uint16_t rcv_sid; - uint16_t rcv_ssn; - uint16_t rcv_flags; - uint32_t rcv_ppid; - uint32_t rcv_tsn; - uint32_t rcv_cumtsn; - uint32_t rcv_context; -}; - -struct bio_dgram_sctp_prinfo { - uint16_t pr_policy; - uint32_t pr_value; -}; -# endif - -/* - * #define BIO_CONN_get_param_hostname BIO_ctrl - */ - -# define BIO_C_SET_CONNECT 100 -# define BIO_C_DO_STATE_MACHINE 101 -# define BIO_C_SET_NBIO 102 -/* # define BIO_C_SET_PROXY_PARAM 103 */ -# define BIO_C_SET_FD 104 -# define BIO_C_GET_FD 105 -# define BIO_C_SET_FILE_PTR 106 -# define BIO_C_GET_FILE_PTR 107 -# define BIO_C_SET_FILENAME 108 -# define BIO_C_SET_SSL 109 -# define BIO_C_GET_SSL 110 -# define BIO_C_SET_MD 111 -# define BIO_C_GET_MD 112 -# define BIO_C_GET_CIPHER_STATUS 113 -# define BIO_C_SET_BUF_MEM 114 -# define BIO_C_GET_BUF_MEM_PTR 115 -# define BIO_C_GET_BUFF_NUM_LINES 116 -# define BIO_C_SET_BUFF_SIZE 117 -# define BIO_C_SET_ACCEPT 118 -# define BIO_C_SSL_MODE 119 -# define BIO_C_GET_MD_CTX 120 -/* # define BIO_C_GET_PROXY_PARAM 121 */ -# define BIO_C_SET_BUFF_READ_DATA 122/* data to read first */ -# define BIO_C_GET_CONNECT 123 -# define BIO_C_GET_ACCEPT 124 -# define BIO_C_SET_SSL_RENEGOTIATE_BYTES 125 -# define BIO_C_GET_SSL_NUM_RENEGOTIATES 126 -# define BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT 127 -# define BIO_C_FILE_SEEK 128 -# define BIO_C_GET_CIPHER_CTX 129 -# define BIO_C_SET_BUF_MEM_EOF_RETURN 130/* return end of input - * value */ -# define BIO_C_SET_BIND_MODE 131 -# define BIO_C_GET_BIND_MODE 132 -# define BIO_C_FILE_TELL 133 -# define BIO_C_GET_SOCKS 134 -# define BIO_C_SET_SOCKS 135 - -# define BIO_C_SET_WRITE_BUF_SIZE 136/* for BIO_s_bio */ -# define BIO_C_GET_WRITE_BUF_SIZE 137 -# define BIO_C_MAKE_BIO_PAIR 138 -# define BIO_C_DESTROY_BIO_PAIR 139 -# define BIO_C_GET_WRITE_GUARANTEE 140 -# define BIO_C_GET_READ_REQUEST 141 -# define BIO_C_SHUTDOWN_WR 142 -# define BIO_C_NREAD0 143 -# define BIO_C_NREAD 144 -# define BIO_C_NWRITE0 145 -# define BIO_C_NWRITE 146 -# define BIO_C_RESET_READ_REQUEST 147 -# define BIO_C_SET_MD_CTX 148 - -# define BIO_C_SET_PREFIX 149 -# define BIO_C_GET_PREFIX 150 -# define BIO_C_SET_SUFFIX 151 -# define BIO_C_GET_SUFFIX 152 - -# define BIO_C_SET_EX_ARG 153 -# define BIO_C_GET_EX_ARG 154 - -# define BIO_C_SET_CONNECT_MODE 155 - -# define BIO_set_app_data(s,arg) BIO_set_ex_data(s,0,arg) -# define BIO_get_app_data(s) BIO_get_ex_data(s,0) - -# define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) - -# ifndef OPENSSL_NO_SOCK -/* IP families we support, for BIO_s_connect() and BIO_s_accept() */ -/* Note: the underlying operating system may not support some of them */ -# define BIO_FAMILY_IPV4 4 -# define BIO_FAMILY_IPV6 6 -# define BIO_FAMILY_IPANY 256 - -/* BIO_s_connect() */ -# define BIO_set_conn_hostname(b,name) BIO_ctrl(b,BIO_C_SET_CONNECT,0,(char *)name) -# define BIO_set_conn_port(b,port) BIO_ctrl(b,BIO_C_SET_CONNECT,1,(char *)port) -# define BIO_set_conn_address(b,addr) BIO_ctrl(b,BIO_C_SET_CONNECT,2,(char *)addr) -# define BIO_set_conn_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_CONNECT,3,f) -# define BIO_get_conn_hostname(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,0)) -# define BIO_get_conn_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,1)) -# define BIO_get_conn_address(b) ((const BIO_ADDR *)BIO_ptr_ctrl(b,BIO_C_GET_CONNECT,2)) -# define BIO_get_conn_ip_family(b) BIO_ctrl(b,BIO_C_GET_CONNECT,3,NULL) -# define BIO_set_conn_mode(b,n) BIO_ctrl(b,BIO_C_SET_CONNECT_MODE,(n),NULL) - -/* BIO_s_accept() */ -# define BIO_set_accept_name(b,name) BIO_ctrl(b,BIO_C_SET_ACCEPT,0,(char *)name) -# define BIO_set_accept_port(b,port) BIO_ctrl(b,BIO_C_SET_ACCEPT,1,(char *)port) -# define BIO_get_accept_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,0)) -# define BIO_get_accept_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,1)) -# define BIO_get_peer_name(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,2)) -# define BIO_get_peer_port(b) ((const char *)BIO_ptr_ctrl(b,BIO_C_GET_ACCEPT,3)) -/* #define BIO_set_nbio(b,n) BIO_ctrl(b,BIO_C_SET_NBIO,(n),NULL) */ -# define BIO_set_nbio_accept(b,n) BIO_ctrl(b,BIO_C_SET_ACCEPT,2,(n)?(void *)"a":NULL) -# define BIO_set_accept_bios(b,bio) BIO_ctrl(b,BIO_C_SET_ACCEPT,3,(char *)bio) -# define BIO_set_accept_ip_family(b,f) BIO_int_ctrl(b,BIO_C_SET_ACCEPT,4,f) -# define BIO_get_accept_ip_family(b) BIO_ctrl(b,BIO_C_GET_ACCEPT,4,NULL) - -/* Aliases kept for backward compatibility */ -# define BIO_BIND_NORMAL 0 -# define BIO_BIND_REUSEADDR BIO_SOCK_REUSEADDR -# define BIO_BIND_REUSEADDR_IF_UNUSED BIO_SOCK_REUSEADDR -# define BIO_set_bind_mode(b,mode) BIO_ctrl(b,BIO_C_SET_BIND_MODE,mode,NULL) -# define BIO_get_bind_mode(b) BIO_ctrl(b,BIO_C_GET_BIND_MODE,0,NULL) - -/* BIO_s_accept() and BIO_s_connect() */ -# define BIO_do_connect(b) BIO_do_handshake(b) -# define BIO_do_accept(b) BIO_do_handshake(b) -# endif /* OPENSSL_NO_SOCK */ - -# define BIO_do_handshake(b) BIO_ctrl(b,BIO_C_DO_STATE_MACHINE,0,NULL) - -/* BIO_s_datagram(), BIO_s_fd(), BIO_s_socket(), BIO_s_accept() and BIO_s_connect() */ -# define BIO_set_fd(b,fd,c) BIO_int_ctrl(b,BIO_C_SET_FD,c,fd) -# define BIO_get_fd(b,c) BIO_ctrl(b,BIO_C_GET_FD,0,(char *)c) - -/* BIO_s_file() */ -# define BIO_set_fp(b,fp,c) BIO_ctrl(b,BIO_C_SET_FILE_PTR,c,(char *)fp) -# define BIO_get_fp(b,fpp) BIO_ctrl(b,BIO_C_GET_FILE_PTR,0,(char *)fpp) - -/* BIO_s_fd() and BIO_s_file() */ -# define BIO_seek(b,ofs) (int)BIO_ctrl(b,BIO_C_FILE_SEEK,ofs,NULL) -# define BIO_tell(b) (int)BIO_ctrl(b,BIO_C_FILE_TELL,0,NULL) - -/* - * name is cast to lose const, but might be better to route through a - * function so we can do it safely - */ -# ifdef CONST_STRICT -/* - * If you are wondering why this isn't defined, its because CONST_STRICT is - * purely a compile-time kludge to allow const to be checked. - */ -int BIO_read_filename(BIO *b, const char *name); -# else -# define BIO_read_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_READ,(char *)name) -# endif -# define BIO_write_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_WRITE,name) -# define BIO_append_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_APPEND,name) -# define BIO_rw_filename(b,name) (int)BIO_ctrl(b,BIO_C_SET_FILENAME, \ - BIO_CLOSE|BIO_FP_READ|BIO_FP_WRITE,name) - -/* - * WARNING WARNING, this ups the reference count on the read bio of the SSL - * structure. This is because the ssl read BIO is now pointed to by the - * next_bio field in the bio. So when you free the BIO, make sure you are - * doing a BIO_free_all() to catch the underlying BIO. - */ -# define BIO_set_ssl(b,ssl,c) BIO_ctrl(b,BIO_C_SET_SSL,c,(char *)ssl) -# define BIO_get_ssl(b,sslp) BIO_ctrl(b,BIO_C_GET_SSL,0,(char *)sslp) -# define BIO_set_ssl_mode(b,client) BIO_ctrl(b,BIO_C_SSL_MODE,client,NULL) -# define BIO_set_ssl_renegotiate_bytes(b,num) \ - BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_BYTES,num,NULL) -# define BIO_get_num_renegotiates(b) \ - BIO_ctrl(b,BIO_C_GET_SSL_NUM_RENEGOTIATES,0,NULL) -# define BIO_set_ssl_renegotiate_timeout(b,seconds) \ - BIO_ctrl(b,BIO_C_SET_SSL_RENEGOTIATE_TIMEOUT,seconds,NULL) - -/* defined in evp.h */ -/* #define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,1,(char *)md) */ - -# define BIO_get_mem_data(b,pp) BIO_ctrl(b,BIO_CTRL_INFO,0,(char *)pp) -# define BIO_set_mem_buf(b,bm,c) BIO_ctrl(b,BIO_C_SET_BUF_MEM,c,(char *)bm) -# define BIO_get_mem_ptr(b,pp) BIO_ctrl(b,BIO_C_GET_BUF_MEM_PTR,0,(char *)pp) -# define BIO_set_mem_eof_return(b,v) \ - BIO_ctrl(b,BIO_C_SET_BUF_MEM_EOF_RETURN,v,NULL) - -/* For the BIO_f_buffer() type */ -# define BIO_get_buffer_num_lines(b) BIO_ctrl(b,BIO_C_GET_BUFF_NUM_LINES,0,NULL) -# define BIO_set_buffer_size(b,size) BIO_ctrl(b,BIO_C_SET_BUFF_SIZE,size,NULL) -# define BIO_set_read_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,0) -# define BIO_set_write_buffer_size(b,size) BIO_int_ctrl(b,BIO_C_SET_BUFF_SIZE,size,1) -# define BIO_set_buffer_read_data(b,buf,num) BIO_ctrl(b,BIO_C_SET_BUFF_READ_DATA,num,buf) - -/* Don't use the next one unless you know what you are doing :-) */ -# define BIO_dup_state(b,ret) BIO_ctrl(b,BIO_CTRL_DUP,0,(char *)(ret)) - -# define BIO_reset(b) (int)BIO_ctrl(b,BIO_CTRL_RESET,0,NULL) -# define BIO_eof(b) (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) -# define BIO_set_close(b,c) (int)BIO_ctrl(b,BIO_CTRL_SET_CLOSE,(c),NULL) -# define BIO_get_close(b) (int)BIO_ctrl(b,BIO_CTRL_GET_CLOSE,0,NULL) -# define BIO_pending(b) (int)BIO_ctrl(b,BIO_CTRL_PENDING,0,NULL) -# define BIO_wpending(b) (int)BIO_ctrl(b,BIO_CTRL_WPENDING,0,NULL) -/* ...pending macros have inappropriate return type */ -size_t BIO_ctrl_pending(BIO *b); -size_t BIO_ctrl_wpending(BIO *b); -# define BIO_flush(b) (int)BIO_ctrl(b,BIO_CTRL_FLUSH,0,NULL) -# define BIO_get_info_callback(b,cbp) (int)BIO_ctrl(b,BIO_CTRL_GET_CALLBACK,0, \ - cbp) -# define BIO_set_info_callback(b,cb) (int)BIO_callback_ctrl(b,BIO_CTRL_SET_CALLBACK,cb) - -/* For the BIO_f_buffer() type */ -# define BIO_buffer_get_num_lines(b) BIO_ctrl(b,BIO_CTRL_GET,0,NULL) - -/* For BIO_s_bio() */ -# define BIO_set_write_buf_size(b,size) (int)BIO_ctrl(b,BIO_C_SET_WRITE_BUF_SIZE,size,NULL) -# define BIO_get_write_buf_size(b,size) (size_t)BIO_ctrl(b,BIO_C_GET_WRITE_BUF_SIZE,size,NULL) -# define BIO_make_bio_pair(b1,b2) (int)BIO_ctrl(b1,BIO_C_MAKE_BIO_PAIR,0,b2) -# define BIO_destroy_bio_pair(b) (int)BIO_ctrl(b,BIO_C_DESTROY_BIO_PAIR,0,NULL) -# define BIO_shutdown_wr(b) (int)BIO_ctrl(b, BIO_C_SHUTDOWN_WR, 0, NULL) -/* macros with inappropriate type -- but ...pending macros use int too: */ -# define BIO_get_write_guarantee(b) (int)BIO_ctrl(b,BIO_C_GET_WRITE_GUARANTEE,0,NULL) -# define BIO_get_read_request(b) (int)BIO_ctrl(b,BIO_C_GET_READ_REQUEST,0,NULL) -size_t BIO_ctrl_get_write_guarantee(BIO *b); -size_t BIO_ctrl_get_read_request(BIO *b); -int BIO_ctrl_reset_read_request(BIO *b); - -/* ctrl macros for dgram */ -# define BIO_ctrl_dgram_connect(b,peer) \ - (int)BIO_ctrl(b,BIO_CTRL_DGRAM_CONNECT,0, (char *)peer) -# define BIO_ctrl_set_connected(b,peer) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_CONNECTED, 0, (char *)peer) -# define BIO_dgram_recv_timedout(b) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_RECV_TIMER_EXP, 0, NULL) -# define BIO_dgram_send_timedout(b) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_SEND_TIMER_EXP, 0, NULL) -# define BIO_dgram_get_peer(b,peer) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_GET_PEER, 0, (char *)peer) -# define BIO_dgram_set_peer(b,peer) \ - (int)BIO_ctrl(b, BIO_CTRL_DGRAM_SET_PEER, 0, (char *)peer) -# define BIO_dgram_get_mtu_overhead(b) \ - (unsigned int)BIO_ctrl((b), BIO_CTRL_DGRAM_GET_MTU_OVERHEAD, 0, NULL) - -#define BIO_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_BIO, l, p, newf, dupf, freef) -int BIO_set_ex_data(BIO *bio, int idx, void *data); -void *BIO_get_ex_data(BIO *bio, int idx); -uint64_t BIO_number_read(BIO *bio); -uint64_t BIO_number_written(BIO *bio); - -/* For BIO_f_asn1() */ -int BIO_asn1_set_prefix(BIO *b, asn1_ps_func *prefix, - asn1_ps_func *prefix_free); -int BIO_asn1_get_prefix(BIO *b, asn1_ps_func **pprefix, - asn1_ps_func **pprefix_free); -int BIO_asn1_set_suffix(BIO *b, asn1_ps_func *suffix, - asn1_ps_func *suffix_free); -int BIO_asn1_get_suffix(BIO *b, asn1_ps_func **psuffix, - asn1_ps_func **psuffix_free); - -const BIO_METHOD *BIO_s_file(void); -BIO *BIO_new_file(const char *filename, const char *mode); -# ifndef OPENSSL_NO_STDIO -BIO *BIO_new_fp(FILE *stream, int close_flag); -# endif -BIO *BIO_new(const BIO_METHOD *type); -int BIO_free(BIO *a); -void BIO_set_data(BIO *a, void *ptr); -void *BIO_get_data(BIO *a); -void BIO_set_init(BIO *a, int init); -int BIO_get_init(BIO *a); -void BIO_set_shutdown(BIO *a, int shut); -int BIO_get_shutdown(BIO *a); -void BIO_vfree(BIO *a); -int BIO_up_ref(BIO *a); -int BIO_read(BIO *b, void *data, int len); -int BIO_gets(BIO *bp, char *buf, int size); -int BIO_write(BIO *b, const void *data, int len); -int BIO_puts(BIO *bp, const char *buf); -int BIO_indent(BIO *b, int indent, int max); -long BIO_ctrl(BIO *bp, int cmd, long larg, void *parg); -long BIO_callback_ctrl(BIO *b, int cmd, - void (*fp) (BIO *, int, const char *, int, long, long)); -void *BIO_ptr_ctrl(BIO *bp, int cmd, long larg); -long BIO_int_ctrl(BIO *bp, int cmd, long larg, int iarg); -BIO *BIO_push(BIO *b, BIO *append); -BIO *BIO_pop(BIO *b); -void BIO_free_all(BIO *a); -BIO *BIO_find_type(BIO *b, int bio_type); -BIO *BIO_next(BIO *b); -void BIO_set_next(BIO *b, BIO *next); -BIO *BIO_get_retry_BIO(BIO *bio, int *reason); -int BIO_get_retry_reason(BIO *bio); -void BIO_set_retry_reason(BIO *bio, int reason); -BIO *BIO_dup_chain(BIO *in); - -int BIO_nread0(BIO *bio, char **buf); -int BIO_nread(BIO *bio, char **buf, int num); -int BIO_nwrite0(BIO *bio, char **buf); -int BIO_nwrite(BIO *bio, char **buf, int num); - -long BIO_debug_callback(BIO *bio, int cmd, const char *argp, int argi, - long argl, long ret); - -const BIO_METHOD *BIO_s_mem(void); -const BIO_METHOD *BIO_s_secmem(void); -BIO *BIO_new_mem_buf(const void *buf, int len); -# ifndef OPENSSL_NO_SOCK -const BIO_METHOD *BIO_s_socket(void); -const BIO_METHOD *BIO_s_connect(void); -const BIO_METHOD *BIO_s_accept(void); -# endif -const BIO_METHOD *BIO_s_fd(void); -const BIO_METHOD *BIO_s_log(void); -const BIO_METHOD *BIO_s_bio(void); -const BIO_METHOD *BIO_s_null(void); -const BIO_METHOD *BIO_f_null(void); -const BIO_METHOD *BIO_f_buffer(void); -const BIO_METHOD *BIO_f_linebuffer(void); -const BIO_METHOD *BIO_f_nbio_test(void); -# ifndef OPENSSL_NO_DGRAM -const BIO_METHOD *BIO_s_datagram(void); -int BIO_dgram_non_fatal_error(int error); -BIO *BIO_new_dgram(int fd, int close_flag); -# ifndef OPENSSL_NO_SCTP -const BIO_METHOD *BIO_s_datagram_sctp(void); -BIO *BIO_new_dgram_sctp(int fd, int close_flag); -int BIO_dgram_is_sctp(BIO *bio); -int BIO_dgram_sctp_notification_cb(BIO *b, - void (*handle_notifications) (BIO *bio, - void *context, - void *buf), - void *context); -int BIO_dgram_sctp_wait_for_dry(BIO *b); -int BIO_dgram_sctp_msg_waiting(BIO *b); -# endif -# endif - -# ifndef OPENSSL_NO_SOCK -int BIO_sock_should_retry(int i); -int BIO_sock_non_fatal_error(int error); -# endif - -int BIO_fd_should_retry(int i); -int BIO_fd_non_fatal_error(int error); -int BIO_dump_cb(int (*cb) (const void *data, size_t len, void *u), - void *u, const char *s, int len); -int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), - void *u, const char *s, int len, int indent); -int BIO_dump(BIO *b, const char *bytes, int len); -int BIO_dump_indent(BIO *b, const char *bytes, int len, int indent); -# ifndef OPENSSL_NO_STDIO -int BIO_dump_fp(FILE *fp, const char *s, int len); -int BIO_dump_indent_fp(FILE *fp, const char *s, int len, int indent); -# endif -int BIO_hex_string(BIO *out, int indent, int width, unsigned char *data, - int datalen); - -# ifndef OPENSSL_NO_SOCK -BIO_ADDR *BIO_ADDR_new(void); -int BIO_ADDR_rawmake(BIO_ADDR *ap, int family, - const void *where, size_t wherelen, unsigned short port); -void BIO_ADDR_free(BIO_ADDR *); -void BIO_ADDR_clear(BIO_ADDR *ap); -int BIO_ADDR_family(const BIO_ADDR *ap); -int BIO_ADDR_rawaddress(const BIO_ADDR *ap, void *p, size_t *l); -unsigned short BIO_ADDR_rawport(const BIO_ADDR *ap); -char *BIO_ADDR_hostname_string(const BIO_ADDR *ap, int numeric); -char *BIO_ADDR_service_string(const BIO_ADDR *ap, int numeric); -char *BIO_ADDR_path_string(const BIO_ADDR *ap); - -const BIO_ADDRINFO *BIO_ADDRINFO_next(const BIO_ADDRINFO *bai); -int BIO_ADDRINFO_family(const BIO_ADDRINFO *bai); -int BIO_ADDRINFO_socktype(const BIO_ADDRINFO *bai); -int BIO_ADDRINFO_protocol(const BIO_ADDRINFO *bai); -const BIO_ADDR *BIO_ADDRINFO_address(const BIO_ADDRINFO *bai); -void BIO_ADDRINFO_free(BIO_ADDRINFO *bai); - -enum BIO_hostserv_priorities { - BIO_PARSE_PRIO_HOST, BIO_PARSE_PRIO_SERV -}; -int BIO_parse_hostserv(const char *hostserv, char **host, char **service, - enum BIO_hostserv_priorities hostserv_prio); -enum BIO_lookup_type { - BIO_LOOKUP_CLIENT, BIO_LOOKUP_SERVER -}; -int BIO_lookup(const char *host, const char *service, - enum BIO_lookup_type lookup_type, - int family, int socktype, BIO_ADDRINFO **res); -int BIO_sock_error(int sock); -int BIO_socket_ioctl(int fd, long type, void *arg); -int BIO_socket_nbio(int fd, int mode); -int BIO_sock_init(void); -# if OPENSSL_API_COMPAT < 0x10100000L -# define BIO_sock_cleanup() while(0) continue -# endif -int BIO_set_tcp_ndelay(int sock, int turn_on); - -DEPRECATEDIN_1_1_0(struct hostent *BIO_gethostbyname(const char *name)) -DEPRECATEDIN_1_1_0(int BIO_get_port(const char *str, unsigned short *port_ptr)) -DEPRECATEDIN_1_1_0(int BIO_get_host_ip(const char *str, unsigned char *ip)) -DEPRECATEDIN_1_1_0(int BIO_get_accept_socket(char *host_port, int mode)) -DEPRECATEDIN_1_1_0(int BIO_accept(int sock, char **ip_port)) - -union BIO_sock_info_u { - BIO_ADDR *addr; -}; -enum BIO_sock_info_type { - BIO_SOCK_INFO_ADDRESS -}; -int BIO_sock_info(int sock, - enum BIO_sock_info_type type, union BIO_sock_info_u *info); - -# define BIO_SOCK_REUSEADDR 0x01 -# define BIO_SOCK_V6_ONLY 0x02 -# define BIO_SOCK_KEEPALIVE 0x04 -# define BIO_SOCK_NONBLOCK 0x08 -# define BIO_SOCK_NODELAY 0x10 - -int BIO_socket(int domain, int socktype, int protocol, int options); -int BIO_connect(int sock, const BIO_ADDR *addr, int options); -int BIO_listen(int sock, const BIO_ADDR *addr, int options); -int BIO_accept_ex(int accept_sock, BIO_ADDR *addr, int options); -int BIO_closesocket(int sock); - -BIO *BIO_new_socket(int sock, int close_flag); -BIO *BIO_new_connect(const char *host_port); -BIO *BIO_new_accept(const char *host_port); -# endif /* OPENSSL_NO_SOCK*/ - -BIO *BIO_new_fd(int fd, int close_flag); - -int BIO_new_bio_pair(BIO **bio1, size_t writebuf1, - BIO **bio2, size_t writebuf2); -/* - * If successful, returns 1 and in *bio1, *bio2 two BIO pair endpoints. - * Otherwise returns 0 and sets *bio1 and *bio2 to NULL. Size 0 uses default - * value. - */ - -void BIO_copy_next_retry(BIO *b); - -/* - * long BIO_ghbn_ctrl(int cmd,int iarg,char *parg); - */ - -# ifdef __GNUC__ -# define __bio_h__attr__ __attribute__ -# else -# define __bio_h__attr__(x) -# endif -int BIO_printf(BIO *bio, const char *format, ...) -__bio_h__attr__((__format__(__printf__, 2, 3))); -int BIO_vprintf(BIO *bio, const char *format, va_list args) -__bio_h__attr__((__format__(__printf__, 2, 0))); -int BIO_snprintf(char *buf, size_t n, const char *format, ...) -__bio_h__attr__((__format__(__printf__, 3, 4))); -int BIO_vsnprintf(char *buf, size_t n, const char *format, va_list args) -__bio_h__attr__((__format__(__printf__, 3, 0))); -# undef __bio_h__attr__ - - -BIO_METHOD *BIO_meth_new(int type, const char *name); -void BIO_meth_free(BIO_METHOD *biom); -int (*BIO_meth_get_write(BIO_METHOD *biom)) (BIO *, const char *, int); -int BIO_meth_set_write(BIO_METHOD *biom, - int (*write) (BIO *, const char *, int)); -int (*BIO_meth_get_read(BIO_METHOD *biom)) (BIO *, char *, int); -int BIO_meth_set_read(BIO_METHOD *biom, - int (*read) (BIO *, char *, int)); -int (*BIO_meth_get_puts(BIO_METHOD *biom)) (BIO *, const char *); -int BIO_meth_set_puts(BIO_METHOD *biom, - int (*puts) (BIO *, const char *)); -int (*BIO_meth_get_gets(BIO_METHOD *biom)) (BIO *, char *, int); -int BIO_meth_set_gets(BIO_METHOD *biom, - int (*gets) (BIO *, char *, int)); -long (*BIO_meth_get_ctrl(BIO_METHOD *biom)) (BIO *, int, long, void *); -int BIO_meth_set_ctrl(BIO_METHOD *biom, - long (*ctrl) (BIO *, int, long, void *)); -int (*BIO_meth_get_create(BIO_METHOD *bion)) (BIO *); -int BIO_meth_set_create(BIO_METHOD *biom, int (*create) (BIO *)); -int (*BIO_meth_get_destroy(BIO_METHOD *biom)) (BIO *); -int BIO_meth_set_destroy(BIO_METHOD *biom, int (*destroy) (BIO *)); -long (*BIO_meth_get_callback_ctrl(BIO_METHOD *biom)) - (BIO *, int, bio_info_cb *); -int BIO_meth_set_callback_ctrl(BIO_METHOD *biom, - long (*callback_ctrl) (BIO *, int, - bio_info_cb *)); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_BIO_strings(void); - -/* Error codes for the BIO functions. */ - -/* Function codes. */ -# define BIO_F_ACPT_STATE 100 -# define BIO_F_ADDR_STRINGS 134 -# define BIO_F_BIO_ACCEPT 101 -# define BIO_F_BIO_ACCEPT_EX 137 -# define BIO_F_BIO_ADDR_NEW 144 -# define BIO_F_BIO_CALLBACK_CTRL 131 -# define BIO_F_BIO_CONNECT 138 -# define BIO_F_BIO_CTRL 103 -# define BIO_F_BIO_GETS 104 -# define BIO_F_BIO_GET_HOST_IP 106 -# define BIO_F_BIO_GET_NEW_INDEX 102 -# define BIO_F_BIO_GET_PORT 107 -# define BIO_F_BIO_LISTEN 139 -# define BIO_F_BIO_LOOKUP 135 -# define BIO_F_BIO_MAKE_PAIR 121 -# define BIO_F_BIO_NEW 108 -# define BIO_F_BIO_NEW_FILE 109 -# define BIO_F_BIO_NEW_MEM_BUF 126 -# define BIO_F_BIO_NREAD 123 -# define BIO_F_BIO_NREAD0 124 -# define BIO_F_BIO_NWRITE 125 -# define BIO_F_BIO_NWRITE0 122 -# define BIO_F_BIO_PARSE_HOSTSERV 136 -# define BIO_F_BIO_PUTS 110 -# define BIO_F_BIO_READ 111 -# define BIO_F_BIO_SOCKET 140 -# define BIO_F_BIO_SOCKET_NBIO 142 -# define BIO_F_BIO_SOCK_INFO 141 -# define BIO_F_BIO_SOCK_INIT 112 -# define BIO_F_BIO_WRITE 113 -# define BIO_F_BUFFER_CTRL 114 -# define BIO_F_CONN_CTRL 127 -# define BIO_F_CONN_STATE 115 -# define BIO_F_DGRAM_SCTP_READ 132 -# define BIO_F_DGRAM_SCTP_WRITE 133 -# define BIO_F_FILE_CTRL 116 -# define BIO_F_FILE_READ 130 -# define BIO_F_LINEBUFFER_CTRL 129 -# define BIO_F_MEM_WRITE 117 -# define BIO_F_SSL_NEW 118 - -/* Reason codes. */ -# define BIO_R_ACCEPT_ERROR 100 -# define BIO_R_ADDRINFO_ADDR_IS_NOT_AF_INET 141 -# define BIO_R_AMBIGUOUS_HOST_OR_SERVICE 129 -# define BIO_R_BAD_FOPEN_MODE 101 -# define BIO_R_BROKEN_PIPE 124 -# define BIO_R_CONNECT_ERROR 103 -# define BIO_R_GETHOSTBYNAME_ADDR_IS_NOT_AF_INET 107 -# define BIO_R_GETSOCKNAME_ERROR 132 -# define BIO_R_GETSOCKNAME_TRUNCATED_ADDRESS 133 -# define BIO_R_GETTING_SOCKTYPE 134 -# define BIO_R_INVALID_ARGUMENT 125 -# define BIO_R_INVALID_SOCKET 135 -# define BIO_R_IN_USE 123 -# define BIO_R_LISTEN_V6_ONLY 136 -# define BIO_R_LOOKUP_RETURNED_NOTHING 142 -# define BIO_R_MALFORMED_HOST_OR_SERVICE 130 -# define BIO_R_NBIO_CONNECT_ERROR 110 -# define BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED 143 -# define BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED 144 -# define BIO_R_NO_PORT_DEFINED 113 -# define BIO_R_NO_SUCH_FILE 128 -# define BIO_R_NULL_PARAMETER 115 -# define BIO_R_UNABLE_TO_BIND_SOCKET 117 -# define BIO_R_UNABLE_TO_CREATE_SOCKET 118 -# define BIO_R_UNABLE_TO_KEEPALIVE 137 -# define BIO_R_UNABLE_TO_LISTEN_SOCKET 119 -# define BIO_R_UNABLE_TO_NODELAY 138 -# define BIO_R_UNABLE_TO_REUSEADDR 139 -# define BIO_R_UNAVAILABLE_IP_FAMILY 145 -# define BIO_R_UNINITIALIZED 120 -# define BIO_R_UNKNOWN_INFO_TYPE 140 -# define BIO_R_UNSUPPORTED_IP_FAMILY 146 -# define BIO_R_UNSUPPORTED_METHOD 121 -# define BIO_R_UNSUPPORTED_PROTOCOL_FAMILY 131 -# define BIO_R_WRITE_TO_READ_ONLY_BIO 126 -# define BIO_R_WSASTARTUP 122 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/blowfish.h b/android/armeabi/include/openssl/blowfish.h deleted file mode 100644 index cd3e460e..00000000 --- a/android/armeabi/include/openssl/blowfish.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_BLOWFISH_H -# define HEADER_BLOWFISH_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_BF -# include <openssl/e_os2.h> -# ifdef __cplusplus -extern "C" { -# endif - -# define BF_ENCRYPT 1 -# define BF_DECRYPT 0 - -/*- - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! BF_LONG has to be at least 32 bits wide. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ -# define BF_LONG unsigned int - -# define BF_ROUNDS 16 -# define BF_BLOCK 8 - -typedef struct bf_key_st { - BF_LONG P[BF_ROUNDS + 2]; - BF_LONG S[4 * 256]; -} BF_KEY; - -void BF_set_key(BF_KEY *key, int len, const unsigned char *data); - -void BF_encrypt(BF_LONG *data, const BF_KEY *key); -void BF_decrypt(BF_LONG *data, const BF_KEY *key); - -void BF_ecb_encrypt(const unsigned char *in, unsigned char *out, - const BF_KEY *key, int enc); -void BF_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - const BF_KEY *schedule, unsigned char *ivec, int enc); -void BF_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, const BF_KEY *schedule, - unsigned char *ivec, int *num, int enc); -void BF_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, const BF_KEY *schedule, - unsigned char *ivec, int *num); -const char *BF_options(void); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/bn.h b/android/armeabi/include/openssl/bn.h deleted file mode 100644 index 17bd5213..00000000 --- a/android/armeabi/include/openssl/bn.h +++ /dev/null @@ -1,575 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the Eric Young open source - * license provided above. - * - * The binary polynomial arithmetic software is originally written by - * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. - * - */ - -#ifndef HEADER_BN_H -# define HEADER_BN_H - -# include <openssl/e_os2.h> -# ifndef OPENSSL_NO_STDIO -# include <stdio.h> -# endif -# include <openssl/opensslconf.h> -# include <openssl/ossl_typ.h> -# include <openssl/crypto.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * 64-bit processor with LP64 ABI - */ -# ifdef SIXTY_FOUR_BIT_LONG -# define BN_ULONG unsigned long -# define BN_BYTES 8 -# endif - -/* - * 64-bit processor other than LP64 ABI - */ -# ifdef SIXTY_FOUR_BIT -# define BN_ULONG unsigned long long -# define BN_BYTES 8 -# endif - -# ifdef THIRTY_TWO_BIT -# define BN_ULONG unsigned int -# define BN_BYTES 4 -# endif - -# define BN_BITS2 (BN_BYTES * 8) -# define BN_BITS (BN_BITS2 * 2) -# define BN_TBIT ((BN_ULONG)1 << (BN_BITS2 - 1)) - -# define BN_FLG_MALLOCED 0x01 -# define BN_FLG_STATIC_DATA 0x02 - -/* - * avoid leaking exponent information through timing, - * BN_mod_exp_mont() will call BN_mod_exp_mont_consttime, - * BN_div() will call BN_div_no_branch, - * BN_mod_inverse() will call BN_mod_inverse_no_branch. - */ -# define BN_FLG_CONSTTIME 0x04 -# define BN_FLG_SECURE 0x08 - -# if OPENSSL_API_COMPAT < 0x00908000L -/* deprecated name for the flag */ -# define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME -# define BN_FLG_FREE 0x8000 /* used for debugging */ -# endif - -void BN_set_flags(BIGNUM *b, int n); -int BN_get_flags(const BIGNUM *b, int n); - -/* Values for |top| in BN_rand() */ -#define BN_RAND_TOP_ANY -1 -#define BN_RAND_TOP_ONE 0 -#define BN_RAND_TOP_TWO 1 - -/* Values for |bottom| in BN_rand() */ -#define BN_RAND_BOTTOM_ANY 0 -#define BN_RAND_BOTTOM_ODD 1 - -/* - * get a clone of a BIGNUM with changed flags, for *temporary* use only (the - * two BIGNUMs cannot be used in parallel!). Also only for *read only* use. The - * value |dest| should be a newly allocated BIGNUM obtained via BN_new() that - * has not been otherwise initialised or used. - */ -void BN_with_flags(BIGNUM *dest, const BIGNUM *b, int flags); - -/* Wrapper function to make using BN_GENCB easier */ -int BN_GENCB_call(BN_GENCB *cb, int a, int b); - -BN_GENCB *BN_GENCB_new(void); -void BN_GENCB_free(BN_GENCB *cb); - -/* Populate a BN_GENCB structure with an "old"-style callback */ -void BN_GENCB_set_old(BN_GENCB *gencb, void (*callback) (int, int, void *), - void *cb_arg); - -/* Populate a BN_GENCB structure with a "new"-style callback */ -void BN_GENCB_set(BN_GENCB *gencb, int (*callback) (int, int, BN_GENCB *), - void *cb_arg); - -void *BN_GENCB_get_arg(BN_GENCB *cb); - -# define BN_prime_checks 0 /* default: select number of iterations based - * on the size of the number */ - -/* - * number of Miller-Rabin iterations for an error rate of less than 2^-80 for - * random 'b'-bit input, b >= 100 (taken from table 4.4 in the Handbook of - * Applied Cryptography [Menezes, van Oorschot, Vanstone; CRC Press 1996]; - * original paper: Damgaard, Landrock, Pomerance: Average case error - * estimates for the strong probable prime test. -- Math. Comp. 61 (1993) - * 177-194) - */ -# define BN_prime_checks_for_size(b) ((b) >= 1300 ? 2 : \ - (b) >= 850 ? 3 : \ - (b) >= 650 ? 4 : \ - (b) >= 550 ? 5 : \ - (b) >= 450 ? 6 : \ - (b) >= 400 ? 7 : \ - (b) >= 350 ? 8 : \ - (b) >= 300 ? 9 : \ - (b) >= 250 ? 12 : \ - (b) >= 200 ? 15 : \ - (b) >= 150 ? 18 : \ - /* b >= 100 */ 27) - -# define BN_num_bytes(a) ((BN_num_bits(a)+7)/8) - -int BN_abs_is_word(const BIGNUM *a, const BN_ULONG w); -int BN_is_zero(const BIGNUM *a); -int BN_is_one(const BIGNUM *a); -int BN_is_word(const BIGNUM *a, const BN_ULONG w); -int BN_is_odd(const BIGNUM *a); - -# define BN_one(a) (BN_set_word((a),1)) - -void BN_zero_ex(BIGNUM *a); - -# if OPENSSL_API_COMPAT >= 0x00908000L -# define BN_zero(a) BN_zero_ex(a) -# else -# define BN_zero(a) (BN_set_word((a),0)) -# endif - -const BIGNUM *BN_value_one(void); -char *BN_options(void); -BN_CTX *BN_CTX_new(void); -BN_CTX *BN_CTX_secure_new(void); -void BN_CTX_free(BN_CTX *c); -void BN_CTX_start(BN_CTX *ctx); -BIGNUM *BN_CTX_get(BN_CTX *ctx); -void BN_CTX_end(BN_CTX *ctx); -int BN_rand(BIGNUM *rnd, int bits, int top, int bottom); -int BN_pseudo_rand(BIGNUM *rnd, int bits, int top, int bottom); -int BN_rand_range(BIGNUM *rnd, const BIGNUM *range); -int BN_pseudo_rand_range(BIGNUM *rnd, const BIGNUM *range); -int BN_num_bits(const BIGNUM *a); -int BN_num_bits_word(BN_ULONG l); -int BN_security_bits(int L, int N); -BIGNUM *BN_new(void); -BIGNUM *BN_secure_new(void); -void BN_clear_free(BIGNUM *a); -BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b); -void BN_swap(BIGNUM *a, BIGNUM *b); -BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret); -int BN_bn2bin(const BIGNUM *a, unsigned char *to); -int BN_bn2binpad(const BIGNUM *a, unsigned char *to, int tolen); -BIGNUM *BN_lebin2bn(const unsigned char *s, int len, BIGNUM *ret); -int BN_bn2lebinpad(const BIGNUM *a, unsigned char *to, int tolen); -BIGNUM *BN_mpi2bn(const unsigned char *s, int len, BIGNUM *ret); -int BN_bn2mpi(const BIGNUM *a, unsigned char *to); -int BN_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_usub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_uadd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); -int BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx); -/** BN_set_negative sets sign of a BIGNUM - * \param b pointer to the BIGNUM object - * \param n 0 if the BIGNUM b should be positive and a value != 0 otherwise - */ -void BN_set_negative(BIGNUM *b, int n); -/** BN_is_negative returns 1 if the BIGNUM is negative - * \param a pointer to the BIGNUM object - * \return 1 if a < 0 and 0 otherwise - */ -int BN_is_negative(const BIGNUM *b); - -int BN_div(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, const BIGNUM *d, - BN_CTX *ctx); -# define BN_mod(rem,m,d,ctx) BN_div(NULL,(rem),(m),(d),(ctx)) -int BN_nnmod(BIGNUM *r, const BIGNUM *m, const BIGNUM *d, BN_CTX *ctx); -int BN_mod_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, - BN_CTX *ctx); -int BN_mod_add_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m); -int BN_mod_sub(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, - BN_CTX *ctx); -int BN_mod_sub_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *m); -int BN_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const BIGNUM *m, - BN_CTX *ctx); -int BN_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_lshift1(BIGNUM *r, const BIGNUM *a, const BIGNUM *m, BN_CTX *ctx); -int BN_mod_lshift1_quick(BIGNUM *r, const BIGNUM *a, const BIGNUM *m); -int BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, - BN_CTX *ctx); -int BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m); - -BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w); -BN_ULONG BN_div_word(BIGNUM *a, BN_ULONG w); -int BN_mul_word(BIGNUM *a, BN_ULONG w); -int BN_add_word(BIGNUM *a, BN_ULONG w); -int BN_sub_word(BIGNUM *a, BN_ULONG w); -int BN_set_word(BIGNUM *a, BN_ULONG w); -BN_ULONG BN_get_word(const BIGNUM *a); - -int BN_cmp(const BIGNUM *a, const BIGNUM *b); -void BN_free(BIGNUM *a); -int BN_is_bit_set(const BIGNUM *a, int n); -int BN_lshift(BIGNUM *r, const BIGNUM *a, int n); -int BN_lshift1(BIGNUM *r, const BIGNUM *a); -int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); - -int BN_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); -int BN_mod_exp_mont(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp_mont_consttime(BIGNUM *rr, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, - BN_MONT_CTX *in_mont); -int BN_mod_exp_mont_word(BIGNUM *r, BN_ULONG a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp2_mont(BIGNUM *r, const BIGNUM *a1, const BIGNUM *p1, - const BIGNUM *a2, const BIGNUM *p2, const BIGNUM *m, - BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int BN_mod_exp_simple(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); - -int BN_mask_bits(BIGNUM *a, int n); -# ifndef OPENSSL_NO_STDIO -int BN_print_fp(FILE *fp, const BIGNUM *a); -# endif -int BN_print(BIO *bio, const BIGNUM *a); -int BN_reciprocal(BIGNUM *r, const BIGNUM *m, int len, BN_CTX *ctx); -int BN_rshift(BIGNUM *r, const BIGNUM *a, int n); -int BN_rshift1(BIGNUM *r, const BIGNUM *a); -void BN_clear(BIGNUM *a); -BIGNUM *BN_dup(const BIGNUM *a); -int BN_ucmp(const BIGNUM *a, const BIGNUM *b); -int BN_set_bit(BIGNUM *a, int n); -int BN_clear_bit(BIGNUM *a, int n); -char *BN_bn2hex(const BIGNUM *a); -char *BN_bn2dec(const BIGNUM *a); -int BN_hex2bn(BIGNUM **a, const char *str); -int BN_dec2bn(BIGNUM **a, const char *str); -int BN_asc2bn(BIGNUM **a, const char *str); -int BN_gcd(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); -int BN_kronecker(const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); /* returns - * -2 for - * error */ -BIGNUM *BN_mod_inverse(BIGNUM *ret, - const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); -BIGNUM *BN_mod_sqrt(BIGNUM *ret, - const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx); - -void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords); - -/* Deprecated versions */ -DEPRECATEDIN_0_9_8(BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, - const BIGNUM *add, - const BIGNUM *rem, - void (*callback) (int, int, - void *), - void *cb_arg)) -DEPRECATEDIN_0_9_8(int - BN_is_prime(const BIGNUM *p, int nchecks, - void (*callback) (int, int, void *), - BN_CTX *ctx, void *cb_arg)) -DEPRECATEDIN_0_9_8(int - BN_is_prime_fasttest(const BIGNUM *p, int nchecks, - void (*callback) (int, int, void *), - BN_CTX *ctx, void *cb_arg, - int do_trial_division)) - -/* Newer versions */ -int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, - const BIGNUM *rem, BN_GENCB *cb); -int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb); -int BN_is_prime_fasttest_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, - int do_trial_division, BN_GENCB *cb); - -int BN_X931_generate_Xpq(BIGNUM *Xp, BIGNUM *Xq, int nbits, BN_CTX *ctx); - -int BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, - const BIGNUM *Xp, const BIGNUM *Xp1, - const BIGNUM *Xp2, const BIGNUM *e, BN_CTX *ctx, - BN_GENCB *cb); -int BN_X931_generate_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, BIGNUM *Xp1, - BIGNUM *Xp2, const BIGNUM *Xp, const BIGNUM *e, - BN_CTX *ctx, BN_GENCB *cb); - -BN_MONT_CTX *BN_MONT_CTX_new(void); -int BN_mod_mul_montgomery(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - BN_MONT_CTX *mont, BN_CTX *ctx); -int BN_to_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, - BN_CTX *ctx); -int BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mont, - BN_CTX *ctx); -void BN_MONT_CTX_free(BN_MONT_CTX *mont); -int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx); -BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from); -BN_MONT_CTX *BN_MONT_CTX_set_locked(BN_MONT_CTX **pmont, CRYPTO_RWLOCK *lock, - const BIGNUM *mod, BN_CTX *ctx); - -/* BN_BLINDING flags */ -# define BN_BLINDING_NO_UPDATE 0x00000001 -# define BN_BLINDING_NO_RECREATE 0x00000002 - -BN_BLINDING *BN_BLINDING_new(const BIGNUM *A, const BIGNUM *Ai, BIGNUM *mod); -void BN_BLINDING_free(BN_BLINDING *b); -int BN_BLINDING_update(BN_BLINDING *b, BN_CTX *ctx); -int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); -int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); -int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); -int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, - BN_CTX *); - -int BN_BLINDING_is_current_thread(BN_BLINDING *b); -void BN_BLINDING_set_current_thread(BN_BLINDING *b); -int BN_BLINDING_lock(BN_BLINDING *b); -int BN_BLINDING_unlock(BN_BLINDING *b); - -unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); -void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); -BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, - const BIGNUM *e, BIGNUM *m, BN_CTX *ctx, - int (*bn_mod_exp) (BIGNUM *r, - const BIGNUM *a, - const BIGNUM *p, - const BIGNUM *m, - BN_CTX *ctx, - BN_MONT_CTX *m_ctx), - BN_MONT_CTX *m_ctx); - -DEPRECATEDIN_0_9_8(void BN_set_params(int mul, int high, int low, int mont)) -DEPRECATEDIN_0_9_8(int BN_get_params(int which)) /* 0, mul, 1 high, 2 low, 3 - * mont */ - -BN_RECP_CTX *BN_RECP_CTX_new(void); -void BN_RECP_CTX_free(BN_RECP_CTX *recp); -int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *rdiv, BN_CTX *ctx); -int BN_mod_mul_reciprocal(BIGNUM *r, const BIGNUM *x, const BIGNUM *y, - BN_RECP_CTX *recp, BN_CTX *ctx); -int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx); -int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, - BN_RECP_CTX *recp, BN_CTX *ctx); - -# ifndef OPENSSL_NO_EC2M - -/* - * Functions for arithmetic over binary polynomials represented by BIGNUMs. - * The BIGNUM::neg property of BIGNUMs representing binary polynomials is - * ignored. Note that input arguments are not const so that their bit arrays - * can be expanded to the appropriate size if needed. - */ - -/* - * r = a + b - */ -int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b); -# define BN_GF2m_sub(r, a, b) BN_GF2m_add(r, a, b) -/* - * r=a mod p - */ -int BN_GF2m_mod(BIGNUM *r, const BIGNUM *a, const BIGNUM *p); -/* r = (a * b) mod p */ -int BN_GF2m_mod_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *p, BN_CTX *ctx); -/* r = (a * a) mod p */ -int BN_GF2m_mod_sqr(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -/* r = (1 / b) mod p */ -int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *b, const BIGNUM *p, BN_CTX *ctx); -/* r = (a / b) mod p */ -int BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *p, BN_CTX *ctx); -/* r = (a ^ b) mod p */ -int BN_GF2m_mod_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const BIGNUM *p, BN_CTX *ctx); -/* r = sqrt(a) mod p */ -int BN_GF2m_mod_sqrt(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - BN_CTX *ctx); -/* r^2 + r = a mod p */ -int BN_GF2m_mod_solve_quad(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - BN_CTX *ctx); -# define BN_GF2m_cmp(a, b) BN_ucmp((a), (b)) -/*- - * Some functions allow for representation of the irreducible polynomials - * as an unsigned int[], say p. The irreducible f(t) is then of the form: - * t^p[0] + t^p[1] + ... + t^p[k] - * where m = p[0] > p[1] > ... > p[k] = 0. - */ -/* r = a mod p */ -int BN_GF2m_mod_arr(BIGNUM *r, const BIGNUM *a, const int p[]); -/* r = (a * b) mod p */ -int BN_GF2m_mod_mul_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const int p[], BN_CTX *ctx); -/* r = (a * a) mod p */ -int BN_GF2m_mod_sqr_arr(BIGNUM *r, const BIGNUM *a, const int p[], - BN_CTX *ctx); -/* r = (1 / b) mod p */ -int BN_GF2m_mod_inv_arr(BIGNUM *r, const BIGNUM *b, const int p[], - BN_CTX *ctx); -/* r = (a / b) mod p */ -int BN_GF2m_mod_div_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const int p[], BN_CTX *ctx); -/* r = (a ^ b) mod p */ -int BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, - const int p[], BN_CTX *ctx); -/* r = sqrt(a) mod p */ -int BN_GF2m_mod_sqrt_arr(BIGNUM *r, const BIGNUM *a, - const int p[], BN_CTX *ctx); -/* r^2 + r = a mod p */ -int BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a, - const int p[], BN_CTX *ctx); -int BN_GF2m_poly2arr(const BIGNUM *a, int p[], int max); -int BN_GF2m_arr2poly(const int p[], BIGNUM *a); - -# endif - -/* - * faster mod functions for the 'NIST primes' 0 <= a < p^2 - */ -int BN_nist_mod_192(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_224(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_256(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_384(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); -int BN_nist_mod_521(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx); - -const BIGNUM *BN_get0_nist_prime_192(void); -const BIGNUM *BN_get0_nist_prime_224(void); -const BIGNUM *BN_get0_nist_prime_256(void); -const BIGNUM *BN_get0_nist_prime_384(void); -const BIGNUM *BN_get0_nist_prime_521(void); - -int (*BN_nist_mod_func(const BIGNUM *p)) (BIGNUM *r, const BIGNUM *a, - const BIGNUM *field, BN_CTX *ctx); - -int BN_generate_dsa_nonce(BIGNUM *out, const BIGNUM *range, - const BIGNUM *priv, const unsigned char *message, - size_t message_len, BN_CTX *ctx); - -/* Primes from RFC 2409 */ -BIGNUM *BN_get_rfc2409_prime_768(BIGNUM *bn); -BIGNUM *BN_get_rfc2409_prime_1024(BIGNUM *bn); - -/* Primes from RFC 3526 */ -BIGNUM *BN_get_rfc3526_prime_1536(BIGNUM *bn); -BIGNUM *BN_get_rfc3526_prime_2048(BIGNUM *bn); -BIGNUM *BN_get_rfc3526_prime_3072(BIGNUM *bn); -BIGNUM *BN_get_rfc3526_prime_4096(BIGNUM *bn); -BIGNUM *BN_get_rfc3526_prime_6144(BIGNUM *bn); -BIGNUM *BN_get_rfc3526_prime_8192(BIGNUM *bn); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define get_rfc2409_prime_768 BN_get_rfc2409_prime_768 -# define get_rfc2409_prime_1024 BN_get_rfc2409_prime_1024 -# define get_rfc3526_prime_1536 BN_get_rfc3526_prime_1536 -# define get_rfc3526_prime_2048 BN_get_rfc3526_prime_2048 -# define get_rfc3526_prime_3072 BN_get_rfc3526_prime_3072 -# define get_rfc3526_prime_4096 BN_get_rfc3526_prime_4096 -# define get_rfc3526_prime_6144 BN_get_rfc3526_prime_6144 -# define get_rfc3526_prime_8192 BN_get_rfc3526_prime_8192 -# endif - -int BN_bntest_rand(BIGNUM *rnd, int bits, int top, int bottom); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_BN_strings(void); - -/* Error codes for the BN functions. */ - -/* Function codes. */ -# define BN_F_BNRAND 127 -# define BN_F_BN_BLINDING_CONVERT_EX 100 -# define BN_F_BN_BLINDING_CREATE_PARAM 128 -# define BN_F_BN_BLINDING_INVERT_EX 101 -# define BN_F_BN_BLINDING_NEW 102 -# define BN_F_BN_BLINDING_UPDATE 103 -# define BN_F_BN_BN2DEC 104 -# define BN_F_BN_BN2HEX 105 -# define BN_F_BN_COMPUTE_WNAF 142 -# define BN_F_BN_CTX_GET 116 -# define BN_F_BN_CTX_NEW 106 -# define BN_F_BN_CTX_START 129 -# define BN_F_BN_DIV 107 -# define BN_F_BN_DIV_RECP 130 -# define BN_F_BN_EXP 123 -# define BN_F_BN_EXPAND_INTERNAL 120 -# define BN_F_BN_GENCB_NEW 143 -# define BN_F_BN_GENERATE_DSA_NONCE 140 -# define BN_F_BN_GENERATE_PRIME_EX 141 -# define BN_F_BN_GF2M_MOD 131 -# define BN_F_BN_GF2M_MOD_EXP 132 -# define BN_F_BN_GF2M_MOD_MUL 133 -# define BN_F_BN_GF2M_MOD_SOLVE_QUAD 134 -# define BN_F_BN_GF2M_MOD_SOLVE_QUAD_ARR 135 -# define BN_F_BN_GF2M_MOD_SQR 136 -# define BN_F_BN_GF2M_MOD_SQRT 137 -# define BN_F_BN_LSHIFT 145 -# define BN_F_BN_MOD_EXP2_MONT 118 -# define BN_F_BN_MOD_EXP_MONT 109 -# define BN_F_BN_MOD_EXP_MONT_CONSTTIME 124 -# define BN_F_BN_MOD_EXP_MONT_WORD 117 -# define BN_F_BN_MOD_EXP_RECP 125 -# define BN_F_BN_MOD_EXP_SIMPLE 126 -# define BN_F_BN_MOD_INVERSE 110 -# define BN_F_BN_MOD_INVERSE_NO_BRANCH 139 -# define BN_F_BN_MOD_LSHIFT_QUICK 119 -# define BN_F_BN_MOD_SQRT 121 -# define BN_F_BN_MPI2BN 112 -# define BN_F_BN_NEW 113 -# define BN_F_BN_RAND 114 -# define BN_F_BN_RAND_RANGE 122 -# define BN_F_BN_RSHIFT 146 -# define BN_F_BN_SET_WORDS 144 -# define BN_F_BN_USUB 115 - -/* Reason codes. */ -# define BN_R_ARG2_LT_ARG3 100 -# define BN_R_BAD_RECIPROCAL 101 -# define BN_R_BIGNUM_TOO_LONG 114 -# define BN_R_BITS_TOO_SMALL 118 -# define BN_R_CALLED_WITH_EVEN_MODULUS 102 -# define BN_R_DIV_BY_ZERO 103 -# define BN_R_ENCODING_ERROR 104 -# define BN_R_EXPAND_ON_STATIC_BIGNUM_DATA 105 -# define BN_R_INPUT_NOT_REDUCED 110 -# define BN_R_INVALID_LENGTH 106 -# define BN_R_INVALID_RANGE 115 -# define BN_R_INVALID_SHIFT 119 -# define BN_R_NOT_A_SQUARE 111 -# define BN_R_NOT_INITIALIZED 107 -# define BN_R_NO_INVERSE 108 -# define BN_R_NO_SOLUTION 116 -# define BN_R_PRIVATE_KEY_TOO_LARGE 117 -# define BN_R_P_IS_NOT_PRIME 112 -# define BN_R_TOO_MANY_ITERATIONS 113 -# define BN_R_TOO_MANY_TEMPORARY_VARIABLES 109 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/buffer.h b/android/armeabi/include/openssl/buffer.h deleted file mode 100644 index 91f0e07f..00000000 --- a/android/armeabi/include/openssl/buffer.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_BUFFER_H -# define HEADER_BUFFER_H - -# include <openssl/ossl_typ.h> -# ifndef HEADER_CRYPTO_H -# include <openssl/crypto.h> -# endif - - -#ifdef __cplusplus -extern "C" { -#endif - -# include <stddef.h> - -# if !defined(NO_SYS_TYPES_H) -# include <sys/types.h> -# endif - -/* - * These names are outdated as of OpenSSL 1.1; a future release - * will move them to be deprecated. - */ -# define BUF_strdup(s) OPENSSL_strdup(s) -# define BUF_strndup(s, size) OPENSSL_strndup(s, size) -# define BUF_memdup(data, size) OPENSSL_memdup(data, size) -# define BUF_strlcpy(dst, src, size) OPENSSL_strlcpy(dst, src, size) -# define BUF_strlcat(dst, src, size) OPENSSL_strlcat(dst, src, size) -# define BUF_strnlen(str, maxlen) OPENSSL_strnlen(str, maxlen) - -struct buf_mem_st { - size_t length; /* current number of bytes */ - char *data; - size_t max; /* size of buffer */ - unsigned long flags; -}; - -# define BUF_MEM_FLAG_SECURE 0x01 - -BUF_MEM *BUF_MEM_new(void); -BUF_MEM *BUF_MEM_new_ex(unsigned long flags); -void BUF_MEM_free(BUF_MEM *a); -size_t BUF_MEM_grow(BUF_MEM *str, size_t len); -size_t BUF_MEM_grow_clean(BUF_MEM *str, size_t len); -void BUF_reverse(unsigned char *out, const unsigned char *in, size_t siz); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_BUF_strings(void); - -/* Error codes for the BUF functions. */ - -/* Function codes. */ -# define BUF_F_BUF_MEM_GROW 100 -# define BUF_F_BUF_MEM_GROW_CLEAN 105 -# define BUF_F_BUF_MEM_NEW 101 - -/* Reason codes. */ - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/camellia.h b/android/armeabi/include/openssl/camellia.h deleted file mode 100644 index 151f3c13..00000000 --- a/android/armeabi/include/openssl/camellia.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CAMELLIA_H -# define HEADER_CAMELLIA_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_CAMELLIA -# include <stddef.h> -#ifdef __cplusplus -extern "C" { -#endif - -# define CAMELLIA_ENCRYPT 1 -# define CAMELLIA_DECRYPT 0 - -/* - * Because array size can't be a const in C, the following two are macros. - * Both sizes are in bytes. - */ - -/* This should be a hidden type, but EVP requires that the size be known */ - -# define CAMELLIA_BLOCK_SIZE 16 -# define CAMELLIA_TABLE_BYTE_LEN 272 -# define CAMELLIA_TABLE_WORD_LEN (CAMELLIA_TABLE_BYTE_LEN / 4) - -typedef unsigned int KEY_TABLE_TYPE[CAMELLIA_TABLE_WORD_LEN]; /* to match - * with WORD */ - -struct camellia_key_st { - union { - double d; /* ensures 64-bit align */ - KEY_TABLE_TYPE rd_key; - } u; - int grand_rounds; -}; -typedef struct camellia_key_st CAMELLIA_KEY; - -int Camellia_set_key(const unsigned char *userKey, const int bits, - CAMELLIA_KEY *key); - -void Camellia_encrypt(const unsigned char *in, unsigned char *out, - const CAMELLIA_KEY *key); -void Camellia_decrypt(const unsigned char *in, unsigned char *out, - const CAMELLIA_KEY *key); - -void Camellia_ecb_encrypt(const unsigned char *in, unsigned char *out, - const CAMELLIA_KEY *key, const int enc); -void Camellia_cbc_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, const int enc); -void Camellia_cfb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num, const int enc); -void Camellia_cfb1_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num, const int enc); -void Camellia_cfb8_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num, const int enc); -void Camellia_ofb128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char *ivec, int *num); -void Camellia_ctr128_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const CAMELLIA_KEY *key, - unsigned char ivec[CAMELLIA_BLOCK_SIZE], - unsigned char ecount_buf[CAMELLIA_BLOCK_SIZE], - unsigned int *num); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/cast.h b/android/armeabi/include/openssl/cast.h deleted file mode 100644 index 2cc89ae0..00000000 --- a/android/armeabi/include/openssl/cast.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CAST_H -# define HEADER_CAST_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_CAST -# ifdef __cplusplus -extern "C" { -# endif - -# define CAST_ENCRYPT 1 -# define CAST_DECRYPT 0 - -# define CAST_LONG unsigned int - -# define CAST_BLOCK 8 -# define CAST_KEY_LENGTH 16 - -typedef struct cast_key_st { - CAST_LONG data[32]; - int short_key; /* Use reduced rounds for short key */ -} CAST_KEY; - -void CAST_set_key(CAST_KEY *key, int len, const unsigned char *data); -void CAST_ecb_encrypt(const unsigned char *in, unsigned char *out, - const CAST_KEY *key, int enc); -void CAST_encrypt(CAST_LONG *data, const CAST_KEY *key); -void CAST_decrypt(CAST_LONG *data, const CAST_KEY *key); -void CAST_cbc_encrypt(const unsigned char *in, unsigned char *out, - long length, const CAST_KEY *ks, unsigned char *iv, - int enc); -void CAST_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, const CAST_KEY *schedule, - unsigned char *ivec, int *num, int enc); -void CAST_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, const CAST_KEY *schedule, - unsigned char *ivec, int *num); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/cmac.h b/android/armeabi/include/openssl/cmac.h deleted file mode 100644 index 3535a9ab..00000000 --- a/android/armeabi/include/openssl/cmac.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 2010-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CMAC_H -# define HEADER_CMAC_H - -# ifndef OPENSSL_NO_CMAC - -#ifdef __cplusplus -extern "C" { -#endif - -# include <openssl/evp.h> - -/* Opaque */ -typedef struct CMAC_CTX_st CMAC_CTX; - -CMAC_CTX *CMAC_CTX_new(void); -void CMAC_CTX_cleanup(CMAC_CTX *ctx); -void CMAC_CTX_free(CMAC_CTX *ctx); -EVP_CIPHER_CTX *CMAC_CTX_get0_cipher_ctx(CMAC_CTX *ctx); -int CMAC_CTX_copy(CMAC_CTX *out, const CMAC_CTX *in); - -int CMAC_Init(CMAC_CTX *ctx, const void *key, size_t keylen, - const EVP_CIPHER *cipher, ENGINE *impl); -int CMAC_Update(CMAC_CTX *ctx, const void *data, size_t dlen); -int CMAC_Final(CMAC_CTX *ctx, unsigned char *out, size_t *poutlen); -int CMAC_resume(CMAC_CTX *ctx); - -#ifdef __cplusplus -} -#endif - -# endif -#endif diff --git a/android/armeabi/include/openssl/cms.h b/android/armeabi/include/openssl/cms.h deleted file mode 100644 index 7e534e0d..00000000 --- a/android/armeabi/include/openssl/cms.h +++ /dev/null @@ -1,512 +0,0 @@ -/* - * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CMS_H -# define HEADER_CMS_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_CMS -# include <openssl/x509.h> -# include <openssl/x509v3.h> -# ifdef __cplusplus -extern "C" { -# endif - -typedef struct CMS_ContentInfo_st CMS_ContentInfo; -typedef struct CMS_SignerInfo_st CMS_SignerInfo; -typedef struct CMS_CertificateChoices CMS_CertificateChoices; -typedef struct CMS_RevocationInfoChoice_st CMS_RevocationInfoChoice; -typedef struct CMS_RecipientInfo_st CMS_RecipientInfo; -typedef struct CMS_ReceiptRequest_st CMS_ReceiptRequest; -typedef struct CMS_Receipt_st CMS_Receipt; -typedef struct CMS_RecipientEncryptedKey_st CMS_RecipientEncryptedKey; -typedef struct CMS_OtherKeyAttribute_st CMS_OtherKeyAttribute; - -DEFINE_STACK_OF(CMS_SignerInfo) -DEFINE_STACK_OF(CMS_RecipientEncryptedKey) -DEFINE_STACK_OF(CMS_RecipientInfo) -DEFINE_STACK_OF(CMS_RevocationInfoChoice) -DECLARE_ASN1_FUNCTIONS(CMS_ContentInfo) -DECLARE_ASN1_FUNCTIONS(CMS_ReceiptRequest) -DECLARE_ASN1_PRINT_FUNCTION(CMS_ContentInfo) - -# define CMS_SIGNERINFO_ISSUER_SERIAL 0 -# define CMS_SIGNERINFO_KEYIDENTIFIER 1 - -# define CMS_RECIPINFO_NONE -1 -# define CMS_RECIPINFO_TRANS 0 -# define CMS_RECIPINFO_AGREE 1 -# define CMS_RECIPINFO_KEK 2 -# define CMS_RECIPINFO_PASS 3 -# define CMS_RECIPINFO_OTHER 4 - -/* S/MIME related flags */ - -# define CMS_TEXT 0x1 -# define CMS_NOCERTS 0x2 -# define CMS_NO_CONTENT_VERIFY 0x4 -# define CMS_NO_ATTR_VERIFY 0x8 -# define CMS_NOSIGS \ - (CMS_NO_CONTENT_VERIFY|CMS_NO_ATTR_VERIFY) -# define CMS_NOINTERN 0x10 -# define CMS_NO_SIGNER_CERT_VERIFY 0x20 -# define CMS_NOVERIFY 0x20 -# define CMS_DETACHED 0x40 -# define CMS_BINARY 0x80 -# define CMS_NOATTR 0x100 -# define CMS_NOSMIMECAP 0x200 -# define CMS_NOOLDMIMETYPE 0x400 -# define CMS_CRLFEOL 0x800 -# define CMS_STREAM 0x1000 -# define CMS_NOCRL 0x2000 -# define CMS_PARTIAL 0x4000 -# define CMS_REUSE_DIGEST 0x8000 -# define CMS_USE_KEYID 0x10000 -# define CMS_DEBUG_DECRYPT 0x20000 -# define CMS_KEY_PARAM 0x40000 -# define CMS_ASCIICRLF 0x80000 - -const ASN1_OBJECT *CMS_get0_type(const CMS_ContentInfo *cms); - -BIO *CMS_dataInit(CMS_ContentInfo *cms, BIO *icont); -int CMS_dataFinal(CMS_ContentInfo *cms, BIO *bio); - -ASN1_OCTET_STRING **CMS_get0_content(CMS_ContentInfo *cms); -int CMS_is_detached(CMS_ContentInfo *cms); -int CMS_set_detached(CMS_ContentInfo *cms, int detached); - -# ifdef HEADER_PEM_H -DECLARE_PEM_rw_const(CMS, CMS_ContentInfo) -# endif -int CMS_stream(unsigned char ***boundary, CMS_ContentInfo *cms); -CMS_ContentInfo *d2i_CMS_bio(BIO *bp, CMS_ContentInfo **cms); -int i2d_CMS_bio(BIO *bp, CMS_ContentInfo *cms); - -BIO *BIO_new_CMS(BIO *out, CMS_ContentInfo *cms); -int i2d_CMS_bio_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, int flags); -int PEM_write_bio_CMS_stream(BIO *out, CMS_ContentInfo *cms, BIO *in, - int flags); -CMS_ContentInfo *SMIME_read_CMS(BIO *bio, BIO **bcont); -int SMIME_write_CMS(BIO *bio, CMS_ContentInfo *cms, BIO *data, int flags); - -int CMS_final(CMS_ContentInfo *cms, BIO *data, BIO *dcont, - unsigned int flags); - -CMS_ContentInfo *CMS_sign(X509 *signcert, EVP_PKEY *pkey, - STACK_OF(X509) *certs, BIO *data, - unsigned int flags); - -CMS_ContentInfo *CMS_sign_receipt(CMS_SignerInfo *si, - X509 *signcert, EVP_PKEY *pkey, - STACK_OF(X509) *certs, unsigned int flags); - -int CMS_data(CMS_ContentInfo *cms, BIO *out, unsigned int flags); -CMS_ContentInfo *CMS_data_create(BIO *in, unsigned int flags); - -int CMS_digest_verify(CMS_ContentInfo *cms, BIO *dcont, BIO *out, - unsigned int flags); -CMS_ContentInfo *CMS_digest_create(BIO *in, const EVP_MD *md, - unsigned int flags); - -int CMS_EncryptedData_decrypt(CMS_ContentInfo *cms, - const unsigned char *key, size_t keylen, - BIO *dcont, BIO *out, unsigned int flags); - -CMS_ContentInfo *CMS_EncryptedData_encrypt(BIO *in, const EVP_CIPHER *cipher, - const unsigned char *key, - size_t keylen, unsigned int flags); - -int CMS_EncryptedData_set1_key(CMS_ContentInfo *cms, const EVP_CIPHER *ciph, - const unsigned char *key, size_t keylen); - -int CMS_verify(CMS_ContentInfo *cms, STACK_OF(X509) *certs, - X509_STORE *store, BIO *dcont, BIO *out, unsigned int flags); - -int CMS_verify_receipt(CMS_ContentInfo *rcms, CMS_ContentInfo *ocms, - STACK_OF(X509) *certs, - X509_STORE *store, unsigned int flags); - -STACK_OF(X509) *CMS_get0_signers(CMS_ContentInfo *cms); - -CMS_ContentInfo *CMS_encrypt(STACK_OF(X509) *certs, BIO *in, - const EVP_CIPHER *cipher, unsigned int flags); - -int CMS_decrypt(CMS_ContentInfo *cms, EVP_PKEY *pkey, X509 *cert, - BIO *dcont, BIO *out, unsigned int flags); - -int CMS_decrypt_set1_pkey(CMS_ContentInfo *cms, EVP_PKEY *pk, X509 *cert); -int CMS_decrypt_set1_key(CMS_ContentInfo *cms, - unsigned char *key, size_t keylen, - const unsigned char *id, size_t idlen); -int CMS_decrypt_set1_password(CMS_ContentInfo *cms, - unsigned char *pass, ossl_ssize_t passlen); - -STACK_OF(CMS_RecipientInfo) *CMS_get0_RecipientInfos(CMS_ContentInfo *cms); -int CMS_RecipientInfo_type(CMS_RecipientInfo *ri); -EVP_PKEY_CTX *CMS_RecipientInfo_get0_pkey_ctx(CMS_RecipientInfo *ri); -CMS_ContentInfo *CMS_EnvelopedData_create(const EVP_CIPHER *cipher); -CMS_RecipientInfo *CMS_add1_recipient_cert(CMS_ContentInfo *cms, - X509 *recip, unsigned int flags); -int CMS_RecipientInfo_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pkey); -int CMS_RecipientInfo_ktri_cert_cmp(CMS_RecipientInfo *ri, X509 *cert); -int CMS_RecipientInfo_ktri_get0_algs(CMS_RecipientInfo *ri, - EVP_PKEY **pk, X509 **recip, - X509_ALGOR **palg); -int CMS_RecipientInfo_ktri_get0_signer_id(CMS_RecipientInfo *ri, - ASN1_OCTET_STRING **keyid, - X509_NAME **issuer, - ASN1_INTEGER **sno); - -CMS_RecipientInfo *CMS_add0_recipient_key(CMS_ContentInfo *cms, int nid, - unsigned char *key, size_t keylen, - unsigned char *id, size_t idlen, - ASN1_GENERALIZEDTIME *date, - ASN1_OBJECT *otherTypeId, - ASN1_TYPE *otherType); - -int CMS_RecipientInfo_kekri_get0_id(CMS_RecipientInfo *ri, - X509_ALGOR **palg, - ASN1_OCTET_STRING **pid, - ASN1_GENERALIZEDTIME **pdate, - ASN1_OBJECT **potherid, - ASN1_TYPE **pothertype); - -int CMS_RecipientInfo_set0_key(CMS_RecipientInfo *ri, - unsigned char *key, size_t keylen); - -int CMS_RecipientInfo_kekri_id_cmp(CMS_RecipientInfo *ri, - const unsigned char *id, size_t idlen); - -int CMS_RecipientInfo_set0_password(CMS_RecipientInfo *ri, - unsigned char *pass, - ossl_ssize_t passlen); - -CMS_RecipientInfo *CMS_add0_recipient_password(CMS_ContentInfo *cms, - int iter, int wrap_nid, - int pbe_nid, - unsigned char *pass, - ossl_ssize_t passlen, - const EVP_CIPHER *kekciph); - -int CMS_RecipientInfo_decrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri); -int CMS_RecipientInfo_encrypt(CMS_ContentInfo *cms, CMS_RecipientInfo *ri); - -int CMS_uncompress(CMS_ContentInfo *cms, BIO *dcont, BIO *out, - unsigned int flags); -CMS_ContentInfo *CMS_compress(BIO *in, int comp_nid, unsigned int flags); - -int CMS_set1_eContentType(CMS_ContentInfo *cms, const ASN1_OBJECT *oid); -const ASN1_OBJECT *CMS_get0_eContentType(CMS_ContentInfo *cms); - -CMS_CertificateChoices *CMS_add0_CertificateChoices(CMS_ContentInfo *cms); -int CMS_add0_cert(CMS_ContentInfo *cms, X509 *cert); -int CMS_add1_cert(CMS_ContentInfo *cms, X509 *cert); -STACK_OF(X509) *CMS_get1_certs(CMS_ContentInfo *cms); - -CMS_RevocationInfoChoice *CMS_add0_RevocationInfoChoice(CMS_ContentInfo *cms); -int CMS_add0_crl(CMS_ContentInfo *cms, X509_CRL *crl); -int CMS_add1_crl(CMS_ContentInfo *cms, X509_CRL *crl); -STACK_OF(X509_CRL) *CMS_get1_crls(CMS_ContentInfo *cms); - -int CMS_SignedData_init(CMS_ContentInfo *cms); -CMS_SignerInfo *CMS_add1_signer(CMS_ContentInfo *cms, - X509 *signer, EVP_PKEY *pk, const EVP_MD *md, - unsigned int flags); -EVP_PKEY_CTX *CMS_SignerInfo_get0_pkey_ctx(CMS_SignerInfo *si); -EVP_MD_CTX *CMS_SignerInfo_get0_md_ctx(CMS_SignerInfo *si); -STACK_OF(CMS_SignerInfo) *CMS_get0_SignerInfos(CMS_ContentInfo *cms); - -void CMS_SignerInfo_set1_signer_cert(CMS_SignerInfo *si, X509 *signer); -int CMS_SignerInfo_get0_signer_id(CMS_SignerInfo *si, - ASN1_OCTET_STRING **keyid, - X509_NAME **issuer, ASN1_INTEGER **sno); -int CMS_SignerInfo_cert_cmp(CMS_SignerInfo *si, X509 *cert); -int CMS_set1_signers_certs(CMS_ContentInfo *cms, STACK_OF(X509) *certs, - unsigned int flags); -void CMS_SignerInfo_get0_algs(CMS_SignerInfo *si, EVP_PKEY **pk, - X509 **signer, X509_ALGOR **pdig, - X509_ALGOR **psig); -ASN1_OCTET_STRING *CMS_SignerInfo_get0_signature(CMS_SignerInfo *si); -int CMS_SignerInfo_sign(CMS_SignerInfo *si); -int CMS_SignerInfo_verify(CMS_SignerInfo *si); -int CMS_SignerInfo_verify_content(CMS_SignerInfo *si, BIO *chain); - -int CMS_add_smimecap(CMS_SignerInfo *si, STACK_OF(X509_ALGOR) *algs); -int CMS_add_simple_smimecap(STACK_OF(X509_ALGOR) **algs, - int algnid, int keysize); -int CMS_add_standard_smimecap(STACK_OF(X509_ALGOR) **smcap); - -int CMS_signed_get_attr_count(const CMS_SignerInfo *si); -int CMS_signed_get_attr_by_NID(const CMS_SignerInfo *si, int nid, - int lastpos); -int CMS_signed_get_attr_by_OBJ(const CMS_SignerInfo *si, const ASN1_OBJECT *obj, - int lastpos); -X509_ATTRIBUTE *CMS_signed_get_attr(const CMS_SignerInfo *si, int loc); -X509_ATTRIBUTE *CMS_signed_delete_attr(CMS_SignerInfo *si, int loc); -int CMS_signed_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr); -int CMS_signed_add1_attr_by_OBJ(CMS_SignerInfo *si, - const ASN1_OBJECT *obj, int type, - const void *bytes, int len); -int CMS_signed_add1_attr_by_NID(CMS_SignerInfo *si, - int nid, int type, - const void *bytes, int len); -int CMS_signed_add1_attr_by_txt(CMS_SignerInfo *si, - const char *attrname, int type, - const void *bytes, int len); -void *CMS_signed_get0_data_by_OBJ(CMS_SignerInfo *si, const ASN1_OBJECT *oid, - int lastpos, int type); - -int CMS_unsigned_get_attr_count(const CMS_SignerInfo *si); -int CMS_unsigned_get_attr_by_NID(const CMS_SignerInfo *si, int nid, - int lastpos); -int CMS_unsigned_get_attr_by_OBJ(const CMS_SignerInfo *si, - const ASN1_OBJECT *obj, int lastpos); -X509_ATTRIBUTE *CMS_unsigned_get_attr(const CMS_SignerInfo *si, int loc); -X509_ATTRIBUTE *CMS_unsigned_delete_attr(CMS_SignerInfo *si, int loc); -int CMS_unsigned_add1_attr(CMS_SignerInfo *si, X509_ATTRIBUTE *attr); -int CMS_unsigned_add1_attr_by_OBJ(CMS_SignerInfo *si, - const ASN1_OBJECT *obj, int type, - const void *bytes, int len); -int CMS_unsigned_add1_attr_by_NID(CMS_SignerInfo *si, - int nid, int type, - const void *bytes, int len); -int CMS_unsigned_add1_attr_by_txt(CMS_SignerInfo *si, - const char *attrname, int type, - const void *bytes, int len); -void *CMS_unsigned_get0_data_by_OBJ(CMS_SignerInfo *si, ASN1_OBJECT *oid, - int lastpos, int type); - -# ifdef HEADER_X509V3_H - -int CMS_get1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest **prr); -CMS_ReceiptRequest *CMS_ReceiptRequest_create0(unsigned char *id, int idlen, - int allorfirst, - STACK_OF(GENERAL_NAMES) - *receiptList, STACK_OF(GENERAL_NAMES) - *receiptsTo); -int CMS_add1_ReceiptRequest(CMS_SignerInfo *si, CMS_ReceiptRequest *rr); -void CMS_ReceiptRequest_get0_values(CMS_ReceiptRequest *rr, - ASN1_STRING **pcid, - int *pallorfirst, - STACK_OF(GENERAL_NAMES) **plist, - STACK_OF(GENERAL_NAMES) **prto); -# endif -int CMS_RecipientInfo_kari_get0_alg(CMS_RecipientInfo *ri, - X509_ALGOR **palg, - ASN1_OCTET_STRING **pukm); -STACK_OF(CMS_RecipientEncryptedKey) -*CMS_RecipientInfo_kari_get0_reks(CMS_RecipientInfo *ri); - -int CMS_RecipientInfo_kari_get0_orig_id(CMS_RecipientInfo *ri, - X509_ALGOR **pubalg, - ASN1_BIT_STRING **pubkey, - ASN1_OCTET_STRING **keyid, - X509_NAME **issuer, - ASN1_INTEGER **sno); - -int CMS_RecipientInfo_kari_orig_id_cmp(CMS_RecipientInfo *ri, X509 *cert); - -int CMS_RecipientEncryptedKey_get0_id(CMS_RecipientEncryptedKey *rek, - ASN1_OCTET_STRING **keyid, - ASN1_GENERALIZEDTIME **tm, - CMS_OtherKeyAttribute **other, - X509_NAME **issuer, ASN1_INTEGER **sno); -int CMS_RecipientEncryptedKey_cert_cmp(CMS_RecipientEncryptedKey *rek, - X509 *cert); -int CMS_RecipientInfo_kari_set0_pkey(CMS_RecipientInfo *ri, EVP_PKEY *pk); -EVP_CIPHER_CTX *CMS_RecipientInfo_kari_get0_ctx(CMS_RecipientInfo *ri); -int CMS_RecipientInfo_kari_decrypt(CMS_ContentInfo *cms, - CMS_RecipientInfo *ri, - CMS_RecipientEncryptedKey *rek); - -int CMS_SharedInfo_encode(unsigned char **pder, X509_ALGOR *kekalg, - ASN1_OCTET_STRING *ukm, int keylen); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_CMS_strings(void); - -/* Error codes for the CMS functions. */ - -/* Function codes. */ -# define CMS_F_CHECK_CONTENT 99 -# define CMS_F_CMS_ADD0_CERT 164 -# define CMS_F_CMS_ADD0_RECIPIENT_KEY 100 -# define CMS_F_CMS_ADD0_RECIPIENT_PASSWORD 165 -# define CMS_F_CMS_ADD1_RECEIPTREQUEST 158 -# define CMS_F_CMS_ADD1_RECIPIENT_CERT 101 -# define CMS_F_CMS_ADD1_SIGNER 102 -# define CMS_F_CMS_ADD1_SIGNINGTIME 103 -# define CMS_F_CMS_COMPRESS 104 -# define CMS_F_CMS_COMPRESSEDDATA_CREATE 105 -# define CMS_F_CMS_COMPRESSEDDATA_INIT_BIO 106 -# define CMS_F_CMS_COPY_CONTENT 107 -# define CMS_F_CMS_COPY_MESSAGEDIGEST 108 -# define CMS_F_CMS_DATA 109 -# define CMS_F_CMS_DATAFINAL 110 -# define CMS_F_CMS_DATAINIT 111 -# define CMS_F_CMS_DECRYPT 112 -# define CMS_F_CMS_DECRYPT_SET1_KEY 113 -# define CMS_F_CMS_DECRYPT_SET1_PASSWORD 166 -# define CMS_F_CMS_DECRYPT_SET1_PKEY 114 -# define CMS_F_CMS_DIGESTALGORITHM_FIND_CTX 115 -# define CMS_F_CMS_DIGESTALGORITHM_INIT_BIO 116 -# define CMS_F_CMS_DIGESTEDDATA_DO_FINAL 117 -# define CMS_F_CMS_DIGEST_VERIFY 118 -# define CMS_F_CMS_ENCODE_RECEIPT 161 -# define CMS_F_CMS_ENCRYPT 119 -# define CMS_F_CMS_ENCRYPTEDCONTENT_INIT_BIO 120 -# define CMS_F_CMS_ENCRYPTEDDATA_DECRYPT 121 -# define CMS_F_CMS_ENCRYPTEDDATA_ENCRYPT 122 -# define CMS_F_CMS_ENCRYPTEDDATA_SET1_KEY 123 -# define CMS_F_CMS_ENVELOPEDDATA_CREATE 124 -# define CMS_F_CMS_ENVELOPEDDATA_INIT_BIO 125 -# define CMS_F_CMS_ENVELOPED_DATA_INIT 126 -# define CMS_F_CMS_ENV_ASN1_CTRL 171 -# define CMS_F_CMS_FINAL 127 -# define CMS_F_CMS_GET0_CERTIFICATE_CHOICES 128 -# define CMS_F_CMS_GET0_CONTENT 129 -# define CMS_F_CMS_GET0_ECONTENT_TYPE 130 -# define CMS_F_CMS_GET0_ENVELOPED 131 -# define CMS_F_CMS_GET0_REVOCATION_CHOICES 132 -# define CMS_F_CMS_GET0_SIGNED 133 -# define CMS_F_CMS_MSGSIGDIGEST_ADD1 162 -# define CMS_F_CMS_RECEIPTREQUEST_CREATE0 159 -# define CMS_F_CMS_RECEIPT_VERIFY 160 -# define CMS_F_CMS_RECIPIENTINFO_DECRYPT 134 -# define CMS_F_CMS_RECIPIENTINFO_ENCRYPT 169 -# define CMS_F_CMS_RECIPIENTINFO_KARI_ENCRYPT 178 -# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ALG 175 -# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_ORIG_ID 173 -# define CMS_F_CMS_RECIPIENTINFO_KARI_GET0_REKS 172 -# define CMS_F_CMS_RECIPIENTINFO_KARI_ORIG_ID_CMP 174 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_DECRYPT 135 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ENCRYPT 136 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_GET0_ID 137 -# define CMS_F_CMS_RECIPIENTINFO_KEKRI_ID_CMP 138 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_CERT_CMP 139 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_DECRYPT 140 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_ENCRYPT 141 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_ALGS 142 -# define CMS_F_CMS_RECIPIENTINFO_KTRI_GET0_SIGNER_ID 143 -# define CMS_F_CMS_RECIPIENTINFO_PWRI_CRYPT 167 -# define CMS_F_CMS_RECIPIENTINFO_SET0_KEY 144 -# define CMS_F_CMS_RECIPIENTINFO_SET0_PASSWORD 168 -# define CMS_F_CMS_RECIPIENTINFO_SET0_PKEY 145 -# define CMS_F_CMS_SD_ASN1_CTRL 170 -# define CMS_F_CMS_SET1_IAS 176 -# define CMS_F_CMS_SET1_KEYID 177 -# define CMS_F_CMS_SET1_SIGNERIDENTIFIER 146 -# define CMS_F_CMS_SET_DETACHED 147 -# define CMS_F_CMS_SIGN 148 -# define CMS_F_CMS_SIGNED_DATA_INIT 149 -# define CMS_F_CMS_SIGNERINFO_CONTENT_SIGN 150 -# define CMS_F_CMS_SIGNERINFO_SIGN 151 -# define CMS_F_CMS_SIGNERINFO_VERIFY 152 -# define CMS_F_CMS_SIGNERINFO_VERIFY_CERT 153 -# define CMS_F_CMS_SIGNERINFO_VERIFY_CONTENT 154 -# define CMS_F_CMS_SIGN_RECEIPT 163 -# define CMS_F_CMS_STREAM 155 -# define CMS_F_CMS_UNCOMPRESS 156 -# define CMS_F_CMS_VERIFY 157 - -/* Reason codes. */ -# define CMS_R_ADD_SIGNER_ERROR 99 -# define CMS_R_CERTIFICATE_ALREADY_PRESENT 175 -# define CMS_R_CERTIFICATE_HAS_NO_KEYID 160 -# define CMS_R_CERTIFICATE_VERIFY_ERROR 100 -# define CMS_R_CIPHER_INITIALISATION_ERROR 101 -# define CMS_R_CIPHER_PARAMETER_INITIALISATION_ERROR 102 -# define CMS_R_CMS_DATAFINAL_ERROR 103 -# define CMS_R_CMS_LIB 104 -# define CMS_R_CONTENTIDENTIFIER_MISMATCH 170 -# define CMS_R_CONTENT_NOT_FOUND 105 -# define CMS_R_CONTENT_TYPE_MISMATCH 171 -# define CMS_R_CONTENT_TYPE_NOT_COMPRESSED_DATA 106 -# define CMS_R_CONTENT_TYPE_NOT_ENVELOPED_DATA 107 -# define CMS_R_CONTENT_TYPE_NOT_SIGNED_DATA 108 -# define CMS_R_CONTENT_VERIFY_ERROR 109 -# define CMS_R_CTRL_ERROR 110 -# define CMS_R_CTRL_FAILURE 111 -# define CMS_R_DECRYPT_ERROR 112 -# define CMS_R_ERROR_GETTING_PUBLIC_KEY 113 -# define CMS_R_ERROR_READING_MESSAGEDIGEST_ATTRIBUTE 114 -# define CMS_R_ERROR_SETTING_KEY 115 -# define CMS_R_ERROR_SETTING_RECIPIENTINFO 116 -# define CMS_R_INVALID_ENCRYPTED_KEY_LENGTH 117 -# define CMS_R_INVALID_KEY_ENCRYPTION_PARAMETER 176 -# define CMS_R_INVALID_KEY_LENGTH 118 -# define CMS_R_MD_BIO_INIT_ERROR 119 -# define CMS_R_MESSAGEDIGEST_ATTRIBUTE_WRONG_LENGTH 120 -# define CMS_R_MESSAGEDIGEST_WRONG_LENGTH 121 -# define CMS_R_MSGSIGDIGEST_ERROR 172 -# define CMS_R_MSGSIGDIGEST_VERIFICATION_FAILURE 162 -# define CMS_R_MSGSIGDIGEST_WRONG_LENGTH 163 -# define CMS_R_NEED_ONE_SIGNER 164 -# define CMS_R_NOT_A_SIGNED_RECEIPT 165 -# define CMS_R_NOT_ENCRYPTED_DATA 122 -# define CMS_R_NOT_KEK 123 -# define CMS_R_NOT_KEY_AGREEMENT 181 -# define CMS_R_NOT_KEY_TRANSPORT 124 -# define CMS_R_NOT_PWRI 177 -# define CMS_R_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 125 -# define CMS_R_NO_CIPHER 126 -# define CMS_R_NO_CONTENT 127 -# define CMS_R_NO_CONTENT_TYPE 173 -# define CMS_R_NO_DEFAULT_DIGEST 128 -# define CMS_R_NO_DIGEST_SET 129 -# define CMS_R_NO_KEY 130 -# define CMS_R_NO_KEY_OR_CERT 174 -# define CMS_R_NO_MATCHING_DIGEST 131 -# define CMS_R_NO_MATCHING_RECIPIENT 132 -# define CMS_R_NO_MATCHING_SIGNATURE 166 -# define CMS_R_NO_MSGSIGDIGEST 167 -# define CMS_R_NO_PASSWORD 178 -# define CMS_R_NO_PRIVATE_KEY 133 -# define CMS_R_NO_PUBLIC_KEY 134 -# define CMS_R_NO_RECEIPT_REQUEST 168 -# define CMS_R_NO_SIGNERS 135 -# define CMS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 136 -# define CMS_R_RECEIPT_DECODE_ERROR 169 -# define CMS_R_RECIPIENT_ERROR 137 -# define CMS_R_SIGNER_CERTIFICATE_NOT_FOUND 138 -# define CMS_R_SIGNFINAL_ERROR 139 -# define CMS_R_SMIME_TEXT_ERROR 140 -# define CMS_R_STORE_INIT_ERROR 141 -# define CMS_R_TYPE_NOT_COMPRESSED_DATA 142 -# define CMS_R_TYPE_NOT_DATA 143 -# define CMS_R_TYPE_NOT_DIGESTED_DATA 144 -# define CMS_R_TYPE_NOT_ENCRYPTED_DATA 145 -# define CMS_R_TYPE_NOT_ENVELOPED_DATA 146 -# define CMS_R_UNABLE_TO_FINALIZE_CONTEXT 147 -# define CMS_R_UNKNOWN_CIPHER 148 -# define CMS_R_UNKNOWN_DIGEST_ALGORIHM 149 -# define CMS_R_UNKNOWN_ID 150 -# define CMS_R_UNSUPPORTED_COMPRESSION_ALGORITHM 151 -# define CMS_R_UNSUPPORTED_CONTENT_TYPE 152 -# define CMS_R_UNSUPPORTED_KEK_ALGORITHM 153 -# define CMS_R_UNSUPPORTED_KEY_ENCRYPTION_ALGORITHM 179 -# define CMS_R_UNSUPPORTED_RECIPIENT_TYPE 154 -# define CMS_R_UNSUPPORTED_RECPIENTINFO_TYPE 155 -# define CMS_R_UNSUPPORTED_TYPE 156 -# define CMS_R_UNWRAP_ERROR 157 -# define CMS_R_UNWRAP_FAILURE 180 -# define CMS_R_VERIFICATION_FAILURE 158 -# define CMS_R_WRAP_ERROR 159 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/comp.h b/android/armeabi/include/openssl/comp.h deleted file mode 100644 index 260ff1e0..00000000 --- a/android/armeabi/include/openssl/comp.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_COMP_H -# define HEADER_COMP_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_COMP -# include <openssl/crypto.h> -# ifdef __cplusplus -extern "C" { -# endif - - - -COMP_CTX *COMP_CTX_new(COMP_METHOD *meth); -const COMP_METHOD *COMP_CTX_get_method(const COMP_CTX *ctx); -int COMP_CTX_get_type(const COMP_CTX* comp); -int COMP_get_type(const COMP_METHOD *meth); -const char *COMP_get_name(const COMP_METHOD *meth); -void COMP_CTX_free(COMP_CTX *ctx); - -int COMP_compress_block(COMP_CTX *ctx, unsigned char *out, int olen, - unsigned char *in, int ilen); -int COMP_expand_block(COMP_CTX *ctx, unsigned char *out, int olen, - unsigned char *in, int ilen); - -COMP_METHOD *COMP_zlib(void); - -#if OPENSSL_API_COMPAT < 0x10100000L -#define COMP_zlib_cleanup() while(0) continue -#endif - -# ifdef HEADER_BIO_H -# ifdef ZLIB -const BIO_METHOD *BIO_f_zlib(void); -# endif -# endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_COMP_strings(void); - -/* Error codes for the COMP functions. */ - -/* Function codes. */ -# define COMP_F_BIO_ZLIB_FLUSH 99 -# define COMP_F_BIO_ZLIB_NEW 100 -# define COMP_F_BIO_ZLIB_READ 101 -# define COMP_F_BIO_ZLIB_WRITE 102 - -/* Reason codes. */ -# define COMP_R_ZLIB_DEFLATE_ERROR 99 -# define COMP_R_ZLIB_INFLATE_ERROR 100 -# define COMP_R_ZLIB_NOT_SUPPORTED 101 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/conf.h b/android/armeabi/include/openssl/conf.h deleted file mode 100644 index 462e3c9d..00000000 --- a/android/armeabi/include/openssl/conf.h +++ /dev/null @@ -1,216 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CONF_H -# define HEADER_CONF_H - -# include <openssl/bio.h> -# include <openssl/lhash.h> -# include <openssl/stack.h> -# include <openssl/safestack.h> -# include <openssl/e_os2.h> - -# include <openssl/ossl_typ.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct { - char *section; - char *name; - char *value; -} CONF_VALUE; - -DEFINE_STACK_OF(CONF_VALUE) -DEFINE_LHASH_OF(CONF_VALUE); - -struct conf_st; -struct conf_method_st; -typedef struct conf_method_st CONF_METHOD; - -struct conf_method_st { - const char *name; - CONF *(*create) (CONF_METHOD *meth); - int (*init) (CONF *conf); - int (*destroy) (CONF *conf); - int (*destroy_data) (CONF *conf); - int (*load_bio) (CONF *conf, BIO *bp, long *eline); - int (*dump) (const CONF *conf, BIO *bp); - int (*is_number) (const CONF *conf, char c); - int (*to_int) (const CONF *conf, char c); - int (*load) (CONF *conf, const char *name, long *eline); -}; - -/* Module definitions */ - -typedef struct conf_imodule_st CONF_IMODULE; -typedef struct conf_module_st CONF_MODULE; - -DEFINE_STACK_OF(CONF_MODULE) -DEFINE_STACK_OF(CONF_IMODULE) - -/* DSO module function typedefs */ -typedef int conf_init_func (CONF_IMODULE *md, const CONF *cnf); -typedef void conf_finish_func (CONF_IMODULE *md); - -# define CONF_MFLAGS_IGNORE_ERRORS 0x1 -# define CONF_MFLAGS_IGNORE_RETURN_CODES 0x2 -# define CONF_MFLAGS_SILENT 0x4 -# define CONF_MFLAGS_NO_DSO 0x8 -# define CONF_MFLAGS_IGNORE_MISSING_FILE 0x10 -# define CONF_MFLAGS_DEFAULT_SECTION 0x20 - -int CONF_set_default_method(CONF_METHOD *meth); -void CONF_set_nconf(CONF *conf, LHASH_OF(CONF_VALUE) *hash); -LHASH_OF(CONF_VALUE) *CONF_load(LHASH_OF(CONF_VALUE) *conf, const char *file, - long *eline); -# ifndef OPENSSL_NO_STDIO -LHASH_OF(CONF_VALUE) *CONF_load_fp(LHASH_OF(CONF_VALUE) *conf, FILE *fp, - long *eline); -# endif -LHASH_OF(CONF_VALUE) *CONF_load_bio(LHASH_OF(CONF_VALUE) *conf, BIO *bp, - long *eline); -STACK_OF(CONF_VALUE) *CONF_get_section(LHASH_OF(CONF_VALUE) *conf, - const char *section); -char *CONF_get_string(LHASH_OF(CONF_VALUE) *conf, const char *group, - const char *name); -long CONF_get_number(LHASH_OF(CONF_VALUE) *conf, const char *group, - const char *name); -void CONF_free(LHASH_OF(CONF_VALUE) *conf); -#ifndef OPENSSL_NO_STDIO -int CONF_dump_fp(LHASH_OF(CONF_VALUE) *conf, FILE *out); -#endif -int CONF_dump_bio(LHASH_OF(CONF_VALUE) *conf, BIO *out); - -DEPRECATEDIN_1_1_0(void OPENSSL_config(const char *config_name)) - -#if OPENSSL_API_COMPAT < 0x10100000L -# define OPENSSL_no_config() \ - OPENSSL_init_crypto(OPENSSL_INIT_NO_LOAD_CONFIG, NULL) -#endif - -/* - * New conf code. The semantics are different from the functions above. If - * that wasn't the case, the above functions would have been replaced - */ - -struct conf_st { - CONF_METHOD *meth; - void *meth_data; - LHASH_OF(CONF_VALUE) *data; -}; - -CONF *NCONF_new(CONF_METHOD *meth); -CONF_METHOD *NCONF_default(void); -CONF_METHOD *NCONF_WIN32(void); -void NCONF_free(CONF *conf); -void NCONF_free_data(CONF *conf); - -int NCONF_load(CONF *conf, const char *file, long *eline); -# ifndef OPENSSL_NO_STDIO -int NCONF_load_fp(CONF *conf, FILE *fp, long *eline); -# endif -int NCONF_load_bio(CONF *conf, BIO *bp, long *eline); -STACK_OF(CONF_VALUE) *NCONF_get_section(const CONF *conf, - const char *section); -char *NCONF_get_string(const CONF *conf, const char *group, const char *name); -int NCONF_get_number_e(const CONF *conf, const char *group, const char *name, - long *result); -#ifndef OPENSSL_NO_STDIO -int NCONF_dump_fp(const CONF *conf, FILE *out); -#endif -int NCONF_dump_bio(const CONF *conf, BIO *out); - -#define NCONF_get_number(c,g,n,r) NCONF_get_number_e(c,g,n,r) - -/* Module functions */ - -int CONF_modules_load(const CONF *cnf, const char *appname, - unsigned long flags); -int CONF_modules_load_file(const char *filename, const char *appname, - unsigned long flags); -void CONF_modules_unload(int all); -void CONF_modules_finish(void); -#if OPENSSL_API_COMPAT < 0x10100000L -# define CONF_modules_free() while(0) continue -#endif -int CONF_module_add(const char *name, conf_init_func *ifunc, - conf_finish_func *ffunc); - -const char *CONF_imodule_get_name(const CONF_IMODULE *md); -const char *CONF_imodule_get_value(const CONF_IMODULE *md); -void *CONF_imodule_get_usr_data(const CONF_IMODULE *md); -void CONF_imodule_set_usr_data(CONF_IMODULE *md, void *usr_data); -CONF_MODULE *CONF_imodule_get_module(const CONF_IMODULE *md); -unsigned long CONF_imodule_get_flags(const CONF_IMODULE *md); -void CONF_imodule_set_flags(CONF_IMODULE *md, unsigned long flags); -void *CONF_module_get_usr_data(CONF_MODULE *pmod); -void CONF_module_set_usr_data(CONF_MODULE *pmod, void *usr_data); - -char *CONF_get1_default_config_file(void); - -int CONF_parse_list(const char *list, int sep, int nospc, - int (*list_cb) (const char *elem, int len, void *usr), - void *arg); - -void OPENSSL_load_builtin_modules(void); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_CONF_strings(void); - -/* Error codes for the CONF functions. */ - -/* Function codes. */ -# define CONF_F_CONF_DUMP_FP 104 -# define CONF_F_CONF_LOAD 100 -# define CONF_F_CONF_LOAD_FP 103 -# define CONF_F_CONF_PARSE_LIST 119 -# define CONF_F_DEF_LOAD 120 -# define CONF_F_DEF_LOAD_BIO 121 -# define CONF_F_MODULE_INIT 115 -# define CONF_F_MODULE_LOAD_DSO 117 -# define CONF_F_MODULE_RUN 118 -# define CONF_F_NCONF_DUMP_BIO 105 -# define CONF_F_NCONF_DUMP_FP 106 -# define CONF_F_NCONF_GET_NUMBER_E 112 -# define CONF_F_NCONF_GET_SECTION 108 -# define CONF_F_NCONF_GET_STRING 109 -# define CONF_F_NCONF_LOAD 113 -# define CONF_F_NCONF_LOAD_BIO 110 -# define CONF_F_NCONF_LOAD_FP 114 -# define CONF_F_NCONF_NEW 111 -# define CONF_F_STR_COPY 101 - -/* Reason codes. */ -# define CONF_R_ERROR_LOADING_DSO 110 -# define CONF_R_LIST_CANNOT_BE_NULL 115 -# define CONF_R_MISSING_CLOSE_SQUARE_BRACKET 100 -# define CONF_R_MISSING_EQUAL_SIGN 101 -# define CONF_R_MISSING_INIT_FUNCTION 112 -# define CONF_R_MODULE_INITIALIZATION_ERROR 109 -# define CONF_R_NO_CLOSE_BRACE 102 -# define CONF_R_NO_CONF 105 -# define CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE 106 -# define CONF_R_NO_SECTION 107 -# define CONF_R_NO_SUCH_FILE 114 -# define CONF_R_NO_VALUE 108 -# define CONF_R_UNABLE_TO_CREATE_NEW_SECTION 103 -# define CONF_R_UNKNOWN_MODULE_NAME 113 -# define CONF_R_VARIABLE_HAS_NO_VALUE 104 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/conf_api.h b/android/armeabi/include/openssl/conf_api.h deleted file mode 100644 index a0275ad7..00000000 --- a/android/armeabi/include/openssl/conf_api.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CONF_API_H -# define HEADER_CONF_API_H - -# include <openssl/lhash.h> -# include <openssl/conf.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* Up until OpenSSL 0.9.5a, this was new_section */ -CONF_VALUE *_CONF_new_section(CONF *conf, const char *section); -/* Up until OpenSSL 0.9.5a, this was get_section */ -CONF_VALUE *_CONF_get_section(const CONF *conf, const char *section); -/* Up until OpenSSL 0.9.5a, this was CONF_get_section */ -STACK_OF(CONF_VALUE) *_CONF_get_section_values(const CONF *conf, - const char *section); - -int _CONF_add_string(CONF *conf, CONF_VALUE *section, CONF_VALUE *value); -char *_CONF_get_string(const CONF *conf, const char *section, - const char *name); -long _CONF_get_number(const CONF *conf, const char *section, - const char *name); - -int _CONF_new_data(CONF *conf); -void _CONF_free_data(CONF *conf); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/android/armeabi/include/openssl/crypto.h b/android/armeabi/include/openssl/crypto.h deleted file mode 100644 index bd0b1408..00000000 --- a/android/armeabi/include/openssl/crypto.h +++ /dev/null @@ -1,463 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECDH support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_CRYPTO_H -# define HEADER_CRYPTO_H - -# include <stdlib.h> -# include <time.h> - -# include <openssl/e_os2.h> - -# ifndef OPENSSL_NO_STDIO -# include <stdio.h> -# endif - -# include <openssl/stack.h> -# include <openssl/safestack.h> -# include <openssl/opensslv.h> -# include <openssl/ossl_typ.h> -# include <openssl/opensslconf.h> - -# ifdef CHARSET_EBCDIC -# include <openssl/ebcdic.h> -# endif - -/* - * Resolve problems on some operating systems with symbol names that clash - * one way or another - */ -# include <openssl/symhacks.h> - -# if OPENSSL_API_COMPAT < 0x10100000L -# include <openssl/opensslv.h> -# endif - -#ifdef __cplusplus -extern "C" { -#endif - -# if OPENSSL_API_COMPAT < 0x10100000L -# define SSLeay OpenSSL_version_num -# define SSLeay_version OpenSSL_version -# define SSLEAY_VERSION_NUMBER OPENSSL_VERSION_NUMBER -# define SSLEAY_VERSION OPENSSL_VERSION -# define SSLEAY_CFLAGS OPENSSL_CFLAGS -# define SSLEAY_BUILT_ON OPENSSL_BUILT_ON -# define SSLEAY_PLATFORM OPENSSL_PLATFORM -# define SSLEAY_DIR OPENSSL_DIR - -/* - * Old type for allocating dynamic locks. No longer used. Use the new thread - * API instead. - */ -typedef struct { - int dummy; -} CRYPTO_dynlock; - -# endif /* OPENSSL_API_COMPAT */ - -typedef void CRYPTO_RWLOCK; - -CRYPTO_RWLOCK *CRYPTO_THREAD_lock_new(void); -int CRYPTO_THREAD_read_lock(CRYPTO_RWLOCK *lock); -int CRYPTO_THREAD_write_lock(CRYPTO_RWLOCK *lock); -int CRYPTO_THREAD_unlock(CRYPTO_RWLOCK *lock); -void CRYPTO_THREAD_lock_free(CRYPTO_RWLOCK *lock); - -int CRYPTO_atomic_add(int *val, int amount, int *ret, CRYPTO_RWLOCK *lock); - -/* - * The following can be used to detect memory leaks in the library. If - * used, it turns on malloc checking - */ -# define CRYPTO_MEM_CHECK_OFF 0x0 /* Control only */ -# define CRYPTO_MEM_CHECK_ON 0x1 /* Control and mode bit */ -# define CRYPTO_MEM_CHECK_ENABLE 0x2 /* Control and mode bit */ -# define CRYPTO_MEM_CHECK_DISABLE 0x3 /* Control only */ - -struct crypto_ex_data_st { - STACK_OF(void) *sk; -}; -DEFINE_STACK_OF(void) - -/* - * Per class, we have a STACK of function pointers. - */ -# define CRYPTO_EX_INDEX_SSL 0 -# define CRYPTO_EX_INDEX_SSL_CTX 1 -# define CRYPTO_EX_INDEX_SSL_SESSION 2 -# define CRYPTO_EX_INDEX_X509 3 -# define CRYPTO_EX_INDEX_X509_STORE 4 -# define CRYPTO_EX_INDEX_X509_STORE_CTX 5 -# define CRYPTO_EX_INDEX_DH 6 -# define CRYPTO_EX_INDEX_DSA 7 -# define CRYPTO_EX_INDEX_EC_KEY 8 -# define CRYPTO_EX_INDEX_RSA 9 -# define CRYPTO_EX_INDEX_ENGINE 10 -# define CRYPTO_EX_INDEX_UI 11 -# define CRYPTO_EX_INDEX_BIO 12 -# define CRYPTO_EX_INDEX_APP 13 -# define CRYPTO_EX_INDEX__COUNT 14 - -/* - * This is the default callbacks, but we can have others as well: this is - * needed in Win32 where the application malloc and the library malloc may - * not be the same. - */ -#define OPENSSL_malloc_init() \ - CRYPTO_set_mem_functions(CRYPTO_malloc, CRYPTO_realloc, CRYPTO_free) - -int CRYPTO_mem_ctrl(int mode); - -# define OPENSSL_malloc(num) \ - CRYPTO_malloc(num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_zalloc(num) \ - CRYPTO_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_realloc(addr, num) \ - CRYPTO_realloc(addr, num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_clear_realloc(addr, old_num, num) \ - CRYPTO_clear_realloc(addr, old_num, num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_clear_free(addr, num) \ - CRYPTO_clear_free(addr, num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_free(addr) \ - CRYPTO_free(addr, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_memdup(str, s) \ - CRYPTO_memdup((str), s, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_strdup(str) \ - CRYPTO_strdup(str, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_strndup(str, n) \ - CRYPTO_strndup(str, n, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_secure_malloc(num) \ - CRYPTO_secure_malloc(num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_secure_zalloc(num) \ - CRYPTO_secure_zalloc(num, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_secure_free(addr) \ - CRYPTO_secure_free(addr, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_secure_actual_size(ptr) \ - CRYPTO_secure_actual_size(ptr) - -size_t OPENSSL_strlcpy(char *dst, const char *src, size_t siz); -size_t OPENSSL_strlcat(char *dst, const char *src, size_t siz); -size_t OPENSSL_strnlen(const char *str, size_t maxlen); -char *OPENSSL_buf2hexstr(const unsigned char *buffer, long len); -unsigned char *OPENSSL_hexstr2buf(const char *str, long *len); -int OPENSSL_hexchar2int(unsigned char c); - -# define OPENSSL_MALLOC_MAX_NELEMS(type) (((1U<<(sizeof(int)*8-1))-1)/sizeof(type)) - -unsigned long OpenSSL_version_num(void); -const char *OpenSSL_version(int type); -# define OPENSSL_VERSION 0 -# define OPENSSL_CFLAGS 1 -# define OPENSSL_BUILT_ON 2 -# define OPENSSL_PLATFORM 3 -# define OPENSSL_DIR 4 -# define OPENSSL_ENGINES_DIR 5 - -int OPENSSL_issetugid(void); - -typedef void CRYPTO_EX_new (void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); -typedef void CRYPTO_EX_free (void *parent, void *ptr, CRYPTO_EX_DATA *ad, - int idx, long argl, void *argp); -typedef int CRYPTO_EX_dup (CRYPTO_EX_DATA *to, const CRYPTO_EX_DATA *from, - void *srcp, int idx, long argl, void *argp); -__owur int CRYPTO_get_ex_new_index(int class_index, long argl, void *argp, - CRYPTO_EX_new *new_func, CRYPTO_EX_dup *dup_func, - CRYPTO_EX_free *free_func); -/* No longer use an index. */ -int CRYPTO_free_ex_index(int class_index, int idx); - -/* - * Initialise/duplicate/free CRYPTO_EX_DATA variables corresponding to a - * given class (invokes whatever per-class callbacks are applicable) - */ -int CRYPTO_new_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); -int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA *to, - const CRYPTO_EX_DATA *from); - -void CRYPTO_free_ex_data(int class_index, void *obj, CRYPTO_EX_DATA *ad); - -/* - * Get/set data in a CRYPTO_EX_DATA variable corresponding to a particular - * index (relative to the class type involved) - */ -int CRYPTO_set_ex_data(CRYPTO_EX_DATA *ad, int idx, void *val); -void *CRYPTO_get_ex_data(const CRYPTO_EX_DATA *ad, int idx); - -# if OPENSSL_API_COMPAT < 0x10100000L -/* - * This function cleans up all "ex_data" state. It mustn't be called under - * potential race-conditions. - */ -# define CRYPTO_cleanup_all_ex_data() while(0) continue - -/* - * The old locking functions have been removed completely without compatibility - * macros. This is because the old functions either could not properly report - * errors, or the returned error values were not clearly documented. - * Replacing the locking functions with with no-ops would cause race condition - * issues in the affected applications. It is far better for them to fail at - * compile time. - * On the other hand, the locking callbacks are no longer used. Consequently, - * the callback management functions can be safely replaced with no-op macros. - */ -# define CRYPTO_num_locks() (1) -# define CRYPTO_set_locking_callback(func) -# define CRYPTO_get_locking_callback() (NULL) -# define CRYPTO_set_add_lock_callback(func) -# define CRYPTO_get_add_lock_callback() (NULL) - -/* - * These defines where used in combination with the old locking callbacks, - * they are not called anymore, but old code that's not called might still - * use them. - */ -# define CRYPTO_LOCK 1 -# define CRYPTO_UNLOCK 2 -# define CRYPTO_READ 4 -# define CRYPTO_WRITE 8 - -/* This structure is no longer used */ -typedef struct crypto_threadid_st { - int dummy; -} CRYPTO_THREADID; -/* Only use CRYPTO_THREADID_set_[numeric|pointer]() within callbacks */ -# define CRYPTO_THREADID_set_numeric(id, val) -# define CRYPTO_THREADID_set_pointer(id, ptr) -# define CRYPTO_THREADID_set_callback(threadid_func) (0) -# define CRYPTO_THREADID_get_callback() (NULL) -# define CRYPTO_THREADID_current(id) -# define CRYPTO_THREADID_cmp(a, b) (-1) -# define CRYPTO_THREADID_cpy(dest, src) -# define CRYPTO_THREADID_hash(id) (0UL) - -# if OPENSSL_API_COMPAT < 0x10000000L -# define CRYPTO_set_id_callback(func) -# define CRYPTO_get_id_callback() (NULL) -# define CRYPTO_thread_id() (0UL) -# endif /* OPENSSL_API_COMPAT < 0x10000000L */ - -# define CRYPTO_set_dynlock_create_callback(dyn_create_function) -# define CRYPTO_set_dynlock_lock_callback(dyn_lock_function) -# define CRYPTO_set_dynlock_destroy_callback(dyn_destroy_function) -# define CRYPTO_get_dynlock_create_callback() (NULL) -# define CRYPTO_get_dynlock_lock_callback() (NULL) -# define CRYPTO_get_dynlock_destroy_callback() (NULL) -# endif /* OPENSSL_API_COMPAT < 0x10100000L */ - -int CRYPTO_set_mem_functions( - void *(*m) (size_t, const char *, int), - void *(*r) (void *, size_t, const char *, int), - void (*f) (void *, const char *, int)); -int CRYPTO_set_mem_debug(int flag); -void CRYPTO_get_mem_functions( - void *(**m) (size_t, const char *, int), - void *(**r) (void *, size_t, const char *, int), - void (**f) (void *, const char *, int)); - -void *CRYPTO_malloc(size_t num, const char *file, int line); -void *CRYPTO_zalloc(size_t num, const char *file, int line); -void *CRYPTO_memdup(const void *str, size_t siz, const char *file, int line); -char *CRYPTO_strdup(const char *str, const char *file, int line); -char *CRYPTO_strndup(const char *str, size_t s, const char *file, int line); -void CRYPTO_free(void *ptr, const char *file, int line); -void CRYPTO_clear_free(void *ptr, size_t num, const char *file, int line); -void *CRYPTO_realloc(void *addr, size_t num, const char *file, int line); -void *CRYPTO_clear_realloc(void *addr, size_t old_num, size_t num, - const char *file, int line); - -int CRYPTO_secure_malloc_init(size_t sz, int minsize); -int CRYPTO_secure_malloc_done(void); -void *CRYPTO_secure_malloc(size_t num, const char *file, int line); -void *CRYPTO_secure_zalloc(size_t num, const char *file, int line); -void CRYPTO_secure_free(void *ptr, const char *file, int line); -int CRYPTO_secure_allocated(const void *ptr); -int CRYPTO_secure_malloc_initialized(void); -size_t CRYPTO_secure_actual_size(void *ptr); -size_t CRYPTO_secure_used(void); - -void OPENSSL_cleanse(void *ptr, size_t len); - -# ifndef OPENSSL_NO_CRYPTO_MDEBUG -# define OPENSSL_mem_debug_push(info) \ - CRYPTO_mem_debug_push(info, OPENSSL_FILE, OPENSSL_LINE) -# define OPENSSL_mem_debug_pop() \ - CRYPTO_mem_debug_pop() -int CRYPTO_mem_debug_push(const char *info, const char *file, int line); -int CRYPTO_mem_debug_pop(void); - -/*- - * Debugging functions (enabled by CRYPTO_set_mem_debug(1)) - * The flag argument has the following significance: - * 0: called before the actual memory allocation has taken place - * 1: called after the actual memory allocation has taken place - */ -void CRYPTO_mem_debug_malloc(void *addr, size_t num, int flag, - const char *file, int line); -void CRYPTO_mem_debug_realloc(void *addr1, void *addr2, size_t num, int flag, - const char *file, int line); -void CRYPTO_mem_debug_free(void *addr, int flag, - const char *file, int line); - -# ifndef OPENSSL_NO_STDIO -int CRYPTO_mem_leaks_fp(FILE *); -# endif -int CRYPTO_mem_leaks(BIO *bio); -# endif - -/* die if we have to */ -ossl_noreturn void OPENSSL_die(const char *assertion, const char *file, int line); -# if OPENSSL_API_COMPAT < 0x10100000L -# define OpenSSLDie(f,l,a) OPENSSL_die((a),(f),(l)) -# endif -# define OPENSSL_assert(e) \ - (void)((e) ? 0 : (OPENSSL_die("assertion failed: " #e, OPENSSL_FILE, OPENSSL_LINE), 1)) - -int OPENSSL_isservice(void); - -int FIPS_mode(void); -int FIPS_mode_set(int r); - -void OPENSSL_init(void); - -struct tm *OPENSSL_gmtime(const time_t *timer, struct tm *result); -int OPENSSL_gmtime_adj(struct tm *tm, int offset_day, long offset_sec); -int OPENSSL_gmtime_diff(int *pday, int *psec, - const struct tm *from, const struct tm *to); - -/* - * CRYPTO_memcmp returns zero iff the |len| bytes at |a| and |b| are equal. - * It takes an amount of time dependent on |len|, but independent of the - * contents of |a| and |b|. Unlike memcmp, it cannot be used to put elements - * into a defined order as the return value when a != b is undefined, other - * than to be non-zero. - */ -int CRYPTO_memcmp(const volatile void * volatile in_a, - const volatile void * volatile in_b, - size_t len); - -/* Standard initialisation options */ -# define OPENSSL_INIT_NO_LOAD_CRYPTO_STRINGS 0x00000001L -# define OPENSSL_INIT_LOAD_CRYPTO_STRINGS 0x00000002L -# define OPENSSL_INIT_ADD_ALL_CIPHERS 0x00000004L -# define OPENSSL_INIT_ADD_ALL_DIGESTS 0x00000008L -# define OPENSSL_INIT_NO_ADD_ALL_CIPHERS 0x00000010L -# define OPENSSL_INIT_NO_ADD_ALL_DIGESTS 0x00000020L -# define OPENSSL_INIT_LOAD_CONFIG 0x00000040L -# define OPENSSL_INIT_NO_LOAD_CONFIG 0x00000080L -# define OPENSSL_INIT_ASYNC 0x00000100L -# define OPENSSL_INIT_ENGINE_RDRAND 0x00000200L -# define OPENSSL_INIT_ENGINE_DYNAMIC 0x00000400L -# define OPENSSL_INIT_ENGINE_OPENSSL 0x00000800L -# define OPENSSL_INIT_ENGINE_CRYPTODEV 0x00001000L -# define OPENSSL_INIT_ENGINE_CAPI 0x00002000L -# define OPENSSL_INIT_ENGINE_PADLOCK 0x00004000L -# define OPENSSL_INIT_ENGINE_AFALG 0x00008000L -/* OPENSSL_INIT flag 0x00010000 reserved for internal use */ -/* OPENSSL_INIT flag range 0xfff00000 reserved for OPENSSL_init_ssl() */ -/* Max OPENSSL_INIT flag value is 0x80000000 */ - -/* openssl and dasync not counted as builtin */ -# define OPENSSL_INIT_ENGINE_ALL_BUILTIN \ - (OPENSSL_INIT_ENGINE_RDRAND | OPENSSL_INIT_ENGINE_DYNAMIC \ - | OPENSSL_INIT_ENGINE_CRYPTODEV | OPENSSL_INIT_ENGINE_CAPI | \ - OPENSSL_INIT_ENGINE_PADLOCK) - - -/* Library initialisation functions */ -void OPENSSL_cleanup(void); -int OPENSSL_init_crypto(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); -int OPENSSL_atexit(void (*handler)(void)); -void OPENSSL_thread_stop(void); - -/* Low-level control of initialization */ -OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void); -# ifndef OPENSSL_NO_STDIO -int OPENSSL_INIT_set_config_appname(OPENSSL_INIT_SETTINGS *settings, - const char *config_file); -# endif -void OPENSSL_INIT_free(OPENSSL_INIT_SETTINGS *settings); - -# if defined(OPENSSL_THREADS) && !defined(CRYPTO_TDEBUG) -# if defined(_WIN32) -# if defined(BASETYPES) || defined(_WINDEF_H) -/* application has to include <windows.h> in order to use this */ -typedef DWORD CRYPTO_THREAD_LOCAL; -typedef DWORD CRYPTO_THREAD_ID; - -typedef LONG CRYPTO_ONCE; -# define CRYPTO_ONCE_STATIC_INIT 0 -# endif -# else -# include <pthread.h> -typedef pthread_once_t CRYPTO_ONCE; -typedef pthread_key_t CRYPTO_THREAD_LOCAL; -typedef pthread_t CRYPTO_THREAD_ID; - -# define CRYPTO_ONCE_STATIC_INIT PTHREAD_ONCE_INIT -# endif -# endif - -# if !defined(CRYPTO_ONCE_STATIC_INIT) -typedef unsigned int CRYPTO_ONCE; -typedef unsigned int CRYPTO_THREAD_LOCAL; -typedef unsigned int CRYPTO_THREAD_ID; -# define CRYPTO_ONCE_STATIC_INIT 0 -# endif - -int CRYPTO_THREAD_run_once(CRYPTO_ONCE *once, void (*init)(void)); - -int CRYPTO_THREAD_init_local(CRYPTO_THREAD_LOCAL *key, void (*cleanup)(void *)); -void *CRYPTO_THREAD_get_local(CRYPTO_THREAD_LOCAL *key); -int CRYPTO_THREAD_set_local(CRYPTO_THREAD_LOCAL *key, void *val); -int CRYPTO_THREAD_cleanup_local(CRYPTO_THREAD_LOCAL *key); - -CRYPTO_THREAD_ID CRYPTO_THREAD_get_current_id(void); -int CRYPTO_THREAD_compare_id(CRYPTO_THREAD_ID a, CRYPTO_THREAD_ID b); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_CRYPTO_strings(void); - -/* Error codes for the CRYPTO functions. */ - -/* Function codes. */ -# define CRYPTO_F_CRYPTO_DUP_EX_DATA 110 -# define CRYPTO_F_CRYPTO_FREE_EX_DATA 111 -# define CRYPTO_F_CRYPTO_GET_EX_NEW_INDEX 100 -# define CRYPTO_F_CRYPTO_MEMDUP 115 -# define CRYPTO_F_CRYPTO_NEW_EX_DATA 112 -# define CRYPTO_F_CRYPTO_SET_EX_DATA 102 -# define CRYPTO_F_FIPS_MODE_SET 109 -# define CRYPTO_F_GET_AND_LOCK 113 -# define CRYPTO_F_OPENSSL_BUF2HEXSTR 117 -# define CRYPTO_F_OPENSSL_HEXSTR2BUF 118 -# define CRYPTO_F_OPENSSL_INIT_CRYPTO 116 - -/* Reason codes. */ -# define CRYPTO_R_FIPS_MODE_NOT_SUPPORTED 101 -# define CRYPTO_R_ILLEGAL_HEX_DIGIT 102 -# define CRYPTO_R_ODD_NUMBER_OF_DIGITS 103 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/ct.h b/android/armeabi/include/openssl/ct.h deleted file mode 100644 index 6c632652..00000000 --- a/android/armeabi/include/openssl/ct.h +++ /dev/null @@ -1,518 +0,0 @@ -/* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_CT_H -# define HEADER_CT_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_CT -# include <openssl/ossl_typ.h> -# include <openssl/safestack.h> -# include <openssl/x509.h> -# ifdef __cplusplus -extern "C" { -# endif - - -/* Minimum RSA key size, from RFC6962 */ -# define SCT_MIN_RSA_BITS 2048 - -/* All hashes are SHA256 in v1 of Certificate Transparency */ -# define CT_V1_HASHLEN SHA256_DIGEST_LENGTH - -typedef enum { - CT_LOG_ENTRY_TYPE_NOT_SET = -1, - CT_LOG_ENTRY_TYPE_X509 = 0, - CT_LOG_ENTRY_TYPE_PRECERT = 1 -} ct_log_entry_type_t; - -typedef enum { - SCT_VERSION_NOT_SET = -1, - SCT_VERSION_V1 = 0 -} sct_version_t; - -typedef enum { - SCT_SOURCE_UNKNOWN, - SCT_SOURCE_TLS_EXTENSION, - SCT_SOURCE_X509V3_EXTENSION, - SCT_SOURCE_OCSP_STAPLED_RESPONSE -} sct_source_t; - -typedef enum { - SCT_VALIDATION_STATUS_NOT_SET, - SCT_VALIDATION_STATUS_UNKNOWN_LOG, - SCT_VALIDATION_STATUS_VALID, - SCT_VALIDATION_STATUS_INVALID, - SCT_VALIDATION_STATUS_UNVERIFIED, - SCT_VALIDATION_STATUS_UNKNOWN_VERSION -} sct_validation_status_t; - -DEFINE_STACK_OF(SCT) -DEFINE_STACK_OF(CTLOG) - -/****************************************** - * CT policy evaluation context functions * - ******************************************/ - -/* - * Creates a new, empty policy evaluation context. - * The caller is responsible for calling CT_POLICY_EVAL_CTX_free when finished - * with the CT_POLICY_EVAL_CTX. - */ -CT_POLICY_EVAL_CTX *CT_POLICY_EVAL_CTX_new(void); - -/* Deletes a policy evaluation context and anything it owns. */ -void CT_POLICY_EVAL_CTX_free(CT_POLICY_EVAL_CTX *ctx); - -/* Gets the peer certificate that the SCTs are for */ -X509* CT_POLICY_EVAL_CTX_get0_cert(const CT_POLICY_EVAL_CTX *ctx); - -/* - * Sets the certificate associated with the received SCTs. - * Increments the reference count of cert. - * Returns 1 on success, 0 otherwise. - */ -int CT_POLICY_EVAL_CTX_set1_cert(CT_POLICY_EVAL_CTX *ctx, X509 *cert); - -/* Gets the issuer of the aforementioned certificate */ -X509* CT_POLICY_EVAL_CTX_get0_issuer(const CT_POLICY_EVAL_CTX *ctx); - -/* - * Sets the issuer of the certificate associated with the received SCTs. - * Increments the reference count of issuer. - * Returns 1 on success, 0 otherwise. - */ -int CT_POLICY_EVAL_CTX_set1_issuer(CT_POLICY_EVAL_CTX *ctx, X509 *issuer); - -/* Gets the CT logs that are trusted sources of SCTs */ -const CTLOG_STORE *CT_POLICY_EVAL_CTX_get0_log_store(const CT_POLICY_EVAL_CTX *ctx); - -/* Sets the log store that is in use. It must outlive the CT_POLICY_EVAL_CTX. */ -void CT_POLICY_EVAL_CTX_set_shared_CTLOG_STORE(CT_POLICY_EVAL_CTX *ctx, - CTLOG_STORE *log_store); - -/***************** - * SCT functions * - *****************/ - -/* - * Creates a new, blank SCT. - * The caller is responsible for calling SCT_free when finished with the SCT. - */ -SCT *SCT_new(void); - -/* - * Creates a new SCT from some base64-encoded strings. - * The caller is responsible for calling SCT_free when finished with the SCT. - */ -SCT *SCT_new_from_base64(unsigned char version, - const char *logid_base64, - ct_log_entry_type_t entry_type, - uint64_t timestamp, - const char *extensions_base64, - const char *signature_base64); - -/* - * Frees the SCT and the underlying data structures. - */ -void SCT_free(SCT *sct); - -/* - * Free a stack of SCTs, and the underlying SCTs themselves. - * Intended to be compatible with X509V3_EXT_FREE. - */ -void SCT_LIST_free(STACK_OF(SCT) *a); - -/* - * Returns the version of the SCT. - */ -sct_version_t SCT_get_version(const SCT *sct); - -/* - * Set the version of an SCT. - * Returns 1 on success, 0 if the version is unrecognized. - */ -__owur int SCT_set_version(SCT *sct, sct_version_t version); - -/* - * Returns the log entry type of the SCT. - */ -ct_log_entry_type_t SCT_get_log_entry_type(const SCT *sct); - -/* - * Set the log entry type of an SCT. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set_log_entry_type(SCT *sct, ct_log_entry_type_t entry_type); - -/* - * Gets the ID of the log that an SCT came from. - * Ownership of the log ID remains with the SCT. - * Returns the length of the log ID. - */ -size_t SCT_get0_log_id(const SCT *sct, unsigned char **log_id); - -/* - * Set the log ID of an SCT to point directly to the *log_id specified. - * The SCT takes ownership of the specified pointer. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set0_log_id(SCT *sct, unsigned char *log_id, size_t log_id_len); - -/* - * Set the log ID of an SCT. - * This makes a copy of the log_id. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set1_log_id(SCT *sct, const unsigned char *log_id, - size_t log_id_len); - -/* - * Returns the timestamp for the SCT (epoch time in milliseconds). - */ -uint64_t SCT_get_timestamp(const SCT *sct); - -/* - * Set the timestamp of an SCT (epoch time in milliseconds). - */ -void SCT_set_timestamp(SCT *sct, uint64_t timestamp); - -/* - * Return the NID for the signature used by the SCT. - * For CT v1, this will be either NID_sha256WithRSAEncryption or - * NID_ecdsa_with_SHA256 (or NID_undef if incorrect/unset). - */ -int SCT_get_signature_nid(const SCT *sct); - -/* - * Set the signature type of an SCT - * For CT v1, this should be either NID_sha256WithRSAEncryption or - * NID_ecdsa_with_SHA256. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set_signature_nid(SCT *sct, int nid); - -/* - * Set *ext to point to the extension data for the SCT. ext must not be NULL. - * The SCT retains ownership of this pointer. - * Returns length of the data pointed to. - */ -size_t SCT_get0_extensions(const SCT *sct, unsigned char **ext); - -/* - * Set the extensions of an SCT to point directly to the *ext specified. - * The SCT takes ownership of the specified pointer. - */ -void SCT_set0_extensions(SCT *sct, unsigned char *ext, size_t ext_len); - -/* - * Set the extensions of an SCT. - * This takes a copy of the ext. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set1_extensions(SCT *sct, const unsigned char *ext, - size_t ext_len); - -/* - * Set *sig to point to the signature for the SCT. sig must not be NULL. - * The SCT retains ownership of this pointer. - * Returns length of the data pointed to. - */ -size_t SCT_get0_signature(const SCT *sct, unsigned char **sig); - -/* - * Set the signature of an SCT to point directly to the *sig specified. - * The SCT takes ownership of the specified pointer. - */ -void SCT_set0_signature(SCT *sct, unsigned char *sig, size_t sig_len); - -/* - * Set the signature of an SCT to be a copy of the *sig specified. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set1_signature(SCT *sct, const unsigned char *sig, - size_t sig_len); - -/* - * The origin of this SCT, e.g. TLS extension, OCSP response, etc. - */ -sct_source_t SCT_get_source(const SCT *sct); - -/* - * Set the origin of this SCT, e.g. TLS extension, OCSP response, etc. - * Returns 1 on success, 0 otherwise. - */ -__owur int SCT_set_source(SCT *sct, sct_source_t source); - -/* - * Returns a text string describing the validation status of |sct|. - */ -const char *SCT_validation_status_string(const SCT *sct); - -/* - * Pretty-prints an |sct| to |out|. - * It will be indented by the number of spaces specified by |indent|. - * If |logs| is not NULL, it will be used to lookup the CT log that the SCT came - * from, so that the log name can be printed. - */ -void SCT_print(const SCT *sct, BIO *out, int indent, const CTLOG_STORE *logs); - -/* - * Pretty-prints an |sct_list| to |out|. - * It will be indented by the number of spaces specified by |indent|. - * SCTs will be delimited by |separator|. - * If |logs| is not NULL, it will be used to lookup the CT log that each SCT - * came from, so that the log names can be printed. - */ -void SCT_LIST_print(const STACK_OF(SCT) *sct_list, BIO *out, int indent, - const char *separator, const CTLOG_STORE *logs); - -/* - * Gets the last result of validating this SCT. - * If it has not been validated yet, returns SCT_VALIDATION_STATUS_NOT_SET. - */ -sct_validation_status_t SCT_get_validation_status(const SCT *sct); - -/* - * Validates the given SCT with the provided context. - * Sets the "validation_status" field of the SCT. - * Returns 1 if the SCT is valid and the signature verifies. - * Returns 0 if the SCT is invalid or could not be verified. - * Returns -1 if an error occurs. - */ -__owur int SCT_validate(SCT *sct, const CT_POLICY_EVAL_CTX *ctx); - -/* - * Validates the given list of SCTs with the provided context. - * Sets the "validation_status" field of each SCT. - * Returns 1 if there are no invalid SCTs and all signatures verify. - * Returns 0 if at least one SCT is invalid or could not be verified. - * Returns a negative integer if an error occurs. - */ -__owur int SCT_LIST_validate(const STACK_OF(SCT) *scts, - CT_POLICY_EVAL_CTX *ctx); - - -/********************************* - * SCT parsing and serialisation * - *********************************/ - -/* - * Serialize (to TLS format) a stack of SCTs and return the length. - * "a" must not be NULL. - * If "pp" is NULL, just return the length of what would have been serialized. - * If "pp" is not NULL and "*pp" is null, function will allocate a new pointer - * for data that caller is responsible for freeing (only if function returns - * successfully). - * If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring - * that "*pp" is large enough to accept all of the serialized data. - * Returns < 0 on error, >= 0 indicating bytes written (or would have been) - * on success. - */ -__owur int i2o_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp); - -/* - * Convert TLS format SCT list to a stack of SCTs. - * If "a" or "*a" is NULL, a new stack will be created that the caller is - * responsible for freeing (by calling SCT_LIST_free). - * "**pp" and "*pp" must not be NULL. - * Upon success, "*pp" will point to after the last bytes read, and a stack - * will be returned. - * Upon failure, a NULL pointer will be returned, and the position of "*pp" is - * not defined. - */ -STACK_OF(SCT) *o2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp, - size_t len); - -/* - * Serialize (to DER format) a stack of SCTs and return the length. - * "a" must not be NULL. - * If "pp" is NULL, just returns the length of what would have been serialized. - * If "pp" is not NULL and "*pp" is null, function will allocate a new pointer - * for data that caller is responsible for freeing (only if function returns - * successfully). - * If "pp" is NULL and "*pp" is not NULL, caller is responsible for ensuring - * that "*pp" is large enough to accept all of the serialized data. - * Returns < 0 on error, >= 0 indicating bytes written (or would have been) - * on success. - */ -__owur int i2d_SCT_LIST(const STACK_OF(SCT) *a, unsigned char **pp); - -/* - * Parses an SCT list in DER format and returns it. - * If "a" or "*a" is NULL, a new stack will be created that the caller is - * responsible for freeing (by calling SCT_LIST_free). - * "**pp" and "*pp" must not be NULL. - * Upon success, "*pp" will point to after the last bytes read, and a stack - * will be returned. - * Upon failure, a NULL pointer will be returned, and the position of "*pp" is - * not defined. - */ -STACK_OF(SCT) *d2i_SCT_LIST(STACK_OF(SCT) **a, const unsigned char **pp, - long len); - -/* - * Serialize (to TLS format) an |sct| and write it to |out|. - * If |out| is null, no SCT will be output but the length will still be returned. - * If |out| points to a null pointer, a string will be allocated to hold the - * TLS-format SCT. It is the responsibility of the caller to free it. - * If |out| points to an allocated string, the TLS-format SCT will be written - * to it. - * The length of the SCT in TLS format will be returned. - */ -__owur int i2o_SCT(const SCT *sct, unsigned char **out); - -/* - * Parses an SCT in TLS format and returns it. - * If |psct| is not null, it will end up pointing to the parsed SCT. If it - * already points to a non-null pointer, the pointer will be free'd. - * |in| should be a pointer to a string containing the TLS-format SCT. - * |in| will be advanced to the end of the SCT if parsing succeeds. - * |len| should be the length of the SCT in |in|. - * Returns NULL if an error occurs. - * If the SCT is an unsupported version, only the SCT's 'sct' and 'sct_len' - * fields will be populated (with |in| and |len| respectively). - */ -SCT *o2i_SCT(SCT **psct, const unsigned char **in, size_t len); - -/******************** - * CT log functions * - ********************/ - -/* - * Creates a new CT log instance with the given |public_key| and |name|. - * Takes ownership of |public_key| but copies |name|. - * Returns NULL if malloc fails or if |public_key| cannot be converted to DER. - * Should be deleted by the caller using CTLOG_free when no longer needed. - */ -CTLOG *CTLOG_new(EVP_PKEY *public_key, const char *name); - -/* - * Creates a new CTLOG instance with the base64-encoded SubjectPublicKeyInfo DER - * in |pkey_base64|. The |name| is a string to help users identify this log. - * Returns 1 on success, 0 on failure. - * Should be deleted by the caller using CTLOG_free when no longer needed. - */ -int CTLOG_new_from_base64(CTLOG ** ct_log, - const char *pkey_base64, const char *name); - -/* - * Deletes a CT log instance and its fields. - */ -void CTLOG_free(CTLOG *log); - -/* Gets the name of the CT log */ -const char *CTLOG_get0_name(const CTLOG *log); -/* Gets the ID of the CT log */ -void CTLOG_get0_log_id(const CTLOG *log, const uint8_t **log_id, - size_t *log_id_len); -/* Gets the public key of the CT log */ -EVP_PKEY *CTLOG_get0_public_key(const CTLOG *log); - -/************************** - * CT log store functions * - **************************/ - -/* - * Creates a new CT log store. - * Should be deleted by the caller using CTLOG_STORE_free when no longer needed. - */ -CTLOG_STORE *CTLOG_STORE_new(void); - -/* - * Deletes a CT log store and all of the CT log instances held within. - */ -void CTLOG_STORE_free(CTLOG_STORE *store); - -/* - * Finds a CT log in the store based on its log ID. - * Returns the CT log, or NULL if no match is found. - */ -const CTLOG *CTLOG_STORE_get0_log_by_id(const CTLOG_STORE *store, - const uint8_t *log_id, - size_t log_id_len); - -/* - * Loads a CT log list into a |store| from a |file|. - * Returns 1 if loading is successful, or 0 otherwise. - */ -__owur int CTLOG_STORE_load_file(CTLOG_STORE *store, const char *file); - -/* - * Loads the default CT log list into a |store|. - * See internal/cryptlib.h for the environment variable and file path that are - * consulted to find the default file. - * Returns 1 if loading is successful, or 0 otherwise. - */ -__owur int CTLOG_STORE_load_default_file(CTLOG_STORE *store); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_CT_strings(void); - -/* Error codes for the CT functions. */ - -/* Function codes. */ -# define CT_F_CTLOG_NEW 117 -# define CT_F_CTLOG_NEW_FROM_BASE64 118 -# define CT_F_CTLOG_NEW_FROM_CONF 119 -# define CT_F_CTLOG_NEW_NULL 120 -# define CT_F_CTLOG_STORE_LOAD_CTX_NEW 122 -# define CT_F_CTLOG_STORE_LOAD_FILE 123 -# define CT_F_CTLOG_STORE_LOAD_LOG 130 -# define CT_F_CTLOG_STORE_NEW 131 -# define CT_F_CT_BASE64_DECODE 124 -# define CT_F_CT_POLICY_EVAL_CTX_NEW 133 -# define CT_F_CT_V1_LOG_ID_FROM_PKEY 125 -# define CT_F_I2O_SCT 107 -# define CT_F_I2O_SCT_LIST 108 -# define CT_F_I2O_SCT_SIGNATURE 109 -# define CT_F_O2I_SCT 110 -# define CT_F_O2I_SCT_LIST 111 -# define CT_F_O2I_SCT_SIGNATURE 112 -# define CT_F_SCT_CTX_NEW 126 -# define CT_F_SCT_NEW 100 -# define CT_F_SCT_NEW_FROM_BASE64 127 -# define CT_F_SCT_SET0_LOG_ID 101 -# define CT_F_SCT_SET1_EXTENSIONS 114 -# define CT_F_SCT_SET1_LOG_ID 115 -# define CT_F_SCT_SET1_SIGNATURE 116 -# define CT_F_SCT_SET_LOG_ENTRY_TYPE 102 -# define CT_F_SCT_SET_SIGNATURE_NID 103 -# define CT_F_SCT_SET_VERSION 104 -# define CT_F_SCT_CTX_VERIFY 128 - -/* Reason codes. */ -# define CT_R_BASE64_DECODE_ERROR 108 -# define CT_R_INVALID_LOG_ID_LENGTH 100 -# define CT_R_LOG_CONF_INVALID 109 -# define CT_R_LOG_CONF_INVALID_KEY 110 -# define CT_R_LOG_CONF_MISSING_DESCRIPTION 111 -# define CT_R_LOG_CONF_MISSING_KEY 112 -# define CT_R_LOG_KEY_INVALID 113 -# define CT_R_SCT_INVALID 104 -# define CT_R_SCT_INVALID_SIGNATURE 107 -# define CT_R_SCT_LIST_INVALID 105 -# define CT_R_SCT_LOG_ID_MISMATCH 114 -# define CT_R_SCT_NOT_SET 106 -# define CT_R_SCT_UNSUPPORTED_VERSION 115 -# define CT_R_UNRECOGNIZED_SIGNATURE_NID 101 -# define CT_R_UNSUPPORTED_ENTRY_TYPE 102 -# define CT_R_UNSUPPORTED_VERSION 103 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/des.h b/android/armeabi/include/openssl/des.h deleted file mode 100644 index be4abbdf..00000000 --- a/android/armeabi/include/openssl/des.h +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_DES_H -# define HEADER_DES_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_DES -# ifdef __cplusplus -extern "C" { -# endif -# include <openssl/e_os2.h> - -typedef unsigned int DES_LONG; - -# ifdef OPENSSL_BUILD_SHLIBCRYPTO -# undef OPENSSL_EXTERN -# define OPENSSL_EXTERN OPENSSL_EXPORT -# endif - -typedef unsigned char DES_cblock[8]; -typedef /* const */ unsigned char const_DES_cblock[8]; -/* - * With "const", gcc 2.8.1 on Solaris thinks that DES_cblock * and - * const_DES_cblock * are incompatible pointer types. - */ - -typedef struct DES_ks { - union { - DES_cblock cblock; - /* - * make sure things are correct size on machines with 8 byte longs - */ - DES_LONG deslong[2]; - } ks[16]; -} DES_key_schedule; - -# define DES_KEY_SZ (sizeof(DES_cblock)) -# define DES_SCHEDULE_SZ (sizeof(DES_key_schedule)) - -# define DES_ENCRYPT 1 -# define DES_DECRYPT 0 - -# define DES_CBC_MODE 0 -# define DES_PCBC_MODE 1 - -# define DES_ecb2_encrypt(i,o,k1,k2,e) \ - DES_ecb3_encrypt((i),(o),(k1),(k2),(k1),(e)) - -# define DES_ede2_cbc_encrypt(i,o,l,k1,k2,iv,e) \ - DES_ede3_cbc_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(e)) - -# define DES_ede2_cfb64_encrypt(i,o,l,k1,k2,iv,n,e) \ - DES_ede3_cfb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n),(e)) - -# define DES_ede2_ofb64_encrypt(i,o,l,k1,k2,iv,n) \ - DES_ede3_ofb64_encrypt((i),(o),(l),(k1),(k2),(k1),(iv),(n)) - -OPENSSL_DECLARE_GLOBAL(int, DES_check_key); /* defaults to false */ -# define DES_check_key OPENSSL_GLOBAL_REF(DES_check_key) - -const char *DES_options(void); -void DES_ecb3_encrypt(const_DES_cblock *input, DES_cblock *output, - DES_key_schedule *ks1, DES_key_schedule *ks2, - DES_key_schedule *ks3, int enc); -DES_LONG DES_cbc_cksum(const unsigned char *input, DES_cblock *output, - long length, DES_key_schedule *schedule, - const_DES_cblock *ivec); -/* DES_cbc_encrypt does not update the IV! Use DES_ncbc_encrypt instead. */ -void DES_cbc_encrypt(const unsigned char *input, unsigned char *output, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int enc); -void DES_ncbc_encrypt(const unsigned char *input, unsigned char *output, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int enc); -void DES_xcbc_encrypt(const unsigned char *input, unsigned char *output, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, const_DES_cblock *inw, - const_DES_cblock *outw, int enc); -void DES_cfb_encrypt(const unsigned char *in, unsigned char *out, int numbits, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int enc); -void DES_ecb_encrypt(const_DES_cblock *input, DES_cblock *output, - DES_key_schedule *ks, int enc); - -/* - * This is the DES encryption function that gets called by just about every - * other DES routine in the library. You should not use this function except - * to implement 'modes' of DES. I say this because the functions that call - * this routine do the conversion from 'char *' to long, and this needs to be - * done to make sure 'non-aligned' memory access do not occur. The - * characters are loaded 'little endian'. Data is a pointer to 2 unsigned - * long's and ks is the DES_key_schedule to use. enc, is non zero specifies - * encryption, zero if decryption. - */ -void DES_encrypt1(DES_LONG *data, DES_key_schedule *ks, int enc); - -/* - * This functions is the same as DES_encrypt1() except that the DES initial - * permutation (IP) and final permutation (FP) have been left out. As for - * DES_encrypt1(), you should not use this function. It is used by the - * routines in the library that implement triple DES. IP() DES_encrypt2() - * DES_encrypt2() DES_encrypt2() FP() is the same as DES_encrypt1() - * DES_encrypt1() DES_encrypt1() except faster :-). - */ -void DES_encrypt2(DES_LONG *data, DES_key_schedule *ks, int enc); - -void DES_encrypt3(DES_LONG *data, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3); -void DES_decrypt3(DES_LONG *data, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3); -void DES_ede3_cbc_encrypt(const unsigned char *input, unsigned char *output, - long length, - DES_key_schedule *ks1, DES_key_schedule *ks2, - DES_key_schedule *ks3, DES_cblock *ivec, int enc); -void DES_ede3_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3, - DES_cblock *ivec, int *num, int enc); -void DES_ede3_cfb_encrypt(const unsigned char *in, unsigned char *out, - int numbits, long length, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3, - DES_cblock *ivec, int enc); -void DES_ede3_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, DES_key_schedule *ks1, - DES_key_schedule *ks2, DES_key_schedule *ks3, - DES_cblock *ivec, int *num); -char *DES_fcrypt(const char *buf, const char *salt, char *ret); -char *DES_crypt(const char *buf, const char *salt); -void DES_ofb_encrypt(const unsigned char *in, unsigned char *out, int numbits, - long length, DES_key_schedule *schedule, - DES_cblock *ivec); -void DES_pcbc_encrypt(const unsigned char *input, unsigned char *output, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int enc); -DES_LONG DES_quad_cksum(const unsigned char *input, DES_cblock output[], - long length, int out_count, DES_cblock *seed); -int DES_random_key(DES_cblock *ret); -void DES_set_odd_parity(DES_cblock *key); -int DES_check_key_parity(const_DES_cblock *key); -int DES_is_weak_key(const_DES_cblock *key); -/* - * DES_set_key (= set_key = DES_key_sched = key_sched) calls - * DES_set_key_checked if global variable DES_check_key is set, - * DES_set_key_unchecked otherwise. - */ -int DES_set_key(const_DES_cblock *key, DES_key_schedule *schedule); -int DES_key_sched(const_DES_cblock *key, DES_key_schedule *schedule); -int DES_set_key_checked(const_DES_cblock *key, DES_key_schedule *schedule); -void DES_set_key_unchecked(const_DES_cblock *key, DES_key_schedule *schedule); -void DES_string_to_key(const char *str, DES_cblock *key); -void DES_string_to_2keys(const char *str, DES_cblock *key1, DES_cblock *key2); -void DES_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int *num, int enc); -void DES_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, DES_key_schedule *schedule, - DES_cblock *ivec, int *num); - -# define DES_fixup_key_parity DES_set_odd_parity - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/dh.h b/android/armeabi/include/openssl/dh.h deleted file mode 100644 index ae309e7b..00000000 --- a/android/armeabi/include/openssl/dh.h +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_DH_H -# define HEADER_DH_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_DH -# include <openssl/e_os2.h> -# include <openssl/bio.h> -# include <openssl/asn1.h> -# include <openssl/ossl_typ.h> -# if OPENSSL_API_COMPAT < 0x10100000L -# include <openssl/bn.h> -# endif - -# ifdef __cplusplus -extern "C" { -# endif - -# ifndef OPENSSL_DH_MAX_MODULUS_BITS -# define OPENSSL_DH_MAX_MODULUS_BITS 10000 -# endif - -# define OPENSSL_DH_FIPS_MIN_MODULUS_BITS 1024 - -# define DH_FLAG_CACHE_MONT_P 0x01 - -# if OPENSSL_API_COMPAT < 0x10100000L -/* - * Does nothing. Previously this switched off constant time behaviour. - */ -# define DH_FLAG_NO_EXP_CONSTTIME 0x00 -# endif - -/* - * If this flag is set the DH method is FIPS compliant and can be used in - * FIPS mode. This is set in the validated module method. If an application - * sets this flag in its own methods it is its responsibility to ensure the - * result is compliant. - */ - -# define DH_FLAG_FIPS_METHOD 0x0400 - -/* - * If this flag is set the operations normally disabled in FIPS mode are - * permitted it is then the applications responsibility to ensure that the - * usage is compliant. - */ - -# define DH_FLAG_NON_FIPS_ALLOW 0x0400 - -/* Already defined in ossl_typ.h */ -/* typedef struct dh_st DH; */ -/* typedef struct dh_method DH_METHOD; */ - -DECLARE_ASN1_ITEM(DHparams) - -# define DH_GENERATOR_2 2 -/* #define DH_GENERATOR_3 3 */ -# define DH_GENERATOR_5 5 - -/* DH_check error codes */ -# define DH_CHECK_P_NOT_PRIME 0x01 -# define DH_CHECK_P_NOT_SAFE_PRIME 0x02 -# define DH_UNABLE_TO_CHECK_GENERATOR 0x04 -# define DH_NOT_SUITABLE_GENERATOR 0x08 -# define DH_CHECK_Q_NOT_PRIME 0x10 -# define DH_CHECK_INVALID_Q_VALUE 0x20 -# define DH_CHECK_INVALID_J_VALUE 0x40 - -/* DH_check_pub_key error codes */ -# define DH_CHECK_PUBKEY_TOO_SMALL 0x01 -# define DH_CHECK_PUBKEY_TOO_LARGE 0x02 -# define DH_CHECK_PUBKEY_INVALID 0x04 - -/* - * primes p where (p-1)/2 is prime too are called "safe"; we define this for - * backward compatibility: - */ -# define DH_CHECK_P_NOT_STRONG_PRIME DH_CHECK_P_NOT_SAFE_PRIME - -# define d2i_DHparams_fp(fp,x) (DH *)ASN1_d2i_fp((char *(*)())DH_new, \ - (char *(*)())d2i_DHparams,(fp),(unsigned char **)(x)) -# define i2d_DHparams_fp(fp,x) ASN1_i2d_fp(i2d_DHparams,(fp), \ - (unsigned char *)(x)) -# define d2i_DHparams_bio(bp,x) ASN1_d2i_bio_of(DH,DH_new,d2i_DHparams,bp,x) -# define i2d_DHparams_bio(bp,x) ASN1_i2d_bio_of_const(DH,i2d_DHparams,bp,x) - -DH *DHparams_dup(DH *); - -const DH_METHOD *DH_OpenSSL(void); - -void DH_set_default_method(const DH_METHOD *meth); -const DH_METHOD *DH_get_default_method(void); -int DH_set_method(DH *dh, const DH_METHOD *meth); -DH *DH_new_method(ENGINE *engine); - -DH *DH_new(void); -void DH_free(DH *dh); -int DH_up_ref(DH *dh); -int DH_bits(const DH *dh); -int DH_size(const DH *dh); -int DH_security_bits(const DH *dh); -#define DH_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DH, l, p, newf, dupf, freef) -int DH_set_ex_data(DH *d, int idx, void *arg); -void *DH_get_ex_data(DH *d, int idx); - -/* Deprecated version */ -DEPRECATEDIN_0_9_8(DH *DH_generate_parameters(int prime_len, int generator, - void (*callback) (int, int, - void *), - void *cb_arg)) - -/* New version */ -int DH_generate_parameters_ex(DH *dh, int prime_len, int generator, - BN_GENCB *cb); - -int DH_check(const DH *dh, int *codes); -int DH_check_pub_key(const DH *dh, const BIGNUM *pub_key, int *codes); -int DH_generate_key(DH *dh); -int DH_compute_key(unsigned char *key, const BIGNUM *pub_key, DH *dh); -int DH_compute_key_padded(unsigned char *key, const BIGNUM *pub_key, DH *dh); -DH *d2i_DHparams(DH **a, const unsigned char **pp, long length); -int i2d_DHparams(const DH *a, unsigned char **pp); -DH *d2i_DHxparams(DH **a, const unsigned char **pp, long length); -int i2d_DHxparams(const DH *a, unsigned char **pp); -# ifndef OPENSSL_NO_STDIO -int DHparams_print_fp(FILE *fp, const DH *x); -# endif -int DHparams_print(BIO *bp, const DH *x); - -/* RFC 5114 parameters */ -DH *DH_get_1024_160(void); -DH *DH_get_2048_224(void); -DH *DH_get_2048_256(void); - -# ifndef OPENSSL_NO_CMS -/* RFC2631 KDF */ -int DH_KDF_X9_42(unsigned char *out, size_t outlen, - const unsigned char *Z, size_t Zlen, - ASN1_OBJECT *key_oid, - const unsigned char *ukm, size_t ukmlen, const EVP_MD *md); -# endif - -void DH_get0_pqg(const DH *dh, - const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); -int DH_set0_pqg(DH *dh, BIGNUM *p, BIGNUM *q, BIGNUM *g); -void DH_get0_key(const DH *dh, - const BIGNUM **pub_key, const BIGNUM **priv_key); -int DH_set0_key(DH *dh, BIGNUM *pub_key, BIGNUM *priv_key); -void DH_clear_flags(DH *dh, int flags); -int DH_test_flags(const DH *dh, int flags); -void DH_set_flags(DH *dh, int flags); -ENGINE *DH_get0_engine(DH *d); -long DH_get_length(const DH *dh); -int DH_set_length(DH *dh, long length); - -DH_METHOD *DH_meth_new(const char *name, int flags); -void DH_meth_free(DH_METHOD *dhm); -DH_METHOD *DH_meth_dup(const DH_METHOD *dhm); -const char *DH_meth_get0_name(const DH_METHOD *dhm); -int DH_meth_set1_name(DH_METHOD *dhm, const char *name); -int DH_meth_get_flags(DH_METHOD *dhm); -int DH_meth_set_flags(DH_METHOD *dhm, int flags); -void *DH_meth_get0_app_data(const DH_METHOD *dhm); -int DH_meth_set0_app_data(DH_METHOD *dhm, void *app_data); -int (*DH_meth_get_generate_key(const DH_METHOD *dhm)) (DH *); -int DH_meth_set_generate_key(DH_METHOD *dhm, int (*generate_key) (DH *)); -int (*DH_meth_get_compute_key(const DH_METHOD *dhm)) - (unsigned char *key, const BIGNUM *pub_key, DH *dh); -int DH_meth_set_compute_key(DH_METHOD *dhm, - int (*compute_key) (unsigned char *key, const BIGNUM *pub_key, DH *dh)); -int (*DH_meth_get_bn_mod_exp(const DH_METHOD *dhm)) - (const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, - BN_CTX *, BN_MONT_CTX *); -int DH_meth_set_bn_mod_exp(DH_METHOD *dhm, - int (*bn_mod_exp) (const DH *, BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, BN_CTX *, BN_MONT_CTX *)); -int (*DH_meth_get_init(const DH_METHOD *dhm))(DH *); -int DH_meth_set_init(DH_METHOD *dhm, int (*init)(DH *)); -int (*DH_meth_get_finish(const DH_METHOD *dhm)) (DH *); -int DH_meth_set_finish(DH_METHOD *dhm, int (*finish) (DH *)); -int (*DH_meth_get_generate_params(const DH_METHOD *dhm)) - (DH *, int, int, BN_GENCB *); -int DH_meth_set_generate_params(DH_METHOD *dhm, - int (*generate_params) (DH *, int, int, BN_GENCB *)); - - -# define EVP_PKEY_CTX_set_dh_paramgen_prime_len(ctx, len) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN, len, NULL) - -# define EVP_PKEY_CTX_set_dh_paramgen_subprime_len(ctx, len) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN, len, NULL) - -# define EVP_PKEY_CTX_set_dh_paramgen_type(ctx, typ) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_PARAMGEN_TYPE, typ, NULL) - -# define EVP_PKEY_CTX_set_dh_paramgen_generator(ctx, gen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DH, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR, gen, NULL) - -# define EVP_PKEY_CTX_set_dh_rfc5114(ctx, gen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_RFC5114, gen, NULL) - -# define EVP_PKEY_CTX_set_dhx_rfc5114(ctx, gen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DH_RFC5114, gen, NULL) - -# define EVP_PKEY_CTX_set_dh_kdf_type(ctx, kdf) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_TYPE, kdf, NULL) - -# define EVP_PKEY_CTX_get_dh_kdf_type(ctx) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_TYPE, -2, NULL) - -# define EVP_PKEY_CTX_set0_dh_kdf_oid(ctx, oid) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_OID, 0, (void *)oid) - -# define EVP_PKEY_CTX_get0_dh_kdf_oid(ctx, poid) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_DH_KDF_OID, 0, (void *)poid) - -# define EVP_PKEY_CTX_set_dh_kdf_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_MD, 0, (void *)md) - -# define EVP_PKEY_CTX_get_dh_kdf_md(ctx, pmd) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_DH_KDF_MD, 0, (void *)pmd) - -# define EVP_PKEY_CTX_set_dh_kdf_outlen(ctx, len) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_OUTLEN, len, NULL) - -# define EVP_PKEY_CTX_get_dh_kdf_outlen(ctx, plen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN, 0, (void *)plen) - -# define EVP_PKEY_CTX_set0_dh_kdf_ukm(ctx, p, plen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_DH_KDF_UKM, plen, (void *)p) - -# define EVP_PKEY_CTX_get0_dh_kdf_ukm(ctx, p) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DHX, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_DH_KDF_UKM, 0, (void *)p) - -# define EVP_PKEY_CTRL_DH_PARAMGEN_PRIME_LEN (EVP_PKEY_ALG_CTRL + 1) -# define EVP_PKEY_CTRL_DH_PARAMGEN_GENERATOR (EVP_PKEY_ALG_CTRL + 2) -# define EVP_PKEY_CTRL_DH_RFC5114 (EVP_PKEY_ALG_CTRL + 3) -# define EVP_PKEY_CTRL_DH_PARAMGEN_SUBPRIME_LEN (EVP_PKEY_ALG_CTRL + 4) -# define EVP_PKEY_CTRL_DH_PARAMGEN_TYPE (EVP_PKEY_ALG_CTRL + 5) -# define EVP_PKEY_CTRL_DH_KDF_TYPE (EVP_PKEY_ALG_CTRL + 6) -# define EVP_PKEY_CTRL_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 7) -# define EVP_PKEY_CTRL_GET_DH_KDF_MD (EVP_PKEY_ALG_CTRL + 8) -# define EVP_PKEY_CTRL_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 9) -# define EVP_PKEY_CTRL_GET_DH_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 10) -# define EVP_PKEY_CTRL_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 11) -# define EVP_PKEY_CTRL_GET_DH_KDF_UKM (EVP_PKEY_ALG_CTRL + 12) -# define EVP_PKEY_CTRL_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 13) -# define EVP_PKEY_CTRL_GET_DH_KDF_OID (EVP_PKEY_ALG_CTRL + 14) - -/* KDF types */ -# define EVP_PKEY_DH_KDF_NONE 1 -# ifndef OPENSSL_NO_CMS -# define EVP_PKEY_DH_KDF_X9_42 2 -# endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_DH_strings(void); - -/* Error codes for the DH functions. */ - -/* Function codes. */ -# define DH_F_COMPUTE_KEY 102 -# define DH_F_DHPARAMS_PRINT_FP 101 -# define DH_F_DH_BUILTIN_GENPARAMS 106 -# define DH_F_DH_CMS_DECRYPT 114 -# define DH_F_DH_CMS_SET_PEERKEY 115 -# define DH_F_DH_CMS_SET_SHARED_INFO 116 -# define DH_F_DH_METH_DUP 117 -# define DH_F_DH_METH_NEW 118 -# define DH_F_DH_METH_SET1_NAME 119 -# define DH_F_DH_NEW_METHOD 105 -# define DH_F_DH_PARAM_DECODE 107 -# define DH_F_DH_PRIV_DECODE 110 -# define DH_F_DH_PRIV_ENCODE 111 -# define DH_F_DH_PUB_DECODE 108 -# define DH_F_DH_PUB_ENCODE 109 -# define DH_F_DO_DH_PRINT 100 -# define DH_F_GENERATE_KEY 103 -# define DH_F_PKEY_DH_DERIVE 112 -# define DH_F_PKEY_DH_KEYGEN 113 - -/* Reason codes. */ -# define DH_R_BAD_GENERATOR 101 -# define DH_R_BN_DECODE_ERROR 109 -# define DH_R_BN_ERROR 106 -# define DH_R_DECODE_ERROR 104 -# define DH_R_INVALID_PUBKEY 102 -# define DH_R_KDF_PARAMETER_ERROR 112 -# define DH_R_KEYS_NOT_SET 108 -# define DH_R_MODULUS_TOO_LARGE 103 -# define DH_R_NO_PARAMETERS_SET 107 -# define DH_R_NO_PRIVATE_VALUE 100 -# define DH_R_PARAMETER_ENCODING_ERROR 105 -# define DH_R_PEER_KEY_ERROR 111 -# define DH_R_SHARED_INFO_ERROR 113 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/dsa.h b/android/armeabi/include/openssl/dsa.h deleted file mode 100644 index cb5fbc2f..00000000 --- a/android/armeabi/include/openssl/dsa.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * The DSS routines are based on patches supplied by - * Steven Schoch <schoch@sheba.arc.nasa.gov>. - */ - -#ifndef HEADER_DSA_H -# define HEADER_DSA_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_DSA -# ifdef __cplusplus -extern "C" { -# endif -# include <openssl/e_os2.h> -# include <openssl/bio.h> -# include <openssl/crypto.h> -# include <openssl/ossl_typ.h> -# include <openssl/opensslconf.h> -# include <openssl/bn.h> -# if OPENSSL_API_COMPAT < 0x10100000L -# include <openssl/dh.h> -# endif - -# ifndef OPENSSL_DSA_MAX_MODULUS_BITS -# define OPENSSL_DSA_MAX_MODULUS_BITS 10000 -# endif - -# define OPENSSL_DSA_FIPS_MIN_MODULUS_BITS 1024 - -# define DSA_FLAG_CACHE_MONT_P 0x01 -# if OPENSSL_API_COMPAT < 0x10100000L -/* - * Does nothing. Previously this switched off constant time behaviour. - */ -# define DSA_FLAG_NO_EXP_CONSTTIME 0x00 -# endif - -/* - * If this flag is set the DSA method is FIPS compliant and can be used in - * FIPS mode. This is set in the validated module method. If an application - * sets this flag in its own methods it is its responsibility to ensure the - * result is compliant. - */ - -# define DSA_FLAG_FIPS_METHOD 0x0400 - -/* - * If this flag is set the operations normally disabled in FIPS mode are - * permitted it is then the applications responsibility to ensure that the - * usage is compliant. - */ - -# define DSA_FLAG_NON_FIPS_ALLOW 0x0400 -# define DSA_FLAG_FIPS_CHECKED 0x0800 - -/* Already defined in ossl_typ.h */ -/* typedef struct dsa_st DSA; */ -/* typedef struct dsa_method DSA_METHOD; */ - -typedef struct DSA_SIG_st DSA_SIG; - -# define d2i_DSAparams_fp(fp,x) (DSA *)ASN1_d2i_fp((char *(*)())DSA_new, \ - (char *(*)())d2i_DSAparams,(fp),(unsigned char **)(x)) -# define i2d_DSAparams_fp(fp,x) ASN1_i2d_fp(i2d_DSAparams,(fp), \ - (unsigned char *)(x)) -# define d2i_DSAparams_bio(bp,x) ASN1_d2i_bio_of(DSA,DSA_new,d2i_DSAparams,bp,x) -# define i2d_DSAparams_bio(bp,x) ASN1_i2d_bio_of_const(DSA,i2d_DSAparams,bp,x) - -DSA *DSAparams_dup(DSA *x); -DSA_SIG *DSA_SIG_new(void); -void DSA_SIG_free(DSA_SIG *a); -int i2d_DSA_SIG(const DSA_SIG *a, unsigned char **pp); -DSA_SIG *d2i_DSA_SIG(DSA_SIG **v, const unsigned char **pp, long length); -void DSA_SIG_get0(const DSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); -int DSA_SIG_set0(DSA_SIG *sig, BIGNUM *r, BIGNUM *s); - -DSA_SIG *DSA_do_sign(const unsigned char *dgst, int dlen, DSA *dsa); -int DSA_do_verify(const unsigned char *dgst, int dgst_len, - DSA_SIG *sig, DSA *dsa); - -const DSA_METHOD *DSA_OpenSSL(void); - -void DSA_set_default_method(const DSA_METHOD *); -const DSA_METHOD *DSA_get_default_method(void); -int DSA_set_method(DSA *dsa, const DSA_METHOD *); -const DSA_METHOD *DSA_get_method(DSA *d); - -DSA *DSA_new(void); -DSA *DSA_new_method(ENGINE *engine); -void DSA_free(DSA *r); -/* "up" the DSA object's reference count */ -int DSA_up_ref(DSA *r); -int DSA_size(const DSA *); -int DSA_bits(const DSA *d); -int DSA_security_bits(const DSA *d); - /* next 4 return -1 on error */ -int DSA_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp); -int DSA_sign(int type, const unsigned char *dgst, int dlen, - unsigned char *sig, unsigned int *siglen, DSA *dsa); -int DSA_verify(int type, const unsigned char *dgst, int dgst_len, - const unsigned char *sigbuf, int siglen, DSA *dsa); -#define DSA_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_DSA, l, p, newf, dupf, freef) -int DSA_set_ex_data(DSA *d, int idx, void *arg); -void *DSA_get_ex_data(DSA *d, int idx); - -DSA *d2i_DSAPublicKey(DSA **a, const unsigned char **pp, long length); -DSA *d2i_DSAPrivateKey(DSA **a, const unsigned char **pp, long length); -DSA *d2i_DSAparams(DSA **a, const unsigned char **pp, long length); - -/* Deprecated version */ -DEPRECATEDIN_0_9_8(DSA *DSA_generate_parameters(int bits, - unsigned char *seed, - int seed_len, - int *counter_ret, - unsigned long *h_ret, void - (*callback) (int, int, - void *), - void *cb_arg)) - -/* New version */ -int DSA_generate_parameters_ex(DSA *dsa, int bits, - const unsigned char *seed, int seed_len, - int *counter_ret, unsigned long *h_ret, - BN_GENCB *cb); - -int DSA_generate_key(DSA *a); -int i2d_DSAPublicKey(const DSA *a, unsigned char **pp); -int i2d_DSAPrivateKey(const DSA *a, unsigned char **pp); -int i2d_DSAparams(const DSA *a, unsigned char **pp); - -int DSAparams_print(BIO *bp, const DSA *x); -int DSA_print(BIO *bp, const DSA *x, int off); -# ifndef OPENSSL_NO_STDIO -int DSAparams_print_fp(FILE *fp, const DSA *x); -int DSA_print_fp(FILE *bp, const DSA *x, int off); -# endif - -# define DSS_prime_checks 50 -/* - * Primality test according to FIPS PUB 186[-1], Appendix 2.1: 50 rounds of - * Rabin-Miller - */ -# define DSA_is_prime(n, callback, cb_arg) \ - BN_is_prime(n, DSS_prime_checks, callback, NULL, cb_arg) - -# ifndef OPENSSL_NO_DH -/* - * Convert DSA structure (key or just parameters) into DH structure (be - * careful to avoid small subgroup attacks when using this!) - */ -DH *DSA_dup_DH(const DSA *r); -# endif - -# define EVP_PKEY_CTX_set_dsa_paramgen_bits(ctx, nbits) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_DSA, EVP_PKEY_OP_PARAMGEN, \ - EVP_PKEY_CTRL_DSA_PARAMGEN_BITS, nbits, NULL) - -# define EVP_PKEY_CTRL_DSA_PARAMGEN_BITS (EVP_PKEY_ALG_CTRL + 1) -# define EVP_PKEY_CTRL_DSA_PARAMGEN_Q_BITS (EVP_PKEY_ALG_CTRL + 2) -# define EVP_PKEY_CTRL_DSA_PARAMGEN_MD (EVP_PKEY_ALG_CTRL + 3) - -void DSA_get0_pqg(const DSA *d, - const BIGNUM **p, const BIGNUM **q, const BIGNUM **g); -int DSA_set0_pqg(DSA *d, BIGNUM *p, BIGNUM *q, BIGNUM *g); -void DSA_get0_key(const DSA *d, - const BIGNUM **pub_key, const BIGNUM **priv_key); -int DSA_set0_key(DSA *d, BIGNUM *pub_key, BIGNUM *priv_key); -void DSA_clear_flags(DSA *d, int flags); -int DSA_test_flags(const DSA *d, int flags); -void DSA_set_flags(DSA *d, int flags); -ENGINE *DSA_get0_engine(DSA *d); - -DSA_METHOD *DSA_meth_new(const char *name, int flags); -void DSA_meth_free(DSA_METHOD *dsam); -DSA_METHOD *DSA_meth_dup(const DSA_METHOD *dsam); -const char *DSA_meth_get0_name(const DSA_METHOD *dsam); -int DSA_meth_set1_name(DSA_METHOD *dsam, const char *name); -int DSA_meth_get_flags(DSA_METHOD *dsam); -int DSA_meth_set_flags(DSA_METHOD *dsam, int flags); -void *DSA_meth_get0_app_data(const DSA_METHOD *dsam); -int DSA_meth_set0_app_data(DSA_METHOD *dsam, void *app_data); -DSA_SIG *(*DSA_meth_get_sign(const DSA_METHOD *dsam)) - (const unsigned char *, int, DSA *); -int DSA_meth_set_sign(DSA_METHOD *dsam, - DSA_SIG *(*sign) (const unsigned char *, int, DSA *)); -int (*DSA_meth_get_sign_setup(const DSA_METHOD *dsam)) - (DSA *, BN_CTX *, BIGNUM **, BIGNUM **); -int DSA_meth_set_sign_setup(DSA_METHOD *dsam, - int (*sign_setup) (DSA *, BN_CTX *, BIGNUM **, BIGNUM **)); -int (*DSA_meth_get_verify(const DSA_METHOD *dsam)) - (const unsigned char *, int , DSA_SIG *, DSA *); -int DSA_meth_set_verify(DSA_METHOD *dsam, - int (*verify) (const unsigned char *, int, DSA_SIG *, DSA *)); -int (*DSA_meth_get_mod_exp(const DSA_METHOD *dsam)) - (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, const BIGNUM *, BN_CTX *, BN_MONT_CTX *); -int DSA_meth_set_mod_exp(DSA_METHOD *dsam, - int (*mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, const BIGNUM *, const BIGNUM *, BN_CTX *, - BN_MONT_CTX *)); -int (*DSA_meth_get_bn_mod_exp(const DSA_METHOD *dsam)) - (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, const BIGNUM *, - BN_CTX *, BN_MONT_CTX *); -int DSA_meth_set_bn_mod_exp(DSA_METHOD *dsam, - int (*bn_mod_exp) (DSA *, BIGNUM *, const BIGNUM *, const BIGNUM *, - const BIGNUM *, BN_CTX *, BN_MONT_CTX *)); -int (*DSA_meth_get_init(const DSA_METHOD *dsam))(DSA *); -int DSA_meth_set_init(DSA_METHOD *dsam, int (*init)(DSA *)); -int (*DSA_meth_get_finish(const DSA_METHOD *dsam)) (DSA *); -int DSA_meth_set_finish(DSA_METHOD *dsam, int (*finish) (DSA *)); -int (*DSA_meth_get_paramgen(const DSA_METHOD *dsam)) - (DSA *, int, const unsigned char *, int, int *, unsigned long *, - BN_GENCB *); -int DSA_meth_set_paramgen(DSA_METHOD *dsam, - int (*paramgen) (DSA *, int, const unsigned char *, int, int *, - unsigned long *, BN_GENCB *)); -int (*DSA_meth_get_keygen(const DSA_METHOD *dsam)) (DSA *); -int DSA_meth_set_keygen(DSA_METHOD *dsam, int (*keygen) (DSA *)); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_DSA_strings(void); - -/* Error codes for the DSA functions. */ - -/* Function codes. */ -# define DSA_F_DSAPARAMS_PRINT 100 -# define DSA_F_DSAPARAMS_PRINT_FP 101 -# define DSA_F_DSA_BUILTIN_PARAMGEN 125 -# define DSA_F_DSA_BUILTIN_PARAMGEN2 126 -# define DSA_F_DSA_DO_SIGN 112 -# define DSA_F_DSA_DO_VERIFY 113 -# define DSA_F_DSA_METH_DUP 127 -# define DSA_F_DSA_METH_NEW 128 -# define DSA_F_DSA_METH_SET1_NAME 129 -# define DSA_F_DSA_NEW_METHOD 103 -# define DSA_F_DSA_PARAM_DECODE 119 -# define DSA_F_DSA_PRINT_FP 105 -# define DSA_F_DSA_PRIV_DECODE 115 -# define DSA_F_DSA_PRIV_ENCODE 116 -# define DSA_F_DSA_PUB_DECODE 117 -# define DSA_F_DSA_PUB_ENCODE 118 -# define DSA_F_DSA_SIGN 106 -# define DSA_F_DSA_SIGN_SETUP 107 -# define DSA_F_DSA_SIG_NEW 102 -# define DSA_F_OLD_DSA_PRIV_DECODE 122 -# define DSA_F_PKEY_DSA_CTRL 120 -# define DSA_F_PKEY_DSA_KEYGEN 121 - -/* Reason codes. */ -# define DSA_R_BAD_Q_VALUE 102 -# define DSA_R_BN_DECODE_ERROR 108 -# define DSA_R_BN_ERROR 109 -# define DSA_R_DECODE_ERROR 104 -# define DSA_R_INVALID_DIGEST_TYPE 106 -# define DSA_R_INVALID_PARAMETERS 112 -# define DSA_R_MISSING_PARAMETERS 101 -# define DSA_R_MODULUS_TOO_LARGE 103 -# define DSA_R_NO_PARAMETERS_SET 107 -# define DSA_R_PARAMETER_ENCODING_ERROR 105 -# define DSA_R_Q_NOT_PRIME 113 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/dtls1.h b/android/armeabi/include/openssl/dtls1.h deleted file mode 100644 index f4769f83..00000000 --- a/android/armeabi/include/openssl/dtls1.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_DTLS1_H -# define HEADER_DTLS1_H - -#ifdef __cplusplus -extern "C" { -#endif - -# define DTLS1_VERSION 0xFEFF -# define DTLS1_2_VERSION 0xFEFD -# define DTLS_MIN_VERSION DTLS1_VERSION -# define DTLS_MAX_VERSION DTLS1_2_VERSION -# define DTLS1_VERSION_MAJOR 0xFE - -# define DTLS1_BAD_VER 0x0100 - -/* Special value for method supporting multiple versions */ -# define DTLS_ANY_VERSION 0x1FFFF - -/* lengths of messages */ -# define DTLS1_COOKIE_LENGTH 256 - -# define DTLS1_RT_HEADER_LENGTH 13 - -# define DTLS1_HM_HEADER_LENGTH 12 - -# define DTLS1_HM_BAD_FRAGMENT -2 -# define DTLS1_HM_FRAGMENT_RETRY -3 - -# define DTLS1_CCS_HEADER_LENGTH 1 - -# ifdef DTLS1_AD_MISSING_HANDSHAKE_MESSAGE -# define DTLS1_AL_HEADER_LENGTH 7 -# else -# define DTLS1_AL_HEADER_LENGTH 2 -# endif - - -/* Timeout multipliers (timeout slice is defined in apps/timeouts.h */ -# define DTLS1_TMO_READ_COUNT 2 -# define DTLS1_TMO_WRITE_COUNT 2 - -# define DTLS1_TMO_ALERT_COUNT 12 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/android/armeabi/include/openssl/e_os2.h b/android/armeabi/include/openssl/e_os2.h deleted file mode 100644 index 99ea3477..00000000 --- a/android/armeabi/include/openssl/e_os2.h +++ /dev/null @@ -1,311 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_E_OS2_H -# define HEADER_E_OS2_H - -# include <openssl/opensslconf.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/****************************************************************************** - * Detect operating systems. This probably needs completing. - * The result is that at least one OPENSSL_SYS_os macro should be defined. - * However, if none is defined, Unix is assumed. - **/ - -# define OPENSSL_SYS_UNIX - -/* --------------------- Microsoft operating systems ---------------------- */ - -/* - * Note that MSDOS actually denotes 32-bit environments running on top of - * MS-DOS, such as DJGPP one. - */ -# if defined(OPENSSL_SYS_MSDOS) -# undef OPENSSL_SYS_UNIX -# endif - -/* - * For 32 bit environment, there seems to be the CygWin environment and then - * all the others that try to do the same thing Microsoft does... - */ -/* - * UEFI lives here because it might be built with a Microsoft toolchain and - * we need to avoid the false positive match on Windows. - */ -# if defined(OPENSSL_SYS_UEFI) -# undef OPENSSL_SYS_UNIX -# elif defined(OPENSSL_SYS_UWIN) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WIN32_UWIN -# else -# if defined(__CYGWIN__) || defined(OPENSSL_SYS_CYGWIN) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WIN32_CYGWIN -# else -# if defined(_WIN32) || defined(OPENSSL_SYS_WIN32) -# undef OPENSSL_SYS_UNIX -# if !defined(OPENSSL_SYS_WIN32) -# define OPENSSL_SYS_WIN32 -# endif -# endif -# if defined(_WIN64) || defined(OPENSSL_SYS_WIN64) -# undef OPENSSL_SYS_UNIX -# if !defined(OPENSSL_SYS_WIN64) -# define OPENSSL_SYS_WIN64 -# endif -# endif -# if defined(OPENSSL_SYS_WINNT) -# undef OPENSSL_SYS_UNIX -# endif -# if defined(OPENSSL_SYS_WINCE) -# undef OPENSSL_SYS_UNIX -# endif -# endif -# endif - -/* Anything that tries to look like Microsoft is "Windows" */ -# if defined(OPENSSL_SYS_WIN32) || defined(OPENSSL_SYS_WIN64) || defined(OPENSSL_SYS_WINNT) || defined(OPENSSL_SYS_WINCE) -# undef OPENSSL_SYS_UNIX -# define OPENSSL_SYS_WINDOWS -# ifndef OPENSSL_SYS_MSDOS -# define OPENSSL_SYS_MSDOS -# endif -# endif - -/* - * DLL settings. This part is a bit tough, because it's up to the - * application implementor how he or she will link the application, so it - * requires some macro to be used. - */ -# ifdef OPENSSL_SYS_WINDOWS -# ifndef OPENSSL_OPT_WINDLL -# if defined(_WINDLL) /* This is used when building OpenSSL to - * indicate that DLL linkage should be used */ -# define OPENSSL_OPT_WINDLL -# endif -# endif -# endif - -/* ------------------------------- OpenVMS -------------------------------- */ -# if defined(__VMS) || defined(VMS) || defined(OPENSSL_SYS_VMS) -# if !defined(OPENSSL_SYS_VMS) -# undef OPENSSL_SYS_UNIX -# endif -# define OPENSSL_SYS_VMS -# if defined(__DECC) -# define OPENSSL_SYS_VMS_DECC -# elif defined(__DECCXX) -# define OPENSSL_SYS_VMS_DECC -# define OPENSSL_SYS_VMS_DECCXX -# else -# define OPENSSL_SYS_VMS_NODECC -# endif -# endif - -/* -------------------------------- Unix ---------------------------------- */ -# ifdef OPENSSL_SYS_UNIX -# if defined(linux) || defined(__linux__) && !defined(OPENSSL_SYS_LINUX) -# define OPENSSL_SYS_LINUX -# endif -# if defined(_AIX) && !defined(OPENSSL_SYS_AIX) -# define OPENSSL_SYS_AIX -# endif -# endif - -/* -------------------------------- VOS ----------------------------------- */ -# if defined(__VOS__) && !defined(OPENSSL_SYS_VOS) -# define OPENSSL_SYS_VOS -# ifdef __HPPA__ -# define OPENSSL_SYS_VOS_HPPA -# endif -# ifdef __IA32__ -# define OPENSSL_SYS_VOS_IA32 -# endif -# endif - -/** - * That's it for OS-specific stuff - *****************************************************************************/ - -/* Specials for I/O an exit */ -# ifdef OPENSSL_SYS_MSDOS -# define OPENSSL_UNISTD_IO <io.h> -# define OPENSSL_DECLARE_EXIT extern void exit(int); -# else -# define OPENSSL_UNISTD_IO OPENSSL_UNISTD -# define OPENSSL_DECLARE_EXIT /* declared in unistd.h */ -# endif - -/*- - * Definitions of OPENSSL_GLOBAL and OPENSSL_EXTERN, to define and declare - * certain global symbols that, with some compilers under VMS, have to be - * defined and declared explicitly with globaldef and globalref. - * Definitions of OPENSSL_EXPORT and OPENSSL_IMPORT, to define and declare - * DLL exports and imports for compilers under Win32. These are a little - * more complicated to use. Basically, for any library that exports some - * global variables, the following code must be present in the header file - * that declares them, before OPENSSL_EXTERN is used: - * - * #ifdef SOME_BUILD_FLAG_MACRO - * # undef OPENSSL_EXTERN - * # define OPENSSL_EXTERN OPENSSL_EXPORT - * #endif - * - * The default is to have OPENSSL_EXPORT, OPENSSL_EXTERN and OPENSSL_GLOBAL - * have some generally sensible values. - */ - -# if defined(OPENSSL_SYS_VMS_NODECC) -# define OPENSSL_EXPORT globalref -# define OPENSSL_EXTERN globalref -# define OPENSSL_GLOBAL globaldef -# elif defined(OPENSSL_SYS_WINDOWS) && defined(OPENSSL_OPT_WINDLL) -# define OPENSSL_EXPORT extern __declspec(dllexport) -# define OPENSSL_EXTERN extern __declspec(dllimport) -# define OPENSSL_GLOBAL -# else -# define OPENSSL_EXPORT extern -# define OPENSSL_EXTERN extern -# define OPENSSL_GLOBAL -# endif - -/*- - * Macros to allow global variables to be reached through function calls when - * required (if a shared library version requires it, for example. - * The way it's done allows definitions like this: - * - * // in foobar.c - * OPENSSL_IMPLEMENT_GLOBAL(int,foobar,0) - * // in foobar.h - * OPENSSL_DECLARE_GLOBAL(int,foobar); - * #define foobar OPENSSL_GLOBAL_REF(foobar) - */ -# ifdef OPENSSL_EXPORT_VAR_AS_FUNCTION -# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) \ - type *_shadow_##name(void) \ - { static type _hide_##name=value; return &_hide_##name; } -# define OPENSSL_DECLARE_GLOBAL(type,name) type *_shadow_##name(void) -# define OPENSSL_GLOBAL_REF(name) (*(_shadow_##name())) -# else -# define OPENSSL_IMPLEMENT_GLOBAL(type,name,value) OPENSSL_GLOBAL type _shadow_##name=value; -# define OPENSSL_DECLARE_GLOBAL(type,name) OPENSSL_EXPORT type _shadow_##name -# define OPENSSL_GLOBAL_REF(name) _shadow_##name -# endif - -# ifdef _WIN32 -# ifdef _WIN64 -# define ossl_ssize_t __int64 -# define OSSL_SSIZE_MAX _I64_MAX -# else -# define ossl_ssize_t int -# define OSSL_SSIZE_MAX INT_MAX -# endif -# endif - -# if defined(OPENSSL_SYS_UEFI) && !defined(ssize_t) -# define ossl_ssize_t int -# define OSSL_SSIZE_MAX INT_MAX -# endif - -# ifndef ossl_ssize_t -# define ossl_ssize_t ssize_t -# if defined(SSIZE_MAX) -# define OSSL_SSIZE_MAX SSIZE_MAX -# elif defined(_POSIX_SSIZE_MAX) -# define OSSL_SSIZE_MAX _POSIX_SSIZE_MAX -# endif -# endif - -# ifdef DEBUG_UNUSED -# define __owur __attribute__((__warn_unused_result__)) -# else -# define __owur -# endif - -/* Standard integer types */ -# if defined(OPENSSL_SYS_UEFI) -typedef INT8 int8_t; -typedef UINT8 uint8_t; -typedef INT16 int16_t; -typedef UINT16 uint16_t; -typedef INT32 int32_t; -typedef UINT32 uint32_t; -typedef INT64 int64_t; -typedef UINT64 uint64_t; -# define PRIu64 "%Lu" -# elif (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || \ - defined(__osf__) || defined(__sgi) || defined(__hpux) || \ - defined(OPENSSL_SYS_VMS) || defined (__OpenBSD__) -# include <inttypes.h> -# elif defined(_MSC_VER) && _MSC_VER<=1500 -/* - * minimally required typdefs for systems not supporting inttypes.h or - * stdint.h: currently just older VC++ - */ -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef short int16_t; -typedef unsigned short uint16_t; -typedef int int32_t; -typedef unsigned int uint32_t; -typedef __int64 int64_t; -typedef unsigned __int64 uint64_t; -# else -# include <stdint.h> -# endif - -/* - * We need a format operator for some client tools for uint64_t. If inttypes.h - * isn't available or did not define it, just go with hard-coded. - */ -# ifndef PRIu64 -# ifdef SIXTY_FOUR_BIT_LONG -# define PRIu64 "lu" -# else -# define PRIu64 "llu" -# endif -# endif - -/* ossl_inline: portable inline definition usable in public headers */ -# if !defined(inline) && !defined(__cplusplus) -# if defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L - /* just use inline */ -# define ossl_inline inline -# elif defined(__GNUC__) && __GNUC__>=2 -# define ossl_inline __inline__ -# elif defined(_MSC_VER) - /* - * Visual Studio: inline is available in C++ only, however - * __inline is available for C, see - * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx - */ -# define ossl_inline __inline -# else -# define ossl_inline -# endif -# else -# define ossl_inline inline -# endif - -# if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112L -# define ossl_noreturn _Noreturn -# elif defined(__GNUC__) && __GNUC__ >= 2 -# define ossl_noreturn __attribute__((noreturn)) -# else -# define ossl_noreturn -# endif - -#ifdef __cplusplus -} -#endif -#endif diff --git a/android/armeabi/include/openssl/ebcdic.h b/android/armeabi/include/openssl/ebcdic.h deleted file mode 100644 index aa012855..00000000 --- a/android/armeabi/include/openssl/ebcdic.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_EBCDIC_H -# define HEADER_EBCDIC_H - -# include <stdlib.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* Avoid name clashes with other applications */ -# define os_toascii _openssl_os_toascii -# define os_toebcdic _openssl_os_toebcdic -# define ebcdic2ascii _openssl_ebcdic2ascii -# define ascii2ebcdic _openssl_ascii2ebcdic - -extern const unsigned char os_toascii[256]; -extern const unsigned char os_toebcdic[256]; -void *ebcdic2ascii(void *dest, const void *srce, size_t count); -void *ascii2ebcdic(void *dest, const void *srce, size_t count); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/android/armeabi/include/openssl/ec.h b/android/armeabi/include/openssl/ec.h deleted file mode 100644 index 656cb410..00000000 --- a/android/armeabi/include/openssl/ec.h +++ /dev/null @@ -1,1581 +0,0 @@ -/* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the OpenSSL open source - * license provided above. - * - * The elliptic curve binary polynomial software is originally written by - * Sheueling Chang Shantz and Douglas Stebila of Sun Microsystems Laboratories. - * - */ - -#ifndef HEADER_EC_H -# define HEADER_EC_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_EC -# include <openssl/asn1.h> -# include <openssl/symhacks.h> -# if OPENSSL_API_COMPAT < 0x10100000L -# include <openssl/bn.h> -# endif -# ifdef __cplusplus -extern "C" { -# endif - -# ifndef OPENSSL_ECC_MAX_FIELD_BITS -# define OPENSSL_ECC_MAX_FIELD_BITS 661 -# endif - -/** Enum for the point conversion form as defined in X9.62 (ECDSA) - * for the encoding of a elliptic curve point (x,y) */ -typedef enum { - /** the point is encoded as z||x, where the octet z specifies - * which solution of the quadratic equation y is */ - POINT_CONVERSION_COMPRESSED = 2, - /** the point is encoded as z||x||y, where z is the octet 0x04 */ - POINT_CONVERSION_UNCOMPRESSED = 4, - /** the point is encoded as z||x||y, where the octet z specifies - * which solution of the quadratic equation y is */ - POINT_CONVERSION_HYBRID = 6 -} point_conversion_form_t; - -typedef struct ec_method_st EC_METHOD; -typedef struct ec_group_st EC_GROUP; -typedef struct ec_point_st EC_POINT; -typedef struct ecpk_parameters_st ECPKPARAMETERS; -typedef struct ec_parameters_st ECPARAMETERS; - -/********************************************************************/ -/* EC_METHODs for curves over GF(p) */ -/********************************************************************/ - -/** Returns the basic GFp ec methods which provides the basis for the - * optimized methods. - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_simple_method(void); - -/** Returns GFp methods using montgomery multiplication. - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_mont_method(void); - -/** Returns GFp methods using optimized methods for NIST recommended curves - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_nist_method(void); - -# ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 -/** Returns 64-bit optimized methods for nistp224 - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_nistp224_method(void); - -/** Returns 64-bit optimized methods for nistp256 - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_nistp256_method(void); - -/** Returns 64-bit optimized methods for nistp521 - * \return EC_METHOD object - */ -const EC_METHOD *EC_GFp_nistp521_method(void); -# endif - -# ifndef OPENSSL_NO_EC2M -/********************************************************************/ -/* EC_METHOD for curves over GF(2^m) */ -/********************************************************************/ - -/** Returns the basic GF2m ec method - * \return EC_METHOD object - */ -const EC_METHOD *EC_GF2m_simple_method(void); - -# endif - -/********************************************************************/ -/* EC_GROUP functions */ -/********************************************************************/ - -/** Creates a new EC_GROUP object - * \param meth EC_METHOD to use - * \return newly created EC_GROUP object or NULL in case of an error. - */ -EC_GROUP *EC_GROUP_new(const EC_METHOD *meth); - -/** Frees a EC_GROUP object - * \param group EC_GROUP object to be freed. - */ -void EC_GROUP_free(EC_GROUP *group); - -/** Clears and frees a EC_GROUP object - * \param group EC_GROUP object to be cleared and freed. - */ -void EC_GROUP_clear_free(EC_GROUP *group); - -/** Copies EC_GROUP objects. Note: both EC_GROUPs must use the same EC_METHOD. - * \param dst destination EC_GROUP object - * \param src source EC_GROUP object - * \return 1 on success and 0 if an error occurred. - */ -int EC_GROUP_copy(EC_GROUP *dst, const EC_GROUP *src); - -/** Creates a new EC_GROUP object and copies the copies the content - * form src to the newly created EC_KEY object - * \param src source EC_GROUP object - * \return newly created EC_GROUP object or NULL in case of an error. - */ -EC_GROUP *EC_GROUP_dup(const EC_GROUP *src); - -/** Returns the EC_METHOD of the EC_GROUP object. - * \param group EC_GROUP object - * \return EC_METHOD used in this EC_GROUP object. - */ -const EC_METHOD *EC_GROUP_method_of(const EC_GROUP *group); - -/** Returns the field type of the EC_METHOD. - * \param meth EC_METHOD object - * \return NID of the underlying field type OID. - */ -int EC_METHOD_get_field_type(const EC_METHOD *meth); - -/** Sets the generator and it's order/cofactor of a EC_GROUP object. - * \param group EC_GROUP object - * \param generator EC_POINT object with the generator. - * \param order the order of the group generated by the generator. - * \param cofactor the index of the sub-group generated by the generator - * in the group of all points on the elliptic curve. - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, - const BIGNUM *order, const BIGNUM *cofactor); - -/** Returns the generator of a EC_GROUP object. - * \param group EC_GROUP object - * \return the currently used generator (possibly NULL). - */ -const EC_POINT *EC_GROUP_get0_generator(const EC_GROUP *group); - -/** Returns the montgomery data for order(Generator) - * \param group EC_GROUP object - * \return the currently used montgomery data (possibly NULL). -*/ -BN_MONT_CTX *EC_GROUP_get_mont_data(const EC_GROUP *group); - -/** Gets the order of a EC_GROUP - * \param group EC_GROUP object - * \param order BIGNUM to which the order is copied - * \param ctx unused - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx); - -/** Gets the order of an EC_GROUP - * \param group EC_GROUP object - * \return the group order - */ -const BIGNUM *EC_GROUP_get0_order(const EC_GROUP *group); - -/** Gets the number of bits of the order of an EC_GROUP - * \param group EC_GROUP object - * \return number of bits of group order. - */ -int EC_GROUP_order_bits(const EC_GROUP *group); - -/** Gets the cofactor of a EC_GROUP - * \param group EC_GROUP object - * \param cofactor BIGNUM to which the cofactor is copied - * \param ctx unused - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, - BN_CTX *ctx); - -/** Gets the cofactor of an EC_GROUP - * \param group EC_GROUP object - * \return the group cofactor - */ -const BIGNUM *EC_GROUP_get0_cofactor(const EC_GROUP *group); - -/** Sets the name of a EC_GROUP object - * \param group EC_GROUP object - * \param nid NID of the curve name OID - */ -void EC_GROUP_set_curve_name(EC_GROUP *group, int nid); - -/** Returns the curve name of a EC_GROUP object - * \param group EC_GROUP object - * \return NID of the curve name OID or 0 if not set. - */ -int EC_GROUP_get_curve_name(const EC_GROUP *group); - -void EC_GROUP_set_asn1_flag(EC_GROUP *group, int flag); -int EC_GROUP_get_asn1_flag(const EC_GROUP *group); - -void EC_GROUP_set_point_conversion_form(EC_GROUP *group, - point_conversion_form_t form); -point_conversion_form_t EC_GROUP_get_point_conversion_form(const EC_GROUP *); - -unsigned char *EC_GROUP_get0_seed(const EC_GROUP *x); -size_t EC_GROUP_get_seed_len(const EC_GROUP *); -size_t EC_GROUP_set_seed(EC_GROUP *, const unsigned char *, size_t len); - -/** Sets the parameter of a ec over GFp defined by y^2 = x^3 + a*x + b - * \param group EC_GROUP object - * \param p BIGNUM with the prime number - * \param a BIGNUM with parameter a of the equation - * \param b BIGNUM with parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_set_curve_GFp(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, - const BIGNUM *b, BN_CTX *ctx); - -/** Gets the parameter of the ec over GFp defined by y^2 = x^3 + a*x + b - * \param group EC_GROUP object - * \param p BIGNUM for the prime number - * \param a BIGNUM for parameter a of the equation - * \param b BIGNUM for parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_get_curve_GFp(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, - BIGNUM *b, BN_CTX *ctx); - -# ifndef OPENSSL_NO_EC2M -/** Sets the parameter of a ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b - * \param group EC_GROUP object - * \param p BIGNUM with the polynomial defining the underlying field - * \param a BIGNUM with parameter a of the equation - * \param b BIGNUM with parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_set_curve_GF2m(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, - const BIGNUM *b, BN_CTX *ctx); - -/** Gets the parameter of the ec over GF2m defined by y^2 + x*y = x^3 + a*x^2 + b - * \param group EC_GROUP object - * \param p BIGNUM for the polynomial defining the underlying field - * \param a BIGNUM for parameter a of the equation - * \param b BIGNUM for parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_get_curve_GF2m(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, - BIGNUM *b, BN_CTX *ctx); -# endif -/** Returns the number of bits needed to represent a field element - * \param group EC_GROUP object - * \return number of bits needed to represent a field element - */ -int EC_GROUP_get_degree(const EC_GROUP *group); - -/** Checks whether the parameter in the EC_GROUP define a valid ec group - * \param group EC_GROUP object - * \param ctx BN_CTX object (optional) - * \return 1 if group is a valid ec group and 0 otherwise - */ -int EC_GROUP_check(const EC_GROUP *group, BN_CTX *ctx); - -/** Checks whether the discriminant of the elliptic curve is zero or not - * \param group EC_GROUP object - * \param ctx BN_CTX object (optional) - * \return 1 if the discriminant is not zero and 0 otherwise - */ -int EC_GROUP_check_discriminant(const EC_GROUP *group, BN_CTX *ctx); - -/** Compares two EC_GROUP objects - * \param a first EC_GROUP object - * \param b second EC_GROUP object - * \param ctx BN_CTX object (optional) - * \return 0 if the groups are equal, 1 if not, or -1 on error - */ -int EC_GROUP_cmp(const EC_GROUP *a, const EC_GROUP *b, BN_CTX *ctx); - -/* - * EC_GROUP_new_GF*() calls EC_GROUP_new() and EC_GROUP_set_GF*() after - * choosing an appropriate EC_METHOD - */ - -/** Creates a new EC_GROUP object with the specified parameters defined - * over GFp (defined by the equation y^2 = x^3 + a*x + b) - * \param p BIGNUM with the prime number - * \param a BIGNUM with the parameter a of the equation - * \param b BIGNUM with the parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return newly created EC_GROUP object with the specified parameters - */ -EC_GROUP *EC_GROUP_new_curve_GFp(const BIGNUM *p, const BIGNUM *a, - const BIGNUM *b, BN_CTX *ctx); -# ifndef OPENSSL_NO_EC2M -/** Creates a new EC_GROUP object with the specified parameters defined - * over GF2m (defined by the equation y^2 + x*y = x^3 + a*x^2 + b) - * \param p BIGNUM with the polynomial defining the underlying field - * \param a BIGNUM with the parameter a of the equation - * \param b BIGNUM with the parameter b of the equation - * \param ctx BN_CTX object (optional) - * \return newly created EC_GROUP object with the specified parameters - */ -EC_GROUP *EC_GROUP_new_curve_GF2m(const BIGNUM *p, const BIGNUM *a, - const BIGNUM *b, BN_CTX *ctx); -# endif - -/** Creates a EC_GROUP object with a curve specified by a NID - * \param nid NID of the OID of the curve name - * \return newly created EC_GROUP object with specified curve or NULL - * if an error occurred - */ -EC_GROUP *EC_GROUP_new_by_curve_name(int nid); - -/** Creates a new EC_GROUP object from an ECPARAMETERS object - * \param params pointer to the ECPARAMETERS object - * \return newly created EC_GROUP object with specified curve or NULL - * if an error occurred - */ -EC_GROUP *EC_GROUP_new_from_ecparameters(const ECPARAMETERS *params); - -/** Creates an ECPARAMETERS object for the the given EC_GROUP object. - * \param group pointer to the EC_GROUP object - * \param params pointer to an existing ECPARAMETERS object or NULL - * \return pointer to the new ECPARAMETERS object or NULL - * if an error occurred. - */ -ECPARAMETERS *EC_GROUP_get_ecparameters(const EC_GROUP *group, - ECPARAMETERS *params); - -/** Creates a new EC_GROUP object from an ECPKPARAMETERS object - * \param params pointer to an existing ECPKPARAMETERS object, or NULL - * \return newly created EC_GROUP object with specified curve, or NULL - * if an error occurred - */ -EC_GROUP *EC_GROUP_new_from_ecpkparameters(const ECPKPARAMETERS *params); - -/** Creates an ECPKPARAMETERS object for the the given EC_GROUP object. - * \param group pointer to the EC_GROUP object - * \param params pointer to an existing ECPKPARAMETERS object or NULL - * \return pointer to the new ECPKPARAMETERS object or NULL - * if an error occurred. - */ -ECPKPARAMETERS *EC_GROUP_get_ecpkparameters(const EC_GROUP *group, - ECPKPARAMETERS *params); - -/********************************************************************/ -/* handling of internal curves */ -/********************************************************************/ - -typedef struct { - int nid; - const char *comment; -} EC_builtin_curve; - -/* - * EC_builtin_curves(EC_builtin_curve *r, size_t size) returns number of all - * available curves or zero if a error occurred. In case r is not zero, - * nitems EC_builtin_curve structures are filled with the data of the first - * nitems internal groups - */ -size_t EC_get_builtin_curves(EC_builtin_curve *r, size_t nitems); - -const char *EC_curve_nid2nist(int nid); -int EC_curve_nist2nid(const char *name); - -/********************************************************************/ -/* EC_POINT functions */ -/********************************************************************/ - -/** Creates a new EC_POINT object for the specified EC_GROUP - * \param group EC_GROUP the underlying EC_GROUP object - * \return newly created EC_POINT object or NULL if an error occurred - */ -EC_POINT *EC_POINT_new(const EC_GROUP *group); - -/** Frees a EC_POINT object - * \param point EC_POINT object to be freed - */ -void EC_POINT_free(EC_POINT *point); - -/** Clears and frees a EC_POINT object - * \param point EC_POINT object to be cleared and freed - */ -void EC_POINT_clear_free(EC_POINT *point); - -/** Copies EC_POINT object - * \param dst destination EC_POINT object - * \param src source EC_POINT object - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_copy(EC_POINT *dst, const EC_POINT *src); - -/** Creates a new EC_POINT object and copies the content of the supplied - * EC_POINT - * \param src source EC_POINT object - * \param group underlying the EC_GROUP object - * \return newly created EC_POINT object or NULL if an error occurred - */ -EC_POINT *EC_POINT_dup(const EC_POINT *src, const EC_GROUP *group); - -/** Returns the EC_METHOD used in EC_POINT object - * \param point EC_POINT object - * \return the EC_METHOD used - */ -const EC_METHOD *EC_POINT_method_of(const EC_POINT *point); - -/** Sets a point to infinity (neutral element) - * \param group underlying EC_GROUP object - * \param point EC_POINT to set to infinity - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_set_to_infinity(const EC_GROUP *group, EC_POINT *point); - -/** Sets the jacobian projective coordinates of a EC_POINT over GFp - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with the x-coordinate - * \param y BIGNUM with the y-coordinate - * \param z BIGNUM with the z-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_set_Jprojective_coordinates_GFp(const EC_GROUP *group, - EC_POINT *p, const BIGNUM *x, - const BIGNUM *y, const BIGNUM *z, - BN_CTX *ctx); - -/** Gets the jacobian projective coordinates of a EC_POINT over GFp - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM for the x-coordinate - * \param y BIGNUM for the y-coordinate - * \param z BIGNUM for the z-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_get_Jprojective_coordinates_GFp(const EC_GROUP *group, - const EC_POINT *p, BIGNUM *x, - BIGNUM *y, BIGNUM *z, - BN_CTX *ctx); - -/** Sets the affine coordinates of a EC_POINT over GFp - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with the x-coordinate - * \param y BIGNUM with the y-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_set_affine_coordinates_GFp(const EC_GROUP *group, EC_POINT *p, - const BIGNUM *x, const BIGNUM *y, - BN_CTX *ctx); - -/** Gets the affine coordinates of a EC_POINT over GFp - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM for the x-coordinate - * \param y BIGNUM for the y-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_get_affine_coordinates_GFp(const EC_GROUP *group, - const EC_POINT *p, BIGNUM *x, - BIGNUM *y, BN_CTX *ctx); - -/** Sets the x9.62 compressed coordinates of a EC_POINT over GFp - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with x-coordinate - * \param y_bit integer with the y-Bit (either 0 or 1) - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_set_compressed_coordinates_GFp(const EC_GROUP *group, - EC_POINT *p, const BIGNUM *x, - int y_bit, BN_CTX *ctx); -# ifndef OPENSSL_NO_EC2M -/** Sets the affine coordinates of a EC_POINT over GF2m - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with the x-coordinate - * \param y BIGNUM with the y-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_set_affine_coordinates_GF2m(const EC_GROUP *group, EC_POINT *p, - const BIGNUM *x, const BIGNUM *y, - BN_CTX *ctx); - -/** Gets the affine coordinates of a EC_POINT over GF2m - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM for the x-coordinate - * \param y BIGNUM for the y-coordinate - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_get_affine_coordinates_GF2m(const EC_GROUP *group, - const EC_POINT *p, BIGNUM *x, - BIGNUM *y, BN_CTX *ctx); - -/** Sets the x9.62 compressed coordinates of a EC_POINT over GF2m - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param x BIGNUM with x-coordinate - * \param y_bit integer with the y-Bit (either 0 or 1) - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_set_compressed_coordinates_GF2m(const EC_GROUP *group, - EC_POINT *p, const BIGNUM *x, - int y_bit, BN_CTX *ctx); -# endif -/** Encodes a EC_POINT object to a octet string - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param form point conversion form - * \param buf memory buffer for the result. If NULL the function returns - * required buffer size. - * \param len length of the memory buffer - * \param ctx BN_CTX object (optional) - * \return the length of the encoded octet string or 0 if an error occurred - */ -size_t EC_POINT_point2oct(const EC_GROUP *group, const EC_POINT *p, - point_conversion_form_t form, - unsigned char *buf, size_t len, BN_CTX *ctx); - -/** Decodes a EC_POINT from a octet string - * \param group underlying EC_GROUP object - * \param p EC_POINT object - * \param buf memory buffer with the encoded ec point - * \param len length of the encoded ec point - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_oct2point(const EC_GROUP *group, EC_POINT *p, - const unsigned char *buf, size_t len, BN_CTX *ctx); - -/** Encodes an EC_POINT object to an allocated octet string - * \param group underlying EC_GROUP object - * \param point EC_POINT object - * \param form point conversion form - * \param pbuf returns pointer to allocated buffer - * \param len length of the memory buffer - * \param ctx BN_CTX object (optional) - * \return the length of the encoded octet string or 0 if an error occurred - */ - -size_t EC_POINT_point2buf(const EC_GROUP *group, const EC_POINT *point, - point_conversion_form_t form, - unsigned char **pbuf, BN_CTX *ctx); - -/* other interfaces to point2oct/oct2point: */ -BIGNUM *EC_POINT_point2bn(const EC_GROUP *, const EC_POINT *, - point_conversion_form_t form, BIGNUM *, BN_CTX *); -EC_POINT *EC_POINT_bn2point(const EC_GROUP *, const BIGNUM *, - EC_POINT *, BN_CTX *); -char *EC_POINT_point2hex(const EC_GROUP *, const EC_POINT *, - point_conversion_form_t form, BN_CTX *); -EC_POINT *EC_POINT_hex2point(const EC_GROUP *, const char *, - EC_POINT *, BN_CTX *); - -/********************************************************************/ -/* functions for doing EC_POINT arithmetic */ -/********************************************************************/ - -/** Computes the sum of two EC_POINT - * \param group underlying EC_GROUP object - * \param r EC_POINT object for the result (r = a + b) - * \param a EC_POINT object with the first summand - * \param b EC_POINT object with the second summand - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, - const EC_POINT *b, BN_CTX *ctx); - -/** Computes the double of a EC_POINT - * \param group underlying EC_GROUP object - * \param r EC_POINT object for the result (r = 2 * a) - * \param a EC_POINT object - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, - BN_CTX *ctx); - -/** Computes the inverse of a EC_POINT - * \param group underlying EC_GROUP object - * \param a EC_POINT object to be inverted (it's used for the result as well) - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_invert(const EC_GROUP *group, EC_POINT *a, BN_CTX *ctx); - -/** Checks whether the point is the neutral element of the group - * \param group the underlying EC_GROUP object - * \param p EC_POINT object - * \return 1 if the point is the neutral element and 0 otherwise - */ -int EC_POINT_is_at_infinity(const EC_GROUP *group, const EC_POINT *p); - -/** Checks whether the point is on the curve - * \param group underlying EC_GROUP object - * \param point EC_POINT object to check - * \param ctx BN_CTX object (optional) - * \return 1 if the point is on the curve, 0 if not, or -1 on error - */ -int EC_POINT_is_on_curve(const EC_GROUP *group, const EC_POINT *point, - BN_CTX *ctx); - -/** Compares two EC_POINTs - * \param group underlying EC_GROUP object - * \param a first EC_POINT object - * \param b second EC_POINT object - * \param ctx BN_CTX object (optional) - * \return 1 if the points are not equal, 0 if they are, or -1 on error - */ -int EC_POINT_cmp(const EC_GROUP *group, const EC_POINT *a, const EC_POINT *b, - BN_CTX *ctx); - -int EC_POINT_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx); -int EC_POINTs_make_affine(const EC_GROUP *group, size_t num, - EC_POINT *points[], BN_CTX *ctx); - -/** Computes r = generator * n + sum_{i=0}^{num-1} p[i] * m[i] - * \param group underlying EC_GROUP object - * \param r EC_POINT object for the result - * \param n BIGNUM with the multiplier for the group generator (optional) - * \param num number further summands - * \param p array of size num of EC_POINT objects - * \param m array of size num of BIGNUM objects - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINTs_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, - size_t num, const EC_POINT *p[], const BIGNUM *m[], - BN_CTX *ctx); - -/** Computes r = generator * n + q * m - * \param group underlying EC_GROUP object - * \param r EC_POINT object for the result - * \param n BIGNUM with the multiplier for the group generator (optional) - * \param q EC_POINT object with the first factor of the second summand - * \param m BIGNUM with the second factor of the second summand - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_POINT_mul(const EC_GROUP *group, EC_POINT *r, const BIGNUM *n, - const EC_POINT *q, const BIGNUM *m, BN_CTX *ctx); - -/** Stores multiples of generator for faster point multiplication - * \param group EC_GROUP object - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ -int EC_GROUP_precompute_mult(EC_GROUP *group, BN_CTX *ctx); - -/** Reports whether a precomputation has been done - * \param group EC_GROUP object - * \return 1 if a pre-computation has been done and 0 otherwise - */ -int EC_GROUP_have_precompute_mult(const EC_GROUP *group); - -/********************************************************************/ -/* ASN1 stuff */ -/********************************************************************/ - -DECLARE_ASN1_ITEM(ECPKPARAMETERS) -DECLARE_ASN1_ALLOC_FUNCTIONS(ECPKPARAMETERS) -DECLARE_ASN1_ITEM(ECPARAMETERS) -DECLARE_ASN1_ALLOC_FUNCTIONS(ECPARAMETERS) - -/* - * EC_GROUP_get_basis_type() returns the NID of the basis type used to - * represent the field elements - */ -int EC_GROUP_get_basis_type(const EC_GROUP *); -# ifndef OPENSSL_NO_EC2M -int EC_GROUP_get_trinomial_basis(const EC_GROUP *, unsigned int *k); -int EC_GROUP_get_pentanomial_basis(const EC_GROUP *, unsigned int *k1, - unsigned int *k2, unsigned int *k3); -# endif - -# define OPENSSL_EC_EXPLICIT_CURVE 0x000 -# define OPENSSL_EC_NAMED_CURVE 0x001 - -EC_GROUP *d2i_ECPKParameters(EC_GROUP **, const unsigned char **in, long len); -int i2d_ECPKParameters(const EC_GROUP *, unsigned char **out); - -# define d2i_ECPKParameters_bio(bp,x) ASN1_d2i_bio_of(EC_GROUP,NULL,d2i_ECPKParameters,bp,x) -# define i2d_ECPKParameters_bio(bp,x) ASN1_i2d_bio_of_const(EC_GROUP,i2d_ECPKParameters,bp,x) -# define d2i_ECPKParameters_fp(fp,x) (EC_GROUP *)ASN1_d2i_fp(NULL, \ - (char *(*)())d2i_ECPKParameters,(fp),(unsigned char **)(x)) -# define i2d_ECPKParameters_fp(fp,x) ASN1_i2d_fp(i2d_ECPKParameters,(fp), \ - (unsigned char *)(x)) - -int ECPKParameters_print(BIO *bp, const EC_GROUP *x, int off); -# ifndef OPENSSL_NO_STDIO -int ECPKParameters_print_fp(FILE *fp, const EC_GROUP *x, int off); -# endif - -/********************************************************************/ -/* EC_KEY functions */ -/********************************************************************/ - -/* some values for the encoding_flag */ -# define EC_PKEY_NO_PARAMETERS 0x001 -# define EC_PKEY_NO_PUBKEY 0x002 - -/* some values for the flags field */ -# define EC_FLAG_NON_FIPS_ALLOW 0x1 -# define EC_FLAG_FIPS_CHECKED 0x2 -# define EC_FLAG_COFACTOR_ECDH 0x1000 - -/** Creates a new EC_KEY object. - * \return EC_KEY object or NULL if an error occurred. - */ -EC_KEY *EC_KEY_new(void); - -int EC_KEY_get_flags(const EC_KEY *key); - -void EC_KEY_set_flags(EC_KEY *key, int flags); - -void EC_KEY_clear_flags(EC_KEY *key, int flags); - -/** Creates a new EC_KEY object using a named curve as underlying - * EC_GROUP object. - * \param nid NID of the named curve. - * \return EC_KEY object or NULL if an error occurred. - */ -EC_KEY *EC_KEY_new_by_curve_name(int nid); - -/** Frees a EC_KEY object. - * \param key EC_KEY object to be freed. - */ -void EC_KEY_free(EC_KEY *key); - -/** Copies a EC_KEY object. - * \param dst destination EC_KEY object - * \param src src EC_KEY object - * \return dst or NULL if an error occurred. - */ -EC_KEY *EC_KEY_copy(EC_KEY *dst, const EC_KEY *src); - -/** Creates a new EC_KEY object and copies the content from src to it. - * \param src the source EC_KEY object - * \return newly created EC_KEY object or NULL if an error occurred. - */ -EC_KEY *EC_KEY_dup(const EC_KEY *src); - -/** Increases the internal reference count of a EC_KEY object. - * \param key EC_KEY object - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_up_ref(EC_KEY *key); - -/** Returns the EC_GROUP object of a EC_KEY object - * \param key EC_KEY object - * \return the EC_GROUP object (possibly NULL). - */ -const EC_GROUP *EC_KEY_get0_group(const EC_KEY *key); - -/** Sets the EC_GROUP of a EC_KEY object. - * \param key EC_KEY object - * \param group EC_GROUP to use in the EC_KEY object (note: the EC_KEY - * object will use an own copy of the EC_GROUP). - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_set_group(EC_KEY *key, const EC_GROUP *group); - -/** Returns the private key of a EC_KEY object. - * \param key EC_KEY object - * \return a BIGNUM with the private key (possibly NULL). - */ -const BIGNUM *EC_KEY_get0_private_key(const EC_KEY *key); - -/** Sets the private key of a EC_KEY object. - * \param key EC_KEY object - * \param prv BIGNUM with the private key (note: the EC_KEY object - * will use an own copy of the BIGNUM). - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_set_private_key(EC_KEY *key, const BIGNUM *prv); - -/** Returns the public key of a EC_KEY object. - * \param key the EC_KEY object - * \return a EC_POINT object with the public key (possibly NULL) - */ -const EC_POINT *EC_KEY_get0_public_key(const EC_KEY *key); - -/** Sets the public key of a EC_KEY object. - * \param key EC_KEY object - * \param pub EC_POINT object with the public key (note: the EC_KEY object - * will use an own copy of the EC_POINT object). - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_set_public_key(EC_KEY *key, const EC_POINT *pub); - -unsigned EC_KEY_get_enc_flags(const EC_KEY *key); -void EC_KEY_set_enc_flags(EC_KEY *eckey, unsigned int flags); -point_conversion_form_t EC_KEY_get_conv_form(const EC_KEY *key); -void EC_KEY_set_conv_form(EC_KEY *eckey, point_conversion_form_t cform); - -#define EC_KEY_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_EC_KEY, l, p, newf, dupf, freef) -int EC_KEY_set_ex_data(EC_KEY *key, int idx, void *arg); -void *EC_KEY_get_ex_data(const EC_KEY *key, int idx); - -/* wrapper functions for the underlying EC_GROUP object */ -void EC_KEY_set_asn1_flag(EC_KEY *eckey, int asn1_flag); - -/** Creates a table of pre-computed multiples of the generator to - * accelerate further EC_KEY operations. - * \param key EC_KEY object - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_precompute_mult(EC_KEY *key, BN_CTX *ctx); - -/** Creates a new ec private (and optional a new public) key. - * \param key EC_KEY object - * \return 1 on success and 0 if an error occurred. - */ -int EC_KEY_generate_key(EC_KEY *key); - -/** Verifies that a private and/or public key is valid. - * \param key the EC_KEY object - * \return 1 on success and 0 otherwise. - */ -int EC_KEY_check_key(const EC_KEY *key); - -/** Indicates if an EC_KEY can be used for signing. - * \param key the EC_KEY object - * \return 1 if can can sign and 0 otherwise. - */ -int EC_KEY_can_sign(const EC_KEY *eckey); - -/** Sets a public key from affine coordinates performing - * necessary NIST PKV tests. - * \param key the EC_KEY object - * \param x public key x coordinate - * \param y public key y coordinate - * \return 1 on success and 0 otherwise. - */ -int EC_KEY_set_public_key_affine_coordinates(EC_KEY *key, BIGNUM *x, - BIGNUM *y); - -/** Encodes an EC_KEY public key to an allocated octet string - * \param key key to encode - * \param form point conversion form - * \param pbuf returns pointer to allocated buffer - * \param len length of the memory buffer - * \param ctx BN_CTX object (optional) - * \return the length of the encoded octet string or 0 if an error occurred - */ - -size_t EC_KEY_key2buf(const EC_KEY *key, point_conversion_form_t form, - unsigned char **pbuf, BN_CTX *ctx); - -/** Decodes a EC_KEY public key from a octet string - * \param key key to decode - * \param buf memory buffer with the encoded ec point - * \param len length of the encoded ec point - * \param ctx BN_CTX object (optional) - * \return 1 on success and 0 if an error occurred - */ - -int EC_KEY_oct2key(EC_KEY *key, const unsigned char *buf, size_t len, - BN_CTX *ctx); - -/** Decodes an EC_KEY private key from an octet string - * \param key key to decode - * \param buf memory buffer with the encoded private key - * \param len length of the encoded key - * \return 1 on success and 0 if an error occurred - */ - -int EC_KEY_oct2priv(EC_KEY *key, const unsigned char *buf, size_t len); - -/** Encodes a EC_KEY private key to an octet string - * \param key key to encode - * \param buf memory buffer for the result. If NULL the function returns - * required buffer size. - * \param len length of the memory buffer - * \return the length of the encoded octet string or 0 if an error occurred - */ - -size_t EC_KEY_priv2oct(const EC_KEY *key, unsigned char *buf, size_t len); - -/** Encodes an EC_KEY private key to an allocated octet string - * \param key key to encode - * \param pbuf returns pointer to allocated buffer - * \return the length of the encoded octet string or 0 if an error occurred - */ - -size_t EC_KEY_priv2buf(const EC_KEY *eckey, unsigned char **pbuf); - -/********************************************************************/ -/* de- and encoding functions for SEC1 ECPrivateKey */ -/********************************************************************/ - -/** Decodes a private key from a memory buffer. - * \param key a pointer to a EC_KEY object which should be used (or NULL) - * \param in pointer to memory with the DER encoded private key - * \param len length of the DER encoded private key - * \return the decoded private key or NULL if an error occurred. - */ -EC_KEY *d2i_ECPrivateKey(EC_KEY **key, const unsigned char **in, long len); - -/** Encodes a private key object and stores the result in a buffer. - * \param key the EC_KEY object to encode - * \param out the buffer for the result (if NULL the function returns number - * of bytes needed). - * \return 1 on success and 0 if an error occurred. - */ -int i2d_ECPrivateKey(EC_KEY *key, unsigned char **out); - -/********************************************************************/ -/* de- and encoding functions for EC parameters */ -/********************************************************************/ - -/** Decodes ec parameter from a memory buffer. - * \param key a pointer to a EC_KEY object which should be used (or NULL) - * \param in pointer to memory with the DER encoded ec parameters - * \param len length of the DER encoded ec parameters - * \return a EC_KEY object with the decoded parameters or NULL if an error - * occurred. - */ -EC_KEY *d2i_ECParameters(EC_KEY **key, const unsigned char **in, long len); - -/** Encodes ec parameter and stores the result in a buffer. - * \param key the EC_KEY object with ec parameters to encode - * \param out the buffer for the result (if NULL the function returns number - * of bytes needed). - * \return 1 on success and 0 if an error occurred. - */ -int i2d_ECParameters(EC_KEY *key, unsigned char **out); - -/********************************************************************/ -/* de- and encoding functions for EC public key */ -/* (octet string, not DER -- hence 'o2i' and 'i2o') */ -/********************************************************************/ - -/** Decodes a ec public key from a octet string. - * \param key a pointer to a EC_KEY object which should be used - * \param in memory buffer with the encoded public key - * \param len length of the encoded public key - * \return EC_KEY object with decoded public key or NULL if an error - * occurred. - */ -EC_KEY *o2i_ECPublicKey(EC_KEY **key, const unsigned char **in, long len); - -/** Encodes a ec public key in an octet string. - * \param key the EC_KEY object with the public key - * \param out the buffer for the result (if NULL the function returns number - * of bytes needed). - * \return 1 on success and 0 if an error occurred - */ -int i2o_ECPublicKey(const EC_KEY *key, unsigned char **out); - -/** Prints out the ec parameters on human readable form. - * \param bp BIO object to which the information is printed - * \param key EC_KEY object - * \return 1 on success and 0 if an error occurred - */ -int ECParameters_print(BIO *bp, const EC_KEY *key); - -/** Prints out the contents of a EC_KEY object - * \param bp BIO object to which the information is printed - * \param key EC_KEY object - * \param off line offset - * \return 1 on success and 0 if an error occurred - */ -int EC_KEY_print(BIO *bp, const EC_KEY *key, int off); - -# ifndef OPENSSL_NO_STDIO -/** Prints out the ec parameters on human readable form. - * \param fp file descriptor to which the information is printed - * \param key EC_KEY object - * \return 1 on success and 0 if an error occurred - */ -int ECParameters_print_fp(FILE *fp, const EC_KEY *key); - -/** Prints out the contents of a EC_KEY object - * \param fp file descriptor to which the information is printed - * \param key EC_KEY object - * \param off line offset - * \return 1 on success and 0 if an error occurred - */ -int EC_KEY_print_fp(FILE *fp, const EC_KEY *key, int off); - -# endif - -const EC_KEY_METHOD *EC_KEY_OpenSSL(void); -const EC_KEY_METHOD *EC_KEY_get_default_method(void); -void EC_KEY_set_default_method(const EC_KEY_METHOD *meth); -const EC_KEY_METHOD *EC_KEY_get_method(const EC_KEY *key); -int EC_KEY_set_method(EC_KEY *key, const EC_KEY_METHOD *meth); -EC_KEY *EC_KEY_new_method(ENGINE *engine); - -int ECDH_KDF_X9_62(unsigned char *out, size_t outlen, - const unsigned char *Z, size_t Zlen, - const unsigned char *sinfo, size_t sinfolen, - const EVP_MD *md); - -int ECDH_compute_key(void *out, size_t outlen, const EC_POINT *pub_key, - const EC_KEY *ecdh, - void *(*KDF) (const void *in, size_t inlen, - void *out, size_t *outlen)); - -typedef struct ECDSA_SIG_st ECDSA_SIG; - -/** Allocates and initialize a ECDSA_SIG structure - * \return pointer to a ECDSA_SIG structure or NULL if an error occurred - */ -ECDSA_SIG *ECDSA_SIG_new(void); - -/** frees a ECDSA_SIG structure - * \param sig pointer to the ECDSA_SIG structure - */ -void ECDSA_SIG_free(ECDSA_SIG *sig); - -/** DER encode content of ECDSA_SIG object (note: this function modifies *pp - * (*pp += length of the DER encoded signature)). - * \param sig pointer to the ECDSA_SIG object - * \param pp pointer to a unsigned char pointer for the output or NULL - * \return the length of the DER encoded ECDSA_SIG object or 0 - */ -int i2d_ECDSA_SIG(const ECDSA_SIG *sig, unsigned char **pp); - -/** Decodes a DER encoded ECDSA signature (note: this function changes *pp - * (*pp += len)). - * \param sig pointer to ECDSA_SIG pointer (may be NULL) - * \param pp memory buffer with the DER encoded signature - * \param len length of the buffer - * \return pointer to the decoded ECDSA_SIG structure (or NULL) - */ -ECDSA_SIG *d2i_ECDSA_SIG(ECDSA_SIG **sig, const unsigned char **pp, long len); - -/** Accessor for r and s fields of ECDSA_SIG - * \param sig pointer to ECDSA_SIG pointer - * \param pr pointer to BIGNUM pointer for r (may be NULL) - * \param ps pointer to BIGNUM pointer for s (may be NULL) - */ -void ECDSA_SIG_get0(const ECDSA_SIG *sig, const BIGNUM **pr, const BIGNUM **ps); - -/** Setter for r and s fields of ECDSA_SIG - * \param sig pointer to ECDSA_SIG pointer - * \param r pointer to BIGNUM for r (may be NULL) - * \param s pointer to BIGNUM for s (may be NULL) - */ -int ECDSA_SIG_set0(ECDSA_SIG *sig, BIGNUM *r, BIGNUM *s); - -/** Computes the ECDSA signature of the given hash value using - * the supplied private key and returns the created signature. - * \param dgst pointer to the hash value - * \param dgst_len length of the hash value - * \param eckey EC_KEY object containing a private EC key - * \return pointer to a ECDSA_SIG structure or NULL if an error occurred - */ -ECDSA_SIG *ECDSA_do_sign(const unsigned char *dgst, int dgst_len, - EC_KEY *eckey); - -/** Computes ECDSA signature of a given hash value using the supplied - * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). - * \param dgst pointer to the hash value to sign - * \param dgstlen length of the hash value - * \param kinv BIGNUM with a pre-computed inverse k (optional) - * \param rp BIGNUM with a pre-computed rp value (optional), - * see ECDSA_sign_setup - * \param eckey EC_KEY object containing a private EC key - * \return pointer to a ECDSA_SIG structure or NULL if an error occurred - */ -ECDSA_SIG *ECDSA_do_sign_ex(const unsigned char *dgst, int dgstlen, - const BIGNUM *kinv, const BIGNUM *rp, - EC_KEY *eckey); - -/** Verifies that the supplied signature is a valid ECDSA - * signature of the supplied hash value using the supplied public key. - * \param dgst pointer to the hash value - * \param dgst_len length of the hash value - * \param sig ECDSA_SIG structure - * \param eckey EC_KEY object containing a public EC key - * \return 1 if the signature is valid, 0 if the signature is invalid - * and -1 on error - */ -int ECDSA_do_verify(const unsigned char *dgst, int dgst_len, - const ECDSA_SIG *sig, EC_KEY *eckey); - -/** Precompute parts of the signing operation - * \param eckey EC_KEY object containing a private EC key - * \param ctx BN_CTX object (optional) - * \param kinv BIGNUM pointer for the inverse of k - * \param rp BIGNUM pointer for x coordinate of k * generator - * \return 1 on success and 0 otherwise - */ -int ECDSA_sign_setup(EC_KEY *eckey, BN_CTX *ctx, BIGNUM **kinv, BIGNUM **rp); - -/** Computes ECDSA signature of a given hash value using the supplied - * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). - * \param type this parameter is ignored - * \param dgst pointer to the hash value to sign - * \param dgstlen length of the hash value - * \param sig memory for the DER encoded created signature - * \param siglen pointer to the length of the returned signature - * \param eckey EC_KEY object containing a private EC key - * \return 1 on success and 0 otherwise - */ -int ECDSA_sign(int type, const unsigned char *dgst, int dgstlen, - unsigned char *sig, unsigned int *siglen, EC_KEY *eckey); - -/** Computes ECDSA signature of a given hash value using the supplied - * private key (note: sig must point to ECDSA_size(eckey) bytes of memory). - * \param type this parameter is ignored - * \param dgst pointer to the hash value to sign - * \param dgstlen length of the hash value - * \param sig buffer to hold the DER encoded signature - * \param siglen pointer to the length of the returned signature - * \param kinv BIGNUM with a pre-computed inverse k (optional) - * \param rp BIGNUM with a pre-computed rp value (optional), - * see ECDSA_sign_setup - * \param eckey EC_KEY object containing a private EC key - * \return 1 on success and 0 otherwise - */ -int ECDSA_sign_ex(int type, const unsigned char *dgst, int dgstlen, - unsigned char *sig, unsigned int *siglen, - const BIGNUM *kinv, const BIGNUM *rp, EC_KEY *eckey); - -/** Verifies that the given signature is valid ECDSA signature - * of the supplied hash value using the specified public key. - * \param type this parameter is ignored - * \param dgst pointer to the hash value - * \param dgstlen length of the hash value - * \param sig pointer to the DER encoded signature - * \param siglen length of the DER encoded signature - * \param eckey EC_KEY object containing a public EC key - * \return 1 if the signature is valid, 0 if the signature is invalid - * and -1 on error - */ -int ECDSA_verify(int type, const unsigned char *dgst, int dgstlen, - const unsigned char *sig, int siglen, EC_KEY *eckey); - -/** Returns the maximum length of the DER encoded signature - * \param eckey EC_KEY object - * \return numbers of bytes required for the DER encoded signature - */ -int ECDSA_size(const EC_KEY *eckey); - -/********************************************************************/ -/* EC_KEY_METHOD constructors, destructors, writers and accessors */ -/********************************************************************/ - -EC_KEY_METHOD *EC_KEY_METHOD_new(const EC_KEY_METHOD *meth); -void EC_KEY_METHOD_free(EC_KEY_METHOD *meth); -void EC_KEY_METHOD_set_init(EC_KEY_METHOD *meth, - int (*init)(EC_KEY *key), - void (*finish)(EC_KEY *key), - int (*copy)(EC_KEY *dest, const EC_KEY *src), - int (*set_group)(EC_KEY *key, const EC_GROUP *grp), - int (*set_private)(EC_KEY *key, - const BIGNUM *priv_key), - int (*set_public)(EC_KEY *key, - const EC_POINT *pub_key)); - -void EC_KEY_METHOD_set_keygen(EC_KEY_METHOD *meth, - int (*keygen)(EC_KEY *key)); - -void EC_KEY_METHOD_set_compute_key(EC_KEY_METHOD *meth, - int (*ckey)(unsigned char **psec, - size_t *pseclen, - const EC_POINT *pub_key, - const EC_KEY *ecdh)); - -void EC_KEY_METHOD_set_sign(EC_KEY_METHOD *meth, - int (*sign)(int type, const unsigned char *dgst, - int dlen, unsigned char *sig, - unsigned int *siglen, - const BIGNUM *kinv, const BIGNUM *r, - EC_KEY *eckey), - int (*sign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, - BIGNUM **kinvp, BIGNUM **rp), - ECDSA_SIG *(*sign_sig)(const unsigned char *dgst, - int dgst_len, - const BIGNUM *in_kinv, - const BIGNUM *in_r, - EC_KEY *eckey)); - -void EC_KEY_METHOD_set_verify(EC_KEY_METHOD *meth, - int (*verify)(int type, const unsigned - char *dgst, int dgst_len, - const unsigned char *sigbuf, - int sig_len, EC_KEY *eckey), - int (*verify_sig)(const unsigned char *dgst, - int dgst_len, - const ECDSA_SIG *sig, - EC_KEY *eckey)); - -void EC_KEY_METHOD_get_init(EC_KEY_METHOD *meth, - int (**pinit)(EC_KEY *key), - void (**pfinish)(EC_KEY *key), - int (**pcopy)(EC_KEY *dest, const EC_KEY *src), - int (**pset_group)(EC_KEY *key, - const EC_GROUP *grp), - int (**pset_private)(EC_KEY *key, - const BIGNUM *priv_key), - int (**pset_public)(EC_KEY *key, - const EC_POINT *pub_key)); - -void EC_KEY_METHOD_get_keygen(EC_KEY_METHOD *meth, - int (**pkeygen)(EC_KEY *key)); - -void EC_KEY_METHOD_get_compute_key(EC_KEY_METHOD *meth, - int (**pck)(unsigned char **psec, - size_t *pseclen, - const EC_POINT *pub_key, - const EC_KEY *ecdh)); - -void EC_KEY_METHOD_get_sign(EC_KEY_METHOD *meth, - int (**psign)(int type, const unsigned char *dgst, - int dlen, unsigned char *sig, - unsigned int *siglen, - const BIGNUM *kinv, const BIGNUM *r, - EC_KEY *eckey), - int (**psign_setup)(EC_KEY *eckey, BN_CTX *ctx_in, - BIGNUM **kinvp, BIGNUM **rp), - ECDSA_SIG *(**psign_sig)(const unsigned char *dgst, - int dgst_len, - const BIGNUM *in_kinv, - const BIGNUM *in_r, - EC_KEY *eckey)); - -void EC_KEY_METHOD_get_verify(EC_KEY_METHOD *meth, - int (**pverify)(int type, const unsigned - char *dgst, int dgst_len, - const unsigned char *sigbuf, - int sig_len, EC_KEY *eckey), - int (**pverify_sig)(const unsigned char *dgst, - int dgst_len, - const ECDSA_SIG *sig, - EC_KEY *eckey)); - -# define ECParameters_dup(x) ASN1_dup_of(EC_KEY,i2d_ECParameters,d2i_ECParameters,x) - -# ifndef __cplusplus -# if defined(__SUNPRO_C) -# if __SUNPRO_C >= 0x520 -# pragma error_messages (default,E_ARRAY_OF_INCOMPLETE_NONAME,E_ARRAY_OF_INCOMPLETE) -# endif -# endif -# endif - -# define EVP_PKEY_CTX_set_ec_paramgen_curve_nid(ctx, nid) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID, nid, NULL) - -# define EVP_PKEY_CTX_set_ec_param_enc(ctx, flag) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_PARAMGEN|EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_EC_PARAM_ENC, flag, NULL) - -# define EVP_PKEY_CTX_set_ecdh_cofactor_mode(ctx, flag) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_ECDH_COFACTOR, flag, NULL) - -# define EVP_PKEY_CTX_get_ecdh_cofactor_mode(ctx) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_ECDH_COFACTOR, -2, NULL) - -# define EVP_PKEY_CTX_set_ecdh_kdf_type(ctx, kdf) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_KDF_TYPE, kdf, NULL) - -# define EVP_PKEY_CTX_get_ecdh_kdf_type(ctx) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_KDF_TYPE, -2, NULL) - -# define EVP_PKEY_CTX_set_ecdh_kdf_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_KDF_MD, 0, (void *)md) - -# define EVP_PKEY_CTX_get_ecdh_kdf_md(ctx, pmd) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_EC_KDF_MD, 0, (void *)pmd) - -# define EVP_PKEY_CTX_set_ecdh_kdf_outlen(ctx, len) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_KDF_OUTLEN, len, NULL) - -# define EVP_PKEY_CTX_get_ecdh_kdf_outlen(ctx, plen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN, 0, (void *)plen) - -# define EVP_PKEY_CTX_set0_ecdh_kdf_ukm(ctx, p, plen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_EC_KDF_UKM, plen, (void *)p) - -# define EVP_PKEY_CTX_get0_ecdh_kdf_ukm(ctx, p) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_EC, \ - EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_GET_EC_KDF_UKM, 0, (void *)p) - -# define EVP_PKEY_CTRL_EC_PARAMGEN_CURVE_NID (EVP_PKEY_ALG_CTRL + 1) -# define EVP_PKEY_CTRL_EC_PARAM_ENC (EVP_PKEY_ALG_CTRL + 2) -# define EVP_PKEY_CTRL_EC_ECDH_COFACTOR (EVP_PKEY_ALG_CTRL + 3) -# define EVP_PKEY_CTRL_EC_KDF_TYPE (EVP_PKEY_ALG_CTRL + 4) -# define EVP_PKEY_CTRL_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 5) -# define EVP_PKEY_CTRL_GET_EC_KDF_MD (EVP_PKEY_ALG_CTRL + 6) -# define EVP_PKEY_CTRL_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 7) -# define EVP_PKEY_CTRL_GET_EC_KDF_OUTLEN (EVP_PKEY_ALG_CTRL + 8) -# define EVP_PKEY_CTRL_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 9) -# define EVP_PKEY_CTRL_GET_EC_KDF_UKM (EVP_PKEY_ALG_CTRL + 10) -/* KDF types */ -# define EVP_PKEY_ECDH_KDF_NONE 1 -# define EVP_PKEY_ECDH_KDF_X9_62 2 - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_EC_strings(void); - -/* Error codes for the EC functions. */ - -/* Function codes. */ -# define EC_F_BN_TO_FELEM 224 -# define EC_F_D2I_ECPARAMETERS 144 -# define EC_F_D2I_ECPKPARAMETERS 145 -# define EC_F_D2I_ECPRIVATEKEY 146 -# define EC_F_DO_EC_KEY_PRINT 221 -# define EC_F_ECDH_CMS_DECRYPT 238 -# define EC_F_ECDH_CMS_SET_SHARED_INFO 239 -# define EC_F_ECDH_COMPUTE_KEY 246 -# define EC_F_ECDH_SIMPLE_COMPUTE_KEY 257 -# define EC_F_ECDSA_DO_SIGN_EX 251 -# define EC_F_ECDSA_DO_VERIFY 252 -# define EC_F_ECDSA_SIGN_EX 254 -# define EC_F_ECDSA_SIGN_SETUP 248 -# define EC_F_ECDSA_SIG_NEW 265 -# define EC_F_ECDSA_VERIFY 253 -# define EC_F_ECKEY_PARAM2TYPE 223 -# define EC_F_ECKEY_PARAM_DECODE 212 -# define EC_F_ECKEY_PRIV_DECODE 213 -# define EC_F_ECKEY_PRIV_ENCODE 214 -# define EC_F_ECKEY_PUB_DECODE 215 -# define EC_F_ECKEY_PUB_ENCODE 216 -# define EC_F_ECKEY_TYPE2PARAM 220 -# define EC_F_ECPARAMETERS_PRINT 147 -# define EC_F_ECPARAMETERS_PRINT_FP 148 -# define EC_F_ECPKPARAMETERS_PRINT 149 -# define EC_F_ECPKPARAMETERS_PRINT_FP 150 -# define EC_F_ECP_NISTZ256_GET_AFFINE 240 -# define EC_F_ECP_NISTZ256_MULT_PRECOMPUTE 243 -# define EC_F_ECP_NISTZ256_POINTS_MUL 241 -# define EC_F_ECP_NISTZ256_PRE_COMP_NEW 244 -# define EC_F_ECP_NISTZ256_WINDOWED_MUL 242 -# define EC_F_ECX_KEY_OP 266 -# define EC_F_ECX_PRIV_ENCODE 267 -# define EC_F_ECX_PUB_ENCODE 268 -# define EC_F_EC_ASN1_GROUP2CURVE 153 -# define EC_F_EC_ASN1_GROUP2FIELDID 154 -# define EC_F_EC_GF2M_MONTGOMERY_POINT_MULTIPLY 208 -# define EC_F_EC_GF2M_SIMPLE_GROUP_CHECK_DISCRIMINANT 159 -# define EC_F_EC_GF2M_SIMPLE_GROUP_SET_CURVE 195 -# define EC_F_EC_GF2M_SIMPLE_OCT2POINT 160 -# define EC_F_EC_GF2M_SIMPLE_POINT2OCT 161 -# define EC_F_EC_GF2M_SIMPLE_POINT_GET_AFFINE_COORDINATES 162 -# define EC_F_EC_GF2M_SIMPLE_POINT_SET_AFFINE_COORDINATES 163 -# define EC_F_EC_GF2M_SIMPLE_SET_COMPRESSED_COORDINATES 164 -# define EC_F_EC_GFP_MONT_FIELD_DECODE 133 -# define EC_F_EC_GFP_MONT_FIELD_ENCODE 134 -# define EC_F_EC_GFP_MONT_FIELD_MUL 131 -# define EC_F_EC_GFP_MONT_FIELD_SET_TO_ONE 209 -# define EC_F_EC_GFP_MONT_FIELD_SQR 132 -# define EC_F_EC_GFP_MONT_GROUP_SET_CURVE 189 -# define EC_F_EC_GFP_NISTP224_GROUP_SET_CURVE 225 -# define EC_F_EC_GFP_NISTP224_POINTS_MUL 228 -# define EC_F_EC_GFP_NISTP224_POINT_GET_AFFINE_COORDINATES 226 -# define EC_F_EC_GFP_NISTP256_GROUP_SET_CURVE 230 -# define EC_F_EC_GFP_NISTP256_POINTS_MUL 231 -# define EC_F_EC_GFP_NISTP256_POINT_GET_AFFINE_COORDINATES 232 -# define EC_F_EC_GFP_NISTP521_GROUP_SET_CURVE 233 -# define EC_F_EC_GFP_NISTP521_POINTS_MUL 234 -# define EC_F_EC_GFP_NISTP521_POINT_GET_AFFINE_COORDINATES 235 -# define EC_F_EC_GFP_NIST_FIELD_MUL 200 -# define EC_F_EC_GFP_NIST_FIELD_SQR 201 -# define EC_F_EC_GFP_NIST_GROUP_SET_CURVE 202 -# define EC_F_EC_GFP_SIMPLE_GROUP_CHECK_DISCRIMINANT 165 -# define EC_F_EC_GFP_SIMPLE_GROUP_SET_CURVE 166 -# define EC_F_EC_GFP_SIMPLE_MAKE_AFFINE 102 -# define EC_F_EC_GFP_SIMPLE_OCT2POINT 103 -# define EC_F_EC_GFP_SIMPLE_POINT2OCT 104 -# define EC_F_EC_GFP_SIMPLE_POINTS_MAKE_AFFINE 137 -# define EC_F_EC_GFP_SIMPLE_POINT_GET_AFFINE_COORDINATES 167 -# define EC_F_EC_GFP_SIMPLE_POINT_SET_AFFINE_COORDINATES 168 -# define EC_F_EC_GFP_SIMPLE_SET_COMPRESSED_COORDINATES 169 -# define EC_F_EC_GROUP_CHECK 170 -# define EC_F_EC_GROUP_CHECK_DISCRIMINANT 171 -# define EC_F_EC_GROUP_COPY 106 -# define EC_F_EC_GROUP_GET_CURVE_GF2M 172 -# define EC_F_EC_GROUP_GET_CURVE_GFP 130 -# define EC_F_EC_GROUP_GET_DEGREE 173 -# define EC_F_EC_GROUP_GET_ECPARAMETERS 261 -# define EC_F_EC_GROUP_GET_ECPKPARAMETERS 262 -# define EC_F_EC_GROUP_GET_PENTANOMIAL_BASIS 193 -# define EC_F_EC_GROUP_GET_TRINOMIAL_BASIS 194 -# define EC_F_EC_GROUP_NEW 108 -# define EC_F_EC_GROUP_NEW_BY_CURVE_NAME 174 -# define EC_F_EC_GROUP_NEW_FROM_DATA 175 -# define EC_F_EC_GROUP_NEW_FROM_ECPARAMETERS 263 -# define EC_F_EC_GROUP_NEW_FROM_ECPKPARAMETERS 264 -# define EC_F_EC_GROUP_SET_CURVE_GF2M 176 -# define EC_F_EC_GROUP_SET_CURVE_GFP 109 -# define EC_F_EC_GROUP_SET_GENERATOR 111 -# define EC_F_EC_KEY_CHECK_KEY 177 -# define EC_F_EC_KEY_COPY 178 -# define EC_F_EC_KEY_GENERATE_KEY 179 -# define EC_F_EC_KEY_NEW 182 -# define EC_F_EC_KEY_NEW_METHOD 245 -# define EC_F_EC_KEY_OCT2PRIV 255 -# define EC_F_EC_KEY_PRINT 180 -# define EC_F_EC_KEY_PRINT_FP 181 -# define EC_F_EC_KEY_PRIV2OCT 256 -# define EC_F_EC_KEY_SET_PUBLIC_KEY_AFFINE_COORDINATES 229 -# define EC_F_EC_KEY_SIMPLE_CHECK_KEY 258 -# define EC_F_EC_KEY_SIMPLE_OCT2PRIV 259 -# define EC_F_EC_KEY_SIMPLE_PRIV2OCT 260 -# define EC_F_EC_POINTS_MAKE_AFFINE 136 -# define EC_F_EC_POINT_ADD 112 -# define EC_F_EC_POINT_CMP 113 -# define EC_F_EC_POINT_COPY 114 -# define EC_F_EC_POINT_DBL 115 -# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GF2M 183 -# define EC_F_EC_POINT_GET_AFFINE_COORDINATES_GFP 116 -# define EC_F_EC_POINT_GET_JPROJECTIVE_COORDINATES_GFP 117 -# define EC_F_EC_POINT_INVERT 210 -# define EC_F_EC_POINT_IS_AT_INFINITY 118 -# define EC_F_EC_POINT_IS_ON_CURVE 119 -# define EC_F_EC_POINT_MAKE_AFFINE 120 -# define EC_F_EC_POINT_NEW 121 -# define EC_F_EC_POINT_OCT2POINT 122 -# define EC_F_EC_POINT_POINT2OCT 123 -# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GF2M 185 -# define EC_F_EC_POINT_SET_AFFINE_COORDINATES_GFP 124 -# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GF2M 186 -# define EC_F_EC_POINT_SET_COMPRESSED_COORDINATES_GFP 125 -# define EC_F_EC_POINT_SET_JPROJECTIVE_COORDINATES_GFP 126 -# define EC_F_EC_POINT_SET_TO_INFINITY 127 -# define EC_F_EC_PRE_COMP_NEW 196 -# define EC_F_EC_WNAF_MUL 187 -# define EC_F_EC_WNAF_PRECOMPUTE_MULT 188 -# define EC_F_I2D_ECPARAMETERS 190 -# define EC_F_I2D_ECPKPARAMETERS 191 -# define EC_F_I2D_ECPRIVATEKEY 192 -# define EC_F_I2O_ECPUBLICKEY 151 -# define EC_F_NISTP224_PRE_COMP_NEW 227 -# define EC_F_NISTP256_PRE_COMP_NEW 236 -# define EC_F_NISTP521_PRE_COMP_NEW 237 -# define EC_F_O2I_ECPUBLICKEY 152 -# define EC_F_OLD_EC_PRIV_DECODE 222 -# define EC_F_OSSL_ECDH_COMPUTE_KEY 247 -# define EC_F_OSSL_ECDSA_SIGN_SIG 249 -# define EC_F_OSSL_ECDSA_VERIFY_SIG 250 -# define EC_F_PKEY_ECX_DERIVE 269 -# define EC_F_PKEY_EC_CTRL 197 -# define EC_F_PKEY_EC_CTRL_STR 198 -# define EC_F_PKEY_EC_DERIVE 217 -# define EC_F_PKEY_EC_KEYGEN 199 -# define EC_F_PKEY_EC_PARAMGEN 219 -# define EC_F_PKEY_EC_SIGN 218 - -/* Reason codes. */ -# define EC_R_ASN1_ERROR 115 -# define EC_R_BAD_SIGNATURE 156 -# define EC_R_BIGNUM_OUT_OF_RANGE 144 -# define EC_R_BUFFER_TOO_SMALL 100 -# define EC_R_COORDINATES_OUT_OF_RANGE 146 -# define EC_R_CURVE_DOES_NOT_SUPPORT_ECDH 160 -# define EC_R_CURVE_DOES_NOT_SUPPORT_SIGNING 159 -# define EC_R_D2I_ECPKPARAMETERS_FAILURE 117 -# define EC_R_DECODE_ERROR 142 -# define EC_R_DISCRIMINANT_IS_ZERO 118 -# define EC_R_EC_GROUP_NEW_BY_NAME_FAILURE 119 -# define EC_R_FIELD_TOO_LARGE 143 -# define EC_R_GF2M_NOT_SUPPORTED 147 -# define EC_R_GROUP2PKPARAMETERS_FAILURE 120 -# define EC_R_I2D_ECPKPARAMETERS_FAILURE 121 -# define EC_R_INCOMPATIBLE_OBJECTS 101 -# define EC_R_INVALID_ARGUMENT 112 -# define EC_R_INVALID_COMPRESSED_POINT 110 -# define EC_R_INVALID_COMPRESSION_BIT 109 -# define EC_R_INVALID_CURVE 141 -# define EC_R_INVALID_DIGEST 151 -# define EC_R_INVALID_DIGEST_TYPE 138 -# define EC_R_INVALID_ENCODING 102 -# define EC_R_INVALID_FIELD 103 -# define EC_R_INVALID_FORM 104 -# define EC_R_INVALID_GROUP_ORDER 122 -# define EC_R_INVALID_KEY 116 -# define EC_R_INVALID_OUTPUT_LENGTH 161 -# define EC_R_INVALID_PEER_KEY 133 -# define EC_R_INVALID_PENTANOMIAL_BASIS 132 -# define EC_R_INVALID_PRIVATE_KEY 123 -# define EC_R_INVALID_TRINOMIAL_BASIS 137 -# define EC_R_KDF_PARAMETER_ERROR 148 -# define EC_R_KEYS_NOT_SET 140 -# define EC_R_MISSING_PARAMETERS 124 -# define EC_R_MISSING_PRIVATE_KEY 125 -# define EC_R_NEED_NEW_SETUP_VALUES 157 -# define EC_R_NOT_A_NIST_PRIME 135 -# define EC_R_NOT_IMPLEMENTED 126 -# define EC_R_NOT_INITIALIZED 111 -# define EC_R_NO_PARAMETERS_SET 139 -# define EC_R_NO_PRIVATE_VALUE 154 -# define EC_R_OPERATION_NOT_SUPPORTED 152 -# define EC_R_PASSED_NULL_PARAMETER 134 -# define EC_R_PEER_KEY_ERROR 149 -# define EC_R_PKPARAMETERS2GROUP_FAILURE 127 -# define EC_R_POINT_ARITHMETIC_FAILURE 155 -# define EC_R_POINT_AT_INFINITY 106 -# define EC_R_POINT_IS_NOT_ON_CURVE 107 -# define EC_R_RANDOM_NUMBER_GENERATION_FAILED 158 -# define EC_R_SHARED_INFO_ERROR 150 -# define EC_R_SLOT_FULL 108 -# define EC_R_UNDEFINED_GENERATOR 113 -# define EC_R_UNDEFINED_ORDER 128 -# define EC_R_UNKNOWN_GROUP 129 -# define EC_R_UNKNOWN_ORDER 114 -# define EC_R_UNSUPPORTED_FIELD 131 -# define EC_R_WRONG_CURVE_PARAMETERS 145 -# define EC_R_WRONG_ORDER 130 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/ecdh.h b/android/armeabi/include/openssl/ecdh.h deleted file mode 100644 index 681f3d5e..00000000 --- a/android/armeabi/include/openssl/ecdh.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <openssl/ec.h> diff --git a/android/armeabi/include/openssl/ecdsa.h b/android/armeabi/include/openssl/ecdsa.h deleted file mode 100644 index 681f3d5e..00000000 --- a/android/armeabi/include/openssl/ecdsa.h +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <openssl/ec.h> diff --git a/android/armeabi/include/openssl/engine.h b/android/armeabi/include/openssl/engine.h deleted file mode 100644 index 319371e4..00000000 --- a/android/armeabi/include/openssl/engine.h +++ /dev/null @@ -1,842 +0,0 @@ -/* - * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECDH support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_ENGINE_H -# define HEADER_ENGINE_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_ENGINE -# if OPENSSL_API_COMPAT < 0x10100000L -# include <openssl/bn.h> -# include <openssl/rsa.h> -# include <openssl/dsa.h> -# include <openssl/dh.h> -# include <openssl/ec.h> -# include <openssl/rand.h> -# include <openssl/ui.h> -# include <openssl/err.h> -# endif -# include <openssl/ossl_typ.h> -# include <openssl/symhacks.h> -# include <openssl/x509.h> -# ifdef __cplusplus -extern "C" { -# endif - -/* - * These flags are used to control combinations of algorithm (methods) by - * bitwise "OR"ing. - */ -# define ENGINE_METHOD_RSA (unsigned int)0x0001 -# define ENGINE_METHOD_DSA (unsigned int)0x0002 -# define ENGINE_METHOD_DH (unsigned int)0x0004 -# define ENGINE_METHOD_RAND (unsigned int)0x0008 -# define ENGINE_METHOD_CIPHERS (unsigned int)0x0040 -# define ENGINE_METHOD_DIGESTS (unsigned int)0x0080 -# define ENGINE_METHOD_PKEY_METHS (unsigned int)0x0200 -# define ENGINE_METHOD_PKEY_ASN1_METHS (unsigned int)0x0400 -# define ENGINE_METHOD_EC (unsigned int)0x0800 -/* Obvious all-or-nothing cases. */ -# define ENGINE_METHOD_ALL (unsigned int)0xFFFF -# define ENGINE_METHOD_NONE (unsigned int)0x0000 - -/* - * This(ese) flag(s) controls behaviour of the ENGINE_TABLE mechanism used - * internally to control registration of ENGINE implementations, and can be - * set by ENGINE_set_table_flags(). The "NOINIT" flag prevents attempts to - * initialise registered ENGINEs if they are not already initialised. - */ -# define ENGINE_TABLE_FLAG_NOINIT (unsigned int)0x0001 - -/* ENGINE flags that can be set by ENGINE_set_flags(). */ -/* Not used */ -/* #define ENGINE_FLAGS_MALLOCED 0x0001 */ - -/* - * This flag is for ENGINEs that wish to handle the various 'CMD'-related - * control commands on their own. Without this flag, ENGINE_ctrl() handles - * these control commands on behalf of the ENGINE using their "cmd_defns" - * data. - */ -# define ENGINE_FLAGS_MANUAL_CMD_CTRL (int)0x0002 - -/* - * This flag is for ENGINEs who return new duplicate structures when found - * via "ENGINE_by_id()". When an ENGINE must store state (eg. if - * ENGINE_ctrl() commands are called in sequence as part of some stateful - * process like key-generation setup and execution), it can set this flag - - * then each attempt to obtain the ENGINE will result in it being copied into - * a new structure. Normally, ENGINEs don't declare this flag so - * ENGINE_by_id() just increments the existing ENGINE's structural reference - * count. - */ -# define ENGINE_FLAGS_BY_ID_COPY (int)0x0004 - -/* - * This flag if for an ENGINE that does not want its methods registered as - * part of ENGINE_register_all_complete() for example if the methods are not - * usable as default methods. - */ - -# define ENGINE_FLAGS_NO_REGISTER_ALL (int)0x0008 - -/* - * ENGINEs can support their own command types, and these flags are used in - * ENGINE_CTRL_GET_CMD_FLAGS to indicate to the caller what kind of input - * each command expects. Currently only numeric and string input is - * supported. If a control command supports none of the _NUMERIC, _STRING, or - * _NO_INPUT options, then it is regarded as an "internal" control command - - * and not for use in config setting situations. As such, they're not - * available to the ENGINE_ctrl_cmd_string() function, only raw ENGINE_ctrl() - * access. Changes to this list of 'command types' should be reflected - * carefully in ENGINE_cmd_is_executable() and ENGINE_ctrl_cmd_string(). - */ - -/* accepts a 'long' input value (3rd parameter to ENGINE_ctrl) */ -# define ENGINE_CMD_FLAG_NUMERIC (unsigned int)0x0001 -/* - * accepts string input (cast from 'void*' to 'const char *', 4th parameter - * to ENGINE_ctrl) - */ -# define ENGINE_CMD_FLAG_STRING (unsigned int)0x0002 -/* - * Indicates that the control command takes *no* input. Ie. the control - * command is unparameterised. - */ -# define ENGINE_CMD_FLAG_NO_INPUT (unsigned int)0x0004 -/* - * Indicates that the control command is internal. This control command won't - * be shown in any output, and is only usable through the ENGINE_ctrl_cmd() - * function. - */ -# define ENGINE_CMD_FLAG_INTERNAL (unsigned int)0x0008 - -/* - * NB: These 3 control commands are deprecated and should not be used. - * ENGINEs relying on these commands should compile conditional support for - * compatibility (eg. if these symbols are defined) but should also migrate - * the same functionality to their own ENGINE-specific control functions that - * can be "discovered" by calling applications. The fact these control - * commands wouldn't be "executable" (ie. usable by text-based config) - * doesn't change the fact that application code can find and use them - * without requiring per-ENGINE hacking. - */ - -/* - * These flags are used to tell the ctrl function what should be done. All - * command numbers are shared between all engines, even if some don't make - * sense to some engines. In such a case, they do nothing but return the - * error ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED. - */ -# define ENGINE_CTRL_SET_LOGSTREAM 1 -# define ENGINE_CTRL_SET_PASSWORD_CALLBACK 2 -# define ENGINE_CTRL_HUP 3/* Close and reinitialise - * any handles/connections - * etc. */ -# define ENGINE_CTRL_SET_USER_INTERFACE 4/* Alternative to callback */ -# define ENGINE_CTRL_SET_CALLBACK_DATA 5/* User-specific data, used - * when calling the password - * callback and the user - * interface */ -# define ENGINE_CTRL_LOAD_CONFIGURATION 6/* Load a configuration, - * given a string that - * represents a file name - * or so */ -# define ENGINE_CTRL_LOAD_SECTION 7/* Load data from a given - * section in the already - * loaded configuration */ - -/* - * These control commands allow an application to deal with an arbitrary - * engine in a dynamic way. Warn: Negative return values indicate errors FOR - * THESE COMMANDS because zero is used to indicate 'end-of-list'. Other - * commands, including ENGINE-specific command types, return zero for an - * error. An ENGINE can choose to implement these ctrl functions, and can - * internally manage things however it chooses - it does so by setting the - * ENGINE_FLAGS_MANUAL_CMD_CTRL flag (using ENGINE_set_flags()). Otherwise - * the ENGINE_ctrl() code handles this on the ENGINE's behalf using the - * cmd_defns data (set using ENGINE_set_cmd_defns()). This means an ENGINE's - * ctrl() handler need only implement its own commands - the above "meta" - * commands will be taken care of. - */ - -/* - * Returns non-zero if the supplied ENGINE has a ctrl() handler. If "not", - * then all the remaining control commands will return failure, so it is - * worth checking this first if the caller is trying to "discover" the - * engine's capabilities and doesn't want errors generated unnecessarily. - */ -# define ENGINE_CTRL_HAS_CTRL_FUNCTION 10 -/* - * Returns a positive command number for the first command supported by the - * engine. Returns zero if no ctrl commands are supported. - */ -# define ENGINE_CTRL_GET_FIRST_CMD_TYPE 11 -/* - * The 'long' argument specifies a command implemented by the engine, and the - * return value is the next command supported, or zero if there are no more. - */ -# define ENGINE_CTRL_GET_NEXT_CMD_TYPE 12 -/* - * The 'void*' argument is a command name (cast from 'const char *'), and the - * return value is the command that corresponds to it. - */ -# define ENGINE_CTRL_GET_CMD_FROM_NAME 13 -/* - * The next two allow a command to be converted into its corresponding string - * form. In each case, the 'long' argument supplies the command. In the - * NAME_LEN case, the return value is the length of the command name (not - * counting a trailing EOL). In the NAME case, the 'void*' argument must be a - * string buffer large enough, and it will be populated with the name of the - * command (WITH a trailing EOL). - */ -# define ENGINE_CTRL_GET_NAME_LEN_FROM_CMD 14 -# define ENGINE_CTRL_GET_NAME_FROM_CMD 15 -/* The next two are similar but give a "short description" of a command. */ -# define ENGINE_CTRL_GET_DESC_LEN_FROM_CMD 16 -# define ENGINE_CTRL_GET_DESC_FROM_CMD 17 -/* - * With this command, the return value is the OR'd combination of - * ENGINE_CMD_FLAG_*** values that indicate what kind of input a given - * engine-specific ctrl command expects. - */ -# define ENGINE_CTRL_GET_CMD_FLAGS 18 - -/* - * ENGINE implementations should start the numbering of their own control - * commands from this value. (ie. ENGINE_CMD_BASE, ENGINE_CMD_BASE + 1, etc). - */ -# define ENGINE_CMD_BASE 200 - -/* - * NB: These 2 nCipher "chil" control commands are deprecated, and their - * functionality is now available through ENGINE-specific control commands - * (exposed through the above-mentioned 'CMD'-handling). Code using these 2 - * commands should be migrated to the more general command handling before - * these are removed. - */ - -/* Flags specific to the nCipher "chil" engine */ -# define ENGINE_CTRL_CHIL_SET_FORKCHECK 100 - /* - * Depending on the value of the (long)i argument, this sets or - * unsets the SimpleForkCheck flag in the CHIL API to enable or - * disable checking and workarounds for applications that fork(). - */ -# define ENGINE_CTRL_CHIL_NO_LOCKING 101 - /* - * This prevents the initialisation function from providing mutex - * callbacks to the nCipher library. - */ - -/* - * If an ENGINE supports its own specific control commands and wishes the - * framework to handle the above 'ENGINE_CMD_***'-manipulation commands on - * its behalf, it should supply a null-terminated array of ENGINE_CMD_DEFN - * entries to ENGINE_set_cmd_defns(). It should also implement a ctrl() - * handler that supports the stated commands (ie. the "cmd_num" entries as - * described by the array). NB: The array must be ordered in increasing order - * of cmd_num. "null-terminated" means that the last ENGINE_CMD_DEFN element - * has cmd_num set to zero and/or cmd_name set to NULL. - */ -typedef struct ENGINE_CMD_DEFN_st { - unsigned int cmd_num; /* The command number */ - const char *cmd_name; /* The command name itself */ - const char *cmd_desc; /* A short description of the command */ - unsigned int cmd_flags; /* The input the command expects */ -} ENGINE_CMD_DEFN; - -/* Generic function pointer */ -typedef int (*ENGINE_GEN_FUNC_PTR) (void); -/* Generic function pointer taking no arguments */ -typedef int (*ENGINE_GEN_INT_FUNC_PTR) (ENGINE *); -/* Specific control function pointer */ -typedef int (*ENGINE_CTRL_FUNC_PTR) (ENGINE *, int, long, void *, - void (*f) (void)); -/* Generic load_key function pointer */ -typedef EVP_PKEY *(*ENGINE_LOAD_KEY_PTR)(ENGINE *, const char *, - UI_METHOD *ui_method, - void *callback_data); -typedef int (*ENGINE_SSL_CLIENT_CERT_PTR) (ENGINE *, SSL *ssl, - STACK_OF(X509_NAME) *ca_dn, - X509 **pcert, EVP_PKEY **pkey, - STACK_OF(X509) **pother, - UI_METHOD *ui_method, - void *callback_data); -/*- - * These callback types are for an ENGINE's handler for cipher and digest logic. - * These handlers have these prototypes; - * int foo(ENGINE *e, const EVP_CIPHER **cipher, const int **nids, int nid); - * int foo(ENGINE *e, const EVP_MD **digest, const int **nids, int nid); - * Looking at how to implement these handlers in the case of cipher support, if - * the framework wants the EVP_CIPHER for 'nid', it will call; - * foo(e, &p_evp_cipher, NULL, nid); (return zero for failure) - * If the framework wants a list of supported 'nid's, it will call; - * foo(e, NULL, &p_nids, 0); (returns number of 'nids' or -1 for error) - */ -/* - * Returns to a pointer to the array of supported cipher 'nid's. If the - * second parameter is non-NULL it is set to the size of the returned array. - */ -typedef int (*ENGINE_CIPHERS_PTR) (ENGINE *, const EVP_CIPHER **, - const int **, int); -typedef int (*ENGINE_DIGESTS_PTR) (ENGINE *, const EVP_MD **, const int **, - int); -typedef int (*ENGINE_PKEY_METHS_PTR) (ENGINE *, EVP_PKEY_METHOD **, - const int **, int); -typedef int (*ENGINE_PKEY_ASN1_METHS_PTR) (ENGINE *, EVP_PKEY_ASN1_METHOD **, - const int **, int); -/* - * STRUCTURE functions ... all of these functions deal with pointers to - * ENGINE structures where the pointers have a "structural reference". This - * means that their reference is to allowed access to the structure but it - * does not imply that the structure is functional. To simply increment or - * decrement the structural reference count, use ENGINE_by_id and - * ENGINE_free. NB: This is not required when iterating using ENGINE_get_next - * as it will automatically decrement the structural reference count of the - * "current" ENGINE and increment the structural reference count of the - * ENGINE it returns (unless it is NULL). - */ - -/* Get the first/last "ENGINE" type available. */ -ENGINE *ENGINE_get_first(void); -ENGINE *ENGINE_get_last(void); -/* Iterate to the next/previous "ENGINE" type (NULL = end of the list). */ -ENGINE *ENGINE_get_next(ENGINE *e); -ENGINE *ENGINE_get_prev(ENGINE *e); -/* Add another "ENGINE" type into the array. */ -int ENGINE_add(ENGINE *e); -/* Remove an existing "ENGINE" type from the array. */ -int ENGINE_remove(ENGINE *e); -/* Retrieve an engine from the list by its unique "id" value. */ -ENGINE *ENGINE_by_id(const char *id); - -#if OPENSSL_API_COMPAT < 0x10100000L -# define ENGINE_load_openssl() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_OPENSSL, NULL) -# define ENGINE_load_dynamic() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DYNAMIC, NULL) -# ifndef OPENSSL_NO_STATIC_ENGINE -# define ENGINE_load_padlock() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_PADLOCK, NULL) -# define ENGINE_load_capi() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CAPI, NULL) -# define ENGINE_load_dasync() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_DASYNC, NULL) -# define ENGINE_load_afalg() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_AFALG, NULL) -# endif -# define ENGINE_load_cryptodev() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_CRYPTODEV, NULL) -# define ENGINE_load_rdrand() \ - OPENSSL_init_crypto(OPENSSL_INIT_ENGINE_RDRAND, NULL) -#endif -void ENGINE_load_builtin_engines(void); - -/* - * Get and set global flags (ENGINE_TABLE_FLAG_***) for the implementation - * "registry" handling. - */ -unsigned int ENGINE_get_table_flags(void); -void ENGINE_set_table_flags(unsigned int flags); - -/*- Manage registration of ENGINEs per "table". For each type, there are 3 - * functions; - * ENGINE_register_***(e) - registers the implementation from 'e' (if it has one) - * ENGINE_unregister_***(e) - unregister the implementation from 'e' - * ENGINE_register_all_***() - call ENGINE_register_***() for each 'e' in the list - * Cleanup is automatically registered from each table when required. - */ - -int ENGINE_register_RSA(ENGINE *e); -void ENGINE_unregister_RSA(ENGINE *e); -void ENGINE_register_all_RSA(void); - -int ENGINE_register_DSA(ENGINE *e); -void ENGINE_unregister_DSA(ENGINE *e); -void ENGINE_register_all_DSA(void); - -int ENGINE_register_EC(ENGINE *e); -void ENGINE_unregister_EC(ENGINE *e); -void ENGINE_register_all_EC(void); - -int ENGINE_register_DH(ENGINE *e); -void ENGINE_unregister_DH(ENGINE *e); -void ENGINE_register_all_DH(void); - -int ENGINE_register_RAND(ENGINE *e); -void ENGINE_unregister_RAND(ENGINE *e); -void ENGINE_register_all_RAND(void); - -int ENGINE_register_ciphers(ENGINE *e); -void ENGINE_unregister_ciphers(ENGINE *e); -void ENGINE_register_all_ciphers(void); - -int ENGINE_register_digests(ENGINE *e); -void ENGINE_unregister_digests(ENGINE *e); -void ENGINE_register_all_digests(void); - -int ENGINE_register_pkey_meths(ENGINE *e); -void ENGINE_unregister_pkey_meths(ENGINE *e); -void ENGINE_register_all_pkey_meths(void); - -int ENGINE_register_pkey_asn1_meths(ENGINE *e); -void ENGINE_unregister_pkey_asn1_meths(ENGINE *e); -void ENGINE_register_all_pkey_asn1_meths(void); - -/* - * These functions register all support from the above categories. Note, use - * of these functions can result in static linkage of code your application - * may not need. If you only need a subset of functionality, consider using - * more selective initialisation. - */ -int ENGINE_register_complete(ENGINE *e); -int ENGINE_register_all_complete(void); - -/* - * Send parametrised control commands to the engine. The possibilities to - * send down an integer, a pointer to data or a function pointer are - * provided. Any of the parameters may or may not be NULL, depending on the - * command number. In actuality, this function only requires a structural - * (rather than functional) reference to an engine, but many control commands - * may require the engine be functional. The caller should be aware of trying - * commands that require an operational ENGINE, and only use functional - * references in such situations. - */ -int ENGINE_ctrl(ENGINE *e, int cmd, long i, void *p, void (*f) (void)); - -/* - * This function tests if an ENGINE-specific command is usable as a - * "setting". Eg. in an application's config file that gets processed through - * ENGINE_ctrl_cmd_string(). If this returns zero, it is not available to - * ENGINE_ctrl_cmd_string(), only ENGINE_ctrl(). - */ -int ENGINE_cmd_is_executable(ENGINE *e, int cmd); - -/* - * This function works like ENGINE_ctrl() with the exception of taking a - * command name instead of a command number, and can handle optional - * commands. See the comment on ENGINE_ctrl_cmd_string() for an explanation - * on how to use the cmd_name and cmd_optional. - */ -int ENGINE_ctrl_cmd(ENGINE *e, const char *cmd_name, - long i, void *p, void (*f) (void), int cmd_optional); - -/* - * This function passes a command-name and argument to an ENGINE. The - * cmd_name is converted to a command number and the control command is - * called using 'arg' as an argument (unless the ENGINE doesn't support such - * a command, in which case no control command is called). The command is - * checked for input flags, and if necessary the argument will be converted - * to a numeric value. If cmd_optional is non-zero, then if the ENGINE - * doesn't support the given cmd_name the return value will be success - * anyway. This function is intended for applications to use so that users - * (or config files) can supply engine-specific config data to the ENGINE at - * run-time to control behaviour of specific engines. As such, it shouldn't - * be used for calling ENGINE_ctrl() functions that return data, deal with - * binary data, or that are otherwise supposed to be used directly through - * ENGINE_ctrl() in application code. Any "return" data from an ENGINE_ctrl() - * operation in this function will be lost - the return value is interpreted - * as failure if the return value is zero, success otherwise, and this - * function returns a boolean value as a result. In other words, vendors of - * 'ENGINE'-enabled devices should write ENGINE implementations with - * parameterisations that work in this scheme, so that compliant ENGINE-based - * applications can work consistently with the same configuration for the - * same ENGINE-enabled devices, across applications. - */ -int ENGINE_ctrl_cmd_string(ENGINE *e, const char *cmd_name, const char *arg, - int cmd_optional); - -/* - * These functions are useful for manufacturing new ENGINE structures. They - * don't address reference counting at all - one uses them to populate an - * ENGINE structure with personalised implementations of things prior to - * using it directly or adding it to the builtin ENGINE list in OpenSSL. - * These are also here so that the ENGINE structure doesn't have to be - * exposed and break binary compatibility! - */ -ENGINE *ENGINE_new(void); -int ENGINE_free(ENGINE *e); -int ENGINE_up_ref(ENGINE *e); -int ENGINE_set_id(ENGINE *e, const char *id); -int ENGINE_set_name(ENGINE *e, const char *name); -int ENGINE_set_RSA(ENGINE *e, const RSA_METHOD *rsa_meth); -int ENGINE_set_DSA(ENGINE *e, const DSA_METHOD *dsa_meth); -int ENGINE_set_EC(ENGINE *e, const EC_KEY_METHOD *ecdsa_meth); -int ENGINE_set_DH(ENGINE *e, const DH_METHOD *dh_meth); -int ENGINE_set_RAND(ENGINE *e, const RAND_METHOD *rand_meth); -int ENGINE_set_destroy_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR destroy_f); -int ENGINE_set_init_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR init_f); -int ENGINE_set_finish_function(ENGINE *e, ENGINE_GEN_INT_FUNC_PTR finish_f); -int ENGINE_set_ctrl_function(ENGINE *e, ENGINE_CTRL_FUNC_PTR ctrl_f); -int ENGINE_set_load_privkey_function(ENGINE *e, - ENGINE_LOAD_KEY_PTR loadpriv_f); -int ENGINE_set_load_pubkey_function(ENGINE *e, ENGINE_LOAD_KEY_PTR loadpub_f); -int ENGINE_set_load_ssl_client_cert_function(ENGINE *e, - ENGINE_SSL_CLIENT_CERT_PTR - loadssl_f); -int ENGINE_set_ciphers(ENGINE *e, ENGINE_CIPHERS_PTR f); -int ENGINE_set_digests(ENGINE *e, ENGINE_DIGESTS_PTR f); -int ENGINE_set_pkey_meths(ENGINE *e, ENGINE_PKEY_METHS_PTR f); -int ENGINE_set_pkey_asn1_meths(ENGINE *e, ENGINE_PKEY_ASN1_METHS_PTR f); -int ENGINE_set_flags(ENGINE *e, int flags); -int ENGINE_set_cmd_defns(ENGINE *e, const ENGINE_CMD_DEFN *defns); -/* These functions allow control over any per-structure ENGINE data. */ -#define ENGINE_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_ENGINE, l, p, newf, dupf, freef) -int ENGINE_set_ex_data(ENGINE *e, int idx, void *arg); -void *ENGINE_get_ex_data(const ENGINE *e, int idx); - -#if OPENSSL_API_COMPAT < 0x10100000L -/* - * This function previously cleaned up anything that needs it. Auto-deinit will - * now take care of it so it is no longer required to call this function. - */ -# define ENGINE_cleanup() while(0) continue -#endif - -/* - * These return values from within the ENGINE structure. These can be useful - * with functional references as well as structural references - it depends - * which you obtained. Using the result for functional purposes if you only - * obtained a structural reference may be problematic! - */ -const char *ENGINE_get_id(const ENGINE *e); -const char *ENGINE_get_name(const ENGINE *e); -const RSA_METHOD *ENGINE_get_RSA(const ENGINE *e); -const DSA_METHOD *ENGINE_get_DSA(const ENGINE *e); -const EC_KEY_METHOD *ENGINE_get_EC(const ENGINE *e); -const DH_METHOD *ENGINE_get_DH(const ENGINE *e); -const RAND_METHOD *ENGINE_get_RAND(const ENGINE *e); -ENGINE_GEN_INT_FUNC_PTR ENGINE_get_destroy_function(const ENGINE *e); -ENGINE_GEN_INT_FUNC_PTR ENGINE_get_init_function(const ENGINE *e); -ENGINE_GEN_INT_FUNC_PTR ENGINE_get_finish_function(const ENGINE *e); -ENGINE_CTRL_FUNC_PTR ENGINE_get_ctrl_function(const ENGINE *e); -ENGINE_LOAD_KEY_PTR ENGINE_get_load_privkey_function(const ENGINE *e); -ENGINE_LOAD_KEY_PTR ENGINE_get_load_pubkey_function(const ENGINE *e); -ENGINE_SSL_CLIENT_CERT_PTR ENGINE_get_ssl_client_cert_function(const ENGINE - *e); -ENGINE_CIPHERS_PTR ENGINE_get_ciphers(const ENGINE *e); -ENGINE_DIGESTS_PTR ENGINE_get_digests(const ENGINE *e); -ENGINE_PKEY_METHS_PTR ENGINE_get_pkey_meths(const ENGINE *e); -ENGINE_PKEY_ASN1_METHS_PTR ENGINE_get_pkey_asn1_meths(const ENGINE *e); -const EVP_CIPHER *ENGINE_get_cipher(ENGINE *e, int nid); -const EVP_MD *ENGINE_get_digest(ENGINE *e, int nid); -const EVP_PKEY_METHOD *ENGINE_get_pkey_meth(ENGINE *e, int nid); -const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth(ENGINE *e, int nid); -const EVP_PKEY_ASN1_METHOD *ENGINE_get_pkey_asn1_meth_str(ENGINE *e, - const char *str, - int len); -const EVP_PKEY_ASN1_METHOD *ENGINE_pkey_asn1_find_str(ENGINE **pe, - const char *str, - int len); -const ENGINE_CMD_DEFN *ENGINE_get_cmd_defns(const ENGINE *e); -int ENGINE_get_flags(const ENGINE *e); - -/* - * FUNCTIONAL functions. These functions deal with ENGINE structures that - * have (or will) be initialised for use. Broadly speaking, the structural - * functions are useful for iterating the list of available engine types, - * creating new engine types, and other "list" operations. These functions - * actually deal with ENGINEs that are to be used. As such these functions - * can fail (if applicable) when particular engines are unavailable - eg. if - * a hardware accelerator is not attached or not functioning correctly. Each - * ENGINE has 2 reference counts; structural and functional. Every time a - * functional reference is obtained or released, a corresponding structural - * reference is automatically obtained or released too. - */ - -/* - * Initialise a engine type for use (or up its reference count if it's - * already in use). This will fail if the engine is not currently operational - * and cannot initialise. - */ -int ENGINE_init(ENGINE *e); -/* - * Free a functional reference to a engine type. This does not require a - * corresponding call to ENGINE_free as it also releases a structural - * reference. - */ -int ENGINE_finish(ENGINE *e); - -/* - * The following functions handle keys that are stored in some secondary - * location, handled by the engine. The storage may be on a card or - * whatever. - */ -EVP_PKEY *ENGINE_load_private_key(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, void *callback_data); -EVP_PKEY *ENGINE_load_public_key(ENGINE *e, const char *key_id, - UI_METHOD *ui_method, void *callback_data); -int ENGINE_load_ssl_client_cert(ENGINE *e, SSL *s, - STACK_OF(X509_NAME) *ca_dn, X509 **pcert, - EVP_PKEY **ppkey, STACK_OF(X509) **pother, - UI_METHOD *ui_method, void *callback_data); - -/* - * This returns a pointer for the current ENGINE structure that is (by - * default) performing any RSA operations. The value returned is an - * incremented reference, so it should be free'd (ENGINE_finish) before it is - * discarded. - */ -ENGINE *ENGINE_get_default_RSA(void); -/* Same for the other "methods" */ -ENGINE *ENGINE_get_default_DSA(void); -ENGINE *ENGINE_get_default_EC(void); -ENGINE *ENGINE_get_default_DH(void); -ENGINE *ENGINE_get_default_RAND(void); -/* - * These functions can be used to get a functional reference to perform - * ciphering or digesting corresponding to "nid". - */ -ENGINE *ENGINE_get_cipher_engine(int nid); -ENGINE *ENGINE_get_digest_engine(int nid); -ENGINE *ENGINE_get_pkey_meth_engine(int nid); -ENGINE *ENGINE_get_pkey_asn1_meth_engine(int nid); - -/* - * This sets a new default ENGINE structure for performing RSA operations. If - * the result is non-zero (success) then the ENGINE structure will have had - * its reference count up'd so the caller should still free their own - * reference 'e'. - */ -int ENGINE_set_default_RSA(ENGINE *e); -int ENGINE_set_default_string(ENGINE *e, const char *def_list); -/* Same for the other "methods" */ -int ENGINE_set_default_DSA(ENGINE *e); -int ENGINE_set_default_EC(ENGINE *e); -int ENGINE_set_default_DH(ENGINE *e); -int ENGINE_set_default_RAND(ENGINE *e); -int ENGINE_set_default_ciphers(ENGINE *e); -int ENGINE_set_default_digests(ENGINE *e); -int ENGINE_set_default_pkey_meths(ENGINE *e); -int ENGINE_set_default_pkey_asn1_meths(ENGINE *e); - -/* - * The combination "set" - the flags are bitwise "OR"d from the - * ENGINE_METHOD_*** defines above. As with the "ENGINE_register_complete()" - * function, this function can result in unnecessary static linkage. If your - * application requires only specific functionality, consider using more - * selective functions. - */ -int ENGINE_set_default(ENGINE *e, unsigned int flags); - -void ENGINE_add_conf_module(void); - -/* Deprecated functions ... */ -/* int ENGINE_clear_defaults(void); */ - -/**************************/ -/* DYNAMIC ENGINE SUPPORT */ -/**************************/ - -/* Binary/behaviour compatibility levels */ -# define OSSL_DYNAMIC_VERSION (unsigned long)0x00030000 -/* - * Binary versions older than this are too old for us (whether we're a loader - * or a loadee) - */ -# define OSSL_DYNAMIC_OLDEST (unsigned long)0x00030000 - -/* - * When compiling an ENGINE entirely as an external shared library, loadable - * by the "dynamic" ENGINE, these types are needed. The 'dynamic_fns' - * structure type provides the calling application's (or library's) error - * functionality and memory management function pointers to the loaded - * library. These should be used/set in the loaded library code so that the - * loading application's 'state' will be used/changed in all operations. The - * 'static_state' pointer allows the loaded library to know if it shares the - * same static data as the calling application (or library), and thus whether - * these callbacks need to be set or not. - */ -typedef void *(*dyn_MEM_malloc_fn) (size_t, const char *, int); -typedef void *(*dyn_MEM_realloc_fn) (void *, size_t, const char *, int); -typedef void (*dyn_MEM_free_fn) (void *, const char *, int); -typedef struct st_dynamic_MEM_fns { - dyn_MEM_malloc_fn malloc_fn; - dyn_MEM_realloc_fn realloc_fn; - dyn_MEM_free_fn free_fn; -} dynamic_MEM_fns; -/* - * FIXME: Perhaps the memory and locking code (crypto.h) should declare and - * use these types so we (and any other dependent code) can simplify a bit?? - */ -/* The top-level structure */ -typedef struct st_dynamic_fns { - void *static_state; - dynamic_MEM_fns mem_fns; -} dynamic_fns; - -/* - * The version checking function should be of this prototype. NB: The - * ossl_version value passed in is the OSSL_DYNAMIC_VERSION of the loading - * code. If this function returns zero, it indicates a (potential) version - * incompatibility and the loaded library doesn't believe it can proceed. - * Otherwise, the returned value is the (latest) version supported by the - * loading library. The loader may still decide that the loaded code's - * version is unsatisfactory and could veto the load. The function is - * expected to be implemented with the symbol name "v_check", and a default - * implementation can be fully instantiated with - * IMPLEMENT_DYNAMIC_CHECK_FN(). - */ -typedef unsigned long (*dynamic_v_check_fn) (unsigned long ossl_version); -# define IMPLEMENT_DYNAMIC_CHECK_FN() \ - OPENSSL_EXPORT unsigned long v_check(unsigned long v); \ - OPENSSL_EXPORT unsigned long v_check(unsigned long v) { \ - if (v >= OSSL_DYNAMIC_OLDEST) return OSSL_DYNAMIC_VERSION; \ - return 0; } - -/* - * This function is passed the ENGINE structure to initialise with its own - * function and command settings. It should not adjust the structural or - * functional reference counts. If this function returns zero, (a) the load - * will be aborted, (b) the previous ENGINE state will be memcpy'd back onto - * the structure, and (c) the shared library will be unloaded. So - * implementations should do their own internal cleanup in failure - * circumstances otherwise they could leak. The 'id' parameter, if non-NULL, - * represents the ENGINE id that the loader is looking for. If this is NULL, - * the shared library can choose to return failure or to initialise a - * 'default' ENGINE. If non-NULL, the shared library must initialise only an - * ENGINE matching the passed 'id'. The function is expected to be - * implemented with the symbol name "bind_engine". A standard implementation - * can be instantiated with IMPLEMENT_DYNAMIC_BIND_FN(fn) where the parameter - * 'fn' is a callback function that populates the ENGINE structure and - * returns an int value (zero for failure). 'fn' should have prototype; - * [static] int fn(ENGINE *e, const char *id); - */ -typedef int (*dynamic_bind_engine) (ENGINE *e, const char *id, - const dynamic_fns *fns); -# define IMPLEMENT_DYNAMIC_BIND_FN(fn) \ - OPENSSL_EXPORT \ - int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns); \ - OPENSSL_EXPORT \ - int bind_engine(ENGINE *e, const char *id, const dynamic_fns *fns) { \ - if (ENGINE_get_static_state() == fns->static_state) goto skip_cbs; \ - CRYPTO_set_mem_functions(fns->mem_fns.malloc_fn, \ - fns->mem_fns.realloc_fn, \ - fns->mem_fns.free_fn); \ - skip_cbs: \ - if (!fn(e, id)) return 0; \ - return 1; } - -/* - * If the loading application (or library) and the loaded ENGINE library - * share the same static data (eg. they're both dynamically linked to the - * same libcrypto.so) we need a way to avoid trying to set system callbacks - - * this would fail, and for the same reason that it's unnecessary to try. If - * the loaded ENGINE has (or gets from through the loader) its own copy of - * the libcrypto static data, we will need to set the callbacks. The easiest - * way to detect this is to have a function that returns a pointer to some - * static data and let the loading application and loaded ENGINE compare - * their respective values. - */ -void *ENGINE_get_static_state(void); - -# if defined(__OpenBSD__) || defined(__FreeBSD__) || defined(HAVE_CRYPTODEV) -DEPRECATEDIN_1_1_0(void ENGINE_setup_bsd_cryptodev(void)) -# endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_ENGINE_strings(void); - -/* Error codes for the ENGINE functions. */ - -/* Function codes. */ -# define ENGINE_F_DYNAMIC_CTRL 180 -# define ENGINE_F_DYNAMIC_GET_DATA_CTX 181 -# define ENGINE_F_DYNAMIC_LOAD 182 -# define ENGINE_F_DYNAMIC_SET_DATA_CTX 183 -# define ENGINE_F_ENGINE_ADD 105 -# define ENGINE_F_ENGINE_BY_ID 106 -# define ENGINE_F_ENGINE_CMD_IS_EXECUTABLE 170 -# define ENGINE_F_ENGINE_CTRL 142 -# define ENGINE_F_ENGINE_CTRL_CMD 178 -# define ENGINE_F_ENGINE_CTRL_CMD_STRING 171 -# define ENGINE_F_ENGINE_FINISH 107 -# define ENGINE_F_ENGINE_GET_CIPHER 185 -# define ENGINE_F_ENGINE_GET_DIGEST 186 -# define ENGINE_F_ENGINE_GET_FIRST 195 -# define ENGINE_F_ENGINE_GET_LAST 196 -# define ENGINE_F_ENGINE_GET_NEXT 115 -# define ENGINE_F_ENGINE_GET_PKEY_ASN1_METH 193 -# define ENGINE_F_ENGINE_GET_PKEY_METH 192 -# define ENGINE_F_ENGINE_GET_PREV 116 -# define ENGINE_F_ENGINE_INIT 119 -# define ENGINE_F_ENGINE_LIST_ADD 120 -# define ENGINE_F_ENGINE_LIST_REMOVE 121 -# define ENGINE_F_ENGINE_LOAD_PRIVATE_KEY 150 -# define ENGINE_F_ENGINE_LOAD_PUBLIC_KEY 151 -# define ENGINE_F_ENGINE_LOAD_SSL_CLIENT_CERT 194 -# define ENGINE_F_ENGINE_NEW 122 -# define ENGINE_F_ENGINE_PKEY_ASN1_FIND_STR 197 -# define ENGINE_F_ENGINE_REMOVE 123 -# define ENGINE_F_ENGINE_SET_DEFAULT_STRING 189 -# define ENGINE_F_ENGINE_SET_ID 129 -# define ENGINE_F_ENGINE_SET_NAME 130 -# define ENGINE_F_ENGINE_TABLE_REGISTER 184 -# define ENGINE_F_ENGINE_UNLOCKED_FINISH 191 -# define ENGINE_F_ENGINE_UP_REF 190 -# define ENGINE_F_INT_CTRL_HELPER 172 -# define ENGINE_F_INT_ENGINE_CONFIGURE 188 -# define ENGINE_F_INT_ENGINE_MODULE_INIT 187 - -/* Reason codes. */ -# define ENGINE_R_ALREADY_LOADED 100 -# define ENGINE_R_ARGUMENT_IS_NOT_A_NUMBER 133 -# define ENGINE_R_CMD_NOT_EXECUTABLE 134 -# define ENGINE_R_COMMAND_TAKES_INPUT 135 -# define ENGINE_R_COMMAND_TAKES_NO_INPUT 136 -# define ENGINE_R_CONFLICTING_ENGINE_ID 103 -# define ENGINE_R_CTRL_COMMAND_NOT_IMPLEMENTED 119 -# define ENGINE_R_DSO_FAILURE 104 -# define ENGINE_R_DSO_NOT_FOUND 132 -# define ENGINE_R_ENGINES_SECTION_ERROR 148 -# define ENGINE_R_ENGINE_CONFIGURATION_ERROR 102 -# define ENGINE_R_ENGINE_IS_NOT_IN_LIST 105 -# define ENGINE_R_ENGINE_SECTION_ERROR 149 -# define ENGINE_R_FAILED_LOADING_PRIVATE_KEY 128 -# define ENGINE_R_FAILED_LOADING_PUBLIC_KEY 129 -# define ENGINE_R_FINISH_FAILED 106 -# define ENGINE_R_ID_OR_NAME_MISSING 108 -# define ENGINE_R_INIT_FAILED 109 -# define ENGINE_R_INTERNAL_LIST_ERROR 110 -# define ENGINE_R_INVALID_ARGUMENT 143 -# define ENGINE_R_INVALID_CMD_NAME 137 -# define ENGINE_R_INVALID_CMD_NUMBER 138 -# define ENGINE_R_INVALID_INIT_VALUE 151 -# define ENGINE_R_INVALID_STRING 150 -# define ENGINE_R_NOT_INITIALISED 117 -# define ENGINE_R_NOT_LOADED 112 -# define ENGINE_R_NO_CONTROL_FUNCTION 120 -# define ENGINE_R_NO_INDEX 144 -# define ENGINE_R_NO_LOAD_FUNCTION 125 -# define ENGINE_R_NO_REFERENCE 130 -# define ENGINE_R_NO_SUCH_ENGINE 116 -# define ENGINE_R_UNIMPLEMENTED_CIPHER 146 -# define ENGINE_R_UNIMPLEMENTED_DIGEST 147 -# define ENGINE_R_UNIMPLEMENTED_PUBLIC_KEY_METHOD 101 -# define ENGINE_R_VERSION_INCOMPATIBILITY 145 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/err.h b/android/armeabi/include/openssl/err.h deleted file mode 100644 index f9390919..00000000 --- a/android/armeabi/include/openssl/err.h +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ERR_H -# define HEADER_ERR_H - -# include <openssl/e_os2.h> - -# ifndef OPENSSL_NO_STDIO -# include <stdio.h> -# include <stdlib.h> -# endif - -# include <openssl/ossl_typ.h> -# include <openssl/bio.h> -# include <openssl/lhash.h> - -#ifdef __cplusplus -extern "C" { -#endif - -# ifndef OPENSSL_NO_ERR -# define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,d,e) -# else -# define ERR_PUT_error(a,b,c,d,e) ERR_put_error(a,b,c,NULL,0) -# endif - -# include <errno.h> - -# define ERR_TXT_MALLOCED 0x01 -# define ERR_TXT_STRING 0x02 - -# define ERR_FLAG_MARK 0x01 - -# define ERR_NUM_ERRORS 16 -typedef struct err_state_st { - int err_flags[ERR_NUM_ERRORS]; - unsigned long err_buffer[ERR_NUM_ERRORS]; - char *err_data[ERR_NUM_ERRORS]; - int err_data_flags[ERR_NUM_ERRORS]; - const char *err_file[ERR_NUM_ERRORS]; - int err_line[ERR_NUM_ERRORS]; - int top, bottom; -} ERR_STATE; - -/* library */ -# define ERR_LIB_NONE 1 -# define ERR_LIB_SYS 2 -# define ERR_LIB_BN 3 -# define ERR_LIB_RSA 4 -# define ERR_LIB_DH 5 -# define ERR_LIB_EVP 6 -# define ERR_LIB_BUF 7 -# define ERR_LIB_OBJ 8 -# define ERR_LIB_PEM 9 -# define ERR_LIB_DSA 10 -# define ERR_LIB_X509 11 -/* #define ERR_LIB_METH 12 */ -# define ERR_LIB_ASN1 13 -# define ERR_LIB_CONF 14 -# define ERR_LIB_CRYPTO 15 -# define ERR_LIB_EC 16 -# define ERR_LIB_SSL 20 -/* #define ERR_LIB_SSL23 21 */ -/* #define ERR_LIB_SSL2 22 */ -/* #define ERR_LIB_SSL3 23 */ -/* #define ERR_LIB_RSAREF 30 */ -/* #define ERR_LIB_PROXY 31 */ -# define ERR_LIB_BIO 32 -# define ERR_LIB_PKCS7 33 -# define ERR_LIB_X509V3 34 -# define ERR_LIB_PKCS12 35 -# define ERR_LIB_RAND 36 -# define ERR_LIB_DSO 37 -# define ERR_LIB_ENGINE 38 -# define ERR_LIB_OCSP 39 -# define ERR_LIB_UI 40 -# define ERR_LIB_COMP 41 -# define ERR_LIB_ECDSA 42 -# define ERR_LIB_ECDH 43 -# define ERR_LIB_STORE 44 -# define ERR_LIB_FIPS 45 -# define ERR_LIB_CMS 46 -# define ERR_LIB_TS 47 -# define ERR_LIB_HMAC 48 -# define ERR_LIB_JPAKE 49 -# define ERR_LIB_CT 50 -# define ERR_LIB_ASYNC 51 -# define ERR_LIB_KDF 52 - -# define ERR_LIB_USER 128 - -# define SYSerr(f,r) ERR_PUT_error(ERR_LIB_SYS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define BNerr(f,r) ERR_PUT_error(ERR_LIB_BN,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define RSAerr(f,r) ERR_PUT_error(ERR_LIB_RSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define DHerr(f,r) ERR_PUT_error(ERR_LIB_DH,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define EVPerr(f,r) ERR_PUT_error(ERR_LIB_EVP,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define BUFerr(f,r) ERR_PUT_error(ERR_LIB_BUF,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define OBJerr(f,r) ERR_PUT_error(ERR_LIB_OBJ,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define PEMerr(f,r) ERR_PUT_error(ERR_LIB_PEM,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define DSAerr(f,r) ERR_PUT_error(ERR_LIB_DSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define X509err(f,r) ERR_PUT_error(ERR_LIB_X509,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ASN1err(f,r) ERR_PUT_error(ERR_LIB_ASN1,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define CONFerr(f,r) ERR_PUT_error(ERR_LIB_CONF,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define CRYPTOerr(f,r) ERR_PUT_error(ERR_LIB_CRYPTO,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ECerr(f,r) ERR_PUT_error(ERR_LIB_EC,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define SSLerr(f,r) ERR_PUT_error(ERR_LIB_SSL,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define BIOerr(f,r) ERR_PUT_error(ERR_LIB_BIO,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define PKCS7err(f,r) ERR_PUT_error(ERR_LIB_PKCS7,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define X509V3err(f,r) ERR_PUT_error(ERR_LIB_X509V3,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define PKCS12err(f,r) ERR_PUT_error(ERR_LIB_PKCS12,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define RANDerr(f,r) ERR_PUT_error(ERR_LIB_RAND,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define DSOerr(f,r) ERR_PUT_error(ERR_LIB_DSO,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ENGINEerr(f,r) ERR_PUT_error(ERR_LIB_ENGINE,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define OCSPerr(f,r) ERR_PUT_error(ERR_LIB_OCSP,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define UIerr(f,r) ERR_PUT_error(ERR_LIB_UI,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define COMPerr(f,r) ERR_PUT_error(ERR_LIB_COMP,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ECDSAerr(f,r) ERR_PUT_error(ERR_LIB_ECDSA,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ECDHerr(f,r) ERR_PUT_error(ERR_LIB_ECDH,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define STOREerr(f,r) ERR_PUT_error(ERR_LIB_STORE,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define FIPSerr(f,r) ERR_PUT_error(ERR_LIB_FIPS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define CMSerr(f,r) ERR_PUT_error(ERR_LIB_CMS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define TSerr(f,r) ERR_PUT_error(ERR_LIB_TS,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define HMACerr(f,r) ERR_PUT_error(ERR_LIB_HMAC,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define JPAKEerr(f,r) ERR_PUT_error(ERR_LIB_JPAKE,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define CTerr(f,r) ERR_PUT_error(ERR_LIB_CT,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define ASYNCerr(f,r) ERR_PUT_error(ERR_LIB_ASYNC,(f),(r),OPENSSL_FILE,OPENSSL_LINE) -# define KDFerr(f,r) ERR_PUT_error(ERR_LIB_KDF,(f),(r),OPENSSL_FILE,OPENSSL_LINE) - -# define ERR_PACK(l,f,r) ( \ - (((unsigned int)(l) & 0x0FF) << 24L) | \ - (((unsigned int)(f) & 0xFFF) << 12L) | \ - (((unsigned int)(r) & 0xFFF) ) ) -# define ERR_GET_LIB(l) (int)(((l) >> 24L) & 0x0FFL) -# define ERR_GET_FUNC(l) (int)(((l) >> 12L) & 0xFFFL) -# define ERR_GET_REASON(l) (int)( (l) & 0xFFFL) - -/* OS functions */ -# define SYS_F_FOPEN 1 -# define SYS_F_CONNECT 2 -# define SYS_F_GETSERVBYNAME 3 -# define SYS_F_SOCKET 4 -# define SYS_F_IOCTLSOCKET 5 -# define SYS_F_BIND 6 -# define SYS_F_LISTEN 7 -# define SYS_F_ACCEPT 8 -# define SYS_F_WSASTARTUP 9/* Winsock stuff */ -# define SYS_F_OPENDIR 10 -# define SYS_F_FREAD 11 -# define SYS_F_GETADDRINFO 12 -# define SYS_F_GETNAMEINFO 13 -# define SYS_F_SETSOCKOPT 14 -# define SYS_F_GETSOCKOPT 15 -# define SYS_F_GETSOCKNAME 16 -# define SYS_F_GETHOSTBYNAME 17 - -/* reasons */ -# define ERR_R_SYS_LIB ERR_LIB_SYS/* 2 */ -# define ERR_R_BN_LIB ERR_LIB_BN/* 3 */ -# define ERR_R_RSA_LIB ERR_LIB_RSA/* 4 */ -# define ERR_R_DH_LIB ERR_LIB_DH/* 5 */ -# define ERR_R_EVP_LIB ERR_LIB_EVP/* 6 */ -# define ERR_R_BUF_LIB ERR_LIB_BUF/* 7 */ -# define ERR_R_OBJ_LIB ERR_LIB_OBJ/* 8 */ -# define ERR_R_PEM_LIB ERR_LIB_PEM/* 9 */ -# define ERR_R_DSA_LIB ERR_LIB_DSA/* 10 */ -# define ERR_R_X509_LIB ERR_LIB_X509/* 11 */ -# define ERR_R_ASN1_LIB ERR_LIB_ASN1/* 13 */ -# define ERR_R_EC_LIB ERR_LIB_EC/* 16 */ -# define ERR_R_BIO_LIB ERR_LIB_BIO/* 32 */ -# define ERR_R_PKCS7_LIB ERR_LIB_PKCS7/* 33 */ -# define ERR_R_X509V3_LIB ERR_LIB_X509V3/* 34 */ -# define ERR_R_ENGINE_LIB ERR_LIB_ENGINE/* 38 */ -# define ERR_R_ECDSA_LIB ERR_LIB_ECDSA/* 42 */ - -# define ERR_R_NESTED_ASN1_ERROR 58 -# define ERR_R_MISSING_ASN1_EOS 63 - -/* fatal error */ -# define ERR_R_FATAL 64 -# define ERR_R_MALLOC_FAILURE (1|ERR_R_FATAL) -# define ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED (2|ERR_R_FATAL) -# define ERR_R_PASSED_NULL_PARAMETER (3|ERR_R_FATAL) -# define ERR_R_INTERNAL_ERROR (4|ERR_R_FATAL) -# define ERR_R_DISABLED (5|ERR_R_FATAL) -# define ERR_R_INIT_FAIL (6|ERR_R_FATAL) -# define ERR_R_PASSED_INVALID_ARGUMENT (7) - -/* - * 99 is the maximum possible ERR_R_... code, higher values are reserved for - * the individual libraries - */ - -typedef struct ERR_string_data_st { - unsigned long error; - const char *string; -} ERR_STRING_DATA; - -DEFINE_LHASH_OF(ERR_STRING_DATA); - -void ERR_put_error(int lib, int func, int reason, const char *file, int line); -void ERR_set_error_data(char *data, int flags); - -unsigned long ERR_get_error(void); -unsigned long ERR_get_error_line(const char **file, int *line); -unsigned long ERR_get_error_line_data(const char **file, int *line, - const char **data, int *flags); -unsigned long ERR_peek_error(void); -unsigned long ERR_peek_error_line(const char **file, int *line); -unsigned long ERR_peek_error_line_data(const char **file, int *line, - const char **data, int *flags); -unsigned long ERR_peek_last_error(void); -unsigned long ERR_peek_last_error_line(const char **file, int *line); -unsigned long ERR_peek_last_error_line_data(const char **file, int *line, - const char **data, int *flags); -void ERR_clear_error(void); -char *ERR_error_string(unsigned long e, char *buf); -void ERR_error_string_n(unsigned long e, char *buf, size_t len); -const char *ERR_lib_error_string(unsigned long e); -const char *ERR_func_error_string(unsigned long e); -const char *ERR_reason_error_string(unsigned long e); -void ERR_print_errors_cb(int (*cb) (const char *str, size_t len, void *u), - void *u); -# ifndef OPENSSL_NO_STDIO -void ERR_print_errors_fp(FILE *fp); -# endif -void ERR_print_errors(BIO *bp); -void ERR_add_error_data(int num, ...); -void ERR_add_error_vdata(int num, va_list args); -int ERR_load_strings(int lib, ERR_STRING_DATA str[]); -int ERR_unload_strings(int lib, ERR_STRING_DATA str[]); -int ERR_load_ERR_strings(void); - -#if OPENSSL_API_COMPAT < 0x10100000L -# define ERR_load_crypto_strings() \ - OPENSSL_init_crypto(OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) -# define ERR_free_strings() while(0) continue -#endif - -DEPRECATEDIN_1_1_0(void ERR_remove_thread_state(void *)) -DEPRECATEDIN_1_0_0(void ERR_remove_state(unsigned long pid)) -ERR_STATE *ERR_get_state(void); - -int ERR_get_next_error_library(void); - -int ERR_set_mark(void); -int ERR_pop_to_mark(void); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android/armeabi/include/openssl/evp.h b/android/armeabi/include/openssl/evp.h deleted file mode 100644 index b9c83b2b..00000000 --- a/android/armeabi/include/openssl/evp.h +++ /dev/null @@ -1,1586 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_ENVELOPE_H -# define HEADER_ENVELOPE_H - -# include <openssl/opensslconf.h> -# include <openssl/ossl_typ.h> -# include <openssl/symhacks.h> -# include <openssl/bio.h> - -# define EVP_MAX_MD_SIZE 64/* longest known is SHA512 */ -# define EVP_MAX_KEY_LENGTH 64 -# define EVP_MAX_IV_LENGTH 16 -# define EVP_MAX_BLOCK_LENGTH 32 - -# define PKCS5_SALT_LEN 8 -/* Default PKCS#5 iteration count */ -# define PKCS5_DEFAULT_ITER 2048 - -# include <openssl/objects.h> - -# define EVP_PK_RSA 0x0001 -# define EVP_PK_DSA 0x0002 -# define EVP_PK_DH 0x0004 -# define EVP_PK_EC 0x0008 -# define EVP_PKT_SIGN 0x0010 -# define EVP_PKT_ENC 0x0020 -# define EVP_PKT_EXCH 0x0040 -# define EVP_PKS_RSA 0x0100 -# define EVP_PKS_DSA 0x0200 -# define EVP_PKS_EC 0x0400 - -# define EVP_PKEY_NONE NID_undef -# define EVP_PKEY_RSA NID_rsaEncryption -# define EVP_PKEY_RSA2 NID_rsa -# define EVP_PKEY_DSA NID_dsa -# define EVP_PKEY_DSA1 NID_dsa_2 -# define EVP_PKEY_DSA2 NID_dsaWithSHA -# define EVP_PKEY_DSA3 NID_dsaWithSHA1 -# define EVP_PKEY_DSA4 NID_dsaWithSHA1_2 -# define EVP_PKEY_DH NID_dhKeyAgreement -# define EVP_PKEY_DHX NID_dhpublicnumber -# define EVP_PKEY_EC NID_X9_62_id_ecPublicKey -# define EVP_PKEY_HMAC NID_hmac -# define EVP_PKEY_CMAC NID_cmac -# define EVP_PKEY_TLS1_PRF NID_tls1_prf -# define EVP_PKEY_HKDF NID_hkdf - -#ifdef __cplusplus -extern "C" { -#endif - -# define EVP_PKEY_MO_SIGN 0x0001 -# define EVP_PKEY_MO_VERIFY 0x0002 -# define EVP_PKEY_MO_ENCRYPT 0x0004 -# define EVP_PKEY_MO_DECRYPT 0x0008 - -# ifndef EVP_MD -EVP_MD *EVP_MD_meth_new(int md_type, int pkey_type); -EVP_MD *EVP_MD_meth_dup(const EVP_MD *md); -void EVP_MD_meth_free(EVP_MD *md); - -int EVP_MD_meth_set_input_blocksize(EVP_MD *md, int blocksize); -int EVP_MD_meth_set_result_size(EVP_MD *md, int resultsize); -int EVP_MD_meth_set_app_datasize(EVP_MD *md, int datasize); -int EVP_MD_meth_set_flags(EVP_MD *md, unsigned long flags); -int EVP_MD_meth_set_init(EVP_MD *md, int (*init)(EVP_MD_CTX *ctx)); -int EVP_MD_meth_set_update(EVP_MD *md, int (*update)(EVP_MD_CTX *ctx, - const void *data, - size_t count)); -int EVP_MD_meth_set_final(EVP_MD *md, int (*final)(EVP_MD_CTX *ctx, - unsigned char *md)); -int EVP_MD_meth_set_copy(EVP_MD *md, int (*copy)(EVP_MD_CTX *to, - const EVP_MD_CTX *from)); -int EVP_MD_meth_set_cleanup(EVP_MD *md, int (*cleanup)(EVP_MD_CTX *ctx)); -int EVP_MD_meth_set_ctrl(EVP_MD *md, int (*ctrl)(EVP_MD_CTX *ctx, int cmd, - int p1, void *p2)); - -int EVP_MD_meth_get_input_blocksize(const EVP_MD *md); -int EVP_MD_meth_get_result_size(const EVP_MD *md); -int EVP_MD_meth_get_app_datasize(const EVP_MD *md); -unsigned long EVP_MD_meth_get_flags(const EVP_MD *md); -int (*EVP_MD_meth_get_init(const EVP_MD *md))(EVP_MD_CTX *ctx); -int (*EVP_MD_meth_get_update(const EVP_MD *md))(EVP_MD_CTX *ctx, - const void *data, - size_t count); -int (*EVP_MD_meth_get_final(const EVP_MD *md))(EVP_MD_CTX *ctx, - unsigned char *md); -int (*EVP_MD_meth_get_copy(const EVP_MD *md))(EVP_MD_CTX *to, - const EVP_MD_CTX *from); -int (*EVP_MD_meth_get_cleanup(const EVP_MD *md))(EVP_MD_CTX *ctx); -int (*EVP_MD_meth_get_ctrl(const EVP_MD *md))(EVP_MD_CTX *ctx, int cmd, - int p1, void *p2); - -/* digest can only handle a single block */ -# define EVP_MD_FLAG_ONESHOT 0x0001 - -/* DigestAlgorithmIdentifier flags... */ - -# define EVP_MD_FLAG_DIGALGID_MASK 0x0018 - -/* NULL or absent parameter accepted. Use NULL */ - -# define EVP_MD_FLAG_DIGALGID_NULL 0x0000 - -/* NULL or absent parameter accepted. Use NULL for PKCS#1 otherwise absent */ - -# define EVP_MD_FLAG_DIGALGID_ABSENT 0x0008 - -/* Custom handling via ctrl */ - -# define EVP_MD_FLAG_DIGALGID_CUSTOM 0x0018 - -/* Note if suitable for use in FIPS mode */ -# define EVP_MD_FLAG_FIPS 0x0400 - -/* Digest ctrls */ - -# define EVP_MD_CTRL_DIGALGID 0x1 -# define EVP_MD_CTRL_MICALG 0x2 - -/* Minimum Algorithm specific ctrl value */ - -# define EVP_MD_CTRL_ALG_CTRL 0x1000 - -# endif /* !EVP_MD */ - -/* values for EVP_MD_CTX flags */ - -# define EVP_MD_CTX_FLAG_ONESHOT 0x0001/* digest update will be - * called once only */ -# define EVP_MD_CTX_FLAG_CLEANED 0x0002/* context has already been - * cleaned */ -# define EVP_MD_CTX_FLAG_REUSE 0x0004/* Don't free up ctx->md_data - * in EVP_MD_CTX_reset */ -/* - * FIPS and pad options are ignored in 1.0.0, definitions are here so we - * don't accidentally reuse the values for other purposes. - */ - -# define EVP_MD_CTX_FLAG_NON_FIPS_ALLOW 0x0008/* Allow use of non FIPS - * digest in FIPS mode */ - -/* - * The following PAD options are also currently ignored in 1.0.0, digest - * parameters are handled through EVP_DigestSign*() and EVP_DigestVerify*() - * instead. - */ -# define EVP_MD_CTX_FLAG_PAD_MASK 0xF0/* RSA mode to use */ -# define EVP_MD_CTX_FLAG_PAD_PKCS1 0x00/* PKCS#1 v1.5 mode */ -# define EVP_MD_CTX_FLAG_PAD_X931 0x10/* X9.31 mode */ -# define EVP_MD_CTX_FLAG_PAD_PSS 0x20/* PSS mode */ - -# define EVP_MD_CTX_FLAG_NO_INIT 0x0100/* Don't initialize md_data */ -/* - * Some functions such as EVP_DigestSign only finalise copies of internal - * contexts so additional data can be included after the finalisation call. - * This is inefficient if this functionality is not required: it is disabled - * if the following flag is set. - */ -# define EVP_MD_CTX_FLAG_FINALISE 0x0200 - -EVP_CIPHER *EVP_CIPHER_meth_new(int cipher_type, int block_size, int key_len); -EVP_CIPHER *EVP_CIPHER_meth_dup(const EVP_CIPHER *cipher); -void EVP_CIPHER_meth_free(EVP_CIPHER *cipher); - -int EVP_CIPHER_meth_set_iv_length(EVP_CIPHER *cipher, int iv_len); -int EVP_CIPHER_meth_set_flags(EVP_CIPHER *cipher, unsigned long flags); -int EVP_CIPHER_meth_set_impl_ctx_size(EVP_CIPHER *cipher, int ctx_size); -int EVP_CIPHER_meth_set_init(EVP_CIPHER *cipher, - int (*init) (EVP_CIPHER_CTX *ctx, - const unsigned char *key, - const unsigned char *iv, - int enc)); -int EVP_CIPHER_meth_set_do_cipher(EVP_CIPHER *cipher, - int (*do_cipher) (EVP_CIPHER_CTX *ctx, - unsigned char *out, - const unsigned char *in, - size_t inl)); -int EVP_CIPHER_meth_set_cleanup(EVP_CIPHER *cipher, - int (*cleanup) (EVP_CIPHER_CTX *)); -int EVP_CIPHER_meth_set_set_asn1_params(EVP_CIPHER *cipher, - int (*set_asn1_parameters) (EVP_CIPHER_CTX *, - ASN1_TYPE *)); -int EVP_CIPHER_meth_set_get_asn1_params(EVP_CIPHER *cipher, - int (*get_asn1_parameters) (EVP_CIPHER_CTX *, - ASN1_TYPE *)); -int EVP_CIPHER_meth_set_ctrl(EVP_CIPHER *cipher, - int (*ctrl) (EVP_CIPHER_CTX *, int type, - int arg, void *ptr)); - -int (*EVP_CIPHER_meth_get_init(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx, - const unsigned char *key, - const unsigned char *iv, - int enc); -int (*EVP_CIPHER_meth_get_do_cipher(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *ctx, - unsigned char *out, - const unsigned char *in, - size_t inl); -int (*EVP_CIPHER_meth_get_cleanup(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *); -int (*EVP_CIPHER_meth_get_set_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, - ASN1_TYPE *); -int (*EVP_CIPHER_meth_get_get_asn1_params(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, - ASN1_TYPE *); -int (*EVP_CIPHER_meth_get_ctrl(const EVP_CIPHER *cipher))(EVP_CIPHER_CTX *, - int type, int arg, - void *ptr); - -/* Values for cipher flags */ - -/* Modes for ciphers */ - -# define EVP_CIPH_STREAM_CIPHER 0x0 -# define EVP_CIPH_ECB_MODE 0x1 -# define EVP_CIPH_CBC_MODE 0x2 -# define EVP_CIPH_CFB_MODE 0x3 -# define EVP_CIPH_OFB_MODE 0x4 -# define EVP_CIPH_CTR_MODE 0x5 -# define EVP_CIPH_GCM_MODE 0x6 -# define EVP_CIPH_CCM_MODE 0x7 -# define EVP_CIPH_XTS_MODE 0x10001 -# define EVP_CIPH_WRAP_MODE 0x10002 -# define EVP_CIPH_OCB_MODE 0x10003 -# define EVP_CIPH_MODE 0xF0007 -/* Set if variable length cipher */ -# define EVP_CIPH_VARIABLE_LENGTH 0x8 -/* Set if the iv handling should be done by the cipher itself */ -# define EVP_CIPH_CUSTOM_IV 0x10 -/* Set if the cipher's init() function should be called if key is NULL */ -# define EVP_CIPH_ALWAYS_CALL_INIT 0x20 -/* Call ctrl() to init cipher parameters */ -# define EVP_CIPH_CTRL_INIT 0x40 -/* Don't use standard key length function */ -# define EVP_CIPH_CUSTOM_KEY_LENGTH 0x80 -/* Don't use standard block padding */ -# define EVP_CIPH_NO_PADDING 0x100 -/* cipher handles random key generation */ -# define EVP_CIPH_RAND_KEY 0x200 -/* cipher has its own additional copying logic */ -# define EVP_CIPH_CUSTOM_COPY 0x400 -/* Allow use default ASN1 get/set iv */ -# define EVP_CIPH_FLAG_DEFAULT_ASN1 0x1000 -/* Buffer length in bits not bytes: CFB1 mode only */ -# define EVP_CIPH_FLAG_LENGTH_BITS 0x2000 -/* Note if suitable for use in FIPS mode */ -# define EVP_CIPH_FLAG_FIPS 0x4000 -/* Allow non FIPS cipher in FIPS mode */ -# define EVP_CIPH_FLAG_NON_FIPS_ALLOW 0x8000 -/* - * Cipher handles any and all padding logic as well as finalisation. - */ -# define EVP_CIPH_FLAG_CUSTOM_CIPHER 0x100000 -# define EVP_CIPH_FLAG_AEAD_CIPHER 0x200000 -# define EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK 0x400000 -/* Cipher can handle pipeline operations */ -# define EVP_CIPH_FLAG_PIPELINE 0X800000 - -/* - * Cipher context flag to indicate we can handle wrap mode: if allowed in - * older applications it could overflow buffers. - */ - -# define EVP_CIPHER_CTX_FLAG_WRAP_ALLOW 0x1 - -/* ctrl() values */ - -# define EVP_CTRL_INIT 0x0 -# define EVP_CTRL_SET_KEY_LENGTH 0x1 -# define EVP_CTRL_GET_RC2_KEY_BITS 0x2 -# define EVP_CTRL_SET_RC2_KEY_BITS 0x3 -# define EVP_CTRL_GET_RC5_ROUNDS 0x4 -# define EVP_CTRL_SET_RC5_ROUNDS 0x5 -# define EVP_CTRL_RAND_KEY 0x6 -# define EVP_CTRL_PBE_PRF_NID 0x7 -# define EVP_CTRL_COPY 0x8 -# define EVP_CTRL_AEAD_SET_IVLEN 0x9 -# define EVP_CTRL_AEAD_GET_TAG 0x10 -# define EVP_CTRL_AEAD_SET_TAG 0x11 -# define EVP_CTRL_AEAD_SET_IV_FIXED 0x12 -# define EVP_CTRL_GCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN -# define EVP_CTRL_GCM_GET_TAG EVP_CTRL_AEAD_GET_TAG -# define EVP_CTRL_GCM_SET_TAG EVP_CTRL_AEAD_SET_TAG -# define EVP_CTRL_GCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED -# define EVP_CTRL_GCM_IV_GEN 0x13 -# define EVP_CTRL_CCM_SET_IVLEN EVP_CTRL_AEAD_SET_IVLEN -# define EVP_CTRL_CCM_GET_TAG EVP_CTRL_AEAD_GET_TAG -# define EVP_CTRL_CCM_SET_TAG EVP_CTRL_AEAD_SET_TAG -# define EVP_CTRL_CCM_SET_IV_FIXED EVP_CTRL_AEAD_SET_IV_FIXED -# define EVP_CTRL_CCM_SET_L 0x14 -# define EVP_CTRL_CCM_SET_MSGLEN 0x15 -/* - * AEAD cipher deduces payload length and returns number of bytes required to - * store MAC and eventual padding. Subsequent call to EVP_Cipher even - * appends/verifies MAC. - */ -# define EVP_CTRL_AEAD_TLS1_AAD 0x16 -/* Used by composite AEAD ciphers, no-op in GCM, CCM... */ -# define EVP_CTRL_AEAD_SET_MAC_KEY 0x17 -/* Set the GCM invocation field, decrypt only */ -# define EVP_CTRL_GCM_SET_IV_INV 0x18 - -# define EVP_CTRL_TLS1_1_MULTIBLOCK_AAD 0x19 -# define EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT 0x1a -# define EVP_CTRL_TLS1_1_MULTIBLOCK_DECRYPT 0x1b -# define EVP_CTRL_TLS1_1_MULTIBLOCK_MAX_BUFSIZE 0x1c - -# define EVP_CTRL_SSL3_MASTER_SECRET 0x1d - -/* EVP_CTRL_SET_SBOX takes the char * specifying S-boxes */ -# define EVP_CTRL_SET_SBOX 0x1e -/* - * EVP_CTRL_SBOX_USED takes a 'size_t' and 'char *', pointing at a - * pre-allocated buffer with specified size - */ -# define EVP_CTRL_SBOX_USED 0x1f -/* EVP_CTRL_KEY_MESH takes 'size_t' number of bytes to mesh the key after, - * 0 switches meshing off - */ -# define EVP_CTRL_KEY_MESH 0x20 -/* EVP_CTRL_BLOCK_PADDING_MODE takes the padding mode */ -# define EVP_CTRL_BLOCK_PADDING_MODE 0x21 - -/* Set the output buffers to use for a pipelined operation */ -# define EVP_CTRL_SET_PIPELINE_OUTPUT_BUFS 0x22 -/* Set the input buffers to use for a pipelined operation */ -# define EVP_CTRL_SET_PIPELINE_INPUT_BUFS 0x23 -/* Set the input buffer lengths to use for a pipelined operation */ -# define EVP_CTRL_SET_PIPELINE_INPUT_LENS 0x24 - -/* Padding modes */ -#define EVP_PADDING_PKCS7 1 -#define EVP_PADDING_ISO7816_4 2 -#define EVP_PADDING_ANSI923 3 -#define EVP_PADDING_ISO10126 4 -#define EVP_PADDING_ZERO 5 - -/* RFC 5246 defines additional data to be 13 bytes in length */ -# define EVP_AEAD_TLS1_AAD_LEN 13 - -typedef struct { - unsigned char *out; - const unsigned char *inp; - size_t len; - unsigned int interleave; -} EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM; - -/* GCM TLS constants */ -/* Length of fixed part of IV derived from PRF */ -# define EVP_GCM_TLS_FIXED_IV_LEN 4 -/* Length of explicit part of IV part of TLS records */ -# define EVP_GCM_TLS_EXPLICIT_IV_LEN 8 -/* Length of tag for TLS */ -# define EVP_GCM_TLS_TAG_LEN 16 - -/* CCM TLS constants */ -/* Length of fixed part of IV derived from PRF */ -# define EVP_CCM_TLS_FIXED_IV_LEN 4 -/* Length of explicit part of IV part of TLS records */ -# define EVP_CCM_TLS_EXPLICIT_IV_LEN 8 - -typedef struct evp_cipher_info_st { - const EVP_CIPHER *cipher; - unsigned char iv[EVP_MAX_IV_LENGTH]; -} EVP_CIPHER_INFO; - - -/* Password based encryption function */ -typedef int (EVP_PBE_KEYGEN) (EVP_CIPHER_CTX *ctx, const char *pass, - int passlen, ASN1_TYPE *param, - const EVP_CIPHER *cipher, const EVP_MD *md, - int en_de); - -# ifndef OPENSSL_NO_RSA -# define EVP_PKEY_assign_RSA(pkey,rsa) EVP_PKEY_assign((pkey),EVP_PKEY_RSA,\ - (char *)(rsa)) -# endif - -# ifndef OPENSSL_NO_DSA -# define EVP_PKEY_assign_DSA(pkey,dsa) EVP_PKEY_assign((pkey),EVP_PKEY_DSA,\ - (char *)(dsa)) -# endif - -# ifndef OPENSSL_NO_DH -# define EVP_PKEY_assign_DH(pkey,dh) EVP_PKEY_assign((pkey),EVP_PKEY_DH,\ - (char *)(dh)) -# endif - -# ifndef OPENSSL_NO_EC -# define EVP_PKEY_assign_EC_KEY(pkey,eckey) EVP_PKEY_assign((pkey),EVP_PKEY_EC,\ - (char *)(eckey)) -# endif - -/* Add some extra combinations */ -# define EVP_get_digestbynid(a) EVP_get_digestbyname(OBJ_nid2sn(a)) -# define EVP_get_digestbyobj(a) EVP_get_digestbynid(OBJ_obj2nid(a)) -# define EVP_get_cipherbynid(a) EVP_get_cipherbyname(OBJ_nid2sn(a)) -# define EVP_get_cipherbyobj(a) EVP_get_cipherbynid(OBJ_obj2nid(a)) - -int EVP_MD_type(const EVP_MD *md); -# define EVP_MD_nid(e) EVP_MD_type(e) -# define EVP_MD_name(e) OBJ_nid2sn(EVP_MD_nid(e)) -int EVP_MD_pkey_type(const EVP_MD *md); -int EVP_MD_size(const EVP_MD *md); -int EVP_MD_block_size(const EVP_MD *md); -unsigned long EVP_MD_flags(const EVP_MD *md); - -const EVP_MD *EVP_MD_CTX_md(const EVP_MD_CTX *ctx); -int (*EVP_MD_CTX_update_fn(EVP_MD_CTX *ctx))(EVP_MD_CTX *ctx, - const void *data, size_t count); -void EVP_MD_CTX_set_update_fn(EVP_MD_CTX *ctx, - int (*update) (EVP_MD_CTX *ctx, - const void *data, size_t count)); -# define EVP_MD_CTX_size(e) EVP_MD_size(EVP_MD_CTX_md(e)) -# define EVP_MD_CTX_block_size(e) EVP_MD_block_size(EVP_MD_CTX_md(e)) -# define EVP_MD_CTX_type(e) EVP_MD_type(EVP_MD_CTX_md(e)) -EVP_PKEY_CTX *EVP_MD_CTX_pkey_ctx(const EVP_MD_CTX *ctx); -void *EVP_MD_CTX_md_data(const EVP_MD_CTX *ctx); - -int EVP_CIPHER_nid(const EVP_CIPHER *cipher); -# define EVP_CIPHER_name(e) OBJ_nid2sn(EVP_CIPHER_nid(e)) -int EVP_CIPHER_block_size(const EVP_CIPHER *cipher); -int EVP_CIPHER_impl_ctx_size(const EVP_CIPHER *cipher); -int EVP_CIPHER_key_length(const EVP_CIPHER *cipher); -int EVP_CIPHER_iv_length(const EVP_CIPHER *cipher); -unsigned long EVP_CIPHER_flags(const EVP_CIPHER *cipher); -# define EVP_CIPHER_mode(e) (EVP_CIPHER_flags(e) & EVP_CIPH_MODE) - -const EVP_CIPHER *EVP_CIPHER_CTX_cipher(const EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_encrypting(const EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_nid(const EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_block_size(const EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_key_length(const EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_iv_length(const EVP_CIPHER_CTX *ctx); -const unsigned char *EVP_CIPHER_CTX_iv(const EVP_CIPHER_CTX *ctx); -const unsigned char *EVP_CIPHER_CTX_original_iv(const EVP_CIPHER_CTX *ctx); -unsigned char *EVP_CIPHER_CTX_iv_noconst(EVP_CIPHER_CTX *ctx); -unsigned char *EVP_CIPHER_CTX_buf_noconst(EVP_CIPHER_CTX *ctx); -int EVP_CIPHER_CTX_num(const EVP_CIPHER_CTX *ctx); -void EVP_CIPHER_CTX_set_num(EVP_CIPHER_CTX *ctx, int num); -int EVP_CIPHER_CTX_copy(EVP_CIPHER_CTX *out, const EVP_CIPHER_CTX *in); -void *EVP_CIPHER_CTX_get_app_data(const EVP_CIPHER_CTX *ctx); -void EVP_CIPHER_CTX_set_app_data(EVP_CIPHER_CTX *ctx, void *data); -void *EVP_CIPHER_CTX_get_cipher_data(const EVP_CIPHER_CTX *ctx); -void *EVP_CIPHER_CTX_set_cipher_data(EVP_CIPHER_CTX *ctx, void *cipher_data); -# define EVP_CIPHER_CTX_type(c) EVP_CIPHER_type(EVP_CIPHER_CTX_cipher(c)) -# if OPENSSL_API_COMPAT < 0x10100000L -# define EVP_CIPHER_CTX_flags(c) EVP_CIPHER_flags(EVP_CIPHER_CTX_cipher(c)) -# endif -# define EVP_CIPHER_CTX_mode(c) EVP_CIPHER_mode(EVP_CIPHER_CTX_cipher(c)) - -# define EVP_ENCODE_LENGTH(l) (((l+2)/3*4)+(l/48+1)*2+80) -# define EVP_DECODE_LENGTH(l) ((l+3)/4*3+80) - -# define EVP_SignInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) -# define EVP_SignInit(a,b) EVP_DigestInit(a,b) -# define EVP_SignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) -# define EVP_VerifyInit_ex(a,b,c) EVP_DigestInit_ex(a,b,c) -# define EVP_VerifyInit(a,b) EVP_DigestInit(a,b) -# define EVP_VerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) -# define EVP_OpenUpdate(a,b,c,d,e) EVP_DecryptUpdate(a,b,c,d,e) -# define EVP_SealUpdate(a,b,c,d,e) EVP_EncryptUpdate(a,b,c,d,e) -# define EVP_DigestSignUpdate(a,b,c) EVP_DigestUpdate(a,b,c) -# define EVP_DigestVerifyUpdate(a,b,c) EVP_DigestUpdate(a,b,c) - -# ifdef CONST_STRICT -void BIO_set_md(BIO *, const EVP_MD *md); -# else -# define BIO_set_md(b,md) BIO_ctrl(b,BIO_C_SET_MD,0,(char *)md) -# endif -# define BIO_get_md(b,mdp) BIO_ctrl(b,BIO_C_GET_MD,0,(char *)mdp) -# define BIO_get_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_GET_MD_CTX,0,(char *)mdcp) -# define BIO_set_md_ctx(b,mdcp) BIO_ctrl(b,BIO_C_SET_MD_CTX,0,(char *)mdcp) -# define BIO_get_cipher_status(b) BIO_ctrl(b,BIO_C_GET_CIPHER_STATUS,0,NULL) -# define BIO_get_cipher_ctx(b,c_pp) BIO_ctrl(b,BIO_C_GET_CIPHER_CTX,0,(char *)c_pp) - -/*__owur*/ int EVP_Cipher(EVP_CIPHER_CTX *c, - unsigned char *out, - const unsigned char *in, unsigned int inl); - -# define EVP_add_cipher_alias(n,alias) \ - OBJ_NAME_add((alias),OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS,(n)) -# define EVP_add_digest_alias(n,alias) \ - OBJ_NAME_add((alias),OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS,(n)) -# define EVP_delete_cipher_alias(alias) \ - OBJ_NAME_remove(alias,OBJ_NAME_TYPE_CIPHER_METH|OBJ_NAME_ALIAS); -# define EVP_delete_digest_alias(alias) \ - OBJ_NAME_remove(alias,OBJ_NAME_TYPE_MD_METH|OBJ_NAME_ALIAS); - -int EVP_MD_CTX_ctrl(EVP_MD_CTX *ctx, int cmd, int p1, void *p2); -EVP_MD_CTX *EVP_MD_CTX_new(void); -int EVP_MD_CTX_reset(EVP_MD_CTX *ctx); -void EVP_MD_CTX_free(EVP_MD_CTX *ctx); -# define EVP_MD_CTX_create() EVP_MD_CTX_new() -# define EVP_MD_CTX_init(ctx) EVP_MD_CTX_reset((ctx)) -# define EVP_MD_CTX_destroy(ctx) EVP_MD_CTX_free((ctx)) -__owur int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in); -void EVP_MD_CTX_set_flags(EVP_MD_CTX *ctx, int flags); -void EVP_MD_CTX_clear_flags(EVP_MD_CTX *ctx, int flags); -int EVP_MD_CTX_test_flags(const EVP_MD_CTX *ctx, int flags); -__owur int EVP_DigestInit_ex(EVP_MD_CTX *ctx, const EVP_MD *type, - ENGINE *impl); -__owur int EVP_DigestUpdate(EVP_MD_CTX *ctx, const void *d, - size_t cnt); -__owur int EVP_DigestFinal_ex(EVP_MD_CTX *ctx, unsigned char *md, - unsigned int *s); -__owur int EVP_Digest(const void *data, size_t count, - unsigned char *md, unsigned int *size, - const EVP_MD *type, ENGINE *impl); - -__owur int EVP_MD_CTX_copy(EVP_MD_CTX *out, const EVP_MD_CTX *in); -__owur int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type); -__owur int EVP_DigestFinal(EVP_MD_CTX *ctx, unsigned char *md, - unsigned int *s); - -#ifndef OPENSSL_NO_UI -int EVP_read_pw_string(char *buf, int length, const char *prompt, int verify); -int EVP_read_pw_string_min(char *buf, int minlen, int maxlen, - const char *prompt, int verify); -void EVP_set_pw_prompt(const char *prompt); -char *EVP_get_pw_prompt(void); -#endif - -__owur int EVP_BytesToKey(const EVP_CIPHER *type, const EVP_MD *md, - const unsigned char *salt, - const unsigned char *data, int datal, int count, - unsigned char *key, unsigned char *iv); - -void EVP_CIPHER_CTX_set_flags(EVP_CIPHER_CTX *ctx, int flags); -void EVP_CIPHER_CTX_clear_flags(EVP_CIPHER_CTX *ctx, int flags); -int EVP_CIPHER_CTX_test_flags(const EVP_CIPHER_CTX *ctx, int flags); - -__owur int EVP_EncryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv); -/*__owur*/ int EVP_EncryptInit_ex(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, - const unsigned char *iv); -/*__owur*/ int EVP_EncryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl, const unsigned char *in, int inl); -/*__owur*/ int EVP_EncryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl); -/*__owur*/ int EVP_EncryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl); - -__owur int EVP_DecryptInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv); -/*__owur*/ int EVP_DecryptInit_ex(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, - const unsigned char *iv); -/*__owur*/ int EVP_DecryptUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl, const unsigned char *in, int inl); -__owur int EVP_DecryptFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, - int *outl); -/*__owur*/ int EVP_DecryptFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, - int *outl); - -__owur int EVP_CipherInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *cipher, - const unsigned char *key, const unsigned char *iv, - int enc); -/*__owur*/ int EVP_CipherInit_ex(EVP_CIPHER_CTX *ctx, - const EVP_CIPHER *cipher, ENGINE *impl, - const unsigned char *key, - const unsigned char *iv, int enc); -__owur int EVP_CipherUpdate(EVP_CIPHER_CTX *ctx, unsigned char *out, - int *outl, const unsigned char *in, int inl); -__owur int EVP_CipherFinal(EVP_CIPHER_CTX *ctx, unsigned char *outm, - int *outl); -__owur int EVP_CipherFinal_ex(EVP_CIPHER_CTX *ctx, unsigned char *outm, - int *outl); - -__owur int EVP_SignFinal(EVP_MD_CTX *ctx, unsigned char *md, unsigned int *s, - EVP_PKEY *pkey); - -__owur int EVP_VerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sigbuf, - unsigned int siglen, EVP_PKEY *pkey); - -/*__owur*/ int EVP_DigestSignInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, - const EVP_MD *type, ENGINE *e, - EVP_PKEY *pkey); -__owur int EVP_DigestSignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, - size_t *siglen); - -__owur int EVP_DigestVerifyInit(EVP_MD_CTX *ctx, EVP_PKEY_CTX **pctx, - const EVP_MD *type, ENGINE *e, - EVP_PKEY *pkey); -__owur int EVP_DigestVerifyFinal(EVP_MD_CTX *ctx, const unsigned char *sig, - size_t siglen); - -# ifndef OPENSSL_NO_RSA -__owur int EVP_OpenInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, - const unsigned char *ek, int ekl, - const unsigned char *iv, EVP_PKEY *priv); -__owur int EVP_OpenFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); - -__owur int EVP_SealInit(EVP_CIPHER_CTX *ctx, const EVP_CIPHER *type, - unsigned char **ek, int *ekl, unsigned char *iv, - EVP_PKEY **pubk, int npubk); -__owur int EVP_SealFinal(EVP_CIPHER_CTX *ctx, unsigned char *out, int *outl); -# endif - -EVP_ENCODE_CTX *EVP_ENCODE_CTX_new(void); -void EVP_ENCODE_CTX_free(EVP_ENCODE_CTX *ctx); -int EVP_ENCODE_CTX_copy(EVP_ENCODE_CTX *dctx, EVP_ENCODE_CTX *sctx); -int EVP_ENCODE_CTX_num(EVP_ENCODE_CTX *ctx); -void EVP_EncodeInit(EVP_ENCODE_CTX *ctx); -int EVP_EncodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, - const unsigned char *in, int inl); -void EVP_EncodeFinal(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl); -int EVP_EncodeBlock(unsigned char *t, const unsigned char *f, int n); - -void EVP_DecodeInit(EVP_ENCODE_CTX *ctx); -int EVP_DecodeUpdate(EVP_ENCODE_CTX *ctx, unsigned char *out, int *outl, - const unsigned char *in, int inl); -int EVP_DecodeFinal(EVP_ENCODE_CTX *ctx, unsigned - char *out, int *outl); -int EVP_DecodeBlock(unsigned char *t, const unsigned char *f, int n); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define EVP_CIPHER_CTX_init(c) EVP_CIPHER_CTX_reset(c) -# define EVP_CIPHER_CTX_cleanup(c) EVP_CIPHER_CTX_reset(c) -# endif -EVP_CIPHER_CTX *EVP_CIPHER_CTX_new(void); -int EVP_CIPHER_CTX_reset(EVP_CIPHER_CTX *c); -void EVP_CIPHER_CTX_free(EVP_CIPHER_CTX *c); -int EVP_CIPHER_CTX_set_key_length(EVP_CIPHER_CTX *x, int keylen); -int EVP_CIPHER_CTX_set_padding(EVP_CIPHER_CTX *c, int pad); -int EVP_CIPHER_CTX_ctrl(EVP_CIPHER_CTX *ctx, int type, int arg, void *ptr); -int EVP_CIPHER_CTX_rand_key(EVP_CIPHER_CTX *ctx, unsigned char *key); - -const BIO_METHOD *BIO_f_md(void); -const BIO_METHOD *BIO_f_base64(void); -const BIO_METHOD *BIO_f_cipher(void); -const BIO_METHOD *BIO_f_reliable(void); -__owur int BIO_set_cipher(BIO *b, const EVP_CIPHER *c, const unsigned char *k, - const unsigned char *i, int enc); - -const EVP_MD *EVP_md_null(void); -# ifndef OPENSSL_NO_MD2 -const EVP_MD *EVP_md2(void); -# endif -# ifndef OPENSSL_NO_MD4 -const EVP_MD *EVP_md4(void); -# endif -# ifndef OPENSSL_NO_MD5 -const EVP_MD *EVP_md5(void); -const EVP_MD *EVP_md5_sha1(void); -# endif -# ifndef OPENSSL_NO_BLAKE2 -const EVP_MD *EVP_blake2b512(void); -const EVP_MD *EVP_blake2s256(void); -# endif -const EVP_MD *EVP_sha1(void); -const EVP_MD *EVP_sha224(void); -const EVP_MD *EVP_sha256(void); -const EVP_MD *EVP_sha384(void); -const EVP_MD *EVP_sha512(void); -# ifndef OPENSSL_NO_MDC2 -const EVP_MD *EVP_mdc2(void); -# endif -# ifndef OPENSSL_NO_RMD160 -const EVP_MD *EVP_ripemd160(void); -# endif -# ifndef OPENSSL_NO_WHIRLPOOL -const EVP_MD *EVP_whirlpool(void); -# endif -const EVP_CIPHER *EVP_enc_null(void); /* does nothing :-) */ -# ifndef OPENSSL_NO_DES -const EVP_CIPHER *EVP_des_ecb(void); -const EVP_CIPHER *EVP_des_ede(void); -const EVP_CIPHER *EVP_des_ede3(void); -const EVP_CIPHER *EVP_des_ede_ecb(void); -const EVP_CIPHER *EVP_des_ede3_ecb(void); -const EVP_CIPHER *EVP_des_cfb64(void); -# define EVP_des_cfb EVP_des_cfb64 -const EVP_CIPHER *EVP_des_cfb1(void); -const EVP_CIPHER *EVP_des_cfb8(void); -const EVP_CIPHER *EVP_des_ede_cfb64(void); -# define EVP_des_ede_cfb EVP_des_ede_cfb64 -const EVP_CIPHER *EVP_des_ede3_cfb64(void); -# define EVP_des_ede3_cfb EVP_des_ede3_cfb64 -const EVP_CIPHER *EVP_des_ede3_cfb1(void); -const EVP_CIPHER *EVP_des_ede3_cfb8(void); -const EVP_CIPHER *EVP_des_ofb(void); -const EVP_CIPHER *EVP_des_ede_ofb(void); -const EVP_CIPHER *EVP_des_ede3_ofb(void); -const EVP_CIPHER *EVP_des_cbc(void); -const EVP_CIPHER *EVP_des_ede_cbc(void); -const EVP_CIPHER *EVP_des_ede3_cbc(void); -const EVP_CIPHER *EVP_desx_cbc(void); -const EVP_CIPHER *EVP_des_ede3_wrap(void); -/* - * This should now be supported through the dev_crypto ENGINE. But also, why - * are rc4 and md5 declarations made here inside a "NO_DES" precompiler - * branch? - */ -# endif -# ifndef OPENSSL_NO_RC4 -const EVP_CIPHER *EVP_rc4(void); -const EVP_CIPHER *EVP_rc4_40(void); -# ifndef OPENSSL_NO_MD5 -const EVP_CIPHER *EVP_rc4_hmac_md5(void); -# endif -# endif -# ifndef OPENSSL_NO_IDEA -const EVP_CIPHER *EVP_idea_ecb(void); -const EVP_CIPHER *EVP_idea_cfb64(void); -# define EVP_idea_cfb EVP_idea_cfb64 -const EVP_CIPHER *EVP_idea_ofb(void); -const EVP_CIPHER *EVP_idea_cbc(void); -# endif -# ifndef OPENSSL_NO_RC2 -const EVP_CIPHER *EVP_rc2_ecb(void); -const EVP_CIPHER *EVP_rc2_cbc(void); -const EVP_CIPHER *EVP_rc2_40_cbc(void); -const EVP_CIPHER *EVP_rc2_64_cbc(void); -const EVP_CIPHER *EVP_rc2_cfb64(void); -# define EVP_rc2_cfb EVP_rc2_cfb64 -const EVP_CIPHER *EVP_rc2_ofb(void); -# endif -# ifndef OPENSSL_NO_BF -const EVP_CIPHER *EVP_bf_ecb(void); -const EVP_CIPHER *EVP_bf_cbc(void); -const EVP_CIPHER *EVP_bf_cfb64(void); -# define EVP_bf_cfb EVP_bf_cfb64 -const EVP_CIPHER *EVP_bf_ofb(void); -# endif -# ifndef OPENSSL_NO_CAST -const EVP_CIPHER *EVP_cast5_ecb(void); -const EVP_CIPHER *EVP_cast5_cbc(void); -const EVP_CIPHER *EVP_cast5_cfb64(void); -# define EVP_cast5_cfb EVP_cast5_cfb64 -const EVP_CIPHER *EVP_cast5_ofb(void); -# endif -# ifndef OPENSSL_NO_RC5 -const EVP_CIPHER *EVP_rc5_32_12_16_cbc(void); -const EVP_CIPHER *EVP_rc5_32_12_16_ecb(void); -const EVP_CIPHER *EVP_rc5_32_12_16_cfb64(void); -# define EVP_rc5_32_12_16_cfb EVP_rc5_32_12_16_cfb64 -const EVP_CIPHER *EVP_rc5_32_12_16_ofb(void); -# endif -const EVP_CIPHER *EVP_aes_128_ecb(void); -const EVP_CIPHER *EVP_aes_128_cbc(void); -const EVP_CIPHER *EVP_aes_128_cfb1(void); -const EVP_CIPHER *EVP_aes_128_cfb8(void); -const EVP_CIPHER *EVP_aes_128_cfb128(void); -# define EVP_aes_128_cfb EVP_aes_128_cfb128 -const EVP_CIPHER *EVP_aes_128_ofb(void); -const EVP_CIPHER *EVP_aes_128_ctr(void); -const EVP_CIPHER *EVP_aes_128_ccm(void); -const EVP_CIPHER *EVP_aes_128_gcm(void); -const EVP_CIPHER *EVP_aes_128_xts(void); -const EVP_CIPHER *EVP_aes_128_wrap(void); -const EVP_CIPHER *EVP_aes_128_wrap_pad(void); -# ifndef OPENSSL_NO_OCB -const EVP_CIPHER *EVP_aes_128_ocb(void); -# endif -const EVP_CIPHER *EVP_aes_192_ecb(void); -const EVP_CIPHER *EVP_aes_192_cbc(void); -const EVP_CIPHER *EVP_aes_192_cfb1(void); -const EVP_CIPHER *EVP_aes_192_cfb8(void); -const EVP_CIPHER *EVP_aes_192_cfb128(void); -# define EVP_aes_192_cfb EVP_aes_192_cfb128 -const EVP_CIPHER *EVP_aes_192_ofb(void); -const EVP_CIPHER *EVP_aes_192_ctr(void); -const EVP_CIPHER *EVP_aes_192_ccm(void); -const EVP_CIPHER *EVP_aes_192_gcm(void); -const EVP_CIPHER *EVP_aes_192_wrap(void); -const EVP_CIPHER *EVP_aes_192_wrap_pad(void); -# ifndef OPENSSL_NO_OCB -const EVP_CIPHER *EVP_aes_192_ocb(void); -# endif -const EVP_CIPHER *EVP_aes_256_ecb(void); -const EVP_CIPHER *EVP_aes_256_cbc(void); -const EVP_CIPHER *EVP_aes_256_cfb1(void); -const EVP_CIPHER *EVP_aes_256_cfb8(void); -const EVP_CIPHER *EVP_aes_256_cfb128(void); -# define EVP_aes_256_cfb EVP_aes_256_cfb128 -const EVP_CIPHER *EVP_aes_256_ofb(void); -const EVP_CIPHER *EVP_aes_256_ctr(void); -const EVP_CIPHER *EVP_aes_256_ccm(void); -const EVP_CIPHER *EVP_aes_256_gcm(void); -const EVP_CIPHER *EVP_aes_256_xts(void); -const EVP_CIPHER *EVP_aes_256_wrap(void); -const EVP_CIPHER *EVP_aes_256_wrap_pad(void); -# ifndef OPENSSL_NO_OCB -const EVP_CIPHER *EVP_aes_256_ocb(void); -# endif -const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha1(void); -const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha1(void); -const EVP_CIPHER *EVP_aes_128_cbc_hmac_sha256(void); -const EVP_CIPHER *EVP_aes_256_cbc_hmac_sha256(void); -# ifndef OPENSSL_NO_CAMELLIA -const EVP_CIPHER *EVP_camellia_128_ecb(void); -const EVP_CIPHER *EVP_camellia_128_cbc(void); -const EVP_CIPHER *EVP_camellia_128_cfb1(void); -const EVP_CIPHER *EVP_camellia_128_cfb8(void); -const EVP_CIPHER *EVP_camellia_128_cfb128(void); -# define EVP_camellia_128_cfb EVP_camellia_128_cfb128 -const EVP_CIPHER *EVP_camellia_128_ofb(void); -const EVP_CIPHER *EVP_camellia_128_ctr(void); -const EVP_CIPHER *EVP_camellia_192_ecb(void); -const EVP_CIPHER *EVP_camellia_192_cbc(void); -const EVP_CIPHER *EVP_camellia_192_cfb1(void); -const EVP_CIPHER *EVP_camellia_192_cfb8(void); -const EVP_CIPHER *EVP_camellia_192_cfb128(void); -# define EVP_camellia_192_cfb EVP_camellia_192_cfb128 -const EVP_CIPHER *EVP_camellia_192_ofb(void); -const EVP_CIPHER *EVP_camellia_192_ctr(void); -const EVP_CIPHER *EVP_camellia_256_ecb(void); -const EVP_CIPHER *EVP_camellia_256_cbc(void); -const EVP_CIPHER *EVP_camellia_256_cfb1(void); -const EVP_CIPHER *EVP_camellia_256_cfb8(void); -const EVP_CIPHER *EVP_camellia_256_cfb128(void); -# define EVP_camellia_256_cfb EVP_camellia_256_cfb128 -const EVP_CIPHER *EVP_camellia_256_ofb(void); -const EVP_CIPHER *EVP_camellia_256_ctr(void); -# endif -# ifndef OPENSSL_NO_CHACHA -const EVP_CIPHER *EVP_chacha20(void); -# ifndef OPENSSL_NO_POLY1305 -const EVP_CIPHER *EVP_chacha20_poly1305(void); -# endif -# endif - -# ifndef OPENSSL_NO_SEED -const EVP_CIPHER *EVP_seed_ecb(void); -const EVP_CIPHER *EVP_seed_cbc(void); -const EVP_CIPHER *EVP_seed_cfb128(void); -# define EVP_seed_cfb EVP_seed_cfb128 -const EVP_CIPHER *EVP_seed_ofb(void); -# endif - -# if OPENSSL_API_COMPAT < 0x10100000L -# define OPENSSL_add_all_algorithms_conf() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \ - | OPENSSL_INIT_ADD_ALL_DIGESTS \ - | OPENSSL_INIT_LOAD_CONFIG, NULL) -# define OPENSSL_add_all_algorithms_noconf() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \ - | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) - -# ifdef OPENSSL_LOAD_CONF -# define OpenSSL_add_all_algorithms() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \ - | OPENSSL_INIT_ADD_ALL_DIGESTS \ - | OPENSSL_INIT_LOAD_CONFIG, NULL) -# else -# define OpenSSL_add_all_algorithms() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS \ - | OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) -# endif - -# define OpenSSL_add_all_ciphers() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_CIPHERS, NULL) -# define OpenSSL_add_all_digests() \ - OPENSSL_init_crypto(OPENSSL_INIT_ADD_ALL_DIGESTS, NULL) - -# define EVP_cleanup() while(0) continue -# endif - -int EVP_add_cipher(const EVP_CIPHER *cipher); -int EVP_add_digest(const EVP_MD *digest); - -const EVP_CIPHER *EVP_get_cipherbyname(const char *name); -const EVP_MD *EVP_get_digestbyname(const char *name); - -void EVP_CIPHER_do_all(void (*fn) (const EVP_CIPHER *ciph, - const char *from, const char *to, void *x), - void *arg); -void EVP_CIPHER_do_all_sorted(void (*fn) - (const EVP_CIPHER *ciph, const char *from, - const char *to, void *x), void *arg); - -void EVP_MD_do_all(void (*fn) (const EVP_MD *ciph, - const char *from, const char *to, void *x), - void *arg); -void EVP_MD_do_all_sorted(void (*fn) - (const EVP_MD *ciph, const char *from, - const char *to, void *x), void *arg); - -int EVP_PKEY_decrypt_old(unsigned char *dec_key, - const unsigned char *enc_key, int enc_key_len, - EVP_PKEY *private_key); -int EVP_PKEY_encrypt_old(unsigned char *enc_key, - const unsigned char *key, int key_len, - EVP_PKEY *pub_key); -int EVP_PKEY_type(int type); -int EVP_PKEY_id(const EVP_PKEY *pkey); -int EVP_PKEY_base_id(const EVP_PKEY *pkey); -int EVP_PKEY_bits(const EVP_PKEY *pkey); -int EVP_PKEY_security_bits(const EVP_PKEY *pkey); -int EVP_PKEY_size(EVP_PKEY *pkey); -int EVP_PKEY_set_type(EVP_PKEY *pkey, int type); -int EVP_PKEY_set_type_str(EVP_PKEY *pkey, const char *str, int len); -int EVP_PKEY_assign(EVP_PKEY *pkey, int type, void *key); -void *EVP_PKEY_get0(const EVP_PKEY *pkey); -const unsigned char *EVP_PKEY_get0_hmac(const EVP_PKEY *pkey, size_t *len); - -# ifndef OPENSSL_NO_RSA -struct rsa_st; -int EVP_PKEY_set1_RSA(EVP_PKEY *pkey, struct rsa_st *key); -struct rsa_st *EVP_PKEY_get0_RSA(EVP_PKEY *pkey); -struct rsa_st *EVP_PKEY_get1_RSA(EVP_PKEY *pkey); -# endif -# ifndef OPENSSL_NO_DSA -struct dsa_st; -int EVP_PKEY_set1_DSA(EVP_PKEY *pkey, struct dsa_st *key); -struct dsa_st *EVP_PKEY_get0_DSA(EVP_PKEY *pkey); -struct dsa_st *EVP_PKEY_get1_DSA(EVP_PKEY *pkey); -# endif -# ifndef OPENSSL_NO_DH -struct dh_st; -int EVP_PKEY_set1_DH(EVP_PKEY *pkey, struct dh_st *key); -struct dh_st *EVP_PKEY_get0_DH(EVP_PKEY *pkey); -struct dh_st *EVP_PKEY_get1_DH(EVP_PKEY *pkey); -# endif -# ifndef OPENSSL_NO_EC -struct ec_key_st; -int EVP_PKEY_set1_EC_KEY(EVP_PKEY *pkey, struct ec_key_st *key); -struct ec_key_st *EVP_PKEY_get0_EC_KEY(EVP_PKEY *pkey); -struct ec_key_st *EVP_PKEY_get1_EC_KEY(EVP_PKEY *pkey); -# endif - -EVP_PKEY *EVP_PKEY_new(void); -int EVP_PKEY_up_ref(EVP_PKEY *pkey); -void EVP_PKEY_free(EVP_PKEY *pkey); - -EVP_PKEY *d2i_PublicKey(int type, EVP_PKEY **a, const unsigned char **pp, - long length); -int i2d_PublicKey(EVP_PKEY *a, unsigned char **pp); - -EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp, - long length); -EVP_PKEY *d2i_AutoPrivateKey(EVP_PKEY **a, const unsigned char **pp, - long length); -int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp); - -int EVP_PKEY_copy_parameters(EVP_PKEY *to, const EVP_PKEY *from); -int EVP_PKEY_missing_parameters(const EVP_PKEY *pkey); -int EVP_PKEY_save_parameters(EVP_PKEY *pkey, int mode); -int EVP_PKEY_cmp_parameters(const EVP_PKEY *a, const EVP_PKEY *b); - -int EVP_PKEY_cmp(const EVP_PKEY *a, const EVP_PKEY *b); - -int EVP_PKEY_print_public(BIO *out, const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx); -int EVP_PKEY_print_private(BIO *out, const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx); -int EVP_PKEY_print_params(BIO *out, const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx); - -int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid); - -int EVP_PKEY_set1_tls_encodedpoint(EVP_PKEY *pkey, - const unsigned char *pt, size_t ptlen); -size_t EVP_PKEY_get1_tls_encodedpoint(EVP_PKEY *pkey, unsigned char **ppt); - -int EVP_CIPHER_type(const EVP_CIPHER *ctx); - -/* calls methods */ -int EVP_CIPHER_param_to_asn1(EVP_CIPHER_CTX *c, ASN1_TYPE *type); -int EVP_CIPHER_asn1_to_param(EVP_CIPHER_CTX *c, ASN1_TYPE *type); - -/* These are used by EVP_CIPHER methods */ -int EVP_CIPHER_set_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); -int EVP_CIPHER_get_asn1_iv(EVP_CIPHER_CTX *c, ASN1_TYPE *type); - -/* PKCS5 password based encryption */ -int PKCS5_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *cipher, - const EVP_MD *md, int en_de); -int PKCS5_PBKDF2_HMAC_SHA1(const char *pass, int passlen, - const unsigned char *salt, int saltlen, int iter, - int keylen, unsigned char *out); -int PKCS5_PBKDF2_HMAC(const char *pass, int passlen, - const unsigned char *salt, int saltlen, int iter, - const EVP_MD *digest, int keylen, unsigned char *out); -int PKCS5_v2_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *cipher, - const EVP_MD *md, int en_de); - -#ifndef OPENSSL_NO_SCRYPT -int EVP_PBE_scrypt(const char *pass, size_t passlen, - const unsigned char *salt, size_t saltlen, - uint64_t N, uint64_t r, uint64_t p, uint64_t maxmem, - unsigned char *key, size_t keylen); - -int PKCS5_v2_scrypt_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, - int passlen, ASN1_TYPE *param, - const EVP_CIPHER *c, const EVP_MD *md, int en_de); -#endif - -void PKCS5_PBE_add(void); - -int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, - ASN1_TYPE *param, EVP_CIPHER_CTX *ctx, int en_de); - -/* PBE type */ - -/* Can appear as the outermost AlgorithmIdentifier */ -# define EVP_PBE_TYPE_OUTER 0x0 -/* Is an PRF type OID */ -# define EVP_PBE_TYPE_PRF 0x1 -/* Is a PKCS#5 v2.0 KDF */ -# define EVP_PBE_TYPE_KDF 0x2 - -int EVP_PBE_alg_add_type(int pbe_type, int pbe_nid, int cipher_nid, - int md_nid, EVP_PBE_KEYGEN *keygen); -int EVP_PBE_alg_add(int nid, const EVP_CIPHER *cipher, const EVP_MD *md, - EVP_PBE_KEYGEN *keygen); -int EVP_PBE_find(int type, int pbe_nid, int *pcnid, int *pmnid, - EVP_PBE_KEYGEN **pkeygen); -void EVP_PBE_cleanup(void); -int EVP_PBE_get(int *ptype, int *ppbe_nid, size_t num); - -# define ASN1_PKEY_ALIAS 0x1 -# define ASN1_PKEY_DYNAMIC 0x2 -# define ASN1_PKEY_SIGPARAM_NULL 0x4 - -# define ASN1_PKEY_CTRL_PKCS7_SIGN 0x1 -# define ASN1_PKEY_CTRL_PKCS7_ENCRYPT 0x2 -# define ASN1_PKEY_CTRL_DEFAULT_MD_NID 0x3 -# define ASN1_PKEY_CTRL_CMS_SIGN 0x5 -# define ASN1_PKEY_CTRL_CMS_ENVELOPE 0x7 -# define ASN1_PKEY_CTRL_CMS_RI_TYPE 0x8 - -# define ASN1_PKEY_CTRL_SET1_TLS_ENCPT 0x9 -# define ASN1_PKEY_CTRL_GET1_TLS_ENCPT 0xa - -int EVP_PKEY_asn1_get_count(void); -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_get0(int idx); -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find(ENGINE **pe, int type); -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_find_str(ENGINE **pe, - const char *str, int len); -int EVP_PKEY_asn1_add0(const EVP_PKEY_ASN1_METHOD *ameth); -int EVP_PKEY_asn1_add_alias(int to, int from); -int EVP_PKEY_asn1_get0_info(int *ppkey_id, int *pkey_base_id, - int *ppkey_flags, const char **pinfo, - const char **ppem_str, - const EVP_PKEY_ASN1_METHOD *ameth); - -const EVP_PKEY_ASN1_METHOD *EVP_PKEY_get0_asn1(const EVP_PKEY *pkey); -EVP_PKEY_ASN1_METHOD *EVP_PKEY_asn1_new(int id, int flags, - const char *pem_str, - const char *info); -void EVP_PKEY_asn1_copy(EVP_PKEY_ASN1_METHOD *dst, - const EVP_PKEY_ASN1_METHOD *src); -void EVP_PKEY_asn1_free(EVP_PKEY_ASN1_METHOD *ameth); -void EVP_PKEY_asn1_set_public(EVP_PKEY_ASN1_METHOD *ameth, - int (*pub_decode) (EVP_PKEY *pk, - X509_PUBKEY *pub), - int (*pub_encode) (X509_PUBKEY *pub, - const EVP_PKEY *pk), - int (*pub_cmp) (const EVP_PKEY *a, - const EVP_PKEY *b), - int (*pub_print) (BIO *out, - const EVP_PKEY *pkey, - int indent, ASN1_PCTX *pctx), - int (*pkey_size) (const EVP_PKEY *pk), - int (*pkey_bits) (const EVP_PKEY *pk)); -void EVP_PKEY_asn1_set_private(EVP_PKEY_ASN1_METHOD *ameth, - int (*priv_decode) (EVP_PKEY *pk, - const PKCS8_PRIV_KEY_INFO - *p8inf), - int (*priv_encode) (PKCS8_PRIV_KEY_INFO *p8, - const EVP_PKEY *pk), - int (*priv_print) (BIO *out, - const EVP_PKEY *pkey, - int indent, - ASN1_PCTX *pctx)); -void EVP_PKEY_asn1_set_param(EVP_PKEY_ASN1_METHOD *ameth, - int (*param_decode) (EVP_PKEY *pkey, - const unsigned char **pder, - int derlen), - int (*param_encode) (const EVP_PKEY *pkey, - unsigned char **pder), - int (*param_missing) (const EVP_PKEY *pk), - int (*param_copy) (EVP_PKEY *to, - const EVP_PKEY *from), - int (*param_cmp) (const EVP_PKEY *a, - const EVP_PKEY *b), - int (*param_print) (BIO *out, - const EVP_PKEY *pkey, - int indent, - ASN1_PCTX *pctx)); - -void EVP_PKEY_asn1_set_free(EVP_PKEY_ASN1_METHOD *ameth, - void (*pkey_free) (EVP_PKEY *pkey)); -void EVP_PKEY_asn1_set_ctrl(EVP_PKEY_ASN1_METHOD *ameth, - int (*pkey_ctrl) (EVP_PKEY *pkey, int op, - long arg1, void *arg2)); -void EVP_PKEY_asn1_set_item(EVP_PKEY_ASN1_METHOD *ameth, - int (*item_verify) (EVP_MD_CTX *ctx, - const ASN1_ITEM *it, - void *asn, - X509_ALGOR *a, - ASN1_BIT_STRING *sig, - EVP_PKEY *pkey), - int (*item_sign) (EVP_MD_CTX *ctx, - const ASN1_ITEM *it, - void *asn, - X509_ALGOR *alg1, - X509_ALGOR *alg2, - ASN1_BIT_STRING *sig)); - -void EVP_PKEY_asn1_set_security_bits(EVP_PKEY_ASN1_METHOD *ameth, - int (*pkey_security_bits) (const EVP_PKEY - *pk)); - -# define EVP_PKEY_OP_UNDEFINED 0 -# define EVP_PKEY_OP_PARAMGEN (1<<1) -# define EVP_PKEY_OP_KEYGEN (1<<2) -# define EVP_PKEY_OP_SIGN (1<<3) -# define EVP_PKEY_OP_VERIFY (1<<4) -# define EVP_PKEY_OP_VERIFYRECOVER (1<<5) -# define EVP_PKEY_OP_SIGNCTX (1<<6) -# define EVP_PKEY_OP_VERIFYCTX (1<<7) -# define EVP_PKEY_OP_ENCRYPT (1<<8) -# define EVP_PKEY_OP_DECRYPT (1<<9) -# define EVP_PKEY_OP_DERIVE (1<<10) - -# define EVP_PKEY_OP_TYPE_SIG \ - (EVP_PKEY_OP_SIGN | EVP_PKEY_OP_VERIFY | EVP_PKEY_OP_VERIFYRECOVER \ - | EVP_PKEY_OP_SIGNCTX | EVP_PKEY_OP_VERIFYCTX) - -# define EVP_PKEY_OP_TYPE_CRYPT \ - (EVP_PKEY_OP_ENCRYPT | EVP_PKEY_OP_DECRYPT) - -# define EVP_PKEY_OP_TYPE_NOGEN \ - (EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT | EVP_PKEY_OP_DERIVE) - -# define EVP_PKEY_OP_TYPE_GEN \ - (EVP_PKEY_OP_PARAMGEN | EVP_PKEY_OP_KEYGEN) - -# define EVP_PKEY_CTX_set_signature_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \ - EVP_PKEY_CTRL_MD, 0, (void *)md) - -# define EVP_PKEY_CTX_get_signature_md(ctx, pmd) \ - EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_TYPE_SIG, \ - EVP_PKEY_CTRL_GET_MD, 0, (void *)pmd) - -# define EVP_PKEY_CTX_set_mac_key(ctx, key, len) \ - EVP_PKEY_CTX_ctrl(ctx, -1, EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_SET_MAC_KEY, len, (void *)key) - -# define EVP_PKEY_CTRL_MD 1 -# define EVP_PKEY_CTRL_PEER_KEY 2 - -# define EVP_PKEY_CTRL_PKCS7_ENCRYPT 3 -# define EVP_PKEY_CTRL_PKCS7_DECRYPT 4 - -# define EVP_PKEY_CTRL_PKCS7_SIGN 5 - -# define EVP_PKEY_CTRL_SET_MAC_KEY 6 - -# define EVP_PKEY_CTRL_DIGESTINIT 7 - -/* Used by GOST key encryption in TLS */ -# define EVP_PKEY_CTRL_SET_IV 8 - -# define EVP_PKEY_CTRL_CMS_ENCRYPT 9 -# define EVP_PKEY_CTRL_CMS_DECRYPT 10 -# define EVP_PKEY_CTRL_CMS_SIGN 11 - -# define EVP_PKEY_CTRL_CIPHER 12 - -# define EVP_PKEY_CTRL_GET_MD 13 - -# define EVP_PKEY_ALG_CTRL 0x1000 - -# define EVP_PKEY_FLAG_AUTOARGLEN 2 -/* - * Method handles all operations: don't assume any digest related defaults. - */ -# define EVP_PKEY_FLAG_SIGCTX_CUSTOM 4 - -const EVP_PKEY_METHOD *EVP_PKEY_meth_find(int type); -EVP_PKEY_METHOD *EVP_PKEY_meth_new(int id, int flags); -void EVP_PKEY_meth_get0_info(int *ppkey_id, int *pflags, - const EVP_PKEY_METHOD *meth); -void EVP_PKEY_meth_copy(EVP_PKEY_METHOD *dst, const EVP_PKEY_METHOD *src); -void EVP_PKEY_meth_free(EVP_PKEY_METHOD *pmeth); -int EVP_PKEY_meth_add0(const EVP_PKEY_METHOD *pmeth); - -EVP_PKEY_CTX *EVP_PKEY_CTX_new(EVP_PKEY *pkey, ENGINE *e); -EVP_PKEY_CTX *EVP_PKEY_CTX_new_id(int id, ENGINE *e); -EVP_PKEY_CTX *EVP_PKEY_CTX_dup(EVP_PKEY_CTX *ctx); -void EVP_PKEY_CTX_free(EVP_PKEY_CTX *ctx); - -int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, - int cmd, int p1, void *p2); -int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, - const char *value); - -int EVP_PKEY_CTX_str2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *str); -int EVP_PKEY_CTX_hex2ctrl(EVP_PKEY_CTX *ctx, int cmd, const char *hex); - -int EVP_PKEY_CTX_get_operation(EVP_PKEY_CTX *ctx); -void EVP_PKEY_CTX_set0_keygen_info(EVP_PKEY_CTX *ctx, int *dat, int datlen); - -EVP_PKEY *EVP_PKEY_new_mac_key(int type, ENGINE *e, - const unsigned char *key, int keylen); - -void EVP_PKEY_CTX_set_data(EVP_PKEY_CTX *ctx, void *data); -void *EVP_PKEY_CTX_get_data(EVP_PKEY_CTX *ctx); -EVP_PKEY *EVP_PKEY_CTX_get0_pkey(EVP_PKEY_CTX *ctx); - -EVP_PKEY *EVP_PKEY_CTX_get0_peerkey(EVP_PKEY_CTX *ctx); - -void EVP_PKEY_CTX_set_app_data(EVP_PKEY_CTX *ctx, void *data); -void *EVP_PKEY_CTX_get_app_data(EVP_PKEY_CTX *ctx); - -int EVP_PKEY_sign_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_sign(EVP_PKEY_CTX *ctx, - unsigned char *sig, size_t *siglen, - const unsigned char *tbs, size_t tbslen); -int EVP_PKEY_verify_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_verify(EVP_PKEY_CTX *ctx, - const unsigned char *sig, size_t siglen, - const unsigned char *tbs, size_t tbslen); -int EVP_PKEY_verify_recover_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_verify_recover(EVP_PKEY_CTX *ctx, - unsigned char *rout, size_t *routlen, - const unsigned char *sig, size_t siglen); -int EVP_PKEY_encrypt_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_encrypt(EVP_PKEY_CTX *ctx, - unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen); -int EVP_PKEY_decrypt_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_decrypt(EVP_PKEY_CTX *ctx, - unsigned char *out, size_t *outlen, - const unsigned char *in, size_t inlen); - -int EVP_PKEY_derive_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_derive_set_peer(EVP_PKEY_CTX *ctx, EVP_PKEY *peer); -int EVP_PKEY_derive(EVP_PKEY_CTX *ctx, unsigned char *key, size_t *keylen); - -typedef int EVP_PKEY_gen_cb(EVP_PKEY_CTX *ctx); - -int EVP_PKEY_paramgen_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_paramgen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); -int EVP_PKEY_keygen_init(EVP_PKEY_CTX *ctx); -int EVP_PKEY_keygen(EVP_PKEY_CTX *ctx, EVP_PKEY **ppkey); - -void EVP_PKEY_CTX_set_cb(EVP_PKEY_CTX *ctx, EVP_PKEY_gen_cb *cb); -EVP_PKEY_gen_cb *EVP_PKEY_CTX_get_cb(EVP_PKEY_CTX *ctx); - -int EVP_PKEY_CTX_get_keygen_info(EVP_PKEY_CTX *ctx, int idx); - -void EVP_PKEY_meth_set_init(EVP_PKEY_METHOD *pmeth, - int (*init) (EVP_PKEY_CTX *ctx)); - -void EVP_PKEY_meth_set_copy(EVP_PKEY_METHOD *pmeth, - int (*copy) (EVP_PKEY_CTX *dst, - EVP_PKEY_CTX *src)); - -void EVP_PKEY_meth_set_cleanup(EVP_PKEY_METHOD *pmeth, - void (*cleanup) (EVP_PKEY_CTX *ctx)); - -void EVP_PKEY_meth_set_paramgen(EVP_PKEY_METHOD *pmeth, - int (*paramgen_init) (EVP_PKEY_CTX *ctx), - int (*paramgen) (EVP_PKEY_CTX *ctx, - EVP_PKEY *pkey)); - -void EVP_PKEY_meth_set_keygen(EVP_PKEY_METHOD *pmeth, - int (*keygen_init) (EVP_PKEY_CTX *ctx), - int (*keygen) (EVP_PKEY_CTX *ctx, - EVP_PKEY *pkey)); - -void EVP_PKEY_meth_set_sign(EVP_PKEY_METHOD *pmeth, - int (*sign_init) (EVP_PKEY_CTX *ctx), - int (*sign) (EVP_PKEY_CTX *ctx, - unsigned char *sig, size_t *siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_set_verify(EVP_PKEY_METHOD *pmeth, - int (*verify_init) (EVP_PKEY_CTX *ctx), - int (*verify) (EVP_PKEY_CTX *ctx, - const unsigned char *sig, - size_t siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_set_verify_recover(EVP_PKEY_METHOD *pmeth, - int (*verify_recover_init) (EVP_PKEY_CTX - *ctx), - int (*verify_recover) (EVP_PKEY_CTX - *ctx, - unsigned char - *sig, - size_t *siglen, - const unsigned - char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_set_signctx(EVP_PKEY_METHOD *pmeth, - int (*signctx_init) (EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx), - int (*signctx) (EVP_PKEY_CTX *ctx, - unsigned char *sig, - size_t *siglen, - EVP_MD_CTX *mctx)); - -void EVP_PKEY_meth_set_verifyctx(EVP_PKEY_METHOD *pmeth, - int (*verifyctx_init) (EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx), - int (*verifyctx) (EVP_PKEY_CTX *ctx, - const unsigned char *sig, - int siglen, - EVP_MD_CTX *mctx)); - -void EVP_PKEY_meth_set_encrypt(EVP_PKEY_METHOD *pmeth, - int (*encrypt_init) (EVP_PKEY_CTX *ctx), - int (*encryptfn) (EVP_PKEY_CTX *ctx, - unsigned char *out, - size_t *outlen, - const unsigned char *in, - size_t inlen)); - -void EVP_PKEY_meth_set_decrypt(EVP_PKEY_METHOD *pmeth, - int (*decrypt_init) (EVP_PKEY_CTX *ctx), - int (*decrypt) (EVP_PKEY_CTX *ctx, - unsigned char *out, - size_t *outlen, - const unsigned char *in, - size_t inlen)); - -void EVP_PKEY_meth_set_derive(EVP_PKEY_METHOD *pmeth, - int (*derive_init) (EVP_PKEY_CTX *ctx), - int (*derive) (EVP_PKEY_CTX *ctx, - unsigned char *key, - size_t *keylen)); - -void EVP_PKEY_meth_set_ctrl(EVP_PKEY_METHOD *pmeth, - int (*ctrl) (EVP_PKEY_CTX *ctx, int type, int p1, - void *p2), - int (*ctrl_str) (EVP_PKEY_CTX *ctx, - const char *type, - const char *value)); - -void EVP_PKEY_meth_get_init(EVP_PKEY_METHOD *pmeth, - int (**pinit) (EVP_PKEY_CTX *ctx)); - -void EVP_PKEY_meth_get_copy(EVP_PKEY_METHOD *pmeth, - int (**pcopy) (EVP_PKEY_CTX *dst, - EVP_PKEY_CTX *src)); - -void EVP_PKEY_meth_get_cleanup(EVP_PKEY_METHOD *pmeth, - void (**pcleanup) (EVP_PKEY_CTX *ctx)); - -void EVP_PKEY_meth_get_paramgen(EVP_PKEY_METHOD *pmeth, - int (**pparamgen_init) (EVP_PKEY_CTX *ctx), - int (**pparamgen) (EVP_PKEY_CTX *ctx, - EVP_PKEY *pkey)); - -void EVP_PKEY_meth_get_keygen(EVP_PKEY_METHOD *pmeth, - int (**pkeygen_init) (EVP_PKEY_CTX *ctx), - int (**pkeygen) (EVP_PKEY_CTX *ctx, - EVP_PKEY *pkey)); - -void EVP_PKEY_meth_get_sign(EVP_PKEY_METHOD *pmeth, - int (**psign_init) (EVP_PKEY_CTX *ctx), - int (**psign) (EVP_PKEY_CTX *ctx, - unsigned char *sig, size_t *siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_get_verify(EVP_PKEY_METHOD *pmeth, - int (**pverify_init) (EVP_PKEY_CTX *ctx), - int (**pverify) (EVP_PKEY_CTX *ctx, - const unsigned char *sig, - size_t siglen, - const unsigned char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_get_verify_recover(EVP_PKEY_METHOD *pmeth, - int (**pverify_recover_init) (EVP_PKEY_CTX - *ctx), - int (**pverify_recover) (EVP_PKEY_CTX - *ctx, - unsigned char - *sig, - size_t *siglen, - const unsigned - char *tbs, - size_t tbslen)); - -void EVP_PKEY_meth_get_signctx(EVP_PKEY_METHOD *pmeth, - int (**psignctx_init) (EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx), - int (**psignctx) (EVP_PKEY_CTX *ctx, - unsigned char *sig, - size_t *siglen, - EVP_MD_CTX *mctx)); - -void EVP_PKEY_meth_get_verifyctx(EVP_PKEY_METHOD *pmeth, - int (**pverifyctx_init) (EVP_PKEY_CTX *ctx, - EVP_MD_CTX *mctx), - int (**pverifyctx) (EVP_PKEY_CTX *ctx, - const unsigned char *sig, - int siglen, - EVP_MD_CTX *mctx)); - -void EVP_PKEY_meth_get_encrypt(EVP_PKEY_METHOD *pmeth, - int (**pencrypt_init) (EVP_PKEY_CTX *ctx), - int (**pencryptfn) (EVP_PKEY_CTX *ctx, - unsigned char *out, - size_t *outlen, - const unsigned char *in, - size_t inlen)); - -void EVP_PKEY_meth_get_decrypt(EVP_PKEY_METHOD *pmeth, - int (**pdecrypt_init) (EVP_PKEY_CTX *ctx), - int (**pdecrypt) (EVP_PKEY_CTX *ctx, - unsigned char *out, - size_t *outlen, - const unsigned char *in, - size_t inlen)); - -void EVP_PKEY_meth_get_derive(EVP_PKEY_METHOD *pmeth, - int (**pderive_init) (EVP_PKEY_CTX *ctx), - int (**pderive) (EVP_PKEY_CTX *ctx, - unsigned char *key, - size_t *keylen)); - -void EVP_PKEY_meth_get_ctrl(EVP_PKEY_METHOD *pmeth, - int (**pctrl) (EVP_PKEY_CTX *ctx, int type, int p1, - void *p2), - int (**pctrl_str) (EVP_PKEY_CTX *ctx, - const char *type, - const char *value)); - -void EVP_add_alg_module(void); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_EVP_strings(void); - -/* Error codes for the EVP functions. */ - -/* Function codes. */ -# define EVP_F_AESNI_INIT_KEY 165 -# define EVP_F_AES_INIT_KEY 133 -# define EVP_F_AES_T4_INIT_KEY 178 -# define EVP_F_ALG_MODULE_INIT 177 -# define EVP_F_CAMELLIA_INIT_KEY 159 -# define EVP_F_CHACHA20_POLY1305_CTRL 182 -# define EVP_F_CMLL_T4_INIT_KEY 179 -# define EVP_F_DO_SIGVER_INIT 161 -# define EVP_F_EVP_CIPHERINIT_EX 123 -# define EVP_F_EVP_CIPHER_CTX_COPY 163 -# define EVP_F_EVP_CIPHER_CTX_CTRL 124 -# define EVP_F_EVP_CIPHER_CTX_SET_KEY_LENGTH 122 -# define EVP_F_EVP_DECRYPTFINAL_EX 101 -# define EVP_F_EVP_DECRYPTUPDATE 166 -# define EVP_F_EVP_DIGESTINIT_EX 128 -# define EVP_F_EVP_ENCRYPTFINAL_EX 127 -# define EVP_F_EVP_ENCRYPTUPDATE 167 -# define EVP_F_EVP_MD_CTX_COPY_EX 110 -# define EVP_F_EVP_MD_SIZE 162 -# define EVP_F_EVP_OPENINIT 102 -# define EVP_F_EVP_PBE_ALG_ADD 115 -# define EVP_F_EVP_PBE_ALG_ADD_TYPE 160 -# define EVP_F_EVP_PBE_CIPHERINIT 116 -# define EVP_F_EVP_PBE_SCRYPT 181 -# define EVP_F_EVP_PKCS82PKEY 111 -# define EVP_F_EVP_PKEY2PKCS8 113 -# define EVP_F_EVP_PKEY_COPY_PARAMETERS 103 -# define EVP_F_EVP_PKEY_CTX_CTRL 137 -# define EVP_F_EVP_PKEY_CTX_CTRL_STR 150 -# define EVP_F_EVP_PKEY_CTX_DUP 156 -# define EVP_F_EVP_PKEY_DECRYPT 104 -# define EVP_F_EVP_PKEY_DECRYPT_INIT 138 -# define EVP_F_EVP_PKEY_DECRYPT_OLD 151 -# define EVP_F_EVP_PKEY_DERIVE 153 -# define EVP_F_EVP_PKEY_DERIVE_INIT 154 -# define EVP_F_EVP_PKEY_DERIVE_SET_PEER 155 -# define EVP_F_EVP_PKEY_ENCRYPT 105 -# define EVP_F_EVP_PKEY_ENCRYPT_INIT 139 -# define EVP_F_EVP_PKEY_ENCRYPT_OLD 152 -# define EVP_F_EVP_PKEY_GET0_DH 119 -# define EVP_F_EVP_PKEY_GET0_DSA 120 -# define EVP_F_EVP_PKEY_GET0_EC_KEY 131 -# define EVP_F_EVP_PKEY_GET0_HMAC 183 -# define EVP_F_EVP_PKEY_GET0_RSA 121 -# define EVP_F_EVP_PKEY_KEYGEN 146 -# define EVP_F_EVP_PKEY_KEYGEN_INIT 147 -# define EVP_F_EVP_PKEY_NEW 106 -# define EVP_F_EVP_PKEY_PARAMGEN 148 -# define EVP_F_EVP_PKEY_PARAMGEN_INIT 149 -# define EVP_F_EVP_PKEY_SIGN 140 -# define EVP_F_EVP_PKEY_SIGN_INIT 141 -# define EVP_F_EVP_PKEY_VERIFY 142 -# define EVP_F_EVP_PKEY_VERIFY_INIT 143 -# define EVP_F_EVP_PKEY_VERIFY_RECOVER 144 -# define EVP_F_EVP_PKEY_VERIFY_RECOVER_INIT 145 -# define EVP_F_EVP_SIGNFINAL 107 -# define EVP_F_EVP_VERIFYFINAL 108 -# define EVP_F_INT_CTX_NEW 157 -# define EVP_F_PKCS5_PBE_KEYIVGEN 117 -# define EVP_F_PKCS5_V2_PBE_KEYIVGEN 118 -# define EVP_F_PKCS5_V2_PBKDF2_KEYIVGEN 164 -# define EVP_F_PKCS5_V2_SCRYPT_KEYIVGEN 180 -# define EVP_F_PKEY_SET_TYPE 158 -# define EVP_F_RC2_MAGIC_TO_METH 109 -# define EVP_F_RC5_CTRL 125 - -/* Reason codes. */ -# define EVP_R_AES_KEY_SETUP_FAILED 143 -# define EVP_R_BAD_DECRYPT 100 -# define EVP_R_BUFFER_TOO_SMALL 155 -# define EVP_R_CAMELLIA_KEY_SETUP_FAILED 157 -# define EVP_R_CIPHER_PARAMETER_ERROR 122 -# define EVP_R_COMMAND_NOT_SUPPORTED 147 -# define EVP_R_COPY_ERROR 173 -# define EVP_R_CTRL_NOT_IMPLEMENTED 132 -# define EVP_R_CTRL_OPERATION_NOT_IMPLEMENTED 133 -# define EVP_R_DATA_NOT_MULTIPLE_OF_BLOCK_LENGTH 138 -# define EVP_R_DECODE_ERROR 114 -# define EVP_R_DIFFERENT_KEY_TYPES 101 -# define EVP_R_DIFFERENT_PARAMETERS 153 -# define EVP_R_ERROR_LOADING_SECTION 165 -# define EVP_R_ERROR_SETTING_FIPS_MODE 166 -# define EVP_R_EXPECTING_AN_HMAC_KEY 174 -# define EVP_R_EXPECTING_AN_RSA_KEY 127 -# define EVP_R_EXPECTING_A_DH_KEY 128 -# define EVP_R_EXPECTING_A_DSA_KEY 129 -# define EVP_R_EXPECTING_A_EC_KEY 142 -# define EVP_R_FIPS_MODE_NOT_SUPPORTED 167 -# define EVP_R_ILLEGAL_SCRYPT_PARAMETERS 171 -# define EVP_R_INITIALIZATION_ERROR 134 -# define EVP_R_INPUT_NOT_INITIALIZED 111 -# define EVP_R_INVALID_DIGEST 152 -# define EVP_R_INVALID_FIPS_MODE 168 -# define EVP_R_INVALID_KEY_LENGTH 130 -# define EVP_R_INVALID_OPERATION 148 -# define EVP_R_KEYGEN_FAILURE 120 -# define EVP_R_MEMORY_LIMIT_EXCEEDED 172 -# define EVP_R_MESSAGE_DIGEST_IS_NULL 159 -# define EVP_R_METHOD_NOT_SUPPORTED 144 -# define EVP_R_MISSING_PARAMETERS 103 -# define EVP_R_NO_CIPHER_SET 131 -# define EVP_R_NO_DEFAULT_DIGEST 158 -# define EVP_R_NO_DIGEST_SET 139 -# define EVP_R_NO_KEY_SET 154 -# define EVP_R_NO_OPERATION_SET 149 -# define EVP_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 150 -# define EVP_R_OPERATON_NOT_INITIALIZED 151 -# define EVP_R_PARTIALLY_OVERLAPPING 162 -# define EVP_R_PRIVATE_KEY_DECODE_ERROR 145 -# define EVP_R_PRIVATE_KEY_ENCODE_ERROR 146 -# define EVP_R_PUBLIC_KEY_NOT_RSA 106 -# define EVP_R_UNKNOWN_CIPHER 160 -# define EVP_R_UNKNOWN_DIGEST 161 -# define EVP_R_UNKNOWN_OPTION 169 -# define EVP_R_UNKNOWN_PBE_ALGORITHM 121 -# define EVP_R_UNSUPPORTED_NUMBER_OF_ROUNDS 135 -# define EVP_R_UNSUPPORTED_ALGORITHM 156 -# define EVP_R_UNSUPPORTED_CIPHER 107 -# define EVP_R_UNSUPPORTED_KEYLENGTH 123 -# define EVP_R_UNSUPPORTED_KEY_DERIVATION_FUNCTION 124 -# define EVP_R_UNSUPPORTED_KEY_SIZE 108 -# define EVP_R_UNSUPPORTED_PRF 125 -# define EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM 118 -# define EVP_R_UNSUPPORTED_SALT_TYPE 126 -# define EVP_R_WRAP_MODE_NOT_ALLOWED 170 -# define EVP_R_WRONG_FINAL_BLOCK_LENGTH 109 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/hmac.h b/android/armeabi/include/openssl/hmac.h deleted file mode 100644 index 9f068960..00000000 --- a/android/armeabi/include/openssl/hmac.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_HMAC_H -# define HEADER_HMAC_H - -# include <openssl/opensslconf.h> - -# include <openssl/evp.h> - -# define HMAC_MAX_MD_CBLOCK 128/* largest known is SHA512 */ - -#ifdef __cplusplus -extern "C" { -#endif - -size_t HMAC_size(const HMAC_CTX *e); -HMAC_CTX *HMAC_CTX_new(void); -int HMAC_CTX_reset(HMAC_CTX *ctx); -void HMAC_CTX_free(HMAC_CTX *ctx); - -DEPRECATEDIN_1_1_0(__owur int HMAC_Init(HMAC_CTX *ctx, const void *key, int len, - const EVP_MD *md)) - -/*__owur*/ int HMAC_Init_ex(HMAC_CTX *ctx, const void *key, int len, - const EVP_MD *md, ENGINE *impl); -/*__owur*/ int HMAC_Update(HMAC_CTX *ctx, const unsigned char *data, - size_t len); -/*__owur*/ int HMAC_Final(HMAC_CTX *ctx, unsigned char *md, - unsigned int *len); -unsigned char *HMAC(const EVP_MD *evp_md, const void *key, int key_len, - const unsigned char *d, size_t n, unsigned char *md, - unsigned int *md_len); -__owur int HMAC_CTX_copy(HMAC_CTX *dctx, HMAC_CTX *sctx); - -void HMAC_CTX_set_flags(HMAC_CTX *ctx, unsigned long flags); -const EVP_MD *HMAC_CTX_get_md(const HMAC_CTX *ctx); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android/armeabi/include/openssl/idea.h b/android/armeabi/include/openssl/idea.h deleted file mode 100644 index 4334f3ea..00000000 --- a/android/armeabi/include/openssl/idea.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_IDEA_H -# define HEADER_IDEA_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_IDEA -# ifdef __cplusplus -extern "C" { -# endif - -typedef unsigned int IDEA_INT; - -# define IDEA_ENCRYPT 1 -# define IDEA_DECRYPT 0 - -# define IDEA_BLOCK 8 -# define IDEA_KEY_LENGTH 16 - -typedef struct idea_key_st { - IDEA_INT data[9][6]; -} IDEA_KEY_SCHEDULE; - -const char *IDEA_options(void); -void IDEA_ecb_encrypt(const unsigned char *in, unsigned char *out, - IDEA_KEY_SCHEDULE *ks); -void IDEA_set_encrypt_key(const unsigned char *key, IDEA_KEY_SCHEDULE *ks); -void IDEA_set_decrypt_key(IDEA_KEY_SCHEDULE *ek, IDEA_KEY_SCHEDULE *dk); -void IDEA_cbc_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, - int enc); -void IDEA_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, - int *num, int enc); -void IDEA_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, IDEA_KEY_SCHEDULE *ks, unsigned char *iv, - int *num); -void IDEA_encrypt(unsigned long *in, IDEA_KEY_SCHEDULE *ks); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define idea_options IDEA_options -# define idea_ecb_encrypt IDEA_ecb_encrypt -# define idea_set_encrypt_key IDEA_set_encrypt_key -# define idea_set_decrypt_key IDEA_set_decrypt_key -# define idea_cbc_encrypt IDEA_cbc_encrypt -# define idea_cfb64_encrypt IDEA_cfb64_encrypt -# define idea_ofb64_encrypt IDEA_ofb64_encrypt -# define idea_encrypt IDEA_encrypt -# endif - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/kdf.h b/android/armeabi/include/openssl/kdf.h deleted file mode 100644 index 9f87f788..00000000 --- a/android/armeabi/include/openssl/kdf.h +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_KDF_H -# define HEADER_KDF_H - -#ifdef __cplusplus -extern "C" { -#endif - -# define EVP_PKEY_CTRL_TLS_MD (EVP_PKEY_ALG_CTRL) -# define EVP_PKEY_CTRL_TLS_SECRET (EVP_PKEY_ALG_CTRL + 1) -# define EVP_PKEY_CTRL_TLS_SEED (EVP_PKEY_ALG_CTRL + 2) -# define EVP_PKEY_CTRL_HKDF_MD (EVP_PKEY_ALG_CTRL + 3) -# define EVP_PKEY_CTRL_HKDF_SALT (EVP_PKEY_ALG_CTRL + 4) -# define EVP_PKEY_CTRL_HKDF_KEY (EVP_PKEY_ALG_CTRL + 5) -# define EVP_PKEY_CTRL_HKDF_INFO (EVP_PKEY_ALG_CTRL + 6) - -# define EVP_PKEY_CTX_set_tls1_prf_md(pctx, md) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_TLS_MD, 0, (void *)md) - -# define EVP_PKEY_CTX_set1_tls1_prf_secret(pctx, sec, seclen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_TLS_SECRET, seclen, (void *)sec) - -# define EVP_PKEY_CTX_add1_tls1_prf_seed(pctx, seed, seedlen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_TLS_SEED, seedlen, (void *)seed) - -# define EVP_PKEY_CTX_set_hkdf_md(pctx, md) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_HKDF_MD, 0, (void *)md) - -# define EVP_PKEY_CTX_set1_hkdf_salt(pctx, salt, saltlen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_HKDF_SALT, saltlen, (void *)salt) - -# define EVP_PKEY_CTX_set1_hkdf_key(pctx, key, keylen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_HKDF_KEY, keylen, (void *)key) - -# define EVP_PKEY_CTX_add1_hkdf_info(pctx, info, infolen) \ - EVP_PKEY_CTX_ctrl(pctx, -1, EVP_PKEY_OP_DERIVE, \ - EVP_PKEY_CTRL_HKDF_INFO, infolen, (void *)info) - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_KDF_strings(void); - -/* Error codes for the KDF functions. */ - -/* Function codes. */ -# define KDF_F_PKEY_TLS1_PRF_CTRL_STR 100 -# define KDF_F_PKEY_TLS1_PRF_DERIVE 101 - -/* Reason codes. */ -# define KDF_R_INVALID_DIGEST 100 -# define KDF_R_MISSING_PARAMETER 101 -# define KDF_R_VALUE_MISSING 102 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/lhash.h b/android/armeabi/include/openssl/lhash.h deleted file mode 100644 index e2ccb65d..00000000 --- a/android/armeabi/include/openssl/lhash.h +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * Header for dynamic hash table routines Author - Eric Young - */ - -#ifndef HEADER_LHASH_H -# define HEADER_LHASH_H - -# include <openssl/e_os2.h> -# include <openssl/bio.h> - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct lhash_node_st OPENSSL_LH_NODE; -typedef int (*OPENSSL_LH_COMPFUNC) (const void *, const void *); -typedef unsigned long (*OPENSSL_LH_HASHFUNC) (const void *); -typedef void (*OPENSSL_LH_DOALL_FUNC) (void *); -typedef void (*OPENSSL_LH_DOALL_FUNCARG) (void *, void *); -typedef struct lhash_st OPENSSL_LHASH; - -/* - * Macros for declaring and implementing type-safe wrappers for LHASH - * callbacks. This way, callbacks can be provided to LHASH structures without - * function pointer casting and the macro-defined callbacks provide - * per-variable casting before deferring to the underlying type-specific - * callbacks. NB: It is possible to place a "static" in front of both the - * DECLARE and IMPLEMENT macros if the functions are strictly internal. - */ - -/* First: "hash" functions */ -# define DECLARE_LHASH_HASH_FN(name, o_type) \ - unsigned long name##_LHASH_HASH(const void *); -# define IMPLEMENT_LHASH_HASH_FN(name, o_type) \ - unsigned long name##_LHASH_HASH(const void *arg) { \ - const o_type *a = arg; \ - return name##_hash(a); } -# define LHASH_HASH_FN(name) name##_LHASH_HASH - -/* Second: "compare" functions */ -# define DECLARE_LHASH_COMP_FN(name, o_type) \ - int name##_LHASH_COMP(const void *, const void *); -# define IMPLEMENT_LHASH_COMP_FN(name, o_type) \ - int name##_LHASH_COMP(const void *arg1, const void *arg2) { \ - const o_type *a = arg1; \ - const o_type *b = arg2; \ - return name##_cmp(a,b); } -# define LHASH_COMP_FN(name) name##_LHASH_COMP - -/* Fourth: "doall_arg" functions */ -# define DECLARE_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ - void name##_LHASH_DOALL_ARG(void *, void *); -# define IMPLEMENT_LHASH_DOALL_ARG_FN(name, o_type, a_type) \ - void name##_LHASH_DOALL_ARG(void *arg1, void *arg2) { \ - o_type *a = arg1; \ - a_type *b = arg2; \ - name##_doall_arg(a, b); } -# define LHASH_DOALL_ARG_FN(name) name##_LHASH_DOALL_ARG - - -# define LH_LOAD_MULT 256 - -int OPENSSL_LH_error(OPENSSL_LHASH *lh); -OPENSSL_LHASH *OPENSSL_LH_new(OPENSSL_LH_HASHFUNC h, OPENSSL_LH_COMPFUNC c); -void OPENSSL_LH_free(OPENSSL_LHASH *lh); -void *OPENSSL_LH_insert(OPENSSL_LHASH *lh, void *data); -void *OPENSSL_LH_delete(OPENSSL_LHASH *lh, const void *data); -void *OPENSSL_LH_retrieve(OPENSSL_LHASH *lh, const void *data); -void OPENSSL_LH_doall(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNC func); -void OPENSSL_LH_doall_arg(OPENSSL_LHASH *lh, OPENSSL_LH_DOALL_FUNCARG func, void *arg); -unsigned long OPENSSL_LH_strhash(const char *c); -unsigned long OPENSSL_LH_num_items(const OPENSSL_LHASH *lh); -unsigned long OPENSSL_LH_get_down_load(const OPENSSL_LHASH *lh); -void OPENSSL_LH_set_down_load(OPENSSL_LHASH *lh, unsigned long down_load); - -# ifndef OPENSSL_NO_STDIO -void OPENSSL_LH_stats(const OPENSSL_LHASH *lh, FILE *fp); -void OPENSSL_LH_node_stats(const OPENSSL_LHASH *lh, FILE *fp); -void OPENSSL_LH_node_usage_stats(const OPENSSL_LHASH *lh, FILE *fp); -# endif -void OPENSSL_LH_stats_bio(const OPENSSL_LHASH *lh, BIO *out); -void OPENSSL_LH_node_stats_bio(const OPENSSL_LHASH *lh, BIO *out); -void OPENSSL_LH_node_usage_stats_bio(const OPENSSL_LHASH *lh, BIO *out); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define _LHASH OPENSSL_LHASH -# define LHASH_NODE OPENSSL_LH_NODE -# define lh_error OPENSSL_LH_error -# define lh_new OPENSSL_lh_new -# define lh_free OPENSSL_LH_free -# define lh_insert OPENSSL_LH_insert -# define lh_delete OPENSSL_LH_delete -# define lh_retrieve OPENSSL_LH_retrieve -# define lh_doall OPENSSL_LH_doall -# define lh_doall_arg OPENSSL_LH_doall_arg -# define lh_strhash OPENSSL_LH_strhash -# define lh_num_items OPENSSL_LH_num_items -# ifndef OPENSSL_NO_STDIO -# define lh_stats OPENSSL_LH_stats -# define lh_node_stats OPENSSL_LH_node_stats -# define lh_node_usage_stats OPENSSL_LH_node_usage_stats -# endif -# define lh_stats_bio OPENSSL_LH_stats_bio -# define lh_node_stats_bio OPENSSL_LH_node_stats_bio -# define lh_node_usage_stats_bio OPENSSL_LH_node_usage_stats_bio -# endif - -/* Type checking... */ - -# define LHASH_OF(type) struct lhash_st_##type - -# define DEFINE_LHASH_OF(type) \ - LHASH_OF(type) { union lh_##type##_dummy { void* d1; unsigned long d2; int d3; } dummy; }; \ - static ossl_inline LHASH_OF(type) * \ - lh_##type##_new(unsigned long (*hfn)(const type *), \ - int (*cfn)(const type *, const type *)) \ - { \ - return (LHASH_OF(type) *) \ - OPENSSL_LH_new((OPENSSL_LH_HASHFUNC)hfn, (OPENSSL_LH_COMPFUNC)cfn); \ - } \ - static ossl_inline void lh_##type##_free(LHASH_OF(type) *lh) \ - { \ - OPENSSL_LH_free((OPENSSL_LHASH *)lh); \ - } \ - static ossl_inline type *lh_##type##_insert(LHASH_OF(type) *lh, type *d) \ - { \ - return (type *)OPENSSL_LH_insert((OPENSSL_LHASH *)lh, d); \ - } \ - static ossl_inline type *lh_##type##_delete(LHASH_OF(type) *lh, const type *d) \ - { \ - return (type *)OPENSSL_LH_delete((OPENSSL_LHASH *)lh, d); \ - } \ - static ossl_inline type *lh_##type##_retrieve(LHASH_OF(type) *lh, const type *d) \ - { \ - return (type *)OPENSSL_LH_retrieve((OPENSSL_LHASH *)lh, d); \ - } \ - static ossl_inline int lh_##type##_error(LHASH_OF(type) *lh) \ - { \ - return OPENSSL_LH_error((OPENSSL_LHASH *)lh); \ - } \ - static ossl_inline unsigned long lh_##type##_num_items(LHASH_OF(type) *lh) \ - { \ - return OPENSSL_LH_num_items((OPENSSL_LHASH *)lh); \ - } \ - static ossl_inline void lh_##type##_node_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ - { \ - OPENSSL_LH_node_stats_bio((const OPENSSL_LHASH *)lh, out); \ - } \ - static ossl_inline void lh_##type##_node_usage_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ - { \ - OPENSSL_LH_node_usage_stats_bio((const OPENSSL_LHASH *)lh, out); \ - } \ - static ossl_inline void lh_##type##_stats_bio(const LHASH_OF(type) *lh, BIO *out) \ - { \ - OPENSSL_LH_stats_bio((const OPENSSL_LHASH *)lh, out); \ - } \ - static ossl_inline unsigned long lh_##type##_get_down_load(LHASH_OF(type) *lh) \ - { \ - return OPENSSL_LH_get_down_load((OPENSSL_LHASH *)lh); \ - } \ - static ossl_inline void lh_##type##_set_down_load(LHASH_OF(type) *lh, unsigned long dl) \ - { \ - OPENSSL_LH_set_down_load((OPENSSL_LHASH *)lh, dl); \ - } \ - static ossl_inline void lh_##type##_doall(LHASH_OF(type) *lh, \ - void (*doall)(type *)) \ - { \ - OPENSSL_LH_doall((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNC)doall); \ - } \ - LHASH_OF(type) - -#define IMPLEMENT_LHASH_DOALL_ARG_CONST(type, argtype) \ - int_implement_lhash_doall(type, argtype, const type) - -#define IMPLEMENT_LHASH_DOALL_ARG(type, argtype) \ - int_implement_lhash_doall(type, argtype, type) - -#define int_implement_lhash_doall(type, argtype, cbargtype) \ - static ossl_inline void \ - lh_##type##_doall_##argtype(LHASH_OF(type) *lh, \ - void (*fn)(cbargtype *, argtype *), \ - argtype *arg) \ - { \ - OPENSSL_LH_doall_arg((OPENSSL_LHASH *)lh, (OPENSSL_LH_DOALL_FUNCARG)fn, (void *)arg); \ - } \ - LHASH_OF(type) - -DEFINE_LHASH_OF(OPENSSL_STRING); -DEFINE_LHASH_OF(OPENSSL_CSTRING); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android/armeabi/include/openssl/md2.h b/android/armeabi/include/openssl/md2.h deleted file mode 100644 index 7faf8e3d..00000000 --- a/android/armeabi/include/openssl/md2.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_MD2_H -# define HEADER_MD2_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_MD2 -# include <stddef.h> -# ifdef __cplusplus -extern "C" { -# endif - -typedef unsigned char MD2_INT; - -# define MD2_DIGEST_LENGTH 16 -# define MD2_BLOCK 16 - -typedef struct MD2state_st { - unsigned int num; - unsigned char data[MD2_BLOCK]; - MD2_INT cksm[MD2_BLOCK]; - MD2_INT state[MD2_BLOCK]; -} MD2_CTX; - -const char *MD2_options(void); -int MD2_Init(MD2_CTX *c); -int MD2_Update(MD2_CTX *c, const unsigned char *data, size_t len); -int MD2_Final(unsigned char *md, MD2_CTX *c); -unsigned char *MD2(const unsigned char *d, size_t n, unsigned char *md); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/md4.h b/android/armeabi/include/openssl/md4.h deleted file mode 100644 index 940e29db..00000000 --- a/android/armeabi/include/openssl/md4.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_MD4_H -# define HEADER_MD4_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_MD4 -# include <openssl/e_os2.h> -# include <stddef.h> -# ifdef __cplusplus -extern "C" { -# endif - -/*- - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! MD4_LONG has to be at least 32 bits wide. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ -# define MD4_LONG unsigned int - -# define MD4_CBLOCK 64 -# define MD4_LBLOCK (MD4_CBLOCK/4) -# define MD4_DIGEST_LENGTH 16 - -typedef struct MD4state_st { - MD4_LONG A, B, C, D; - MD4_LONG Nl, Nh; - MD4_LONG data[MD4_LBLOCK]; - unsigned int num; -} MD4_CTX; - -int MD4_Init(MD4_CTX *c); -int MD4_Update(MD4_CTX *c, const void *data, size_t len); -int MD4_Final(unsigned char *md, MD4_CTX *c); -unsigned char *MD4(const unsigned char *d, size_t n, unsigned char *md); -void MD4_Transform(MD4_CTX *c, const unsigned char *b); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/md5.h b/android/armeabi/include/openssl/md5.h deleted file mode 100644 index 2deb7721..00000000 --- a/android/armeabi/include/openssl/md5.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_MD5_H -# define HEADER_MD5_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_MD5 -# include <openssl/e_os2.h> -# include <stddef.h> -# ifdef __cplusplus -extern "C" { -# endif - -/* - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! MD5_LONG has to be at least 32 bits wide. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ -# define MD5_LONG unsigned int - -# define MD5_CBLOCK 64 -# define MD5_LBLOCK (MD5_CBLOCK/4) -# define MD5_DIGEST_LENGTH 16 - -typedef struct MD5state_st { - MD5_LONG A, B, C, D; - MD5_LONG Nl, Nh; - MD5_LONG data[MD5_LBLOCK]; - unsigned int num; -} MD5_CTX; - -int MD5_Init(MD5_CTX *c); -int MD5_Update(MD5_CTX *c, const void *data, size_t len); -int MD5_Final(unsigned char *md, MD5_CTX *c); -unsigned char *MD5(const unsigned char *d, size_t n, unsigned char *md); -void MD5_Transform(MD5_CTX *c, const unsigned char *b); -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/mdc2.h b/android/armeabi/include/openssl/mdc2.h deleted file mode 100644 index aabd2bfa..00000000 --- a/android/armeabi/include/openssl/mdc2.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_MDC2_H -# define HEADER_MDC2_H - -# include <openssl/opensslconf.h> - -#ifndef OPENSSL_NO_MDC2 -# include <stdlib.h> -# include <openssl/des.h> -# ifdef __cplusplus -extern "C" { -# endif - -# define MDC2_BLOCK 8 -# define MDC2_DIGEST_LENGTH 16 - -typedef struct mdc2_ctx_st { - unsigned int num; - unsigned char data[MDC2_BLOCK]; - DES_cblock h, hh; - int pad_type; /* either 1 or 2, default 1 */ -} MDC2_CTX; - -int MDC2_Init(MDC2_CTX *c); -int MDC2_Update(MDC2_CTX *c, const unsigned char *data, size_t len); -int MDC2_Final(unsigned char *md, MDC2_CTX *c); -unsigned char *MDC2(const unsigned char *d, size_t n, unsigned char *md); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/modes.h b/android/armeabi/include/openssl/modes.h deleted file mode 100644 index a04c6a59..00000000 --- a/android/armeabi/include/openssl/modes.h +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright 2008-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif -typedef void (*block128_f) (const unsigned char in[16], - unsigned char out[16], const void *key); - -typedef void (*cbc128_f) (const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], int enc); - -typedef void (*ctr128_f) (const unsigned char *in, unsigned char *out, - size_t blocks, const void *key, - const unsigned char ivec[16]); - -typedef void (*ccm128_f) (const unsigned char *in, unsigned char *out, - size_t blocks, const void *key, - const unsigned char ivec[16], - unsigned char cmac[16]); - -void CRYPTO_cbc128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], block128_f block); -void CRYPTO_cbc128_decrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], block128_f block); - -void CRYPTO_ctr128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], - unsigned char ecount_buf[16], unsigned int *num, - block128_f block); - -void CRYPTO_ctr128_encrypt_ctr32(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], - unsigned char ecount_buf[16], - unsigned int *num, ctr128_f ctr); - -void CRYPTO_ofb128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], int *num, - block128_f block); - -void CRYPTO_cfb128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], int *num, - int enc, block128_f block); -void CRYPTO_cfb128_8_encrypt(const unsigned char *in, unsigned char *out, - size_t length, const void *key, - unsigned char ivec[16], int *num, - int enc, block128_f block); -void CRYPTO_cfb128_1_encrypt(const unsigned char *in, unsigned char *out, - size_t bits, const void *key, - unsigned char ivec[16], int *num, - int enc, block128_f block); - -size_t CRYPTO_cts128_encrypt_block(const unsigned char *in, - unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], - block128_f block); -size_t CRYPTO_cts128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], cbc128_f cbc); -size_t CRYPTO_cts128_decrypt_block(const unsigned char *in, - unsigned char *out, size_t len, - const void *key, unsigned char ivec[16], - block128_f block); -size_t CRYPTO_cts128_decrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], cbc128_f cbc); - -size_t CRYPTO_nistcts128_encrypt_block(const unsigned char *in, - unsigned char *out, size_t len, - const void *key, - unsigned char ivec[16], - block128_f block); -size_t CRYPTO_nistcts128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], cbc128_f cbc); -size_t CRYPTO_nistcts128_decrypt_block(const unsigned char *in, - unsigned char *out, size_t len, - const void *key, - unsigned char ivec[16], - block128_f block); -size_t CRYPTO_nistcts128_decrypt(const unsigned char *in, unsigned char *out, - size_t len, const void *key, - unsigned char ivec[16], cbc128_f cbc); - -typedef struct gcm128_context GCM128_CONTEXT; - -GCM128_CONTEXT *CRYPTO_gcm128_new(void *key, block128_f block); -void CRYPTO_gcm128_init(GCM128_CONTEXT *ctx, void *key, block128_f block); -void CRYPTO_gcm128_setiv(GCM128_CONTEXT *ctx, const unsigned char *iv, - size_t len); -int CRYPTO_gcm128_aad(GCM128_CONTEXT *ctx, const unsigned char *aad, - size_t len); -int CRYPTO_gcm128_encrypt(GCM128_CONTEXT *ctx, - const unsigned char *in, unsigned char *out, - size_t len); -int CRYPTO_gcm128_decrypt(GCM128_CONTEXT *ctx, - const unsigned char *in, unsigned char *out, - size_t len); -int CRYPTO_gcm128_encrypt_ctr32(GCM128_CONTEXT *ctx, - const unsigned char *in, unsigned char *out, - size_t len, ctr128_f stream); -int CRYPTO_gcm128_decrypt_ctr32(GCM128_CONTEXT *ctx, - const unsigned char *in, unsigned char *out, - size_t len, ctr128_f stream); -int CRYPTO_gcm128_finish(GCM128_CONTEXT *ctx, const unsigned char *tag, - size_t len); -void CRYPTO_gcm128_tag(GCM128_CONTEXT *ctx, unsigned char *tag, size_t len); -void CRYPTO_gcm128_release(GCM128_CONTEXT *ctx); - -typedef struct ccm128_context CCM128_CONTEXT; - -void CRYPTO_ccm128_init(CCM128_CONTEXT *ctx, - unsigned int M, unsigned int L, void *key, - block128_f block); -int CRYPTO_ccm128_setiv(CCM128_CONTEXT *ctx, const unsigned char *nonce, - size_t nlen, size_t mlen); -void CRYPTO_ccm128_aad(CCM128_CONTEXT *ctx, const unsigned char *aad, - size_t alen); -int CRYPTO_ccm128_encrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, - unsigned char *out, size_t len); -int CRYPTO_ccm128_decrypt(CCM128_CONTEXT *ctx, const unsigned char *inp, - unsigned char *out, size_t len); -int CRYPTO_ccm128_encrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, - unsigned char *out, size_t len, - ccm128_f stream); -int CRYPTO_ccm128_decrypt_ccm64(CCM128_CONTEXT *ctx, const unsigned char *inp, - unsigned char *out, size_t len, - ccm128_f stream); -size_t CRYPTO_ccm128_tag(CCM128_CONTEXT *ctx, unsigned char *tag, size_t len); - -typedef struct xts128_context XTS128_CONTEXT; - -int CRYPTO_xts128_encrypt(const XTS128_CONTEXT *ctx, - const unsigned char iv[16], - const unsigned char *inp, unsigned char *out, - size_t len, int enc); - -size_t CRYPTO_128_wrap(void *key, const unsigned char *iv, - unsigned char *out, - const unsigned char *in, size_t inlen, - block128_f block); - -size_t CRYPTO_128_unwrap(void *key, const unsigned char *iv, - unsigned char *out, - const unsigned char *in, size_t inlen, - block128_f block); -size_t CRYPTO_128_wrap_pad(void *key, const unsigned char *icv, - unsigned char *out, const unsigned char *in, - size_t inlen, block128_f block); -size_t CRYPTO_128_unwrap_pad(void *key, const unsigned char *icv, - unsigned char *out, const unsigned char *in, - size_t inlen, block128_f block); - -#ifndef OPENSSL_NO_OCB -typedef struct ocb128_context OCB128_CONTEXT; - -typedef void (*ocb128_f) (const unsigned char *in, unsigned char *out, - size_t blocks, const void *key, - size_t start_block_num, - unsigned char offset_i[16], - const unsigned char L_[][16], - unsigned char checksum[16]); - -OCB128_CONTEXT *CRYPTO_ocb128_new(void *keyenc, void *keydec, - block128_f encrypt, block128_f decrypt, - ocb128_f stream); -int CRYPTO_ocb128_init(OCB128_CONTEXT *ctx, void *keyenc, void *keydec, - block128_f encrypt, block128_f decrypt, - ocb128_f stream); -int CRYPTO_ocb128_copy_ctx(OCB128_CONTEXT *dest, OCB128_CONTEXT *src, - void *keyenc, void *keydec); -int CRYPTO_ocb128_setiv(OCB128_CONTEXT *ctx, const unsigned char *iv, - size_t len, size_t taglen); -int CRYPTO_ocb128_aad(OCB128_CONTEXT *ctx, const unsigned char *aad, - size_t len); -int CRYPTO_ocb128_encrypt(OCB128_CONTEXT *ctx, const unsigned char *in, - unsigned char *out, size_t len); -int CRYPTO_ocb128_decrypt(OCB128_CONTEXT *ctx, const unsigned char *in, - unsigned char *out, size_t len); -int CRYPTO_ocb128_finish(OCB128_CONTEXT *ctx, const unsigned char *tag, - size_t len); -int CRYPTO_ocb128_tag(OCB128_CONTEXT *ctx, unsigned char *tag, size_t len); -void CRYPTO_ocb128_cleanup(OCB128_CONTEXT *ctx); -#endif /* OPENSSL_NO_OCB */ - -#ifdef __cplusplus -} -#endif diff --git a/android/armeabi/include/openssl/obj_mac.h b/android/armeabi/include/openssl/obj_mac.h deleted file mode 100644 index f97f3eaa..00000000 --- a/android/armeabi/include/openssl/obj_mac.h +++ /dev/null @@ -1,4577 +0,0 @@ -/* - * WARNING: do not edit! - * Generated by crypto/objects/objects.pl - * - * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#define SN_undef "UNDEF" -#define LN_undef "undefined" -#define NID_undef 0 -#define OBJ_undef 0L - -#define SN_itu_t "ITU-T" -#define LN_itu_t "itu-t" -#define NID_itu_t 645 -#define OBJ_itu_t 0L - -#define NID_ccitt 404 -#define OBJ_ccitt OBJ_itu_t - -#define SN_iso "ISO" -#define LN_iso "iso" -#define NID_iso 181 -#define OBJ_iso 1L - -#define SN_joint_iso_itu_t "JOINT-ISO-ITU-T" -#define LN_joint_iso_itu_t "joint-iso-itu-t" -#define NID_joint_iso_itu_t 646 -#define OBJ_joint_iso_itu_t 2L - -#define NID_joint_iso_ccitt 393 -#define OBJ_joint_iso_ccitt OBJ_joint_iso_itu_t - -#define SN_member_body "member-body" -#define LN_member_body "ISO Member Body" -#define NID_member_body 182 -#define OBJ_member_body OBJ_iso,2L - -#define SN_identified_organization "identified-organization" -#define NID_identified_organization 676 -#define OBJ_identified_organization OBJ_iso,3L - -#define SN_hmac_md5 "HMAC-MD5" -#define LN_hmac_md5 "hmac-md5" -#define NID_hmac_md5 780 -#define OBJ_hmac_md5 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,1L - -#define SN_hmac_sha1 "HMAC-SHA1" -#define LN_hmac_sha1 "hmac-sha1" -#define NID_hmac_sha1 781 -#define OBJ_hmac_sha1 OBJ_identified_organization,6L,1L,5L,5L,8L,1L,2L - -#define SN_certicom_arc "certicom-arc" -#define NID_certicom_arc 677 -#define OBJ_certicom_arc OBJ_identified_organization,132L - -#define SN_international_organizations "international-organizations" -#define LN_international_organizations "International Organizations" -#define NID_international_organizations 647 -#define OBJ_international_organizations OBJ_joint_iso_itu_t,23L - -#define SN_wap "wap" -#define NID_wap 678 -#define OBJ_wap OBJ_international_organizations,43L - -#define SN_wap_wsg "wap-wsg" -#define NID_wap_wsg 679 -#define OBJ_wap_wsg OBJ_wap,1L - -#define SN_selected_attribute_types "selected-attribute-types" -#define LN_selected_attribute_types "Selected Attribute Types" -#define NID_selected_attribute_types 394 -#define OBJ_selected_attribute_types OBJ_joint_iso_itu_t,5L,1L,5L - -#define SN_clearance "clearance" -#define NID_clearance 395 -#define OBJ_clearance OBJ_selected_attribute_types,55L - -#define SN_ISO_US "ISO-US" -#define LN_ISO_US "ISO US Member Body" -#define NID_ISO_US 183 -#define OBJ_ISO_US OBJ_member_body,840L - -#define SN_X9_57 "X9-57" -#define LN_X9_57 "X9.57" -#define NID_X9_57 184 -#define OBJ_X9_57 OBJ_ISO_US,10040L - -#define SN_X9cm "X9cm" -#define LN_X9cm "X9.57 CM ?" -#define NID_X9cm 185 -#define OBJ_X9cm OBJ_X9_57,4L - -#define SN_dsa "DSA" -#define LN_dsa "dsaEncryption" -#define NID_dsa 116 -#define OBJ_dsa OBJ_X9cm,1L - -#define SN_dsaWithSHA1 "DSA-SHA1" -#define LN_dsaWithSHA1 "dsaWithSHA1" -#define NID_dsaWithSHA1 113 -#define OBJ_dsaWithSHA1 OBJ_X9cm,3L - -#define SN_ansi_X9_62 "ansi-X9-62" -#define LN_ansi_X9_62 "ANSI X9.62" -#define NID_ansi_X9_62 405 -#define OBJ_ansi_X9_62 OBJ_ISO_US,10045L - -#define OBJ_X9_62_id_fieldType OBJ_ansi_X9_62,1L - -#define SN_X9_62_prime_field "prime-field" -#define NID_X9_62_prime_field 406 -#define OBJ_X9_62_prime_field OBJ_X9_62_id_fieldType,1L - -#define SN_X9_62_characteristic_two_field "characteristic-two-field" -#define NID_X9_62_characteristic_two_field 407 -#define OBJ_X9_62_characteristic_two_field OBJ_X9_62_id_fieldType,2L - -#define SN_X9_62_id_characteristic_two_basis "id-characteristic-two-basis" -#define NID_X9_62_id_characteristic_two_basis 680 -#define OBJ_X9_62_id_characteristic_two_basis OBJ_X9_62_characteristic_two_field,3L - -#define SN_X9_62_onBasis "onBasis" -#define NID_X9_62_onBasis 681 -#define OBJ_X9_62_onBasis OBJ_X9_62_id_characteristic_two_basis,1L - -#define SN_X9_62_tpBasis "tpBasis" -#define NID_X9_62_tpBasis 682 -#define OBJ_X9_62_tpBasis OBJ_X9_62_id_characteristic_two_basis,2L - -#define SN_X9_62_ppBasis "ppBasis" -#define NID_X9_62_ppBasis 683 -#define OBJ_X9_62_ppBasis OBJ_X9_62_id_characteristic_two_basis,3L - -#define OBJ_X9_62_id_publicKeyType OBJ_ansi_X9_62,2L - -#define SN_X9_62_id_ecPublicKey "id-ecPublicKey" -#define NID_X9_62_id_ecPublicKey 408 -#define OBJ_X9_62_id_ecPublicKey OBJ_X9_62_id_publicKeyType,1L - -#define OBJ_X9_62_ellipticCurve OBJ_ansi_X9_62,3L - -#define OBJ_X9_62_c_TwoCurve OBJ_X9_62_ellipticCurve,0L - -#define SN_X9_62_c2pnb163v1 "c2pnb163v1" -#define NID_X9_62_c2pnb163v1 684 -#define OBJ_X9_62_c2pnb163v1 OBJ_X9_62_c_TwoCurve,1L - -#define SN_X9_62_c2pnb163v2 "c2pnb163v2" -#define NID_X9_62_c2pnb163v2 685 -#define OBJ_X9_62_c2pnb163v2 OBJ_X9_62_c_TwoCurve,2L - -#define SN_X9_62_c2pnb163v3 "c2pnb163v3" -#define NID_X9_62_c2pnb163v3 686 -#define OBJ_X9_62_c2pnb163v3 OBJ_X9_62_c_TwoCurve,3L - -#define SN_X9_62_c2pnb176v1 "c2pnb176v1" -#define NID_X9_62_c2pnb176v1 687 -#define OBJ_X9_62_c2pnb176v1 OBJ_X9_62_c_TwoCurve,4L - -#define SN_X9_62_c2tnb191v1 "c2tnb191v1" -#define NID_X9_62_c2tnb191v1 688 -#define OBJ_X9_62_c2tnb191v1 OBJ_X9_62_c_TwoCurve,5L - -#define SN_X9_62_c2tnb191v2 "c2tnb191v2" -#define NID_X9_62_c2tnb191v2 689 -#define OBJ_X9_62_c2tnb191v2 OBJ_X9_62_c_TwoCurve,6L - -#define SN_X9_62_c2tnb191v3 "c2tnb191v3" -#define NID_X9_62_c2tnb191v3 690 -#define OBJ_X9_62_c2tnb191v3 OBJ_X9_62_c_TwoCurve,7L - -#define SN_X9_62_c2onb191v4 "c2onb191v4" -#define NID_X9_62_c2onb191v4 691 -#define OBJ_X9_62_c2onb191v4 OBJ_X9_62_c_TwoCurve,8L - -#define SN_X9_62_c2onb191v5 "c2onb191v5" -#define NID_X9_62_c2onb191v5 692 -#define OBJ_X9_62_c2onb191v5 OBJ_X9_62_c_TwoCurve,9L - -#define SN_X9_62_c2pnb208w1 "c2pnb208w1" -#define NID_X9_62_c2pnb208w1 693 -#define OBJ_X9_62_c2pnb208w1 OBJ_X9_62_c_TwoCurve,10L - -#define SN_X9_62_c2tnb239v1 "c2tnb239v1" -#define NID_X9_62_c2tnb239v1 694 -#define OBJ_X9_62_c2tnb239v1 OBJ_X9_62_c_TwoCurve,11L - -#define SN_X9_62_c2tnb239v2 "c2tnb239v2" -#define NID_X9_62_c2tnb239v2 695 -#define OBJ_X9_62_c2tnb239v2 OBJ_X9_62_c_TwoCurve,12L - -#define SN_X9_62_c2tnb239v3 "c2tnb239v3" -#define NID_X9_62_c2tnb239v3 696 -#define OBJ_X9_62_c2tnb239v3 OBJ_X9_62_c_TwoCurve,13L - -#define SN_X9_62_c2onb239v4 "c2onb239v4" -#define NID_X9_62_c2onb239v4 697 -#define OBJ_X9_62_c2onb239v4 OBJ_X9_62_c_TwoCurve,14L - -#define SN_X9_62_c2onb239v5 "c2onb239v5" -#define NID_X9_62_c2onb239v5 698 -#define OBJ_X9_62_c2onb239v5 OBJ_X9_62_c_TwoCurve,15L - -#define SN_X9_62_c2pnb272w1 "c2pnb272w1" -#define NID_X9_62_c2pnb272w1 699 -#define OBJ_X9_62_c2pnb272w1 OBJ_X9_62_c_TwoCurve,16L - -#define SN_X9_62_c2pnb304w1 "c2pnb304w1" -#define NID_X9_62_c2pnb304w1 700 -#define OBJ_X9_62_c2pnb304w1 OBJ_X9_62_c_TwoCurve,17L - -#define SN_X9_62_c2tnb359v1 "c2tnb359v1" -#define NID_X9_62_c2tnb359v1 701 -#define OBJ_X9_62_c2tnb359v1 OBJ_X9_62_c_TwoCurve,18L - -#define SN_X9_62_c2pnb368w1 "c2pnb368w1" -#define NID_X9_62_c2pnb368w1 702 -#define OBJ_X9_62_c2pnb368w1 OBJ_X9_62_c_TwoCurve,19L - -#define SN_X9_62_c2tnb431r1 "c2tnb431r1" -#define NID_X9_62_c2tnb431r1 703 -#define OBJ_X9_62_c2tnb431r1 OBJ_X9_62_c_TwoCurve,20L - -#define OBJ_X9_62_primeCurve OBJ_X9_62_ellipticCurve,1L - -#define SN_X9_62_prime192v1 "prime192v1" -#define NID_X9_62_prime192v1 409 -#define OBJ_X9_62_prime192v1 OBJ_X9_62_primeCurve,1L - -#define SN_X9_62_prime192v2 "prime192v2" -#define NID_X9_62_prime192v2 410 -#define OBJ_X9_62_prime192v2 OBJ_X9_62_primeCurve,2L - -#define SN_X9_62_prime192v3 "prime192v3" -#define NID_X9_62_prime192v3 411 -#define OBJ_X9_62_prime192v3 OBJ_X9_62_primeCurve,3L - -#define SN_X9_62_prime239v1 "prime239v1" -#define NID_X9_62_prime239v1 412 -#define OBJ_X9_62_prime239v1 OBJ_X9_62_primeCurve,4L - -#define SN_X9_62_prime239v2 "prime239v2" -#define NID_X9_62_prime239v2 413 -#define OBJ_X9_62_prime239v2 OBJ_X9_62_primeCurve,5L - -#define SN_X9_62_prime239v3 "prime239v3" -#define NID_X9_62_prime239v3 414 -#define OBJ_X9_62_prime239v3 OBJ_X9_62_primeCurve,6L - -#define SN_X9_62_prime256v1 "prime256v1" -#define NID_X9_62_prime256v1 415 -#define OBJ_X9_62_prime256v1 OBJ_X9_62_primeCurve,7L - -#define OBJ_X9_62_id_ecSigType OBJ_ansi_X9_62,4L - -#define SN_ecdsa_with_SHA1 "ecdsa-with-SHA1" -#define NID_ecdsa_with_SHA1 416 -#define OBJ_ecdsa_with_SHA1 OBJ_X9_62_id_ecSigType,1L - -#define SN_ecdsa_with_Recommended "ecdsa-with-Recommended" -#define NID_ecdsa_with_Recommended 791 -#define OBJ_ecdsa_with_Recommended OBJ_X9_62_id_ecSigType,2L - -#define SN_ecdsa_with_Specified "ecdsa-with-Specified" -#define NID_ecdsa_with_Specified 792 -#define OBJ_ecdsa_with_Specified OBJ_X9_62_id_ecSigType,3L - -#define SN_ecdsa_with_SHA224 "ecdsa-with-SHA224" -#define NID_ecdsa_with_SHA224 793 -#define OBJ_ecdsa_with_SHA224 OBJ_ecdsa_with_Specified,1L - -#define SN_ecdsa_with_SHA256 "ecdsa-with-SHA256" -#define NID_ecdsa_with_SHA256 794 -#define OBJ_ecdsa_with_SHA256 OBJ_ecdsa_with_Specified,2L - -#define SN_ecdsa_with_SHA384 "ecdsa-with-SHA384" -#define NID_ecdsa_with_SHA384 795 -#define OBJ_ecdsa_with_SHA384 OBJ_ecdsa_with_Specified,3L - -#define SN_ecdsa_with_SHA512 "ecdsa-with-SHA512" -#define NID_ecdsa_with_SHA512 796 -#define OBJ_ecdsa_with_SHA512 OBJ_ecdsa_with_Specified,4L - -#define OBJ_secg_ellipticCurve OBJ_certicom_arc,0L - -#define SN_secp112r1 "secp112r1" -#define NID_secp112r1 704 -#define OBJ_secp112r1 OBJ_secg_ellipticCurve,6L - -#define SN_secp112r2 "secp112r2" -#define NID_secp112r2 705 -#define OBJ_secp112r2 OBJ_secg_ellipticCurve,7L - -#define SN_secp128r1 "secp128r1" -#define NID_secp128r1 706 -#define OBJ_secp128r1 OBJ_secg_ellipticCurve,28L - -#define SN_secp128r2 "secp128r2" -#define NID_secp128r2 707 -#define OBJ_secp128r2 OBJ_secg_ellipticCurve,29L - -#define SN_secp160k1 "secp160k1" -#define NID_secp160k1 708 -#define OBJ_secp160k1 OBJ_secg_ellipticCurve,9L - -#define SN_secp160r1 "secp160r1" -#define NID_secp160r1 709 -#define OBJ_secp160r1 OBJ_secg_ellipticCurve,8L - -#define SN_secp160r2 "secp160r2" -#define NID_secp160r2 710 -#define OBJ_secp160r2 OBJ_secg_ellipticCurve,30L - -#define SN_secp192k1 "secp192k1" -#define NID_secp192k1 711 -#define OBJ_secp192k1 OBJ_secg_ellipticCurve,31L - -#define SN_secp224k1 "secp224k1" -#define NID_secp224k1 712 -#define OBJ_secp224k1 OBJ_secg_ellipticCurve,32L - -#define SN_secp224r1 "secp224r1" -#define NID_secp224r1 713 -#define OBJ_secp224r1 OBJ_secg_ellipticCurve,33L - -#define SN_secp256k1 "secp256k1" -#define NID_secp256k1 714 -#define OBJ_secp256k1 OBJ_secg_ellipticCurve,10L - -#define SN_secp384r1 "secp384r1" -#define NID_secp384r1 715 -#define OBJ_secp384r1 OBJ_secg_ellipticCurve,34L - -#define SN_secp521r1 "secp521r1" -#define NID_secp521r1 716 -#define OBJ_secp521r1 OBJ_secg_ellipticCurve,35L - -#define SN_sect113r1 "sect113r1" -#define NID_sect113r1 717 -#define OBJ_sect113r1 OBJ_secg_ellipticCurve,4L - -#define SN_sect113r2 "sect113r2" -#define NID_sect113r2 718 -#define OBJ_sect113r2 OBJ_secg_ellipticCurve,5L - -#define SN_sect131r1 "sect131r1" -#define NID_sect131r1 719 -#define OBJ_sect131r1 OBJ_secg_ellipticCurve,22L - -#define SN_sect131r2 "sect131r2" -#define NID_sect131r2 720 -#define OBJ_sect131r2 OBJ_secg_ellipticCurve,23L - -#define SN_sect163k1 "sect163k1" -#define NID_sect163k1 721 -#define OBJ_sect163k1 OBJ_secg_ellipticCurve,1L - -#define SN_sect163r1 "sect163r1" -#define NID_sect163r1 722 -#define OBJ_sect163r1 OBJ_secg_ellipticCurve,2L - -#define SN_sect163r2 "sect163r2" -#define NID_sect163r2 723 -#define OBJ_sect163r2 OBJ_secg_ellipticCurve,15L - -#define SN_sect193r1 "sect193r1" -#define NID_sect193r1 724 -#define OBJ_sect193r1 OBJ_secg_ellipticCurve,24L - -#define SN_sect193r2 "sect193r2" -#define NID_sect193r2 725 -#define OBJ_sect193r2 OBJ_secg_ellipticCurve,25L - -#define SN_sect233k1 "sect233k1" -#define NID_sect233k1 726 -#define OBJ_sect233k1 OBJ_secg_ellipticCurve,26L - -#define SN_sect233r1 "sect233r1" -#define NID_sect233r1 727 -#define OBJ_sect233r1 OBJ_secg_ellipticCurve,27L - -#define SN_sect239k1 "sect239k1" -#define NID_sect239k1 728 -#define OBJ_sect239k1 OBJ_secg_ellipticCurve,3L - -#define SN_sect283k1 "sect283k1" -#define NID_sect283k1 729 -#define OBJ_sect283k1 OBJ_secg_ellipticCurve,16L - -#define SN_sect283r1 "sect283r1" -#define NID_sect283r1 730 -#define OBJ_sect283r1 OBJ_secg_ellipticCurve,17L - -#define SN_sect409k1 "sect409k1" -#define NID_sect409k1 731 -#define OBJ_sect409k1 OBJ_secg_ellipticCurve,36L - -#define SN_sect409r1 "sect409r1" -#define NID_sect409r1 732 -#define OBJ_sect409r1 OBJ_secg_ellipticCurve,37L - -#define SN_sect571k1 "sect571k1" -#define NID_sect571k1 733 -#define OBJ_sect571k1 OBJ_secg_ellipticCurve,38L - -#define SN_sect571r1 "sect571r1" -#define NID_sect571r1 734 -#define OBJ_sect571r1 OBJ_secg_ellipticCurve,39L - -#define OBJ_wap_wsg_idm_ecid OBJ_wap_wsg,4L - -#define SN_wap_wsg_idm_ecid_wtls1 "wap-wsg-idm-ecid-wtls1" -#define NID_wap_wsg_idm_ecid_wtls1 735 -#define OBJ_wap_wsg_idm_ecid_wtls1 OBJ_wap_wsg_idm_ecid,1L - -#define SN_wap_wsg_idm_ecid_wtls3 "wap-wsg-idm-ecid-wtls3" -#define NID_wap_wsg_idm_ecid_wtls3 736 -#define OBJ_wap_wsg_idm_ecid_wtls3 OBJ_wap_wsg_idm_ecid,3L - -#define SN_wap_wsg_idm_ecid_wtls4 "wap-wsg-idm-ecid-wtls4" -#define NID_wap_wsg_idm_ecid_wtls4 737 -#define OBJ_wap_wsg_idm_ecid_wtls4 OBJ_wap_wsg_idm_ecid,4L - -#define SN_wap_wsg_idm_ecid_wtls5 "wap-wsg-idm-ecid-wtls5" -#define NID_wap_wsg_idm_ecid_wtls5 738 -#define OBJ_wap_wsg_idm_ecid_wtls5 OBJ_wap_wsg_idm_ecid,5L - -#define SN_wap_wsg_idm_ecid_wtls6 "wap-wsg-idm-ecid-wtls6" -#define NID_wap_wsg_idm_ecid_wtls6 739 -#define OBJ_wap_wsg_idm_ecid_wtls6 OBJ_wap_wsg_idm_ecid,6L - -#define SN_wap_wsg_idm_ecid_wtls7 "wap-wsg-idm-ecid-wtls7" -#define NID_wap_wsg_idm_ecid_wtls7 740 -#define OBJ_wap_wsg_idm_ecid_wtls7 OBJ_wap_wsg_idm_ecid,7L - -#define SN_wap_wsg_idm_ecid_wtls8 "wap-wsg-idm-ecid-wtls8" -#define NID_wap_wsg_idm_ecid_wtls8 741 -#define OBJ_wap_wsg_idm_ecid_wtls8 OBJ_wap_wsg_idm_ecid,8L - -#define SN_wap_wsg_idm_ecid_wtls9 "wap-wsg-idm-ecid-wtls9" -#define NID_wap_wsg_idm_ecid_wtls9 742 -#define OBJ_wap_wsg_idm_ecid_wtls9 OBJ_wap_wsg_idm_ecid,9L - -#define SN_wap_wsg_idm_ecid_wtls10 "wap-wsg-idm-ecid-wtls10" -#define NID_wap_wsg_idm_ecid_wtls10 743 -#define OBJ_wap_wsg_idm_ecid_wtls10 OBJ_wap_wsg_idm_ecid,10L - -#define SN_wap_wsg_idm_ecid_wtls11 "wap-wsg-idm-ecid-wtls11" -#define NID_wap_wsg_idm_ecid_wtls11 744 -#define OBJ_wap_wsg_idm_ecid_wtls11 OBJ_wap_wsg_idm_ecid,11L - -#define SN_wap_wsg_idm_ecid_wtls12 "wap-wsg-idm-ecid-wtls12" -#define NID_wap_wsg_idm_ecid_wtls12 745 -#define OBJ_wap_wsg_idm_ecid_wtls12 OBJ_wap_wsg_idm_ecid,12L - -#define SN_cast5_cbc "CAST5-CBC" -#define LN_cast5_cbc "cast5-cbc" -#define NID_cast5_cbc 108 -#define OBJ_cast5_cbc OBJ_ISO_US,113533L,7L,66L,10L - -#define SN_cast5_ecb "CAST5-ECB" -#define LN_cast5_ecb "cast5-ecb" -#define NID_cast5_ecb 109 - -#define SN_cast5_cfb64 "CAST5-CFB" -#define LN_cast5_cfb64 "cast5-cfb" -#define NID_cast5_cfb64 110 - -#define SN_cast5_ofb64 "CAST5-OFB" -#define LN_cast5_ofb64 "cast5-ofb" -#define NID_cast5_ofb64 111 - -#define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" -#define NID_pbeWithMD5AndCast5_CBC 112 -#define OBJ_pbeWithMD5AndCast5_CBC OBJ_ISO_US,113533L,7L,66L,12L - -#define SN_id_PasswordBasedMAC "id-PasswordBasedMAC" -#define LN_id_PasswordBasedMAC "password based MAC" -#define NID_id_PasswordBasedMAC 782 -#define OBJ_id_PasswordBasedMAC OBJ_ISO_US,113533L,7L,66L,13L - -#define SN_id_DHBasedMac "id-DHBasedMac" -#define LN_id_DHBasedMac "Diffie-Hellman based MAC" -#define NID_id_DHBasedMac 783 -#define OBJ_id_DHBasedMac OBJ_ISO_US,113533L,7L,66L,30L - -#define SN_rsadsi "rsadsi" -#define LN_rsadsi "RSA Data Security, Inc." -#define NID_rsadsi 1 -#define OBJ_rsadsi OBJ_ISO_US,113549L - -#define SN_pkcs "pkcs" -#define LN_pkcs "RSA Data Security, Inc. PKCS" -#define NID_pkcs 2 -#define OBJ_pkcs OBJ_rsadsi,1L - -#define SN_pkcs1 "pkcs1" -#define NID_pkcs1 186 -#define OBJ_pkcs1 OBJ_pkcs,1L - -#define LN_rsaEncryption "rsaEncryption" -#define NID_rsaEncryption 6 -#define OBJ_rsaEncryption OBJ_pkcs1,1L - -#define SN_md2WithRSAEncryption "RSA-MD2" -#define LN_md2WithRSAEncryption "md2WithRSAEncryption" -#define NID_md2WithRSAEncryption 7 -#define OBJ_md2WithRSAEncryption OBJ_pkcs1,2L - -#define SN_md4WithRSAEncryption "RSA-MD4" -#define LN_md4WithRSAEncryption "md4WithRSAEncryption" -#define NID_md4WithRSAEncryption 396 -#define OBJ_md4WithRSAEncryption OBJ_pkcs1,3L - -#define SN_md5WithRSAEncryption "RSA-MD5" -#define LN_md5WithRSAEncryption "md5WithRSAEncryption" -#define NID_md5WithRSAEncryption 8 -#define OBJ_md5WithRSAEncryption OBJ_pkcs1,4L - -#define SN_sha1WithRSAEncryption "RSA-SHA1" -#define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" -#define NID_sha1WithRSAEncryption 65 -#define OBJ_sha1WithRSAEncryption OBJ_pkcs1,5L - -#define SN_rsaesOaep "RSAES-OAEP" -#define LN_rsaesOaep "rsaesOaep" -#define NID_rsaesOaep 919 -#define OBJ_rsaesOaep OBJ_pkcs1,7L - -#define SN_mgf1 "MGF1" -#define LN_mgf1 "mgf1" -#define NID_mgf1 911 -#define OBJ_mgf1 OBJ_pkcs1,8L - -#define SN_pSpecified "PSPECIFIED" -#define LN_pSpecified "pSpecified" -#define NID_pSpecified 935 -#define OBJ_pSpecified OBJ_pkcs1,9L - -#define SN_rsassaPss "RSASSA-PSS" -#define LN_rsassaPss "rsassaPss" -#define NID_rsassaPss 912 -#define OBJ_rsassaPss OBJ_pkcs1,10L - -#define SN_sha256WithRSAEncryption "RSA-SHA256" -#define LN_sha256WithRSAEncryption "sha256WithRSAEncryption" -#define NID_sha256WithRSAEncryption 668 -#define OBJ_sha256WithRSAEncryption OBJ_pkcs1,11L - -#define SN_sha384WithRSAEncryption "RSA-SHA384" -#define LN_sha384WithRSAEncryption "sha384WithRSAEncryption" -#define NID_sha384WithRSAEncryption 669 -#define OBJ_sha384WithRSAEncryption OBJ_pkcs1,12L - -#define SN_sha512WithRSAEncryption "RSA-SHA512" -#define LN_sha512WithRSAEncryption "sha512WithRSAEncryption" -#define NID_sha512WithRSAEncryption 670 -#define OBJ_sha512WithRSAEncryption OBJ_pkcs1,13L - -#define SN_sha224WithRSAEncryption "RSA-SHA224" -#define LN_sha224WithRSAEncryption "sha224WithRSAEncryption" -#define NID_sha224WithRSAEncryption 671 -#define OBJ_sha224WithRSAEncryption OBJ_pkcs1,14L - -#define SN_pkcs3 "pkcs3" -#define NID_pkcs3 27 -#define OBJ_pkcs3 OBJ_pkcs,3L - -#define LN_dhKeyAgreement "dhKeyAgreement" -#define NID_dhKeyAgreement 28 -#define OBJ_dhKeyAgreement OBJ_pkcs3,1L - -#define SN_pkcs5 "pkcs5" -#define NID_pkcs5 187 -#define OBJ_pkcs5 OBJ_pkcs,5L - -#define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" -#define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" -#define NID_pbeWithMD2AndDES_CBC 9 -#define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs5,1L - -#define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" -#define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" -#define NID_pbeWithMD5AndDES_CBC 10 -#define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs5,3L - -#define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" -#define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" -#define NID_pbeWithMD2AndRC2_CBC 168 -#define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs5,4L - -#define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" -#define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" -#define NID_pbeWithMD5AndRC2_CBC 169 -#define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs5,6L - -#define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" -#define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" -#define NID_pbeWithSHA1AndDES_CBC 170 -#define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs5,10L - -#define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" -#define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" -#define NID_pbeWithSHA1AndRC2_CBC 68 -#define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs5,11L - -#define LN_id_pbkdf2 "PBKDF2" -#define NID_id_pbkdf2 69 -#define OBJ_id_pbkdf2 OBJ_pkcs5,12L - -#define LN_pbes2 "PBES2" -#define NID_pbes2 161 -#define OBJ_pbes2 OBJ_pkcs5,13L - -#define LN_pbmac1 "PBMAC1" -#define NID_pbmac1 162 -#define OBJ_pbmac1 OBJ_pkcs5,14L - -#define SN_pkcs7 "pkcs7" -#define NID_pkcs7 20 -#define OBJ_pkcs7 OBJ_pkcs,7L - -#define LN_pkcs7_data "pkcs7-data" -#define NID_pkcs7_data 21 -#define OBJ_pkcs7_data OBJ_pkcs7,1L - -#define LN_pkcs7_signed "pkcs7-signedData" -#define NID_pkcs7_signed 22 -#define OBJ_pkcs7_signed OBJ_pkcs7,2L - -#define LN_pkcs7_enveloped "pkcs7-envelopedData" -#define NID_pkcs7_enveloped 23 -#define OBJ_pkcs7_enveloped OBJ_pkcs7,3L - -#define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" -#define NID_pkcs7_signedAndEnveloped 24 -#define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L - -#define LN_pkcs7_digest "pkcs7-digestData" -#define NID_pkcs7_digest 25 -#define OBJ_pkcs7_digest OBJ_pkcs7,5L - -#define LN_pkcs7_encrypted "pkcs7-encryptedData" -#define NID_pkcs7_encrypted 26 -#define OBJ_pkcs7_encrypted OBJ_pkcs7,6L - -#define SN_pkcs9 "pkcs9" -#define NID_pkcs9 47 -#define OBJ_pkcs9 OBJ_pkcs,9L - -#define LN_pkcs9_emailAddress "emailAddress" -#define NID_pkcs9_emailAddress 48 -#define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L - -#define LN_pkcs9_unstructuredName "unstructuredName" -#define NID_pkcs9_unstructuredName 49 -#define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L - -#define LN_pkcs9_contentType "contentType" -#define NID_pkcs9_contentType 50 -#define OBJ_pkcs9_contentType OBJ_pkcs9,3L - -#define LN_pkcs9_messageDigest "messageDigest" -#define NID_pkcs9_messageDigest 51 -#define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L - -#define LN_pkcs9_signingTime "signingTime" -#define NID_pkcs9_signingTime 52 -#define OBJ_pkcs9_signingTime OBJ_pkcs9,5L - -#define LN_pkcs9_countersignature "countersignature" -#define NID_pkcs9_countersignature 53 -#define OBJ_pkcs9_countersignature OBJ_pkcs9,6L - -#define LN_pkcs9_challengePassword "challengePassword" -#define NID_pkcs9_challengePassword 54 -#define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L - -#define LN_pkcs9_unstructuredAddress "unstructuredAddress" -#define NID_pkcs9_unstructuredAddress 55 -#define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L - -#define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" -#define NID_pkcs9_extCertAttributes 56 -#define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L - -#define SN_ext_req "extReq" -#define LN_ext_req "Extension Request" -#define NID_ext_req 172 -#define OBJ_ext_req OBJ_pkcs9,14L - -#define SN_SMIMECapabilities "SMIME-CAPS" -#define LN_SMIMECapabilities "S/MIME Capabilities" -#define NID_SMIMECapabilities 167 -#define OBJ_SMIMECapabilities OBJ_pkcs9,15L - -#define SN_SMIME "SMIME" -#define LN_SMIME "S/MIME" -#define NID_SMIME 188 -#define OBJ_SMIME OBJ_pkcs9,16L - -#define SN_id_smime_mod "id-smime-mod" -#define NID_id_smime_mod 189 -#define OBJ_id_smime_mod OBJ_SMIME,0L - -#define SN_id_smime_ct "id-smime-ct" -#define NID_id_smime_ct 190 -#define OBJ_id_smime_ct OBJ_SMIME,1L - -#define SN_id_smime_aa "id-smime-aa" -#define NID_id_smime_aa 191 -#define OBJ_id_smime_aa OBJ_SMIME,2L - -#define SN_id_smime_alg "id-smime-alg" -#define NID_id_smime_alg 192 -#define OBJ_id_smime_alg OBJ_SMIME,3L - -#define SN_id_smime_cd "id-smime-cd" -#define NID_id_smime_cd 193 -#define OBJ_id_smime_cd OBJ_SMIME,4L - -#define SN_id_smime_spq "id-smime-spq" -#define NID_id_smime_spq 194 -#define OBJ_id_smime_spq OBJ_SMIME,5L - -#define SN_id_smime_cti "id-smime-cti" -#define NID_id_smime_cti 195 -#define OBJ_id_smime_cti OBJ_SMIME,6L - -#define SN_id_smime_mod_cms "id-smime-mod-cms" -#define NID_id_smime_mod_cms 196 -#define OBJ_id_smime_mod_cms OBJ_id_smime_mod,1L - -#define SN_id_smime_mod_ess "id-smime-mod-ess" -#define NID_id_smime_mod_ess 197 -#define OBJ_id_smime_mod_ess OBJ_id_smime_mod,2L - -#define SN_id_smime_mod_oid "id-smime-mod-oid" -#define NID_id_smime_mod_oid 198 -#define OBJ_id_smime_mod_oid OBJ_id_smime_mod,3L - -#define SN_id_smime_mod_msg_v3 "id-smime-mod-msg-v3" -#define NID_id_smime_mod_msg_v3 199 -#define OBJ_id_smime_mod_msg_v3 OBJ_id_smime_mod,4L - -#define SN_id_smime_mod_ets_eSignature_88 "id-smime-mod-ets-eSignature-88" -#define NID_id_smime_mod_ets_eSignature_88 200 -#define OBJ_id_smime_mod_ets_eSignature_88 OBJ_id_smime_mod,5L - -#define SN_id_smime_mod_ets_eSignature_97 "id-smime-mod-ets-eSignature-97" -#define NID_id_smime_mod_ets_eSignature_97 201 -#define OBJ_id_smime_mod_ets_eSignature_97 OBJ_id_smime_mod,6L - -#define SN_id_smime_mod_ets_eSigPolicy_88 "id-smime-mod-ets-eSigPolicy-88" -#define NID_id_smime_mod_ets_eSigPolicy_88 202 -#define OBJ_id_smime_mod_ets_eSigPolicy_88 OBJ_id_smime_mod,7L - -#define SN_id_smime_mod_ets_eSigPolicy_97 "id-smime-mod-ets-eSigPolicy-97" -#define NID_id_smime_mod_ets_eSigPolicy_97 203 -#define OBJ_id_smime_mod_ets_eSigPolicy_97 OBJ_id_smime_mod,8L - -#define SN_id_smime_ct_receipt "id-smime-ct-receipt" -#define NID_id_smime_ct_receipt 204 -#define OBJ_id_smime_ct_receipt OBJ_id_smime_ct,1L - -#define SN_id_smime_ct_authData "id-smime-ct-authData" -#define NID_id_smime_ct_authData 205 -#define OBJ_id_smime_ct_authData OBJ_id_smime_ct,2L - -#define SN_id_smime_ct_publishCert "id-smime-ct-publishCert" -#define NID_id_smime_ct_publishCert 206 -#define OBJ_id_smime_ct_publishCert OBJ_id_smime_ct,3L - -#define SN_id_smime_ct_TSTInfo "id-smime-ct-TSTInfo" -#define NID_id_smime_ct_TSTInfo 207 -#define OBJ_id_smime_ct_TSTInfo OBJ_id_smime_ct,4L - -#define SN_id_smime_ct_TDTInfo "id-smime-ct-TDTInfo" -#define NID_id_smime_ct_TDTInfo 208 -#define OBJ_id_smime_ct_TDTInfo OBJ_id_smime_ct,5L - -#define SN_id_smime_ct_contentInfo "id-smime-ct-contentInfo" -#define NID_id_smime_ct_contentInfo 209 -#define OBJ_id_smime_ct_contentInfo OBJ_id_smime_ct,6L - -#define SN_id_smime_ct_DVCSRequestData "id-smime-ct-DVCSRequestData" -#define NID_id_smime_ct_DVCSRequestData 210 -#define OBJ_id_smime_ct_DVCSRequestData OBJ_id_smime_ct,7L - -#define SN_id_smime_ct_DVCSResponseData "id-smime-ct-DVCSResponseData" -#define NID_id_smime_ct_DVCSResponseData 211 -#define OBJ_id_smime_ct_DVCSResponseData OBJ_id_smime_ct,8L - -#define SN_id_smime_ct_compressedData "id-smime-ct-compressedData" -#define NID_id_smime_ct_compressedData 786 -#define OBJ_id_smime_ct_compressedData OBJ_id_smime_ct,9L - -#define SN_id_smime_ct_contentCollection "id-smime-ct-contentCollection" -#define NID_id_smime_ct_contentCollection 1058 -#define OBJ_id_smime_ct_contentCollection OBJ_id_smime_ct,19L - -#define SN_id_smime_ct_authEnvelopedData "id-smime-ct-authEnvelopedData" -#define NID_id_smime_ct_authEnvelopedData 1059 -#define OBJ_id_smime_ct_authEnvelopedData OBJ_id_smime_ct,23L - -#define SN_id_ct_asciiTextWithCRLF "id-ct-asciiTextWithCRLF" -#define NID_id_ct_asciiTextWithCRLF 787 -#define OBJ_id_ct_asciiTextWithCRLF OBJ_id_smime_ct,27L - -#define SN_id_ct_xml "id-ct-xml" -#define NID_id_ct_xml 1060 -#define OBJ_id_ct_xml OBJ_id_smime_ct,28L - -#define SN_id_smime_aa_receiptRequest "id-smime-aa-receiptRequest" -#define NID_id_smime_aa_receiptRequest 212 -#define OBJ_id_smime_aa_receiptRequest OBJ_id_smime_aa,1L - -#define SN_id_smime_aa_securityLabel "id-smime-aa-securityLabel" -#define NID_id_smime_aa_securityLabel 213 -#define OBJ_id_smime_aa_securityLabel OBJ_id_smime_aa,2L - -#define SN_id_smime_aa_mlExpandHistory "id-smime-aa-mlExpandHistory" -#define NID_id_smime_aa_mlExpandHistory 214 -#define OBJ_id_smime_aa_mlExpandHistory OBJ_id_smime_aa,3L - -#define SN_id_smime_aa_contentHint "id-smime-aa-contentHint" -#define NID_id_smime_aa_contentHint 215 -#define OBJ_id_smime_aa_contentHint OBJ_id_smime_aa,4L - -#define SN_id_smime_aa_msgSigDigest "id-smime-aa-msgSigDigest" -#define NID_id_smime_aa_msgSigDigest 216 -#define OBJ_id_smime_aa_msgSigDigest OBJ_id_smime_aa,5L - -#define SN_id_smime_aa_encapContentType "id-smime-aa-encapContentType" -#define NID_id_smime_aa_encapContentType 217 -#define OBJ_id_smime_aa_encapContentType OBJ_id_smime_aa,6L - -#define SN_id_smime_aa_contentIdentifier "id-smime-aa-contentIdentifier" -#define NID_id_smime_aa_contentIdentifier 218 -#define OBJ_id_smime_aa_contentIdentifier OBJ_id_smime_aa,7L - -#define SN_id_smime_aa_macValue "id-smime-aa-macValue" -#define NID_id_smime_aa_macValue 219 -#define OBJ_id_smime_aa_macValue OBJ_id_smime_aa,8L - -#define SN_id_smime_aa_equivalentLabels "id-smime-aa-equivalentLabels" -#define NID_id_smime_aa_equivalentLabels 220 -#define OBJ_id_smime_aa_equivalentLabels OBJ_id_smime_aa,9L - -#define SN_id_smime_aa_contentReference "id-smime-aa-contentReference" -#define NID_id_smime_aa_contentReference 221 -#define OBJ_id_smime_aa_contentReference OBJ_id_smime_aa,10L - -#define SN_id_smime_aa_encrypKeyPref "id-smime-aa-encrypKeyPref" -#define NID_id_smime_aa_encrypKeyPref 222 -#define OBJ_id_smime_aa_encrypKeyPref OBJ_id_smime_aa,11L - -#define SN_id_smime_aa_signingCertificate "id-smime-aa-signingCertificate" -#define NID_id_smime_aa_signingCertificate 223 -#define OBJ_id_smime_aa_signingCertificate OBJ_id_smime_aa,12L - -#define SN_id_smime_aa_smimeEncryptCerts "id-smime-aa-smimeEncryptCerts" -#define NID_id_smime_aa_smimeEncryptCerts 224 -#define OBJ_id_smime_aa_smimeEncryptCerts OBJ_id_smime_aa,13L - -#define SN_id_smime_aa_timeStampToken "id-smime-aa-timeStampToken" -#define NID_id_smime_aa_timeStampToken 225 -#define OBJ_id_smime_aa_timeStampToken OBJ_id_smime_aa,14L - -#define SN_id_smime_aa_ets_sigPolicyId "id-smime-aa-ets-sigPolicyId" -#define NID_id_smime_aa_ets_sigPolicyId 226 -#define OBJ_id_smime_aa_ets_sigPolicyId OBJ_id_smime_aa,15L - -#define SN_id_smime_aa_ets_commitmentType "id-smime-aa-ets-commitmentType" -#define NID_id_smime_aa_ets_commitmentType 227 -#define OBJ_id_smime_aa_ets_commitmentType OBJ_id_smime_aa,16L - -#define SN_id_smime_aa_ets_signerLocation "id-smime-aa-ets-signerLocation" -#define NID_id_smime_aa_ets_signerLocation 228 -#define OBJ_id_smime_aa_ets_signerLocation OBJ_id_smime_aa,17L - -#define SN_id_smime_aa_ets_signerAttr "id-smime-aa-ets-signerAttr" -#define NID_id_smime_aa_ets_signerAttr 229 -#define OBJ_id_smime_aa_ets_signerAttr OBJ_id_smime_aa,18L - -#define SN_id_smime_aa_ets_otherSigCert "id-smime-aa-ets-otherSigCert" -#define NID_id_smime_aa_ets_otherSigCert 230 -#define OBJ_id_smime_aa_ets_otherSigCert OBJ_id_smime_aa,19L - -#define SN_id_smime_aa_ets_contentTimestamp "id-smime-aa-ets-contentTimestamp" -#define NID_id_smime_aa_ets_contentTimestamp 231 -#define OBJ_id_smime_aa_ets_contentTimestamp OBJ_id_smime_aa,20L - -#define SN_id_smime_aa_ets_CertificateRefs "id-smime-aa-ets-CertificateRefs" -#define NID_id_smime_aa_ets_CertificateRefs 232 -#define OBJ_id_smime_aa_ets_CertificateRefs OBJ_id_smime_aa,21L - -#define SN_id_smime_aa_ets_RevocationRefs "id-smime-aa-ets-RevocationRefs" -#define NID_id_smime_aa_ets_RevocationRefs 233 -#define OBJ_id_smime_aa_ets_RevocationRefs OBJ_id_smime_aa,22L - -#define SN_id_smime_aa_ets_certValues "id-smime-aa-ets-certValues" -#define NID_id_smime_aa_ets_certValues 234 -#define OBJ_id_smime_aa_ets_certValues OBJ_id_smime_aa,23L - -#define SN_id_smime_aa_ets_revocationValues "id-smime-aa-ets-revocationValues" -#define NID_id_smime_aa_ets_revocationValues 235 -#define OBJ_id_smime_aa_ets_revocationValues OBJ_id_smime_aa,24L - -#define SN_id_smime_aa_ets_escTimeStamp "id-smime-aa-ets-escTimeStamp" -#define NID_id_smime_aa_ets_escTimeStamp 236 -#define OBJ_id_smime_aa_ets_escTimeStamp OBJ_id_smime_aa,25L - -#define SN_id_smime_aa_ets_certCRLTimestamp "id-smime-aa-ets-certCRLTimestamp" -#define NID_id_smime_aa_ets_certCRLTimestamp 237 -#define OBJ_id_smime_aa_ets_certCRLTimestamp OBJ_id_smime_aa,26L - -#define SN_id_smime_aa_ets_archiveTimeStamp "id-smime-aa-ets-archiveTimeStamp" -#define NID_id_smime_aa_ets_archiveTimeStamp 238 -#define OBJ_id_smime_aa_ets_archiveTimeStamp OBJ_id_smime_aa,27L - -#define SN_id_smime_aa_signatureType "id-smime-aa-signatureType" -#define NID_id_smime_aa_signatureType 239 -#define OBJ_id_smime_aa_signatureType OBJ_id_smime_aa,28L - -#define SN_id_smime_aa_dvcs_dvc "id-smime-aa-dvcs-dvc" -#define NID_id_smime_aa_dvcs_dvc 240 -#define OBJ_id_smime_aa_dvcs_dvc OBJ_id_smime_aa,29L - -#define SN_id_smime_alg_ESDHwith3DES "id-smime-alg-ESDHwith3DES" -#define NID_id_smime_alg_ESDHwith3DES 241 -#define OBJ_id_smime_alg_ESDHwith3DES OBJ_id_smime_alg,1L - -#define SN_id_smime_alg_ESDHwithRC2 "id-smime-alg-ESDHwithRC2" -#define NID_id_smime_alg_ESDHwithRC2 242 -#define OBJ_id_smime_alg_ESDHwithRC2 OBJ_id_smime_alg,2L - -#define SN_id_smime_alg_3DESwrap "id-smime-alg-3DESwrap" -#define NID_id_smime_alg_3DESwrap 243 -#define OBJ_id_smime_alg_3DESwrap OBJ_id_smime_alg,3L - -#define SN_id_smime_alg_RC2wrap "id-smime-alg-RC2wrap" -#define NID_id_smime_alg_RC2wrap 244 -#define OBJ_id_smime_alg_RC2wrap OBJ_id_smime_alg,4L - -#define SN_id_smime_alg_ESDH "id-smime-alg-ESDH" -#define NID_id_smime_alg_ESDH 245 -#define OBJ_id_smime_alg_ESDH OBJ_id_smime_alg,5L - -#define SN_id_smime_alg_CMS3DESwrap "id-smime-alg-CMS3DESwrap" -#define NID_id_smime_alg_CMS3DESwrap 246 -#define OBJ_id_smime_alg_CMS3DESwrap OBJ_id_smime_alg,6L - -#define SN_id_smime_alg_CMSRC2wrap "id-smime-alg-CMSRC2wrap" -#define NID_id_smime_alg_CMSRC2wrap 247 -#define OBJ_id_smime_alg_CMSRC2wrap OBJ_id_smime_alg,7L - -#define SN_id_alg_PWRI_KEK "id-alg-PWRI-KEK" -#define NID_id_alg_PWRI_KEK 893 -#define OBJ_id_alg_PWRI_KEK OBJ_id_smime_alg,9L - -#define SN_id_smime_cd_ldap "id-smime-cd-ldap" -#define NID_id_smime_cd_ldap 248 -#define OBJ_id_smime_cd_ldap OBJ_id_smime_cd,1L - -#define SN_id_smime_spq_ets_sqt_uri "id-smime-spq-ets-sqt-uri" -#define NID_id_smime_spq_ets_sqt_uri 249 -#define OBJ_id_smime_spq_ets_sqt_uri OBJ_id_smime_spq,1L - -#define SN_id_smime_spq_ets_sqt_unotice "id-smime-spq-ets-sqt-unotice" -#define NID_id_smime_spq_ets_sqt_unotice 250 -#define OBJ_id_smime_spq_ets_sqt_unotice OBJ_id_smime_spq,2L - -#define SN_id_smime_cti_ets_proofOfOrigin "id-smime-cti-ets-proofOfOrigin" -#define NID_id_smime_cti_ets_proofOfOrigin 251 -#define OBJ_id_smime_cti_ets_proofOfOrigin OBJ_id_smime_cti,1L - -#define SN_id_smime_cti_ets_proofOfReceipt "id-smime-cti-ets-proofOfReceipt" -#define NID_id_smime_cti_ets_proofOfReceipt 252 -#define OBJ_id_smime_cti_ets_proofOfReceipt OBJ_id_smime_cti,2L - -#define SN_id_smime_cti_ets_proofOfDelivery "id-smime-cti-ets-proofOfDelivery" -#define NID_id_smime_cti_ets_proofOfDelivery 253 -#define OBJ_id_smime_cti_ets_proofOfDelivery OBJ_id_smime_cti,3L - -#define SN_id_smime_cti_ets_proofOfSender "id-smime-cti-ets-proofOfSender" -#define NID_id_smime_cti_ets_proofOfSender 254 -#define OBJ_id_smime_cti_ets_proofOfSender OBJ_id_smime_cti,4L - -#define SN_id_smime_cti_ets_proofOfApproval "id-smime-cti-ets-proofOfApproval" -#define NID_id_smime_cti_ets_proofOfApproval 255 -#define OBJ_id_smime_cti_ets_proofOfApproval OBJ_id_smime_cti,5L - -#define SN_id_smime_cti_ets_proofOfCreation "id-smime-cti-ets-proofOfCreation" -#define NID_id_smime_cti_ets_proofOfCreation 256 -#define OBJ_id_smime_cti_ets_proofOfCreation OBJ_id_smime_cti,6L - -#define LN_friendlyName "friendlyName" -#define NID_friendlyName 156 -#define OBJ_friendlyName OBJ_pkcs9,20L - -#define LN_localKeyID "localKeyID" -#define NID_localKeyID 157 -#define OBJ_localKeyID OBJ_pkcs9,21L - -#define SN_ms_csp_name "CSPName" -#define LN_ms_csp_name "Microsoft CSP Name" -#define NID_ms_csp_name 417 -#define OBJ_ms_csp_name 1L,3L,6L,1L,4L,1L,311L,17L,1L - -#define SN_LocalKeySet "LocalKeySet" -#define LN_LocalKeySet "Microsoft Local Key set" -#define NID_LocalKeySet 856 -#define OBJ_LocalKeySet 1L,3L,6L,1L,4L,1L,311L,17L,2L - -#define OBJ_certTypes OBJ_pkcs9,22L - -#define LN_x509Certificate "x509Certificate" -#define NID_x509Certificate 158 -#define OBJ_x509Certificate OBJ_certTypes,1L - -#define LN_sdsiCertificate "sdsiCertificate" -#define NID_sdsiCertificate 159 -#define OBJ_sdsiCertificate OBJ_certTypes,2L - -#define OBJ_crlTypes OBJ_pkcs9,23L - -#define LN_x509Crl "x509Crl" -#define NID_x509Crl 160 -#define OBJ_x509Crl OBJ_crlTypes,1L - -#define OBJ_pkcs12 OBJ_pkcs,12L - -#define OBJ_pkcs12_pbeids OBJ_pkcs12,1L - -#define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" -#define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" -#define NID_pbe_WithSHA1And128BitRC4 144 -#define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids,1L - -#define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" -#define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" -#define NID_pbe_WithSHA1And40BitRC4 145 -#define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids,2L - -#define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" -#define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 -#define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids,3L - -#define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" -#define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" -#define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 -#define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids,4L - -#define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" -#define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" -#define NID_pbe_WithSHA1And128BitRC2_CBC 148 -#define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids,5L - -#define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" -#define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" -#define NID_pbe_WithSHA1And40BitRC2_CBC 149 -#define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids,6L - -#define OBJ_pkcs12_Version1 OBJ_pkcs12,10L - -#define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1,1L - -#define LN_keyBag "keyBag" -#define NID_keyBag 150 -#define OBJ_keyBag OBJ_pkcs12_BagIds,1L - -#define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" -#define NID_pkcs8ShroudedKeyBag 151 -#define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds,2L - -#define LN_certBag "certBag" -#define NID_certBag 152 -#define OBJ_certBag OBJ_pkcs12_BagIds,3L - -#define LN_crlBag "crlBag" -#define NID_crlBag 153 -#define OBJ_crlBag OBJ_pkcs12_BagIds,4L - -#define LN_secretBag "secretBag" -#define NID_secretBag 154 -#define OBJ_secretBag OBJ_pkcs12_BagIds,5L - -#define LN_safeContentsBag "safeContentsBag" -#define NID_safeContentsBag 155 -#define OBJ_safeContentsBag OBJ_pkcs12_BagIds,6L - -#define SN_md2 "MD2" -#define LN_md2 "md2" -#define NID_md2 3 -#define OBJ_md2 OBJ_rsadsi,2L,2L - -#define SN_md4 "MD4" -#define LN_md4 "md4" -#define NID_md4 257 -#define OBJ_md4 OBJ_rsadsi,2L,4L - -#define SN_md5 "MD5" -#define LN_md5 "md5" -#define NID_md5 4 -#define OBJ_md5 OBJ_rsadsi,2L,5L - -#define SN_md5_sha1 "MD5-SHA1" -#define LN_md5_sha1 "md5-sha1" -#define NID_md5_sha1 114 - -#define LN_hmacWithMD5 "hmacWithMD5" -#define NID_hmacWithMD5 797 -#define OBJ_hmacWithMD5 OBJ_rsadsi,2L,6L - -#define LN_hmacWithSHA1 "hmacWithSHA1" -#define NID_hmacWithSHA1 163 -#define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L - -#define LN_hmacWithSHA224 "hmacWithSHA224" -#define NID_hmacWithSHA224 798 -#define OBJ_hmacWithSHA224 OBJ_rsadsi,2L,8L - -#define LN_hmacWithSHA256 "hmacWithSHA256" -#define NID_hmacWithSHA256 799 -#define OBJ_hmacWithSHA256 OBJ_rsadsi,2L,9L - -#define LN_hmacWithSHA384 "hmacWithSHA384" -#define NID_hmacWithSHA384 800 -#define OBJ_hmacWithSHA384 OBJ_rsadsi,2L,10L - -#define LN_hmacWithSHA512 "hmacWithSHA512" -#define NID_hmacWithSHA512 801 -#define OBJ_hmacWithSHA512 OBJ_rsadsi,2L,11L - -#define SN_rc2_cbc "RC2-CBC" -#define LN_rc2_cbc "rc2-cbc" -#define NID_rc2_cbc 37 -#define OBJ_rc2_cbc OBJ_rsadsi,3L,2L - -#define SN_rc2_ecb "RC2-ECB" -#define LN_rc2_ecb "rc2-ecb" -#define NID_rc2_ecb 38 - -#define SN_rc2_cfb64 "RC2-CFB" -#define LN_rc2_cfb64 "rc2-cfb" -#define NID_rc2_cfb64 39 - -#define SN_rc2_ofb64 "RC2-OFB" -#define LN_rc2_ofb64 "rc2-ofb" -#define NID_rc2_ofb64 40 - -#define SN_rc2_40_cbc "RC2-40-CBC" -#define LN_rc2_40_cbc "rc2-40-cbc" -#define NID_rc2_40_cbc 98 - -#define SN_rc2_64_cbc "RC2-64-CBC" -#define LN_rc2_64_cbc "rc2-64-cbc" -#define NID_rc2_64_cbc 166 - -#define SN_rc4 "RC4" -#define LN_rc4 "rc4" -#define NID_rc4 5 -#define OBJ_rc4 OBJ_rsadsi,3L,4L - -#define SN_rc4_40 "RC4-40" -#define LN_rc4_40 "rc4-40" -#define NID_rc4_40 97 - -#define SN_des_ede3_cbc "DES-EDE3-CBC" -#define LN_des_ede3_cbc "des-ede3-cbc" -#define NID_des_ede3_cbc 44 -#define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L - -#define SN_rc5_cbc "RC5-CBC" -#define LN_rc5_cbc "rc5-cbc" -#define NID_rc5_cbc 120 -#define OBJ_rc5_cbc OBJ_rsadsi,3L,8L - -#define SN_rc5_ecb "RC5-ECB" -#define LN_rc5_ecb "rc5-ecb" -#define NID_rc5_ecb 121 - -#define SN_rc5_cfb64 "RC5-CFB" -#define LN_rc5_cfb64 "rc5-cfb" -#define NID_rc5_cfb64 122 - -#define SN_rc5_ofb64 "RC5-OFB" -#define LN_rc5_ofb64 "rc5-ofb" -#define NID_rc5_ofb64 123 - -#define SN_ms_ext_req "msExtReq" -#define LN_ms_ext_req "Microsoft Extension Request" -#define NID_ms_ext_req 171 -#define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L - -#define SN_ms_code_ind "msCodeInd" -#define LN_ms_code_ind "Microsoft Individual Code Signing" -#define NID_ms_code_ind 134 -#define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L - -#define SN_ms_code_com "msCodeCom" -#define LN_ms_code_com "Microsoft Commercial Code Signing" -#define NID_ms_code_com 135 -#define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L - -#define SN_ms_ctl_sign "msCTLSign" -#define LN_ms_ctl_sign "Microsoft Trust List Signing" -#define NID_ms_ctl_sign 136 -#define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L - -#define SN_ms_sgc "msSGC" -#define LN_ms_sgc "Microsoft Server Gated Crypto" -#define NID_ms_sgc 137 -#define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L - -#define SN_ms_efs "msEFS" -#define LN_ms_efs "Microsoft Encrypted File System" -#define NID_ms_efs 138 -#define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L - -#define SN_ms_smartcard_login "msSmartcardLogin" -#define LN_ms_smartcard_login "Microsoft Smartcardlogin" -#define NID_ms_smartcard_login 648 -#define OBJ_ms_smartcard_login 1L,3L,6L,1L,4L,1L,311L,20L,2L,2L - -#define SN_ms_upn "msUPN" -#define LN_ms_upn "Microsoft Universal Principal Name" -#define NID_ms_upn 649 -#define OBJ_ms_upn 1L,3L,6L,1L,4L,1L,311L,20L,2L,3L - -#define SN_idea_cbc "IDEA-CBC" -#define LN_idea_cbc "idea-cbc" -#define NID_idea_cbc 34 -#define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L - -#define SN_idea_ecb "IDEA-ECB" -#define LN_idea_ecb "idea-ecb" -#define NID_idea_ecb 36 - -#define SN_idea_cfb64 "IDEA-CFB" -#define LN_idea_cfb64 "idea-cfb" -#define NID_idea_cfb64 35 - -#define SN_idea_ofb64 "IDEA-OFB" -#define LN_idea_ofb64 "idea-ofb" -#define NID_idea_ofb64 46 - -#define SN_bf_cbc "BF-CBC" -#define LN_bf_cbc "bf-cbc" -#define NID_bf_cbc 91 -#define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L - -#define SN_bf_ecb "BF-ECB" -#define LN_bf_ecb "bf-ecb" -#define NID_bf_ecb 92 - -#define SN_bf_cfb64 "BF-CFB" -#define LN_bf_cfb64 "bf-cfb" -#define NID_bf_cfb64 93 - -#define SN_bf_ofb64 "BF-OFB" -#define LN_bf_ofb64 "bf-ofb" -#define NID_bf_ofb64 94 - -#define SN_id_pkix "PKIX" -#define NID_id_pkix 127 -#define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L - -#define SN_id_pkix_mod "id-pkix-mod" -#define NID_id_pkix_mod 258 -#define OBJ_id_pkix_mod OBJ_id_pkix,0L - -#define SN_id_pe "id-pe" -#define NID_id_pe 175 -#define OBJ_id_pe OBJ_id_pkix,1L - -#define SN_id_qt "id-qt" -#define NID_id_qt 259 -#define OBJ_id_qt OBJ_id_pkix,2L - -#define SN_id_kp "id-kp" -#define NID_id_kp 128 -#define OBJ_id_kp OBJ_id_pkix,3L - -#define SN_id_it "id-it" -#define NID_id_it 260 -#define OBJ_id_it OBJ_id_pkix,4L - -#define SN_id_pkip "id-pkip" -#define NID_id_pkip 261 -#define OBJ_id_pkip OBJ_id_pkix,5L - -#define SN_id_alg "id-alg" -#define NID_id_alg 262 -#define OBJ_id_alg OBJ_id_pkix,6L - -#define SN_id_cmc "id-cmc" -#define NID_id_cmc 263 -#define OBJ_id_cmc OBJ_id_pkix,7L - -#define SN_id_on "id-on" -#define NID_id_on 264 -#define OBJ_id_on OBJ_id_pkix,8L - -#define SN_id_pda "id-pda" -#define NID_id_pda 265 -#define OBJ_id_pda OBJ_id_pkix,9L - -#define SN_id_aca "id-aca" -#define NID_id_aca 266 -#define OBJ_id_aca OBJ_id_pkix,10L - -#define SN_id_qcs "id-qcs" -#define NID_id_qcs 267 -#define OBJ_id_qcs OBJ_id_pkix,11L - -#define SN_id_cct "id-cct" -#define NID_id_cct 268 -#define OBJ_id_cct OBJ_id_pkix,12L - -#define SN_id_ppl "id-ppl" -#define NID_id_ppl 662 -#define OBJ_id_ppl OBJ_id_pkix,21L - -#define SN_id_ad "id-ad" -#define NID_id_ad 176 -#define OBJ_id_ad OBJ_id_pkix,48L - -#define SN_id_pkix1_explicit_88 "id-pkix1-explicit-88" -#define NID_id_pkix1_explicit_88 269 -#define OBJ_id_pkix1_explicit_88 OBJ_id_pkix_mod,1L - -#define SN_id_pkix1_implicit_88 "id-pkix1-implicit-88" -#define NID_id_pkix1_implicit_88 270 -#define OBJ_id_pkix1_implicit_88 OBJ_id_pkix_mod,2L - -#define SN_id_pkix1_explicit_93 "id-pkix1-explicit-93" -#define NID_id_pkix1_explicit_93 271 -#define OBJ_id_pkix1_explicit_93 OBJ_id_pkix_mod,3L - -#define SN_id_pkix1_implicit_93 "id-pkix1-implicit-93" -#define NID_id_pkix1_implicit_93 272 -#define OBJ_id_pkix1_implicit_93 OBJ_id_pkix_mod,4L - -#define SN_id_mod_crmf "id-mod-crmf" -#define NID_id_mod_crmf 273 -#define OBJ_id_mod_crmf OBJ_id_pkix_mod,5L - -#define SN_id_mod_cmc "id-mod-cmc" -#define NID_id_mod_cmc 274 -#define OBJ_id_mod_cmc OBJ_id_pkix_mod,6L - -#define SN_id_mod_kea_profile_88 "id-mod-kea-profile-88" -#define NID_id_mod_kea_profile_88 275 -#define OBJ_id_mod_kea_profile_88 OBJ_id_pkix_mod,7L - -#define SN_id_mod_kea_profile_93 "id-mod-kea-profile-93" -#define NID_id_mod_kea_profile_93 276 -#define OBJ_id_mod_kea_profile_93 OBJ_id_pkix_mod,8L - -#define SN_id_mod_cmp "id-mod-cmp" -#define NID_id_mod_cmp 277 -#define OBJ_id_mod_cmp OBJ_id_pkix_mod,9L - -#define SN_id_mod_qualified_cert_88 "id-mod-qualified-cert-88" -#define NID_id_mod_qualified_cert_88 278 -#define OBJ_id_mod_qualified_cert_88 OBJ_id_pkix_mod,10L - -#define SN_id_mod_qualified_cert_93 "id-mod-qualified-cert-93" -#define NID_id_mod_qualified_cert_93 279 -#define OBJ_id_mod_qualified_cert_93 OBJ_id_pkix_mod,11L - -#define SN_id_mod_attribute_cert "id-mod-attribute-cert" -#define NID_id_mod_attribute_cert 280 -#define OBJ_id_mod_attribute_cert OBJ_id_pkix_mod,12L - -#define SN_id_mod_timestamp_protocol "id-mod-timestamp-protocol" -#define NID_id_mod_timestamp_protocol 281 -#define OBJ_id_mod_timestamp_protocol OBJ_id_pkix_mod,13L - -#define SN_id_mod_ocsp "id-mod-ocsp" -#define NID_id_mod_ocsp 282 -#define OBJ_id_mod_ocsp OBJ_id_pkix_mod,14L - -#define SN_id_mod_dvcs "id-mod-dvcs" -#define NID_id_mod_dvcs 283 -#define OBJ_id_mod_dvcs OBJ_id_pkix_mod,15L - -#define SN_id_mod_cmp2000 "id-mod-cmp2000" -#define NID_id_mod_cmp2000 284 -#define OBJ_id_mod_cmp2000 OBJ_id_pkix_mod,16L - -#define SN_info_access "authorityInfoAccess" -#define LN_info_access "Authority Information Access" -#define NID_info_access 177 -#define OBJ_info_access OBJ_id_pe,1L - -#define SN_biometricInfo "biometricInfo" -#define LN_biometricInfo "Biometric Info" -#define NID_biometricInfo 285 -#define OBJ_biometricInfo OBJ_id_pe,2L - -#define SN_qcStatements "qcStatements" -#define NID_qcStatements 286 -#define OBJ_qcStatements OBJ_id_pe,3L - -#define SN_ac_auditEntity "ac-auditEntity" -#define NID_ac_auditEntity 287 -#define OBJ_ac_auditEntity OBJ_id_pe,4L - -#define SN_ac_targeting "ac-targeting" -#define NID_ac_targeting 288 -#define OBJ_ac_targeting OBJ_id_pe,5L - -#define SN_aaControls "aaControls" -#define NID_aaControls 289 -#define OBJ_aaControls OBJ_id_pe,6L - -#define SN_sbgp_ipAddrBlock "sbgp-ipAddrBlock" -#define NID_sbgp_ipAddrBlock 290 -#define OBJ_sbgp_ipAddrBlock OBJ_id_pe,7L - -#define SN_sbgp_autonomousSysNum "sbgp-autonomousSysNum" -#define NID_sbgp_autonomousSysNum 291 -#define OBJ_sbgp_autonomousSysNum OBJ_id_pe,8L - -#define SN_sbgp_routerIdentifier "sbgp-routerIdentifier" -#define NID_sbgp_routerIdentifier 292 -#define OBJ_sbgp_routerIdentifier OBJ_id_pe,9L - -#define SN_ac_proxying "ac-proxying" -#define NID_ac_proxying 397 -#define OBJ_ac_proxying OBJ_id_pe,10L - -#define SN_sinfo_access "subjectInfoAccess" -#define LN_sinfo_access "Subject Information Access" -#define NID_sinfo_access 398 -#define OBJ_sinfo_access OBJ_id_pe,11L - -#define SN_proxyCertInfo "proxyCertInfo" -#define LN_proxyCertInfo "Proxy Certificate Information" -#define NID_proxyCertInfo 663 -#define OBJ_proxyCertInfo OBJ_id_pe,14L - -#define SN_tlsfeature "tlsfeature" -#define LN_tlsfeature "TLS Feature" -#define NID_tlsfeature 1020 -#define OBJ_tlsfeature OBJ_id_pe,24L - -#define SN_id_qt_cps "id-qt-cps" -#define LN_id_qt_cps "Policy Qualifier CPS" -#define NID_id_qt_cps 164 -#define OBJ_id_qt_cps OBJ_id_qt,1L - -#define SN_id_qt_unotice "id-qt-unotice" -#define LN_id_qt_unotice "Policy Qualifier User Notice" -#define NID_id_qt_unotice 165 -#define OBJ_id_qt_unotice OBJ_id_qt,2L - -#define SN_textNotice "textNotice" -#define NID_textNotice 293 -#define OBJ_textNotice OBJ_id_qt,3L - -#define SN_server_auth "serverAuth" -#define LN_server_auth "TLS Web Server Authentication" -#define NID_server_auth 129 -#define OBJ_server_auth OBJ_id_kp,1L - -#define SN_client_auth "clientAuth" -#define LN_client_auth "TLS Web Client Authentication" -#define NID_client_auth 130 -#define OBJ_client_auth OBJ_id_kp,2L - -#define SN_code_sign "codeSigning" -#define LN_code_sign "Code Signing" -#define NID_code_sign 131 -#define OBJ_code_sign OBJ_id_kp,3L - -#define SN_email_protect "emailProtection" -#define LN_email_protect "E-mail Protection" -#define NID_email_protect 132 -#define OBJ_email_protect OBJ_id_kp,4L - -#define SN_ipsecEndSystem "ipsecEndSystem" -#define LN_ipsecEndSystem "IPSec End System" -#define NID_ipsecEndSystem 294 -#define OBJ_ipsecEndSystem OBJ_id_kp,5L - -#define SN_ipsecTunnel "ipsecTunnel" -#define LN_ipsecTunnel "IPSec Tunnel" -#define NID_ipsecTunnel 295 -#define OBJ_ipsecTunnel OBJ_id_kp,6L - -#define SN_ipsecUser "ipsecUser" -#define LN_ipsecUser "IPSec User" -#define NID_ipsecUser 296 -#define OBJ_ipsecUser OBJ_id_kp,7L - -#define SN_time_stamp "timeStamping" -#define LN_time_stamp "Time Stamping" -#define NID_time_stamp 133 -#define OBJ_time_stamp OBJ_id_kp,8L - -#define SN_OCSP_sign "OCSPSigning" -#define LN_OCSP_sign "OCSP Signing" -#define NID_OCSP_sign 180 -#define OBJ_OCSP_sign OBJ_id_kp,9L - -#define SN_dvcs "DVCS" -#define LN_dvcs "dvcs" -#define NID_dvcs 297 -#define OBJ_dvcs OBJ_id_kp,10L - -#define SN_ipsec_IKE "ipsecIKE" -#define LN_ipsec_IKE "ipsec Internet Key Exchange" -#define NID_ipsec_IKE 1022 -#define OBJ_ipsec_IKE OBJ_id_kp,17L - -#define SN_capwapAC "capwapAC" -#define LN_capwapAC "Ctrl/provision WAP Access" -#define NID_capwapAC 1023 -#define OBJ_capwapAC OBJ_id_kp,18L - -#define SN_capwapWTP "capwapWTP" -#define LN_capwapWTP "Ctrl/Provision WAP Termination" -#define NID_capwapWTP 1024 -#define OBJ_capwapWTP OBJ_id_kp,19L - -#define SN_sshClient "secureShellClient" -#define LN_sshClient "SSH Client" -#define NID_sshClient 1025 -#define OBJ_sshClient OBJ_id_kp,21L - -#define SN_sshServer "secureShellServer" -#define LN_sshServer "SSH Server" -#define NID_sshServer 1026 -#define OBJ_sshServer OBJ_id_kp,22L - -#define SN_sendRouter "sendRouter" -#define LN_sendRouter "Send Router" -#define NID_sendRouter 1027 -#define OBJ_sendRouter OBJ_id_kp,23L - -#define SN_sendProxiedRouter "sendProxiedRouter" -#define LN_sendProxiedRouter "Send Proxied Router" -#define NID_sendProxiedRouter 1028 -#define OBJ_sendProxiedRouter OBJ_id_kp,24L - -#define SN_sendOwner "sendOwner" -#define LN_sendOwner "Send Owner" -#define NID_sendOwner 1029 -#define OBJ_sendOwner OBJ_id_kp,25L - -#define SN_sendProxiedOwner "sendProxiedOwner" -#define LN_sendProxiedOwner "Send Proxied Owner" -#define NID_sendProxiedOwner 1030 -#define OBJ_sendProxiedOwner OBJ_id_kp,26L - -#define SN_id_it_caProtEncCert "id-it-caProtEncCert" -#define NID_id_it_caProtEncCert 298 -#define OBJ_id_it_caProtEncCert OBJ_id_it,1L - -#define SN_id_it_signKeyPairTypes "id-it-signKeyPairTypes" -#define NID_id_it_signKeyPairTypes 299 -#define OBJ_id_it_signKeyPairTypes OBJ_id_it,2L - -#define SN_id_it_encKeyPairTypes "id-it-encKeyPairTypes" -#define NID_id_it_encKeyPairTypes 300 -#define OBJ_id_it_encKeyPairTypes OBJ_id_it,3L - -#define SN_id_it_preferredSymmAlg "id-it-preferredSymmAlg" -#define NID_id_it_preferredSymmAlg 301 -#define OBJ_id_it_preferredSymmAlg OBJ_id_it,4L - -#define SN_id_it_caKeyUpdateInfo "id-it-caKeyUpdateInfo" -#define NID_id_it_caKeyUpdateInfo 302 -#define OBJ_id_it_caKeyUpdateInfo OBJ_id_it,5L - -#define SN_id_it_currentCRL "id-it-currentCRL" -#define NID_id_it_currentCRL 303 -#define OBJ_id_it_currentCRL OBJ_id_it,6L - -#define SN_id_it_unsupportedOIDs "id-it-unsupportedOIDs" -#define NID_id_it_unsupportedOIDs 304 -#define OBJ_id_it_unsupportedOIDs OBJ_id_it,7L - -#define SN_id_it_subscriptionRequest "id-it-subscriptionRequest" -#define NID_id_it_subscriptionRequest 305 -#define OBJ_id_it_subscriptionRequest OBJ_id_it,8L - -#define SN_id_it_subscriptionResponse "id-it-subscriptionResponse" -#define NID_id_it_subscriptionResponse 306 -#define OBJ_id_it_subscriptionResponse OBJ_id_it,9L - -#define SN_id_it_keyPairParamReq "id-it-keyPairParamReq" -#define NID_id_it_keyPairParamReq 307 -#define OBJ_id_it_keyPairParamReq OBJ_id_it,10L - -#define SN_id_it_keyPairParamRep "id-it-keyPairParamRep" -#define NID_id_it_keyPairParamRep 308 -#define OBJ_id_it_keyPairParamRep OBJ_id_it,11L - -#define SN_id_it_revPassphrase "id-it-revPassphrase" -#define NID_id_it_revPassphrase 309 -#define OBJ_id_it_revPassphrase OBJ_id_it,12L - -#define SN_id_it_implicitConfirm "id-it-implicitConfirm" -#define NID_id_it_implicitConfirm 310 -#define OBJ_id_it_implicitConfirm OBJ_id_it,13L - -#define SN_id_it_confirmWaitTime "id-it-confirmWaitTime" -#define NID_id_it_confirmWaitTime 311 -#define OBJ_id_it_confirmWaitTime OBJ_id_it,14L - -#define SN_id_it_origPKIMessage "id-it-origPKIMessage" -#define NID_id_it_origPKIMessage 312 -#define OBJ_id_it_origPKIMessage OBJ_id_it,15L - -#define SN_id_it_suppLangTags "id-it-suppLangTags" -#define NID_id_it_suppLangTags 784 -#define OBJ_id_it_suppLangTags OBJ_id_it,16L - -#define SN_id_regCtrl "id-regCtrl" -#define NID_id_regCtrl 313 -#define OBJ_id_regCtrl OBJ_id_pkip,1L - -#define SN_id_regInfo "id-regInfo" -#define NID_id_regInfo 314 -#define OBJ_id_regInfo OBJ_id_pkip,2L - -#define SN_id_regCtrl_regToken "id-regCtrl-regToken" -#define NID_id_regCtrl_regToken 315 -#define OBJ_id_regCtrl_regToken OBJ_id_regCtrl,1L - -#define SN_id_regCtrl_authenticator "id-regCtrl-authenticator" -#define NID_id_regCtrl_authenticator 316 -#define OBJ_id_regCtrl_authenticator OBJ_id_regCtrl,2L - -#define SN_id_regCtrl_pkiPublicationInfo "id-regCtrl-pkiPublicationInfo" -#define NID_id_regCtrl_pkiPublicationInfo 317 -#define OBJ_id_regCtrl_pkiPublicationInfo OBJ_id_regCtrl,3L - -#define SN_id_regCtrl_pkiArchiveOptions "id-regCtrl-pkiArchiveOptions" -#define NID_id_regCtrl_pkiArchiveOptions 318 -#define OBJ_id_regCtrl_pkiArchiveOptions OBJ_id_regCtrl,4L - -#define SN_id_regCtrl_oldCertID "id-regCtrl-oldCertID" -#define NID_id_regCtrl_oldCertID 319 -#define OBJ_id_regCtrl_oldCertID OBJ_id_regCtrl,5L - -#define SN_id_regCtrl_protocolEncrKey "id-regCtrl-protocolEncrKey" -#define NID_id_regCtrl_protocolEncrKey 320 -#define OBJ_id_regCtrl_protocolEncrKey OBJ_id_regCtrl,6L - -#define SN_id_regInfo_utf8Pairs "id-regInfo-utf8Pairs" -#define NID_id_regInfo_utf8Pairs 321 -#define OBJ_id_regInfo_utf8Pairs OBJ_id_regInfo,1L - -#define SN_id_regInfo_certReq "id-regInfo-certReq" -#define NID_id_regInfo_certReq 322 -#define OBJ_id_regInfo_certReq OBJ_id_regInfo,2L - -#define SN_id_alg_des40 "id-alg-des40" -#define NID_id_alg_des40 323 -#define OBJ_id_alg_des40 OBJ_id_alg,1L - -#define SN_id_alg_noSignature "id-alg-noSignature" -#define NID_id_alg_noSignature 324 -#define OBJ_id_alg_noSignature OBJ_id_alg,2L - -#define SN_id_alg_dh_sig_hmac_sha1 "id-alg-dh-sig-hmac-sha1" -#define NID_id_alg_dh_sig_hmac_sha1 325 -#define OBJ_id_alg_dh_sig_hmac_sha1 OBJ_id_alg,3L - -#define SN_id_alg_dh_pop "id-alg-dh-pop" -#define NID_id_alg_dh_pop 326 -#define OBJ_id_alg_dh_pop OBJ_id_alg,4L - -#define SN_id_cmc_statusInfo "id-cmc-statusInfo" -#define NID_id_cmc_statusInfo 327 -#define OBJ_id_cmc_statusInfo OBJ_id_cmc,1L - -#define SN_id_cmc_identification "id-cmc-identification" -#define NID_id_cmc_identification 328 -#define OBJ_id_cmc_identification OBJ_id_cmc,2L - -#define SN_id_cmc_identityProof "id-cmc-identityProof" -#define NID_id_cmc_identityProof 329 -#define OBJ_id_cmc_identityProof OBJ_id_cmc,3L - -#define SN_id_cmc_dataReturn "id-cmc-dataReturn" -#define NID_id_cmc_dataReturn 330 -#define OBJ_id_cmc_dataReturn OBJ_id_cmc,4L - -#define SN_id_cmc_transactionId "id-cmc-transactionId" -#define NID_id_cmc_transactionId 331 -#define OBJ_id_cmc_transactionId OBJ_id_cmc,5L - -#define SN_id_cmc_senderNonce "id-cmc-senderNonce" -#define NID_id_cmc_senderNonce 332 -#define OBJ_id_cmc_senderNonce OBJ_id_cmc,6L - -#define SN_id_cmc_recipientNonce "id-cmc-recipientNonce" -#define NID_id_cmc_recipientNonce 333 -#define OBJ_id_cmc_recipientNonce OBJ_id_cmc,7L - -#define SN_id_cmc_addExtensions "id-cmc-addExtensions" -#define NID_id_cmc_addExtensions 334 -#define OBJ_id_cmc_addExtensions OBJ_id_cmc,8L - -#define SN_id_cmc_encryptedPOP "id-cmc-encryptedPOP" -#define NID_id_cmc_encryptedPOP 335 -#define OBJ_id_cmc_encryptedPOP OBJ_id_cmc,9L - -#define SN_id_cmc_decryptedPOP "id-cmc-decryptedPOP" -#define NID_id_cmc_decryptedPOP 336 -#define OBJ_id_cmc_decryptedPOP OBJ_id_cmc,10L - -#define SN_id_cmc_lraPOPWitness "id-cmc-lraPOPWitness" -#define NID_id_cmc_lraPOPWitness 337 -#define OBJ_id_cmc_lraPOPWitness OBJ_id_cmc,11L - -#define SN_id_cmc_getCert "id-cmc-getCert" -#define NID_id_cmc_getCert 338 -#define OBJ_id_cmc_getCert OBJ_id_cmc,15L - -#define SN_id_cmc_getCRL "id-cmc-getCRL" -#define NID_id_cmc_getCRL 339 -#define OBJ_id_cmc_getCRL OBJ_id_cmc,16L - -#define SN_id_cmc_revokeRequest "id-cmc-revokeRequest" -#define NID_id_cmc_revokeRequest 340 -#define OBJ_id_cmc_revokeRequest OBJ_id_cmc,17L - -#define SN_id_cmc_regInfo "id-cmc-regInfo" -#define NID_id_cmc_regInfo 341 -#define OBJ_id_cmc_regInfo OBJ_id_cmc,18L - -#define SN_id_cmc_responseInfo "id-cmc-responseInfo" -#define NID_id_cmc_responseInfo 342 -#define OBJ_id_cmc_responseInfo OBJ_id_cmc,19L - -#define SN_id_cmc_queryPending "id-cmc-queryPending" -#define NID_id_cmc_queryPending 343 -#define OBJ_id_cmc_queryPending OBJ_id_cmc,21L - -#define SN_id_cmc_popLinkRandom "id-cmc-popLinkRandom" -#define NID_id_cmc_popLinkRandom 344 -#define OBJ_id_cmc_popLinkRandom OBJ_id_cmc,22L - -#define SN_id_cmc_popLinkWitness "id-cmc-popLinkWitness" -#define NID_id_cmc_popLinkWitness 345 -#define OBJ_id_cmc_popLinkWitness OBJ_id_cmc,23L - -#define SN_id_cmc_confirmCertAcceptance "id-cmc-confirmCertAcceptance" -#define NID_id_cmc_confirmCertAcceptance 346 -#define OBJ_id_cmc_confirmCertAcceptance OBJ_id_cmc,24L - -#define SN_id_on_personalData "id-on-personalData" -#define NID_id_on_personalData 347 -#define OBJ_id_on_personalData OBJ_id_on,1L - -#define SN_id_on_permanentIdentifier "id-on-permanentIdentifier" -#define LN_id_on_permanentIdentifier "Permanent Identifier" -#define NID_id_on_permanentIdentifier 858 -#define OBJ_id_on_permanentIdentifier OBJ_id_on,3L - -#define SN_id_pda_dateOfBirth "id-pda-dateOfBirth" -#define NID_id_pda_dateOfBirth 348 -#define OBJ_id_pda_dateOfBirth OBJ_id_pda,1L - -#define SN_id_pda_placeOfBirth "id-pda-placeOfBirth" -#define NID_id_pda_placeOfBirth 349 -#define OBJ_id_pda_placeOfBirth OBJ_id_pda,2L - -#define SN_id_pda_gender "id-pda-gender" -#define NID_id_pda_gender 351 -#define OBJ_id_pda_gender OBJ_id_pda,3L - -#define SN_id_pda_countryOfCitizenship "id-pda-countryOfCitizenship" -#define NID_id_pda_countryOfCitizenship 352 -#define OBJ_id_pda_countryOfCitizenship OBJ_id_pda,4L - -#define SN_id_pda_countryOfResidence "id-pda-countryOfResidence" -#define NID_id_pda_countryOfResidence 353 -#define OBJ_id_pda_countryOfResidence OBJ_id_pda,5L - -#define SN_id_aca_authenticationInfo "id-aca-authenticationInfo" -#define NID_id_aca_authenticationInfo 354 -#define OBJ_id_aca_authenticationInfo OBJ_id_aca,1L - -#define SN_id_aca_accessIdentity "id-aca-accessIdentity" -#define NID_id_aca_accessIdentity 355 -#define OBJ_id_aca_accessIdentity OBJ_id_aca,2L - -#define SN_id_aca_chargingIdentity "id-aca-chargingIdentity" -#define NID_id_aca_chargingIdentity 356 -#define OBJ_id_aca_chargingIdentity OBJ_id_aca,3L - -#define SN_id_aca_group "id-aca-group" -#define NID_id_aca_group 357 -#define OBJ_id_aca_group OBJ_id_aca,4L - -#define SN_id_aca_role "id-aca-role" -#define NID_id_aca_role 358 -#define OBJ_id_aca_role OBJ_id_aca,5L - -#define SN_id_aca_encAttrs "id-aca-encAttrs" -#define NID_id_aca_encAttrs 399 -#define OBJ_id_aca_encAttrs OBJ_id_aca,6L - -#define SN_id_qcs_pkixQCSyntax_v1 "id-qcs-pkixQCSyntax-v1" -#define NID_id_qcs_pkixQCSyntax_v1 359 -#define OBJ_id_qcs_pkixQCSyntax_v1 OBJ_id_qcs,1L - -#define SN_id_cct_crs "id-cct-crs" -#define NID_id_cct_crs 360 -#define OBJ_id_cct_crs OBJ_id_cct,1L - -#define SN_id_cct_PKIData "id-cct-PKIData" -#define NID_id_cct_PKIData 361 -#define OBJ_id_cct_PKIData OBJ_id_cct,2L - -#define SN_id_cct_PKIResponse "id-cct-PKIResponse" -#define NID_id_cct_PKIResponse 362 -#define OBJ_id_cct_PKIResponse OBJ_id_cct,3L - -#define SN_id_ppl_anyLanguage "id-ppl-anyLanguage" -#define LN_id_ppl_anyLanguage "Any language" -#define NID_id_ppl_anyLanguage 664 -#define OBJ_id_ppl_anyLanguage OBJ_id_ppl,0L - -#define SN_id_ppl_inheritAll "id-ppl-inheritAll" -#define LN_id_ppl_inheritAll "Inherit all" -#define NID_id_ppl_inheritAll 665 -#define OBJ_id_ppl_inheritAll OBJ_id_ppl,1L - -#define SN_Independent "id-ppl-independent" -#define LN_Independent "Independent" -#define NID_Independent 667 -#define OBJ_Independent OBJ_id_ppl,2L - -#define SN_ad_OCSP "OCSP" -#define LN_ad_OCSP "OCSP" -#define NID_ad_OCSP 178 -#define OBJ_ad_OCSP OBJ_id_ad,1L - -#define SN_ad_ca_issuers "caIssuers" -#define LN_ad_ca_issuers "CA Issuers" -#define NID_ad_ca_issuers 179 -#define OBJ_ad_ca_issuers OBJ_id_ad,2L - -#define SN_ad_timeStamping "ad_timestamping" -#define LN_ad_timeStamping "AD Time Stamping" -#define NID_ad_timeStamping 363 -#define OBJ_ad_timeStamping OBJ_id_ad,3L - -#define SN_ad_dvcs "AD_DVCS" -#define LN_ad_dvcs "ad dvcs" -#define NID_ad_dvcs 364 -#define OBJ_ad_dvcs OBJ_id_ad,4L - -#define SN_caRepository "caRepository" -#define LN_caRepository "CA Repository" -#define NID_caRepository 785 -#define OBJ_caRepository OBJ_id_ad,5L - -#define OBJ_id_pkix_OCSP OBJ_ad_OCSP - -#define SN_id_pkix_OCSP_basic "basicOCSPResponse" -#define LN_id_pkix_OCSP_basic "Basic OCSP Response" -#define NID_id_pkix_OCSP_basic 365 -#define OBJ_id_pkix_OCSP_basic OBJ_id_pkix_OCSP,1L - -#define SN_id_pkix_OCSP_Nonce "Nonce" -#define LN_id_pkix_OCSP_Nonce "OCSP Nonce" -#define NID_id_pkix_OCSP_Nonce 366 -#define OBJ_id_pkix_OCSP_Nonce OBJ_id_pkix_OCSP,2L - -#define SN_id_pkix_OCSP_CrlID "CrlID" -#define LN_id_pkix_OCSP_CrlID "OCSP CRL ID" -#define NID_id_pkix_OCSP_CrlID 367 -#define OBJ_id_pkix_OCSP_CrlID OBJ_id_pkix_OCSP,3L - -#define SN_id_pkix_OCSP_acceptableResponses "acceptableResponses" -#define LN_id_pkix_OCSP_acceptableResponses "Acceptable OCSP Responses" -#define NID_id_pkix_OCSP_acceptableResponses 368 -#define OBJ_id_pkix_OCSP_acceptableResponses OBJ_id_pkix_OCSP,4L - -#define SN_id_pkix_OCSP_noCheck "noCheck" -#define LN_id_pkix_OCSP_noCheck "OCSP No Check" -#define NID_id_pkix_OCSP_noCheck 369 -#define OBJ_id_pkix_OCSP_noCheck OBJ_id_pkix_OCSP,5L - -#define SN_id_pkix_OCSP_archiveCutoff "archiveCutoff" -#define LN_id_pkix_OCSP_archiveCutoff "OCSP Archive Cutoff" -#define NID_id_pkix_OCSP_archiveCutoff 370 -#define OBJ_id_pkix_OCSP_archiveCutoff OBJ_id_pkix_OCSP,6L - -#define SN_id_pkix_OCSP_serviceLocator "serviceLocator" -#define LN_id_pkix_OCSP_serviceLocator "OCSP Service Locator" -#define NID_id_pkix_OCSP_serviceLocator 371 -#define OBJ_id_pkix_OCSP_serviceLocator OBJ_id_pkix_OCSP,7L - -#define SN_id_pkix_OCSP_extendedStatus "extendedStatus" -#define LN_id_pkix_OCSP_extendedStatus "Extended OCSP Status" -#define NID_id_pkix_OCSP_extendedStatus 372 -#define OBJ_id_pkix_OCSP_extendedStatus OBJ_id_pkix_OCSP,8L - -#define SN_id_pkix_OCSP_valid "valid" -#define NID_id_pkix_OCSP_valid 373 -#define OBJ_id_pkix_OCSP_valid OBJ_id_pkix_OCSP,9L - -#define SN_id_pkix_OCSP_path "path" -#define NID_id_pkix_OCSP_path 374 -#define OBJ_id_pkix_OCSP_path OBJ_id_pkix_OCSP,10L - -#define SN_id_pkix_OCSP_trustRoot "trustRoot" -#define LN_id_pkix_OCSP_trustRoot "Trust Root" -#define NID_id_pkix_OCSP_trustRoot 375 -#define OBJ_id_pkix_OCSP_trustRoot OBJ_id_pkix_OCSP,11L - -#define SN_algorithm "algorithm" -#define LN_algorithm "algorithm" -#define NID_algorithm 376 -#define OBJ_algorithm 1L,3L,14L,3L,2L - -#define SN_md5WithRSA "RSA-NP-MD5" -#define LN_md5WithRSA "md5WithRSA" -#define NID_md5WithRSA 104 -#define OBJ_md5WithRSA OBJ_algorithm,3L - -#define SN_des_ecb "DES-ECB" -#define LN_des_ecb "des-ecb" -#define NID_des_ecb 29 -#define OBJ_des_ecb OBJ_algorithm,6L - -#define SN_des_cbc "DES-CBC" -#define LN_des_cbc "des-cbc" -#define NID_des_cbc 31 -#define OBJ_des_cbc OBJ_algorithm,7L - -#define SN_des_ofb64 "DES-OFB" -#define LN_des_ofb64 "des-ofb" -#define NID_des_ofb64 45 -#define OBJ_des_ofb64 OBJ_algorithm,8L - -#define SN_des_cfb64 "DES-CFB" -#define LN_des_cfb64 "des-cfb" -#define NID_des_cfb64 30 -#define OBJ_des_cfb64 OBJ_algorithm,9L - -#define SN_rsaSignature "rsaSignature" -#define NID_rsaSignature 377 -#define OBJ_rsaSignature OBJ_algorithm,11L - -#define SN_dsa_2 "DSA-old" -#define LN_dsa_2 "dsaEncryption-old" -#define NID_dsa_2 67 -#define OBJ_dsa_2 OBJ_algorithm,12L - -#define SN_dsaWithSHA "DSA-SHA" -#define LN_dsaWithSHA "dsaWithSHA" -#define NID_dsaWithSHA 66 -#define OBJ_dsaWithSHA OBJ_algorithm,13L - -#define SN_shaWithRSAEncryption "RSA-SHA" -#define LN_shaWithRSAEncryption "shaWithRSAEncryption" -#define NID_shaWithRSAEncryption 42 -#define OBJ_shaWithRSAEncryption OBJ_algorithm,15L - -#define SN_des_ede_ecb "DES-EDE" -#define LN_des_ede_ecb "des-ede" -#define NID_des_ede_ecb 32 -#define OBJ_des_ede_ecb OBJ_algorithm,17L - -#define SN_des_ede3_ecb "DES-EDE3" -#define LN_des_ede3_ecb "des-ede3" -#define NID_des_ede3_ecb 33 - -#define SN_des_ede_cbc "DES-EDE-CBC" -#define LN_des_ede_cbc "des-ede-cbc" -#define NID_des_ede_cbc 43 - -#define SN_des_ede_cfb64 "DES-EDE-CFB" -#define LN_des_ede_cfb64 "des-ede-cfb" -#define NID_des_ede_cfb64 60 - -#define SN_des_ede3_cfb64 "DES-EDE3-CFB" -#define LN_des_ede3_cfb64 "des-ede3-cfb" -#define NID_des_ede3_cfb64 61 - -#define SN_des_ede_ofb64 "DES-EDE-OFB" -#define LN_des_ede_ofb64 "des-ede-ofb" -#define NID_des_ede_ofb64 62 - -#define SN_des_ede3_ofb64 "DES-EDE3-OFB" -#define LN_des_ede3_ofb64 "des-ede3-ofb" -#define NID_des_ede3_ofb64 63 - -#define SN_desx_cbc "DESX-CBC" -#define LN_desx_cbc "desx-cbc" -#define NID_desx_cbc 80 - -#define SN_sha "SHA" -#define LN_sha "sha" -#define NID_sha 41 -#define OBJ_sha OBJ_algorithm,18L - -#define SN_sha1 "SHA1" -#define LN_sha1 "sha1" -#define NID_sha1 64 -#define OBJ_sha1 OBJ_algorithm,26L - -#define SN_dsaWithSHA1_2 "DSA-SHA1-old" -#define LN_dsaWithSHA1_2 "dsaWithSHA1-old" -#define NID_dsaWithSHA1_2 70 -#define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L - -#define SN_sha1WithRSA "RSA-SHA1-2" -#define LN_sha1WithRSA "sha1WithRSA" -#define NID_sha1WithRSA 115 -#define OBJ_sha1WithRSA OBJ_algorithm,29L - -#define SN_ripemd160 "RIPEMD160" -#define LN_ripemd160 "ripemd160" -#define NID_ripemd160 117 -#define OBJ_ripemd160 1L,3L,36L,3L,2L,1L - -#define SN_ripemd160WithRSA "RSA-RIPEMD160" -#define LN_ripemd160WithRSA "ripemd160WithRSA" -#define NID_ripemd160WithRSA 119 -#define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L - -#define SN_blake2b512 "BLAKE2b512" -#define LN_blake2b512 "blake2b512" -#define NID_blake2b512 1056 -#define OBJ_blake2b512 1L,3L,6L,1L,4L,1L,1722L,12L,2L,1L,16L - -#define SN_blake2s256 "BLAKE2s256" -#define LN_blake2s256 "blake2s256" -#define NID_blake2s256 1057 -#define OBJ_blake2s256 1L,3L,6L,1L,4L,1L,1722L,12L,2L,2L,8L - -#define SN_sxnet "SXNetID" -#define LN_sxnet "Strong Extranet ID" -#define NID_sxnet 143 -#define OBJ_sxnet 1L,3L,101L,1L,4L,1L - -#define SN_X500 "X500" -#define LN_X500 "directory services (X.500)" -#define NID_X500 11 -#define OBJ_X500 2L,5L - -#define SN_X509 "X509" -#define NID_X509 12 -#define OBJ_X509 OBJ_X500,4L - -#define SN_commonName "CN" -#define LN_commonName "commonName" -#define NID_commonName 13 -#define OBJ_commonName OBJ_X509,3L - -#define SN_surname "SN" -#define LN_surname "surname" -#define NID_surname 100 -#define OBJ_surname OBJ_X509,4L - -#define LN_serialNumber "serialNumber" -#define NID_serialNumber 105 -#define OBJ_serialNumber OBJ_X509,5L - -#define SN_countryName "C" -#define LN_countryName "countryName" -#define NID_countryName 14 -#define OBJ_countryName OBJ_X509,6L - -#define SN_localityName "L" -#define LN_localityName "localityName" -#define NID_localityName 15 -#define OBJ_localityName OBJ_X509,7L - -#define SN_stateOrProvinceName "ST" -#define LN_stateOrProvinceName "stateOrProvinceName" -#define NID_stateOrProvinceName 16 -#define OBJ_stateOrProvinceName OBJ_X509,8L - -#define SN_streetAddress "street" -#define LN_streetAddress "streetAddress" -#define NID_streetAddress 660 -#define OBJ_streetAddress OBJ_X509,9L - -#define SN_organizationName "O" -#define LN_organizationName "organizationName" -#define NID_organizationName 17 -#define OBJ_organizationName OBJ_X509,10L - -#define SN_organizationalUnitName "OU" -#define LN_organizationalUnitName "organizationalUnitName" -#define NID_organizationalUnitName 18 -#define OBJ_organizationalUnitName OBJ_X509,11L - -#define SN_title "title" -#define LN_title "title" -#define NID_title 106 -#define OBJ_title OBJ_X509,12L - -#define LN_description "description" -#define NID_description 107 -#define OBJ_description OBJ_X509,13L - -#define LN_searchGuide "searchGuide" -#define NID_searchGuide 859 -#define OBJ_searchGuide OBJ_X509,14L - -#define LN_businessCategory "businessCategory" -#define NID_businessCategory 860 -#define OBJ_businessCategory OBJ_X509,15L - -#define LN_postalAddress "postalAddress" -#define NID_postalAddress 861 -#define OBJ_postalAddress OBJ_X509,16L - -#define LN_postalCode "postalCode" -#define NID_postalCode 661 -#define OBJ_postalCode OBJ_X509,17L - -#define LN_postOfficeBox "postOfficeBox" -#define NID_postOfficeBox 862 -#define OBJ_postOfficeBox OBJ_X509,18L - -#define LN_physicalDeliveryOfficeName "physicalDeliveryOfficeName" -#define NID_physicalDeliveryOfficeName 863 -#define OBJ_physicalDeliveryOfficeName OBJ_X509,19L - -#define LN_telephoneNumber "telephoneNumber" -#define NID_telephoneNumber 864 -#define OBJ_telephoneNumber OBJ_X509,20L - -#define LN_telexNumber "telexNumber" -#define NID_telexNumber 865 -#define OBJ_telexNumber OBJ_X509,21L - -#define LN_teletexTerminalIdentifier "teletexTerminalIdentifier" -#define NID_teletexTerminalIdentifier 866 -#define OBJ_teletexTerminalIdentifier OBJ_X509,22L - -#define LN_facsimileTelephoneNumber "facsimileTelephoneNumber" -#define NID_facsimileTelephoneNumber 867 -#define OBJ_facsimileTelephoneNumber OBJ_X509,23L - -#define LN_x121Address "x121Address" -#define NID_x121Address 868 -#define OBJ_x121Address OBJ_X509,24L - -#define LN_internationaliSDNNumber "internationaliSDNNumber" -#define NID_internationaliSDNNumber 869 -#define OBJ_internationaliSDNNumber OBJ_X509,25L - -#define LN_registeredAddress "registeredAddress" -#define NID_registeredAddress 870 -#define OBJ_registeredAddress OBJ_X509,26L - -#define LN_destinationIndicator "destinationIndicator" -#define NID_destinationIndicator 871 -#define OBJ_destinationIndicator OBJ_X509,27L - -#define LN_preferredDeliveryMethod "preferredDeliveryMethod" -#define NID_preferredDeliveryMethod 872 -#define OBJ_preferredDeliveryMethod OBJ_X509,28L - -#define LN_presentationAddress "presentationAddress" -#define NID_presentationAddress 873 -#define OBJ_presentationAddress OBJ_X509,29L - -#define LN_supportedApplicationContext "supportedApplicationContext" -#define NID_supportedApplicationContext 874 -#define OBJ_supportedApplicationContext OBJ_X509,30L - -#define SN_member "member" -#define NID_member 875 -#define OBJ_member OBJ_X509,31L - -#define SN_owner "owner" -#define NID_owner 876 -#define OBJ_owner OBJ_X509,32L - -#define LN_roleOccupant "roleOccupant" -#define NID_roleOccupant 877 -#define OBJ_roleOccupant OBJ_X509,33L - -#define SN_seeAlso "seeAlso" -#define NID_seeAlso 878 -#define OBJ_seeAlso OBJ_X509,34L - -#define LN_userPassword "userPassword" -#define NID_userPassword 879 -#define OBJ_userPassword OBJ_X509,35L - -#define LN_userCertificate "userCertificate" -#define NID_userCertificate 880 -#define OBJ_userCertificate OBJ_X509,36L - -#define LN_cACertificate "cACertificate" -#define NID_cACertificate 881 -#define OBJ_cACertificate OBJ_X509,37L - -#define LN_authorityRevocationList "authorityRevocationList" -#define NID_authorityRevocationList 882 -#define OBJ_authorityRevocationList OBJ_X509,38L - -#define LN_certificateRevocationList "certificateRevocationList" -#define NID_certificateRevocationList 883 -#define OBJ_certificateRevocationList OBJ_X509,39L - -#define LN_crossCertificatePair "crossCertificatePair" -#define NID_crossCertificatePair 884 -#define OBJ_crossCertificatePair OBJ_X509,40L - -#define SN_name "name" -#define LN_name "name" -#define NID_name 173 -#define OBJ_name OBJ_X509,41L - -#define SN_givenName "GN" -#define LN_givenName "givenName" -#define NID_givenName 99 -#define OBJ_givenName OBJ_X509,42L - -#define SN_initials "initials" -#define LN_initials "initials" -#define NID_initials 101 -#define OBJ_initials OBJ_X509,43L - -#define LN_generationQualifier "generationQualifier" -#define NID_generationQualifier 509 -#define OBJ_generationQualifier OBJ_X509,44L - -#define LN_x500UniqueIdentifier "x500UniqueIdentifier" -#define NID_x500UniqueIdentifier 503 -#define OBJ_x500UniqueIdentifier OBJ_X509,45L - -#define SN_dnQualifier "dnQualifier" -#define LN_dnQualifier "dnQualifier" -#define NID_dnQualifier 174 -#define OBJ_dnQualifier OBJ_X509,46L - -#define LN_enhancedSearchGuide "enhancedSearchGuide" -#define NID_enhancedSearchGuide 885 -#define OBJ_enhancedSearchGuide OBJ_X509,47L - -#define LN_protocolInformation "protocolInformation" -#define NID_protocolInformation 886 -#define OBJ_protocolInformation OBJ_X509,48L - -#define LN_distinguishedName "distinguishedName" -#define NID_distinguishedName 887 -#define OBJ_distinguishedName OBJ_X509,49L - -#define LN_uniqueMember "uniqueMember" -#define NID_uniqueMember 888 -#define OBJ_uniqueMember OBJ_X509,50L - -#define LN_houseIdentifier "houseIdentifier" -#define NID_houseIdentifier 889 -#define OBJ_houseIdentifier OBJ_X509,51L - -#define LN_supportedAlgorithms "supportedAlgorithms" -#define NID_supportedAlgorithms 890 -#define OBJ_supportedAlgorithms OBJ_X509,52L - -#define LN_deltaRevocationList "deltaRevocationList" -#define NID_deltaRevocationList 891 -#define OBJ_deltaRevocationList OBJ_X509,53L - -#define SN_dmdName "dmdName" -#define NID_dmdName 892 -#define OBJ_dmdName OBJ_X509,54L - -#define LN_pseudonym "pseudonym" -#define NID_pseudonym 510 -#define OBJ_pseudonym OBJ_X509,65L - -#define SN_role "role" -#define LN_role "role" -#define NID_role 400 -#define OBJ_role OBJ_X509,72L - -#define SN_X500algorithms "X500algorithms" -#define LN_X500algorithms "directory services - algorithms" -#define NID_X500algorithms 378 -#define OBJ_X500algorithms OBJ_X500,8L - -#define SN_rsa "RSA" -#define LN_rsa "rsa" -#define NID_rsa 19 -#define OBJ_rsa OBJ_X500algorithms,1L,1L - -#define SN_mdc2WithRSA "RSA-MDC2" -#define LN_mdc2WithRSA "mdc2WithRSA" -#define NID_mdc2WithRSA 96 -#define OBJ_mdc2WithRSA OBJ_X500algorithms,3L,100L - -#define SN_mdc2 "MDC2" -#define LN_mdc2 "mdc2" -#define NID_mdc2 95 -#define OBJ_mdc2 OBJ_X500algorithms,3L,101L - -#define SN_id_ce "id-ce" -#define NID_id_ce 81 -#define OBJ_id_ce OBJ_X500,29L - -#define SN_subject_directory_attributes "subjectDirectoryAttributes" -#define LN_subject_directory_attributes "X509v3 Subject Directory Attributes" -#define NID_subject_directory_attributes 769 -#define OBJ_subject_directory_attributes OBJ_id_ce,9L - -#define SN_subject_key_identifier "subjectKeyIdentifier" -#define LN_subject_key_identifier "X509v3 Subject Key Identifier" -#define NID_subject_key_identifier 82 -#define OBJ_subject_key_identifier OBJ_id_ce,14L - -#define SN_key_usage "keyUsage" -#define LN_key_usage "X509v3 Key Usage" -#define NID_key_usage 83 -#define OBJ_key_usage OBJ_id_ce,15L - -#define SN_private_key_usage_period "privateKeyUsagePeriod" -#define LN_private_key_usage_period "X509v3 Private Key Usage Period" -#define NID_private_key_usage_period 84 -#define OBJ_private_key_usage_period OBJ_id_ce,16L - -#define SN_subject_alt_name "subjectAltName" -#define LN_subject_alt_name "X509v3 Subject Alternative Name" -#define NID_subject_alt_name 85 -#define OBJ_subject_alt_name OBJ_id_ce,17L - -#define SN_issuer_alt_name "issuerAltName" -#define LN_issuer_alt_name "X509v3 Issuer Alternative Name" -#define NID_issuer_alt_name 86 -#define OBJ_issuer_alt_name OBJ_id_ce,18L - -#define SN_basic_constraints "basicConstraints" -#define LN_basic_constraints "X509v3 Basic Constraints" -#define NID_basic_constraints 87 -#define OBJ_basic_constraints OBJ_id_ce,19L - -#define SN_crl_number "crlNumber" -#define LN_crl_number "X509v3 CRL Number" -#define NID_crl_number 88 -#define OBJ_crl_number OBJ_id_ce,20L - -#define SN_crl_reason "CRLReason" -#define LN_crl_reason "X509v3 CRL Reason Code" -#define NID_crl_reason 141 -#define OBJ_crl_reason OBJ_id_ce,21L - -#define SN_invalidity_date "invalidityDate" -#define LN_invalidity_date "Invalidity Date" -#define NID_invalidity_date 142 -#define OBJ_invalidity_date OBJ_id_ce,24L - -#define SN_delta_crl "deltaCRL" -#define LN_delta_crl "X509v3 Delta CRL Indicator" -#define NID_delta_crl 140 -#define OBJ_delta_crl OBJ_id_ce,27L - -#define SN_issuing_distribution_point "issuingDistributionPoint" -#define LN_issuing_distribution_point "X509v3 Issuing Distribution Point" -#define NID_issuing_distribution_point 770 -#define OBJ_issuing_distribution_point OBJ_id_ce,28L - -#define SN_certificate_issuer "certificateIssuer" -#define LN_certificate_issuer "X509v3 Certificate Issuer" -#define NID_certificate_issuer 771 -#define OBJ_certificate_issuer OBJ_id_ce,29L - -#define SN_name_constraints "nameConstraints" -#define LN_name_constraints "X509v3 Name Constraints" -#define NID_name_constraints 666 -#define OBJ_name_constraints OBJ_id_ce,30L - -#define SN_crl_distribution_points "crlDistributionPoints" -#define LN_crl_distribution_points "X509v3 CRL Distribution Points" -#define NID_crl_distribution_points 103 -#define OBJ_crl_distribution_points OBJ_id_ce,31L - -#define SN_certificate_policies "certificatePolicies" -#define LN_certificate_policies "X509v3 Certificate Policies" -#define NID_certificate_policies 89 -#define OBJ_certificate_policies OBJ_id_ce,32L - -#define SN_any_policy "anyPolicy" -#define LN_any_policy "X509v3 Any Policy" -#define NID_any_policy 746 -#define OBJ_any_policy OBJ_certificate_policies,0L - -#define SN_policy_mappings "policyMappings" -#define LN_policy_mappings "X509v3 Policy Mappings" -#define NID_policy_mappings 747 -#define OBJ_policy_mappings OBJ_id_ce,33L - -#define SN_authority_key_identifier "authorityKeyIdentifier" -#define LN_authority_key_identifier "X509v3 Authority Key Identifier" -#define NID_authority_key_identifier 90 -#define OBJ_authority_key_identifier OBJ_id_ce,35L - -#define SN_policy_constraints "policyConstraints" -#define LN_policy_constraints "X509v3 Policy Constraints" -#define NID_policy_constraints 401 -#define OBJ_policy_constraints OBJ_id_ce,36L - -#define SN_ext_key_usage "extendedKeyUsage" -#define LN_ext_key_usage "X509v3 Extended Key Usage" -#define NID_ext_key_usage 126 -#define OBJ_ext_key_usage OBJ_id_ce,37L - -#define SN_freshest_crl "freshestCRL" -#define LN_freshest_crl "X509v3 Freshest CRL" -#define NID_freshest_crl 857 -#define OBJ_freshest_crl OBJ_id_ce,46L - -#define SN_inhibit_any_policy "inhibitAnyPolicy" -#define LN_inhibit_any_policy "X509v3 Inhibit Any Policy" -#define NID_inhibit_any_policy 748 -#define OBJ_inhibit_any_policy OBJ_id_ce,54L - -#define SN_target_information "targetInformation" -#define LN_target_information "X509v3 AC Targeting" -#define NID_target_information 402 -#define OBJ_target_information OBJ_id_ce,55L - -#define SN_no_rev_avail "noRevAvail" -#define LN_no_rev_avail "X509v3 No Revocation Available" -#define NID_no_rev_avail 403 -#define OBJ_no_rev_avail OBJ_id_ce,56L - -#define SN_anyExtendedKeyUsage "anyExtendedKeyUsage" -#define LN_anyExtendedKeyUsage "Any Extended Key Usage" -#define NID_anyExtendedKeyUsage 910 -#define OBJ_anyExtendedKeyUsage OBJ_ext_key_usage,0L - -#define SN_netscape "Netscape" -#define LN_netscape "Netscape Communications Corp." -#define NID_netscape 57 -#define OBJ_netscape 2L,16L,840L,1L,113730L - -#define SN_netscape_cert_extension "nsCertExt" -#define LN_netscape_cert_extension "Netscape Certificate Extension" -#define NID_netscape_cert_extension 58 -#define OBJ_netscape_cert_extension OBJ_netscape,1L - -#define SN_netscape_data_type "nsDataType" -#define LN_netscape_data_type "Netscape Data Type" -#define NID_netscape_data_type 59 -#define OBJ_netscape_data_type OBJ_netscape,2L - -#define SN_netscape_cert_type "nsCertType" -#define LN_netscape_cert_type "Netscape Cert Type" -#define NID_netscape_cert_type 71 -#define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L - -#define SN_netscape_base_url "nsBaseUrl" -#define LN_netscape_base_url "Netscape Base Url" -#define NID_netscape_base_url 72 -#define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L - -#define SN_netscape_revocation_url "nsRevocationUrl" -#define LN_netscape_revocation_url "Netscape Revocation Url" -#define NID_netscape_revocation_url 73 -#define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L - -#define SN_netscape_ca_revocation_url "nsCaRevocationUrl" -#define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" -#define NID_netscape_ca_revocation_url 74 -#define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L - -#define SN_netscape_renewal_url "nsRenewalUrl" -#define LN_netscape_renewal_url "Netscape Renewal Url" -#define NID_netscape_renewal_url 75 -#define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L - -#define SN_netscape_ca_policy_url "nsCaPolicyUrl" -#define LN_netscape_ca_policy_url "Netscape CA Policy Url" -#define NID_netscape_ca_policy_url 76 -#define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L - -#define SN_netscape_ssl_server_name "nsSslServerName" -#define LN_netscape_ssl_server_name "Netscape SSL Server Name" -#define NID_netscape_ssl_server_name 77 -#define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L - -#define SN_netscape_comment "nsComment" -#define LN_netscape_comment "Netscape Comment" -#define NID_netscape_comment 78 -#define OBJ_netscape_comment OBJ_netscape_cert_extension,13L - -#define SN_netscape_cert_sequence "nsCertSequence" -#define LN_netscape_cert_sequence "Netscape Certificate Sequence" -#define NID_netscape_cert_sequence 79 -#define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L - -#define SN_ns_sgc "nsSGC" -#define LN_ns_sgc "Netscape Server Gated Crypto" -#define NID_ns_sgc 139 -#define OBJ_ns_sgc OBJ_netscape,4L,1L - -#define SN_org "ORG" -#define LN_org "org" -#define NID_org 379 -#define OBJ_org OBJ_iso,3L - -#define SN_dod "DOD" -#define LN_dod "dod" -#define NID_dod 380 -#define OBJ_dod OBJ_org,6L - -#define SN_iana "IANA" -#define LN_iana "iana" -#define NID_iana 381 -#define OBJ_iana OBJ_dod,1L - -#define OBJ_internet OBJ_iana - -#define SN_Directory "directory" -#define LN_Directory "Directory" -#define NID_Directory 382 -#define OBJ_Directory OBJ_internet,1L - -#define SN_Management "mgmt" -#define LN_Management "Management" -#define NID_Management 383 -#define OBJ_Management OBJ_internet,2L - -#define SN_Experimental "experimental" -#define LN_Experimental "Experimental" -#define NID_Experimental 384 -#define OBJ_Experimental OBJ_internet,3L - -#define SN_Private "private" -#define LN_Private "Private" -#define NID_Private 385 -#define OBJ_Private OBJ_internet,4L - -#define SN_Security "security" -#define LN_Security "Security" -#define NID_Security 386 -#define OBJ_Security OBJ_internet,5L - -#define SN_SNMPv2 "snmpv2" -#define LN_SNMPv2 "SNMPv2" -#define NID_SNMPv2 387 -#define OBJ_SNMPv2 OBJ_internet,6L - -#define LN_Mail "Mail" -#define NID_Mail 388 -#define OBJ_Mail OBJ_internet,7L - -#define SN_Enterprises "enterprises" -#define LN_Enterprises "Enterprises" -#define NID_Enterprises 389 -#define OBJ_Enterprises OBJ_Private,1L - -#define SN_dcObject "dcobject" -#define LN_dcObject "dcObject" -#define NID_dcObject 390 -#define OBJ_dcObject OBJ_Enterprises,1466L,344L - -#define SN_mime_mhs "mime-mhs" -#define LN_mime_mhs "MIME MHS" -#define NID_mime_mhs 504 -#define OBJ_mime_mhs OBJ_Mail,1L - -#define SN_mime_mhs_headings "mime-mhs-headings" -#define LN_mime_mhs_headings "mime-mhs-headings" -#define NID_mime_mhs_headings 505 -#define OBJ_mime_mhs_headings OBJ_mime_mhs,1L - -#define SN_mime_mhs_bodies "mime-mhs-bodies" -#define LN_mime_mhs_bodies "mime-mhs-bodies" -#define NID_mime_mhs_bodies 506 -#define OBJ_mime_mhs_bodies OBJ_mime_mhs,2L - -#define SN_id_hex_partial_message "id-hex-partial-message" -#define LN_id_hex_partial_message "id-hex-partial-message" -#define NID_id_hex_partial_message 507 -#define OBJ_id_hex_partial_message OBJ_mime_mhs_headings,1L - -#define SN_id_hex_multipart_message "id-hex-multipart-message" -#define LN_id_hex_multipart_message "id-hex-multipart-message" -#define NID_id_hex_multipart_message 508 -#define OBJ_id_hex_multipart_message OBJ_mime_mhs_headings,2L - -#define SN_zlib_compression "ZLIB" -#define LN_zlib_compression "zlib compression" -#define NID_zlib_compression 125 -#define OBJ_zlib_compression OBJ_id_smime_alg,8L - -#define OBJ_csor 2L,16L,840L,1L,101L,3L - -#define OBJ_nistAlgorithms OBJ_csor,4L - -#define OBJ_aes OBJ_nistAlgorithms,1L - -#define SN_aes_128_ecb "AES-128-ECB" -#define LN_aes_128_ecb "aes-128-ecb" -#define NID_aes_128_ecb 418 -#define OBJ_aes_128_ecb OBJ_aes,1L - -#define SN_aes_128_cbc "AES-128-CBC" -#define LN_aes_128_cbc "aes-128-cbc" -#define NID_aes_128_cbc 419 -#define OBJ_aes_128_cbc OBJ_aes,2L - -#define SN_aes_128_ofb128 "AES-128-OFB" -#define LN_aes_128_ofb128 "aes-128-ofb" -#define NID_aes_128_ofb128 420 -#define OBJ_aes_128_ofb128 OBJ_aes,3L - -#define SN_aes_128_cfb128 "AES-128-CFB" -#define LN_aes_128_cfb128 "aes-128-cfb" -#define NID_aes_128_cfb128 421 -#define OBJ_aes_128_cfb128 OBJ_aes,4L - -#define SN_id_aes128_wrap "id-aes128-wrap" -#define NID_id_aes128_wrap 788 -#define OBJ_id_aes128_wrap OBJ_aes,5L - -#define SN_aes_128_gcm "id-aes128-GCM" -#define LN_aes_128_gcm "aes-128-gcm" -#define NID_aes_128_gcm 895 -#define OBJ_aes_128_gcm OBJ_aes,6L - -#define SN_aes_128_ccm "id-aes128-CCM" -#define LN_aes_128_ccm "aes-128-ccm" -#define NID_aes_128_ccm 896 -#define OBJ_aes_128_ccm OBJ_aes,7L - -#define SN_id_aes128_wrap_pad "id-aes128-wrap-pad" -#define NID_id_aes128_wrap_pad 897 -#define OBJ_id_aes128_wrap_pad OBJ_aes,8L - -#define SN_aes_192_ecb "AES-192-ECB" -#define LN_aes_192_ecb "aes-192-ecb" -#define NID_aes_192_ecb 422 -#define OBJ_aes_192_ecb OBJ_aes,21L - -#define SN_aes_192_cbc "AES-192-CBC" -#define LN_aes_192_cbc "aes-192-cbc" -#define NID_aes_192_cbc 423 -#define OBJ_aes_192_cbc OBJ_aes,22L - -#define SN_aes_192_ofb128 "AES-192-OFB" -#define LN_aes_192_ofb128 "aes-192-ofb" -#define NID_aes_192_ofb128 424 -#define OBJ_aes_192_ofb128 OBJ_aes,23L - -#define SN_aes_192_cfb128 "AES-192-CFB" -#define LN_aes_192_cfb128 "aes-192-cfb" -#define NID_aes_192_cfb128 425 -#define OBJ_aes_192_cfb128 OBJ_aes,24L - -#define SN_id_aes192_wrap "id-aes192-wrap" -#define NID_id_aes192_wrap 789 -#define OBJ_id_aes192_wrap OBJ_aes,25L - -#define SN_aes_192_gcm "id-aes192-GCM" -#define LN_aes_192_gcm "aes-192-gcm" -#define NID_aes_192_gcm 898 -#define OBJ_aes_192_gcm OBJ_aes,26L - -#define SN_aes_192_ccm "id-aes192-CCM" -#define LN_aes_192_ccm "aes-192-ccm" -#define NID_aes_192_ccm 899 -#define OBJ_aes_192_ccm OBJ_aes,27L - -#define SN_id_aes192_wrap_pad "id-aes192-wrap-pad" -#define NID_id_aes192_wrap_pad 900 -#define OBJ_id_aes192_wrap_pad OBJ_aes,28L - -#define SN_aes_256_ecb "AES-256-ECB" -#define LN_aes_256_ecb "aes-256-ecb" -#define NID_aes_256_ecb 426 -#define OBJ_aes_256_ecb OBJ_aes,41L - -#define SN_aes_256_cbc "AES-256-CBC" -#define LN_aes_256_cbc "aes-256-cbc" -#define NID_aes_256_cbc 427 -#define OBJ_aes_256_cbc OBJ_aes,42L - -#define SN_aes_256_ofb128 "AES-256-OFB" -#define LN_aes_256_ofb128 "aes-256-ofb" -#define NID_aes_256_ofb128 428 -#define OBJ_aes_256_ofb128 OBJ_aes,43L - -#define SN_aes_256_cfb128 "AES-256-CFB" -#define LN_aes_256_cfb128 "aes-256-cfb" -#define NID_aes_256_cfb128 429 -#define OBJ_aes_256_cfb128 OBJ_aes,44L - -#define SN_id_aes256_wrap "id-aes256-wrap" -#define NID_id_aes256_wrap 790 -#define OBJ_id_aes256_wrap OBJ_aes,45L - -#define SN_aes_256_gcm "id-aes256-GCM" -#define LN_aes_256_gcm "aes-256-gcm" -#define NID_aes_256_gcm 901 -#define OBJ_aes_256_gcm OBJ_aes,46L - -#define SN_aes_256_ccm "id-aes256-CCM" -#define LN_aes_256_ccm "aes-256-ccm" -#define NID_aes_256_ccm 902 -#define OBJ_aes_256_ccm OBJ_aes,47L - -#define SN_id_aes256_wrap_pad "id-aes256-wrap-pad" -#define NID_id_aes256_wrap_pad 903 -#define OBJ_id_aes256_wrap_pad OBJ_aes,48L - -#define SN_aes_128_cfb1 "AES-128-CFB1" -#define LN_aes_128_cfb1 "aes-128-cfb1" -#define NID_aes_128_cfb1 650 - -#define SN_aes_192_cfb1 "AES-192-CFB1" -#define LN_aes_192_cfb1 "aes-192-cfb1" -#define NID_aes_192_cfb1 651 - -#define SN_aes_256_cfb1 "AES-256-CFB1" -#define LN_aes_256_cfb1 "aes-256-cfb1" -#define NID_aes_256_cfb1 652 - -#define SN_aes_128_cfb8 "AES-128-CFB8" -#define LN_aes_128_cfb8 "aes-128-cfb8" -#define NID_aes_128_cfb8 653 - -#define SN_aes_192_cfb8 "AES-192-CFB8" -#define LN_aes_192_cfb8 "aes-192-cfb8" -#define NID_aes_192_cfb8 654 - -#define SN_aes_256_cfb8 "AES-256-CFB8" -#define LN_aes_256_cfb8 "aes-256-cfb8" -#define NID_aes_256_cfb8 655 - -#define SN_aes_128_ctr "AES-128-CTR" -#define LN_aes_128_ctr "aes-128-ctr" -#define NID_aes_128_ctr 904 - -#define SN_aes_192_ctr "AES-192-CTR" -#define LN_aes_192_ctr "aes-192-ctr" -#define NID_aes_192_ctr 905 - -#define SN_aes_256_ctr "AES-256-CTR" -#define LN_aes_256_ctr "aes-256-ctr" -#define NID_aes_256_ctr 906 - -#define SN_aes_128_ocb "AES-128-OCB" -#define LN_aes_128_ocb "aes-128-ocb" -#define NID_aes_128_ocb 958 - -#define SN_aes_192_ocb "AES-192-OCB" -#define LN_aes_192_ocb "aes-192-ocb" -#define NID_aes_192_ocb 959 - -#define SN_aes_256_ocb "AES-256-OCB" -#define LN_aes_256_ocb "aes-256-ocb" -#define NID_aes_256_ocb 960 - -#define SN_aes_128_xts "AES-128-XTS" -#define LN_aes_128_xts "aes-128-xts" -#define NID_aes_128_xts 913 - -#define SN_aes_256_xts "AES-256-XTS" -#define LN_aes_256_xts "aes-256-xts" -#define NID_aes_256_xts 914 - -#define SN_des_cfb1 "DES-CFB1" -#define LN_des_cfb1 "des-cfb1" -#define NID_des_cfb1 656 - -#define SN_des_cfb8 "DES-CFB8" -#define LN_des_cfb8 "des-cfb8" -#define NID_des_cfb8 657 - -#define SN_des_ede3_cfb1 "DES-EDE3-CFB1" -#define LN_des_ede3_cfb1 "des-ede3-cfb1" -#define NID_des_ede3_cfb1 658 - -#define SN_des_ede3_cfb8 "DES-EDE3-CFB8" -#define LN_des_ede3_cfb8 "des-ede3-cfb8" -#define NID_des_ede3_cfb8 659 - -#define OBJ_nist_hashalgs OBJ_nistAlgorithms,2L - -#define SN_sha256 "SHA256" -#define LN_sha256 "sha256" -#define NID_sha256 672 -#define OBJ_sha256 OBJ_nist_hashalgs,1L - -#define SN_sha384 "SHA384" -#define LN_sha384 "sha384" -#define NID_sha384 673 -#define OBJ_sha384 OBJ_nist_hashalgs,2L - -#define SN_sha512 "SHA512" -#define LN_sha512 "sha512" -#define NID_sha512 674 -#define OBJ_sha512 OBJ_nist_hashalgs,3L - -#define SN_sha224 "SHA224" -#define LN_sha224 "sha224" -#define NID_sha224 675 -#define OBJ_sha224 OBJ_nist_hashalgs,4L - -#define OBJ_dsa_with_sha2 OBJ_nistAlgorithms,3L - -#define SN_dsa_with_SHA224 "dsa_with_SHA224" -#define NID_dsa_with_SHA224 802 -#define OBJ_dsa_with_SHA224 OBJ_dsa_with_sha2,1L - -#define SN_dsa_with_SHA256 "dsa_with_SHA256" -#define NID_dsa_with_SHA256 803 -#define OBJ_dsa_with_SHA256 OBJ_dsa_with_sha2,2L - -#define SN_hold_instruction_code "holdInstructionCode" -#define LN_hold_instruction_code "Hold Instruction Code" -#define NID_hold_instruction_code 430 -#define OBJ_hold_instruction_code OBJ_id_ce,23L - -#define OBJ_holdInstruction OBJ_X9_57,2L - -#define SN_hold_instruction_none "holdInstructionNone" -#define LN_hold_instruction_none "Hold Instruction None" -#define NID_hold_instruction_none 431 -#define OBJ_hold_instruction_none OBJ_holdInstruction,1L - -#define SN_hold_instruction_call_issuer "holdInstructionCallIssuer" -#define LN_hold_instruction_call_issuer "Hold Instruction Call Issuer" -#define NID_hold_instruction_call_issuer 432 -#define OBJ_hold_instruction_call_issuer OBJ_holdInstruction,2L - -#define SN_hold_instruction_reject "holdInstructionReject" -#define LN_hold_instruction_reject "Hold Instruction Reject" -#define NID_hold_instruction_reject 433 -#define OBJ_hold_instruction_reject OBJ_holdInstruction,3L - -#define SN_data "data" -#define NID_data 434 -#define OBJ_data OBJ_itu_t,9L - -#define SN_pss "pss" -#define NID_pss 435 -#define OBJ_pss OBJ_data,2342L - -#define SN_ucl "ucl" -#define NID_ucl 436 -#define OBJ_ucl OBJ_pss,19200300L - -#define SN_pilot "pilot" -#define NID_pilot 437 -#define OBJ_pilot OBJ_ucl,100L - -#define LN_pilotAttributeType "pilotAttributeType" -#define NID_pilotAttributeType 438 -#define OBJ_pilotAttributeType OBJ_pilot,1L - -#define LN_pilotAttributeSyntax "pilotAttributeSyntax" -#define NID_pilotAttributeSyntax 439 -#define OBJ_pilotAttributeSyntax OBJ_pilot,3L - -#define LN_pilotObjectClass "pilotObjectClass" -#define NID_pilotObjectClass 440 -#define OBJ_pilotObjectClass OBJ_pilot,4L - -#define LN_pilotGroups "pilotGroups" -#define NID_pilotGroups 441 -#define OBJ_pilotGroups OBJ_pilot,10L - -#define LN_iA5StringSyntax "iA5StringSyntax" -#define NID_iA5StringSyntax 442 -#define OBJ_iA5StringSyntax OBJ_pilotAttributeSyntax,4L - -#define LN_caseIgnoreIA5StringSyntax "caseIgnoreIA5StringSyntax" -#define NID_caseIgnoreIA5StringSyntax 443 -#define OBJ_caseIgnoreIA5StringSyntax OBJ_pilotAttributeSyntax,5L - -#define LN_pilotObject "pilotObject" -#define NID_pilotObject 444 -#define OBJ_pilotObject OBJ_pilotObjectClass,3L - -#define LN_pilotPerson "pilotPerson" -#define NID_pilotPerson 445 -#define OBJ_pilotPerson OBJ_pilotObjectClass,4L - -#define SN_account "account" -#define NID_account 446 -#define OBJ_account OBJ_pilotObjectClass,5L - -#define SN_document "document" -#define NID_document 447 -#define OBJ_document OBJ_pilotObjectClass,6L - -#define SN_room "room" -#define NID_room 448 -#define OBJ_room OBJ_pilotObjectClass,7L - -#define LN_documentSeries "documentSeries" -#define NID_documentSeries 449 -#define OBJ_documentSeries OBJ_pilotObjectClass,9L - -#define SN_Domain "domain" -#define LN_Domain "Domain" -#define NID_Domain 392 -#define OBJ_Domain OBJ_pilotObjectClass,13L - -#define LN_rFC822localPart "rFC822localPart" -#define NID_rFC822localPart 450 -#define OBJ_rFC822localPart OBJ_pilotObjectClass,14L - -#define LN_dNSDomain "dNSDomain" -#define NID_dNSDomain 451 -#define OBJ_dNSDomain OBJ_pilotObjectClass,15L - -#define LN_domainRelatedObject "domainRelatedObject" -#define NID_domainRelatedObject 452 -#define OBJ_domainRelatedObject OBJ_pilotObjectClass,17L - -#define LN_friendlyCountry "friendlyCountry" -#define NID_friendlyCountry 453 -#define OBJ_friendlyCountry OBJ_pilotObjectClass,18L - -#define LN_simpleSecurityObject "simpleSecurityObject" -#define NID_simpleSecurityObject 454 -#define OBJ_simpleSecurityObject OBJ_pilotObjectClass,19L - -#define LN_pilotOrganization "pilotOrganization" -#define NID_pilotOrganization 455 -#define OBJ_pilotOrganization OBJ_pilotObjectClass,20L - -#define LN_pilotDSA "pilotDSA" -#define NID_pilotDSA 456 -#define OBJ_pilotDSA OBJ_pilotObjectClass,21L - -#define LN_qualityLabelledData "qualityLabelledData" -#define NID_qualityLabelledData 457 -#define OBJ_qualityLabelledData OBJ_pilotObjectClass,22L - -#define SN_userId "UID" -#define LN_userId "userId" -#define NID_userId 458 -#define OBJ_userId OBJ_pilotAttributeType,1L - -#define LN_textEncodedORAddress "textEncodedORAddress" -#define NID_textEncodedORAddress 459 -#define OBJ_textEncodedORAddress OBJ_pilotAttributeType,2L - -#define SN_rfc822Mailbox "mail" -#define LN_rfc822Mailbox "rfc822Mailbox" -#define NID_rfc822Mailbox 460 -#define OBJ_rfc822Mailbox OBJ_pilotAttributeType,3L - -#define SN_info "info" -#define NID_info 461 -#define OBJ_info OBJ_pilotAttributeType,4L - -#define LN_favouriteDrink "favouriteDrink" -#define NID_favouriteDrink 462 -#define OBJ_favouriteDrink OBJ_pilotAttributeType,5L - -#define LN_roomNumber "roomNumber" -#define NID_roomNumber 463 -#define OBJ_roomNumber OBJ_pilotAttributeType,6L - -#define SN_photo "photo" -#define NID_photo 464 -#define OBJ_photo OBJ_pilotAttributeType,7L - -#define LN_userClass "userClass" -#define NID_userClass 465 -#define OBJ_userClass OBJ_pilotAttributeType,8L - -#define SN_host "host" -#define NID_host 466 -#define OBJ_host OBJ_pilotAttributeType,9L - -#define SN_manager "manager" -#define NID_manager 467 -#define OBJ_manager OBJ_pilotAttributeType,10L - -#define LN_documentIdentifier "documentIdentifier" -#define NID_documentIdentifier 468 -#define OBJ_documentIdentifier OBJ_pilotAttributeType,11L - -#define LN_documentTitle "documentTitle" -#define NID_documentTitle 469 -#define OBJ_documentTitle OBJ_pilotAttributeType,12L - -#define LN_documentVersion "documentVersion" -#define NID_documentVersion 470 -#define OBJ_documentVersion OBJ_pilotAttributeType,13L - -#define LN_documentAuthor "documentAuthor" -#define NID_documentAuthor 471 -#define OBJ_documentAuthor OBJ_pilotAttributeType,14L - -#define LN_documentLocation "documentLocation" -#define NID_documentLocation 472 -#define OBJ_documentLocation OBJ_pilotAttributeType,15L - -#define LN_homeTelephoneNumber "homeTelephoneNumber" -#define NID_homeTelephoneNumber 473 -#define OBJ_homeTelephoneNumber OBJ_pilotAttributeType,20L - -#define SN_secretary "secretary" -#define NID_secretary 474 -#define OBJ_secretary OBJ_pilotAttributeType,21L - -#define LN_otherMailbox "otherMailbox" -#define NID_otherMailbox 475 -#define OBJ_otherMailbox OBJ_pilotAttributeType,22L - -#define LN_lastModifiedTime "lastModifiedTime" -#define NID_lastModifiedTime 476 -#define OBJ_lastModifiedTime OBJ_pilotAttributeType,23L - -#define LN_lastModifiedBy "lastModifiedBy" -#define NID_lastModifiedBy 477 -#define OBJ_lastModifiedBy OBJ_pilotAttributeType,24L - -#define SN_domainComponent "DC" -#define LN_domainComponent "domainComponent" -#define NID_domainComponent 391 -#define OBJ_domainComponent OBJ_pilotAttributeType,25L - -#define LN_aRecord "aRecord" -#define NID_aRecord 478 -#define OBJ_aRecord OBJ_pilotAttributeType,26L - -#define LN_pilotAttributeType27 "pilotAttributeType27" -#define NID_pilotAttributeType27 479 -#define OBJ_pilotAttributeType27 OBJ_pilotAttributeType,27L - -#define LN_mXRecord "mXRecord" -#define NID_mXRecord 480 -#define OBJ_mXRecord OBJ_pilotAttributeType,28L - -#define LN_nSRecord "nSRecord" -#define NID_nSRecord 481 -#define OBJ_nSRecord OBJ_pilotAttributeType,29L - -#define LN_sOARecord "sOARecord" -#define NID_sOARecord 482 -#define OBJ_sOARecord OBJ_pilotAttributeType,30L - -#define LN_cNAMERecord "cNAMERecord" -#define NID_cNAMERecord 483 -#define OBJ_cNAMERecord OBJ_pilotAttributeType,31L - -#define LN_associatedDomain "associatedDomain" -#define NID_associatedDomain 484 -#define OBJ_associatedDomain OBJ_pilotAttributeType,37L - -#define LN_associatedName "associatedName" -#define NID_associatedName 485 -#define OBJ_associatedName OBJ_pilotAttributeType,38L - -#define LN_homePostalAddress "homePostalAddress" -#define NID_homePostalAddress 486 -#define OBJ_homePostalAddress OBJ_pilotAttributeType,39L - -#define LN_personalTitle "personalTitle" -#define NID_personalTitle 487 -#define OBJ_personalTitle OBJ_pilotAttributeType,40L - -#define LN_mobileTelephoneNumber "mobileTelephoneNumber" -#define NID_mobileTelephoneNumber 488 -#define OBJ_mobileTelephoneNumber OBJ_pilotAttributeType,41L - -#define LN_pagerTelephoneNumber "pagerTelephoneNumber" -#define NID_pagerTelephoneNumber 489 -#define OBJ_pagerTelephoneNumber OBJ_pilotAttributeType,42L - -#define LN_friendlyCountryName "friendlyCountryName" -#define NID_friendlyCountryName 490 -#define OBJ_friendlyCountryName OBJ_pilotAttributeType,43L - -#define SN_uniqueIdentifier "uid" -#define LN_uniqueIdentifier "uniqueIdentifier" -#define NID_uniqueIdentifier 102 -#define OBJ_uniqueIdentifier OBJ_pilotAttributeType,44L - -#define LN_organizationalStatus "organizationalStatus" -#define NID_organizationalStatus 491 -#define OBJ_organizationalStatus OBJ_pilotAttributeType,45L - -#define LN_janetMailbox "janetMailbox" -#define NID_janetMailbox 492 -#define OBJ_janetMailbox OBJ_pilotAttributeType,46L - -#define LN_mailPreferenceOption "mailPreferenceOption" -#define NID_mailPreferenceOption 493 -#define OBJ_mailPreferenceOption OBJ_pilotAttributeType,47L - -#define LN_buildingName "buildingName" -#define NID_buildingName 494 -#define OBJ_buildingName OBJ_pilotAttributeType,48L - -#define LN_dSAQuality "dSAQuality" -#define NID_dSAQuality 495 -#define OBJ_dSAQuality OBJ_pilotAttributeType,49L - -#define LN_singleLevelQuality "singleLevelQuality" -#define NID_singleLevelQuality 496 -#define OBJ_singleLevelQuality OBJ_pilotAttributeType,50L - -#define LN_subtreeMinimumQuality "subtreeMinimumQuality" -#define NID_subtreeMinimumQuality 497 -#define OBJ_subtreeMinimumQuality OBJ_pilotAttributeType,51L - -#define LN_subtreeMaximumQuality "subtreeMaximumQuality" -#define NID_subtreeMaximumQuality 498 -#define OBJ_subtreeMaximumQuality OBJ_pilotAttributeType,52L - -#define LN_personalSignature "personalSignature" -#define NID_personalSignature 499 -#define OBJ_personalSignature OBJ_pilotAttributeType,53L - -#define LN_dITRedirect "dITRedirect" -#define NID_dITRedirect 500 -#define OBJ_dITRedirect OBJ_pilotAttributeType,54L - -#define SN_audio "audio" -#define NID_audio 501 -#define OBJ_audio OBJ_pilotAttributeType,55L - -#define LN_documentPublisher "documentPublisher" -#define NID_documentPublisher 502 -#define OBJ_documentPublisher OBJ_pilotAttributeType,56L - -#define SN_id_set "id-set" -#define LN_id_set "Secure Electronic Transactions" -#define NID_id_set 512 -#define OBJ_id_set OBJ_international_organizations,42L - -#define SN_set_ctype "set-ctype" -#define LN_set_ctype "content types" -#define NID_set_ctype 513 -#define OBJ_set_ctype OBJ_id_set,0L - -#define SN_set_msgExt "set-msgExt" -#define LN_set_msgExt "message extensions" -#define NID_set_msgExt 514 -#define OBJ_set_msgExt OBJ_id_set,1L - -#define SN_set_attr "set-attr" -#define NID_set_attr 515 -#define OBJ_set_attr OBJ_id_set,3L - -#define SN_set_policy "set-policy" -#define NID_set_policy 516 -#define OBJ_set_policy OBJ_id_set,5L - -#define SN_set_certExt "set-certExt" -#define LN_set_certExt "certificate extensions" -#define NID_set_certExt 517 -#define OBJ_set_certExt OBJ_id_set,7L - -#define SN_set_brand "set-brand" -#define NID_set_brand 518 -#define OBJ_set_brand OBJ_id_set,8L - -#define SN_setct_PANData "setct-PANData" -#define NID_setct_PANData 519 -#define OBJ_setct_PANData OBJ_set_ctype,0L - -#define SN_setct_PANToken "setct-PANToken" -#define NID_setct_PANToken 520 -#define OBJ_setct_PANToken OBJ_set_ctype,1L - -#define SN_setct_PANOnly "setct-PANOnly" -#define NID_setct_PANOnly 521 -#define OBJ_setct_PANOnly OBJ_set_ctype,2L - -#define SN_setct_OIData "setct-OIData" -#define NID_setct_OIData 522 -#define OBJ_setct_OIData OBJ_set_ctype,3L - -#define SN_setct_PI "setct-PI" -#define NID_setct_PI 523 -#define OBJ_setct_PI OBJ_set_ctype,4L - -#define SN_setct_PIData "setct-PIData" -#define NID_setct_PIData 524 -#define OBJ_setct_PIData OBJ_set_ctype,5L - -#define SN_setct_PIDataUnsigned "setct-PIDataUnsigned" -#define NID_setct_PIDataUnsigned 525 -#define OBJ_setct_PIDataUnsigned OBJ_set_ctype,6L - -#define SN_setct_HODInput "setct-HODInput" -#define NID_setct_HODInput 526 -#define OBJ_setct_HODInput OBJ_set_ctype,7L - -#define SN_setct_AuthResBaggage "setct-AuthResBaggage" -#define NID_setct_AuthResBaggage 527 -#define OBJ_setct_AuthResBaggage OBJ_set_ctype,8L - -#define SN_setct_AuthRevReqBaggage "setct-AuthRevReqBaggage" -#define NID_setct_AuthRevReqBaggage 528 -#define OBJ_setct_AuthRevReqBaggage OBJ_set_ctype,9L - -#define SN_setct_AuthRevResBaggage "setct-AuthRevResBaggage" -#define NID_setct_AuthRevResBaggage 529 -#define OBJ_setct_AuthRevResBaggage OBJ_set_ctype,10L - -#define SN_setct_CapTokenSeq "setct-CapTokenSeq" -#define NID_setct_CapTokenSeq 530 -#define OBJ_setct_CapTokenSeq OBJ_set_ctype,11L - -#define SN_setct_PInitResData "setct-PInitResData" -#define NID_setct_PInitResData 531 -#define OBJ_setct_PInitResData OBJ_set_ctype,12L - -#define SN_setct_PI_TBS "setct-PI-TBS" -#define NID_setct_PI_TBS 532 -#define OBJ_setct_PI_TBS OBJ_set_ctype,13L - -#define SN_setct_PResData "setct-PResData" -#define NID_setct_PResData 533 -#define OBJ_setct_PResData OBJ_set_ctype,14L - -#define SN_setct_AuthReqTBS "setct-AuthReqTBS" -#define NID_setct_AuthReqTBS 534 -#define OBJ_setct_AuthReqTBS OBJ_set_ctype,16L - -#define SN_setct_AuthResTBS "setct-AuthResTBS" -#define NID_setct_AuthResTBS 535 -#define OBJ_setct_AuthResTBS OBJ_set_ctype,17L - -#define SN_setct_AuthResTBSX "setct-AuthResTBSX" -#define NID_setct_AuthResTBSX 536 -#define OBJ_setct_AuthResTBSX OBJ_set_ctype,18L - -#define SN_setct_AuthTokenTBS "setct-AuthTokenTBS" -#define NID_setct_AuthTokenTBS 537 -#define OBJ_setct_AuthTokenTBS OBJ_set_ctype,19L - -#define SN_setct_CapTokenData "setct-CapTokenData" -#define NID_setct_CapTokenData 538 -#define OBJ_setct_CapTokenData OBJ_set_ctype,20L - -#define SN_setct_CapTokenTBS "setct-CapTokenTBS" -#define NID_setct_CapTokenTBS 539 -#define OBJ_setct_CapTokenTBS OBJ_set_ctype,21L - -#define SN_setct_AcqCardCodeMsg "setct-AcqCardCodeMsg" -#define NID_setct_AcqCardCodeMsg 540 -#define OBJ_setct_AcqCardCodeMsg OBJ_set_ctype,22L - -#define SN_setct_AuthRevReqTBS "setct-AuthRevReqTBS" -#define NID_setct_AuthRevReqTBS 541 -#define OBJ_setct_AuthRevReqTBS OBJ_set_ctype,23L - -#define SN_setct_AuthRevResData "setct-AuthRevResData" -#define NID_setct_AuthRevResData 542 -#define OBJ_setct_AuthRevResData OBJ_set_ctype,24L - -#define SN_setct_AuthRevResTBS "setct-AuthRevResTBS" -#define NID_setct_AuthRevResTBS 543 -#define OBJ_setct_AuthRevResTBS OBJ_set_ctype,25L - -#define SN_setct_CapReqTBS "setct-CapReqTBS" -#define NID_setct_CapReqTBS 544 -#define OBJ_setct_CapReqTBS OBJ_set_ctype,26L - -#define SN_setct_CapReqTBSX "setct-CapReqTBSX" -#define NID_setct_CapReqTBSX 545 -#define OBJ_setct_CapReqTBSX OBJ_set_ctype,27L - -#define SN_setct_CapResData "setct-CapResData" -#define NID_setct_CapResData 546 -#define OBJ_setct_CapResData OBJ_set_ctype,28L - -#define SN_setct_CapRevReqTBS "setct-CapRevReqTBS" -#define NID_setct_CapRevReqTBS 547 -#define OBJ_setct_CapRevReqTBS OBJ_set_ctype,29L - -#define SN_setct_CapRevReqTBSX "setct-CapRevReqTBSX" -#define NID_setct_CapRevReqTBSX 548 -#define OBJ_setct_CapRevReqTBSX OBJ_set_ctype,30L - -#define SN_setct_CapRevResData "setct-CapRevResData" -#define NID_setct_CapRevResData 549 -#define OBJ_setct_CapRevResData OBJ_set_ctype,31L - -#define SN_setct_CredReqTBS "setct-CredReqTBS" -#define NID_setct_CredReqTBS 550 -#define OBJ_setct_CredReqTBS OBJ_set_ctype,32L - -#define SN_setct_CredReqTBSX "setct-CredReqTBSX" -#define NID_setct_CredReqTBSX 551 -#define OBJ_setct_CredReqTBSX OBJ_set_ctype,33L - -#define SN_setct_CredResData "setct-CredResData" -#define NID_setct_CredResData 552 -#define OBJ_setct_CredResData OBJ_set_ctype,34L - -#define SN_setct_CredRevReqTBS "setct-CredRevReqTBS" -#define NID_setct_CredRevReqTBS 553 -#define OBJ_setct_CredRevReqTBS OBJ_set_ctype,35L - -#define SN_setct_CredRevReqTBSX "setct-CredRevReqTBSX" -#define NID_setct_CredRevReqTBSX 554 -#define OBJ_setct_CredRevReqTBSX OBJ_set_ctype,36L - -#define SN_setct_CredRevResData "setct-CredRevResData" -#define NID_setct_CredRevResData 555 -#define OBJ_setct_CredRevResData OBJ_set_ctype,37L - -#define SN_setct_PCertReqData "setct-PCertReqData" -#define NID_setct_PCertReqData 556 -#define OBJ_setct_PCertReqData OBJ_set_ctype,38L - -#define SN_setct_PCertResTBS "setct-PCertResTBS" -#define NID_setct_PCertResTBS 557 -#define OBJ_setct_PCertResTBS OBJ_set_ctype,39L - -#define SN_setct_BatchAdminReqData "setct-BatchAdminReqData" -#define NID_setct_BatchAdminReqData 558 -#define OBJ_setct_BatchAdminReqData OBJ_set_ctype,40L - -#define SN_setct_BatchAdminResData "setct-BatchAdminResData" -#define NID_setct_BatchAdminResData 559 -#define OBJ_setct_BatchAdminResData OBJ_set_ctype,41L - -#define SN_setct_CardCInitResTBS "setct-CardCInitResTBS" -#define NID_setct_CardCInitResTBS 560 -#define OBJ_setct_CardCInitResTBS OBJ_set_ctype,42L - -#define SN_setct_MeAqCInitResTBS "setct-MeAqCInitResTBS" -#define NID_setct_MeAqCInitResTBS 561 -#define OBJ_setct_MeAqCInitResTBS OBJ_set_ctype,43L - -#define SN_setct_RegFormResTBS "setct-RegFormResTBS" -#define NID_setct_RegFormResTBS 562 -#define OBJ_setct_RegFormResTBS OBJ_set_ctype,44L - -#define SN_setct_CertReqData "setct-CertReqData" -#define NID_setct_CertReqData 563 -#define OBJ_setct_CertReqData OBJ_set_ctype,45L - -#define SN_setct_CertReqTBS "setct-CertReqTBS" -#define NID_setct_CertReqTBS 564 -#define OBJ_setct_CertReqTBS OBJ_set_ctype,46L - -#define SN_setct_CertResData "setct-CertResData" -#define NID_setct_CertResData 565 -#define OBJ_setct_CertResData OBJ_set_ctype,47L - -#define SN_setct_CertInqReqTBS "setct-CertInqReqTBS" -#define NID_setct_CertInqReqTBS 566 -#define OBJ_setct_CertInqReqTBS OBJ_set_ctype,48L - -#define SN_setct_ErrorTBS "setct-ErrorTBS" -#define NID_setct_ErrorTBS 567 -#define OBJ_setct_ErrorTBS OBJ_set_ctype,49L - -#define SN_setct_PIDualSignedTBE "setct-PIDualSignedTBE" -#define NID_setct_PIDualSignedTBE 568 -#define OBJ_setct_PIDualSignedTBE OBJ_set_ctype,50L - -#define SN_setct_PIUnsignedTBE "setct-PIUnsignedTBE" -#define NID_setct_PIUnsignedTBE 569 -#define OBJ_setct_PIUnsignedTBE OBJ_set_ctype,51L - -#define SN_setct_AuthReqTBE "setct-AuthReqTBE" -#define NID_setct_AuthReqTBE 570 -#define OBJ_setct_AuthReqTBE OBJ_set_ctype,52L - -#define SN_setct_AuthResTBE "setct-AuthResTBE" -#define NID_setct_AuthResTBE 571 -#define OBJ_setct_AuthResTBE OBJ_set_ctype,53L - -#define SN_setct_AuthResTBEX "setct-AuthResTBEX" -#define NID_setct_AuthResTBEX 572 -#define OBJ_setct_AuthResTBEX OBJ_set_ctype,54L - -#define SN_setct_AuthTokenTBE "setct-AuthTokenTBE" -#define NID_setct_AuthTokenTBE 573 -#define OBJ_setct_AuthTokenTBE OBJ_set_ctype,55L - -#define SN_setct_CapTokenTBE "setct-CapTokenTBE" -#define NID_setct_CapTokenTBE 574 -#define OBJ_setct_CapTokenTBE OBJ_set_ctype,56L - -#define SN_setct_CapTokenTBEX "setct-CapTokenTBEX" -#define NID_setct_CapTokenTBEX 575 -#define OBJ_setct_CapTokenTBEX OBJ_set_ctype,57L - -#define SN_setct_AcqCardCodeMsgTBE "setct-AcqCardCodeMsgTBE" -#define NID_setct_AcqCardCodeMsgTBE 576 -#define OBJ_setct_AcqCardCodeMsgTBE OBJ_set_ctype,58L - -#define SN_setct_AuthRevReqTBE "setct-AuthRevReqTBE" -#define NID_setct_AuthRevReqTBE 577 -#define OBJ_setct_AuthRevReqTBE OBJ_set_ctype,59L - -#define SN_setct_AuthRevResTBE "setct-AuthRevResTBE" -#define NID_setct_AuthRevResTBE 578 -#define OBJ_setct_AuthRevResTBE OBJ_set_ctype,60L - -#define SN_setct_AuthRevResTBEB "setct-AuthRevResTBEB" -#define NID_setct_AuthRevResTBEB 579 -#define OBJ_setct_AuthRevResTBEB OBJ_set_ctype,61L - -#define SN_setct_CapReqTBE "setct-CapReqTBE" -#define NID_setct_CapReqTBE 580 -#define OBJ_setct_CapReqTBE OBJ_set_ctype,62L - -#define SN_setct_CapReqTBEX "setct-CapReqTBEX" -#define NID_setct_CapReqTBEX 581 -#define OBJ_setct_CapReqTBEX OBJ_set_ctype,63L - -#define SN_setct_CapResTBE "setct-CapResTBE" -#define NID_setct_CapResTBE 582 -#define OBJ_setct_CapResTBE OBJ_set_ctype,64L - -#define SN_setct_CapRevReqTBE "setct-CapRevReqTBE" -#define NID_setct_CapRevReqTBE 583 -#define OBJ_setct_CapRevReqTBE OBJ_set_ctype,65L - -#define SN_setct_CapRevReqTBEX "setct-CapRevReqTBEX" -#define NID_setct_CapRevReqTBEX 584 -#define OBJ_setct_CapRevReqTBEX OBJ_set_ctype,66L - -#define SN_setct_CapRevResTBE "setct-CapRevResTBE" -#define NID_setct_CapRevResTBE 585 -#define OBJ_setct_CapRevResTBE OBJ_set_ctype,67L - -#define SN_setct_CredReqTBE "setct-CredReqTBE" -#define NID_setct_CredReqTBE 586 -#define OBJ_setct_CredReqTBE OBJ_set_ctype,68L - -#define SN_setct_CredReqTBEX "setct-CredReqTBEX" -#define NID_setct_CredReqTBEX 587 -#define OBJ_setct_CredReqTBEX OBJ_set_ctype,69L - -#define SN_setct_CredResTBE "setct-CredResTBE" -#define NID_setct_CredResTBE 588 -#define OBJ_setct_CredResTBE OBJ_set_ctype,70L - -#define SN_setct_CredRevReqTBE "setct-CredRevReqTBE" -#define NID_setct_CredRevReqTBE 589 -#define OBJ_setct_CredRevReqTBE OBJ_set_ctype,71L - -#define SN_setct_CredRevReqTBEX "setct-CredRevReqTBEX" -#define NID_setct_CredRevReqTBEX 590 -#define OBJ_setct_CredRevReqTBEX OBJ_set_ctype,72L - -#define SN_setct_CredRevResTBE "setct-CredRevResTBE" -#define NID_setct_CredRevResTBE 591 -#define OBJ_setct_CredRevResTBE OBJ_set_ctype,73L - -#define SN_setct_BatchAdminReqTBE "setct-BatchAdminReqTBE" -#define NID_setct_BatchAdminReqTBE 592 -#define OBJ_setct_BatchAdminReqTBE OBJ_set_ctype,74L - -#define SN_setct_BatchAdminResTBE "setct-BatchAdminResTBE" -#define NID_setct_BatchAdminResTBE 593 -#define OBJ_setct_BatchAdminResTBE OBJ_set_ctype,75L - -#define SN_setct_RegFormReqTBE "setct-RegFormReqTBE" -#define NID_setct_RegFormReqTBE 594 -#define OBJ_setct_RegFormReqTBE OBJ_set_ctype,76L - -#define SN_setct_CertReqTBE "setct-CertReqTBE" -#define NID_setct_CertReqTBE 595 -#define OBJ_setct_CertReqTBE OBJ_set_ctype,77L - -#define SN_setct_CertReqTBEX "setct-CertReqTBEX" -#define NID_setct_CertReqTBEX 596 -#define OBJ_setct_CertReqTBEX OBJ_set_ctype,78L - -#define SN_setct_CertResTBE "setct-CertResTBE" -#define NID_setct_CertResTBE 597 -#define OBJ_setct_CertResTBE OBJ_set_ctype,79L - -#define SN_setct_CRLNotificationTBS "setct-CRLNotificationTBS" -#define NID_setct_CRLNotificationTBS 598 -#define OBJ_setct_CRLNotificationTBS OBJ_set_ctype,80L - -#define SN_setct_CRLNotificationResTBS "setct-CRLNotificationResTBS" -#define NID_setct_CRLNotificationResTBS 599 -#define OBJ_setct_CRLNotificationResTBS OBJ_set_ctype,81L - -#define SN_setct_BCIDistributionTBS "setct-BCIDistributionTBS" -#define NID_setct_BCIDistributionTBS 600 -#define OBJ_setct_BCIDistributionTBS OBJ_set_ctype,82L - -#define SN_setext_genCrypt "setext-genCrypt" -#define LN_setext_genCrypt "generic cryptogram" -#define NID_setext_genCrypt 601 -#define OBJ_setext_genCrypt OBJ_set_msgExt,1L - -#define SN_setext_miAuth "setext-miAuth" -#define LN_setext_miAuth "merchant initiated auth" -#define NID_setext_miAuth 602 -#define OBJ_setext_miAuth OBJ_set_msgExt,3L - -#define SN_setext_pinSecure "setext-pinSecure" -#define NID_setext_pinSecure 603 -#define OBJ_setext_pinSecure OBJ_set_msgExt,4L - -#define SN_setext_pinAny "setext-pinAny" -#define NID_setext_pinAny 604 -#define OBJ_setext_pinAny OBJ_set_msgExt,5L - -#define SN_setext_track2 "setext-track2" -#define NID_setext_track2 605 -#define OBJ_setext_track2 OBJ_set_msgExt,7L - -#define SN_setext_cv "setext-cv" -#define LN_setext_cv "additional verification" -#define NID_setext_cv 606 -#define OBJ_setext_cv OBJ_set_msgExt,8L - -#define SN_set_policy_root "set-policy-root" -#define NID_set_policy_root 607 -#define OBJ_set_policy_root OBJ_set_policy,0L - -#define SN_setCext_hashedRoot "setCext-hashedRoot" -#define NID_setCext_hashedRoot 608 -#define OBJ_setCext_hashedRoot OBJ_set_certExt,0L - -#define SN_setCext_certType "setCext-certType" -#define NID_setCext_certType 609 -#define OBJ_setCext_certType OBJ_set_certExt,1L - -#define SN_setCext_merchData "setCext-merchData" -#define NID_setCext_merchData 610 -#define OBJ_setCext_merchData OBJ_set_certExt,2L - -#define SN_setCext_cCertRequired "setCext-cCertRequired" -#define NID_setCext_cCertRequired 611 -#define OBJ_setCext_cCertRequired OBJ_set_certExt,3L - -#define SN_setCext_tunneling "setCext-tunneling" -#define NID_setCext_tunneling 612 -#define OBJ_setCext_tunneling OBJ_set_certExt,4L - -#define SN_setCext_setExt "setCext-setExt" -#define NID_setCext_setExt 613 -#define OBJ_setCext_setExt OBJ_set_certExt,5L - -#define SN_setCext_setQualf "setCext-setQualf" -#define NID_setCext_setQualf 614 -#define OBJ_setCext_setQualf OBJ_set_certExt,6L - -#define SN_setCext_PGWYcapabilities "setCext-PGWYcapabilities" -#define NID_setCext_PGWYcapabilities 615 -#define OBJ_setCext_PGWYcapabilities OBJ_set_certExt,7L - -#define SN_setCext_TokenIdentifier "setCext-TokenIdentifier" -#define NID_setCext_TokenIdentifier 616 -#define OBJ_setCext_TokenIdentifier OBJ_set_certExt,8L - -#define SN_setCext_Track2Data "setCext-Track2Data" -#define NID_setCext_Track2Data 617 -#define OBJ_setCext_Track2Data OBJ_set_certExt,9L - -#define SN_setCext_TokenType "setCext-TokenType" -#define NID_setCext_TokenType 618 -#define OBJ_setCext_TokenType OBJ_set_certExt,10L - -#define SN_setCext_IssuerCapabilities "setCext-IssuerCapabilities" -#define NID_setCext_IssuerCapabilities 619 -#define OBJ_setCext_IssuerCapabilities OBJ_set_certExt,11L - -#define SN_setAttr_Cert "setAttr-Cert" -#define NID_setAttr_Cert 620 -#define OBJ_setAttr_Cert OBJ_set_attr,0L - -#define SN_setAttr_PGWYcap "setAttr-PGWYcap" -#define LN_setAttr_PGWYcap "payment gateway capabilities" -#define NID_setAttr_PGWYcap 621 -#define OBJ_setAttr_PGWYcap OBJ_set_attr,1L - -#define SN_setAttr_TokenType "setAttr-TokenType" -#define NID_setAttr_TokenType 622 -#define OBJ_setAttr_TokenType OBJ_set_attr,2L - -#define SN_setAttr_IssCap "setAttr-IssCap" -#define LN_setAttr_IssCap "issuer capabilities" -#define NID_setAttr_IssCap 623 -#define OBJ_setAttr_IssCap OBJ_set_attr,3L - -#define SN_set_rootKeyThumb "set-rootKeyThumb" -#define NID_set_rootKeyThumb 624 -#define OBJ_set_rootKeyThumb OBJ_setAttr_Cert,0L - -#define SN_set_addPolicy "set-addPolicy" -#define NID_set_addPolicy 625 -#define OBJ_set_addPolicy OBJ_setAttr_Cert,1L - -#define SN_setAttr_Token_EMV "setAttr-Token-EMV" -#define NID_setAttr_Token_EMV 626 -#define OBJ_setAttr_Token_EMV OBJ_setAttr_TokenType,1L - -#define SN_setAttr_Token_B0Prime "setAttr-Token-B0Prime" -#define NID_setAttr_Token_B0Prime 627 -#define OBJ_setAttr_Token_B0Prime OBJ_setAttr_TokenType,2L - -#define SN_setAttr_IssCap_CVM "setAttr-IssCap-CVM" -#define NID_setAttr_IssCap_CVM 628 -#define OBJ_setAttr_IssCap_CVM OBJ_setAttr_IssCap,3L - -#define SN_setAttr_IssCap_T2 "setAttr-IssCap-T2" -#define NID_setAttr_IssCap_T2 629 -#define OBJ_setAttr_IssCap_T2 OBJ_setAttr_IssCap,4L - -#define SN_setAttr_IssCap_Sig "setAttr-IssCap-Sig" -#define NID_setAttr_IssCap_Sig 630 -#define OBJ_setAttr_IssCap_Sig OBJ_setAttr_IssCap,5L - -#define SN_setAttr_GenCryptgrm "setAttr-GenCryptgrm" -#define LN_setAttr_GenCryptgrm "generate cryptogram" -#define NID_setAttr_GenCryptgrm 631 -#define OBJ_setAttr_GenCryptgrm OBJ_setAttr_IssCap_CVM,1L - -#define SN_setAttr_T2Enc "setAttr-T2Enc" -#define LN_setAttr_T2Enc "encrypted track 2" -#define NID_setAttr_T2Enc 632 -#define OBJ_setAttr_T2Enc OBJ_setAttr_IssCap_T2,1L - -#define SN_setAttr_T2cleartxt "setAttr-T2cleartxt" -#define LN_setAttr_T2cleartxt "cleartext track 2" -#define NID_setAttr_T2cleartxt 633 -#define OBJ_setAttr_T2cleartxt OBJ_setAttr_IssCap_T2,2L - -#define SN_setAttr_TokICCsig "setAttr-TokICCsig" -#define LN_setAttr_TokICCsig "ICC or token signature" -#define NID_setAttr_TokICCsig 634 -#define OBJ_setAttr_TokICCsig OBJ_setAttr_IssCap_Sig,1L - -#define SN_setAttr_SecDevSig "setAttr-SecDevSig" -#define LN_setAttr_SecDevSig "secure device signature" -#define NID_setAttr_SecDevSig 635 -#define OBJ_setAttr_SecDevSig OBJ_setAttr_IssCap_Sig,2L - -#define SN_set_brand_IATA_ATA "set-brand-IATA-ATA" -#define NID_set_brand_IATA_ATA 636 -#define OBJ_set_brand_IATA_ATA OBJ_set_brand,1L - -#define SN_set_brand_Diners "set-brand-Diners" -#define NID_set_brand_Diners 637 -#define OBJ_set_brand_Diners OBJ_set_brand,30L - -#define SN_set_brand_AmericanExpress "set-brand-AmericanExpress" -#define NID_set_brand_AmericanExpress 638 -#define OBJ_set_brand_AmericanExpress OBJ_set_brand,34L - -#define SN_set_brand_JCB "set-brand-JCB" -#define NID_set_brand_JCB 639 -#define OBJ_set_brand_JCB OBJ_set_brand,35L - -#define SN_set_brand_Visa "set-brand-Visa" -#define NID_set_brand_Visa 640 -#define OBJ_set_brand_Visa OBJ_set_brand,4L - -#define SN_set_brand_MasterCard "set-brand-MasterCard" -#define NID_set_brand_MasterCard 641 -#define OBJ_set_brand_MasterCard OBJ_set_brand,5L - -#define SN_set_brand_Novus "set-brand-Novus" -#define NID_set_brand_Novus 642 -#define OBJ_set_brand_Novus OBJ_set_brand,6011L - -#define SN_des_cdmf "DES-CDMF" -#define LN_des_cdmf "des-cdmf" -#define NID_des_cdmf 643 -#define OBJ_des_cdmf OBJ_rsadsi,3L,10L - -#define SN_rsaOAEPEncryptionSET "rsaOAEPEncryptionSET" -#define NID_rsaOAEPEncryptionSET 644 -#define OBJ_rsaOAEPEncryptionSET OBJ_rsadsi,1L,1L,6L - -#define SN_ipsec3 "Oakley-EC2N-3" -#define LN_ipsec3 "ipsec3" -#define NID_ipsec3 749 - -#define SN_ipsec4 "Oakley-EC2N-4" -#define LN_ipsec4 "ipsec4" -#define NID_ipsec4 750 - -#define SN_whirlpool "whirlpool" -#define NID_whirlpool 804 -#define OBJ_whirlpool OBJ_iso,0L,10118L,3L,0L,55L - -#define SN_cryptopro "cryptopro" -#define NID_cryptopro 805 -#define OBJ_cryptopro OBJ_member_body,643L,2L,2L - -#define SN_cryptocom "cryptocom" -#define NID_cryptocom 806 -#define OBJ_cryptocom OBJ_member_body,643L,2L,9L - -#define SN_id_tc26 "id-tc26" -#define NID_id_tc26 974 -#define OBJ_id_tc26 OBJ_member_body,643L,7L,1L - -#define SN_id_GostR3411_94_with_GostR3410_2001 "id-GostR3411-94-with-GostR3410-2001" -#define LN_id_GostR3411_94_with_GostR3410_2001 "GOST R 34.11-94 with GOST R 34.10-2001" -#define NID_id_GostR3411_94_with_GostR3410_2001 807 -#define OBJ_id_GostR3411_94_with_GostR3410_2001 OBJ_cryptopro,3L - -#define SN_id_GostR3411_94_with_GostR3410_94 "id-GostR3411-94-with-GostR3410-94" -#define LN_id_GostR3411_94_with_GostR3410_94 "GOST R 34.11-94 with GOST R 34.10-94" -#define NID_id_GostR3411_94_with_GostR3410_94 808 -#define OBJ_id_GostR3411_94_with_GostR3410_94 OBJ_cryptopro,4L - -#define SN_id_GostR3411_94 "md_gost94" -#define LN_id_GostR3411_94 "GOST R 34.11-94" -#define NID_id_GostR3411_94 809 -#define OBJ_id_GostR3411_94 OBJ_cryptopro,9L - -#define SN_id_HMACGostR3411_94 "id-HMACGostR3411-94" -#define LN_id_HMACGostR3411_94 "HMAC GOST 34.11-94" -#define NID_id_HMACGostR3411_94 810 -#define OBJ_id_HMACGostR3411_94 OBJ_cryptopro,10L - -#define SN_id_GostR3410_2001 "gost2001" -#define LN_id_GostR3410_2001 "GOST R 34.10-2001" -#define NID_id_GostR3410_2001 811 -#define OBJ_id_GostR3410_2001 OBJ_cryptopro,19L - -#define SN_id_GostR3410_94 "gost94" -#define LN_id_GostR3410_94 "GOST R 34.10-94" -#define NID_id_GostR3410_94 812 -#define OBJ_id_GostR3410_94 OBJ_cryptopro,20L - -#define SN_id_Gost28147_89 "gost89" -#define LN_id_Gost28147_89 "GOST 28147-89" -#define NID_id_Gost28147_89 813 -#define OBJ_id_Gost28147_89 OBJ_cryptopro,21L - -#define SN_gost89_cnt "gost89-cnt" -#define NID_gost89_cnt 814 - -#define SN_gost89_cnt_12 "gost89-cnt-12" -#define NID_gost89_cnt_12 975 - -#define SN_gost89_cbc "gost89-cbc" -#define NID_gost89_cbc 1009 - -#define SN_gost89_ecb "gost89-ecb" -#define NID_gost89_ecb 1010 - -#define SN_gost89_ctr "gost89-ctr" -#define NID_gost89_ctr 1011 - -#define SN_id_Gost28147_89_MAC "gost-mac" -#define LN_id_Gost28147_89_MAC "GOST 28147-89 MAC" -#define NID_id_Gost28147_89_MAC 815 -#define OBJ_id_Gost28147_89_MAC OBJ_cryptopro,22L - -#define SN_gost_mac_12 "gost-mac-12" -#define NID_gost_mac_12 976 - -#define SN_id_GostR3411_94_prf "prf-gostr3411-94" -#define LN_id_GostR3411_94_prf "GOST R 34.11-94 PRF" -#define NID_id_GostR3411_94_prf 816 -#define OBJ_id_GostR3411_94_prf OBJ_cryptopro,23L - -#define SN_id_GostR3410_2001DH "id-GostR3410-2001DH" -#define LN_id_GostR3410_2001DH "GOST R 34.10-2001 DH" -#define NID_id_GostR3410_2001DH 817 -#define OBJ_id_GostR3410_2001DH OBJ_cryptopro,98L - -#define SN_id_GostR3410_94DH "id-GostR3410-94DH" -#define LN_id_GostR3410_94DH "GOST R 34.10-94 DH" -#define NID_id_GostR3410_94DH 818 -#define OBJ_id_GostR3410_94DH OBJ_cryptopro,99L - -#define SN_id_Gost28147_89_CryptoPro_KeyMeshing "id-Gost28147-89-CryptoPro-KeyMeshing" -#define NID_id_Gost28147_89_CryptoPro_KeyMeshing 819 -#define OBJ_id_Gost28147_89_CryptoPro_KeyMeshing OBJ_cryptopro,14L,1L - -#define SN_id_Gost28147_89_None_KeyMeshing "id-Gost28147-89-None-KeyMeshing" -#define NID_id_Gost28147_89_None_KeyMeshing 820 -#define OBJ_id_Gost28147_89_None_KeyMeshing OBJ_cryptopro,14L,0L - -#define SN_id_GostR3411_94_TestParamSet "id-GostR3411-94-TestParamSet" -#define NID_id_GostR3411_94_TestParamSet 821 -#define OBJ_id_GostR3411_94_TestParamSet OBJ_cryptopro,30L,0L - -#define SN_id_GostR3411_94_CryptoProParamSet "id-GostR3411-94-CryptoProParamSet" -#define NID_id_GostR3411_94_CryptoProParamSet 822 -#define OBJ_id_GostR3411_94_CryptoProParamSet OBJ_cryptopro,30L,1L - -#define SN_id_Gost28147_89_TestParamSet "id-Gost28147-89-TestParamSet" -#define NID_id_Gost28147_89_TestParamSet 823 -#define OBJ_id_Gost28147_89_TestParamSet OBJ_cryptopro,31L,0L - -#define SN_id_Gost28147_89_CryptoPro_A_ParamSet "id-Gost28147-89-CryptoPro-A-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_A_ParamSet 824 -#define OBJ_id_Gost28147_89_CryptoPro_A_ParamSet OBJ_cryptopro,31L,1L - -#define SN_id_Gost28147_89_CryptoPro_B_ParamSet "id-Gost28147-89-CryptoPro-B-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_B_ParamSet 825 -#define OBJ_id_Gost28147_89_CryptoPro_B_ParamSet OBJ_cryptopro,31L,2L - -#define SN_id_Gost28147_89_CryptoPro_C_ParamSet "id-Gost28147-89-CryptoPro-C-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_C_ParamSet 826 -#define OBJ_id_Gost28147_89_CryptoPro_C_ParamSet OBJ_cryptopro,31L,3L - -#define SN_id_Gost28147_89_CryptoPro_D_ParamSet "id-Gost28147-89-CryptoPro-D-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_D_ParamSet 827 -#define OBJ_id_Gost28147_89_CryptoPro_D_ParamSet OBJ_cryptopro,31L,4L - -#define SN_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-1-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet 828 -#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_1_ParamSet OBJ_cryptopro,31L,5L - -#define SN_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet "id-Gost28147-89-CryptoPro-Oscar-1-0-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet 829 -#define OBJ_id_Gost28147_89_CryptoPro_Oscar_1_0_ParamSet OBJ_cryptopro,31L,6L - -#define SN_id_Gost28147_89_CryptoPro_RIC_1_ParamSet "id-Gost28147-89-CryptoPro-RIC-1-ParamSet" -#define NID_id_Gost28147_89_CryptoPro_RIC_1_ParamSet 830 -#define OBJ_id_Gost28147_89_CryptoPro_RIC_1_ParamSet OBJ_cryptopro,31L,7L - -#define SN_id_GostR3410_94_TestParamSet "id-GostR3410-94-TestParamSet" -#define NID_id_GostR3410_94_TestParamSet 831 -#define OBJ_id_GostR3410_94_TestParamSet OBJ_cryptopro,32L,0L - -#define SN_id_GostR3410_94_CryptoPro_A_ParamSet "id-GostR3410-94-CryptoPro-A-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_A_ParamSet 832 -#define OBJ_id_GostR3410_94_CryptoPro_A_ParamSet OBJ_cryptopro,32L,2L - -#define SN_id_GostR3410_94_CryptoPro_B_ParamSet "id-GostR3410-94-CryptoPro-B-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_B_ParamSet 833 -#define OBJ_id_GostR3410_94_CryptoPro_B_ParamSet OBJ_cryptopro,32L,3L - -#define SN_id_GostR3410_94_CryptoPro_C_ParamSet "id-GostR3410-94-CryptoPro-C-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_C_ParamSet 834 -#define OBJ_id_GostR3410_94_CryptoPro_C_ParamSet OBJ_cryptopro,32L,4L - -#define SN_id_GostR3410_94_CryptoPro_D_ParamSet "id-GostR3410-94-CryptoPro-D-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_D_ParamSet 835 -#define OBJ_id_GostR3410_94_CryptoPro_D_ParamSet OBJ_cryptopro,32L,5L - -#define SN_id_GostR3410_94_CryptoPro_XchA_ParamSet "id-GostR3410-94-CryptoPro-XchA-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_XchA_ParamSet 836 -#define OBJ_id_GostR3410_94_CryptoPro_XchA_ParamSet OBJ_cryptopro,33L,1L - -#define SN_id_GostR3410_94_CryptoPro_XchB_ParamSet "id-GostR3410-94-CryptoPro-XchB-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_XchB_ParamSet 837 -#define OBJ_id_GostR3410_94_CryptoPro_XchB_ParamSet OBJ_cryptopro,33L,2L - -#define SN_id_GostR3410_94_CryptoPro_XchC_ParamSet "id-GostR3410-94-CryptoPro-XchC-ParamSet" -#define NID_id_GostR3410_94_CryptoPro_XchC_ParamSet 838 -#define OBJ_id_GostR3410_94_CryptoPro_XchC_ParamSet OBJ_cryptopro,33L,3L - -#define SN_id_GostR3410_2001_TestParamSet "id-GostR3410-2001-TestParamSet" -#define NID_id_GostR3410_2001_TestParamSet 839 -#define OBJ_id_GostR3410_2001_TestParamSet OBJ_cryptopro,35L,0L - -#define SN_id_GostR3410_2001_CryptoPro_A_ParamSet "id-GostR3410-2001-CryptoPro-A-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_A_ParamSet 840 -#define OBJ_id_GostR3410_2001_CryptoPro_A_ParamSet OBJ_cryptopro,35L,1L - -#define SN_id_GostR3410_2001_CryptoPro_B_ParamSet "id-GostR3410-2001-CryptoPro-B-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_B_ParamSet 841 -#define OBJ_id_GostR3410_2001_CryptoPro_B_ParamSet OBJ_cryptopro,35L,2L - -#define SN_id_GostR3410_2001_CryptoPro_C_ParamSet "id-GostR3410-2001-CryptoPro-C-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_C_ParamSet 842 -#define OBJ_id_GostR3410_2001_CryptoPro_C_ParamSet OBJ_cryptopro,35L,3L - -#define SN_id_GostR3410_2001_CryptoPro_XchA_ParamSet "id-GostR3410-2001-CryptoPro-XchA-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_XchA_ParamSet 843 -#define OBJ_id_GostR3410_2001_CryptoPro_XchA_ParamSet OBJ_cryptopro,36L,0L - -#define SN_id_GostR3410_2001_CryptoPro_XchB_ParamSet "id-GostR3410-2001-CryptoPro-XchB-ParamSet" -#define NID_id_GostR3410_2001_CryptoPro_XchB_ParamSet 844 -#define OBJ_id_GostR3410_2001_CryptoPro_XchB_ParamSet OBJ_cryptopro,36L,1L - -#define SN_id_GostR3410_94_a "id-GostR3410-94-a" -#define NID_id_GostR3410_94_a 845 -#define OBJ_id_GostR3410_94_a OBJ_id_GostR3410_94,1L - -#define SN_id_GostR3410_94_aBis "id-GostR3410-94-aBis" -#define NID_id_GostR3410_94_aBis 846 -#define OBJ_id_GostR3410_94_aBis OBJ_id_GostR3410_94,2L - -#define SN_id_GostR3410_94_b "id-GostR3410-94-b" -#define NID_id_GostR3410_94_b 847 -#define OBJ_id_GostR3410_94_b OBJ_id_GostR3410_94,3L - -#define SN_id_GostR3410_94_bBis "id-GostR3410-94-bBis" -#define NID_id_GostR3410_94_bBis 848 -#define OBJ_id_GostR3410_94_bBis OBJ_id_GostR3410_94,4L - -#define SN_id_Gost28147_89_cc "id-Gost28147-89-cc" -#define LN_id_Gost28147_89_cc "GOST 28147-89 Cryptocom ParamSet" -#define NID_id_Gost28147_89_cc 849 -#define OBJ_id_Gost28147_89_cc OBJ_cryptocom,1L,6L,1L - -#define SN_id_GostR3410_94_cc "gost94cc" -#define LN_id_GostR3410_94_cc "GOST 34.10-94 Cryptocom" -#define NID_id_GostR3410_94_cc 850 -#define OBJ_id_GostR3410_94_cc OBJ_cryptocom,1L,5L,3L - -#define SN_id_GostR3410_2001_cc "gost2001cc" -#define LN_id_GostR3410_2001_cc "GOST 34.10-2001 Cryptocom" -#define NID_id_GostR3410_2001_cc 851 -#define OBJ_id_GostR3410_2001_cc OBJ_cryptocom,1L,5L,4L - -#define SN_id_GostR3411_94_with_GostR3410_94_cc "id-GostR3411-94-with-GostR3410-94-cc" -#define LN_id_GostR3411_94_with_GostR3410_94_cc "GOST R 34.11-94 with GOST R 34.10-94 Cryptocom" -#define NID_id_GostR3411_94_with_GostR3410_94_cc 852 -#define OBJ_id_GostR3411_94_with_GostR3410_94_cc OBJ_cryptocom,1L,3L,3L - -#define SN_id_GostR3411_94_with_GostR3410_2001_cc "id-GostR3411-94-with-GostR3410-2001-cc" -#define LN_id_GostR3411_94_with_GostR3410_2001_cc "GOST R 34.11-94 with GOST R 34.10-2001 Cryptocom" -#define NID_id_GostR3411_94_with_GostR3410_2001_cc 853 -#define OBJ_id_GostR3411_94_with_GostR3410_2001_cc OBJ_cryptocom,1L,3L,4L - -#define SN_id_GostR3410_2001_ParamSet_cc "id-GostR3410-2001-ParamSet-cc" -#define LN_id_GostR3410_2001_ParamSet_cc "GOST R 3410-2001 Parameter Set Cryptocom" -#define NID_id_GostR3410_2001_ParamSet_cc 854 -#define OBJ_id_GostR3410_2001_ParamSet_cc OBJ_cryptocom,1L,8L,1L - -#define SN_id_tc26_algorithms "id-tc26-algorithms" -#define NID_id_tc26_algorithms 977 -#define OBJ_id_tc26_algorithms OBJ_id_tc26,1L - -#define SN_id_tc26_sign "id-tc26-sign" -#define NID_id_tc26_sign 978 -#define OBJ_id_tc26_sign OBJ_id_tc26_algorithms,1L - -#define SN_id_GostR3410_2012_256 "gost2012_256" -#define LN_id_GostR3410_2012_256 "GOST R 34.10-2012 with 256 bit modulus" -#define NID_id_GostR3410_2012_256 979 -#define OBJ_id_GostR3410_2012_256 OBJ_id_tc26_sign,1L - -#define SN_id_GostR3410_2012_512 "gost2012_512" -#define LN_id_GostR3410_2012_512 "GOST R 34.10-2012 with 512 bit modulus" -#define NID_id_GostR3410_2012_512 980 -#define OBJ_id_GostR3410_2012_512 OBJ_id_tc26_sign,2L - -#define SN_id_tc26_digest "id-tc26-digest" -#define NID_id_tc26_digest 981 -#define OBJ_id_tc26_digest OBJ_id_tc26_algorithms,2L - -#define SN_id_GostR3411_2012_256 "md_gost12_256" -#define LN_id_GostR3411_2012_256 "GOST R 34.11-2012 with 256 bit hash" -#define NID_id_GostR3411_2012_256 982 -#define OBJ_id_GostR3411_2012_256 OBJ_id_tc26_digest,2L - -#define SN_id_GostR3411_2012_512 "md_gost12_512" -#define LN_id_GostR3411_2012_512 "GOST R 34.11-2012 with 512 bit hash" -#define NID_id_GostR3411_2012_512 983 -#define OBJ_id_GostR3411_2012_512 OBJ_id_tc26_digest,3L - -#define SN_id_tc26_signwithdigest "id-tc26-signwithdigest" -#define NID_id_tc26_signwithdigest 984 -#define OBJ_id_tc26_signwithdigest OBJ_id_tc26_algorithms,3L - -#define SN_id_tc26_signwithdigest_gost3410_2012_256 "id-tc26-signwithdigest-gost3410-2012-256" -#define LN_id_tc26_signwithdigest_gost3410_2012_256 "GOST R 34.10-2012 with GOST R 34.11-2012 (256 bit)" -#define NID_id_tc26_signwithdigest_gost3410_2012_256 985 -#define OBJ_id_tc26_signwithdigest_gost3410_2012_256 OBJ_id_tc26_signwithdigest,2L - -#define SN_id_tc26_signwithdigest_gost3410_2012_512 "id-tc26-signwithdigest-gost3410-2012-512" -#define LN_id_tc26_signwithdigest_gost3410_2012_512 "GOST R 34.10-2012 with GOST R 34.11-2012 (512 bit)" -#define NID_id_tc26_signwithdigest_gost3410_2012_512 986 -#define OBJ_id_tc26_signwithdigest_gost3410_2012_512 OBJ_id_tc26_signwithdigest,3L - -#define SN_id_tc26_mac "id-tc26-mac" -#define NID_id_tc26_mac 987 -#define OBJ_id_tc26_mac OBJ_id_tc26_algorithms,4L - -#define SN_id_tc26_hmac_gost_3411_2012_256 "id-tc26-hmac-gost-3411-2012-256" -#define LN_id_tc26_hmac_gost_3411_2012_256 "HMAC GOST 34.11-2012 256 bit" -#define NID_id_tc26_hmac_gost_3411_2012_256 988 -#define OBJ_id_tc26_hmac_gost_3411_2012_256 OBJ_id_tc26_mac,1L - -#define SN_id_tc26_hmac_gost_3411_2012_512 "id-tc26-hmac-gost-3411-2012-512" -#define LN_id_tc26_hmac_gost_3411_2012_512 "HMAC GOST 34.11-2012 512 bit" -#define NID_id_tc26_hmac_gost_3411_2012_512 989 -#define OBJ_id_tc26_hmac_gost_3411_2012_512 OBJ_id_tc26_mac,2L - -#define SN_id_tc26_cipher "id-tc26-cipher" -#define NID_id_tc26_cipher 990 -#define OBJ_id_tc26_cipher OBJ_id_tc26_algorithms,5L - -#define SN_id_tc26_agreement "id-tc26-agreement" -#define NID_id_tc26_agreement 991 -#define OBJ_id_tc26_agreement OBJ_id_tc26_algorithms,6L - -#define SN_id_tc26_agreement_gost_3410_2012_256 "id-tc26-agreement-gost-3410-2012-256" -#define NID_id_tc26_agreement_gost_3410_2012_256 992 -#define OBJ_id_tc26_agreement_gost_3410_2012_256 OBJ_id_tc26_agreement,1L - -#define SN_id_tc26_agreement_gost_3410_2012_512 "id-tc26-agreement-gost-3410-2012-512" -#define NID_id_tc26_agreement_gost_3410_2012_512 993 -#define OBJ_id_tc26_agreement_gost_3410_2012_512 OBJ_id_tc26_agreement,2L - -#define SN_id_tc26_constants "id-tc26-constants" -#define NID_id_tc26_constants 994 -#define OBJ_id_tc26_constants OBJ_id_tc26,2L - -#define SN_id_tc26_sign_constants "id-tc26-sign-constants" -#define NID_id_tc26_sign_constants 995 -#define OBJ_id_tc26_sign_constants OBJ_id_tc26_constants,1L - -#define SN_id_tc26_gost_3410_2012_512_constants "id-tc26-gost-3410-2012-512-constants" -#define NID_id_tc26_gost_3410_2012_512_constants 996 -#define OBJ_id_tc26_gost_3410_2012_512_constants OBJ_id_tc26_sign_constants,2L - -#define SN_id_tc26_gost_3410_2012_512_paramSetTest "id-tc26-gost-3410-2012-512-paramSetTest" -#define LN_id_tc26_gost_3410_2012_512_paramSetTest "GOST R 34.10-2012 (512 bit) testing parameter set" -#define NID_id_tc26_gost_3410_2012_512_paramSetTest 997 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetTest OBJ_id_tc26_gost_3410_2012_512_constants,0L - -#define SN_id_tc26_gost_3410_2012_512_paramSetA "id-tc26-gost-3410-2012-512-paramSetA" -#define LN_id_tc26_gost_3410_2012_512_paramSetA "GOST R 34.10-2012 (512 bit) ParamSet A" -#define NID_id_tc26_gost_3410_2012_512_paramSetA 998 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetA OBJ_id_tc26_gost_3410_2012_512_constants,1L - -#define SN_id_tc26_gost_3410_2012_512_paramSetB "id-tc26-gost-3410-2012-512-paramSetB" -#define LN_id_tc26_gost_3410_2012_512_paramSetB "GOST R 34.10-2012 (512 bit) ParamSet B" -#define NID_id_tc26_gost_3410_2012_512_paramSetB 999 -#define OBJ_id_tc26_gost_3410_2012_512_paramSetB OBJ_id_tc26_gost_3410_2012_512_constants,2L - -#define SN_id_tc26_digest_constants "id-tc26-digest-constants" -#define NID_id_tc26_digest_constants 1000 -#define OBJ_id_tc26_digest_constants OBJ_id_tc26_constants,2L - -#define SN_id_tc26_cipher_constants "id-tc26-cipher-constants" -#define NID_id_tc26_cipher_constants 1001 -#define OBJ_id_tc26_cipher_constants OBJ_id_tc26_constants,5L - -#define SN_id_tc26_gost_28147_constants "id-tc26-gost-28147-constants" -#define NID_id_tc26_gost_28147_constants 1002 -#define OBJ_id_tc26_gost_28147_constants OBJ_id_tc26_cipher_constants,1L - -#define SN_id_tc26_gost_28147_param_Z "id-tc26-gost-28147-param-Z" -#define LN_id_tc26_gost_28147_param_Z "GOST 28147-89 TC26 parameter set" -#define NID_id_tc26_gost_28147_param_Z 1003 -#define OBJ_id_tc26_gost_28147_param_Z OBJ_id_tc26_gost_28147_constants,1L - -#define SN_INN "INN" -#define LN_INN "INN" -#define NID_INN 1004 -#define OBJ_INN OBJ_member_body,643L,3L,131L,1L,1L - -#define SN_OGRN "OGRN" -#define LN_OGRN "OGRN" -#define NID_OGRN 1005 -#define OBJ_OGRN OBJ_member_body,643L,100L,1L - -#define SN_SNILS "SNILS" -#define LN_SNILS "SNILS" -#define NID_SNILS 1006 -#define OBJ_SNILS OBJ_member_body,643L,100L,3L - -#define SN_subjectSignTool "subjectSignTool" -#define LN_subjectSignTool "Signing Tool of Subject" -#define NID_subjectSignTool 1007 -#define OBJ_subjectSignTool OBJ_member_body,643L,100L,111L - -#define SN_issuerSignTool "issuerSignTool" -#define LN_issuerSignTool "Signing Tool of Issuer" -#define NID_issuerSignTool 1008 -#define OBJ_issuerSignTool OBJ_member_body,643L,100L,112L - -#define SN_grasshopper_ecb "grasshopper-ecb" -#define NID_grasshopper_ecb 1012 - -#define SN_grasshopper_ctr "grasshopper-ctr" -#define NID_grasshopper_ctr 1013 - -#define SN_grasshopper_ofb "grasshopper-ofb" -#define NID_grasshopper_ofb 1014 - -#define SN_grasshopper_cbc "grasshopper-cbc" -#define NID_grasshopper_cbc 1015 - -#define SN_grasshopper_cfb "grasshopper-cfb" -#define NID_grasshopper_cfb 1016 - -#define SN_grasshopper_mac "grasshopper-mac" -#define NID_grasshopper_mac 1017 - -#define SN_camellia_128_cbc "CAMELLIA-128-CBC" -#define LN_camellia_128_cbc "camellia-128-cbc" -#define NID_camellia_128_cbc 751 -#define OBJ_camellia_128_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,2L - -#define SN_camellia_192_cbc "CAMELLIA-192-CBC" -#define LN_camellia_192_cbc "camellia-192-cbc" -#define NID_camellia_192_cbc 752 -#define OBJ_camellia_192_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,3L - -#define SN_camellia_256_cbc "CAMELLIA-256-CBC" -#define LN_camellia_256_cbc "camellia-256-cbc" -#define NID_camellia_256_cbc 753 -#define OBJ_camellia_256_cbc 1L,2L,392L,200011L,61L,1L,1L,1L,4L - -#define SN_id_camellia128_wrap "id-camellia128-wrap" -#define NID_id_camellia128_wrap 907 -#define OBJ_id_camellia128_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,2L - -#define SN_id_camellia192_wrap "id-camellia192-wrap" -#define NID_id_camellia192_wrap 908 -#define OBJ_id_camellia192_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,3L - -#define SN_id_camellia256_wrap "id-camellia256-wrap" -#define NID_id_camellia256_wrap 909 -#define OBJ_id_camellia256_wrap 1L,2L,392L,200011L,61L,1L,1L,3L,4L - -#define OBJ_ntt_ds 0L,3L,4401L,5L - -#define OBJ_camellia OBJ_ntt_ds,3L,1L,9L - -#define SN_camellia_128_ecb "CAMELLIA-128-ECB" -#define LN_camellia_128_ecb "camellia-128-ecb" -#define NID_camellia_128_ecb 754 -#define OBJ_camellia_128_ecb OBJ_camellia,1L - -#define SN_camellia_128_ofb128 "CAMELLIA-128-OFB" -#define LN_camellia_128_ofb128 "camellia-128-ofb" -#define NID_camellia_128_ofb128 766 -#define OBJ_camellia_128_ofb128 OBJ_camellia,3L - -#define SN_camellia_128_cfb128 "CAMELLIA-128-CFB" -#define LN_camellia_128_cfb128 "camellia-128-cfb" -#define NID_camellia_128_cfb128 757 -#define OBJ_camellia_128_cfb128 OBJ_camellia,4L - -#define SN_camellia_128_gcm "CAMELLIA-128-GCM" -#define LN_camellia_128_gcm "camellia-128-gcm" -#define NID_camellia_128_gcm 961 -#define OBJ_camellia_128_gcm OBJ_camellia,6L - -#define SN_camellia_128_ccm "CAMELLIA-128-CCM" -#define LN_camellia_128_ccm "camellia-128-ccm" -#define NID_camellia_128_ccm 962 -#define OBJ_camellia_128_ccm OBJ_camellia,7L - -#define SN_camellia_128_ctr "CAMELLIA-128-CTR" -#define LN_camellia_128_ctr "camellia-128-ctr" -#define NID_camellia_128_ctr 963 -#define OBJ_camellia_128_ctr OBJ_camellia,9L - -#define SN_camellia_128_cmac "CAMELLIA-128-CMAC" -#define LN_camellia_128_cmac "camellia-128-cmac" -#define NID_camellia_128_cmac 964 -#define OBJ_camellia_128_cmac OBJ_camellia,10L - -#define SN_camellia_192_ecb "CAMELLIA-192-ECB" -#define LN_camellia_192_ecb "camellia-192-ecb" -#define NID_camellia_192_ecb 755 -#define OBJ_camellia_192_ecb OBJ_camellia,21L - -#define SN_camellia_192_ofb128 "CAMELLIA-192-OFB" -#define LN_camellia_192_ofb128 "camellia-192-ofb" -#define NID_camellia_192_ofb128 767 -#define OBJ_camellia_192_ofb128 OBJ_camellia,23L - -#define SN_camellia_192_cfb128 "CAMELLIA-192-CFB" -#define LN_camellia_192_cfb128 "camellia-192-cfb" -#define NID_camellia_192_cfb128 758 -#define OBJ_camellia_192_cfb128 OBJ_camellia,24L - -#define SN_camellia_192_gcm "CAMELLIA-192-GCM" -#define LN_camellia_192_gcm "camellia-192-gcm" -#define NID_camellia_192_gcm 965 -#define OBJ_camellia_192_gcm OBJ_camellia,26L - -#define SN_camellia_192_ccm "CAMELLIA-192-CCM" -#define LN_camellia_192_ccm "camellia-192-ccm" -#define NID_camellia_192_ccm 966 -#define OBJ_camellia_192_ccm OBJ_camellia,27L - -#define SN_camellia_192_ctr "CAMELLIA-192-CTR" -#define LN_camellia_192_ctr "camellia-192-ctr" -#define NID_camellia_192_ctr 967 -#define OBJ_camellia_192_ctr OBJ_camellia,29L - -#define SN_camellia_192_cmac "CAMELLIA-192-CMAC" -#define LN_camellia_192_cmac "camellia-192-cmac" -#define NID_camellia_192_cmac 968 -#define OBJ_camellia_192_cmac OBJ_camellia,30L - -#define SN_camellia_256_ecb "CAMELLIA-256-ECB" -#define LN_camellia_256_ecb "camellia-256-ecb" -#define NID_camellia_256_ecb 756 -#define OBJ_camellia_256_ecb OBJ_camellia,41L - -#define SN_camellia_256_ofb128 "CAMELLIA-256-OFB" -#define LN_camellia_256_ofb128 "camellia-256-ofb" -#define NID_camellia_256_ofb128 768 -#define OBJ_camellia_256_ofb128 OBJ_camellia,43L - -#define SN_camellia_256_cfb128 "CAMELLIA-256-CFB" -#define LN_camellia_256_cfb128 "camellia-256-cfb" -#define NID_camellia_256_cfb128 759 -#define OBJ_camellia_256_cfb128 OBJ_camellia,44L - -#define SN_camellia_256_gcm "CAMELLIA-256-GCM" -#define LN_camellia_256_gcm "camellia-256-gcm" -#define NID_camellia_256_gcm 969 -#define OBJ_camellia_256_gcm OBJ_camellia,46L - -#define SN_camellia_256_ccm "CAMELLIA-256-CCM" -#define LN_camellia_256_ccm "camellia-256-ccm" -#define NID_camellia_256_ccm 970 -#define OBJ_camellia_256_ccm OBJ_camellia,47L - -#define SN_camellia_256_ctr "CAMELLIA-256-CTR" -#define LN_camellia_256_ctr "camellia-256-ctr" -#define NID_camellia_256_ctr 971 -#define OBJ_camellia_256_ctr OBJ_camellia,49L - -#define SN_camellia_256_cmac "CAMELLIA-256-CMAC" -#define LN_camellia_256_cmac "camellia-256-cmac" -#define NID_camellia_256_cmac 972 -#define OBJ_camellia_256_cmac OBJ_camellia,50L - -#define SN_camellia_128_cfb1 "CAMELLIA-128-CFB1" -#define LN_camellia_128_cfb1 "camellia-128-cfb1" -#define NID_camellia_128_cfb1 760 - -#define SN_camellia_192_cfb1 "CAMELLIA-192-CFB1" -#define LN_camellia_192_cfb1 "camellia-192-cfb1" -#define NID_camellia_192_cfb1 761 - -#define SN_camellia_256_cfb1 "CAMELLIA-256-CFB1" -#define LN_camellia_256_cfb1 "camellia-256-cfb1" -#define NID_camellia_256_cfb1 762 - -#define SN_camellia_128_cfb8 "CAMELLIA-128-CFB8" -#define LN_camellia_128_cfb8 "camellia-128-cfb8" -#define NID_camellia_128_cfb8 763 - -#define SN_camellia_192_cfb8 "CAMELLIA-192-CFB8" -#define LN_camellia_192_cfb8 "camellia-192-cfb8" -#define NID_camellia_192_cfb8 764 - -#define SN_camellia_256_cfb8 "CAMELLIA-256-CFB8" -#define LN_camellia_256_cfb8 "camellia-256-cfb8" -#define NID_camellia_256_cfb8 765 - -#define SN_kisa "KISA" -#define LN_kisa "kisa" -#define NID_kisa 773 -#define OBJ_kisa OBJ_member_body,410L,200004L - -#define SN_seed_ecb "SEED-ECB" -#define LN_seed_ecb "seed-ecb" -#define NID_seed_ecb 776 -#define OBJ_seed_ecb OBJ_kisa,1L,3L - -#define SN_seed_cbc "SEED-CBC" -#define LN_seed_cbc "seed-cbc" -#define NID_seed_cbc 777 -#define OBJ_seed_cbc OBJ_kisa,1L,4L - -#define SN_seed_cfb128 "SEED-CFB" -#define LN_seed_cfb128 "seed-cfb" -#define NID_seed_cfb128 779 -#define OBJ_seed_cfb128 OBJ_kisa,1L,5L - -#define SN_seed_ofb128 "SEED-OFB" -#define LN_seed_ofb128 "seed-ofb" -#define NID_seed_ofb128 778 -#define OBJ_seed_ofb128 OBJ_kisa,1L,6L - -#define SN_hmac "HMAC" -#define LN_hmac "hmac" -#define NID_hmac 855 - -#define SN_cmac "CMAC" -#define LN_cmac "cmac" -#define NID_cmac 894 - -#define SN_rc4_hmac_md5 "RC4-HMAC-MD5" -#define LN_rc4_hmac_md5 "rc4-hmac-md5" -#define NID_rc4_hmac_md5 915 - -#define SN_aes_128_cbc_hmac_sha1 "AES-128-CBC-HMAC-SHA1" -#define LN_aes_128_cbc_hmac_sha1 "aes-128-cbc-hmac-sha1" -#define NID_aes_128_cbc_hmac_sha1 916 - -#define SN_aes_192_cbc_hmac_sha1 "AES-192-CBC-HMAC-SHA1" -#define LN_aes_192_cbc_hmac_sha1 "aes-192-cbc-hmac-sha1" -#define NID_aes_192_cbc_hmac_sha1 917 - -#define SN_aes_256_cbc_hmac_sha1 "AES-256-CBC-HMAC-SHA1" -#define LN_aes_256_cbc_hmac_sha1 "aes-256-cbc-hmac-sha1" -#define NID_aes_256_cbc_hmac_sha1 918 - -#define SN_aes_128_cbc_hmac_sha256 "AES-128-CBC-HMAC-SHA256" -#define LN_aes_128_cbc_hmac_sha256 "aes-128-cbc-hmac-sha256" -#define NID_aes_128_cbc_hmac_sha256 948 - -#define SN_aes_192_cbc_hmac_sha256 "AES-192-CBC-HMAC-SHA256" -#define LN_aes_192_cbc_hmac_sha256 "aes-192-cbc-hmac-sha256" -#define NID_aes_192_cbc_hmac_sha256 949 - -#define SN_aes_256_cbc_hmac_sha256 "AES-256-CBC-HMAC-SHA256" -#define LN_aes_256_cbc_hmac_sha256 "aes-256-cbc-hmac-sha256" -#define NID_aes_256_cbc_hmac_sha256 950 - -#define SN_chacha20_poly1305 "ChaCha20-Poly1305" -#define LN_chacha20_poly1305 "chacha20-poly1305" -#define NID_chacha20_poly1305 1018 - -#define SN_chacha20 "ChaCha20" -#define LN_chacha20 "chacha20" -#define NID_chacha20 1019 - -#define SN_dhpublicnumber "dhpublicnumber" -#define LN_dhpublicnumber "X9.42 DH" -#define NID_dhpublicnumber 920 -#define OBJ_dhpublicnumber OBJ_ISO_US,10046L,2L,1L - -#define SN_brainpoolP160r1 "brainpoolP160r1" -#define NID_brainpoolP160r1 921 -#define OBJ_brainpoolP160r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,1L - -#define SN_brainpoolP160t1 "brainpoolP160t1" -#define NID_brainpoolP160t1 922 -#define OBJ_brainpoolP160t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,2L - -#define SN_brainpoolP192r1 "brainpoolP192r1" -#define NID_brainpoolP192r1 923 -#define OBJ_brainpoolP192r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,3L - -#define SN_brainpoolP192t1 "brainpoolP192t1" -#define NID_brainpoolP192t1 924 -#define OBJ_brainpoolP192t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,4L - -#define SN_brainpoolP224r1 "brainpoolP224r1" -#define NID_brainpoolP224r1 925 -#define OBJ_brainpoolP224r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,5L - -#define SN_brainpoolP224t1 "brainpoolP224t1" -#define NID_brainpoolP224t1 926 -#define OBJ_brainpoolP224t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,6L - -#define SN_brainpoolP256r1 "brainpoolP256r1" -#define NID_brainpoolP256r1 927 -#define OBJ_brainpoolP256r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,7L - -#define SN_brainpoolP256t1 "brainpoolP256t1" -#define NID_brainpoolP256t1 928 -#define OBJ_brainpoolP256t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,8L - -#define SN_brainpoolP320r1 "brainpoolP320r1" -#define NID_brainpoolP320r1 929 -#define OBJ_brainpoolP320r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,9L - -#define SN_brainpoolP320t1 "brainpoolP320t1" -#define NID_brainpoolP320t1 930 -#define OBJ_brainpoolP320t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,10L - -#define SN_brainpoolP384r1 "brainpoolP384r1" -#define NID_brainpoolP384r1 931 -#define OBJ_brainpoolP384r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,11L - -#define SN_brainpoolP384t1 "brainpoolP384t1" -#define NID_brainpoolP384t1 932 -#define OBJ_brainpoolP384t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,12L - -#define SN_brainpoolP512r1 "brainpoolP512r1" -#define NID_brainpoolP512r1 933 -#define OBJ_brainpoolP512r1 1L,3L,36L,3L,3L,2L,8L,1L,1L,13L - -#define SN_brainpoolP512t1 "brainpoolP512t1" -#define NID_brainpoolP512t1 934 -#define OBJ_brainpoolP512t1 1L,3L,36L,3L,3L,2L,8L,1L,1L,14L - -#define OBJ_x9_63_scheme 1L,3L,133L,16L,840L,63L,0L - -#define OBJ_secg_scheme OBJ_certicom_arc,1L - -#define SN_dhSinglePass_stdDH_sha1kdf_scheme "dhSinglePass-stdDH-sha1kdf-scheme" -#define NID_dhSinglePass_stdDH_sha1kdf_scheme 936 -#define OBJ_dhSinglePass_stdDH_sha1kdf_scheme OBJ_x9_63_scheme,2L - -#define SN_dhSinglePass_stdDH_sha224kdf_scheme "dhSinglePass-stdDH-sha224kdf-scheme" -#define NID_dhSinglePass_stdDH_sha224kdf_scheme 937 -#define OBJ_dhSinglePass_stdDH_sha224kdf_scheme OBJ_secg_scheme,11L,0L - -#define SN_dhSinglePass_stdDH_sha256kdf_scheme "dhSinglePass-stdDH-sha256kdf-scheme" -#define NID_dhSinglePass_stdDH_sha256kdf_scheme 938 -#define OBJ_dhSinglePass_stdDH_sha256kdf_scheme OBJ_secg_scheme,11L,1L - -#define SN_dhSinglePass_stdDH_sha384kdf_scheme "dhSinglePass-stdDH-sha384kdf-scheme" -#define NID_dhSinglePass_stdDH_sha384kdf_scheme 939 -#define OBJ_dhSinglePass_stdDH_sha384kdf_scheme OBJ_secg_scheme,11L,2L - -#define SN_dhSinglePass_stdDH_sha512kdf_scheme "dhSinglePass-stdDH-sha512kdf-scheme" -#define NID_dhSinglePass_stdDH_sha512kdf_scheme 940 -#define OBJ_dhSinglePass_stdDH_sha512kdf_scheme OBJ_secg_scheme,11L,3L - -#define SN_dhSinglePass_cofactorDH_sha1kdf_scheme "dhSinglePass-cofactorDH-sha1kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha1kdf_scheme 941 -#define OBJ_dhSinglePass_cofactorDH_sha1kdf_scheme OBJ_x9_63_scheme,3L - -#define SN_dhSinglePass_cofactorDH_sha224kdf_scheme "dhSinglePass-cofactorDH-sha224kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha224kdf_scheme 942 -#define OBJ_dhSinglePass_cofactorDH_sha224kdf_scheme OBJ_secg_scheme,14L,0L - -#define SN_dhSinglePass_cofactorDH_sha256kdf_scheme "dhSinglePass-cofactorDH-sha256kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha256kdf_scheme 943 -#define OBJ_dhSinglePass_cofactorDH_sha256kdf_scheme OBJ_secg_scheme,14L,1L - -#define SN_dhSinglePass_cofactorDH_sha384kdf_scheme "dhSinglePass-cofactorDH-sha384kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha384kdf_scheme 944 -#define OBJ_dhSinglePass_cofactorDH_sha384kdf_scheme OBJ_secg_scheme,14L,2L - -#define SN_dhSinglePass_cofactorDH_sha512kdf_scheme "dhSinglePass-cofactorDH-sha512kdf-scheme" -#define NID_dhSinglePass_cofactorDH_sha512kdf_scheme 945 -#define OBJ_dhSinglePass_cofactorDH_sha512kdf_scheme OBJ_secg_scheme,14L,3L - -#define SN_dh_std_kdf "dh-std-kdf" -#define NID_dh_std_kdf 946 - -#define SN_dh_cofactor_kdf "dh-cofactor-kdf" -#define NID_dh_cofactor_kdf 947 - -#define SN_ct_precert_scts "ct_precert_scts" -#define LN_ct_precert_scts "CT Precertificate SCTs" -#define NID_ct_precert_scts 951 -#define OBJ_ct_precert_scts 1L,3L,6L,1L,4L,1L,11129L,2L,4L,2L - -#define SN_ct_precert_poison "ct_precert_poison" -#define LN_ct_precert_poison "CT Precertificate Poison" -#define NID_ct_precert_poison 952 -#define OBJ_ct_precert_poison 1L,3L,6L,1L,4L,1L,11129L,2L,4L,3L - -#define SN_ct_precert_signer "ct_precert_signer" -#define LN_ct_precert_signer "CT Precertificate Signer" -#define NID_ct_precert_signer 953 -#define OBJ_ct_precert_signer 1L,3L,6L,1L,4L,1L,11129L,2L,4L,4L - -#define SN_ct_cert_scts "ct_cert_scts" -#define LN_ct_cert_scts "CT Certificate SCTs" -#define NID_ct_cert_scts 954 -#define OBJ_ct_cert_scts 1L,3L,6L,1L,4L,1L,11129L,2L,4L,5L - -#define SN_jurisdictionLocalityName "jurisdictionL" -#define LN_jurisdictionLocalityName "jurisdictionLocalityName" -#define NID_jurisdictionLocalityName 955 -#define OBJ_jurisdictionLocalityName 1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,1L - -#define SN_jurisdictionStateOrProvinceName "jurisdictionST" -#define LN_jurisdictionStateOrProvinceName "jurisdictionStateOrProvinceName" -#define NID_jurisdictionStateOrProvinceName 956 -#define OBJ_jurisdictionStateOrProvinceName 1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,2L - -#define SN_jurisdictionCountryName "jurisdictionC" -#define LN_jurisdictionCountryName "jurisdictionCountryName" -#define NID_jurisdictionCountryName 957 -#define OBJ_jurisdictionCountryName 1L,3L,6L,1L,4L,1L,311L,60L,2L,1L,3L - -#define SN_id_scrypt "id-scrypt" -#define NID_id_scrypt 973 -#define OBJ_id_scrypt 1L,3L,6L,1L,4L,1L,11591L,4L,11L - -#define SN_tls1_prf "TLS1-PRF" -#define LN_tls1_prf "tls1-prf" -#define NID_tls1_prf 1021 - -#define SN_hkdf "HKDF" -#define LN_hkdf "hkdf" -#define NID_hkdf 1036 - -#define SN_id_pkinit "id-pkinit" -#define NID_id_pkinit 1031 -#define OBJ_id_pkinit 1L,3L,6L,1L,5L,2L,3L - -#define SN_pkInitClientAuth "pkInitClientAuth" -#define LN_pkInitClientAuth "PKINIT Client Auth" -#define NID_pkInitClientAuth 1032 -#define OBJ_pkInitClientAuth OBJ_id_pkinit,4L - -#define SN_pkInitKDC "pkInitKDC" -#define LN_pkInitKDC "Signing KDC Response" -#define NID_pkInitKDC 1033 -#define OBJ_pkInitKDC OBJ_id_pkinit,5L - -#define SN_X25519 "X25519" -#define NID_X25519 1034 -#define OBJ_X25519 1L,3L,101L,110L - -#define SN_X448 "X448" -#define NID_X448 1035 -#define OBJ_X448 1L,3L,101L,111L - -#define SN_kx_rsa "KxRSA" -#define LN_kx_rsa "kx-rsa" -#define NID_kx_rsa 1037 - -#define SN_kx_ecdhe "KxECDHE" -#define LN_kx_ecdhe "kx-ecdhe" -#define NID_kx_ecdhe 1038 - -#define SN_kx_dhe "KxDHE" -#define LN_kx_dhe "kx-dhe" -#define NID_kx_dhe 1039 - -#define SN_kx_ecdhe_psk "KxECDHE-PSK" -#define LN_kx_ecdhe_psk "kx-ecdhe-psk" -#define NID_kx_ecdhe_psk 1040 - -#define SN_kx_dhe_psk "KxDHE-PSK" -#define LN_kx_dhe_psk "kx-dhe-psk" -#define NID_kx_dhe_psk 1041 - -#define SN_kx_rsa_psk "KxRSA_PSK" -#define LN_kx_rsa_psk "kx-rsa-psk" -#define NID_kx_rsa_psk 1042 - -#define SN_kx_psk "KxPSK" -#define LN_kx_psk "kx-psk" -#define NID_kx_psk 1043 - -#define SN_kx_srp "KxSRP" -#define LN_kx_srp "kx-srp" -#define NID_kx_srp 1044 - -#define SN_kx_gost "KxGOST" -#define LN_kx_gost "kx-gost" -#define NID_kx_gost 1045 - -#define SN_auth_rsa "AuthRSA" -#define LN_auth_rsa "auth-rsa" -#define NID_auth_rsa 1046 - -#define SN_auth_ecdsa "AuthECDSA" -#define LN_auth_ecdsa "auth-ecdsa" -#define NID_auth_ecdsa 1047 - -#define SN_auth_psk "AuthPSK" -#define LN_auth_psk "auth-psk" -#define NID_auth_psk 1048 - -#define SN_auth_dss "AuthDSS" -#define LN_auth_dss "auth-dss" -#define NID_auth_dss 1049 - -#define SN_auth_gost01 "AuthGOST01" -#define LN_auth_gost01 "auth-gost01" -#define NID_auth_gost01 1050 - -#define SN_auth_gost12 "AuthGOST12" -#define LN_auth_gost12 "auth-gost12" -#define NID_auth_gost12 1051 - -#define SN_auth_srp "AuthSRP" -#define LN_auth_srp "auth-srp" -#define NID_auth_srp 1052 - -#define SN_auth_null "AuthNULL" -#define LN_auth_null "auth-null" -#define NID_auth_null 1053 diff --git a/android/armeabi/include/openssl/objects.h b/android/armeabi/include/openssl/objects.h deleted file mode 100644 index 09d614ff..00000000 --- a/android/armeabi/include/openssl/objects.h +++ /dev/null @@ -1,1097 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OBJECTS_H -# define HEADER_OBJECTS_H - -# define USE_OBJ_MAC - -# ifdef USE_OBJ_MAC -# include <openssl/obj_mac.h> -# else -# define SN_undef "UNDEF" -# define LN_undef "undefined" -# define NID_undef 0 -# define OBJ_undef 0L - -# define SN_Algorithm "Algorithm" -# define LN_algorithm "algorithm" -# define NID_algorithm 38 -# define OBJ_algorithm 1L,3L,14L,3L,2L - -# define LN_rsadsi "rsadsi" -# define NID_rsadsi 1 -# define OBJ_rsadsi 1L,2L,840L,113549L - -# define LN_pkcs "pkcs" -# define NID_pkcs 2 -# define OBJ_pkcs OBJ_rsadsi,1L - -# define SN_md2 "MD2" -# define LN_md2 "md2" -# define NID_md2 3 -# define OBJ_md2 OBJ_rsadsi,2L,2L - -# define SN_md5 "MD5" -# define LN_md5 "md5" -# define NID_md5 4 -# define OBJ_md5 OBJ_rsadsi,2L,5L - -# define SN_rc4 "RC4" -# define LN_rc4 "rc4" -# define NID_rc4 5 -# define OBJ_rc4 OBJ_rsadsi,3L,4L - -# define LN_rsaEncryption "rsaEncryption" -# define NID_rsaEncryption 6 -# define OBJ_rsaEncryption OBJ_pkcs,1L,1L - -# define SN_md2WithRSAEncryption "RSA-MD2" -# define LN_md2WithRSAEncryption "md2WithRSAEncryption" -# define NID_md2WithRSAEncryption 7 -# define OBJ_md2WithRSAEncryption OBJ_pkcs,1L,2L - -# define SN_md5WithRSAEncryption "RSA-MD5" -# define LN_md5WithRSAEncryption "md5WithRSAEncryption" -# define NID_md5WithRSAEncryption 8 -# define OBJ_md5WithRSAEncryption OBJ_pkcs,1L,4L - -# define SN_pbeWithMD2AndDES_CBC "PBE-MD2-DES" -# define LN_pbeWithMD2AndDES_CBC "pbeWithMD2AndDES-CBC" -# define NID_pbeWithMD2AndDES_CBC 9 -# define OBJ_pbeWithMD2AndDES_CBC OBJ_pkcs,5L,1L - -# define SN_pbeWithMD5AndDES_CBC "PBE-MD5-DES" -# define LN_pbeWithMD5AndDES_CBC "pbeWithMD5AndDES-CBC" -# define NID_pbeWithMD5AndDES_CBC 10 -# define OBJ_pbeWithMD5AndDES_CBC OBJ_pkcs,5L,3L - -# define LN_X500 "X500" -# define NID_X500 11 -# define OBJ_X500 2L,5L - -# define LN_X509 "X509" -# define NID_X509 12 -# define OBJ_X509 OBJ_X500,4L - -# define SN_commonName "CN" -# define LN_commonName "commonName" -# define NID_commonName 13 -# define OBJ_commonName OBJ_X509,3L - -# define SN_countryName "C" -# define LN_countryName "countryName" -# define NID_countryName 14 -# define OBJ_countryName OBJ_X509,6L - -# define SN_localityName "L" -# define LN_localityName "localityName" -# define NID_localityName 15 -# define OBJ_localityName OBJ_X509,7L - -/* Postal Address? PA */ - -/* should be "ST" (rfc1327) but MS uses 'S' */ -# define SN_stateOrProvinceName "ST" -# define LN_stateOrProvinceName "stateOrProvinceName" -# define NID_stateOrProvinceName 16 -# define OBJ_stateOrProvinceName OBJ_X509,8L - -# define SN_organizationName "O" -# define LN_organizationName "organizationName" -# define NID_organizationName 17 -# define OBJ_organizationName OBJ_X509,10L - -# define SN_organizationalUnitName "OU" -# define LN_organizationalUnitName "organizationalUnitName" -# define NID_organizationalUnitName 18 -# define OBJ_organizationalUnitName OBJ_X509,11L - -# define SN_rsa "RSA" -# define LN_rsa "rsa" -# define NID_rsa 19 -# define OBJ_rsa OBJ_X500,8L,1L,1L - -# define LN_pkcs7 "pkcs7" -# define NID_pkcs7 20 -# define OBJ_pkcs7 OBJ_pkcs,7L - -# define LN_pkcs7_data "pkcs7-data" -# define NID_pkcs7_data 21 -# define OBJ_pkcs7_data OBJ_pkcs7,1L - -# define LN_pkcs7_signed "pkcs7-signedData" -# define NID_pkcs7_signed 22 -# define OBJ_pkcs7_signed OBJ_pkcs7,2L - -# define LN_pkcs7_enveloped "pkcs7-envelopedData" -# define NID_pkcs7_enveloped 23 -# define OBJ_pkcs7_enveloped OBJ_pkcs7,3L - -# define LN_pkcs7_signedAndEnveloped "pkcs7-signedAndEnvelopedData" -# define NID_pkcs7_signedAndEnveloped 24 -# define OBJ_pkcs7_signedAndEnveloped OBJ_pkcs7,4L - -# define LN_pkcs7_digest "pkcs7-digestData" -# define NID_pkcs7_digest 25 -# define OBJ_pkcs7_digest OBJ_pkcs7,5L - -# define LN_pkcs7_encrypted "pkcs7-encryptedData" -# define NID_pkcs7_encrypted 26 -# define OBJ_pkcs7_encrypted OBJ_pkcs7,6L - -# define LN_pkcs3 "pkcs3" -# define NID_pkcs3 27 -# define OBJ_pkcs3 OBJ_pkcs,3L - -# define LN_dhKeyAgreement "dhKeyAgreement" -# define NID_dhKeyAgreement 28 -# define OBJ_dhKeyAgreement OBJ_pkcs3,1L - -# define SN_des_ecb "DES-ECB" -# define LN_des_ecb "des-ecb" -# define NID_des_ecb 29 -# define OBJ_des_ecb OBJ_algorithm,6L - -# define SN_des_cfb64 "DES-CFB" -# define LN_des_cfb64 "des-cfb" -# define NID_des_cfb64 30 -/* IV + num */ -# define OBJ_des_cfb64 OBJ_algorithm,9L - -# define SN_des_cbc "DES-CBC" -# define LN_des_cbc "des-cbc" -# define NID_des_cbc 31 -/* IV */ -# define OBJ_des_cbc OBJ_algorithm,7L - -# define SN_des_ede "DES-EDE" -# define LN_des_ede "des-ede" -# define NID_des_ede 32 -/* ?? */ -# define OBJ_des_ede OBJ_algorithm,17L - -# define SN_des_ede3 "DES-EDE3" -# define LN_des_ede3 "des-ede3" -# define NID_des_ede3 33 - -# define SN_idea_cbc "IDEA-CBC" -# define LN_idea_cbc "idea-cbc" -# define NID_idea_cbc 34 -# define OBJ_idea_cbc 1L,3L,6L,1L,4L,1L,188L,7L,1L,1L,2L - -# define SN_idea_cfb64 "IDEA-CFB" -# define LN_idea_cfb64 "idea-cfb" -# define NID_idea_cfb64 35 - -# define SN_idea_ecb "IDEA-ECB" -# define LN_idea_ecb "idea-ecb" -# define NID_idea_ecb 36 - -# define SN_rc2_cbc "RC2-CBC" -# define LN_rc2_cbc "rc2-cbc" -# define NID_rc2_cbc 37 -# define OBJ_rc2_cbc OBJ_rsadsi,3L,2L - -# define SN_rc2_ecb "RC2-ECB" -# define LN_rc2_ecb "rc2-ecb" -# define NID_rc2_ecb 38 - -# define SN_rc2_cfb64 "RC2-CFB" -# define LN_rc2_cfb64 "rc2-cfb" -# define NID_rc2_cfb64 39 - -# define SN_rc2_ofb64 "RC2-OFB" -# define LN_rc2_ofb64 "rc2-ofb" -# define NID_rc2_ofb64 40 - -# define SN_sha "SHA" -# define LN_sha "sha" -# define NID_sha 41 -# define OBJ_sha OBJ_algorithm,18L - -# define SN_shaWithRSAEncryption "RSA-SHA" -# define LN_shaWithRSAEncryption "shaWithRSAEncryption" -# define NID_shaWithRSAEncryption 42 -# define OBJ_shaWithRSAEncryption OBJ_algorithm,15L - -# define SN_des_ede_cbc "DES-EDE-CBC" -# define LN_des_ede_cbc "des-ede-cbc" -# define NID_des_ede_cbc 43 - -# define SN_des_ede3_cbc "DES-EDE3-CBC" -# define LN_des_ede3_cbc "des-ede3-cbc" -# define NID_des_ede3_cbc 44 -# define OBJ_des_ede3_cbc OBJ_rsadsi,3L,7L - -# define SN_des_ofb64 "DES-OFB" -# define LN_des_ofb64 "des-ofb" -# define NID_des_ofb64 45 -# define OBJ_des_ofb64 OBJ_algorithm,8L - -# define SN_idea_ofb64 "IDEA-OFB" -# define LN_idea_ofb64 "idea-ofb" -# define NID_idea_ofb64 46 - -# define LN_pkcs9 "pkcs9" -# define NID_pkcs9 47 -# define OBJ_pkcs9 OBJ_pkcs,9L - -# define SN_pkcs9_emailAddress "Email" -# define LN_pkcs9_emailAddress "emailAddress" -# define NID_pkcs9_emailAddress 48 -# define OBJ_pkcs9_emailAddress OBJ_pkcs9,1L - -# define LN_pkcs9_unstructuredName "unstructuredName" -# define NID_pkcs9_unstructuredName 49 -# define OBJ_pkcs9_unstructuredName OBJ_pkcs9,2L - -# define LN_pkcs9_contentType "contentType" -# define NID_pkcs9_contentType 50 -# define OBJ_pkcs9_contentType OBJ_pkcs9,3L - -# define LN_pkcs9_messageDigest "messageDigest" -# define NID_pkcs9_messageDigest 51 -# define OBJ_pkcs9_messageDigest OBJ_pkcs9,4L - -# define LN_pkcs9_signingTime "signingTime" -# define NID_pkcs9_signingTime 52 -# define OBJ_pkcs9_signingTime OBJ_pkcs9,5L - -# define LN_pkcs9_countersignature "countersignature" -# define NID_pkcs9_countersignature 53 -# define OBJ_pkcs9_countersignature OBJ_pkcs9,6L - -# define LN_pkcs9_challengePassword "challengePassword" -# define NID_pkcs9_challengePassword 54 -# define OBJ_pkcs9_challengePassword OBJ_pkcs9,7L - -# define LN_pkcs9_unstructuredAddress "unstructuredAddress" -# define NID_pkcs9_unstructuredAddress 55 -# define OBJ_pkcs9_unstructuredAddress OBJ_pkcs9,8L - -# define LN_pkcs9_extCertAttributes "extendedCertificateAttributes" -# define NID_pkcs9_extCertAttributes 56 -# define OBJ_pkcs9_extCertAttributes OBJ_pkcs9,9L - -# define SN_netscape "Netscape" -# define LN_netscape "Netscape Communications Corp." -# define NID_netscape 57 -# define OBJ_netscape 2L,16L,840L,1L,113730L - -# define SN_netscape_cert_extension "nsCertExt" -# define LN_netscape_cert_extension "Netscape Certificate Extension" -# define NID_netscape_cert_extension 58 -# define OBJ_netscape_cert_extension OBJ_netscape,1L - -# define SN_netscape_data_type "nsDataType" -# define LN_netscape_data_type "Netscape Data Type" -# define NID_netscape_data_type 59 -# define OBJ_netscape_data_type OBJ_netscape,2L - -# define SN_des_ede_cfb64 "DES-EDE-CFB" -# define LN_des_ede_cfb64 "des-ede-cfb" -# define NID_des_ede_cfb64 60 - -# define SN_des_ede3_cfb64 "DES-EDE3-CFB" -# define LN_des_ede3_cfb64 "des-ede3-cfb" -# define NID_des_ede3_cfb64 61 - -# define SN_des_ede_ofb64 "DES-EDE-OFB" -# define LN_des_ede_ofb64 "des-ede-ofb" -# define NID_des_ede_ofb64 62 - -# define SN_des_ede3_ofb64 "DES-EDE3-OFB" -# define LN_des_ede3_ofb64 "des-ede3-ofb" -# define NID_des_ede3_ofb64 63 - -/* I'm not sure about the object ID */ -# define SN_sha1 "SHA1" -# define LN_sha1 "sha1" -# define NID_sha1 64 -# define OBJ_sha1 OBJ_algorithm,26L -/* 28 Jun 1996 - eay */ -/* #define OBJ_sha1 1L,3L,14L,2L,26L,05L <- wrong */ - -# define SN_sha1WithRSAEncryption "RSA-SHA1" -# define LN_sha1WithRSAEncryption "sha1WithRSAEncryption" -# define NID_sha1WithRSAEncryption 65 -# define OBJ_sha1WithRSAEncryption OBJ_pkcs,1L,5L - -# define SN_dsaWithSHA "DSA-SHA" -# define LN_dsaWithSHA "dsaWithSHA" -# define NID_dsaWithSHA 66 -# define OBJ_dsaWithSHA OBJ_algorithm,13L - -# define SN_dsa_2 "DSA-old" -# define LN_dsa_2 "dsaEncryption-old" -# define NID_dsa_2 67 -# define OBJ_dsa_2 OBJ_algorithm,12L - -/* proposed by microsoft to RSA */ -# define SN_pbeWithSHA1AndRC2_CBC "PBE-SHA1-RC2-64" -# define LN_pbeWithSHA1AndRC2_CBC "pbeWithSHA1AndRC2-CBC" -# define NID_pbeWithSHA1AndRC2_CBC 68 -# define OBJ_pbeWithSHA1AndRC2_CBC OBJ_pkcs,5L,11L - -/* - * proposed by microsoft to RSA as pbeWithSHA1AndRC4: it is now defined - * explicitly in PKCS#5 v2.0 as id-PBKDF2 which is something completely - * different. - */ -# define LN_id_pbkdf2 "PBKDF2" -# define NID_id_pbkdf2 69 -# define OBJ_id_pbkdf2 OBJ_pkcs,5L,12L - -# define SN_dsaWithSHA1_2 "DSA-SHA1-old" -# define LN_dsaWithSHA1_2 "dsaWithSHA1-old" -# define NID_dsaWithSHA1_2 70 -/* Got this one from 'sdn706r20.pdf' which is actually an NSA document :-) */ -# define OBJ_dsaWithSHA1_2 OBJ_algorithm,27L - -# define SN_netscape_cert_type "nsCertType" -# define LN_netscape_cert_type "Netscape Cert Type" -# define NID_netscape_cert_type 71 -# define OBJ_netscape_cert_type OBJ_netscape_cert_extension,1L - -# define SN_netscape_base_url "nsBaseUrl" -# define LN_netscape_base_url "Netscape Base Url" -# define NID_netscape_base_url 72 -# define OBJ_netscape_base_url OBJ_netscape_cert_extension,2L - -# define SN_netscape_revocation_url "nsRevocationUrl" -# define LN_netscape_revocation_url "Netscape Revocation Url" -# define NID_netscape_revocation_url 73 -# define OBJ_netscape_revocation_url OBJ_netscape_cert_extension,3L - -# define SN_netscape_ca_revocation_url "nsCaRevocationUrl" -# define LN_netscape_ca_revocation_url "Netscape CA Revocation Url" -# define NID_netscape_ca_revocation_url 74 -# define OBJ_netscape_ca_revocation_url OBJ_netscape_cert_extension,4L - -# define SN_netscape_renewal_url "nsRenewalUrl" -# define LN_netscape_renewal_url "Netscape Renewal Url" -# define NID_netscape_renewal_url 75 -# define OBJ_netscape_renewal_url OBJ_netscape_cert_extension,7L - -# define SN_netscape_ca_policy_url "nsCaPolicyUrl" -# define LN_netscape_ca_policy_url "Netscape CA Policy Url" -# define NID_netscape_ca_policy_url 76 -# define OBJ_netscape_ca_policy_url OBJ_netscape_cert_extension,8L - -# define SN_netscape_ssl_server_name "nsSslServerName" -# define LN_netscape_ssl_server_name "Netscape SSL Server Name" -# define NID_netscape_ssl_server_name 77 -# define OBJ_netscape_ssl_server_name OBJ_netscape_cert_extension,12L - -# define SN_netscape_comment "nsComment" -# define LN_netscape_comment "Netscape Comment" -# define NID_netscape_comment 78 -# define OBJ_netscape_comment OBJ_netscape_cert_extension,13L - -# define SN_netscape_cert_sequence "nsCertSequence" -# define LN_netscape_cert_sequence "Netscape Certificate Sequence" -# define NID_netscape_cert_sequence 79 -# define OBJ_netscape_cert_sequence OBJ_netscape_data_type,5L - -# define SN_desx_cbc "DESX-CBC" -# define LN_desx_cbc "desx-cbc" -# define NID_desx_cbc 80 - -# define SN_id_ce "id-ce" -# define NID_id_ce 81 -# define OBJ_id_ce 2L,5L,29L - -# define SN_subject_key_identifier "subjectKeyIdentifier" -# define LN_subject_key_identifier "X509v3 Subject Key Identifier" -# define NID_subject_key_identifier 82 -# define OBJ_subject_key_identifier OBJ_id_ce,14L - -# define SN_key_usage "keyUsage" -# define LN_key_usage "X509v3 Key Usage" -# define NID_key_usage 83 -# define OBJ_key_usage OBJ_id_ce,15L - -# define SN_private_key_usage_period "privateKeyUsagePeriod" -# define LN_private_key_usage_period "X509v3 Private Key Usage Period" -# define NID_private_key_usage_period 84 -# define OBJ_private_key_usage_period OBJ_id_ce,16L - -# define SN_subject_alt_name "subjectAltName" -# define LN_subject_alt_name "X509v3 Subject Alternative Name" -# define NID_subject_alt_name 85 -# define OBJ_subject_alt_name OBJ_id_ce,17L - -# define SN_issuer_alt_name "issuerAltName" -# define LN_issuer_alt_name "X509v3 Issuer Alternative Name" -# define NID_issuer_alt_name 86 -# define OBJ_issuer_alt_name OBJ_id_ce,18L - -# define SN_basic_constraints "basicConstraints" -# define LN_basic_constraints "X509v3 Basic Constraints" -# define NID_basic_constraints 87 -# define OBJ_basic_constraints OBJ_id_ce,19L - -# define SN_crl_number "crlNumber" -# define LN_crl_number "X509v3 CRL Number" -# define NID_crl_number 88 -# define OBJ_crl_number OBJ_id_ce,20L - -# define SN_certificate_policies "certificatePolicies" -# define LN_certificate_policies "X509v3 Certificate Policies" -# define NID_certificate_policies 89 -# define OBJ_certificate_policies OBJ_id_ce,32L - -# define SN_authority_key_identifier "authorityKeyIdentifier" -# define LN_authority_key_identifier "X509v3 Authority Key Identifier" -# define NID_authority_key_identifier 90 -# define OBJ_authority_key_identifier OBJ_id_ce,35L - -# define SN_bf_cbc "BF-CBC" -# define LN_bf_cbc "bf-cbc" -# define NID_bf_cbc 91 -# define OBJ_bf_cbc 1L,3L,6L,1L,4L,1L,3029L,1L,2L - -# define SN_bf_ecb "BF-ECB" -# define LN_bf_ecb "bf-ecb" -# define NID_bf_ecb 92 - -# define SN_bf_cfb64 "BF-CFB" -# define LN_bf_cfb64 "bf-cfb" -# define NID_bf_cfb64 93 - -# define SN_bf_ofb64 "BF-OFB" -# define LN_bf_ofb64 "bf-ofb" -# define NID_bf_ofb64 94 - -# define SN_mdc2 "MDC2" -# define LN_mdc2 "mdc2" -# define NID_mdc2 95 -# define OBJ_mdc2 2L,5L,8L,3L,101L -/* An alternative? 1L,3L,14L,3L,2L,19L */ - -# define SN_mdc2WithRSA "RSA-MDC2" -# define LN_mdc2WithRSA "mdc2withRSA" -# define NID_mdc2WithRSA 96 -# define OBJ_mdc2WithRSA 2L,5L,8L,3L,100L - -# define SN_rc4_40 "RC4-40" -# define LN_rc4_40 "rc4-40" -# define NID_rc4_40 97 - -# define SN_rc2_40_cbc "RC2-40-CBC" -# define LN_rc2_40_cbc "rc2-40-cbc" -# define NID_rc2_40_cbc 98 - -# define SN_givenName "G" -# define LN_givenName "givenName" -# define NID_givenName 99 -# define OBJ_givenName OBJ_X509,42L - -# define SN_surname "S" -# define LN_surname "surname" -# define NID_surname 100 -# define OBJ_surname OBJ_X509,4L - -# define SN_initials "I" -# define LN_initials "initials" -# define NID_initials 101 -# define OBJ_initials OBJ_X509,43L - -# define SN_uniqueIdentifier "UID" -# define LN_uniqueIdentifier "uniqueIdentifier" -# define NID_uniqueIdentifier 102 -# define OBJ_uniqueIdentifier OBJ_X509,45L - -# define SN_crl_distribution_points "crlDistributionPoints" -# define LN_crl_distribution_points "X509v3 CRL Distribution Points" -# define NID_crl_distribution_points 103 -# define OBJ_crl_distribution_points OBJ_id_ce,31L - -# define SN_md5WithRSA "RSA-NP-MD5" -# define LN_md5WithRSA "md5WithRSA" -# define NID_md5WithRSA 104 -# define OBJ_md5WithRSA OBJ_algorithm,3L - -# define SN_serialNumber "SN" -# define LN_serialNumber "serialNumber" -# define NID_serialNumber 105 -# define OBJ_serialNumber OBJ_X509,5L - -# define SN_title "T" -# define LN_title "title" -# define NID_title 106 -# define OBJ_title OBJ_X509,12L - -# define SN_description "D" -# define LN_description "description" -# define NID_description 107 -# define OBJ_description OBJ_X509,13L - -/* CAST5 is CAST-128, I'm just sticking with the documentation */ -# define SN_cast5_cbc "CAST5-CBC" -# define LN_cast5_cbc "cast5-cbc" -# define NID_cast5_cbc 108 -# define OBJ_cast5_cbc 1L,2L,840L,113533L,7L,66L,10L - -# define SN_cast5_ecb "CAST5-ECB" -# define LN_cast5_ecb "cast5-ecb" -# define NID_cast5_ecb 109 - -# define SN_cast5_cfb64 "CAST5-CFB" -# define LN_cast5_cfb64 "cast5-cfb" -# define NID_cast5_cfb64 110 - -# define SN_cast5_ofb64 "CAST5-OFB" -# define LN_cast5_ofb64 "cast5-ofb" -# define NID_cast5_ofb64 111 - -# define LN_pbeWithMD5AndCast5_CBC "pbeWithMD5AndCast5CBC" -# define NID_pbeWithMD5AndCast5_CBC 112 -# define OBJ_pbeWithMD5AndCast5_CBC 1L,2L,840L,113533L,7L,66L,12L - -/*- - * This is one sun will soon be using :-( - * id-dsa-with-sha1 ID ::= { - * iso(1) member-body(2) us(840) x9-57 (10040) x9cm(4) 3 } - */ -# define SN_dsaWithSHA1 "DSA-SHA1" -# define LN_dsaWithSHA1 "dsaWithSHA1" -# define NID_dsaWithSHA1 113 -# define OBJ_dsaWithSHA1 1L,2L,840L,10040L,4L,3L - -# define NID_md5_sha1 114 -# define SN_md5_sha1 "MD5-SHA1" -# define LN_md5_sha1 "md5-sha1" - -# define SN_sha1WithRSA "RSA-SHA1-2" -# define LN_sha1WithRSA "sha1WithRSA" -# define NID_sha1WithRSA 115 -# define OBJ_sha1WithRSA OBJ_algorithm,29L - -# define SN_dsa "DSA" -# define LN_dsa "dsaEncryption" -# define NID_dsa 116 -# define OBJ_dsa 1L,2L,840L,10040L,4L,1L - -# define SN_ripemd160 "RIPEMD160" -# define LN_ripemd160 "ripemd160" -# define NID_ripemd160 117 -# define OBJ_ripemd160 1L,3L,36L,3L,2L,1L - -/* - * The name should actually be rsaSignatureWithripemd160, but I'm going to - * continue using the convention I'm using with the other ciphers - */ -# define SN_ripemd160WithRSA "RSA-RIPEMD160" -# define LN_ripemd160WithRSA "ripemd160WithRSA" -# define NID_ripemd160WithRSA 119 -# define OBJ_ripemd160WithRSA 1L,3L,36L,3L,3L,1L,2L - -/*- - * Taken from rfc2040 - * RC5_CBC_Parameters ::= SEQUENCE { - * version INTEGER (v1_0(16)), - * rounds INTEGER (8..127), - * blockSizeInBits INTEGER (64, 128), - * iv OCTET STRING OPTIONAL - * } - */ -# define SN_rc5_cbc "RC5-CBC" -# define LN_rc5_cbc "rc5-cbc" -# define NID_rc5_cbc 120 -# define OBJ_rc5_cbc OBJ_rsadsi,3L,8L - -# define SN_rc5_ecb "RC5-ECB" -# define LN_rc5_ecb "rc5-ecb" -# define NID_rc5_ecb 121 - -# define SN_rc5_cfb64 "RC5-CFB" -# define LN_rc5_cfb64 "rc5-cfb" -# define NID_rc5_cfb64 122 - -# define SN_rc5_ofb64 "RC5-OFB" -# define LN_rc5_ofb64 "rc5-ofb" -# define NID_rc5_ofb64 123 - -# define SN_rle_compression "RLE" -# define LN_rle_compression "run length compression" -# define NID_rle_compression 124 -# define OBJ_rle_compression 1L,1L,1L,1L,666L,1L - -# define SN_zlib_compression "ZLIB" -# define LN_zlib_compression "zlib compression" -# define NID_zlib_compression 125 -# define OBJ_zlib_compression 1L,1L,1L,1L,666L,2L - -# define SN_ext_key_usage "extendedKeyUsage" -# define LN_ext_key_usage "X509v3 Extended Key Usage" -# define NID_ext_key_usage 126 -# define OBJ_ext_key_usage OBJ_id_ce,37 - -# define SN_id_pkix "PKIX" -# define NID_id_pkix 127 -# define OBJ_id_pkix 1L,3L,6L,1L,5L,5L,7L - -# define SN_id_kp "id-kp" -# define NID_id_kp 128 -# define OBJ_id_kp OBJ_id_pkix,3L - -/* PKIX extended key usage OIDs */ - -# define SN_server_auth "serverAuth" -# define LN_server_auth "TLS Web Server Authentication" -# define NID_server_auth 129 -# define OBJ_server_auth OBJ_id_kp,1L - -# define SN_client_auth "clientAuth" -# define LN_client_auth "TLS Web Client Authentication" -# define NID_client_auth 130 -# define OBJ_client_auth OBJ_id_kp,2L - -# define SN_code_sign "codeSigning" -# define LN_code_sign "Code Signing" -# define NID_code_sign 131 -# define OBJ_code_sign OBJ_id_kp,3L - -# define SN_email_protect "emailProtection" -# define LN_email_protect "E-mail Protection" -# define NID_email_protect 132 -# define OBJ_email_protect OBJ_id_kp,4L - -# define SN_time_stamp "timeStamping" -# define LN_time_stamp "Time Stamping" -# define NID_time_stamp 133 -# define OBJ_time_stamp OBJ_id_kp,8L - -/* Additional extended key usage OIDs: Microsoft */ - -# define SN_ms_code_ind "msCodeInd" -# define LN_ms_code_ind "Microsoft Individual Code Signing" -# define NID_ms_code_ind 134 -# define OBJ_ms_code_ind 1L,3L,6L,1L,4L,1L,311L,2L,1L,21L - -# define SN_ms_code_com "msCodeCom" -# define LN_ms_code_com "Microsoft Commercial Code Signing" -# define NID_ms_code_com 135 -# define OBJ_ms_code_com 1L,3L,6L,1L,4L,1L,311L,2L,1L,22L - -# define SN_ms_ctl_sign "msCTLSign" -# define LN_ms_ctl_sign "Microsoft Trust List Signing" -# define NID_ms_ctl_sign 136 -# define OBJ_ms_ctl_sign 1L,3L,6L,1L,4L,1L,311L,10L,3L,1L - -# define SN_ms_sgc "msSGC" -# define LN_ms_sgc "Microsoft Server Gated Crypto" -# define NID_ms_sgc 137 -# define OBJ_ms_sgc 1L,3L,6L,1L,4L,1L,311L,10L,3L,3L - -# define SN_ms_efs "msEFS" -# define LN_ms_efs "Microsoft Encrypted File System" -# define NID_ms_efs 138 -# define OBJ_ms_efs 1L,3L,6L,1L,4L,1L,311L,10L,3L,4L - -/* Additional usage: Netscape */ - -# define SN_ns_sgc "nsSGC" -# define LN_ns_sgc "Netscape Server Gated Crypto" -# define NID_ns_sgc 139 -# define OBJ_ns_sgc OBJ_netscape,4L,1L - -# define SN_delta_crl "deltaCRL" -# define LN_delta_crl "X509v3 Delta CRL Indicator" -# define NID_delta_crl 140 -# define OBJ_delta_crl OBJ_id_ce,27L - -# define SN_crl_reason "CRLReason" -# define LN_crl_reason "CRL Reason Code" -# define NID_crl_reason 141 -# define OBJ_crl_reason OBJ_id_ce,21L - -# define SN_invalidity_date "invalidityDate" -# define LN_invalidity_date "Invalidity Date" -# define NID_invalidity_date 142 -# define OBJ_invalidity_date OBJ_id_ce,24L - -# define SN_sxnet "SXNetID" -# define LN_sxnet "Strong Extranet ID" -# define NID_sxnet 143 -# define OBJ_sxnet 1L,3L,101L,1L,4L,1L - -/* PKCS12 and related OBJECT IDENTIFIERS */ - -# define OBJ_pkcs12 OBJ_pkcs,12L -# define OBJ_pkcs12_pbeids OBJ_pkcs12, 1 - -# define SN_pbe_WithSHA1And128BitRC4 "PBE-SHA1-RC4-128" -# define LN_pbe_WithSHA1And128BitRC4 "pbeWithSHA1And128BitRC4" -# define NID_pbe_WithSHA1And128BitRC4 144 -# define OBJ_pbe_WithSHA1And128BitRC4 OBJ_pkcs12_pbeids, 1L - -# define SN_pbe_WithSHA1And40BitRC4 "PBE-SHA1-RC4-40" -# define LN_pbe_WithSHA1And40BitRC4 "pbeWithSHA1And40BitRC4" -# define NID_pbe_WithSHA1And40BitRC4 145 -# define OBJ_pbe_WithSHA1And40BitRC4 OBJ_pkcs12_pbeids, 2L - -# define SN_pbe_WithSHA1And3_Key_TripleDES_CBC "PBE-SHA1-3DES" -# define LN_pbe_WithSHA1And3_Key_TripleDES_CBC "pbeWithSHA1And3-KeyTripleDES-CBC" -# define NID_pbe_WithSHA1And3_Key_TripleDES_CBC 146 -# define OBJ_pbe_WithSHA1And3_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 3L - -# define SN_pbe_WithSHA1And2_Key_TripleDES_CBC "PBE-SHA1-2DES" -# define LN_pbe_WithSHA1And2_Key_TripleDES_CBC "pbeWithSHA1And2-KeyTripleDES-CBC" -# define NID_pbe_WithSHA1And2_Key_TripleDES_CBC 147 -# define OBJ_pbe_WithSHA1And2_Key_TripleDES_CBC OBJ_pkcs12_pbeids, 4L - -# define SN_pbe_WithSHA1And128BitRC2_CBC "PBE-SHA1-RC2-128" -# define LN_pbe_WithSHA1And128BitRC2_CBC "pbeWithSHA1And128BitRC2-CBC" -# define NID_pbe_WithSHA1And128BitRC2_CBC 148 -# define OBJ_pbe_WithSHA1And128BitRC2_CBC OBJ_pkcs12_pbeids, 5L - -# define SN_pbe_WithSHA1And40BitRC2_CBC "PBE-SHA1-RC2-40" -# define LN_pbe_WithSHA1And40BitRC2_CBC "pbeWithSHA1And40BitRC2-CBC" -# define NID_pbe_WithSHA1And40BitRC2_CBC 149 -# define OBJ_pbe_WithSHA1And40BitRC2_CBC OBJ_pkcs12_pbeids, 6L - -# define OBJ_pkcs12_Version1 OBJ_pkcs12, 10L - -# define OBJ_pkcs12_BagIds OBJ_pkcs12_Version1, 1L - -# define LN_keyBag "keyBag" -# define NID_keyBag 150 -# define OBJ_keyBag OBJ_pkcs12_BagIds, 1L - -# define LN_pkcs8ShroudedKeyBag "pkcs8ShroudedKeyBag" -# define NID_pkcs8ShroudedKeyBag 151 -# define OBJ_pkcs8ShroudedKeyBag OBJ_pkcs12_BagIds, 2L - -# define LN_certBag "certBag" -# define NID_certBag 152 -# define OBJ_certBag OBJ_pkcs12_BagIds, 3L - -# define LN_crlBag "crlBag" -# define NID_crlBag 153 -# define OBJ_crlBag OBJ_pkcs12_BagIds, 4L - -# define LN_secretBag "secretBag" -# define NID_secretBag 154 -# define OBJ_secretBag OBJ_pkcs12_BagIds, 5L - -# define LN_safeContentsBag "safeContentsBag" -# define NID_safeContentsBag 155 -# define OBJ_safeContentsBag OBJ_pkcs12_BagIds, 6L - -# define LN_friendlyName "friendlyName" -# define NID_friendlyName 156 -# define OBJ_friendlyName OBJ_pkcs9, 20L - -# define LN_localKeyID "localKeyID" -# define NID_localKeyID 157 -# define OBJ_localKeyID OBJ_pkcs9, 21L - -# define OBJ_certTypes OBJ_pkcs9, 22L - -# define LN_x509Certificate "x509Certificate" -# define NID_x509Certificate 158 -# define OBJ_x509Certificate OBJ_certTypes, 1L - -# define LN_sdsiCertificate "sdsiCertificate" -# define NID_sdsiCertificate 159 -# define OBJ_sdsiCertificate OBJ_certTypes, 2L - -# define OBJ_crlTypes OBJ_pkcs9, 23L - -# define LN_x509Crl "x509Crl" -# define NID_x509Crl 160 -# define OBJ_x509Crl OBJ_crlTypes, 1L - -/* PKCS#5 v2 OIDs */ - -# define LN_pbes2 "PBES2" -# define NID_pbes2 161 -# define OBJ_pbes2 OBJ_pkcs,5L,13L - -# define LN_pbmac1 "PBMAC1" -# define NID_pbmac1 162 -# define OBJ_pbmac1 OBJ_pkcs,5L,14L - -# define LN_hmacWithSHA1 "hmacWithSHA1" -# define NID_hmacWithSHA1 163 -# define OBJ_hmacWithSHA1 OBJ_rsadsi,2L,7L - -/* Policy Qualifier Ids */ - -# define LN_id_qt_cps "Policy Qualifier CPS" -# define SN_id_qt_cps "id-qt-cps" -# define NID_id_qt_cps 164 -# define OBJ_id_qt_cps OBJ_id_pkix,2L,1L - -# define LN_id_qt_unotice "Policy Qualifier User Notice" -# define SN_id_qt_unotice "id-qt-unotice" -# define NID_id_qt_unotice 165 -# define OBJ_id_qt_unotice OBJ_id_pkix,2L,2L - -# define SN_rc2_64_cbc "RC2-64-CBC" -# define LN_rc2_64_cbc "rc2-64-cbc" -# define NID_rc2_64_cbc 166 - -# define SN_SMIMECapabilities "SMIME-CAPS" -# define LN_SMIMECapabilities "S/MIME Capabilities" -# define NID_SMIMECapabilities 167 -# define OBJ_SMIMECapabilities OBJ_pkcs9,15L - -# define SN_pbeWithMD2AndRC2_CBC "PBE-MD2-RC2-64" -# define LN_pbeWithMD2AndRC2_CBC "pbeWithMD2AndRC2-CBC" -# define NID_pbeWithMD2AndRC2_CBC 168 -# define OBJ_pbeWithMD2AndRC2_CBC OBJ_pkcs,5L,4L - -# define SN_pbeWithMD5AndRC2_CBC "PBE-MD5-RC2-64" -# define LN_pbeWithMD5AndRC2_CBC "pbeWithMD5AndRC2-CBC" -# define NID_pbeWithMD5AndRC2_CBC 169 -# define OBJ_pbeWithMD5AndRC2_CBC OBJ_pkcs,5L,6L - -# define SN_pbeWithSHA1AndDES_CBC "PBE-SHA1-DES" -# define LN_pbeWithSHA1AndDES_CBC "pbeWithSHA1AndDES-CBC" -# define NID_pbeWithSHA1AndDES_CBC 170 -# define OBJ_pbeWithSHA1AndDES_CBC OBJ_pkcs,5L,10L - -/* Extension request OIDs */ - -# define LN_ms_ext_req "Microsoft Extension Request" -# define SN_ms_ext_req "msExtReq" -# define NID_ms_ext_req 171 -# define OBJ_ms_ext_req 1L,3L,6L,1L,4L,1L,311L,2L,1L,14L - -# define LN_ext_req "Extension Request" -# define SN_ext_req "extReq" -# define NID_ext_req 172 -# define OBJ_ext_req OBJ_pkcs9,14L - -# define SN_name "name" -# define LN_name "name" -# define NID_name 173 -# define OBJ_name OBJ_X509,41L - -# define SN_dnQualifier "dnQualifier" -# define LN_dnQualifier "dnQualifier" -# define NID_dnQualifier 174 -# define OBJ_dnQualifier OBJ_X509,46L - -# define SN_id_pe "id-pe" -# define NID_id_pe 175 -# define OBJ_id_pe OBJ_id_pkix,1L - -# define SN_id_ad "id-ad" -# define NID_id_ad 176 -# define OBJ_id_ad OBJ_id_pkix,48L - -# define SN_info_access "authorityInfoAccess" -# define LN_info_access "Authority Information Access" -# define NID_info_access 177 -# define OBJ_info_access OBJ_id_pe,1L - -# define SN_ad_OCSP "OCSP" -# define LN_ad_OCSP "OCSP" -# define NID_ad_OCSP 178 -# define OBJ_ad_OCSP OBJ_id_ad,1L - -# define SN_ad_ca_issuers "caIssuers" -# define LN_ad_ca_issuers "CA Issuers" -# define NID_ad_ca_issuers 179 -# define OBJ_ad_ca_issuers OBJ_id_ad,2L - -# define SN_OCSP_sign "OCSPSigning" -# define LN_OCSP_sign "OCSP Signing" -# define NID_OCSP_sign 180 -# define OBJ_OCSP_sign OBJ_id_kp,9L -# endif /* USE_OBJ_MAC */ - -# include <openssl/bio.h> -# include <openssl/asn1.h> - -# define OBJ_NAME_TYPE_UNDEF 0x00 -# define OBJ_NAME_TYPE_MD_METH 0x01 -# define OBJ_NAME_TYPE_CIPHER_METH 0x02 -# define OBJ_NAME_TYPE_PKEY_METH 0x03 -# define OBJ_NAME_TYPE_COMP_METH 0x04 -# define OBJ_NAME_TYPE_NUM 0x05 - -# define OBJ_NAME_ALIAS 0x8000 - -# define OBJ_BSEARCH_VALUE_ON_NOMATCH 0x01 -# define OBJ_BSEARCH_FIRST_VALUE_ON_MATCH 0x02 - - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct obj_name_st { - int type; - int alias; - const char *name; - const char *data; -} OBJ_NAME; - -# define OBJ_create_and_add_object(a,b,c) OBJ_create(a,b,c) - -int OBJ_NAME_init(void); -int OBJ_NAME_new_index(unsigned long (*hash_func) (const char *), - int (*cmp_func) (const char *, const char *), - void (*free_func) (const char *, int, const char *)); -const char *OBJ_NAME_get(const char *name, int type); -int OBJ_NAME_add(const char *name, int type, const char *data); -int OBJ_NAME_remove(const char *name, int type); -void OBJ_NAME_cleanup(int type); /* -1 for everything */ -void OBJ_NAME_do_all(int type, void (*fn) (const OBJ_NAME *, void *arg), - void *arg); -void OBJ_NAME_do_all_sorted(int type, - void (*fn) (const OBJ_NAME *, void *arg), - void *arg); - -ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o); -ASN1_OBJECT *OBJ_nid2obj(int n); -const char *OBJ_nid2ln(int n); -const char *OBJ_nid2sn(int n); -int OBJ_obj2nid(const ASN1_OBJECT *o); -ASN1_OBJECT *OBJ_txt2obj(const char *s, int no_name); -int OBJ_obj2txt(char *buf, int buf_len, const ASN1_OBJECT *a, int no_name); -int OBJ_txt2nid(const char *s); -int OBJ_ln2nid(const char *s); -int OBJ_sn2nid(const char *s); -int OBJ_cmp(const ASN1_OBJECT *a, const ASN1_OBJECT *b); -const void *OBJ_bsearch_(const void *key, const void *base, int num, int size, - int (*cmp) (const void *, const void *)); -const void *OBJ_bsearch_ex_(const void *key, const void *base, int num, - int size, - int (*cmp) (const void *, const void *), - int flags); - -# define _DECLARE_OBJ_BSEARCH_CMP_FN(scope, type1, type2, nm) \ - static int nm##_cmp_BSEARCH_CMP_FN(const void *, const void *); \ - static int nm##_cmp(type1 const *, type2 const *); \ - scope type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) - -# define DECLARE_OBJ_BSEARCH_CMP_FN(type1, type2, cmp) \ - _DECLARE_OBJ_BSEARCH_CMP_FN(static, type1, type2, cmp) -# define DECLARE_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ - type2 * OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) - -/*- - * Unsolved problem: if a type is actually a pointer type, like - * nid_triple is, then its impossible to get a const where you need - * it. Consider: - * - * typedef int nid_triple[3]; - * const void *a_; - * const nid_triple const *a = a_; - * - * The assignement discards a const because what you really want is: - * - * const int const * const *a = a_; - * - * But if you do that, you lose the fact that a is an array of 3 ints, - * which breaks comparison functions. - * - * Thus we end up having to cast, sadly, or unpack the - * declarations. Or, as I finally did in this case, delcare nid_triple - * to be a struct, which it should have been in the first place. - * - * Ben, August 2008. - * - * Also, strictly speaking not all types need be const, but handling - * the non-constness means a lot of complication, and in practice - * comparison routines do always not touch their arguments. - */ - -# define IMPLEMENT_OBJ_BSEARCH_CMP_FN(type1, type2, nm) \ - static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ - { \ - type1 const *a = a_; \ - type2 const *b = b_; \ - return nm##_cmp(a,b); \ - } \ - static type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ - { \ - return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ - nm##_cmp_BSEARCH_CMP_FN); \ - } \ - extern void dummy_prototype(void) - -# define IMPLEMENT_OBJ_BSEARCH_GLOBAL_CMP_FN(type1, type2, nm) \ - static int nm##_cmp_BSEARCH_CMP_FN(const void *a_, const void *b_) \ - { \ - type1 const *a = a_; \ - type2 const *b = b_; \ - return nm##_cmp(a,b); \ - } \ - type2 *OBJ_bsearch_##nm(type1 *key, type2 const *base, int num) \ - { \ - return (type2 *)OBJ_bsearch_(key, base, num, sizeof(type2), \ - nm##_cmp_BSEARCH_CMP_FN); \ - } \ - extern void dummy_prototype(void) - -# define OBJ_bsearch(type1,key,type2,base,num,cmp) \ - ((type2 *)OBJ_bsearch_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \ - num,sizeof(type2), \ - ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \ - (void)CHECKED_PTR_OF(type2,cmp##_type_2), \ - cmp##_BSEARCH_CMP_FN))) - -# define OBJ_bsearch_ex(type1,key,type2,base,num,cmp,flags) \ - ((type2 *)OBJ_bsearch_ex_(CHECKED_PTR_OF(type1,key),CHECKED_PTR_OF(type2,base), \ - num,sizeof(type2), \ - ((void)CHECKED_PTR_OF(type1,cmp##_type_1), \ - (void)type_2=CHECKED_PTR_OF(type2,cmp##_type_2), \ - cmp##_BSEARCH_CMP_FN)),flags) - -int OBJ_new_nid(int num); -int OBJ_add_object(const ASN1_OBJECT *obj); -int OBJ_create(const char *oid, const char *sn, const char *ln); -#if OPENSSL_API_COMPAT < 0x10100000L -# define OBJ_cleanup() while(0) continue -#endif -int OBJ_create_objects(BIO *in); - -size_t OBJ_length(const ASN1_OBJECT *obj); -const unsigned char *OBJ_get0_data(const ASN1_OBJECT *obj); - -int OBJ_find_sigid_algs(int signid, int *pdig_nid, int *ppkey_nid); -int OBJ_find_sigid_by_algs(int *psignid, int dig_nid, int pkey_nid); -int OBJ_add_sigid(int signid, int dig_id, int pkey_id); -void OBJ_sigid_free(void); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_OBJ_strings(void); - -/* Error codes for the OBJ functions. */ - -/* Function codes. */ -# define OBJ_F_OBJ_ADD_OBJECT 105 -# define OBJ_F_OBJ_CREATE 100 -# define OBJ_F_OBJ_DUP 101 -# define OBJ_F_OBJ_NAME_NEW_INDEX 106 -# define OBJ_F_OBJ_NID2LN 102 -# define OBJ_F_OBJ_NID2OBJ 103 -# define OBJ_F_OBJ_NID2SN 104 - -/* Reason codes. */ -# define OBJ_R_OID_EXISTS 102 -# define OBJ_R_UNKNOWN_NID 101 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/ocsp.h b/android/armeabi/include/openssl/ocsp.h deleted file mode 100644 index 08debc5b..00000000 --- a/android/armeabi/include/openssl/ocsp.h +++ /dev/null @@ -1,412 +0,0 @@ -/* - * Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OCSP_H -# define HEADER_OCSP_H - -#include <openssl/opensslconf.h> - -/* - * These definitions are outside the OPENSSL_NO_OCSP guard because although for - * historical reasons they have OCSP_* names, they can actually be used - * independently of OCSP. E.g. see RFC5280 - */ -/*- - * CRLReason ::= ENUMERATED { - * unspecified (0), - * keyCompromise (1), - * cACompromise (2), - * affiliationChanged (3), - * superseded (4), - * cessationOfOperation (5), - * certificateHold (6), - * removeFromCRL (8) } - */ -# define OCSP_REVOKED_STATUS_NOSTATUS -1 -# define OCSP_REVOKED_STATUS_UNSPECIFIED 0 -# define OCSP_REVOKED_STATUS_KEYCOMPROMISE 1 -# define OCSP_REVOKED_STATUS_CACOMPROMISE 2 -# define OCSP_REVOKED_STATUS_AFFILIATIONCHANGED 3 -# define OCSP_REVOKED_STATUS_SUPERSEDED 4 -# define OCSP_REVOKED_STATUS_CESSATIONOFOPERATION 5 -# define OCSP_REVOKED_STATUS_CERTIFICATEHOLD 6 -# define OCSP_REVOKED_STATUS_REMOVEFROMCRL 8 - - -# ifndef OPENSSL_NO_OCSP - -# include <openssl/ossl_typ.h> -# include <openssl/x509.h> -# include <openssl/x509v3.h> -# include <openssl/safestack.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* Various flags and values */ - -# define OCSP_DEFAULT_NONCE_LENGTH 16 - -# define OCSP_NOCERTS 0x1 -# define OCSP_NOINTERN 0x2 -# define OCSP_NOSIGS 0x4 -# define OCSP_NOCHAIN 0x8 -# define OCSP_NOVERIFY 0x10 -# define OCSP_NOEXPLICIT 0x20 -# define OCSP_NOCASIGN 0x40 -# define OCSP_NODELEGATED 0x80 -# define OCSP_NOCHECKS 0x100 -# define OCSP_TRUSTOTHER 0x200 -# define OCSP_RESPID_KEY 0x400 -# define OCSP_NOTIME 0x800 - -typedef struct ocsp_cert_id_st OCSP_CERTID; - -DEFINE_STACK_OF(OCSP_CERTID) - -typedef struct ocsp_one_request_st OCSP_ONEREQ; - -DEFINE_STACK_OF(OCSP_ONEREQ) - -typedef struct ocsp_req_info_st OCSP_REQINFO; -typedef struct ocsp_signature_st OCSP_SIGNATURE; -typedef struct ocsp_request_st OCSP_REQUEST; - -# define OCSP_RESPONSE_STATUS_SUCCESSFUL 0 -# define OCSP_RESPONSE_STATUS_MALFORMEDREQUEST 1 -# define OCSP_RESPONSE_STATUS_INTERNALERROR 2 -# define OCSP_RESPONSE_STATUS_TRYLATER 3 -# define OCSP_RESPONSE_STATUS_SIGREQUIRED 5 -# define OCSP_RESPONSE_STATUS_UNAUTHORIZED 6 - -typedef struct ocsp_resp_bytes_st OCSP_RESPBYTES; - -# define V_OCSP_RESPID_NAME 0 -# define V_OCSP_RESPID_KEY 1 - -DEFINE_STACK_OF(OCSP_RESPID) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPID) - -typedef struct ocsp_revoked_info_st OCSP_REVOKEDINFO; - -# define V_OCSP_CERTSTATUS_GOOD 0 -# define V_OCSP_CERTSTATUS_REVOKED 1 -# define V_OCSP_CERTSTATUS_UNKNOWN 2 - -typedef struct ocsp_cert_status_st OCSP_CERTSTATUS; -typedef struct ocsp_single_response_st OCSP_SINGLERESP; - -DEFINE_STACK_OF(OCSP_SINGLERESP) - -typedef struct ocsp_response_data_st OCSP_RESPDATA; - -typedef struct ocsp_basic_response_st OCSP_BASICRESP; - -typedef struct ocsp_crl_id_st OCSP_CRLID; -typedef struct ocsp_service_locator_st OCSP_SERVICELOC; - -# define PEM_STRING_OCSP_REQUEST "OCSP REQUEST" -# define PEM_STRING_OCSP_RESPONSE "OCSP RESPONSE" - -# define d2i_OCSP_REQUEST_bio(bp,p) ASN1_d2i_bio_of(OCSP_REQUEST,OCSP_REQUEST_new,d2i_OCSP_REQUEST,bp,p) - -# define d2i_OCSP_RESPONSE_bio(bp,p) ASN1_d2i_bio_of(OCSP_RESPONSE,OCSP_RESPONSE_new,d2i_OCSP_RESPONSE,bp,p) - -# define PEM_read_bio_OCSP_REQUEST(bp,x,cb) (OCSP_REQUEST *)PEM_ASN1_read_bio( \ - (char *(*)())d2i_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,bp,(char **)x,cb,NULL) - -# define PEM_read_bio_OCSP_RESPONSE(bp,x,cb)(OCSP_RESPONSE *)PEM_ASN1_read_bio(\ - (char *(*)())d2i_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,bp,(char **)x,cb,NULL) - -# define PEM_write_bio_OCSP_REQUEST(bp,o) \ - PEM_ASN1_write_bio((int (*)())i2d_OCSP_REQUEST,PEM_STRING_OCSP_REQUEST,\ - bp,(char *)o, NULL,NULL,0,NULL,NULL) - -# define PEM_write_bio_OCSP_RESPONSE(bp,o) \ - PEM_ASN1_write_bio((int (*)())i2d_OCSP_RESPONSE,PEM_STRING_OCSP_RESPONSE,\ - bp,(char *)o, NULL,NULL,0,NULL,NULL) - -# define i2d_OCSP_RESPONSE_bio(bp,o) ASN1_i2d_bio_of(OCSP_RESPONSE,i2d_OCSP_RESPONSE,bp,o) - -# define i2d_OCSP_REQUEST_bio(bp,o) ASN1_i2d_bio_of(OCSP_REQUEST,i2d_OCSP_REQUEST,bp,o) - -# define OCSP_REQUEST_sign(o,pkey,md) \ - ASN1_item_sign(ASN1_ITEM_rptr(OCSP_REQINFO),\ - &o->optionalSignature->signatureAlgorithm,NULL,\ - o->optionalSignature->signature,&o->tbsRequest,pkey,md) - -# define OCSP_BASICRESP_sign(o,pkey,md,d) \ - ASN1_item_sign(ASN1_ITEM_rptr(OCSP_RESPDATA),&o->signatureAlgorithm,NULL,\ - o->signature,&o->tbsResponseData,pkey,md) - -# define OCSP_REQUEST_verify(a,r) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_REQINFO),\ - &a->optionalSignature->signatureAlgorithm,\ - a->optionalSignature->signature,&a->tbsRequest,r) - -# define OCSP_BASICRESP_verify(a,r,d) ASN1_item_verify(ASN1_ITEM_rptr(OCSP_RESPDATA),\ - &a->signatureAlgorithm,a->signature,&a->tbsResponseData,r) - -# define ASN1_BIT_STRING_digest(data,type,md,len) \ - ASN1_item_digest(ASN1_ITEM_rptr(ASN1_BIT_STRING),type,data,md,len) - -# define OCSP_CERTSTATUS_dup(cs)\ - (OCSP_CERTSTATUS*)ASN1_dup((int(*)())i2d_OCSP_CERTSTATUS,\ - (char *(*)())d2i_OCSP_CERTSTATUS,(char *)(cs)) - -OCSP_CERTID *OCSP_CERTID_dup(OCSP_CERTID *id); - -OCSP_RESPONSE *OCSP_sendreq_bio(BIO *b, const char *path, OCSP_REQUEST *req); -OCSP_REQ_CTX *OCSP_sendreq_new(BIO *io, const char *path, OCSP_REQUEST *req, - int maxline); -int OCSP_REQ_CTX_nbio(OCSP_REQ_CTX *rctx); -int OCSP_sendreq_nbio(OCSP_RESPONSE **presp, OCSP_REQ_CTX *rctx); -OCSP_REQ_CTX *OCSP_REQ_CTX_new(BIO *io, int maxline); -void OCSP_REQ_CTX_free(OCSP_REQ_CTX *rctx); -void OCSP_set_max_response_length(OCSP_REQ_CTX *rctx, unsigned long len); -int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it, - ASN1_VALUE *val); -int OCSP_REQ_CTX_nbio_d2i(OCSP_REQ_CTX *rctx, ASN1_VALUE **pval, - const ASN1_ITEM *it); -BIO *OCSP_REQ_CTX_get0_mem_bio(OCSP_REQ_CTX *rctx); -int OCSP_REQ_CTX_i2d(OCSP_REQ_CTX *rctx, const ASN1_ITEM *it, - ASN1_VALUE *val); -int OCSP_REQ_CTX_http(OCSP_REQ_CTX *rctx, const char *op, const char *path); -int OCSP_REQ_CTX_set1_req(OCSP_REQ_CTX *rctx, OCSP_REQUEST *req); -int OCSP_REQ_CTX_add1_header(OCSP_REQ_CTX *rctx, - const char *name, const char *value); - -OCSP_CERTID *OCSP_cert_to_id(const EVP_MD *dgst, const X509 *subject, - const X509 *issuer); - -OCSP_CERTID *OCSP_cert_id_new(const EVP_MD *dgst, - const X509_NAME *issuerName, - const ASN1_BIT_STRING *issuerKey, - const ASN1_INTEGER *serialNumber); - -OCSP_ONEREQ *OCSP_request_add0_id(OCSP_REQUEST *req, OCSP_CERTID *cid); - -int OCSP_request_add1_nonce(OCSP_REQUEST *req, unsigned char *val, int len); -int OCSP_basic_add1_nonce(OCSP_BASICRESP *resp, unsigned char *val, int len); -int OCSP_check_nonce(OCSP_REQUEST *req, OCSP_BASICRESP *bs); -int OCSP_copy_nonce(OCSP_BASICRESP *resp, OCSP_REQUEST *req); - -int OCSP_request_set1_name(OCSP_REQUEST *req, X509_NAME *nm); -int OCSP_request_add1_cert(OCSP_REQUEST *req, X509 *cert); - -int OCSP_request_sign(OCSP_REQUEST *req, - X509 *signer, - EVP_PKEY *key, - const EVP_MD *dgst, - STACK_OF(X509) *certs, unsigned long flags); - -int OCSP_response_status(OCSP_RESPONSE *resp); -OCSP_BASICRESP *OCSP_response_get1_basic(OCSP_RESPONSE *resp); - -const ASN1_OCTET_STRING *OCSP_resp_get0_signature(const OCSP_BASICRESP *bs); - -int OCSP_resp_count(OCSP_BASICRESP *bs); -OCSP_SINGLERESP *OCSP_resp_get0(OCSP_BASICRESP *bs, int idx); -const ASN1_GENERALIZEDTIME *OCSP_resp_get0_produced_at(const OCSP_BASICRESP* bs); -const STACK_OF(X509) *OCSP_resp_get0_certs(const OCSP_BASICRESP *bs); -int OCSP_resp_get0_id(const OCSP_BASICRESP *bs, - const ASN1_OCTET_STRING **pid, - const X509_NAME **pname); - -int OCSP_resp_find(OCSP_BASICRESP *bs, OCSP_CERTID *id, int last); -int OCSP_single_get0_status(OCSP_SINGLERESP *single, int *reason, - ASN1_GENERALIZEDTIME **revtime, - ASN1_GENERALIZEDTIME **thisupd, - ASN1_GENERALIZEDTIME **nextupd); -int OCSP_resp_find_status(OCSP_BASICRESP *bs, OCSP_CERTID *id, int *status, - int *reason, - ASN1_GENERALIZEDTIME **revtime, - ASN1_GENERALIZEDTIME **thisupd, - ASN1_GENERALIZEDTIME **nextupd); -int OCSP_check_validity(ASN1_GENERALIZEDTIME *thisupd, - ASN1_GENERALIZEDTIME *nextupd, long sec, long maxsec); - -int OCSP_request_verify(OCSP_REQUEST *req, STACK_OF(X509) *certs, - X509_STORE *store, unsigned long flags); - -int OCSP_parse_url(const char *url, char **phost, char **pport, char **ppath, - int *pssl); - -int OCSP_id_issuer_cmp(OCSP_CERTID *a, OCSP_CERTID *b); -int OCSP_id_cmp(OCSP_CERTID *a, OCSP_CERTID *b); - -int OCSP_request_onereq_count(OCSP_REQUEST *req); -OCSP_ONEREQ *OCSP_request_onereq_get0(OCSP_REQUEST *req, int i); -OCSP_CERTID *OCSP_onereq_get0_id(OCSP_ONEREQ *one); -int OCSP_id_get0_info(ASN1_OCTET_STRING **piNameHash, ASN1_OBJECT **pmd, - ASN1_OCTET_STRING **pikeyHash, - ASN1_INTEGER **pserial, OCSP_CERTID *cid); -int OCSP_request_is_signed(OCSP_REQUEST *req); -OCSP_RESPONSE *OCSP_response_create(int status, OCSP_BASICRESP *bs); -OCSP_SINGLERESP *OCSP_basic_add1_status(OCSP_BASICRESP *rsp, - OCSP_CERTID *cid, - int status, int reason, - ASN1_TIME *revtime, - ASN1_TIME *thisupd, - ASN1_TIME *nextupd); -int OCSP_basic_add1_cert(OCSP_BASICRESP *resp, X509 *cert); -int OCSP_basic_sign(OCSP_BASICRESP *brsp, - X509 *signer, EVP_PKEY *key, const EVP_MD *dgst, - STACK_OF(X509) *certs, unsigned long flags); -int OCSP_RESPID_set_by_name(OCSP_RESPID *respid, X509 *cert); -int OCSP_RESPID_set_by_key(OCSP_RESPID *respid, X509 *cert); -int OCSP_RESPID_match(OCSP_RESPID *respid, X509 *cert); - -X509_EXTENSION *OCSP_crlID_new(const char *url, long *n, char *tim); - -X509_EXTENSION *OCSP_accept_responses_new(char **oids); - -X509_EXTENSION *OCSP_archive_cutoff_new(char *tim); - -X509_EXTENSION *OCSP_url_svcloc_new(X509_NAME *issuer, const char **urls); - -int OCSP_REQUEST_get_ext_count(OCSP_REQUEST *x); -int OCSP_REQUEST_get_ext_by_NID(OCSP_REQUEST *x, int nid, int lastpos); -int OCSP_REQUEST_get_ext_by_OBJ(OCSP_REQUEST *x, const ASN1_OBJECT *obj, - int lastpos); -int OCSP_REQUEST_get_ext_by_critical(OCSP_REQUEST *x, int crit, int lastpos); -X509_EXTENSION *OCSP_REQUEST_get_ext(OCSP_REQUEST *x, int loc); -X509_EXTENSION *OCSP_REQUEST_delete_ext(OCSP_REQUEST *x, int loc); -void *OCSP_REQUEST_get1_ext_d2i(OCSP_REQUEST *x, int nid, int *crit, - int *idx); -int OCSP_REQUEST_add1_ext_i2d(OCSP_REQUEST *x, int nid, void *value, int crit, - unsigned long flags); -int OCSP_REQUEST_add_ext(OCSP_REQUEST *x, X509_EXTENSION *ex, int loc); - -int OCSP_ONEREQ_get_ext_count(OCSP_ONEREQ *x); -int OCSP_ONEREQ_get_ext_by_NID(OCSP_ONEREQ *x, int nid, int lastpos); -int OCSP_ONEREQ_get_ext_by_OBJ(OCSP_ONEREQ *x, const ASN1_OBJECT *obj, int lastpos); -int OCSP_ONEREQ_get_ext_by_critical(OCSP_ONEREQ *x, int crit, int lastpos); -X509_EXTENSION *OCSP_ONEREQ_get_ext(OCSP_ONEREQ *x, int loc); -X509_EXTENSION *OCSP_ONEREQ_delete_ext(OCSP_ONEREQ *x, int loc); -void *OCSP_ONEREQ_get1_ext_d2i(OCSP_ONEREQ *x, int nid, int *crit, int *idx); -int OCSP_ONEREQ_add1_ext_i2d(OCSP_ONEREQ *x, int nid, void *value, int crit, - unsigned long flags); -int OCSP_ONEREQ_add_ext(OCSP_ONEREQ *x, X509_EXTENSION *ex, int loc); - -int OCSP_BASICRESP_get_ext_count(OCSP_BASICRESP *x); -int OCSP_BASICRESP_get_ext_by_NID(OCSP_BASICRESP *x, int nid, int lastpos); -int OCSP_BASICRESP_get_ext_by_OBJ(OCSP_BASICRESP *x, const ASN1_OBJECT *obj, - int lastpos); -int OCSP_BASICRESP_get_ext_by_critical(OCSP_BASICRESP *x, int crit, - int lastpos); -X509_EXTENSION *OCSP_BASICRESP_get_ext(OCSP_BASICRESP *x, int loc); -X509_EXTENSION *OCSP_BASICRESP_delete_ext(OCSP_BASICRESP *x, int loc); -void *OCSP_BASICRESP_get1_ext_d2i(OCSP_BASICRESP *x, int nid, int *crit, - int *idx); -int OCSP_BASICRESP_add1_ext_i2d(OCSP_BASICRESP *x, int nid, void *value, - int crit, unsigned long flags); -int OCSP_BASICRESP_add_ext(OCSP_BASICRESP *x, X509_EXTENSION *ex, int loc); - -int OCSP_SINGLERESP_get_ext_count(OCSP_SINGLERESP *x); -int OCSP_SINGLERESP_get_ext_by_NID(OCSP_SINGLERESP *x, int nid, int lastpos); -int OCSP_SINGLERESP_get_ext_by_OBJ(OCSP_SINGLERESP *x, const ASN1_OBJECT *obj, - int lastpos); -int OCSP_SINGLERESP_get_ext_by_critical(OCSP_SINGLERESP *x, int crit, - int lastpos); -X509_EXTENSION *OCSP_SINGLERESP_get_ext(OCSP_SINGLERESP *x, int loc); -X509_EXTENSION *OCSP_SINGLERESP_delete_ext(OCSP_SINGLERESP *x, int loc); -void *OCSP_SINGLERESP_get1_ext_d2i(OCSP_SINGLERESP *x, int nid, int *crit, - int *idx); -int OCSP_SINGLERESP_add1_ext_i2d(OCSP_SINGLERESP *x, int nid, void *value, - int crit, unsigned long flags); -int OCSP_SINGLERESP_add_ext(OCSP_SINGLERESP *x, X509_EXTENSION *ex, int loc); -const OCSP_CERTID *OCSP_SINGLERESP_get0_id(const OCSP_SINGLERESP *x); - -DECLARE_ASN1_FUNCTIONS(OCSP_SINGLERESP) -DECLARE_ASN1_FUNCTIONS(OCSP_CERTSTATUS) -DECLARE_ASN1_FUNCTIONS(OCSP_REVOKEDINFO) -DECLARE_ASN1_FUNCTIONS(OCSP_BASICRESP) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPDATA) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPID) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPONSE) -DECLARE_ASN1_FUNCTIONS(OCSP_RESPBYTES) -DECLARE_ASN1_FUNCTIONS(OCSP_ONEREQ) -DECLARE_ASN1_FUNCTIONS(OCSP_CERTID) -DECLARE_ASN1_FUNCTIONS(OCSP_REQUEST) -DECLARE_ASN1_FUNCTIONS(OCSP_SIGNATURE) -DECLARE_ASN1_FUNCTIONS(OCSP_REQINFO) -DECLARE_ASN1_FUNCTIONS(OCSP_CRLID) -DECLARE_ASN1_FUNCTIONS(OCSP_SERVICELOC) - -const char *OCSP_response_status_str(long s); -const char *OCSP_cert_status_str(long s); -const char *OCSP_crl_reason_str(long s); - -int OCSP_REQUEST_print(BIO *bp, OCSP_REQUEST *a, unsigned long flags); -int OCSP_RESPONSE_print(BIO *bp, OCSP_RESPONSE *o, unsigned long flags); - -int OCSP_basic_verify(OCSP_BASICRESP *bs, STACK_OF(X509) *certs, - X509_STORE *st, unsigned long flags); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_OCSP_strings(void); - -/* Error codes for the OCSP functions. */ - -/* Function codes. */ -# define OCSP_F_D2I_OCSP_NONCE 102 -# define OCSP_F_OCSP_BASIC_ADD1_STATUS 103 -# define OCSP_F_OCSP_BASIC_SIGN 104 -# define OCSP_F_OCSP_BASIC_VERIFY 105 -# define OCSP_F_OCSP_CERT_ID_NEW 101 -# define OCSP_F_OCSP_CHECK_DELEGATED 106 -# define OCSP_F_OCSP_CHECK_IDS 107 -# define OCSP_F_OCSP_CHECK_ISSUER 108 -# define OCSP_F_OCSP_CHECK_VALIDITY 115 -# define OCSP_F_OCSP_MATCH_ISSUERID 109 -# define OCSP_F_OCSP_PARSE_URL 114 -# define OCSP_F_OCSP_REQUEST_SIGN 110 -# define OCSP_F_OCSP_REQUEST_VERIFY 116 -# define OCSP_F_OCSP_RESPONSE_GET1_BASIC 111 -# define OCSP_F_PARSE_HTTP_LINE1 118 - -/* Reason codes. */ -# define OCSP_R_CERTIFICATE_VERIFY_ERROR 101 -# define OCSP_R_DIGEST_ERR 102 -# define OCSP_R_ERROR_IN_NEXTUPDATE_FIELD 122 -# define OCSP_R_ERROR_IN_THISUPDATE_FIELD 123 -# define OCSP_R_ERROR_PARSING_URL 121 -# define OCSP_R_MISSING_OCSPSIGNING_USAGE 103 -# define OCSP_R_NEXTUPDATE_BEFORE_THISUPDATE 124 -# define OCSP_R_NOT_BASIC_RESPONSE 104 -# define OCSP_R_NO_CERTIFICATES_IN_CHAIN 105 -# define OCSP_R_NO_RESPONSE_DATA 108 -# define OCSP_R_NO_REVOKED_TIME 109 -# define OCSP_R_NO_SIGNER_KEY 130 -# define OCSP_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 110 -# define OCSP_R_REQUEST_NOT_SIGNED 128 -# define OCSP_R_RESPONSE_CONTAINS_NO_REVOCATION_DATA 111 -# define OCSP_R_ROOT_CA_NOT_TRUSTED 112 -# define OCSP_R_SERVER_RESPONSE_ERROR 114 -# define OCSP_R_SERVER_RESPONSE_PARSE_ERROR 115 -# define OCSP_R_SIGNATURE_FAILURE 117 -# define OCSP_R_SIGNER_CERTIFICATE_NOT_FOUND 118 -# define OCSP_R_STATUS_EXPIRED 125 -# define OCSP_R_STATUS_NOT_YET_VALID 126 -# define OCSP_R_STATUS_TOO_OLD 127 -# define OCSP_R_UNKNOWN_MESSAGE_DIGEST 119 -# define OCSP_R_UNKNOWN_NID 120 -# define OCSP_R_UNSUPPORTED_REQUESTORNAME_TYPE 129 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/opensslconf-arm32.h b/android/armeabi/include/openssl/opensslconf-arm32.h deleted file mode 100644 index 527f4d5b..00000000 --- a/android/armeabi/include/openssl/opensslconf-arm32.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * WARNING: do not edit! - * Generated by Makefile from include/openssl/opensslconf.h.in - * - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_ALGORITHM_DEFINES -# error OPENSSL_ALGORITHM_DEFINES no longer supported -#endif - -/* - * OpenSSL was configured with the following options: - */ - -#ifndef OPENSSL_NO_MD2 -# define OPENSSL_NO_MD2 -#endif -#ifndef OPENSSL_NO_RC5 -# define OPENSSL_NO_RC5 -#endif -#ifndef OPENSSL_THREADS -# define OPENSSL_THREADS -#endif -#ifndef OPENSSL_NO_ASAN -# define OPENSSL_NO_ASAN -#endif -#ifndef OPENSSL_NO_CRYPTO_MDEBUG -# define OPENSSL_NO_CRYPTO_MDEBUG -#endif -#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE -# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE -#endif -#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 -# define OPENSSL_NO_EC_NISTP_64_GCC_128 -#endif -#ifndef OPENSSL_NO_EGD -# define OPENSSL_NO_EGD -#endif -#ifndef OPENSSL_NO_FUZZ_AFL -# define OPENSSL_NO_FUZZ_AFL -#endif -#ifndef OPENSSL_NO_FUZZ_LIBFUZZER -# define OPENSSL_NO_FUZZ_LIBFUZZER -#endif -#ifndef OPENSSL_NO_HEARTBEATS -# define OPENSSL_NO_HEARTBEATS -#endif -#ifndef OPENSSL_NO_MSAN -# define OPENSSL_NO_MSAN -#endif -#ifndef OPENSSL_NO_SCTP -# define OPENSSL_NO_SCTP -#endif -#ifndef OPENSSL_NO_SSL_TRACE -# define OPENSSL_NO_SSL_TRACE -#endif -#ifndef OPENSSL_NO_SSL3 -# define OPENSSL_NO_SSL3 -#endif -#ifndef OPENSSL_NO_SSL3_METHOD -# define OPENSSL_NO_SSL3_METHOD -#endif -#ifndef OPENSSL_NO_UBSAN -# define OPENSSL_NO_UBSAN -#endif -#ifndef OPENSSL_NO_UNIT_TEST -# define OPENSSL_NO_UNIT_TEST -#endif -#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS -# define OPENSSL_NO_WEAK_SSL_CIPHERS -#endif -#ifndef OPENSSL_NO_AFALGENG -# define OPENSSL_NO_AFALGENG -#endif - - -/* - * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers - * don't like that. This will hopefully silence them. - */ -#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy; - -/* - * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the - * declarations of functions deprecated in or before <version>. Otherwise, they - * still won't see them if the library has been built to disable deprecated - * functions. - */ -#if defined(OPENSSL_NO_DEPRECATED) -# define DECLARE_DEPRECATED(f) -#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0) -# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated)); -#else -# define DECLARE_DEPRECATED(f) f; -#endif - -#ifndef OPENSSL_FILE -# ifdef OPENSSL_NO_FILENAMES -# define OPENSSL_FILE "" -# define OPENSSL_LINE 0 -# else -# define OPENSSL_FILE __FILE__ -# define OPENSSL_LINE __LINE__ -# endif -#endif - -#ifndef OPENSSL_MIN_API -# define OPENSSL_MIN_API 0 -#endif - -#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API -# undef OPENSSL_API_COMPAT -# define OPENSSL_API_COMPAT OPENSSL_MIN_API -#endif - -#if OPENSSL_API_COMPAT < 0x10100000L -# define DEPRECATEDIN_1_1_0(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_1_1_0(f) -#endif - -#if OPENSSL_API_COMPAT < 0x10000000L -# define DEPRECATEDIN_1_0_0(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_1_0_0(f) -#endif - -#if OPENSSL_API_COMPAT < 0x00908000L -# define DEPRECATEDIN_0_9_8(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_0_9_8(f) -#endif - -#define OPENSSL_CPUID_OBJ - -/* Generate 80386 code? */ -#undef I386_ONLY - -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD <unistd.h> - -#undef OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* - * The following are cipher-specific, but are part of the public API. - */ -#if !defined(OPENSSL_SYS_UEFI) -# define BN_LLONG -/* Only one for the following should be defined */ -# undef SIXTY_FOUR_BIT_LONG -# undef SIXTY_FOUR_BIT -# define THIRTY_TWO_BIT -#endif - -#define RC4_INT unsigned char - -#ifdef __cplusplus -} -#endif diff --git a/android/armeabi/include/openssl/opensslconf-arm64.h b/android/armeabi/include/openssl/opensslconf-arm64.h deleted file mode 100644 index f3d83b5c..00000000 --- a/android/armeabi/include/openssl/opensslconf-arm64.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * WARNING: do not edit! - * Generated by Makefile from include/openssl/opensslconf.h.in - * - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_ALGORITHM_DEFINES -# error OPENSSL_ALGORITHM_DEFINES no longer supported -#endif - -/* - * OpenSSL was configured with the following options: - */ - -#ifndef OPENSSL_NO_MD2 -# define OPENSSL_NO_MD2 -#endif -#ifndef OPENSSL_NO_RC5 -# define OPENSSL_NO_RC5 -#endif -#ifndef OPENSSL_THREADS -# define OPENSSL_THREADS -#endif -#ifndef OPENSSL_NO_ASAN -# define OPENSSL_NO_ASAN -#endif -#ifndef OPENSSL_NO_CRYPTO_MDEBUG -# define OPENSSL_NO_CRYPTO_MDEBUG -#endif -#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE -# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE -#endif -#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 -# define OPENSSL_NO_EC_NISTP_64_GCC_128 -#endif -#ifndef OPENSSL_NO_EGD -# define OPENSSL_NO_EGD -#endif -#ifndef OPENSSL_NO_FUZZ_AFL -# define OPENSSL_NO_FUZZ_AFL -#endif -#ifndef OPENSSL_NO_FUZZ_LIBFUZZER -# define OPENSSL_NO_FUZZ_LIBFUZZER -#endif -#ifndef OPENSSL_NO_HEARTBEATS -# define OPENSSL_NO_HEARTBEATS -#endif -#ifndef OPENSSL_NO_MSAN -# define OPENSSL_NO_MSAN -#endif -#ifndef OPENSSL_NO_SCTP -# define OPENSSL_NO_SCTP -#endif -#ifndef OPENSSL_NO_SSL_TRACE -# define OPENSSL_NO_SSL_TRACE -#endif -#ifndef OPENSSL_NO_SSL3 -# define OPENSSL_NO_SSL3 -#endif -#ifndef OPENSSL_NO_SSL3_METHOD -# define OPENSSL_NO_SSL3_METHOD -#endif -#ifndef OPENSSL_NO_UBSAN -# define OPENSSL_NO_UBSAN -#endif -#ifndef OPENSSL_NO_UNIT_TEST -# define OPENSSL_NO_UNIT_TEST -#endif -#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS -# define OPENSSL_NO_WEAK_SSL_CIPHERS -#endif -#ifndef OPENSSL_NO_AFALGENG -# define OPENSSL_NO_AFALGENG -#endif - - -/* - * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers - * don't like that. This will hopefully silence them. - */ -#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy; - -/* - * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the - * declarations of functions deprecated in or before <version>. Otherwise, they - * still won't see them if the library has been built to disable deprecated - * functions. - */ -#if defined(OPENSSL_NO_DEPRECATED) -# define DECLARE_DEPRECATED(f) -#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0) -# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated)); -#else -# define DECLARE_DEPRECATED(f) f; -#endif - -#ifndef OPENSSL_FILE -# ifdef OPENSSL_NO_FILENAMES -# define OPENSSL_FILE "" -# define OPENSSL_LINE 0 -# else -# define OPENSSL_FILE __FILE__ -# define OPENSSL_LINE __LINE__ -# endif -#endif - -#ifndef OPENSSL_MIN_API -# define OPENSSL_MIN_API 0 -#endif - -#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API -# undef OPENSSL_API_COMPAT -# define OPENSSL_API_COMPAT OPENSSL_MIN_API -#endif - -#if OPENSSL_API_COMPAT < 0x10100000L -# define DEPRECATEDIN_1_1_0(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_1_1_0(f) -#endif - -#if OPENSSL_API_COMPAT < 0x10000000L -# define DEPRECATEDIN_1_0_0(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_1_0_0(f) -#endif - -#if OPENSSL_API_COMPAT < 0x00908000L -# define DEPRECATEDIN_0_9_8(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_0_9_8(f) -#endif - -#define OPENSSL_CPUID_OBJ - -/* Generate 80386 code? */ -#undef I386_ONLY - -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD <unistd.h> - -#undef OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* - * The following are cipher-specific, but are part of the public API. - */ -#if !defined(OPENSSL_SYS_UEFI) -# undef BN_LLONG -/* Only one for the following should be defined */ -# define SIXTY_FOUR_BIT_LONG -# undef SIXTY_FOUR_BIT -# undef THIRTY_TWO_BIT -#endif - -#define RC4_INT unsigned char - -#ifdef __cplusplus -} -#endif diff --git a/android/armeabi/include/openssl/opensslconf-x86.h b/android/armeabi/include/openssl/opensslconf-x86.h deleted file mode 100644 index 9891b5d8..00000000 --- a/android/armeabi/include/openssl/opensslconf-x86.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - * WARNING: do not edit! - * Generated by Makefile from include/openssl/opensslconf.h.in - * - * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef OPENSSL_ALGORITHM_DEFINES -# error OPENSSL_ALGORITHM_DEFINES no longer supported -#endif - -/* - * OpenSSL was configured with the following options: - */ - -#ifndef OPENSSL_NO_MD2 -# define OPENSSL_NO_MD2 -#endif -#ifndef OPENSSL_NO_RC5 -# define OPENSSL_NO_RC5 -#endif -#ifndef OPENSSL_THREADS -# define OPENSSL_THREADS -#endif -#ifndef OPENSSL_NO_ASAN -# define OPENSSL_NO_ASAN -#endif -#ifndef OPENSSL_NO_CRYPTO_MDEBUG -# define OPENSSL_NO_CRYPTO_MDEBUG -#endif -#ifndef OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE -# define OPENSSL_NO_CRYPTO_MDEBUG_BACKTRACE -#endif -#ifndef OPENSSL_NO_EC_NISTP_64_GCC_128 -# define OPENSSL_NO_EC_NISTP_64_GCC_128 -#endif -#ifndef OPENSSL_NO_EGD -# define OPENSSL_NO_EGD -#endif -#ifndef OPENSSL_NO_FUZZ_AFL -# define OPENSSL_NO_FUZZ_AFL -#endif -#ifndef OPENSSL_NO_FUZZ_LIBFUZZER -# define OPENSSL_NO_FUZZ_LIBFUZZER -#endif -#ifndef OPENSSL_NO_HEARTBEATS -# define OPENSSL_NO_HEARTBEATS -#endif -#ifndef OPENSSL_NO_MSAN -# define OPENSSL_NO_MSAN -#endif -#ifndef OPENSSL_NO_SCTP -# define OPENSSL_NO_SCTP -#endif -#ifndef OPENSSL_NO_SSL_TRACE -# define OPENSSL_NO_SSL_TRACE -#endif -#ifndef OPENSSL_NO_SSL3 -# define OPENSSL_NO_SSL3 -#endif -#ifndef OPENSSL_NO_SSL3_METHOD -# define OPENSSL_NO_SSL3_METHOD -#endif -#ifndef OPENSSL_NO_UBSAN -# define OPENSSL_NO_UBSAN -#endif -#ifndef OPENSSL_NO_UNIT_TEST -# define OPENSSL_NO_UNIT_TEST -#endif -#ifndef OPENSSL_NO_WEAK_SSL_CIPHERS -# define OPENSSL_NO_WEAK_SSL_CIPHERS -#endif -#ifndef OPENSSL_NO_AFALGENG -# define OPENSSL_NO_AFALGENG -#endif - - -/* - * Sometimes OPENSSSL_NO_xxx ends up with an empty file and some compilers - * don't like that. This will hopefully silence them. - */ -#define NON_EMPTY_TRANSLATION_UNIT static void *dummy = &dummy; - -/* - * Applications should use -DOPENSSL_API_COMPAT=<version> to suppress the - * declarations of functions deprecated in or before <version>. Otherwise, they - * still won't see them if the library has been built to disable deprecated - * functions. - */ -#if defined(OPENSSL_NO_DEPRECATED) -# define DECLARE_DEPRECATED(f) -#elif __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ > 0) -# define DECLARE_DEPRECATED(f) f __attribute__ ((deprecated)); -#else -# define DECLARE_DEPRECATED(f) f; -#endif - -#ifndef OPENSSL_FILE -# ifdef OPENSSL_NO_FILENAMES -# define OPENSSL_FILE "" -# define OPENSSL_LINE 0 -# else -# define OPENSSL_FILE __FILE__ -# define OPENSSL_LINE __LINE__ -# endif -#endif - -#ifndef OPENSSL_MIN_API -# define OPENSSL_MIN_API 0 -#endif - -#if !defined(OPENSSL_API_COMPAT) || OPENSSL_API_COMPAT < OPENSSL_MIN_API -# undef OPENSSL_API_COMPAT -# define OPENSSL_API_COMPAT OPENSSL_MIN_API -#endif - -#if OPENSSL_API_COMPAT < 0x10100000L -# define DEPRECATEDIN_1_1_0(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_1_1_0(f) -#endif - -#if OPENSSL_API_COMPAT < 0x10000000L -# define DEPRECATEDIN_1_0_0(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_1_0_0(f) -#endif - -#if OPENSSL_API_COMPAT < 0x00908000L -# define DEPRECATEDIN_0_9_8(f) DECLARE_DEPRECATED(f) -#else -# define DEPRECATEDIN_0_9_8(f) -#endif - -#define OPENSSL_CPUID_OBJ - -/* Generate 80386 code? */ -#undef I386_ONLY - -#undef OPENSSL_UNISTD -#define OPENSSL_UNISTD <unistd.h> - -#undef OPENSSL_EXPORT_VAR_AS_FUNCTION - -/* - * The following are cipher-specific, but are part of the public API. - */ -#if !defined(OPENSSL_SYS_UEFI) -# define BN_LLONG -/* Only one for the following should be defined */ -# undef SIXTY_FOUR_BIT_LONG -# undef SIXTY_FOUR_BIT -# define THIRTY_TWO_BIT -#endif - -#define RC4_INT unsigned int - -#ifdef __cplusplus -} -#endif diff --git a/android/armeabi/include/openssl/opensslconf.h b/android/armeabi/include/openssl/opensslconf.h deleted file mode 100644 index 94174f30..00000000 --- a/android/armeabi/include/openssl/opensslconf.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifdef __aarch64__ -#include "opensslconf-arm64.h" -#elif __arm__ -#include "opensslconf-arm32.h" -#elif __i386__ -#include "opensslconf-x86.h" -#else -#error "Unsupported architecture!" -#endif diff --git a/android/armeabi/include/openssl/opensslv.h b/android/armeabi/include/openssl/opensslv.h deleted file mode 100644 index 2d54b69b..00000000 --- a/android/armeabi/include/openssl/opensslv.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OPENSSLV_H -# define HEADER_OPENSSLV_H - -#ifdef __cplusplus -extern "C" { -#endif - -/*- - * Numeric release version identifier: - * MNNFFPPS: major minor fix patch status - * The status nibble has one of the values 0 for development, 1 to e for betas - * 1 to 14, and f for release. The patch level is exactly that. - * For example: - * 0.9.3-dev 0x00903000 - * 0.9.3-beta1 0x00903001 - * 0.9.3-beta2-dev 0x00903002 - * 0.9.3-beta2 0x00903002 (same as ...beta2-dev) - * 0.9.3 0x0090300f - * 0.9.3a 0x0090301f - * 0.9.4 0x0090400f - * 1.2.3z 0x102031af - * - * For continuity reasons (because 0.9.5 is already out, and is coded - * 0x00905100), between 0.9.5 and 0.9.6 the coding of the patch level - * part is slightly different, by setting the highest bit. This means - * that 0.9.5a looks like this: 0x0090581f. At 0.9.6, we can start - * with 0x0090600S... - * - * (Prior to 0.9.3-dev a different scheme was used: 0.9.2b is 0x0922.) - * (Prior to 0.9.5a beta1, a different scheme was used: MMNNFFRBB for - * major minor fix final patch/beta) - */ -# define OPENSSL_VERSION_NUMBER 0x1010003fL -# ifdef OPENSSL_FIPS -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0c-fips 10 Nov 2016" -# else -# define OPENSSL_VERSION_TEXT "OpenSSL 1.1.0c 10 Nov 2016" -# endif - -/*- - * The macros below are to be used for shared library (.so, .dll, ...) - * versioning. That kind of versioning works a bit differently between - * operating systems. The most usual scheme is to set a major and a minor - * number, and have the runtime loader check that the major number is equal - * to what it was at application link time, while the minor number has to - * be greater or equal to what it was at application link time. With this - * scheme, the version number is usually part of the file name, like this: - * - * libcrypto.so.0.9 - * - * Some unixen also make a softlink with the major version number only: - * - * libcrypto.so.0 - * - * On Tru64 and IRIX 6.x it works a little bit differently. There, the - * shared library version is stored in the file, and is actually a series - * of versions, separated by colons. The rightmost version present in the - * library when linking an application is stored in the application to be - * matched at run time. When the application is run, a check is done to - * see if the library version stored in the application matches any of the - * versions in the version string of the library itself. - * This version string can be constructed in any way, depending on what - * kind of matching is desired. However, to implement the same scheme as - * the one used in the other unixen, all compatible versions, from lowest - * to highest, should be part of the string. Consecutive builds would - * give the following versions strings: - * - * 3.0 - * 3.0:3.1 - * 3.0:3.1:3.2 - * 4.0 - * 4.0:4.1 - * - * Notice how version 4 is completely incompatible with version, and - * therefore give the breach you can see. - * - * There may be other schemes as well that I haven't yet discovered. - * - * So, here's the way it works here: first of all, the library version - * number doesn't need at all to match the overall OpenSSL version. - * However, it's nice and more understandable if it actually does. - * The current library version is stored in the macro SHLIB_VERSION_NUMBER, - * which is just a piece of text in the format "M.m.e" (Major, minor, edit). - * For the sake of Tru64, IRIX, and any other OS that behaves in similar ways, - * we need to keep a history of version numbers, which is done in the - * macro SHLIB_VERSION_HISTORY. The numbers are separated by colons and - * should only keep the versions that are binary compatible with the current. - */ -# define SHLIB_VERSION_HISTORY "" -# define SHLIB_VERSION_NUMBER "1.1" - - -#ifdef __cplusplus -} -#endif -#endif /* HEADER_OPENSSLV_H */ diff --git a/android/armeabi/include/openssl/ossl_typ.h b/android/armeabi/include/openssl/ossl_typ.h deleted file mode 100644 index 129a67f0..00000000 --- a/android/armeabi/include/openssl/ossl_typ.h +++ /dev/null @@ -1,190 +0,0 @@ -/* - * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_OPENSSL_TYPES_H -# define HEADER_OPENSSL_TYPES_H - -#include <limits.h> - -#ifdef __cplusplus -extern "C" { -#endif - -# include <openssl/e_os2.h> - -# ifdef NO_ASN1_TYPEDEFS -# define ASN1_INTEGER ASN1_STRING -# define ASN1_ENUMERATED ASN1_STRING -# define ASN1_BIT_STRING ASN1_STRING -# define ASN1_OCTET_STRING ASN1_STRING -# define ASN1_PRINTABLESTRING ASN1_STRING -# define ASN1_T61STRING ASN1_STRING -# define ASN1_IA5STRING ASN1_STRING -# define ASN1_UTCTIME ASN1_STRING -# define ASN1_GENERALIZEDTIME ASN1_STRING -# define ASN1_TIME ASN1_STRING -# define ASN1_GENERALSTRING ASN1_STRING -# define ASN1_UNIVERSALSTRING ASN1_STRING -# define ASN1_BMPSTRING ASN1_STRING -# define ASN1_VISIBLESTRING ASN1_STRING -# define ASN1_UTF8STRING ASN1_STRING -# define ASN1_BOOLEAN int -# define ASN1_NULL int -# else -typedef struct asn1_string_st ASN1_INTEGER; -typedef struct asn1_string_st ASN1_ENUMERATED; -typedef struct asn1_string_st ASN1_BIT_STRING; -typedef struct asn1_string_st ASN1_OCTET_STRING; -typedef struct asn1_string_st ASN1_PRINTABLESTRING; -typedef struct asn1_string_st ASN1_T61STRING; -typedef struct asn1_string_st ASN1_IA5STRING; -typedef struct asn1_string_st ASN1_GENERALSTRING; -typedef struct asn1_string_st ASN1_UNIVERSALSTRING; -typedef struct asn1_string_st ASN1_BMPSTRING; -typedef struct asn1_string_st ASN1_UTCTIME; -typedef struct asn1_string_st ASN1_TIME; -typedef struct asn1_string_st ASN1_GENERALIZEDTIME; -typedef struct asn1_string_st ASN1_VISIBLESTRING; -typedef struct asn1_string_st ASN1_UTF8STRING; -typedef struct asn1_string_st ASN1_STRING; -typedef int ASN1_BOOLEAN; -typedef int ASN1_NULL; -# endif - -typedef struct asn1_object_st ASN1_OBJECT; - -typedef struct ASN1_ITEM_st ASN1_ITEM; -typedef struct asn1_pctx_st ASN1_PCTX; -typedef struct asn1_sctx_st ASN1_SCTX; - -# ifdef _WIN32 -# undef X509_NAME -# undef X509_EXTENSIONS -# undef PKCS7_ISSUER_AND_SERIAL -# undef PKCS7_SIGNER_INFO -# undef OCSP_REQUEST -# undef OCSP_RESPONSE -# endif - -# ifdef BIGNUM -# undef BIGNUM -# endif -struct dane_st; -typedef struct bio_st BIO; -typedef struct bignum_st BIGNUM; -typedef struct bignum_ctx BN_CTX; -typedef struct bn_blinding_st BN_BLINDING; -typedef struct bn_mont_ctx_st BN_MONT_CTX; -typedef struct bn_recp_ctx_st BN_RECP_CTX; -typedef struct bn_gencb_st BN_GENCB; - -typedef struct buf_mem_st BUF_MEM; - -typedef struct evp_cipher_st EVP_CIPHER; -typedef struct evp_cipher_ctx_st EVP_CIPHER_CTX; -typedef struct evp_md_st EVP_MD; -typedef struct evp_md_ctx_st EVP_MD_CTX; -typedef struct evp_pkey_st EVP_PKEY; - -typedef struct evp_pkey_asn1_method_st EVP_PKEY_ASN1_METHOD; - -typedef struct evp_pkey_method_st EVP_PKEY_METHOD; -typedef struct evp_pkey_ctx_st EVP_PKEY_CTX; - -typedef struct evp_Encode_Ctx_st EVP_ENCODE_CTX; - -typedef struct hmac_ctx_st HMAC_CTX; - -typedef struct dh_st DH; -typedef struct dh_method DH_METHOD; - -typedef struct dsa_st DSA; -typedef struct dsa_method DSA_METHOD; - -typedef struct rsa_st RSA; -typedef struct rsa_meth_st RSA_METHOD; - -typedef struct ec_key_st EC_KEY; -typedef struct ec_key_method_st EC_KEY_METHOD; - -typedef struct rand_meth_st RAND_METHOD; - -typedef struct ssl_dane_st SSL_DANE; -typedef struct x509_st X509; -typedef struct X509_algor_st X509_ALGOR; -typedef struct X509_crl_st X509_CRL; -typedef struct x509_crl_method_st X509_CRL_METHOD; -typedef struct x509_revoked_st X509_REVOKED; -typedef struct X509_name_st X509_NAME; -typedef struct X509_pubkey_st X509_PUBKEY; -typedef struct x509_store_st X509_STORE; -typedef struct x509_store_ctx_st X509_STORE_CTX; - -typedef struct x509_object_st X509_OBJECT; -typedef struct x509_lookup_st X509_LOOKUP; -typedef struct x509_lookup_method_st X509_LOOKUP_METHOD; -typedef struct X509_VERIFY_PARAM_st X509_VERIFY_PARAM; - -typedef struct pkcs8_priv_key_info_st PKCS8_PRIV_KEY_INFO; - -typedef struct v3_ext_ctx X509V3_CTX; -typedef struct conf_st CONF; -typedef struct ossl_init_settings_st OPENSSL_INIT_SETTINGS; - -typedef struct ui_st UI; -typedef struct ui_method_st UI_METHOD; - -typedef struct engine_st ENGINE; -typedef struct ssl_st SSL; -typedef struct ssl_ctx_st SSL_CTX; - -typedef struct comp_ctx_st COMP_CTX; -typedef struct comp_method_st COMP_METHOD; - -typedef struct X509_POLICY_NODE_st X509_POLICY_NODE; -typedef struct X509_POLICY_LEVEL_st X509_POLICY_LEVEL; -typedef struct X509_POLICY_TREE_st X509_POLICY_TREE; -typedef struct X509_POLICY_CACHE_st X509_POLICY_CACHE; - -typedef struct AUTHORITY_KEYID_st AUTHORITY_KEYID; -typedef struct DIST_POINT_st DIST_POINT; -typedef struct ISSUING_DIST_POINT_st ISSUING_DIST_POINT; -typedef struct NAME_CONSTRAINTS_st NAME_CONSTRAINTS; - -typedef struct crypto_ex_data_st CRYPTO_EX_DATA; - -typedef struct ocsp_req_ctx_st OCSP_REQ_CTX; -typedef struct ocsp_response_st OCSP_RESPONSE; -typedef struct ocsp_responder_id_st OCSP_RESPID; - -typedef struct sct_st SCT; -typedef struct sct_ctx_st SCT_CTX; -typedef struct ctlog_st CTLOG; -typedef struct ctlog_store_st CTLOG_STORE; -typedef struct ct_policy_eval_ctx_st CT_POLICY_EVAL_CTX; - -#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L && \ - defined(INTMAX_MAX) && defined(UINTMAX_MAX) -typedef intmax_t ossl_intmax_t; -typedef uintmax_t ossl_uintmax_t; -#else -/* - * Not long long, because the C-library can only be expected to provide - * strtoll(), strtoull() at the same time as intmax_t and strtoimax(), - * strtoumax(). Since we use these for parsing arguments, we need the - * conversion functions, not just the sizes. - */ -typedef long ossl_intmax_t; -typedef unsigned long ossl_uintmax_t; -#endif - -#ifdef __cplusplus -} -#endif -#endif /* def HEADER_OPENSSL_TYPES_H */ diff --git a/android/armeabi/include/openssl/pem.h b/android/armeabi/include/openssl/pem.h deleted file mode 100644 index 2375d635..00000000 --- a/android/armeabi/include/openssl/pem.h +++ /dev/null @@ -1,501 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_PEM_H -# define HEADER_PEM_H - -# include <openssl/e_os2.h> -# include <openssl/bio.h> -# include <openssl/stack.h> -# include <openssl/evp.h> -# include <openssl/x509.h> -# include <openssl/pem2.h> - -#ifdef __cplusplus -extern "C" { -#endif - -# define PEM_BUFSIZE 1024 - -# define PEM_STRING_X509_OLD "X509 CERTIFICATE" -# define PEM_STRING_X509 "CERTIFICATE" -# define PEM_STRING_X509_TRUSTED "TRUSTED CERTIFICATE" -# define PEM_STRING_X509_REQ_OLD "NEW CERTIFICATE REQUEST" -# define PEM_STRING_X509_REQ "CERTIFICATE REQUEST" -# define PEM_STRING_X509_CRL "X509 CRL" -# define PEM_STRING_EVP_PKEY "ANY PRIVATE KEY" -# define PEM_STRING_PUBLIC "PUBLIC KEY" -# define PEM_STRING_RSA "RSA PRIVATE KEY" -# define PEM_STRING_RSA_PUBLIC "RSA PUBLIC KEY" -# define PEM_STRING_DSA "DSA PRIVATE KEY" -# define PEM_STRING_DSA_PUBLIC "DSA PUBLIC KEY" -# define PEM_STRING_PKCS7 "PKCS7" -# define PEM_STRING_PKCS7_SIGNED "PKCS #7 SIGNED DATA" -# define PEM_STRING_PKCS8 "ENCRYPTED PRIVATE KEY" -# define PEM_STRING_PKCS8INF "PRIVATE KEY" -# define PEM_STRING_DHPARAMS "DH PARAMETERS" -# define PEM_STRING_DHXPARAMS "X9.42 DH PARAMETERS" -# define PEM_STRING_SSL_SESSION "SSL SESSION PARAMETERS" -# define PEM_STRING_DSAPARAMS "DSA PARAMETERS" -# define PEM_STRING_ECDSA_PUBLIC "ECDSA PUBLIC KEY" -# define PEM_STRING_ECPARAMETERS "EC PARAMETERS" -# define PEM_STRING_ECPRIVATEKEY "EC PRIVATE KEY" -# define PEM_STRING_PARAMETERS "PARAMETERS" -# define PEM_STRING_CMS "CMS" - -# define PEM_TYPE_ENCRYPTED 10 -# define PEM_TYPE_MIC_ONLY 20 -# define PEM_TYPE_MIC_CLEAR 30 -# define PEM_TYPE_CLEAR 40 - -typedef struct pem_recip_st { - char *name; - X509_NAME *dn; - int cipher; - int key_enc; - /* char iv[8]; unused and wrong size */ -} PEM_USER; - -typedef struct pem_ctx_st { - int type; /* what type of object */ - struct { - int version; - int mode; - } proc_type; - - char *domain; - - struct { - int cipher; - /*- - unused, and wrong size - unsigned char iv[8]; */ - } DEK_info; - - PEM_USER *originator; - - int num_recipient; - PEM_USER **recipient; - -/*- - XXX(ben): don#t think this is used! - STACK *x509_chain; / * certificate chain */ - EVP_MD *md; /* signature type */ - - int md_enc; /* is the md encrypted or not? */ - int md_len; /* length of md_data */ - char *md_data; /* message digest, could be pkey encrypted */ - - EVP_CIPHER *dec; /* date encryption cipher */ - int key_len; /* key length */ - unsigned char *key; /* key */ - /*- - unused, and wrong size - unsigned char iv[8]; */ - - int data_enc; /* is the data encrypted */ - int data_len; - unsigned char *data; -} PEM_CTX; - -/* - * These macros make the PEM_read/PEM_write functions easier to maintain and - * write. Now they are all implemented with either: IMPLEMENT_PEM_rw(...) or - * IMPLEMENT_PEM_rw_cb(...) - */ - -# ifdef OPENSSL_NO_STDIO - -# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) /**/ -# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) /**/ -# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) /**/ -# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) /**/ -# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) /**/ -# else - -# define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \ -type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\ -{ \ -return PEM_ASN1_read((d2i_of_void *)d2i_##asn1, str,fp,(void **)x,cb,u); \ -} - -# define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, type *x) \ -{ \ -return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL); \ -} - -# define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, const type *x) \ -{ \ -return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,(void *)x,NULL,NULL,0,NULL,NULL); \ -} - -# define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, \ - void *u) \ - { \ - return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ - } - -# define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \ -int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, \ - void *u) \ - { \ - return PEM_ASN1_write((i2d_of_void *)i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u); \ - } - -# endif - -# define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ -type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\ -{ \ -return PEM_ASN1_read_bio((d2i_of_void *)d2i_##asn1, str,bp,(void **)x,cb,u); \ -} - -# define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, type *x) \ -{ \ -return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL); \ -} - -# define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, const type *x) \ -{ \ -return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,NULL,NULL,0,NULL,NULL); \ -} - -# define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ - { \ - return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u); \ - } - -# define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ -int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \ - { \ - return PEM_ASN1_write_bio((i2d_of_void *)i2d_##asn1,str,bp,(void *)x,enc,kstr,klen,cb,u); \ - } - -# define IMPLEMENT_PEM_write(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_write_fp(name, type, str, asn1) - -# define IMPLEMENT_PEM_write_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) - -# define IMPLEMENT_PEM_write_cb(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) - -# define IMPLEMENT_PEM_write_cb_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) - -# define IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_read_bio(name, type, str, asn1) \ - IMPLEMENT_PEM_read_fp(name, type, str, asn1) - -# define IMPLEMENT_PEM_rw(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write(name, type, str, asn1) - -# define IMPLEMENT_PEM_rw_const(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write_const(name, type, str, asn1) - -# define IMPLEMENT_PEM_rw_cb(name, type, str, asn1) \ - IMPLEMENT_PEM_read(name, type, str, asn1) \ - IMPLEMENT_PEM_write_cb(name, type, str, asn1) - -/* These are the same except they are for the declarations */ - -# if defined(OPENSSL_NO_STDIO) - -# define DECLARE_PEM_read_fp(name, type) /**/ -# define DECLARE_PEM_write_fp(name, type) /**/ -# define DECLARE_PEM_write_fp_const(name, type) /**/ -# define DECLARE_PEM_write_cb_fp(name, type) /**/ -# else - -# define DECLARE_PEM_read_fp(name, type) \ - type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u); - -# define DECLARE_PEM_write_fp(name, type) \ - int PEM_write_##name(FILE *fp, type *x); - -# define DECLARE_PEM_write_fp_const(name, type) \ - int PEM_write_##name(FILE *fp, const type *x); - -# define DECLARE_PEM_write_cb_fp(name, type) \ - int PEM_write_##name(FILE *fp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u); - -# endif - -# define DECLARE_PEM_read_bio(name, type) \ - type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u); - -# define DECLARE_PEM_write_bio(name, type) \ - int PEM_write_bio_##name(BIO *bp, type *x); - -# define DECLARE_PEM_write_bio_const(name, type) \ - int PEM_write_bio_##name(BIO *bp, const type *x); - -# define DECLARE_PEM_write_cb_bio(name, type) \ - int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \ - unsigned char *kstr, int klen, pem_password_cb *cb, void *u); - -# define DECLARE_PEM_write(name, type) \ - DECLARE_PEM_write_bio(name, type) \ - DECLARE_PEM_write_fp(name, type) -# define DECLARE_PEM_write_const(name, type) \ - DECLARE_PEM_write_bio_const(name, type) \ - DECLARE_PEM_write_fp_const(name, type) -# define DECLARE_PEM_write_cb(name, type) \ - DECLARE_PEM_write_cb_bio(name, type) \ - DECLARE_PEM_write_cb_fp(name, type) -# define DECLARE_PEM_read(name, type) \ - DECLARE_PEM_read_bio(name, type) \ - DECLARE_PEM_read_fp(name, type) -# define DECLARE_PEM_rw(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write(name, type) -# define DECLARE_PEM_rw_const(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write_const(name, type) -# define DECLARE_PEM_rw_cb(name, type) \ - DECLARE_PEM_read(name, type) \ - DECLARE_PEM_write_cb(name, type) -typedef int pem_password_cb (char *buf, int size, int rwflag, void *userdata); - -int PEM_get_EVP_CIPHER_INFO(char *header, EVP_CIPHER_INFO *cipher); -int PEM_do_header(EVP_CIPHER_INFO *cipher, unsigned char *data, long *len, - pem_password_cb *callback, void *u); - -int PEM_read_bio(BIO *bp, char **name, char **header, - unsigned char **data, long *len); -int PEM_write_bio(BIO *bp, const char *name, const char *hdr, - const unsigned char *data, long len); -int PEM_bytes_read_bio(unsigned char **pdata, long *plen, char **pnm, - const char *name, BIO *bp, pem_password_cb *cb, - void *u); -void *PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp, void **x, - pem_password_cb *cb, void *u); -int PEM_ASN1_write_bio(i2d_of_void *i2d, const char *name, BIO *bp, void *x, - const EVP_CIPHER *enc, unsigned char *kstr, int klen, - pem_password_cb *cb, void *u); - -STACK_OF(X509_INFO) *PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, - pem_password_cb *cb, void *u); -int PEM_X509_INFO_write_bio(BIO *bp, X509_INFO *xi, EVP_CIPHER *enc, - unsigned char *kstr, int klen, - pem_password_cb *cd, void *u); - -#ifndef OPENSSL_NO_STDIO -int PEM_read(FILE *fp, char **name, char **header, - unsigned char **data, long *len); -int PEM_write(FILE *fp, const char *name, const char *hdr, - const unsigned char *data, long len); -void *PEM_ASN1_read(d2i_of_void *d2i, const char *name, FILE *fp, void **x, - pem_password_cb *cb, void *u); -int PEM_ASN1_write(i2d_of_void *i2d, const char *name, FILE *fp, - void *x, const EVP_CIPHER *enc, unsigned char *kstr, - int klen, pem_password_cb *callback, void *u); -STACK_OF(X509_INFO) *PEM_X509_INFO_read(FILE *fp, STACK_OF(X509_INFO) *sk, - pem_password_cb *cb, void *u); -#endif - -int PEM_SignInit(EVP_MD_CTX *ctx, EVP_MD *type); -int PEM_SignUpdate(EVP_MD_CTX *ctx, unsigned char *d, unsigned int cnt); -int PEM_SignFinal(EVP_MD_CTX *ctx, unsigned char *sigret, - unsigned int *siglen, EVP_PKEY *pkey); - -int PEM_def_callback(char *buf, int num, int w, void *key); -void PEM_proc_type(char *buf, int type); -void PEM_dek_info(char *buf, const char *type, int len, char *str); - -# include <openssl/symhacks.h> - -DECLARE_PEM_rw(X509, X509) -DECLARE_PEM_rw(X509_AUX, X509) -DECLARE_PEM_rw(X509_REQ, X509_REQ) -DECLARE_PEM_write(X509_REQ_NEW, X509_REQ) -DECLARE_PEM_rw(X509_CRL, X509_CRL) -DECLARE_PEM_rw(PKCS7, PKCS7) -DECLARE_PEM_rw(NETSCAPE_CERT_SEQUENCE, NETSCAPE_CERT_SEQUENCE) -DECLARE_PEM_rw(PKCS8, X509_SIG) -DECLARE_PEM_rw(PKCS8_PRIV_KEY_INFO, PKCS8_PRIV_KEY_INFO) -# ifndef OPENSSL_NO_RSA -DECLARE_PEM_rw_cb(RSAPrivateKey, RSA) -DECLARE_PEM_rw_const(RSAPublicKey, RSA) -DECLARE_PEM_rw(RSA_PUBKEY, RSA) -# endif -# ifndef OPENSSL_NO_DSA -DECLARE_PEM_rw_cb(DSAPrivateKey, DSA) -DECLARE_PEM_rw(DSA_PUBKEY, DSA) -DECLARE_PEM_rw_const(DSAparams, DSA) -# endif -# ifndef OPENSSL_NO_EC -DECLARE_PEM_rw_const(ECPKParameters, EC_GROUP) -DECLARE_PEM_rw_cb(ECPrivateKey, EC_KEY) -DECLARE_PEM_rw(EC_PUBKEY, EC_KEY) -# endif -# ifndef OPENSSL_NO_DH -DECLARE_PEM_rw_const(DHparams, DH) -DECLARE_PEM_write_const(DHxparams, DH) -# endif -DECLARE_PEM_rw_cb(PrivateKey, EVP_PKEY) -DECLARE_PEM_rw(PUBKEY, EVP_PKEY) - -int PEM_write_bio_PrivateKey_traditional(BIO *bp, EVP_PKEY *x, - const EVP_CIPHER *enc, - unsigned char *kstr, int klen, - pem_password_cb *cb, void *u); - -int PEM_write_bio_PKCS8PrivateKey_nid(BIO *bp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int PEM_write_bio_PKCS8PrivateKey(BIO *, EVP_PKEY *, const EVP_CIPHER *, - char *, int, pem_password_cb *, void *); -int i2d_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY *x, const EVP_CIPHER *enc, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int i2d_PKCS8PrivateKey_nid_bio(BIO *bp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); -EVP_PKEY *d2i_PKCS8PrivateKey_bio(BIO *bp, EVP_PKEY **x, pem_password_cb *cb, - void *u); - -# ifndef OPENSSL_NO_STDIO -int i2d_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int i2d_PKCS8PrivateKey_nid_fp(FILE *fp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); -int PEM_write_PKCS8PrivateKey_nid(FILE *fp, EVP_PKEY *x, int nid, - char *kstr, int klen, - pem_password_cb *cb, void *u); - -EVP_PKEY *d2i_PKCS8PrivateKey_fp(FILE *fp, EVP_PKEY **x, pem_password_cb *cb, - void *u); - -int PEM_write_PKCS8PrivateKey(FILE *fp, EVP_PKEY *x, const EVP_CIPHER *enc, - char *kstr, int klen, pem_password_cb *cd, - void *u); -# endif -EVP_PKEY *PEM_read_bio_Parameters(BIO *bp, EVP_PKEY **x); -int PEM_write_bio_Parameters(BIO *bp, EVP_PKEY *x); - -# ifndef OPENSSL_NO_DSA -EVP_PKEY *b2i_PrivateKey(const unsigned char **in, long length); -EVP_PKEY *b2i_PublicKey(const unsigned char **in, long length); -EVP_PKEY *b2i_PrivateKey_bio(BIO *in); -EVP_PKEY *b2i_PublicKey_bio(BIO *in); -int i2b_PrivateKey_bio(BIO *out, EVP_PKEY *pk); -int i2b_PublicKey_bio(BIO *out, EVP_PKEY *pk); -# ifndef OPENSSL_NO_RC4 -EVP_PKEY *b2i_PVK_bio(BIO *in, pem_password_cb *cb, void *u); -int i2b_PVK_bio(BIO *out, EVP_PKEY *pk, int enclevel, - pem_password_cb *cb, void *u); -# endif -# endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_PEM_strings(void); - -/* Error codes for the PEM functions. */ - -/* Function codes. */ -# define PEM_F_B2I_DSS 127 -# define PEM_F_B2I_PVK_BIO 128 -# define PEM_F_B2I_RSA 129 -# define PEM_F_CHECK_BITLEN_DSA 130 -# define PEM_F_CHECK_BITLEN_RSA 131 -# define PEM_F_D2I_PKCS8PRIVATEKEY_BIO 120 -# define PEM_F_D2I_PKCS8PRIVATEKEY_FP 121 -# define PEM_F_DO_B2I 132 -# define PEM_F_DO_B2I_BIO 133 -# define PEM_F_DO_BLOB_HEADER 134 -# define PEM_F_DO_PK8PKEY 126 -# define PEM_F_DO_PK8PKEY_FP 125 -# define PEM_F_DO_PVK_BODY 135 -# define PEM_F_DO_PVK_HEADER 136 -# define PEM_F_I2B_PVK 137 -# define PEM_F_I2B_PVK_BIO 138 -# define PEM_F_LOAD_IV 101 -# define PEM_F_PEM_ASN1_READ 102 -# define PEM_F_PEM_ASN1_READ_BIO 103 -# define PEM_F_PEM_ASN1_WRITE 104 -# define PEM_F_PEM_ASN1_WRITE_BIO 105 -# define PEM_F_PEM_DEF_CALLBACK 100 -# define PEM_F_PEM_DO_HEADER 106 -# define PEM_F_PEM_GET_EVP_CIPHER_INFO 107 -# define PEM_F_PEM_READ 108 -# define PEM_F_PEM_READ_BIO 109 -# define PEM_F_PEM_READ_BIO_DHPARAMS 141 -# define PEM_F_PEM_READ_BIO_PARAMETERS 140 -# define PEM_F_PEM_READ_BIO_PRIVATEKEY 123 -# define PEM_F_PEM_READ_DHPARAMS 142 -# define PEM_F_PEM_READ_PRIVATEKEY 124 -# define PEM_F_PEM_SIGNFINAL 112 -# define PEM_F_PEM_WRITE 113 -# define PEM_F_PEM_WRITE_BIO 114 -# define PEM_F_PEM_WRITE_PRIVATEKEY 139 -# define PEM_F_PEM_X509_INFO_READ 115 -# define PEM_F_PEM_X509_INFO_READ_BIO 116 -# define PEM_F_PEM_X509_INFO_WRITE_BIO 117 - -/* Reason codes. */ -# define PEM_R_BAD_BASE64_DECODE 100 -# define PEM_R_BAD_DECRYPT 101 -# define PEM_R_BAD_END_LINE 102 -# define PEM_R_BAD_IV_CHARS 103 -# define PEM_R_BAD_MAGIC_NUMBER 116 -# define PEM_R_BAD_PASSWORD_READ 104 -# define PEM_R_BAD_VERSION_NUMBER 117 -# define PEM_R_BIO_WRITE_FAILURE 118 -# define PEM_R_CIPHER_IS_NULL 127 -# define PEM_R_ERROR_CONVERTING_PRIVATE_KEY 115 -# define PEM_R_EXPECTING_PRIVATE_KEY_BLOB 119 -# define PEM_R_EXPECTING_PUBLIC_KEY_BLOB 120 -# define PEM_R_HEADER_TOO_LONG 128 -# define PEM_R_INCONSISTENT_HEADER 121 -# define PEM_R_KEYBLOB_HEADER_PARSE_ERROR 122 -# define PEM_R_KEYBLOB_TOO_SHORT 123 -# define PEM_R_MISSING_DEK_IV 129 -# define PEM_R_NOT_DEK_INFO 105 -# define PEM_R_NOT_ENCRYPTED 106 -# define PEM_R_NOT_PROC_TYPE 107 -# define PEM_R_NO_START_LINE 108 -# define PEM_R_PROBLEMS_GETTING_PASSWORD 109 -# define PEM_R_PVK_DATA_TOO_SHORT 124 -# define PEM_R_PVK_TOO_SHORT 125 -# define PEM_R_READ_KEY 111 -# define PEM_R_SHORT_HEADER 112 -# define PEM_R_UNEXPECTED_DEK_IV 130 -# define PEM_R_UNSUPPORTED_CIPHER 113 -# define PEM_R_UNSUPPORTED_ENCRYPTION 114 -# define PEM_R_UNSUPPORTED_KEY_COMPONENTS 126 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/pem2.h b/android/armeabi/include/openssl/pem2.h deleted file mode 100644 index cfe73f13..00000000 --- a/android/armeabi/include/openssl/pem2.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef HEADER_PEM_H -int ERR_load_PEM_strings(void); -#endif - -#ifdef __cplusplus -} -#endif diff --git a/android/armeabi/include/openssl/pkcs12.h b/android/armeabi/include/openssl/pkcs12.h deleted file mode 100644 index deaded9d..00000000 --- a/android/armeabi/include/openssl/pkcs12.h +++ /dev/null @@ -1,282 +0,0 @@ -/* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_PKCS12_H -# define HEADER_PKCS12_H - -# include <openssl/bio.h> -# include <openssl/x509.h> - -#ifdef __cplusplus -extern "C" { -#endif - -# define PKCS12_KEY_ID 1 -# define PKCS12_IV_ID 2 -# define PKCS12_MAC_ID 3 - -/* Default iteration count */ -# ifndef PKCS12_DEFAULT_ITER -# define PKCS12_DEFAULT_ITER PKCS5_DEFAULT_ITER -# endif - -# define PKCS12_MAC_KEY_LENGTH 20 - -# define PKCS12_SALT_LEN 8 - -/* It's not clear if these are actually needed... */ -# define PKCS12_key_gen PKCS12_key_gen_utf8 -# define PKCS12_add_friendlyname PKCS12_add_friendlyname_utf8 - -/* MS key usage constants */ - -# define KEY_EX 0x10 -# define KEY_SIG 0x80 - -typedef struct PKCS12_MAC_DATA_st PKCS12_MAC_DATA; - -typedef struct PKCS12_st PKCS12; - -typedef struct PKCS12_SAFEBAG_st PKCS12_SAFEBAG; - -DEFINE_STACK_OF(PKCS12_SAFEBAG) - -typedef struct pkcs12_bag_st PKCS12_BAGS; - -# define PKCS12_ERROR 0 -# define PKCS12_OK 1 - -/* Compatibility macros */ - -#if OPENSSL_API_COMPAT < 0x10100000L - -# define M_PKCS12_bag_type PKCS12_bag_type -# define M_PKCS12_cert_bag_type PKCS12_cert_bag_type -# define M_PKCS12_crl_bag_type PKCS12_cert_bag_type - -# define PKCS12_certbag2x509 PKCS12_SAFEBAG_get1_cert -# define PKCS12_certbag2scrl PKCS12_SAFEBAG_get1_crl -# define PKCS12_bag_type PKCS12_SAFEBAG_get_nid -# define PKCS12_cert_bag_type PKCS12_SAFEBAG_get_bag_nid -# define PKCS12_x5092certbag PKCS12_SAFEBAG_create_cert -# define PKCS12_x509crl2certbag PKCS12_SAFEBAG_create_crl -# define PKCS12_MAKE_KEYBAG PKCS12_SAFEBAG_create0_p8inf -# define PKCS12_MAKE_SHKEYBAG PKCS12_SAFEBAG_create_pkcs8_encrypt - -#endif - -DEPRECATEDIN_1_1_0(ASN1_TYPE *PKCS12_get_attr(const PKCS12_SAFEBAG *bag, int attr_nid)) - -ASN1_TYPE *PKCS8_get_attr(PKCS8_PRIV_KEY_INFO *p8, int attr_nid); -int PKCS12_mac_present(const PKCS12 *p12); -void PKCS12_get0_mac(const ASN1_OCTET_STRING **pmac, - const X509_ALGOR **pmacalg, - const ASN1_OCTET_STRING **psalt, - const ASN1_INTEGER **piter, - const PKCS12 *p12); - -const ASN1_TYPE *PKCS12_SAFEBAG_get0_attr(const PKCS12_SAFEBAG *bag, - int attr_nid); -const ASN1_OBJECT *PKCS12_SAFEBAG_get0_type(const PKCS12_SAFEBAG *bag); -int PKCS12_SAFEBAG_get_nid(const PKCS12_SAFEBAG *bag); -int PKCS12_SAFEBAG_get_bag_nid(const PKCS12_SAFEBAG *bag); - -X509 *PKCS12_SAFEBAG_get1_cert(const PKCS12_SAFEBAG *bag); -X509_CRL *PKCS12_SAFEBAG_get1_crl(const PKCS12_SAFEBAG *bag); -const STACK_OF(PKCS12_SAFEBAG) * -PKCS12_SAFEBAG_get0_safes(const PKCS12_SAFEBAG *bag); -const PKCS8_PRIV_KEY_INFO *PKCS12_SAFEBAG_get0_p8inf(const PKCS12_SAFEBAG *bag); -const X509_SIG *PKCS12_SAFEBAG_get0_pkcs8(const PKCS12_SAFEBAG *bag); - -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_cert(X509 *x509); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_crl(X509_CRL *crl); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_p8inf(PKCS8_PRIV_KEY_INFO *p8); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create0_pkcs8(X509_SIG *p8); -PKCS12_SAFEBAG *PKCS12_SAFEBAG_create_pkcs8_encrypt(int pbe_nid, - const char *pass, - int passlen, - unsigned char *salt, - int saltlen, int iter, - PKCS8_PRIV_KEY_INFO *p8inf); - -PKCS12_SAFEBAG *PKCS12_item_pack_safebag(void *obj, const ASN1_ITEM *it, - int nid1, int nid2); -PKCS8_PRIV_KEY_INFO *PKCS8_decrypt(const X509_SIG *p8, const char *pass, - int passlen); -PKCS8_PRIV_KEY_INFO *PKCS12_decrypt_skey(const PKCS12_SAFEBAG *bag, - const char *pass, int passlen); -X509_SIG *PKCS8_encrypt(int pbe_nid, const EVP_CIPHER *cipher, - const char *pass, int passlen, unsigned char *salt, - int saltlen, int iter, PKCS8_PRIV_KEY_INFO *p8); -X509_SIG *PKCS8_set0_pbe(const char *pass, int passlen, - PKCS8_PRIV_KEY_INFO *p8inf, X509_ALGOR *pbe); -PKCS7 *PKCS12_pack_p7data(STACK_OF(PKCS12_SAFEBAG) *sk); -STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7data(PKCS7 *p7); -PKCS7 *PKCS12_pack_p7encdata(int pbe_nid, const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, - STACK_OF(PKCS12_SAFEBAG) *bags); -STACK_OF(PKCS12_SAFEBAG) *PKCS12_unpack_p7encdata(PKCS7 *p7, const char *pass, - int passlen); - -int PKCS12_pack_authsafes(PKCS12 *p12, STACK_OF(PKCS7) *safes); -STACK_OF(PKCS7) *PKCS12_unpack_authsafes(const PKCS12 *p12); - -int PKCS12_add_localkeyid(PKCS12_SAFEBAG *bag, unsigned char *name, - int namelen); -int PKCS12_add_friendlyname_asc(PKCS12_SAFEBAG *bag, const char *name, - int namelen); -int PKCS12_add_friendlyname_utf8(PKCS12_SAFEBAG *bag, const char *name, - int namelen); -int PKCS12_add_CSPName_asc(PKCS12_SAFEBAG *bag, const char *name, - int namelen); -int PKCS12_add_friendlyname_uni(PKCS12_SAFEBAG *bag, - const unsigned char *name, int namelen); -int PKCS8_add_keyusage(PKCS8_PRIV_KEY_INFO *p8, int usage); -ASN1_TYPE *PKCS12_get_attr_gen(const STACK_OF(X509_ATTRIBUTE) *attrs, - int attr_nid); -char *PKCS12_get_friendlyname(PKCS12_SAFEBAG *bag); -const STACK_OF(X509_ATTRIBUTE) * -PKCS12_SAFEBAG_get0_attrs(const PKCS12_SAFEBAG *bag); -unsigned char *PKCS12_pbe_crypt(const X509_ALGOR *algor, - const char *pass, int passlen, - const unsigned char *in, int inlen, - unsigned char **data, int *datalen, - int en_de); -void *PKCS12_item_decrypt_d2i(const X509_ALGOR *algor, const ASN1_ITEM *it, - const char *pass, int passlen, - const ASN1_OCTET_STRING *oct, int zbuf); -ASN1_OCTET_STRING *PKCS12_item_i2d_encrypt(X509_ALGOR *algor, - const ASN1_ITEM *it, - const char *pass, int passlen, - void *obj, int zbuf); -PKCS12 *PKCS12_init(int mode); -int PKCS12_key_gen_asc(const char *pass, int passlen, unsigned char *salt, - int saltlen, int id, int iter, int n, - unsigned char *out, const EVP_MD *md_type); -int PKCS12_key_gen_uni(unsigned char *pass, int passlen, unsigned char *salt, - int saltlen, int id, int iter, int n, - unsigned char *out, const EVP_MD *md_type); -int PKCS12_key_gen_utf8(const char *pass, int passlen, unsigned char *salt, - int saltlen, int id, int iter, int n, - unsigned char *out, const EVP_MD *md_type); -int PKCS12_PBE_keyivgen(EVP_CIPHER_CTX *ctx, const char *pass, int passlen, - ASN1_TYPE *param, const EVP_CIPHER *cipher, - const EVP_MD *md_type, int en_de); -int PKCS12_gen_mac(PKCS12 *p12, const char *pass, int passlen, - unsigned char *mac, unsigned int *maclen); -int PKCS12_verify_mac(PKCS12 *p12, const char *pass, int passlen); -int PKCS12_set_mac(PKCS12 *p12, const char *pass, int passlen, - unsigned char *salt, int saltlen, int iter, - const EVP_MD *md_type); -int PKCS12_setup_mac(PKCS12 *p12, int iter, unsigned char *salt, - int saltlen, const EVP_MD *md_type); -unsigned char *OPENSSL_asc2uni(const char *asc, int asclen, - unsigned char **uni, int *unilen); -char *OPENSSL_uni2asc(const unsigned char *uni, int unilen); -unsigned char *OPENSSL_utf82uni(const char *asc, int asclen, - unsigned char **uni, int *unilen); -char *OPENSSL_uni2utf8(const unsigned char *uni, int unilen); - -DECLARE_ASN1_FUNCTIONS(PKCS12) -DECLARE_ASN1_FUNCTIONS(PKCS12_MAC_DATA) -DECLARE_ASN1_FUNCTIONS(PKCS12_SAFEBAG) -DECLARE_ASN1_FUNCTIONS(PKCS12_BAGS) - -DECLARE_ASN1_ITEM(PKCS12_SAFEBAGS) -DECLARE_ASN1_ITEM(PKCS12_AUTHSAFES) - -void PKCS12_PBE_add(void); -int PKCS12_parse(PKCS12 *p12, const char *pass, EVP_PKEY **pkey, X509 **cert, - STACK_OF(X509) **ca); -PKCS12 *PKCS12_create(const char *pass, const char *name, EVP_PKEY *pkey, - X509 *cert, STACK_OF(X509) *ca, int nid_key, int nid_cert, - int iter, int mac_iter, int keytype); - -PKCS12_SAFEBAG *PKCS12_add_cert(STACK_OF(PKCS12_SAFEBAG) **pbags, X509 *cert); -PKCS12_SAFEBAG *PKCS12_add_key(STACK_OF(PKCS12_SAFEBAG) **pbags, - EVP_PKEY *key, int key_usage, int iter, - int key_nid, const char *pass); -int PKCS12_add_safe(STACK_OF(PKCS7) **psafes, STACK_OF(PKCS12_SAFEBAG) *bags, - int safe_nid, int iter, const char *pass); -PKCS12 *PKCS12_add_safes(STACK_OF(PKCS7) *safes, int p7_nid); - -int i2d_PKCS12_bio(BIO *bp, PKCS12 *p12); -# ifndef OPENSSL_NO_STDIO -int i2d_PKCS12_fp(FILE *fp, PKCS12 *p12); -# endif -PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); -# ifndef OPENSSL_NO_STDIO -PKCS12 *d2i_PKCS12_fp(FILE *fp, PKCS12 **p12); -# endif -int PKCS12_newpass(PKCS12 *p12, const char *oldpass, const char *newpass); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_PKCS12_strings(void); - -/* Error codes for the PKCS12 functions. */ - -/* Function codes. */ -# define PKCS12_F_PKCS12_CREATE 105 -# define PKCS12_F_PKCS12_GEN_MAC 107 -# define PKCS12_F_PKCS12_INIT 109 -# define PKCS12_F_PKCS12_ITEM_DECRYPT_D2I 106 -# define PKCS12_F_PKCS12_ITEM_I2D_ENCRYPT 108 -# define PKCS12_F_PKCS12_ITEM_PACK_SAFEBAG 117 -# define PKCS12_F_PKCS12_KEY_GEN_ASC 110 -# define PKCS12_F_PKCS12_KEY_GEN_UNI 111 -# define PKCS12_F_PKCS12_KEY_GEN_UTF8 116 -# define PKCS12_F_PKCS12_NEWPASS 128 -# define PKCS12_F_PKCS12_PACK_P7DATA 114 -# define PKCS12_F_PKCS12_PACK_P7ENCDATA 115 -# define PKCS12_F_PKCS12_PARSE 118 -# define PKCS12_F_PKCS12_PBE_CRYPT 119 -# define PKCS12_F_PKCS12_PBE_KEYIVGEN 120 -# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_P8INF 112 -# define PKCS12_F_PKCS12_SAFEBAG_CREATE0_PKCS8 113 -# define PKCS12_F_PKCS12_SAFEBAG_CREATE_PKCS8_ENCRYPT 133 -# define PKCS12_F_PKCS12_SETUP_MAC 122 -# define PKCS12_F_PKCS12_SET_MAC 123 -# define PKCS12_F_PKCS12_UNPACK_AUTHSAFES 130 -# define PKCS12_F_PKCS12_UNPACK_P7DATA 131 -# define PKCS12_F_PKCS12_VERIFY_MAC 126 -# define PKCS12_F_PKCS8_ENCRYPT 125 -# define PKCS12_F_PKCS8_SET0_PBE 132 - -/* Reason codes. */ -# define PKCS12_R_CANT_PACK_STRUCTURE 100 -# define PKCS12_R_CONTENT_TYPE_NOT_DATA 121 -# define PKCS12_R_DECODE_ERROR 101 -# define PKCS12_R_ENCODE_ERROR 102 -# define PKCS12_R_ENCRYPT_ERROR 103 -# define PKCS12_R_ERROR_SETTING_ENCRYPTED_DATA_TYPE 120 -# define PKCS12_R_INVALID_NULL_ARGUMENT 104 -# define PKCS12_R_INVALID_NULL_PKCS12_POINTER 105 -# define PKCS12_R_IV_GEN_ERROR 106 -# define PKCS12_R_KEY_GEN_ERROR 107 -# define PKCS12_R_MAC_ABSENT 108 -# define PKCS12_R_MAC_GENERATION_ERROR 109 -# define PKCS12_R_MAC_SETUP_ERROR 110 -# define PKCS12_R_MAC_STRING_SET_ERROR 111 -# define PKCS12_R_MAC_VERIFY_FAILURE 113 -# define PKCS12_R_PARSE_ERROR 114 -# define PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR 115 -# define PKCS12_R_PKCS12_CIPHERFINAL_ERROR 116 -# define PKCS12_R_PKCS12_PBE_CRYPT_ERROR 117 -# define PKCS12_R_UNKNOWN_DIGEST_ALGORITHM 118 -# define PKCS12_R_UNSUPPORTED_PKCS12_MODE 119 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/pkcs7.h b/android/armeabi/include/openssl/pkcs7.h deleted file mode 100644 index 691f7220..00000000 --- a/android/armeabi/include/openssl/pkcs7.h +++ /dev/null @@ -1,404 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_PKCS7_H -# define HEADER_PKCS7_H - -# include <openssl/asn1.h> -# include <openssl/bio.h> -# include <openssl/e_os2.h> - -# include <openssl/symhacks.h> -# include <openssl/ossl_typ.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*- -Encryption_ID DES-CBC -Digest_ID MD5 -Digest_Encryption_ID rsaEncryption -Key_Encryption_ID rsaEncryption -*/ - -typedef struct pkcs7_issuer_and_serial_st { - X509_NAME *issuer; - ASN1_INTEGER *serial; -} PKCS7_ISSUER_AND_SERIAL; - -typedef struct pkcs7_signer_info_st { - ASN1_INTEGER *version; /* version 1 */ - PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; - X509_ALGOR *digest_alg; - STACK_OF(X509_ATTRIBUTE) *auth_attr; /* [ 0 ] */ - X509_ALGOR *digest_enc_alg; - ASN1_OCTET_STRING *enc_digest; - STACK_OF(X509_ATTRIBUTE) *unauth_attr; /* [ 1 ] */ - /* The private key to sign with */ - EVP_PKEY *pkey; -} PKCS7_SIGNER_INFO; - -DEFINE_STACK_OF(PKCS7_SIGNER_INFO) - -typedef struct pkcs7_recip_info_st { - ASN1_INTEGER *version; /* version 0 */ - PKCS7_ISSUER_AND_SERIAL *issuer_and_serial; - X509_ALGOR *key_enc_algor; - ASN1_OCTET_STRING *enc_key; - X509 *cert; /* get the pub-key from this */ -} PKCS7_RECIP_INFO; - -DEFINE_STACK_OF(PKCS7_RECIP_INFO) - -typedef struct pkcs7_signed_st { - ASN1_INTEGER *version; /* version 1 */ - STACK_OF(X509_ALGOR) *md_algs; /* md used */ - STACK_OF(X509) *cert; /* [ 0 ] */ - STACK_OF(X509_CRL) *crl; /* [ 1 ] */ - STACK_OF(PKCS7_SIGNER_INFO) *signer_info; - struct pkcs7_st *contents; -} PKCS7_SIGNED; -/* - * The above structure is very very similar to PKCS7_SIGN_ENVELOPE. How about - * merging the two - */ - -typedef struct pkcs7_enc_content_st { - ASN1_OBJECT *content_type; - X509_ALGOR *algorithm; - ASN1_OCTET_STRING *enc_data; /* [ 0 ] */ - const EVP_CIPHER *cipher; -} PKCS7_ENC_CONTENT; - -typedef struct pkcs7_enveloped_st { - ASN1_INTEGER *version; /* version 0 */ - STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; - PKCS7_ENC_CONTENT *enc_data; -} PKCS7_ENVELOPE; - -typedef struct pkcs7_signedandenveloped_st { - ASN1_INTEGER *version; /* version 1 */ - STACK_OF(X509_ALGOR) *md_algs; /* md used */ - STACK_OF(X509) *cert; /* [ 0 ] */ - STACK_OF(X509_CRL) *crl; /* [ 1 ] */ - STACK_OF(PKCS7_SIGNER_INFO) *signer_info; - PKCS7_ENC_CONTENT *enc_data; - STACK_OF(PKCS7_RECIP_INFO) *recipientinfo; -} PKCS7_SIGN_ENVELOPE; - -typedef struct pkcs7_digest_st { - ASN1_INTEGER *version; /* version 0 */ - X509_ALGOR *md; /* md used */ - struct pkcs7_st *contents; - ASN1_OCTET_STRING *digest; -} PKCS7_DIGEST; - -typedef struct pkcs7_encrypted_st { - ASN1_INTEGER *version; /* version 0 */ - PKCS7_ENC_CONTENT *enc_data; -} PKCS7_ENCRYPT; - -typedef struct pkcs7_st { - /* - * The following is non NULL if it contains ASN1 encoding of this - * structure - */ - unsigned char *asn1; - long length; -# define PKCS7_S_HEADER 0 -# define PKCS7_S_BODY 1 -# define PKCS7_S_TAIL 2 - int state; /* used during processing */ - int detached; - ASN1_OBJECT *type; - /* content as defined by the type */ - /* - * all encryption/message digests are applied to the 'contents', leaving - * out the 'type' field. - */ - union { - char *ptr; - /* NID_pkcs7_data */ - ASN1_OCTET_STRING *data; - /* NID_pkcs7_signed */ - PKCS7_SIGNED *sign; - /* NID_pkcs7_enveloped */ - PKCS7_ENVELOPE *enveloped; - /* NID_pkcs7_signedAndEnveloped */ - PKCS7_SIGN_ENVELOPE *signed_and_enveloped; - /* NID_pkcs7_digest */ - PKCS7_DIGEST *digest; - /* NID_pkcs7_encrypted */ - PKCS7_ENCRYPT *encrypted; - /* Anything else */ - ASN1_TYPE *other; - } d; -} PKCS7; - -DEFINE_STACK_OF(PKCS7) - -# define PKCS7_OP_SET_DETACHED_SIGNATURE 1 -# define PKCS7_OP_GET_DETACHED_SIGNATURE 2 - -# define PKCS7_get_signed_attributes(si) ((si)->auth_attr) -# define PKCS7_get_attributes(si) ((si)->unauth_attr) - -# define PKCS7_type_is_signed(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_signed) -# define PKCS7_type_is_encrypted(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_encrypted) -# define PKCS7_type_is_enveloped(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_enveloped) -# define PKCS7_type_is_signedAndEnveloped(a) \ - (OBJ_obj2nid((a)->type) == NID_pkcs7_signedAndEnveloped) -# define PKCS7_type_is_data(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_data) -# define PKCS7_type_is_digest(a) (OBJ_obj2nid((a)->type) == NID_pkcs7_digest) - -# define PKCS7_set_detached(p,v) \ - PKCS7_ctrl(p,PKCS7_OP_SET_DETACHED_SIGNATURE,v,NULL) -# define PKCS7_get_detached(p) \ - PKCS7_ctrl(p,PKCS7_OP_GET_DETACHED_SIGNATURE,0,NULL) - -# define PKCS7_is_detached(p7) (PKCS7_type_is_signed(p7) && PKCS7_get_detached(p7)) - -/* S/MIME related flags */ - -# define PKCS7_TEXT 0x1 -# define PKCS7_NOCERTS 0x2 -# define PKCS7_NOSIGS 0x4 -# define PKCS7_NOCHAIN 0x8 -# define PKCS7_NOINTERN 0x10 -# define PKCS7_NOVERIFY 0x20 -# define PKCS7_DETACHED 0x40 -# define PKCS7_BINARY 0x80 -# define PKCS7_NOATTR 0x100 -# define PKCS7_NOSMIMECAP 0x200 -# define PKCS7_NOOLDMIMETYPE 0x400 -# define PKCS7_CRLFEOL 0x800 -# define PKCS7_STREAM 0x1000 -# define PKCS7_NOCRL 0x2000 -# define PKCS7_PARTIAL 0x4000 -# define PKCS7_REUSE_DIGEST 0x8000 -# define PKCS7_NO_DUAL_CONTENT 0x10000 - -/* Flags: for compatibility with older code */ - -# define SMIME_TEXT PKCS7_TEXT -# define SMIME_NOCERTS PKCS7_NOCERTS -# define SMIME_NOSIGS PKCS7_NOSIGS -# define SMIME_NOCHAIN PKCS7_NOCHAIN -# define SMIME_NOINTERN PKCS7_NOINTERN -# define SMIME_NOVERIFY PKCS7_NOVERIFY -# define SMIME_DETACHED PKCS7_DETACHED -# define SMIME_BINARY PKCS7_BINARY -# define SMIME_NOATTR PKCS7_NOATTR - -/* CRLF ASCII canonicalisation */ -# define SMIME_ASCIICRLF 0x80000 - -DECLARE_ASN1_FUNCTIONS(PKCS7_ISSUER_AND_SERIAL) - -int PKCS7_ISSUER_AND_SERIAL_digest(PKCS7_ISSUER_AND_SERIAL *data, - const EVP_MD *type, unsigned char *md, - unsigned int *len); -# ifndef OPENSSL_NO_STDIO -PKCS7 *d2i_PKCS7_fp(FILE *fp, PKCS7 **p7); -int i2d_PKCS7_fp(FILE *fp, PKCS7 *p7); -# endif -PKCS7 *PKCS7_dup(PKCS7 *p7); -PKCS7 *d2i_PKCS7_bio(BIO *bp, PKCS7 **p7); -int i2d_PKCS7_bio(BIO *bp, PKCS7 *p7); -int i2d_PKCS7_bio_stream(BIO *out, PKCS7 *p7, BIO *in, int flags); -int PEM_write_bio_PKCS7_stream(BIO *out, PKCS7 *p7, BIO *in, int flags); - -DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNER_INFO) -DECLARE_ASN1_FUNCTIONS(PKCS7_RECIP_INFO) -DECLARE_ASN1_FUNCTIONS(PKCS7_SIGNED) -DECLARE_ASN1_FUNCTIONS(PKCS7_ENC_CONTENT) -DECLARE_ASN1_FUNCTIONS(PKCS7_ENVELOPE) -DECLARE_ASN1_FUNCTIONS(PKCS7_SIGN_ENVELOPE) -DECLARE_ASN1_FUNCTIONS(PKCS7_DIGEST) -DECLARE_ASN1_FUNCTIONS(PKCS7_ENCRYPT) -DECLARE_ASN1_FUNCTIONS(PKCS7) - -DECLARE_ASN1_ITEM(PKCS7_ATTR_SIGN) -DECLARE_ASN1_ITEM(PKCS7_ATTR_VERIFY) - -DECLARE_ASN1_NDEF_FUNCTION(PKCS7) -DECLARE_ASN1_PRINT_FUNCTION(PKCS7) - -long PKCS7_ctrl(PKCS7 *p7, int cmd, long larg, char *parg); - -int PKCS7_set_type(PKCS7 *p7, int type); -int PKCS7_set0_type_other(PKCS7 *p7, int type, ASN1_TYPE *other); -int PKCS7_set_content(PKCS7 *p7, PKCS7 *p7_data); -int PKCS7_SIGNER_INFO_set(PKCS7_SIGNER_INFO *p7i, X509 *x509, EVP_PKEY *pkey, - const EVP_MD *dgst); -int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si); -int PKCS7_add_signer(PKCS7 *p7, PKCS7_SIGNER_INFO *p7i); -int PKCS7_add_certificate(PKCS7 *p7, X509 *x509); -int PKCS7_add_crl(PKCS7 *p7, X509_CRL *x509); -int PKCS7_content_new(PKCS7 *p7, int nid); -int PKCS7_dataVerify(X509_STORE *cert_store, X509_STORE_CTX *ctx, - BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si); -int PKCS7_signatureVerify(BIO *bio, PKCS7 *p7, PKCS7_SIGNER_INFO *si, - X509 *x509); - -BIO *PKCS7_dataInit(PKCS7 *p7, BIO *bio); -int PKCS7_dataFinal(PKCS7 *p7, BIO *bio); -BIO *PKCS7_dataDecode(PKCS7 *p7, EVP_PKEY *pkey, BIO *in_bio, X509 *pcert); - -PKCS7_SIGNER_INFO *PKCS7_add_signature(PKCS7 *p7, X509 *x509, - EVP_PKEY *pkey, const EVP_MD *dgst); -X509 *PKCS7_cert_from_signer_info(PKCS7 *p7, PKCS7_SIGNER_INFO *si); -int PKCS7_set_digest(PKCS7 *p7, const EVP_MD *md); -STACK_OF(PKCS7_SIGNER_INFO) *PKCS7_get_signer_info(PKCS7 *p7); - -PKCS7_RECIP_INFO *PKCS7_add_recipient(PKCS7 *p7, X509 *x509); -void PKCS7_SIGNER_INFO_get0_algs(PKCS7_SIGNER_INFO *si, EVP_PKEY **pk, - X509_ALGOR **pdig, X509_ALGOR **psig); -void PKCS7_RECIP_INFO_get0_alg(PKCS7_RECIP_INFO *ri, X509_ALGOR **penc); -int PKCS7_add_recipient_info(PKCS7 *p7, PKCS7_RECIP_INFO *ri); -int PKCS7_RECIP_INFO_set(PKCS7_RECIP_INFO *p7i, X509 *x509); -int PKCS7_set_cipher(PKCS7 *p7, const EVP_CIPHER *cipher); -int PKCS7_stream(unsigned char ***boundary, PKCS7 *p7); - -PKCS7_ISSUER_AND_SERIAL *PKCS7_get_issuer_and_serial(PKCS7 *p7, int idx); -ASN1_OCTET_STRING *PKCS7_digest_from_attributes(STACK_OF(X509_ATTRIBUTE) *sk); -int PKCS7_add_signed_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int type, - void *data); -int PKCS7_add_attribute(PKCS7_SIGNER_INFO *p7si, int nid, int atrtype, - void *value); -ASN1_TYPE *PKCS7_get_attribute(PKCS7_SIGNER_INFO *si, int nid); -ASN1_TYPE *PKCS7_get_signed_attribute(PKCS7_SIGNER_INFO *si, int nid); -int PKCS7_set_signed_attributes(PKCS7_SIGNER_INFO *p7si, - STACK_OF(X509_ATTRIBUTE) *sk); -int PKCS7_set_attributes(PKCS7_SIGNER_INFO *p7si, - STACK_OF(X509_ATTRIBUTE) *sk); - -PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, - BIO *data, int flags); - -PKCS7_SIGNER_INFO *PKCS7_sign_add_signer(PKCS7 *p7, - X509 *signcert, EVP_PKEY *pkey, - const EVP_MD *md, int flags); - -int PKCS7_final(PKCS7 *p7, BIO *data, int flags); -int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, - BIO *indata, BIO *out, int flags); -STACK_OF(X509) *PKCS7_get0_signers(PKCS7 *p7, STACK_OF(X509) *certs, - int flags); -PKCS7 *PKCS7_encrypt(STACK_OF(X509) *certs, BIO *in, const EVP_CIPHER *cipher, - int flags); -int PKCS7_decrypt(PKCS7 *p7, EVP_PKEY *pkey, X509 *cert, BIO *data, - int flags); - -int PKCS7_add_attrib_smimecap(PKCS7_SIGNER_INFO *si, - STACK_OF(X509_ALGOR) *cap); -STACK_OF(X509_ALGOR) *PKCS7_get_smimecap(PKCS7_SIGNER_INFO *si); -int PKCS7_simple_smimecap(STACK_OF(X509_ALGOR) *sk, int nid, int arg); - -int PKCS7_add_attrib_content_type(PKCS7_SIGNER_INFO *si, ASN1_OBJECT *coid); -int PKCS7_add0_attrib_signing_time(PKCS7_SIGNER_INFO *si, ASN1_TIME *t); -int PKCS7_add1_attrib_digest(PKCS7_SIGNER_INFO *si, - const unsigned char *md, int mdlen); - -int SMIME_write_PKCS7(BIO *bio, PKCS7 *p7, BIO *data, int flags); -PKCS7 *SMIME_read_PKCS7(BIO *bio, BIO **bcont); - -BIO *BIO_new_PKCS7(BIO *out, PKCS7 *p7); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_PKCS7_strings(void); - -/* Error codes for the PKCS7 functions. */ - -/* Function codes. */ -# define PKCS7_F_DO_PKCS7_SIGNED_ATTRIB 136 -# define PKCS7_F_PKCS7_ADD0_ATTRIB_SIGNING_TIME 135 -# define PKCS7_F_PKCS7_ADD_ATTRIB_SMIMECAP 118 -# define PKCS7_F_PKCS7_ADD_CERTIFICATE 100 -# define PKCS7_F_PKCS7_ADD_CRL 101 -# define PKCS7_F_PKCS7_ADD_RECIPIENT_INFO 102 -# define PKCS7_F_PKCS7_ADD_SIGNATURE 131 -# define PKCS7_F_PKCS7_ADD_SIGNER 103 -# define PKCS7_F_PKCS7_BIO_ADD_DIGEST 125 -# define PKCS7_F_PKCS7_COPY_EXISTING_DIGEST 138 -# define PKCS7_F_PKCS7_CTRL 104 -# define PKCS7_F_PKCS7_DATADECODE 112 -# define PKCS7_F_PKCS7_DATAFINAL 128 -# define PKCS7_F_PKCS7_DATAINIT 105 -# define PKCS7_F_PKCS7_DATAVERIFY 107 -# define PKCS7_F_PKCS7_DECRYPT 114 -# define PKCS7_F_PKCS7_DECRYPT_RINFO 133 -# define PKCS7_F_PKCS7_ENCODE_RINFO 132 -# define PKCS7_F_PKCS7_ENCRYPT 115 -# define PKCS7_F_PKCS7_FINAL 134 -# define PKCS7_F_PKCS7_FIND_DIGEST 127 -# define PKCS7_F_PKCS7_GET0_SIGNERS 124 -# define PKCS7_F_PKCS7_RECIP_INFO_SET 130 -# define PKCS7_F_PKCS7_SET_CIPHER 108 -# define PKCS7_F_PKCS7_SET_CONTENT 109 -# define PKCS7_F_PKCS7_SET_DIGEST 126 -# define PKCS7_F_PKCS7_SET_TYPE 110 -# define PKCS7_F_PKCS7_SIGN 116 -# define PKCS7_F_PKCS7_SIGNATUREVERIFY 113 -# define PKCS7_F_PKCS7_SIGNER_INFO_SET 129 -# define PKCS7_F_PKCS7_SIGNER_INFO_SIGN 139 -# define PKCS7_F_PKCS7_SIGN_ADD_SIGNER 137 -# define PKCS7_F_PKCS7_SIMPLE_SMIMECAP 119 -# define PKCS7_F_PKCS7_VERIFY 117 - -/* Reason codes. */ -# define PKCS7_R_CERTIFICATE_VERIFY_ERROR 117 -# define PKCS7_R_CIPHER_HAS_NO_OBJECT_IDENTIFIER 144 -# define PKCS7_R_CIPHER_NOT_INITIALIZED 116 -# define PKCS7_R_CONTENT_AND_DATA_PRESENT 118 -# define PKCS7_R_CTRL_ERROR 152 -# define PKCS7_R_DECRYPT_ERROR 119 -# define PKCS7_R_DIGEST_FAILURE 101 -# define PKCS7_R_ENCRYPTION_CTRL_FAILURE 149 -# define PKCS7_R_ENCRYPTION_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 150 -# define PKCS7_R_ERROR_ADDING_RECIPIENT 120 -# define PKCS7_R_ERROR_SETTING_CIPHER 121 -# define PKCS7_R_INVALID_NULL_POINTER 143 -# define PKCS7_R_INVALID_SIGNED_DATA_TYPE 155 -# define PKCS7_R_NO_CONTENT 122 -# define PKCS7_R_NO_DEFAULT_DIGEST 151 -# define PKCS7_R_NO_MATCHING_DIGEST_TYPE_FOUND 154 -# define PKCS7_R_NO_RECIPIENT_MATCHES_CERTIFICATE 115 -# define PKCS7_R_NO_SIGNATURES_ON_DATA 123 -# define PKCS7_R_NO_SIGNERS 142 -# define PKCS7_R_OPERATION_NOT_SUPPORTED_ON_THIS_TYPE 104 -# define PKCS7_R_PKCS7_ADD_SIGNATURE_ERROR 124 -# define PKCS7_R_PKCS7_ADD_SIGNER_ERROR 153 -# define PKCS7_R_PKCS7_DATASIGN 145 -# define PKCS7_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 127 -# define PKCS7_R_SIGNATURE_FAILURE 105 -# define PKCS7_R_SIGNER_CERTIFICATE_NOT_FOUND 128 -# define PKCS7_R_SIGNING_CTRL_FAILURE 147 -# define PKCS7_R_SIGNING_NOT_SUPPORTED_FOR_THIS_KEY_TYPE 148 -# define PKCS7_R_SMIME_TEXT_ERROR 129 -# define PKCS7_R_UNABLE_TO_FIND_CERTIFICATE 106 -# define PKCS7_R_UNABLE_TO_FIND_MEM_BIO 107 -# define PKCS7_R_UNABLE_TO_FIND_MESSAGE_DIGEST 108 -# define PKCS7_R_UNKNOWN_DIGEST_TYPE 109 -# define PKCS7_R_UNKNOWN_OPERATION 110 -# define PKCS7_R_UNSUPPORTED_CIPHER_TYPE 111 -# define PKCS7_R_UNSUPPORTED_CONTENT_TYPE 112 -# define PKCS7_R_WRONG_CONTENT_TYPE 113 -# define PKCS7_R_WRONG_PKCS7_TYPE 114 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/rand.h b/android/armeabi/include/openssl/rand.h deleted file mode 100644 index d521ae19..00000000 --- a/android/armeabi/include/openssl/rand.h +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RAND_H -# define HEADER_RAND_H - -# include <stdlib.h> -# include <openssl/ossl_typ.h> -# include <openssl/e_os2.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* Already defined in ossl_typ.h */ -/* typedef struct rand_meth_st RAND_METHOD; */ - -struct rand_meth_st { - int (*seed) (const void *buf, int num); - int (*bytes) (unsigned char *buf, int num); - void (*cleanup) (void); - int (*add) (const void *buf, int num, double entropy); - int (*pseudorand) (unsigned char *buf, int num); - int (*status) (void); -}; - -# ifdef BN_DEBUG -extern int rand_predictable; -# endif - -int RAND_set_rand_method(const RAND_METHOD *meth); -const RAND_METHOD *RAND_get_rand_method(void); -# ifndef OPENSSL_NO_ENGINE -int RAND_set_rand_engine(ENGINE *engine); -# endif -RAND_METHOD *RAND_OpenSSL(void); -#if OPENSSL_API_COMPAT < 0x10100000L -# define RAND_cleanup() while(0) continue -#endif -int RAND_bytes(unsigned char *buf, int num); -DEPRECATEDIN_1_1_0(int RAND_pseudo_bytes(unsigned char *buf, int num)) -void RAND_seed(const void *buf, int num); -#if defined(__ANDROID__) && defined(__NDK_FPABI__) -__NDK_FPABI__ /* __attribute__((pcs("aapcs"))) on ARM */ -#endif -void RAND_add(const void *buf, int num, double entropy); -int RAND_load_file(const char *file, long max_bytes); -int RAND_write_file(const char *file); -const char *RAND_file_name(char *file, size_t num); -int RAND_status(void); -# ifndef OPENSSL_NO_EGD -int RAND_query_egd_bytes(const char *path, unsigned char *buf, int bytes); -int RAND_egd(const char *path); -int RAND_egd_bytes(const char *path, int bytes); -# endif -int RAND_poll(void); - -#if defined(_WIN32) && (defined(BASETYPES) || defined(_WINDEF_H)) -/* application has to include <windows.h> in order to use these */ -DEPRECATEDIN_1_1_0(void RAND_screen(void)) -DEPRECATEDIN_1_1_0(int RAND_event(UINT, WPARAM, LPARAM)) -#endif - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_RAND_strings(void); - -/* Error codes for the RAND functions. */ - -/* Function codes. */ -# define RAND_F_RAND_BYTES 100 - -/* Reason codes. */ -# define RAND_R_PRNG_NOT_SEEDED 100 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/rc2.h b/android/armeabi/include/openssl/rc2.h deleted file mode 100644 index 585f9e4c..00000000 --- a/android/armeabi/include/openssl/rc2.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RC2_H -# define HEADER_RC2_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_RC2 -# ifdef __cplusplus -extern "C" { -# endif - -typedef unsigned int RC2_INT; - -# define RC2_ENCRYPT 1 -# define RC2_DECRYPT 0 - -# define RC2_BLOCK 8 -# define RC2_KEY_LENGTH 16 - -typedef struct rc2_key_st { - RC2_INT data[64]; -} RC2_KEY; - -void RC2_set_key(RC2_KEY *key, int len, const unsigned char *data, int bits); -void RC2_ecb_encrypt(const unsigned char *in, unsigned char *out, - RC2_KEY *key, int enc); -void RC2_encrypt(unsigned long *data, RC2_KEY *key); -void RC2_decrypt(unsigned long *data, RC2_KEY *key); -void RC2_cbc_encrypt(const unsigned char *in, unsigned char *out, long length, - RC2_KEY *ks, unsigned char *iv, int enc); -void RC2_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC2_KEY *schedule, unsigned char *ivec, - int *num, int enc); -void RC2_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC2_KEY *schedule, unsigned char *ivec, - int *num); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/rc4.h b/android/armeabi/include/openssl/rc4.h deleted file mode 100644 index 86803b37..00000000 --- a/android/armeabi/include/openssl/rc4.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RC4_H -# define HEADER_RC4_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_RC4 -# include <stddef.h> -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct rc4_key_st { - RC4_INT x, y; - RC4_INT data[256]; -} RC4_KEY; - -const char *RC4_options(void); -void RC4_set_key(RC4_KEY *key, int len, const unsigned char *data); -void RC4(RC4_KEY *key, size_t len, const unsigned char *indata, - unsigned char *outdata); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/rc5.h b/android/armeabi/include/openssl/rc5.h deleted file mode 100644 index 793f88e4..00000000 --- a/android/armeabi/include/openssl/rc5.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RC5_H -# define HEADER_RC5_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_RC5 -# ifdef __cplusplus -extern "C" { -# endif - -# define RC5_ENCRYPT 1 -# define RC5_DECRYPT 0 - -# define RC5_32_INT unsigned int - -# define RC5_32_BLOCK 8 -# define RC5_32_KEY_LENGTH 16/* This is a default, max is 255 */ - -/* - * This are the only values supported. Tweak the code if you want more The - * most supported modes will be RC5-32/12/16 RC5-32/16/8 - */ -# define RC5_8_ROUNDS 8 -# define RC5_12_ROUNDS 12 -# define RC5_16_ROUNDS 16 - -typedef struct rc5_key_st { - /* Number of rounds */ - int rounds; - RC5_32_INT data[2 * (RC5_16_ROUNDS + 1)]; -} RC5_32_KEY; - -void RC5_32_set_key(RC5_32_KEY *key, int len, const unsigned char *data, - int rounds); -void RC5_32_ecb_encrypt(const unsigned char *in, unsigned char *out, - RC5_32_KEY *key, int enc); -void RC5_32_encrypt(unsigned long *data, RC5_32_KEY *key); -void RC5_32_decrypt(unsigned long *data, RC5_32_KEY *key); -void RC5_32_cbc_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *ks, unsigned char *iv, - int enc); -void RC5_32_cfb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *schedule, - unsigned char *ivec, int *num, int enc); -void RC5_32_ofb64_encrypt(const unsigned char *in, unsigned char *out, - long length, RC5_32_KEY *schedule, - unsigned char *ivec, int *num); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/ripemd.h b/android/armeabi/include/openssl/ripemd.h deleted file mode 100644 index c42026aa..00000000 --- a/android/armeabi/include/openssl/ripemd.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RIPEMD_H -# define HEADER_RIPEMD_H - -# include <openssl/opensslconf.h> - -#ifndef OPENSSL_NO_RMD160 -# include <openssl/e_os2.h> -# include <stddef.h> -# ifdef __cplusplus -extern "C" { -# endif - -# define RIPEMD160_LONG unsigned int - -# define RIPEMD160_CBLOCK 64 -# define RIPEMD160_LBLOCK (RIPEMD160_CBLOCK/4) -# define RIPEMD160_DIGEST_LENGTH 20 - -typedef struct RIPEMD160state_st { - RIPEMD160_LONG A, B, C, D, E; - RIPEMD160_LONG Nl, Nh; - RIPEMD160_LONG data[RIPEMD160_LBLOCK]; - unsigned int num; -} RIPEMD160_CTX; - -int RIPEMD160_Init(RIPEMD160_CTX *c); -int RIPEMD160_Update(RIPEMD160_CTX *c, const void *data, size_t len); -int RIPEMD160_Final(unsigned char *md, RIPEMD160_CTX *c); -unsigned char *RIPEMD160(const unsigned char *d, size_t n, unsigned char *md); -void RIPEMD160_Transform(RIPEMD160_CTX *c, const unsigned char *b); - -# ifdef __cplusplus -} -# endif -# endif - - -#endif diff --git a/android/armeabi/include/openssl/rsa.h b/android/armeabi/include/openssl/rsa.h deleted file mode 100644 index 4d6e9cc9..00000000 --- a/android/armeabi/include/openssl/rsa.h +++ /dev/null @@ -1,589 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_RSA_H -# define HEADER_RSA_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_RSA -# include <openssl/asn1.h> -# include <openssl/bio.h> -# include <openssl/crypto.h> -# include <openssl/ossl_typ.h> -# if OPENSSL_API_COMPAT < 0x10100000L -# include <openssl/bn.h> -# endif -# ifdef __cplusplus -extern "C" { -# endif - -/* The types RSA and RSA_METHOD are defined in ossl_typ.h */ - -# ifndef OPENSSL_RSA_MAX_MODULUS_BITS -# define OPENSSL_RSA_MAX_MODULUS_BITS 16384 -# endif - -# define OPENSSL_RSA_FIPS_MIN_MODULUS_BITS 1024 - -# ifndef OPENSSL_RSA_SMALL_MODULUS_BITS -# define OPENSSL_RSA_SMALL_MODULUS_BITS 3072 -# endif -# ifndef OPENSSL_RSA_MAX_PUBEXP_BITS - -/* exponent limit enforced for "large" modulus only */ -# define OPENSSL_RSA_MAX_PUBEXP_BITS 64 -# endif - -# define RSA_3 0x3L -# define RSA_F4 0x10001L - -# define RSA_METHOD_FLAG_NO_CHECK 0x0001/* don't check pub/private - * match */ - -# define RSA_FLAG_CACHE_PUBLIC 0x0002 -# define RSA_FLAG_CACHE_PRIVATE 0x0004 -# define RSA_FLAG_BLINDING 0x0008 -# define RSA_FLAG_THREAD_SAFE 0x0010 -/* - * This flag means the private key operations will be handled by rsa_mod_exp - * and that they do not depend on the private key components being present: - * for example a key stored in external hardware. Without this flag - * bn_mod_exp gets called when private key components are absent. - */ -# define RSA_FLAG_EXT_PKEY 0x0020 - -/* - * new with 0.9.6j and 0.9.7b; the built-in - * RSA implementation now uses blinding by - * default (ignoring RSA_FLAG_BLINDING), - * but other engines might not need it - */ -# define RSA_FLAG_NO_BLINDING 0x0080 -# if OPENSSL_API_COMPAT < 0x10100000L -/* - * Does nothing. Previously this switched off constant time behaviour. - */ -# define RSA_FLAG_NO_CONSTTIME 0x0000 -# endif -# if OPENSSL_API_COMPAT < 0x00908000L -/* deprecated name for the flag*/ -/* - * new with 0.9.7h; the built-in RSA - * implementation now uses constant time - * modular exponentiation for secret exponents - * by default. This flag causes the - * faster variable sliding window method to - * be used for all exponents. - */ -# define RSA_FLAG_NO_EXP_CONSTTIME RSA_FLAG_NO_CONSTTIME -# endif - -# define EVP_PKEY_CTX_set_rsa_padding(ctx, pad) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, EVP_PKEY_CTRL_RSA_PADDING, \ - pad, NULL) - -# define EVP_PKEY_CTX_get_rsa_padding(ctx, ppad) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, -1, \ - EVP_PKEY_CTRL_GET_RSA_PADDING, 0, ppad) - -# define EVP_PKEY_CTX_set_rsa_pss_saltlen(ctx, len) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \ - (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \ - EVP_PKEY_CTRL_RSA_PSS_SALTLEN, \ - len, NULL) - -# define EVP_PKEY_CTX_get_rsa_pss_saltlen(ctx, plen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \ - (EVP_PKEY_OP_SIGN|EVP_PKEY_OP_VERIFY), \ - EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN, \ - 0, plen) - -# define EVP_PKEY_CTX_set_rsa_keygen_bits(ctx, bits) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_RSA_KEYGEN_BITS, bits, NULL) - -# define EVP_PKEY_CTX_set_rsa_keygen_pubexp(ctx, pubexp) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_KEYGEN, \ - EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP, 0, pubexp) - -# define EVP_PKEY_CTX_set_rsa_mgf1_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \ - EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_RSA_MGF1_MD, 0, (void *)md) - -# define EVP_PKEY_CTX_set_rsa_oaep_md(ctx, md) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_RSA_OAEP_MD, 0, (void *)md) - -# define EVP_PKEY_CTX_get_rsa_mgf1_md(ctx, pmd) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, \ - EVP_PKEY_OP_TYPE_SIG | EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_GET_RSA_MGF1_MD, 0, (void *)pmd) - -# define EVP_PKEY_CTX_get_rsa_oaep_md(ctx, pmd) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_GET_RSA_OAEP_MD, 0, (void *)pmd) - -# define EVP_PKEY_CTX_set0_rsa_oaep_label(ctx, l, llen) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_RSA_OAEP_LABEL, llen, (void *)l) - -# define EVP_PKEY_CTX_get0_rsa_oaep_label(ctx, l) \ - EVP_PKEY_CTX_ctrl(ctx, EVP_PKEY_RSA, EVP_PKEY_OP_TYPE_CRYPT, \ - EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL, 0, (void *)l) - -# define EVP_PKEY_CTRL_RSA_PADDING (EVP_PKEY_ALG_CTRL + 1) -# define EVP_PKEY_CTRL_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 2) - -# define EVP_PKEY_CTRL_RSA_KEYGEN_BITS (EVP_PKEY_ALG_CTRL + 3) -# define EVP_PKEY_CTRL_RSA_KEYGEN_PUBEXP (EVP_PKEY_ALG_CTRL + 4) -# define EVP_PKEY_CTRL_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 5) - -# define EVP_PKEY_CTRL_GET_RSA_PADDING (EVP_PKEY_ALG_CTRL + 6) -# define EVP_PKEY_CTRL_GET_RSA_PSS_SALTLEN (EVP_PKEY_ALG_CTRL + 7) -# define EVP_PKEY_CTRL_GET_RSA_MGF1_MD (EVP_PKEY_ALG_CTRL + 8) - -# define EVP_PKEY_CTRL_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 9) -# define EVP_PKEY_CTRL_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 10) - -# define EVP_PKEY_CTRL_GET_RSA_OAEP_MD (EVP_PKEY_ALG_CTRL + 11) -# define EVP_PKEY_CTRL_GET_RSA_OAEP_LABEL (EVP_PKEY_ALG_CTRL + 12) - -# define RSA_PKCS1_PADDING 1 -# define RSA_SSLV23_PADDING 2 -# define RSA_NO_PADDING 3 -# define RSA_PKCS1_OAEP_PADDING 4 -# define RSA_X931_PADDING 5 -/* EVP_PKEY_ only */ -# define RSA_PKCS1_PSS_PADDING 6 - -# define RSA_PKCS1_PADDING_SIZE 11 - -# define RSA_set_app_data(s,arg) RSA_set_ex_data(s,0,arg) -# define RSA_get_app_data(s) RSA_get_ex_data(s,0) - -RSA *RSA_new(void); -RSA *RSA_new_method(ENGINE *engine); -int RSA_bits(const RSA *rsa); -int RSA_size(const RSA *rsa); -int RSA_security_bits(const RSA *rsa); - -int RSA_set0_key(RSA *r, BIGNUM *n, BIGNUM *e, BIGNUM *d); -int RSA_set0_factors(RSA *r, BIGNUM *p, BIGNUM *q); -int RSA_set0_crt_params(RSA *r,BIGNUM *dmp1, BIGNUM *dmq1, BIGNUM *iqmp); -void RSA_get0_key(const RSA *r, - const BIGNUM **n, const BIGNUM **e, const BIGNUM **d); -void RSA_get0_factors(const RSA *r, const BIGNUM **p, const BIGNUM **q); -void RSA_get0_crt_params(const RSA *r, - const BIGNUM **dmp1, const BIGNUM **dmq1, - const BIGNUM **iqmp); -void RSA_clear_flags(RSA *r, int flags); -int RSA_test_flags(const RSA *r, int flags); -void RSA_set_flags(RSA *r, int flags); -ENGINE *RSA_get0_engine(const RSA *r); - -/* Deprecated version */ -DEPRECATEDIN_0_9_8(RSA *RSA_generate_key(int bits, unsigned long e, void - (*callback) (int, int, void *), - void *cb_arg)) - -/* New version */ -int RSA_generate_key_ex(RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); - -int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1, - BIGNUM *q2, const BIGNUM *Xp1, const BIGNUM *Xp2, - const BIGNUM *Xp, const BIGNUM *Xq1, const BIGNUM *Xq2, - const BIGNUM *Xq, const BIGNUM *e, BN_GENCB *cb); -int RSA_X931_generate_key_ex(RSA *rsa, int bits, const BIGNUM *e, - BN_GENCB *cb); - -int RSA_check_key(const RSA *); -int RSA_check_key_ex(const RSA *, BN_GENCB *cb); - /* next 4 return -1 on error */ -int RSA_public_encrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_private_encrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_public_decrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_private_decrypt(int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -void RSA_free(RSA *r); -/* "up" the RSA object's reference count */ -int RSA_up_ref(RSA *r); - -int RSA_flags(const RSA *r); - -void RSA_set_default_method(const RSA_METHOD *meth); -const RSA_METHOD *RSA_get_default_method(void); -const RSA_METHOD *RSA_get_method(const RSA *rsa); -int RSA_set_method(RSA *rsa, const RSA_METHOD *meth); - -/* these are the actual RSA functions */ -const RSA_METHOD *RSA_PKCS1_OpenSSL(void); - -const RSA_METHOD *RSA_null_method(void); - -DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPublicKey) -DECLARE_ASN1_ENCODE_FUNCTIONS_const(RSA, RSAPrivateKey) - -typedef struct rsa_pss_params_st { - X509_ALGOR *hashAlgorithm; - X509_ALGOR *maskGenAlgorithm; - ASN1_INTEGER *saltLength; - ASN1_INTEGER *trailerField; -} RSA_PSS_PARAMS; - -DECLARE_ASN1_FUNCTIONS(RSA_PSS_PARAMS) - -typedef struct rsa_oaep_params_st { - X509_ALGOR *hashFunc; - X509_ALGOR *maskGenFunc; - X509_ALGOR *pSourceFunc; -} RSA_OAEP_PARAMS; - -DECLARE_ASN1_FUNCTIONS(RSA_OAEP_PARAMS) - -# ifndef OPENSSL_NO_STDIO -int RSA_print_fp(FILE *fp, const RSA *r, int offset); -# endif - -int RSA_print(BIO *bp, const RSA *r, int offset); - -/* - * The following 2 functions sign and verify a X509_SIG ASN1 object inside - * PKCS#1 padded RSA encryption - */ -int RSA_sign(int type, const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, RSA *rsa); -int RSA_verify(int type, const unsigned char *m, unsigned int m_length, - const unsigned char *sigbuf, unsigned int siglen, RSA *rsa); - -/* - * The following 2 function sign and verify a ASN1_OCTET_STRING object inside - * PKCS#1 padded RSA encryption - */ -int RSA_sign_ASN1_OCTET_STRING(int type, - const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, - RSA *rsa); -int RSA_verify_ASN1_OCTET_STRING(int type, const unsigned char *m, - unsigned int m_length, unsigned char *sigbuf, - unsigned int siglen, RSA *rsa); - -int RSA_blinding_on(RSA *rsa, BN_CTX *ctx); -void RSA_blinding_off(RSA *rsa); -BN_BLINDING *RSA_setup_blinding(RSA *rsa, BN_CTX *ctx); - -int RSA_padding_add_PKCS1_type_1(unsigned char *to, int tlen, - const unsigned char *f, int fl); -int RSA_padding_check_PKCS1_type_1(unsigned char *to, int tlen, - const unsigned char *f, int fl, - int rsa_len); -int RSA_padding_add_PKCS1_type_2(unsigned char *to, int tlen, - const unsigned char *f, int fl); -int RSA_padding_check_PKCS1_type_2(unsigned char *to, int tlen, - const unsigned char *f, int fl, - int rsa_len); -int PKCS1_MGF1(unsigned char *mask, long len, const unsigned char *seed, - long seedlen, const EVP_MD *dgst); -int RSA_padding_add_PKCS1_OAEP(unsigned char *to, int tlen, - const unsigned char *f, int fl, - const unsigned char *p, int pl); -int RSA_padding_check_PKCS1_OAEP(unsigned char *to, int tlen, - const unsigned char *f, int fl, int rsa_len, - const unsigned char *p, int pl); -int RSA_padding_add_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, - const unsigned char *from, int flen, - const unsigned char *param, int plen, - const EVP_MD *md, const EVP_MD *mgf1md); -int RSA_padding_check_PKCS1_OAEP_mgf1(unsigned char *to, int tlen, - const unsigned char *from, int flen, - int num, const unsigned char *param, - int plen, const EVP_MD *md, - const EVP_MD *mgf1md); -int RSA_padding_add_SSLv23(unsigned char *to, int tlen, - const unsigned char *f, int fl); -int RSA_padding_check_SSLv23(unsigned char *to, int tlen, - const unsigned char *f, int fl, int rsa_len); -int RSA_padding_add_none(unsigned char *to, int tlen, const unsigned char *f, - int fl); -int RSA_padding_check_none(unsigned char *to, int tlen, - const unsigned char *f, int fl, int rsa_len); -int RSA_padding_add_X931(unsigned char *to, int tlen, const unsigned char *f, - int fl); -int RSA_padding_check_X931(unsigned char *to, int tlen, - const unsigned char *f, int fl, int rsa_len); -int RSA_X931_hash_id(int nid); - -int RSA_verify_PKCS1_PSS(RSA *rsa, const unsigned char *mHash, - const EVP_MD *Hash, const unsigned char *EM, - int sLen); -int RSA_padding_add_PKCS1_PSS(RSA *rsa, unsigned char *EM, - const unsigned char *mHash, const EVP_MD *Hash, - int sLen); - -int RSA_verify_PKCS1_PSS_mgf1(RSA *rsa, const unsigned char *mHash, - const EVP_MD *Hash, const EVP_MD *mgf1Hash, - const unsigned char *EM, int sLen); - -int RSA_padding_add_PKCS1_PSS_mgf1(RSA *rsa, unsigned char *EM, - const unsigned char *mHash, - const EVP_MD *Hash, const EVP_MD *mgf1Hash, - int sLen); - -#define RSA_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_RSA, l, p, newf, dupf, freef) -int RSA_set_ex_data(RSA *r, int idx, void *arg); -void *RSA_get_ex_data(const RSA *r, int idx); - -RSA *RSAPublicKey_dup(RSA *rsa); -RSA *RSAPrivateKey_dup(RSA *rsa); - -/* - * If this flag is set the RSA method is FIPS compliant and can be used in - * FIPS mode. This is set in the validated module method. If an application - * sets this flag in its own methods it is its responsibility to ensure the - * result is compliant. - */ - -# define RSA_FLAG_FIPS_METHOD 0x0400 - -/* - * If this flag is set the operations normally disabled in FIPS mode are - * permitted it is then the applications responsibility to ensure that the - * usage is compliant. - */ - -# define RSA_FLAG_NON_FIPS_ALLOW 0x0400 -/* - * Application has decided PRNG is good enough to generate a key: don't - * check. - */ -# define RSA_FLAG_CHECKED 0x0800 - -RSA_METHOD *RSA_meth_new(const char *name, int flags); -void RSA_meth_free(RSA_METHOD *meth); -RSA_METHOD *RSA_meth_dup(const RSA_METHOD *meth); -const char *RSA_meth_get0_name(const RSA_METHOD *meth); -int RSA_meth_set1_name(RSA_METHOD *meth, const char *name); -int RSA_meth_get_flags(RSA_METHOD *meth); -int RSA_meth_set_flags(RSA_METHOD *meth, int flags); -void *RSA_meth_get0_app_data(const RSA_METHOD *meth); -int RSA_meth_set0_app_data(RSA_METHOD *meth, void *app_data); -int (*RSA_meth_get_pub_enc(const RSA_METHOD *meth)) - (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_meth_set_pub_enc(RSA_METHOD *rsa, - int (*pub_enc) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)); -int (*RSA_meth_get_pub_dec(const RSA_METHOD *meth)) - (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_meth_set_pub_dec(RSA_METHOD *rsa, - int (*pub_dec) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)); -int (*RSA_meth_get_priv_enc(const RSA_METHOD *meth)) - (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_meth_set_priv_enc(RSA_METHOD *rsa, - int (*priv_enc) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)); -int (*RSA_meth_get_priv_dec(const RSA_METHOD *meth)) - (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, int padding); -int RSA_meth_set_priv_dec(RSA_METHOD *rsa, - int (*priv_dec) (int flen, const unsigned char *from, - unsigned char *to, RSA *rsa, - int padding)); -int (*RSA_meth_get_mod_exp(const RSA_METHOD *meth)) - (BIGNUM *r0, const BIGNUM *I, RSA *rsa, BN_CTX *ctx); -int RSA_meth_set_mod_exp(RSA_METHOD *rsa, - int (*mod_exp) (BIGNUM *r0, const BIGNUM *I, RSA *rsa, - BN_CTX *ctx)); -int (*RSA_meth_get_bn_mod_exp(const RSA_METHOD *meth)) - (BIGNUM *r, const BIGNUM *a, const BIGNUM *p, - const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); -int RSA_meth_set_bn_mod_exp(RSA_METHOD *rsa, - int (*bn_mod_exp) (BIGNUM *r, - const BIGNUM *a, - const BIGNUM *p, - const BIGNUM *m, - BN_CTX *ctx, - BN_MONT_CTX *m_ctx)); -int (*RSA_meth_get_init(const RSA_METHOD *meth)) (RSA *rsa); -int RSA_meth_set_init(RSA_METHOD *rsa, int (*init) (RSA *rsa)); -int (*RSA_meth_get_finish(const RSA_METHOD *meth)) (RSA *rsa); -int RSA_meth_set_finish(RSA_METHOD *rsa, int (*finish) (RSA *rsa)); -int (*RSA_meth_get_sign(const RSA_METHOD *meth)) - (int type, - const unsigned char *m, unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, - const RSA *rsa); -int RSA_meth_set_sign(RSA_METHOD *rsa, - int (*sign) (int type, const unsigned char *m, - unsigned int m_length, - unsigned char *sigret, unsigned int *siglen, - const RSA *rsa)); -int (*RSA_meth_get_verify(const RSA_METHOD *meth)) - (int dtype, const unsigned char *m, - unsigned int m_length, const unsigned char *sigbuf, - unsigned int siglen, const RSA *rsa); -int RSA_meth_set_verify(RSA_METHOD *rsa, - int (*verify) (int dtype, const unsigned char *m, - unsigned int m_length, - const unsigned char *sigbuf, - unsigned int siglen, const RSA *rsa)); -int (*RSA_meth_get_keygen(const RSA_METHOD *meth)) - (RSA *rsa, int bits, BIGNUM *e, BN_GENCB *cb); -int RSA_meth_set_keygen(RSA_METHOD *rsa, - int (*keygen) (RSA *rsa, int bits, BIGNUM *e, - BN_GENCB *cb)); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_RSA_strings(void); - -/* Error codes for the RSA functions. */ - -/* Function codes. */ -# define RSA_F_CHECK_PADDING_MD 140 -# define RSA_F_ENCODE_PKCS1 146 -# define RSA_F_INT_RSA_VERIFY 145 -# define RSA_F_OLD_RSA_PRIV_DECODE 147 -# define RSA_F_PKEY_RSA_CTRL 143 -# define RSA_F_PKEY_RSA_CTRL_STR 144 -# define RSA_F_PKEY_RSA_SIGN 142 -# define RSA_F_PKEY_RSA_VERIFYRECOVER 141 -# define RSA_F_RSA_ALGOR_TO_MD 156 -# define RSA_F_RSA_BUILTIN_KEYGEN 129 -# define RSA_F_RSA_CHECK_KEY 123 -# define RSA_F_RSA_CHECK_KEY_EX 160 -# define RSA_F_RSA_CMS_DECRYPT 159 -# define RSA_F_RSA_ITEM_VERIFY 148 -# define RSA_F_RSA_METH_DUP 161 -# define RSA_F_RSA_METH_NEW 162 -# define RSA_F_RSA_METH_SET1_NAME 163 -# define RSA_F_RSA_MGF1_TO_MD 157 -# define RSA_F_RSA_NEW_METHOD 106 -# define RSA_F_RSA_NULL 124 -# define RSA_F_RSA_NULL_PRIVATE_DECRYPT 132 -# define RSA_F_RSA_NULL_PRIVATE_ENCRYPT 133 -# define RSA_F_RSA_NULL_PUBLIC_DECRYPT 134 -# define RSA_F_RSA_NULL_PUBLIC_ENCRYPT 135 -# define RSA_F_RSA_OSSL_PRIVATE_DECRYPT 101 -# define RSA_F_RSA_OSSL_PRIVATE_ENCRYPT 102 -# define RSA_F_RSA_OSSL_PUBLIC_DECRYPT 103 -# define RSA_F_RSA_OSSL_PUBLIC_ENCRYPT 104 -# define RSA_F_RSA_PADDING_ADD_NONE 107 -# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP 121 -# define RSA_F_RSA_PADDING_ADD_PKCS1_OAEP_MGF1 154 -# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS 125 -# define RSA_F_RSA_PADDING_ADD_PKCS1_PSS_MGF1 152 -# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_1 108 -# define RSA_F_RSA_PADDING_ADD_PKCS1_TYPE_2 109 -# define RSA_F_RSA_PADDING_ADD_SSLV23 110 -# define RSA_F_RSA_PADDING_ADD_X931 127 -# define RSA_F_RSA_PADDING_CHECK_NONE 111 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP 122 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_OAEP_MGF1 153 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_1 112 -# define RSA_F_RSA_PADDING_CHECK_PKCS1_TYPE_2 113 -# define RSA_F_RSA_PADDING_CHECK_SSLV23 114 -# define RSA_F_RSA_PADDING_CHECK_X931 128 -# define RSA_F_RSA_PRINT 115 -# define RSA_F_RSA_PRINT_FP 116 -# define RSA_F_RSA_PRIV_ENCODE 138 -# define RSA_F_RSA_PSS_TO_CTX 155 -# define RSA_F_RSA_PUB_DECODE 139 -# define RSA_F_RSA_SETUP_BLINDING 136 -# define RSA_F_RSA_SIGN 117 -# define RSA_F_RSA_SIGN_ASN1_OCTET_STRING 118 -# define RSA_F_RSA_VERIFY 119 -# define RSA_F_RSA_VERIFY_ASN1_OCTET_STRING 120 -# define RSA_F_RSA_VERIFY_PKCS1_PSS_MGF1 126 - -/* Reason codes. */ -# define RSA_R_ALGORITHM_MISMATCH 100 -# define RSA_R_BAD_E_VALUE 101 -# define RSA_R_BAD_FIXED_HEADER_DECRYPT 102 -# define RSA_R_BAD_PAD_BYTE_COUNT 103 -# define RSA_R_BAD_SIGNATURE 104 -# define RSA_R_BLOCK_TYPE_IS_NOT_01 106 -# define RSA_R_BLOCK_TYPE_IS_NOT_02 107 -# define RSA_R_DATA_GREATER_THAN_MOD_LEN 108 -# define RSA_R_DATA_TOO_LARGE 109 -# define RSA_R_DATA_TOO_LARGE_FOR_KEY_SIZE 110 -# define RSA_R_DATA_TOO_LARGE_FOR_MODULUS 132 -# define RSA_R_DATA_TOO_SMALL 111 -# define RSA_R_DATA_TOO_SMALL_FOR_KEY_SIZE 122 -# define RSA_R_DIGEST_DOES_NOT_MATCH 158 -# define RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY 112 -# define RSA_R_DMP1_NOT_CONGRUENT_TO_D 124 -# define RSA_R_DMQ1_NOT_CONGRUENT_TO_D 125 -# define RSA_R_D_E_NOT_CONGRUENT_TO_1 123 -# define RSA_R_FIRST_OCTET_INVALID 133 -# define RSA_R_ILLEGAL_OR_UNSUPPORTED_PADDING_MODE 144 -# define RSA_R_INVALID_DIGEST 157 -# define RSA_R_INVALID_DIGEST_LENGTH 143 -# define RSA_R_INVALID_HEADER 137 -# define RSA_R_INVALID_LABEL 160 -# define RSA_R_INVALID_MESSAGE_LENGTH 131 -# define RSA_R_INVALID_MGF1_MD 156 -# define RSA_R_INVALID_OAEP_PARAMETERS 161 -# define RSA_R_INVALID_PADDING 138 -# define RSA_R_INVALID_PADDING_MODE 141 -# define RSA_R_INVALID_PSS_PARAMETERS 149 -# define RSA_R_INVALID_PSS_SALTLEN 146 -# define RSA_R_INVALID_SALT_LENGTH 150 -# define RSA_R_INVALID_TRAILER 139 -# define RSA_R_INVALID_X931_DIGEST 142 -# define RSA_R_IQMP_NOT_INVERSE_OF_Q 126 -# define RSA_R_KEY_SIZE_TOO_SMALL 120 -# define RSA_R_LAST_OCTET_INVALID 134 -# define RSA_R_MODULUS_TOO_LARGE 105 -# define RSA_R_NO_PUBLIC_EXPONENT 140 -# define RSA_R_NULL_BEFORE_BLOCK_MISSING 113 -# define RSA_R_N_DOES_NOT_EQUAL_P_Q 127 -# define RSA_R_OAEP_DECODING_ERROR 121 -# define RSA_R_OPERATION_NOT_SUPPORTED_FOR_THIS_KEYTYPE 148 -# define RSA_R_PADDING_CHECK_FAILED 114 -# define RSA_R_PKCS_DECODING_ERROR 159 -# define RSA_R_P_NOT_PRIME 128 -# define RSA_R_Q_NOT_PRIME 129 -# define RSA_R_RSA_OPERATIONS_NOT_SUPPORTED 130 -# define RSA_R_SLEN_CHECK_FAILED 136 -# define RSA_R_SLEN_RECOVERY_FAILED 135 -# define RSA_R_SSLV3_ROLLBACK_ATTACK 115 -# define RSA_R_THE_ASN1_OBJECT_IDENTIFIER_IS_NOT_KNOWN_FOR_THIS_MD 116 -# define RSA_R_UNKNOWN_ALGORITHM_TYPE 117 -# define RSA_R_UNKNOWN_DIGEST 166 -# define RSA_R_UNKNOWN_MASK_DIGEST 151 -# define RSA_R_UNKNOWN_PADDING_TYPE 118 -# define RSA_R_UNSUPPORTED_ENCRYPTION_TYPE 162 -# define RSA_R_UNSUPPORTED_LABEL_SOURCE 163 -# define RSA_R_UNSUPPORTED_MASK_ALGORITHM 153 -# define RSA_R_UNSUPPORTED_MASK_PARAMETER 154 -# define RSA_R_UNSUPPORTED_SIGNATURE_TYPE 155 -# define RSA_R_VALUE_MISSING 147 -# define RSA_R_WRONG_SIGNATURE_LENGTH 119 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/safestack.h b/android/armeabi/include/openssl/safestack.h deleted file mode 100644 index 9fe733c2..00000000 --- a/android/armeabi/include/openssl/safestack.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SAFESTACK_H -# define HEADER_SAFESTACK_H - -# include <openssl/stack.h> -# include <openssl/e_os2.h> - -#ifdef __cplusplus -extern "C" { -#endif - -# define STACK_OF(type) struct stack_st_##type - -# define SKM_DEFINE_STACK_OF(t1, t2, t3) \ - STACK_OF(t1); \ - typedef int (*sk_##t1##_compfunc)(const t3 * const *a, const t3 *const *b); \ - typedef void (*sk_##t1##_freefunc)(t3 *a); \ - typedef t3 * (*sk_##t1##_copyfunc)(const t3 *a); \ - static ossl_inline int sk_##t1##_num(const STACK_OF(t1) *sk) \ - { \ - return OPENSSL_sk_num((const OPENSSL_STACK *)sk); \ - } \ - static ossl_inline t2 *sk_##t1##_value(const STACK_OF(t1) *sk, int idx) \ - { \ - return (t2 *)OPENSSL_sk_value((const OPENSSL_STACK *)sk, idx); \ - } \ - static ossl_inline STACK_OF(t1) *sk_##t1##_new(sk_##t1##_compfunc compare) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_new((OPENSSL_sk_compfunc)compare); \ - } \ - static ossl_inline STACK_OF(t1) *sk_##t1##_new_null(void) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_new_null(); \ - } \ - static ossl_inline void sk_##t1##_free(STACK_OF(t1) *sk) \ - { \ - OPENSSL_sk_free((OPENSSL_STACK *)sk); \ - } \ - static ossl_inline void sk_##t1##_zero(STACK_OF(t1) *sk) \ - { \ - OPENSSL_sk_zero((OPENSSL_STACK *)sk); \ - } \ - static ossl_inline t2 *sk_##t1##_delete(STACK_OF(t1) *sk, int i) \ - { \ - return (t2 *)OPENSSL_sk_delete((OPENSSL_STACK *)sk, i); \ - } \ - static ossl_inline t2 *sk_##t1##_delete_ptr(STACK_OF(t1) *sk, t2 *ptr) \ - { \ - return (t2 *)OPENSSL_sk_delete_ptr((OPENSSL_STACK *)sk, \ - (const void *)ptr); \ - } \ - static ossl_inline int sk_##t1##_push(STACK_OF(t1) *sk, t2 *ptr) \ - { \ - return OPENSSL_sk_push((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_inline int sk_##t1##_unshift(STACK_OF(t1) *sk, t2 *ptr) \ - { \ - return OPENSSL_sk_unshift((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_inline t2 *sk_##t1##_pop(STACK_OF(t1) *sk) \ - { \ - return (t2 *)OPENSSL_sk_pop((OPENSSL_STACK *)sk); \ - } \ - static ossl_inline t2 *sk_##t1##_shift(STACK_OF(t1) *sk) \ - { \ - return (t2 *)OPENSSL_sk_shift((OPENSSL_STACK *)sk); \ - } \ - static ossl_inline void sk_##t1##_pop_free(STACK_OF(t1) *sk, sk_##t1##_freefunc freefunc) \ - { \ - OPENSSL_sk_pop_free((OPENSSL_STACK *)sk, (OPENSSL_sk_freefunc)freefunc); \ - } \ - static ossl_inline int sk_##t1##_insert(STACK_OF(t1) *sk, t2 *ptr, int idx) \ - { \ - return OPENSSL_sk_insert((OPENSSL_STACK *)sk, (const void *)ptr, idx); \ - } \ - static ossl_inline t2 *sk_##t1##_set(STACK_OF(t1) *sk, int idx, t2 *ptr) \ - { \ - return (t2 *)OPENSSL_sk_set((OPENSSL_STACK *)sk, idx, (const void *)ptr); \ - } \ - static ossl_inline int sk_##t1##_find(STACK_OF(t1) *sk, t2 *ptr) \ - { \ - return OPENSSL_sk_find((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_inline int sk_##t1##_find_ex(STACK_OF(t1) *sk, t2 *ptr) \ - { \ - return OPENSSL_sk_find_ex((OPENSSL_STACK *)sk, (const void *)ptr); \ - } \ - static ossl_inline void sk_##t1##_sort(STACK_OF(t1) *sk) \ - { \ - OPENSSL_sk_sort((OPENSSL_STACK *)sk); \ - } \ - static ossl_inline int sk_##t1##_is_sorted(const STACK_OF(t1) *sk) \ - { \ - return OPENSSL_sk_is_sorted((const OPENSSL_STACK *)sk); \ - } \ - static ossl_inline STACK_OF(t1) * sk_##t1##_dup(const STACK_OF(t1) *sk) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_dup((const OPENSSL_STACK *)sk); \ - } \ - static ossl_inline STACK_OF(t1) *sk_##t1##_deep_copy(const STACK_OF(t1) *sk, \ - sk_##t1##_copyfunc copyfunc, \ - sk_##t1##_freefunc freefunc) \ - { \ - return (STACK_OF(t1) *)OPENSSL_sk_deep_copy((const OPENSSL_STACK *)sk, \ - (OPENSSL_sk_copyfunc)copyfunc, \ - (OPENSSL_sk_freefunc)freefunc); \ - } \ - static ossl_inline sk_##t1##_compfunc sk_##t1##_set_cmp_func(STACK_OF(t1) *sk, sk_##t1##_compfunc compare) \ - { \ - return (sk_##t1##_compfunc)OPENSSL_sk_set_cmp_func((OPENSSL_STACK *)sk, (OPENSSL_sk_compfunc)compare); \ - } - -# define DEFINE_SPECIAL_STACK_OF(t1, t2) SKM_DEFINE_STACK_OF(t1, t2, t2) -# define DEFINE_STACK_OF(t) SKM_DEFINE_STACK_OF(t, t, t) -# define DEFINE_SPECIAL_STACK_OF_CONST(t1, t2) \ - SKM_DEFINE_STACK_OF(t1, const t2, t2) -# define DEFINE_STACK_OF_CONST(t) SKM_DEFINE_STACK_OF(t, const t, t) - -/*- - * Strings are special: normally an lhash entry will point to a single - * (somewhat) mutable object. In the case of strings: - * - * a) Instead of a single char, there is an array of chars, NUL-terminated. - * b) The string may have be immutable. - * - * So, they need their own declarations. Especially important for - * type-checking tools, such as Deputy. - * - * In practice, however, it appears to be hard to have a const - * string. For now, I'm settling for dealing with the fact it is a - * string at all. - */ -typedef char *OPENSSL_STRING; -typedef const char *OPENSSL_CSTRING; - -/*- - * Confusingly, LHASH_OF(STRING) deals with char ** throughout, but - * STACK_OF(STRING) is really more like STACK_OF(char), only, as mentioned - * above, instead of a single char each entry is a NUL-terminated array of - * chars. So, we have to implement STRING specially for STACK_OF. This is - * dealt with in the autogenerated macros below. - */ -DEFINE_SPECIAL_STACK_OF(OPENSSL_STRING, char) -DEFINE_SPECIAL_STACK_OF_CONST(OPENSSL_CSTRING, char) - -/* - * Similarly, we sometimes use a block of characters, NOT nul-terminated. - * These should also be distinguished from "normal" stacks. - */ -typedef void *OPENSSL_BLOCK; -DEFINE_SPECIAL_STACK_OF(OPENSSL_BLOCK, void) - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/seed.h b/android/armeabi/include/openssl/seed.h deleted file mode 100644 index bb97131d..00000000 --- a/android/armeabi/include/openssl/seed.h +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2007-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * Copyright (c) 2007 KISA(Korea Information Security Agency). All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Neither the name of author nor the names of its contributors may - * be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * 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 HEADER_SEED_H -# define HEADER_SEED_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_SEED -# include <openssl/e_os2.h> -# include <openssl/crypto.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* look whether we need 'long' to get 32 bits */ -# ifdef AES_LONG -# ifndef SEED_LONG -# define SEED_LONG 1 -# endif -# endif - -# if !defined(NO_SYS_TYPES_H) -# include <sys/types.h> -# endif - -# define SEED_BLOCK_SIZE 16 -# define SEED_KEY_LENGTH 16 - -typedef struct seed_key_st { -# ifdef SEED_LONG - unsigned long data[32]; -# else - unsigned int data[32]; -# endif -} SEED_KEY_SCHEDULE; - -void SEED_set_key(const unsigned char rawkey[SEED_KEY_LENGTH], - SEED_KEY_SCHEDULE *ks); - -void SEED_encrypt(const unsigned char s[SEED_BLOCK_SIZE], - unsigned char d[SEED_BLOCK_SIZE], - const SEED_KEY_SCHEDULE *ks); -void SEED_decrypt(const unsigned char s[SEED_BLOCK_SIZE], - unsigned char d[SEED_BLOCK_SIZE], - const SEED_KEY_SCHEDULE *ks); - -void SEED_ecb_encrypt(const unsigned char *in, unsigned char *out, - const SEED_KEY_SCHEDULE *ks, int enc); -void SEED_cbc_encrypt(const unsigned char *in, unsigned char *out, size_t len, - const SEED_KEY_SCHEDULE *ks, - unsigned char ivec[SEED_BLOCK_SIZE], int enc); -void SEED_cfb128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const SEED_KEY_SCHEDULE *ks, - unsigned char ivec[SEED_BLOCK_SIZE], int *num, - int enc); -void SEED_ofb128_encrypt(const unsigned char *in, unsigned char *out, - size_t len, const SEED_KEY_SCHEDULE *ks, - unsigned char ivec[SEED_BLOCK_SIZE], int *num); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/sha.h b/android/armeabi/include/openssl/sha.h deleted file mode 100644 index 6a1eb0de..00000000 --- a/android/armeabi/include/openssl/sha.h +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SHA_H -# define HEADER_SHA_H - -# include <openssl/e_os2.h> -# include <stddef.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*- - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * ! SHA_LONG has to be at least 32 bits wide. ! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - */ -# define SHA_LONG unsigned int - -# define SHA_LBLOCK 16 -# define SHA_CBLOCK (SHA_LBLOCK*4)/* SHA treats input data as a - * contiguous array of 32 bit wide - * big-endian values. */ -# define SHA_LAST_BLOCK (SHA_CBLOCK-8) -# define SHA_DIGEST_LENGTH 20 - -typedef struct SHAstate_st { - SHA_LONG h0, h1, h2, h3, h4; - SHA_LONG Nl, Nh; - SHA_LONG data[SHA_LBLOCK]; - unsigned int num; -} SHA_CTX; - -int SHA1_Init(SHA_CTX *c); -int SHA1_Update(SHA_CTX *c, const void *data, size_t len); -int SHA1_Final(unsigned char *md, SHA_CTX *c); -unsigned char *SHA1(const unsigned char *d, size_t n, unsigned char *md); -void SHA1_Transform(SHA_CTX *c, const unsigned char *data); - -# define SHA256_CBLOCK (SHA_LBLOCK*4)/* SHA-256 treats input data as a - * contiguous array of 32 bit wide - * big-endian values. */ - -typedef struct SHA256state_st { - SHA_LONG h[8]; - SHA_LONG Nl, Nh; - SHA_LONG data[SHA_LBLOCK]; - unsigned int num, md_len; -} SHA256_CTX; - -int SHA224_Init(SHA256_CTX *c); -int SHA224_Update(SHA256_CTX *c, const void *data, size_t len); -int SHA224_Final(unsigned char *md, SHA256_CTX *c); -unsigned char *SHA224(const unsigned char *d, size_t n, unsigned char *md); -int SHA256_Init(SHA256_CTX *c); -int SHA256_Update(SHA256_CTX *c, const void *data, size_t len); -int SHA256_Final(unsigned char *md, SHA256_CTX *c); -unsigned char *SHA256(const unsigned char *d, size_t n, unsigned char *md); -void SHA256_Transform(SHA256_CTX *c, const unsigned char *data); - -# define SHA224_DIGEST_LENGTH 28 -# define SHA256_DIGEST_LENGTH 32 -# define SHA384_DIGEST_LENGTH 48 -# define SHA512_DIGEST_LENGTH 64 - -/* - * Unlike 32-bit digest algorithms, SHA-512 *relies* on SHA_LONG64 - * being exactly 64-bit wide. See Implementation Notes in sha512.c - * for further details. - */ -/* - * SHA-512 treats input data as a - * contiguous array of 64 bit - * wide big-endian values. - */ -# define SHA512_CBLOCK (SHA_LBLOCK*8) -# if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__) -# define SHA_LONG64 unsigned __int64 -# define U64(C) C##UI64 -# elif defined(__arch64__) -# define SHA_LONG64 unsigned long -# define U64(C) C##UL -# else -# define SHA_LONG64 unsigned long long -# define U64(C) C##ULL -# endif - -typedef struct SHA512state_st { - SHA_LONG64 h[8]; - SHA_LONG64 Nl, Nh; - union { - SHA_LONG64 d[SHA_LBLOCK]; - unsigned char p[SHA512_CBLOCK]; - } u; - unsigned int num, md_len; -} SHA512_CTX; - -int SHA384_Init(SHA512_CTX *c); -int SHA384_Update(SHA512_CTX *c, const void *data, size_t len); -int SHA384_Final(unsigned char *md, SHA512_CTX *c); -unsigned char *SHA384(const unsigned char *d, size_t n, unsigned char *md); -int SHA512_Init(SHA512_CTX *c); -int SHA512_Update(SHA512_CTX *c, const void *data, size_t len); -int SHA512_Final(unsigned char *md, SHA512_CTX *c); -unsigned char *SHA512(const unsigned char *d, size_t n, unsigned char *md); -void SHA512_Transform(SHA512_CTX *c, const unsigned char *data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android/armeabi/include/openssl/srp.h b/android/armeabi/include/openssl/srp.h deleted file mode 100644 index f2b6ec75..00000000 --- a/android/armeabi/include/openssl/srp.h +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SRP_H -# define HEADER_SRP_H - -#include <openssl/opensslconf.h> - -#ifndef OPENSSL_NO_SRP -# include <stdio.h> -# include <string.h> -# include <openssl/safestack.h> -# include <openssl/bn.h> -# include <openssl/crypto.h> - -# ifdef __cplusplus -extern "C" { -# endif - -typedef struct SRP_gN_cache_st { - char *b64_bn; - BIGNUM *bn; -} SRP_gN_cache; - - -DEFINE_STACK_OF(SRP_gN_cache) - -typedef struct SRP_user_pwd_st { - /* Owned by us. */ - char *id; - BIGNUM *s; - BIGNUM *v; - /* Not owned by us. */ - const BIGNUM *g; - const BIGNUM *N; - /* Owned by us. */ - char *info; -} SRP_user_pwd; - -void SRP_user_pwd_free(SRP_user_pwd *user_pwd); - -DEFINE_STACK_OF(SRP_user_pwd) - -typedef struct SRP_VBASE_st { - STACK_OF(SRP_user_pwd) *users_pwd; - STACK_OF(SRP_gN_cache) *gN_cache; -/* to simulate a user */ - char *seed_key; - const BIGNUM *default_g; - const BIGNUM *default_N; -} SRP_VBASE; - -/* - * Internal structure storing N and g pair - */ -typedef struct SRP_gN_st { - char *id; - const BIGNUM *g; - const BIGNUM *N; -} SRP_gN; - -DEFINE_STACK_OF(SRP_gN) - -SRP_VBASE *SRP_VBASE_new(char *seed_key); -void SRP_VBASE_free(SRP_VBASE *vb); -int SRP_VBASE_init(SRP_VBASE *vb, char *verifier_file); - -/* This method ignores the configured seed and fails for an unknown user. */ -DEPRECATEDIN_1_1_0(SRP_user_pwd *SRP_VBASE_get_by_user(SRP_VBASE *vb, char *username)) -/* NOTE: unlike in SRP_VBASE_get_by_user, caller owns the returned pointer.*/ -SRP_user_pwd *SRP_VBASE_get1_by_user(SRP_VBASE *vb, char *username); - -char *SRP_create_verifier(const char *user, const char *pass, char **salt, - char **verifier, const char *N, const char *g); -int SRP_create_verifier_BN(const char *user, const char *pass, BIGNUM **salt, - BIGNUM **verifier, const BIGNUM *N, - const BIGNUM *g); - -# define SRP_NO_ERROR 0 -# define SRP_ERR_VBASE_INCOMPLETE_FILE 1 -# define SRP_ERR_VBASE_BN_LIB 2 -# define SRP_ERR_OPEN_FILE 3 -# define SRP_ERR_MEMORY 4 - -# define DB_srptype 0 -# define DB_srpverifier 1 -# define DB_srpsalt 2 -# define DB_srpid 3 -# define DB_srpgN 4 -# define DB_srpinfo 5 -# undef DB_NUMBER -# define DB_NUMBER 6 - -# define DB_SRP_INDEX 'I' -# define DB_SRP_VALID 'V' -# define DB_SRP_REVOKED 'R' -# define DB_SRP_MODIF 'v' - -/* see srp.c */ -char *SRP_check_known_gN_param(const BIGNUM *g, const BIGNUM *N); -SRP_gN *SRP_get_default_gN(const char *id); - -/* server side .... */ -BIGNUM *SRP_Calc_server_key(const BIGNUM *A, const BIGNUM *v, const BIGNUM *u, - const BIGNUM *b, const BIGNUM *N); -BIGNUM *SRP_Calc_B(const BIGNUM *b, const BIGNUM *N, const BIGNUM *g, - const BIGNUM *v); -int SRP_Verify_A_mod_N(const BIGNUM *A, const BIGNUM *N); -BIGNUM *SRP_Calc_u(const BIGNUM *A, const BIGNUM *B, const BIGNUM *N); - -/* client side .... */ -BIGNUM *SRP_Calc_x(const BIGNUM *s, const char *user, const char *pass); -BIGNUM *SRP_Calc_A(const BIGNUM *a, const BIGNUM *N, const BIGNUM *g); -BIGNUM *SRP_Calc_client_key(const BIGNUM *N, const BIGNUM *B, const BIGNUM *g, - const BIGNUM *x, const BIGNUM *a, const BIGNUM *u); -int SRP_Verify_B_mod_N(const BIGNUM *B, const BIGNUM *N); - -# define SRP_MINIMAL_N 1024 - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/srtp.h b/android/armeabi/include/openssl/srtp.h deleted file mode 100644 index 5ddfa46d..00000000 --- a/android/armeabi/include/openssl/srtp.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright 2011-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* - * DTLS code by Eric Rescorla <ekr@rtfm.com> - * - * Copyright (C) 2006, Network Resonance, Inc. Copyright (C) 2011, RTFM, Inc. - */ - -#ifndef HEADER_D1_SRTP_H -# define HEADER_D1_SRTP_H - -# include <openssl/ssl.h> - -#ifdef __cplusplus -extern "C" { -#endif - -# define SRTP_AES128_CM_SHA1_80 0x0001 -# define SRTP_AES128_CM_SHA1_32 0x0002 -# define SRTP_AES128_F8_SHA1_80 0x0003 -# define SRTP_AES128_F8_SHA1_32 0x0004 -# define SRTP_NULL_SHA1_80 0x0005 -# define SRTP_NULL_SHA1_32 0x0006 - -/* AEAD SRTP protection profiles from RFC 7714 */ -# define SRTP_AEAD_AES_128_GCM 0x0007 -# define SRTP_AEAD_AES_256_GCM 0x0008 - -# ifndef OPENSSL_NO_SRTP - -__owur int SSL_CTX_set_tlsext_use_srtp(SSL_CTX *ctx, const char *profiles); -__owur int SSL_set_tlsext_use_srtp(SSL *ctx, const char *profiles); - -__owur STACK_OF(SRTP_PROTECTION_PROFILE) *SSL_get_srtp_profiles(SSL *ssl); -__owur SRTP_PROTECTION_PROFILE *SSL_get_selected_srtp_profile(SSL *s); - -# endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android/armeabi/include/openssl/ssl.h b/android/armeabi/include/openssl/ssl.h deleted file mode 100644 index 86ab9125..00000000 --- a/android/armeabi/include/openssl/ssl.h +++ /dev/null @@ -1,2529 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECC cipher suite support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ -/* ==================================================================== - * Copyright 2005 Nokia. All rights reserved. - * - * The portions of the attached software ("Contribution") is developed by - * Nokia Corporation and is licensed pursuant to the OpenSSL open source - * license. - * - * The Contribution, originally written by Mika Kousa and Pasi Eronen of - * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites - * support (see RFC 4279) to OpenSSL. - * - * No patent licenses or other rights except those expressly stated in - * the OpenSSL open source license shall be deemed granted or received - * expressly, by implication, estoppel, or otherwise. - * - * No assurances are provided by Nokia that the Contribution does not - * infringe the patent or other intellectual property rights of any third - * party or that the license provides you with all the necessary rights - * to make use of the Contribution. - * - * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN - * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA - * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY - * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR - * OTHERWISE. - */ - -#ifndef HEADER_SSL_H -# define HEADER_SSL_H - -# include <openssl/e_os2.h> -# include <openssl/opensslconf.h> -# include <openssl/comp.h> -# include <openssl/bio.h> -# if OPENSSL_API_COMPAT < 0x10100000L -# include <openssl/x509.h> -# include <openssl/crypto.h> -# include <openssl/lhash.h> -# include <openssl/buffer.h> -# endif -# include <openssl/pem.h> -# include <openssl/hmac.h> -# include <openssl/async.h> - -# include <openssl/safestack.h> -# include <openssl/symhacks.h> -# include <openssl/ct.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* OpenSSL version number for ASN.1 encoding of the session information */ -/*- - * Version 0 - initial version - * Version 1 - added the optional peer certificate - */ -# define SSL_SESSION_ASN1_VERSION 0x0001 - -# define SSL_MAX_SSL_SESSION_ID_LENGTH 32 -# define SSL_MAX_SID_CTX_LENGTH 32 - -# define SSL_MIN_RSA_MODULUS_LENGTH_IN_BYTES (512/8) -# define SSL_MAX_KEY_ARG_LENGTH 8 -# define SSL_MAX_MASTER_KEY_LENGTH 48 - -/* The maximum number of encrypt/decrypt pipelines we can support */ -# define SSL_MAX_PIPELINES 32 - -/* text strings for the ciphers */ - -/* These are used to specify which ciphers to use and not to use */ - -# define SSL_TXT_LOW "LOW" -# define SSL_TXT_MEDIUM "MEDIUM" -# define SSL_TXT_HIGH "HIGH" -# define SSL_TXT_FIPS "FIPS" - -# define SSL_TXT_aNULL "aNULL" -# define SSL_TXT_eNULL "eNULL" -# define SSL_TXT_NULL "NULL" - -# define SSL_TXT_kRSA "kRSA" -# define SSL_TXT_kDHr "kDHr" -# define SSL_TXT_kDHd "kDHd" -# define SSL_TXT_kDH "kDH" -# define SSL_TXT_kEDH "kEDH"/* alias for kDHE */ -# define SSL_TXT_kDHE "kDHE" -# define SSL_TXT_kECDHr "kECDHr" -# define SSL_TXT_kECDHe "kECDHe" -# define SSL_TXT_kECDH "kECDH" -# define SSL_TXT_kEECDH "kEECDH"/* alias for kECDHE */ -# define SSL_TXT_kECDHE "kECDHE" -# define SSL_TXT_kPSK "kPSK" -# define SSL_TXT_kRSAPSK "kRSAPSK" -# define SSL_TXT_kECDHEPSK "kECDHEPSK" -# define SSL_TXT_kDHEPSK "kDHEPSK" -# define SSL_TXT_kGOST "kGOST" -# define SSL_TXT_kSRP "kSRP" - -# define SSL_TXT_aRSA "aRSA" -# define SSL_TXT_aDSS "aDSS" -# define SSL_TXT_aDH "aDH" -# define SSL_TXT_aECDH "aECDH" -# define SSL_TXT_aECDSA "aECDSA" -# define SSL_TXT_aPSK "aPSK" -# define SSL_TXT_aGOST94 "aGOST94" -# define SSL_TXT_aGOST01 "aGOST01" -# define SSL_TXT_aGOST12 "aGOST12" -# define SSL_TXT_aGOST "aGOST" -# define SSL_TXT_aSRP "aSRP" - -# define SSL_TXT_DSS "DSS" -# define SSL_TXT_DH "DH" -# define SSL_TXT_DHE "DHE"/* same as "kDHE:-ADH" */ -# define SSL_TXT_EDH "EDH"/* alias for DHE */ -# define SSL_TXT_ADH "ADH" -# define SSL_TXT_RSA "RSA" -# define SSL_TXT_ECDH "ECDH" -# define SSL_TXT_EECDH "EECDH"/* alias for ECDHE" */ -# define SSL_TXT_ECDHE "ECDHE"/* same as "kECDHE:-AECDH" */ -# define SSL_TXT_AECDH "AECDH" -# define SSL_TXT_ECDSA "ECDSA" -# define SSL_TXT_PSK "PSK" -# define SSL_TXT_SRP "SRP" - -# define SSL_TXT_DES "DES" -# define SSL_TXT_3DES "3DES" -# define SSL_TXT_RC4 "RC4" -# define SSL_TXT_RC2 "RC2" -# define SSL_TXT_IDEA "IDEA" -# define SSL_TXT_SEED "SEED" -# define SSL_TXT_AES128 "AES128" -# define SSL_TXT_AES256 "AES256" -# define SSL_TXT_AES "AES" -# define SSL_TXT_AES_GCM "AESGCM" -# define SSL_TXT_AES_CCM "AESCCM" -# define SSL_TXT_AES_CCM_8 "AESCCM8" -# define SSL_TXT_CAMELLIA128 "CAMELLIA128" -# define SSL_TXT_CAMELLIA256 "CAMELLIA256" -# define SSL_TXT_CAMELLIA "CAMELLIA" -# define SSL_TXT_CHACHA20 "CHACHA20" -# define SSL_TXT_GOST "GOST89" - -# define SSL_TXT_MD5 "MD5" -# define SSL_TXT_SHA1 "SHA1" -# define SSL_TXT_SHA "SHA"/* same as "SHA1" */ -# define SSL_TXT_GOST94 "GOST94" -# define SSL_TXT_GOST89MAC "GOST89MAC" -# define SSL_TXT_GOST12 "GOST12" -# define SSL_TXT_GOST89MAC12 "GOST89MAC12" -# define SSL_TXT_SHA256 "SHA256" -# define SSL_TXT_SHA384 "SHA384" - -# define SSL_TXT_SSLV3 "SSLv3" -# define SSL_TXT_TLSV1 "TLSv1" -# define SSL_TXT_TLSV1_1 "TLSv1.1" -# define SSL_TXT_TLSV1_2 "TLSv1.2" - -# define SSL_TXT_ALL "ALL" - -/*- - * COMPLEMENTOF* definitions. These identifiers are used to (de-select) - * ciphers normally not being used. - * Example: "RC4" will activate all ciphers using RC4 including ciphers - * without authentication, which would normally disabled by DEFAULT (due - * the "!ADH" being part of default). Therefore "RC4:!COMPLEMENTOFDEFAULT" - * will make sure that it is also disabled in the specific selection. - * COMPLEMENTOF* identifiers are portable between version, as adjustments - * to the default cipher setup will also be included here. - * - * COMPLEMENTOFDEFAULT does not experience the same special treatment that - * DEFAULT gets, as only selection is being done and no sorting as needed - * for DEFAULT. - */ -# define SSL_TXT_CMPALL "COMPLEMENTOFALL" -# define SSL_TXT_CMPDEF "COMPLEMENTOFDEFAULT" - -/* - * The following cipher list is used by default. It also is substituted when - * an application-defined cipher list string starts with 'DEFAULT'. - */ -# define SSL_DEFAULT_CIPHER_LIST "ALL:!COMPLEMENTOFDEFAULT:!eNULL" -/* - * As of OpenSSL 1.0.0, ssl_create_cipher_list() in ssl/ssl_ciph.c always - * starts with a reasonable order, and all we have to do for DEFAULT is - * throwing out anonymous and unencrypted ciphersuites! (The latter are not - * actually enabled by ALL, but "ALL:RSA" would enable some of them.) - */ - -/* Used in SSL_set_shutdown()/SSL_get_shutdown(); */ -# define SSL_SENT_SHUTDOWN 1 -# define SSL_RECEIVED_SHUTDOWN 2 - -#ifdef __cplusplus -} -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -# define SSL_FILETYPE_ASN1 X509_FILETYPE_ASN1 -# define SSL_FILETYPE_PEM X509_FILETYPE_PEM - -/* - * This is needed to stop compilers complaining about the 'struct ssl_st *' - * function parameters used to prototype callbacks in SSL_CTX. - */ -typedef struct ssl_st *ssl_crock_st; -typedef struct tls_session_ticket_ext_st TLS_SESSION_TICKET_EXT; -typedef struct ssl_method_st SSL_METHOD; -typedef struct ssl_cipher_st SSL_CIPHER; -typedef struct ssl_session_st SSL_SESSION; -typedef struct tls_sigalgs_st TLS_SIGALGS; -typedef struct ssl_conf_ctx_st SSL_CONF_CTX; -typedef struct ssl_comp_st SSL_COMP; - -STACK_OF(SSL_CIPHER); -STACK_OF(SSL_COMP); - -/* SRTP protection profiles for use with the use_srtp extension (RFC 5764)*/ -typedef struct srtp_protection_profile_st { - const char *name; - unsigned long id; -} SRTP_PROTECTION_PROFILE; - -DEFINE_STACK_OF(SRTP_PROTECTION_PROFILE) - -typedef int (*tls_session_ticket_ext_cb_fn) (SSL *s, - const unsigned char *data, - int len, void *arg); -typedef int (*tls_session_secret_cb_fn) (SSL *s, void *secret, - int *secret_len, - STACK_OF(SSL_CIPHER) *peer_ciphers, - const SSL_CIPHER **cipher, void *arg); - -/* Typedefs for handling custom extensions */ - -typedef int (*custom_ext_add_cb) (SSL *s, unsigned int ext_type, - const unsigned char **out, - size_t *outlen, int *al, void *add_arg); - -typedef void (*custom_ext_free_cb) (SSL *s, unsigned int ext_type, - const unsigned char *out, void *add_arg); - -typedef int (*custom_ext_parse_cb) (SSL *s, unsigned int ext_type, - const unsigned char *in, - size_t inlen, int *al, void *parse_arg); - -/* Allow initial connection to servers that don't support RI */ -# define SSL_OP_LEGACY_SERVER_CONNECT 0x00000004U -/* Removed from OpenSSL 0.9.8q and 1.0.0c */ -/* Dead forever, see CVE-2010-4180. */ -# define SSL_OP_NETSCAPE_REUSE_CIPHER_CHANGE_BUG 0x0U -# define SSL_OP_TLSEXT_PADDING 0x00000010U -# define SSL_OP_MICROSOFT_BIG_SSLV3_BUFFER 0x0U -# define SSL_OP_SAFARI_ECDHE_ECDSA_BUG 0x00000040U -/* Ancient SSLeay version, retained for compatibility */ -# define SSL_OP_SSLEAY_080_CLIENT_DH_BUG 0x0 -# define SSL_OP_TLS_D5_BUG 0x0U -/* Removed from OpenSSL 1.1.0 */ -# define SSL_OP_TLS_BLOCK_PADDING_BUG 0x0U - -/* Hasn't done anything since OpenSSL 0.9.7h, retained for compatibility */ -# define SSL_OP_MSIE_SSLV2_RSA_PADDING 0x0 -/* Refers to ancient SSLREF and SSLv2, retained for compatibility */ -# define SSL_OP_SSLREF2_REUSE_CERT_TYPE_BUG 0x0 -/* Related to removed SSLv2 */ -# define SSL_OP_MICROSOFT_SESS_ID_BUG 0x0 -# define SSL_OP_NETSCAPE_CHALLENGE_BUG 0x0 - -/* - * Disable SSL 3.0/TLS 1.0 CBC vulnerability workaround that was added in - * OpenSSL 0.9.6d. Usually (depending on the application protocol) the - * workaround is not needed. Unfortunately some broken SSL/TLS - * implementations cannot handle it at all, which is why we include it in - * SSL_OP_ALL. - */ -/* added in 0.9.6e */ -# define SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS 0x00000800U - -/* - * SSL_OP_ALL: various bug workarounds that should be rather harmless. This - * used to be 0x000FFFFFL before 0.9.7. - */ -# define SSL_OP_ALL 0x80000BFFU - -/* DTLS options */ -# define SSL_OP_NO_QUERY_MTU 0x00001000U -/* Turn on Cookie Exchange (on relevant for servers) */ -# define SSL_OP_COOKIE_EXCHANGE 0x00002000U -/* Don't use RFC4507 ticket extension */ -# define SSL_OP_NO_TICKET 0x00004000U -# ifndef OPENSSL_NO_DTLS1_METHOD -/* Use Cisco's "speshul" version of DTLS_BAD_VER - * (only with deprecated DTLSv1_client_method()) */ -# define SSL_OP_CISCO_ANYCONNECT 0x00008000U -# endif - -/* As server, disallow session resumption on renegotiation */ -# define SSL_OP_NO_SESSION_RESUMPTION_ON_RENEGOTIATION 0x00010000U -/* Don't use compression even if supported */ -# define SSL_OP_NO_COMPRESSION 0x00020000U -/* Permit unsafe legacy renegotiation */ -# define SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION 0x00040000U -/* Does nothing: retained for compatibility */ -# define SSL_OP_SINGLE_ECDH_USE 0x0 -/* Does nothing: retained for compatibility */ -# define SSL_OP_SINGLE_DH_USE 0x0 -/* Does nothing: retained for compatibility */ -# define SSL_OP_EPHEMERAL_RSA 0x0 -/* - * Set on servers to choose the cipher according to the server's preferences - */ -# define SSL_OP_CIPHER_SERVER_PREFERENCE 0x00400000U -/* - * If set, a server will allow a client to issue a SSLv3.0 version number as - * latest version supported in the premaster secret, even when TLSv1.0 - * (version 3.1) was announced in the client hello. Normally this is - * forbidden to prevent version rollback attacks. - */ -# define SSL_OP_TLS_ROLLBACK_BUG 0x00800000U - -# define SSL_OP_NO_SSLv2 0x00000000U -# define SSL_OP_NO_SSLv3 0x02000000U -# define SSL_OP_NO_TLSv1 0x04000000U -# define SSL_OP_NO_TLSv1_2 0x08000000U -# define SSL_OP_NO_TLSv1_1 0x10000000U - -# define SSL_OP_NO_DTLSv1 0x04000000U -# define SSL_OP_NO_DTLSv1_2 0x08000000U - -# define SSL_OP_NO_SSL_MASK (SSL_OP_NO_SSLv3|\ - SSL_OP_NO_TLSv1|SSL_OP_NO_TLSv1_1|SSL_OP_NO_TLSv1_2) -# define SSL_OP_NO_DTLS_MASK (SSL_OP_NO_DTLSv1|SSL_OP_NO_DTLSv1_2) - - -/* Removed from previous versions */ -# define SSL_OP_PKCS1_CHECK_1 0x0 -# define SSL_OP_PKCS1_CHECK_2 0x0 -# define SSL_OP_NETSCAPE_CA_DN_BUG 0x0 -# define SSL_OP_NETSCAPE_DEMO_CIPHER_CHANGE_BUG 0x0U -/* - * Make server add server-hello extension from early version of cryptopro - * draft, when GOST ciphersuite is negotiated. Required for interoperability - * with CryptoPro CSP 3.x - */ -# define SSL_OP_CRYPTOPRO_TLSEXT_BUG 0x80000000U - -/* - * Allow SSL_write(..., n) to return r with 0 < r < n (i.e. report success - * when just a single record has been written): - */ -# define SSL_MODE_ENABLE_PARTIAL_WRITE 0x00000001U -/* - * Make it possible to retry SSL_write() with changed buffer location (buffer - * contents must stay the same!); this is not the default to avoid the - * misconception that non-blocking SSL_write() behaves like non-blocking - * write(): - */ -# define SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 0x00000002U -/* - * Never bother the application with retries if the transport is blocking: - */ -# define SSL_MODE_AUTO_RETRY 0x00000004U -/* Don't attempt to automatically build certificate chain */ -# define SSL_MODE_NO_AUTO_CHAIN 0x00000008U -/* - * Save RAM by releasing read and write buffers when they're empty. (SSL3 and - * TLS only.) "Released" buffers are put onto a free-list in the context or - * just freed (depending on the context's setting for freelist_max_len). - */ -# define SSL_MODE_RELEASE_BUFFERS 0x00000010U -/* - * Send the current time in the Random fields of the ClientHello and - * ServerHello records for compatibility with hypothetical implementations - * that require it. - */ -# define SSL_MODE_SEND_CLIENTHELLO_TIME 0x00000020U -# define SSL_MODE_SEND_SERVERHELLO_TIME 0x00000040U -/* - * Send TLS_FALLBACK_SCSV in the ClientHello. To be set only by applications - * that reconnect with a downgraded protocol version; see - * draft-ietf-tls-downgrade-scsv-00 for details. DO NOT ENABLE THIS if your - * application attempts a normal handshake. Only use this in explicit - * fallback retries, following the guidance in - * draft-ietf-tls-downgrade-scsv-00. - */ -# define SSL_MODE_SEND_FALLBACK_SCSV 0x00000080U -/* - * Support Asynchronous operation - */ -# define SSL_MODE_ASYNC 0x00000100U - -/* Cert related flags */ -/* - * Many implementations ignore some aspects of the TLS standards such as - * enforcing certificate chain algorithms. When this is set we enforce them. - */ -# define SSL_CERT_FLAG_TLS_STRICT 0x00000001U - -/* Suite B modes, takes same values as certificate verify flags */ -# define SSL_CERT_FLAG_SUITEB_128_LOS_ONLY 0x10000 -/* Suite B 192 bit only mode */ -# define SSL_CERT_FLAG_SUITEB_192_LOS 0x20000 -/* Suite B 128 bit mode allowing 192 bit algorithms */ -# define SSL_CERT_FLAG_SUITEB_128_LOS 0x30000 - -/* Perform all sorts of protocol violations for testing purposes */ -# define SSL_CERT_FLAG_BROKEN_PROTOCOL 0x10000000 - -/* Flags for building certificate chains */ -/* Treat any existing certificates as untrusted CAs */ -# define SSL_BUILD_CHAIN_FLAG_UNTRUSTED 0x1 -/* Don't include root CA in chain */ -# define SSL_BUILD_CHAIN_FLAG_NO_ROOT 0x2 -/* Just check certificates already there */ -# define SSL_BUILD_CHAIN_FLAG_CHECK 0x4 -/* Ignore verification errors */ -# define SSL_BUILD_CHAIN_FLAG_IGNORE_ERROR 0x8 -/* Clear verification errors from queue */ -# define SSL_BUILD_CHAIN_FLAG_CLEAR_ERROR 0x10 - -/* Flags returned by SSL_check_chain */ -/* Certificate can be used with this session */ -# define CERT_PKEY_VALID 0x1 -/* Certificate can also be used for signing */ -# define CERT_PKEY_SIGN 0x2 -/* EE certificate signing algorithm OK */ -# define CERT_PKEY_EE_SIGNATURE 0x10 -/* CA signature algorithms OK */ -# define CERT_PKEY_CA_SIGNATURE 0x20 -/* EE certificate parameters OK */ -# define CERT_PKEY_EE_PARAM 0x40 -/* CA certificate parameters OK */ -# define CERT_PKEY_CA_PARAM 0x80 -/* Signing explicitly allowed as opposed to SHA1 fallback */ -# define CERT_PKEY_EXPLICIT_SIGN 0x100 -/* Client CA issuer names match (always set for server cert) */ -# define CERT_PKEY_ISSUER_NAME 0x200 -/* Cert type matches client types (always set for server cert) */ -# define CERT_PKEY_CERT_TYPE 0x400 -/* Cert chain suitable to Suite B */ -# define CERT_PKEY_SUITEB 0x800 - -# define SSL_CONF_FLAG_CMDLINE 0x1 -# define SSL_CONF_FLAG_FILE 0x2 -# define SSL_CONF_FLAG_CLIENT 0x4 -# define SSL_CONF_FLAG_SERVER 0x8 -# define SSL_CONF_FLAG_SHOW_ERRORS 0x10 -# define SSL_CONF_FLAG_CERTIFICATE 0x20 -# define SSL_CONF_FLAG_REQUIRE_PRIVATE 0x40 -/* Configuration value types */ -# define SSL_CONF_TYPE_UNKNOWN 0x0 -# define SSL_CONF_TYPE_STRING 0x1 -# define SSL_CONF_TYPE_FILE 0x2 -# define SSL_CONF_TYPE_DIR 0x3 -# define SSL_CONF_TYPE_NONE 0x4 - -/* - * Note: SSL[_CTX]_set_{options,mode} use |= op on the previous value, they - * cannot be used to clear bits. - */ - -unsigned long SSL_CTX_get_options(const SSL_CTX *ctx); -unsigned long SSL_get_options(const SSL* s); -unsigned long SSL_CTX_clear_options(SSL_CTX *ctx, unsigned long op); -unsigned long SSL_clear_options(SSL *s, unsigned long op); -unsigned long SSL_CTX_set_options(SSL_CTX *ctx, unsigned long op); -unsigned long SSL_set_options(SSL *s, unsigned long op); - -# define SSL_CTX_set_mode(ctx,op) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,(op),NULL) -# define SSL_CTX_clear_mode(ctx,op) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_MODE,(op),NULL) -# define SSL_CTX_get_mode(ctx) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_MODE,0,NULL) -# define SSL_clear_mode(ssl,op) \ - SSL_ctrl((ssl),SSL_CTRL_CLEAR_MODE,(op),NULL) -# define SSL_set_mode(ssl,op) \ - SSL_ctrl((ssl),SSL_CTRL_MODE,(op),NULL) -# define SSL_get_mode(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_MODE,0,NULL) -# define SSL_set_mtu(ssl, mtu) \ - SSL_ctrl((ssl),SSL_CTRL_SET_MTU,(mtu),NULL) -# define DTLS_set_link_mtu(ssl, mtu) \ - SSL_ctrl((ssl),DTLS_CTRL_SET_LINK_MTU,(mtu),NULL) -# define DTLS_get_link_min_mtu(ssl) \ - SSL_ctrl((ssl),DTLS_CTRL_GET_LINK_MIN_MTU,0,NULL) - -# define SSL_get_secure_renegotiation_support(ssl) \ - SSL_ctrl((ssl), SSL_CTRL_GET_RI_SUPPORT, 0, NULL) - -# ifndef OPENSSL_NO_HEARTBEATS -# define SSL_heartbeat(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT,0,NULL) -# endif - -# define SSL_CTX_set_cert_flags(ctx,op) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_CERT_FLAGS,(op),NULL) -# define SSL_set_cert_flags(s,op) \ - SSL_ctrl((s),SSL_CTRL_CERT_FLAGS,(op),NULL) -# define SSL_CTX_clear_cert_flags(ctx,op) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL) -# define SSL_clear_cert_flags(s,op) \ - SSL_ctrl((s),SSL_CTRL_CLEAR_CERT_FLAGS,(op),NULL) - -void SSL_CTX_set_msg_callback(SSL_CTX *ctx, - void (*cb) (int write_p, int version, - int content_type, const void *buf, - size_t len, SSL *ssl, void *arg)); -void SSL_set_msg_callback(SSL *ssl, - void (*cb) (int write_p, int version, - int content_type, const void *buf, - size_t len, SSL *ssl, void *arg)); -# define SSL_CTX_set_msg_callback_arg(ctx, arg) SSL_CTX_ctrl((ctx), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) -# define SSL_set_msg_callback_arg(ssl, arg) SSL_ctrl((ssl), SSL_CTRL_SET_MSG_CALLBACK_ARG, 0, (arg)) - -# define SSL_get_extms_support(s) \ - SSL_ctrl((s),SSL_CTRL_GET_EXTMS_SUPPORT,0,NULL) - -# ifndef OPENSSL_NO_SRP - -/* see tls_srp.c */ -__owur int SSL_SRP_CTX_init(SSL *s); -__owur int SSL_CTX_SRP_CTX_init(SSL_CTX *ctx); -int SSL_SRP_CTX_free(SSL *ctx); -int SSL_CTX_SRP_CTX_free(SSL_CTX *ctx); -__owur int SSL_srp_server_param_with_username(SSL *s, int *ad); -__owur int SRP_Calc_A_param(SSL *s); - -# endif - -/* 100k max cert list */ -# define SSL_MAX_CERT_LIST_DEFAULT 1024*100 - -# define SSL_SESSION_CACHE_MAX_SIZE_DEFAULT (1024*20) - -/* - * This callback type is used inside SSL_CTX, SSL, and in the functions that - * set them. It is used to override the generation of SSL/TLS session IDs in - * a server. Return value should be zero on an error, non-zero to proceed. - * Also, callbacks should themselves check if the id they generate is unique - * otherwise the SSL handshake will fail with an error - callbacks can do - * this using the 'ssl' value they're passed by; - * SSL_has_matching_session_id(ssl, id, *id_len) The length value passed in - * is set at the maximum size the session ID can be. In SSLv3/TLSv1 it is 32 - * bytes. The callback can alter this length to be less if desired. It is - * also an error for the callback to set the size to zero. - */ -typedef int (*GEN_SESSION_CB) (const SSL *ssl, unsigned char *id, - unsigned int *id_len); - -# define SSL_SESS_CACHE_OFF 0x0000 -# define SSL_SESS_CACHE_CLIENT 0x0001 -# define SSL_SESS_CACHE_SERVER 0x0002 -# define SSL_SESS_CACHE_BOTH (SSL_SESS_CACHE_CLIENT|SSL_SESS_CACHE_SERVER) -# define SSL_SESS_CACHE_NO_AUTO_CLEAR 0x0080 -/* enough comments already ... see SSL_CTX_set_session_cache_mode(3) */ -# define SSL_SESS_CACHE_NO_INTERNAL_LOOKUP 0x0100 -# define SSL_SESS_CACHE_NO_INTERNAL_STORE 0x0200 -# define SSL_SESS_CACHE_NO_INTERNAL \ - (SSL_SESS_CACHE_NO_INTERNAL_LOOKUP|SSL_SESS_CACHE_NO_INTERNAL_STORE) - -LHASH_OF(SSL_SESSION) *SSL_CTX_sessions(SSL_CTX *ctx); -# define SSL_CTX_sess_number(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_NUMBER,0,NULL) -# define SSL_CTX_sess_connect(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT,0,NULL) -# define SSL_CTX_sess_connect_good(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_GOOD,0,NULL) -# define SSL_CTX_sess_connect_renegotiate(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CONNECT_RENEGOTIATE,0,NULL) -# define SSL_CTX_sess_accept(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT,0,NULL) -# define SSL_CTX_sess_accept_renegotiate(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_RENEGOTIATE,0,NULL) -# define SSL_CTX_sess_accept_good(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_ACCEPT_GOOD,0,NULL) -# define SSL_CTX_sess_hits(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_HIT,0,NULL) -# define SSL_CTX_sess_cb_hits(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CB_HIT,0,NULL) -# define SSL_CTX_sess_misses(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_MISSES,0,NULL) -# define SSL_CTX_sess_timeouts(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_TIMEOUTS,0,NULL) -# define SSL_CTX_sess_cache_full(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SESS_CACHE_FULL,0,NULL) - -void SSL_CTX_sess_set_new_cb(SSL_CTX *ctx, - int (*new_session_cb) (struct ssl_st *ssl, - SSL_SESSION *sess)); -int (*SSL_CTX_sess_get_new_cb(SSL_CTX *ctx)) (struct ssl_st *ssl, - SSL_SESSION *sess); -void SSL_CTX_sess_set_remove_cb(SSL_CTX *ctx, - void (*remove_session_cb) (struct ssl_ctx_st - *ctx, - SSL_SESSION - *sess)); -void (*SSL_CTX_sess_get_remove_cb(SSL_CTX *ctx)) (struct ssl_ctx_st *ctx, - SSL_SESSION *sess); -void SSL_CTX_sess_set_get_cb(SSL_CTX *ctx, - SSL_SESSION *(*get_session_cb) (struct ssl_st - *ssl, - const unsigned char - *data, int len, - int *copy)); -SSL_SESSION *(*SSL_CTX_sess_get_get_cb(SSL_CTX *ctx)) (struct ssl_st *ssl, - const unsigned char *data, - int len, int *copy); -void SSL_CTX_set_info_callback(SSL_CTX *ctx, - void (*cb) (const SSL *ssl, int type, - int val)); -void (*SSL_CTX_get_info_callback(SSL_CTX *ctx)) (const SSL *ssl, int type, - int val); -void SSL_CTX_set_client_cert_cb(SSL_CTX *ctx, - int (*client_cert_cb) (SSL *ssl, X509 **x509, - EVP_PKEY **pkey)); -int (*SSL_CTX_get_client_cert_cb(SSL_CTX *ctx)) (SSL *ssl, X509 **x509, - EVP_PKEY **pkey); -# ifndef OPENSSL_NO_ENGINE -__owur int SSL_CTX_set_client_cert_engine(SSL_CTX *ctx, ENGINE *e); -# endif -void SSL_CTX_set_cookie_generate_cb(SSL_CTX *ctx, - int (*app_gen_cookie_cb) (SSL *ssl, - unsigned char - *cookie, - unsigned int - *cookie_len)); -void SSL_CTX_set_cookie_verify_cb(SSL_CTX *ctx, - int (*app_verify_cookie_cb) (SSL *ssl, - const unsigned char - *cookie, - unsigned int - cookie_len)); -# ifndef OPENSSL_NO_NEXTPROTONEG -void SSL_CTX_set_next_protos_advertised_cb(SSL_CTX *s, - int (*cb) (SSL *ssl, - const unsigned char - **out, - unsigned int *outlen, - void *arg), void *arg); -void SSL_CTX_set_next_proto_select_cb(SSL_CTX *s, - int (*cb) (SSL *ssl, - unsigned char **out, - unsigned char *outlen, - const unsigned char *in, - unsigned int inlen, - void *arg), void *arg); -void SSL_get0_next_proto_negotiated(const SSL *s, const unsigned char **data, - unsigned *len); -# endif - -__owur int SSL_select_next_proto(unsigned char **out, unsigned char *outlen, - const unsigned char *in, unsigned int inlen, - const unsigned char *client, - unsigned int client_len); - -# define OPENSSL_NPN_UNSUPPORTED 0 -# define OPENSSL_NPN_NEGOTIATED 1 -# define OPENSSL_NPN_NO_OVERLAP 2 - -__owur int SSL_CTX_set_alpn_protos(SSL_CTX *ctx, const unsigned char *protos, - unsigned int protos_len); -__owur int SSL_set_alpn_protos(SSL *ssl, const unsigned char *protos, - unsigned int protos_len); -void SSL_CTX_set_alpn_select_cb(SSL_CTX *ctx, - int (*cb) (SSL *ssl, - const unsigned char **out, - unsigned char *outlen, - const unsigned char *in, - unsigned int inlen, - void *arg), void *arg); -void SSL_get0_alpn_selected(const SSL *ssl, const unsigned char **data, - unsigned int *len); - -# ifndef OPENSSL_NO_PSK -/* - * the maximum length of the buffer given to callbacks containing the - * resulting identity/psk - */ -# define PSK_MAX_IDENTITY_LEN 128 -# define PSK_MAX_PSK_LEN 256 -void SSL_CTX_set_psk_client_callback(SSL_CTX *ctx, - unsigned int (*psk_client_callback) (SSL - *ssl, - const - char - *hint, - char - *identity, - unsigned - int - max_identity_len, - unsigned - char - *psk, - unsigned - int - max_psk_len)); -void SSL_set_psk_client_callback(SSL *ssl, - unsigned int (*psk_client_callback) (SSL - *ssl, - const - char - *hint, - char - *identity, - unsigned - int - max_identity_len, - unsigned - char - *psk, - unsigned - int - max_psk_len)); -void SSL_CTX_set_psk_server_callback(SSL_CTX *ctx, - unsigned int (*psk_server_callback) (SSL - *ssl, - const - char - *identity, - unsigned - char - *psk, - unsigned - int - max_psk_len)); -void SSL_set_psk_server_callback(SSL *ssl, - unsigned int (*psk_server_callback) (SSL - *ssl, - const - char - *identity, - unsigned - char - *psk, - unsigned - int - max_psk_len)); -__owur int SSL_CTX_use_psk_identity_hint(SSL_CTX *ctx, const char *identity_hint); -__owur int SSL_use_psk_identity_hint(SSL *s, const char *identity_hint); -const char *SSL_get_psk_identity_hint(const SSL *s); -const char *SSL_get_psk_identity(const SSL *s); -# endif - -/* Register callbacks to handle custom TLS Extensions for client or server. */ - -__owur int SSL_CTX_has_client_custom_ext(const SSL_CTX *ctx, - unsigned int ext_type); - -__owur int SSL_CTX_add_client_custom_ext(SSL_CTX *ctx, unsigned int ext_type, - custom_ext_add_cb add_cb, - custom_ext_free_cb free_cb, - void *add_arg, - custom_ext_parse_cb parse_cb, - void *parse_arg); - -__owur int SSL_CTX_add_server_custom_ext(SSL_CTX *ctx, unsigned int ext_type, - custom_ext_add_cb add_cb, - custom_ext_free_cb free_cb, - void *add_arg, - custom_ext_parse_cb parse_cb, - void *parse_arg); - -__owur int SSL_extension_supported(unsigned int ext_type); - -# define SSL_NOTHING 1 -# define SSL_WRITING 2 -# define SSL_READING 3 -# define SSL_X509_LOOKUP 4 -# define SSL_ASYNC_PAUSED 5 -# define SSL_ASYNC_NO_JOBS 6 - -/* These will only be used when doing non-blocking IO */ -# define SSL_want_nothing(s) (SSL_want(s) == SSL_NOTHING) -# define SSL_want_read(s) (SSL_want(s) == SSL_READING) -# define SSL_want_write(s) (SSL_want(s) == SSL_WRITING) -# define SSL_want_x509_lookup(s) (SSL_want(s) == SSL_X509_LOOKUP) -# define SSL_want_async(s) (SSL_want(s) == SSL_ASYNC_PAUSED) -# define SSL_want_async_job(s) (SSL_want(s) == SSL_ASYNC_NO_JOBS) - -# define SSL_MAC_FLAG_READ_MAC_STREAM 1 -# define SSL_MAC_FLAG_WRITE_MAC_STREAM 2 - -#ifdef __cplusplus -} -#endif - -# include <openssl/ssl2.h> -# include <openssl/ssl3.h> -# include <openssl/tls1.h> /* This is mostly sslv3 with a few tweaks */ -# include <openssl/dtls1.h> /* Datagram TLS */ -# include <openssl/srtp.h> /* Support for the use_srtp extension */ - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * These need to be after the above set of includes due to a compiler bug - * in VisualStudio 2015 - */ -DEFINE_STACK_OF_CONST(SSL_CIPHER) -DEFINE_STACK_OF(SSL_COMP) - -/* compatibility */ -# define SSL_set_app_data(s,arg) (SSL_set_ex_data(s,0,(char *)arg)) -# define SSL_get_app_data(s) (SSL_get_ex_data(s,0)) -# define SSL_SESSION_set_app_data(s,a) (SSL_SESSION_set_ex_data(s,0,(char *)a)) -# define SSL_SESSION_get_app_data(s) (SSL_SESSION_get_ex_data(s,0)) -# define SSL_CTX_get_app_data(ctx) (SSL_CTX_get_ex_data(ctx,0)) -# define SSL_CTX_set_app_data(ctx,arg) (SSL_CTX_set_ex_data(ctx,0,(char *)arg)) -DEPRECATEDIN_1_1_0(void SSL_set_debug(SSL *s, int debug)) - - -/* - * The valid handshake states (one for each type message sent and one for each - * type of message received). There are also two "special" states: - * TLS = TLS or DTLS state - * DTLS = DTLS specific state - * CR/SR = Client Read/Server Read - * CW/SW = Client Write/Server Write - * - * The "special" states are: - * TLS_ST_BEFORE = No handshake has been initiated yet - * TLS_ST_OK = A handshake has been successfully completed - */ -typedef enum { - TLS_ST_BEFORE, - TLS_ST_OK, - DTLS_ST_CR_HELLO_VERIFY_REQUEST, - TLS_ST_CR_SRVR_HELLO, - TLS_ST_CR_CERT, - TLS_ST_CR_CERT_STATUS, - TLS_ST_CR_KEY_EXCH, - TLS_ST_CR_CERT_REQ, - TLS_ST_CR_SRVR_DONE, - TLS_ST_CR_SESSION_TICKET, - TLS_ST_CR_CHANGE, - TLS_ST_CR_FINISHED, - TLS_ST_CW_CLNT_HELLO, - TLS_ST_CW_CERT, - TLS_ST_CW_KEY_EXCH, - TLS_ST_CW_CERT_VRFY, - TLS_ST_CW_CHANGE, - TLS_ST_CW_NEXT_PROTO, - TLS_ST_CW_FINISHED, - TLS_ST_SW_HELLO_REQ, - TLS_ST_SR_CLNT_HELLO, - DTLS_ST_SW_HELLO_VERIFY_REQUEST, - TLS_ST_SW_SRVR_HELLO, - TLS_ST_SW_CERT, - TLS_ST_SW_KEY_EXCH, - TLS_ST_SW_CERT_REQ, - TLS_ST_SW_SRVR_DONE, - TLS_ST_SR_CERT, - TLS_ST_SR_KEY_EXCH, - TLS_ST_SR_CERT_VRFY, - TLS_ST_SR_NEXT_PROTO, - TLS_ST_SR_CHANGE, - TLS_ST_SR_FINISHED, - TLS_ST_SW_SESSION_TICKET, - TLS_ST_SW_CERT_STATUS, - TLS_ST_SW_CHANGE, - TLS_ST_SW_FINISHED -} OSSL_HANDSHAKE_STATE; - -/* - * Most of the following state values are no longer used and are defined to be - * the closest equivalent value in the current state machine code. Not all - * defines have an equivalent and are set to a dummy value (-1). SSL_ST_CONNECT - * and SSL_ST_ACCEPT are still in use in the definition of SSL_CB_ACCEPT_LOOP, - * SSL_CB_ACCEPT_EXIT, SSL_CB_CONNECT_LOOP and SSL_CB_CONNECT_EXIT. - */ - -# define SSL_ST_CONNECT 0x1000 -# define SSL_ST_ACCEPT 0x2000 - -# define SSL_ST_MASK 0x0FFF - -# define SSL_CB_LOOP 0x01 -# define SSL_CB_EXIT 0x02 -# define SSL_CB_READ 0x04 -# define SSL_CB_WRITE 0x08 -# define SSL_CB_ALERT 0x4000/* used in callback */ -# define SSL_CB_READ_ALERT (SSL_CB_ALERT|SSL_CB_READ) -# define SSL_CB_WRITE_ALERT (SSL_CB_ALERT|SSL_CB_WRITE) -# define SSL_CB_ACCEPT_LOOP (SSL_ST_ACCEPT|SSL_CB_LOOP) -# define SSL_CB_ACCEPT_EXIT (SSL_ST_ACCEPT|SSL_CB_EXIT) -# define SSL_CB_CONNECT_LOOP (SSL_ST_CONNECT|SSL_CB_LOOP) -# define SSL_CB_CONNECT_EXIT (SSL_ST_CONNECT|SSL_CB_EXIT) -# define SSL_CB_HANDSHAKE_START 0x10 -# define SSL_CB_HANDSHAKE_DONE 0x20 - -/* Is the SSL_connection established? */ -# define SSL_in_connect_init(a) (SSL_in_init(a) && !SSL_is_server(a)) -# define SSL_in_accept_init(a) (SSL_in_init(a) && SSL_is_server(a)) -int SSL_in_init(SSL *s); -int SSL_in_before(SSL *s); -int SSL_is_init_finished(SSL *s); - -/* - * The following 3 states are kept in ssl->rlayer.rstate when reads fail, you - * should not need these - */ -# define SSL_ST_READ_HEADER 0xF0 -# define SSL_ST_READ_BODY 0xF1 -# define SSL_ST_READ_DONE 0xF2 - -/*- - * Obtain latest Finished message - * -- that we sent (SSL_get_finished) - * -- that we expected from peer (SSL_get_peer_finished). - * Returns length (0 == no Finished so far), copies up to 'count' bytes. - */ -size_t SSL_get_finished(const SSL *s, void *buf, size_t count); -size_t SSL_get_peer_finished(const SSL *s, void *buf, size_t count); - -/* - * use either SSL_VERIFY_NONE or SSL_VERIFY_PEER, the last 2 options are - * 'ored' with SSL_VERIFY_PEER if they are desired - */ -# define SSL_VERIFY_NONE 0x00 -# define SSL_VERIFY_PEER 0x01 -# define SSL_VERIFY_FAIL_IF_NO_PEER_CERT 0x02 -# define SSL_VERIFY_CLIENT_ONCE 0x04 - -# define OpenSSL_add_ssl_algorithms() SSL_library_init() -# if OPENSSL_API_COMPAT < 0x10100000L -# define SSLeay_add_ssl_algorithms() SSL_library_init() -# endif - -/* More backward compatibility */ -# define SSL_get_cipher(s) \ - SSL_CIPHER_get_name(SSL_get_current_cipher(s)) -# define SSL_get_cipher_bits(s,np) \ - SSL_CIPHER_get_bits(SSL_get_current_cipher(s),np) -# define SSL_get_cipher_version(s) \ - SSL_CIPHER_get_version(SSL_get_current_cipher(s)) -# define SSL_get_cipher_name(s) \ - SSL_CIPHER_get_name(SSL_get_current_cipher(s)) -# define SSL_get_time(a) SSL_SESSION_get_time(a) -# define SSL_set_time(a,b) SSL_SESSION_set_time((a),(b)) -# define SSL_get_timeout(a) SSL_SESSION_get_timeout(a) -# define SSL_set_timeout(a,b) SSL_SESSION_set_timeout((a),(b)) - -# define d2i_SSL_SESSION_bio(bp,s_id) ASN1_d2i_bio_of(SSL_SESSION,SSL_SESSION_new,d2i_SSL_SESSION,bp,s_id) -# define i2d_SSL_SESSION_bio(bp,s_id) ASN1_i2d_bio_of(SSL_SESSION,i2d_SSL_SESSION,bp,s_id) - -DECLARE_PEM_rw(SSL_SESSION, SSL_SESSION) -# define SSL_AD_REASON_OFFSET 1000/* offset to get SSL_R_... value - * from SSL_AD_... */ -/* These alert types are for SSLv3 and TLSv1 */ -# define SSL_AD_CLOSE_NOTIFY SSL3_AD_CLOSE_NOTIFY -/* fatal */ -# define SSL_AD_UNEXPECTED_MESSAGE SSL3_AD_UNEXPECTED_MESSAGE -/* fatal */ -# define SSL_AD_BAD_RECORD_MAC SSL3_AD_BAD_RECORD_MAC -# define SSL_AD_DECRYPTION_FAILED TLS1_AD_DECRYPTION_FAILED -# define SSL_AD_RECORD_OVERFLOW TLS1_AD_RECORD_OVERFLOW -/* fatal */ -# define SSL_AD_DECOMPRESSION_FAILURE SSL3_AD_DECOMPRESSION_FAILURE -/* fatal */ -# define SSL_AD_HANDSHAKE_FAILURE SSL3_AD_HANDSHAKE_FAILURE -/* Not for TLS */ -# define SSL_AD_NO_CERTIFICATE SSL3_AD_NO_CERTIFICATE -# define SSL_AD_BAD_CERTIFICATE SSL3_AD_BAD_CERTIFICATE -# define SSL_AD_UNSUPPORTED_CERTIFICATE SSL3_AD_UNSUPPORTED_CERTIFICATE -# define SSL_AD_CERTIFICATE_REVOKED SSL3_AD_CERTIFICATE_REVOKED -# define SSL_AD_CERTIFICATE_EXPIRED SSL3_AD_CERTIFICATE_EXPIRED -# define SSL_AD_CERTIFICATE_UNKNOWN SSL3_AD_CERTIFICATE_UNKNOWN -/* fatal */ -# define SSL_AD_ILLEGAL_PARAMETER SSL3_AD_ILLEGAL_PARAMETER -/* fatal */ -# define SSL_AD_UNKNOWN_CA TLS1_AD_UNKNOWN_CA -/* fatal */ -# define SSL_AD_ACCESS_DENIED TLS1_AD_ACCESS_DENIED -/* fatal */ -# define SSL_AD_DECODE_ERROR TLS1_AD_DECODE_ERROR -# define SSL_AD_DECRYPT_ERROR TLS1_AD_DECRYPT_ERROR -/* fatal */ -# define SSL_AD_EXPORT_RESTRICTION TLS1_AD_EXPORT_RESTRICTION -/* fatal */ -# define SSL_AD_PROTOCOL_VERSION TLS1_AD_PROTOCOL_VERSION -/* fatal */ -# define SSL_AD_INSUFFICIENT_SECURITY TLS1_AD_INSUFFICIENT_SECURITY -/* fatal */ -# define SSL_AD_INTERNAL_ERROR TLS1_AD_INTERNAL_ERROR -# define SSL_AD_USER_CANCELLED TLS1_AD_USER_CANCELLED -# define SSL_AD_NO_RENEGOTIATION TLS1_AD_NO_RENEGOTIATION -# define SSL_AD_UNSUPPORTED_EXTENSION TLS1_AD_UNSUPPORTED_EXTENSION -# define SSL_AD_CERTIFICATE_UNOBTAINABLE TLS1_AD_CERTIFICATE_UNOBTAINABLE -# define SSL_AD_UNRECOGNIZED_NAME TLS1_AD_UNRECOGNIZED_NAME -# define SSL_AD_BAD_CERTIFICATE_STATUS_RESPONSE TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE -# define SSL_AD_BAD_CERTIFICATE_HASH_VALUE TLS1_AD_BAD_CERTIFICATE_HASH_VALUE -/* fatal */ -# define SSL_AD_UNKNOWN_PSK_IDENTITY TLS1_AD_UNKNOWN_PSK_IDENTITY -/* fatal */ -# define SSL_AD_INAPPROPRIATE_FALLBACK TLS1_AD_INAPPROPRIATE_FALLBACK -# define SSL_AD_NO_APPLICATION_PROTOCOL TLS1_AD_NO_APPLICATION_PROTOCOL -# define SSL_ERROR_NONE 0 -# define SSL_ERROR_SSL 1 -# define SSL_ERROR_WANT_READ 2 -# define SSL_ERROR_WANT_WRITE 3 -# define SSL_ERROR_WANT_X509_LOOKUP 4 -# define SSL_ERROR_SYSCALL 5/* look at error stack/return - * value/errno */ -# define SSL_ERROR_ZERO_RETURN 6 -# define SSL_ERROR_WANT_CONNECT 7 -# define SSL_ERROR_WANT_ACCEPT 8 -# define SSL_ERROR_WANT_ASYNC 9 -# define SSL_ERROR_WANT_ASYNC_JOB 10 -# define SSL_CTRL_SET_TMP_DH 3 -# define SSL_CTRL_SET_TMP_ECDH 4 -# define SSL_CTRL_SET_TMP_DH_CB 6 -# define SSL_CTRL_GET_CLIENT_CERT_REQUEST 9 -# define SSL_CTRL_GET_NUM_RENEGOTIATIONS 10 -# define SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS 11 -# define SSL_CTRL_GET_TOTAL_RENEGOTIATIONS 12 -# define SSL_CTRL_GET_FLAGS 13 -# define SSL_CTRL_EXTRA_CHAIN_CERT 14 -# define SSL_CTRL_SET_MSG_CALLBACK 15 -# define SSL_CTRL_SET_MSG_CALLBACK_ARG 16 -/* only applies to datagram connections */ -# define SSL_CTRL_SET_MTU 17 -/* Stats */ -# define SSL_CTRL_SESS_NUMBER 20 -# define SSL_CTRL_SESS_CONNECT 21 -# define SSL_CTRL_SESS_CONNECT_GOOD 22 -# define SSL_CTRL_SESS_CONNECT_RENEGOTIATE 23 -# define SSL_CTRL_SESS_ACCEPT 24 -# define SSL_CTRL_SESS_ACCEPT_GOOD 25 -# define SSL_CTRL_SESS_ACCEPT_RENEGOTIATE 26 -# define SSL_CTRL_SESS_HIT 27 -# define SSL_CTRL_SESS_CB_HIT 28 -# define SSL_CTRL_SESS_MISSES 29 -# define SSL_CTRL_SESS_TIMEOUTS 30 -# define SSL_CTRL_SESS_CACHE_FULL 31 -# define SSL_CTRL_MODE 33 -# define SSL_CTRL_GET_READ_AHEAD 40 -# define SSL_CTRL_SET_READ_AHEAD 41 -# define SSL_CTRL_SET_SESS_CACHE_SIZE 42 -# define SSL_CTRL_GET_SESS_CACHE_SIZE 43 -# define SSL_CTRL_SET_SESS_CACHE_MODE 44 -# define SSL_CTRL_GET_SESS_CACHE_MODE 45 -# define SSL_CTRL_GET_MAX_CERT_LIST 50 -# define SSL_CTRL_SET_MAX_CERT_LIST 51 -# define SSL_CTRL_SET_MAX_SEND_FRAGMENT 52 -/* see tls1.h for macros based on these */ -# define SSL_CTRL_SET_TLSEXT_SERVERNAME_CB 53 -# define SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG 54 -# define SSL_CTRL_SET_TLSEXT_HOSTNAME 55 -# define SSL_CTRL_SET_TLSEXT_DEBUG_CB 56 -# define SSL_CTRL_SET_TLSEXT_DEBUG_ARG 57 -# define SSL_CTRL_GET_TLSEXT_TICKET_KEYS 58 -# define SSL_CTRL_SET_TLSEXT_TICKET_KEYS 59 -/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT 60 */ -/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB 61 */ -/*# define SSL_CTRL_SET_TLSEXT_OPAQUE_PRF_INPUT_CB_ARG 62 */ -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB 63 -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG 64 -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE 65 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS 66 -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS 67 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS 68 -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS 69 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP 70 -# define SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP 71 -# define SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB 72 -# define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME_CB 75 -# define SSL_CTRL_SET_SRP_VERIFY_PARAM_CB 76 -# define SSL_CTRL_SET_SRP_GIVE_CLIENT_PWD_CB 77 -# define SSL_CTRL_SET_SRP_ARG 78 -# define SSL_CTRL_SET_TLS_EXT_SRP_USERNAME 79 -# define SSL_CTRL_SET_TLS_EXT_SRP_STRENGTH 80 -# define SSL_CTRL_SET_TLS_EXT_SRP_PASSWORD 81 -# ifndef OPENSSL_NO_HEARTBEATS -# define SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT 85 -# define SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING 86 -# define SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS 87 -# endif -# define DTLS_CTRL_GET_TIMEOUT 73 -# define DTLS_CTRL_HANDLE_TIMEOUT 74 -# define SSL_CTRL_GET_RI_SUPPORT 76 -# define SSL_CTRL_CLEAR_MODE 78 -# define SSL_CTRL_SET_NOT_RESUMABLE_SESS_CB 79 -# define SSL_CTRL_GET_EXTRA_CHAIN_CERTS 82 -# define SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS 83 -# define SSL_CTRL_CHAIN 88 -# define SSL_CTRL_CHAIN_CERT 89 -# define SSL_CTRL_GET_CURVES 90 -# define SSL_CTRL_SET_CURVES 91 -# define SSL_CTRL_SET_CURVES_LIST 92 -# define SSL_CTRL_GET_SHARED_CURVE 93 -# define SSL_CTRL_SET_SIGALGS 97 -# define SSL_CTRL_SET_SIGALGS_LIST 98 -# define SSL_CTRL_CERT_FLAGS 99 -# define SSL_CTRL_CLEAR_CERT_FLAGS 100 -# define SSL_CTRL_SET_CLIENT_SIGALGS 101 -# define SSL_CTRL_SET_CLIENT_SIGALGS_LIST 102 -# define SSL_CTRL_GET_CLIENT_CERT_TYPES 103 -# define SSL_CTRL_SET_CLIENT_CERT_TYPES 104 -# define SSL_CTRL_BUILD_CERT_CHAIN 105 -# define SSL_CTRL_SET_VERIFY_CERT_STORE 106 -# define SSL_CTRL_SET_CHAIN_CERT_STORE 107 -# define SSL_CTRL_GET_PEER_SIGNATURE_NID 108 -# define SSL_CTRL_GET_SERVER_TMP_KEY 109 -# define SSL_CTRL_GET_RAW_CIPHERLIST 110 -# define SSL_CTRL_GET_EC_POINT_FORMATS 111 -# define SSL_CTRL_GET_CHAIN_CERTS 115 -# define SSL_CTRL_SELECT_CURRENT_CERT 116 -# define SSL_CTRL_SET_CURRENT_CERT 117 -# define SSL_CTRL_SET_DH_AUTO 118 -# define DTLS_CTRL_SET_LINK_MTU 120 -# define DTLS_CTRL_GET_LINK_MIN_MTU 121 -# define SSL_CTRL_GET_EXTMS_SUPPORT 122 -# define SSL_CTRL_SET_MIN_PROTO_VERSION 123 -# define SSL_CTRL_SET_MAX_PROTO_VERSION 124 -# define SSL_CTRL_SET_SPLIT_SEND_FRAGMENT 125 -# define SSL_CTRL_SET_MAX_PIPELINES 126 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE 127 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB 128 -# define SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG 129 -# define SSL_CERT_SET_FIRST 1 -# define SSL_CERT_SET_NEXT 2 -# define SSL_CERT_SET_SERVER 3 -# define DTLSv1_get_timeout(ssl, arg) \ - SSL_ctrl(ssl,DTLS_CTRL_GET_TIMEOUT,0, (void *)arg) -# define DTLSv1_handle_timeout(ssl) \ - SSL_ctrl(ssl,DTLS_CTRL_HANDLE_TIMEOUT,0, NULL) -# define SSL_num_renegotiations(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_GET_NUM_RENEGOTIATIONS,0,NULL) -# define SSL_clear_num_renegotiations(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_CLEAR_NUM_RENEGOTIATIONS,0,NULL) -# define SSL_total_renegotiations(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_GET_TOTAL_RENEGOTIATIONS,0,NULL) -# define SSL_CTX_set_tmp_dh(ctx,dh) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_DH,0,(char *)dh) -# define SSL_CTX_set_tmp_ecdh(ctx,ecdh) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) -# define SSL_CTX_set_dh_auto(ctx, onoff) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_DH_AUTO,onoff,NULL) -# define SSL_set_dh_auto(s, onoff) \ - SSL_ctrl(s,SSL_CTRL_SET_DH_AUTO,onoff,NULL) -# define SSL_set_tmp_dh(ssl,dh) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TMP_DH,0,(char *)dh) -# define SSL_set_tmp_ecdh(ssl,ecdh) \ - SSL_ctrl(ssl,SSL_CTRL_SET_TMP_ECDH,0,(char *)ecdh) -# define SSL_CTX_add_extra_chain_cert(ctx,x509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_EXTRA_CHAIN_CERT,0,(char *)x509) -# define SSL_CTX_get_extra_chain_certs(ctx,px509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,0,px509) -# define SSL_CTX_get_extra_chain_certs_only(ctx,px509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_EXTRA_CHAIN_CERTS,1,px509) -# define SSL_CTX_clear_extra_chain_certs(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_CLEAR_EXTRA_CHAIN_CERTS,0,NULL) -# define SSL_CTX_set0_chain(ctx,sk) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)sk) -# define SSL_CTX_set1_chain(ctx,sk) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)sk) -# define SSL_CTX_add0_chain_cert(ctx,x509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)x509) -# define SSL_CTX_add1_chain_cert(ctx,x509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)x509) -# define SSL_CTX_get0_chain_certs(ctx,px509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509) -# define SSL_CTX_clear_chain_certs(ctx) \ - SSL_CTX_set0_chain(ctx,NULL) -# define SSL_CTX_build_cert_chain(ctx, flags) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) -# define SSL_CTX_select_current_cert(ctx,x509) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)x509) -# define SSL_CTX_set_current_cert(ctx, op) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL) -# define SSL_CTX_set0_verify_cert_store(ctx,st) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)st) -# define SSL_CTX_set1_verify_cert_store(ctx,st) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)st) -# define SSL_CTX_set0_chain_cert_store(ctx,st) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)st) -# define SSL_CTX_set1_chain_cert_store(ctx,st) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)st) -# define SSL_set0_chain(ctx,sk) \ - SSL_ctrl(ctx,SSL_CTRL_CHAIN,0,(char *)sk) -# define SSL_set1_chain(ctx,sk) \ - SSL_ctrl(ctx,SSL_CTRL_CHAIN,1,(char *)sk) -# define SSL_add0_chain_cert(ctx,x509) \ - SSL_ctrl(ctx,SSL_CTRL_CHAIN_CERT,0,(char *)x509) -# define SSL_add1_chain_cert(ctx,x509) \ - SSL_ctrl(ctx,SSL_CTRL_CHAIN_CERT,1,(char *)x509) -# define SSL_get0_chain_certs(ctx,px509) \ - SSL_ctrl(ctx,SSL_CTRL_GET_CHAIN_CERTS,0,px509) -# define SSL_clear_chain_certs(ctx) \ - SSL_set0_chain(ctx,NULL) -# define SSL_build_cert_chain(s, flags) \ - SSL_ctrl(s,SSL_CTRL_BUILD_CERT_CHAIN, flags, NULL) -# define SSL_select_current_cert(ctx,x509) \ - SSL_ctrl(ctx,SSL_CTRL_SELECT_CURRENT_CERT,0,(char *)x509) -# define SSL_set_current_cert(ctx,op) \ - SSL_ctrl(ctx,SSL_CTRL_SET_CURRENT_CERT, op, NULL) -# define SSL_set0_verify_cert_store(s,st) \ - SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,0,(char *)st) -# define SSL_set1_verify_cert_store(s,st) \ - SSL_ctrl(s,SSL_CTRL_SET_VERIFY_CERT_STORE,1,(char *)st) -# define SSL_set0_chain_cert_store(s,st) \ - SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,0,(char *)st) -# define SSL_set1_chain_cert_store(s,st) \ - SSL_ctrl(s,SSL_CTRL_SET_CHAIN_CERT_STORE,1,(char *)st) -# define SSL_get1_curves(ctx, s) \ - SSL_ctrl(ctx,SSL_CTRL_GET_CURVES,0,(char *)s) -# define SSL_CTX_set1_curves(ctx, clist, clistlen) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURVES,clistlen,(char *)clist) -# define SSL_CTX_set1_curves_list(ctx, s) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CURVES_LIST,0,(char *)s) -# define SSL_set1_curves(ctx, clist, clistlen) \ - SSL_ctrl(ctx,SSL_CTRL_SET_CURVES,clistlen,(char *)clist) -# define SSL_set1_curves_list(ctx, s) \ - SSL_ctrl(ctx,SSL_CTRL_SET_CURVES_LIST,0,(char *)s) -# define SSL_get_shared_curve(s, n) \ - SSL_ctrl(s,SSL_CTRL_GET_SHARED_CURVE,n,NULL) -# define SSL_CTX_set1_sigalgs(ctx, slist, slistlen) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS,slistlen,(int *)slist) -# define SSL_CTX_set1_sigalgs_list(ctx, s) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)s) -# define SSL_set1_sigalgs(ctx, slist, slistlen) \ - SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS,clistlen,(int *)slist) -# define SSL_set1_sigalgs_list(ctx, s) \ - SSL_ctrl(ctx,SSL_CTRL_SET_SIGALGS_LIST,0,(char *)s) -# define SSL_CTX_set1_client_sigalgs(ctx, slist, slistlen) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,slistlen,(int *)slist) -# define SSL_CTX_set1_client_sigalgs_list(ctx, s) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)s) -# define SSL_set1_client_sigalgs(ctx, slist, slistlen) \ - SSL_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS,clistlen,(int *)slist) -# define SSL_set1_client_sigalgs_list(ctx, s) \ - SSL_ctrl(ctx,SSL_CTRL_SET_CLIENT_SIGALGS_LIST,0,(char *)s) -# define SSL_get0_certificate_types(s, clist) \ - SSL_ctrl(s, SSL_CTRL_GET_CLIENT_CERT_TYPES, 0, (char *)clist) -# define SSL_CTX_set1_client_certificate_types(ctx, clist, clistlen) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)clist) -# define SSL_set1_client_certificate_types(s, clist, clistlen) \ - SSL_ctrl(s,SSL_CTRL_SET_CLIENT_CERT_TYPES,clistlen,(char *)clist) -# define SSL_get_peer_signature_nid(s, pn) \ - SSL_ctrl(s,SSL_CTRL_GET_PEER_SIGNATURE_NID,0,pn) -# define SSL_get_server_tmp_key(s, pk) \ - SSL_ctrl(s,SSL_CTRL_GET_SERVER_TMP_KEY,0,pk) -# define SSL_get0_raw_cipherlist(s, plst) \ - SSL_ctrl(s,SSL_CTRL_GET_RAW_CIPHERLIST,0,plst) -# define SSL_get0_ec_point_formats(s, plst) \ - SSL_ctrl(s,SSL_CTRL_GET_EC_POINT_FORMATS,0,plst) -#define SSL_CTX_set_min_proto_version(ctx, version) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL) -#define SSL_CTX_set_max_proto_version(ctx, version) \ - SSL_CTX_ctrl(ctx, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL) -#define SSL_set_min_proto_version(s, version) \ - SSL_ctrl(s, SSL_CTRL_SET_MIN_PROTO_VERSION, version, NULL) -#define SSL_set_max_proto_version(s, version) \ - SSL_ctrl(s, SSL_CTRL_SET_MAX_PROTO_VERSION, version, NULL) - -#if OPENSSL_API_COMPAT < 0x10100000L -/* Provide some compatibility macros for removed functionality. */ -# define SSL_CTX_need_tmp_RSA(ctx) 0 -# define SSL_CTX_set_tmp_rsa(ctx,rsa) 1 -# define SSL_need_tmp_RSA(ssl) 0 -# define SSL_set_tmp_rsa(ssl,rsa) 1 -# define SSL_CTX_set_ecdh_auto(dummy, onoff) ((onoff) != 0) -# define SSL_set_ecdh_auto(dummy, onoff) ((onoff) != 0) -/* - * We "pretend" to call the callback to avoid warnings about unused static - * functions. - */ -# define SSL_CTX_set_tmp_rsa_callback(ctx, cb) while(0) (cb)(NULL, 0, 0) -# define SSL_set_tmp_rsa_callback(ssl, cb) while(0) (cb)(NULL, 0, 0) -#endif - -__owur const BIO_METHOD *BIO_f_ssl(void); -__owur BIO *BIO_new_ssl(SSL_CTX *ctx, int client); -__owur BIO *BIO_new_ssl_connect(SSL_CTX *ctx); -__owur BIO *BIO_new_buffer_ssl_connect(SSL_CTX *ctx); -__owur int BIO_ssl_copy_session_id(BIO *to, BIO *from); -void BIO_ssl_shutdown(BIO *ssl_bio); - -__owur int SSL_CTX_set_cipher_list(SSL_CTX *, const char *str); -__owur SSL_CTX *SSL_CTX_new(const SSL_METHOD *meth); -int SSL_CTX_up_ref(SSL_CTX *ctx); -void SSL_CTX_free(SSL_CTX *); -__owur long SSL_CTX_set_timeout(SSL_CTX *ctx, long t); -__owur long SSL_CTX_get_timeout(const SSL_CTX *ctx); -__owur X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *); -void SSL_CTX_set_cert_store(SSL_CTX *, X509_STORE *); -__owur int SSL_want(const SSL *s); -__owur int SSL_clear(SSL *s); - -void SSL_CTX_flush_sessions(SSL_CTX *ctx, long tm); - -__owur const SSL_CIPHER *SSL_get_current_cipher(const SSL *s); -__owur int SSL_CIPHER_get_bits(const SSL_CIPHER *c, int *alg_bits); -__owur const char *SSL_CIPHER_get_version(const SSL_CIPHER *c); -__owur const char *SSL_CIPHER_get_name(const SSL_CIPHER *c); -__owur uint32_t SSL_CIPHER_get_id(const SSL_CIPHER *c); -__owur int SSL_CIPHER_get_kx_nid(const SSL_CIPHER *c); -__owur int SSL_CIPHER_get_auth_nid(const SSL_CIPHER *c); -__owur int SSL_CIPHER_is_aead(const SSL_CIPHER *c); - -__owur int SSL_get_fd(const SSL *s); -__owur int SSL_get_rfd(const SSL *s); -__owur int SSL_get_wfd(const SSL *s); -__owur const char *SSL_get_cipher_list(const SSL *s, int n); -__owur char *SSL_get_shared_ciphers(const SSL *s, char *buf, int len); -__owur int SSL_get_read_ahead(const SSL *s); -__owur int SSL_pending(const SSL *s); -__owur int SSL_has_pending(const SSL *s); -# ifndef OPENSSL_NO_SOCK -__owur int SSL_set_fd(SSL *s, int fd); -__owur int SSL_set_rfd(SSL *s, int fd); -__owur int SSL_set_wfd(SSL *s, int fd); -# endif -void SSL_set0_rbio(SSL *s, BIO *rbio); -void SSL_set0_wbio(SSL *s, BIO *wbio); -void SSL_set_bio(SSL *s, BIO *rbio, BIO *wbio); -__owur BIO *SSL_get_rbio(const SSL *s); -__owur BIO *SSL_get_wbio(const SSL *s); -__owur int SSL_set_cipher_list(SSL *s, const char *str); -void SSL_set_read_ahead(SSL *s, int yes); -__owur int SSL_get_verify_mode(const SSL *s); -__owur int SSL_get_verify_depth(const SSL *s); -__owur int (*SSL_get_verify_callback(const SSL *s)) (int, X509_STORE_CTX *); -void SSL_set_verify(SSL *s, int mode, - int (*callback) (int ok, X509_STORE_CTX *ctx)); -void SSL_set_verify_depth(SSL *s, int depth); -void SSL_set_cert_cb(SSL *s, int (*cb) (SSL *ssl, void *arg), void *arg); -# ifndef OPENSSL_NO_RSA -__owur int SSL_use_RSAPrivateKey(SSL *ssl, RSA *rsa); -__owur int SSL_use_RSAPrivateKey_ASN1(SSL *ssl, const unsigned char *d, long len); -# endif -__owur int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey); -__owur int SSL_use_PrivateKey_ASN1(int pk, SSL *ssl, const unsigned char *d, - long len); -__owur int SSL_use_certificate(SSL *ssl, X509 *x); -__owur int SSL_use_certificate_ASN1(SSL *ssl, const unsigned char *d, int len); - -/* Set serverinfo data for the current active cert. */ -__owur int SSL_CTX_use_serverinfo(SSL_CTX *ctx, const unsigned char *serverinfo, - size_t serverinfo_length); -__owur int SSL_CTX_use_serverinfo_file(SSL_CTX *ctx, const char *file); - -#ifndef OPENSSL_NO_RSA -__owur int SSL_use_RSAPrivateKey_file(SSL *ssl, const char *file, int type); -#endif - -__owur int SSL_use_PrivateKey_file(SSL *ssl, const char *file, int type); -__owur int SSL_use_certificate_file(SSL *ssl, const char *file, int type); - -#ifndef OPENSSL_NO_RSA -__owur int SSL_CTX_use_RSAPrivateKey_file(SSL_CTX *ctx, const char *file, int type); -#endif -__owur int SSL_CTX_use_PrivateKey_file(SSL_CTX *ctx, const char *file, int type); -__owur int SSL_CTX_use_certificate_file(SSL_CTX *ctx, const char *file, int type); -/* PEM type */ -__owur int SSL_CTX_use_certificate_chain_file(SSL_CTX *ctx, const char *file); -__owur int SSL_use_certificate_chain_file(SSL *ssl, const char *file); -__owur STACK_OF(X509_NAME) *SSL_load_client_CA_file(const char *file); -__owur int SSL_add_file_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, - const char *file); -int SSL_add_dir_cert_subjects_to_stack(STACK_OF(X509_NAME) *stackCAs, - const char *dir); - -#if OPENSSL_API_COMPAT < 0x10100000L -# define SSL_load_error_strings() \ - OPENSSL_init_ssl(OPENSSL_INIT_LOAD_SSL_STRINGS \ - | OPENSSL_INIT_LOAD_CRYPTO_STRINGS, NULL) -#endif - -__owur const char *SSL_state_string(const SSL *s); -__owur const char *SSL_rstate_string(const SSL *s); -__owur const char *SSL_state_string_long(const SSL *s); -__owur const char *SSL_rstate_string_long(const SSL *s); -__owur long SSL_SESSION_get_time(const SSL_SESSION *s); -__owur long SSL_SESSION_set_time(SSL_SESSION *s, long t); -__owur long SSL_SESSION_get_timeout(const SSL_SESSION *s); -__owur long SSL_SESSION_set_timeout(SSL_SESSION *s, long t); -__owur int SSL_SESSION_get_protocol_version(const SSL_SESSION *s); -__owur const char *SSL_SESSION_get0_hostname(const SSL_SESSION *s); -__owur const SSL_CIPHER *SSL_SESSION_get0_cipher(const SSL_SESSION *s); -__owur int SSL_SESSION_has_ticket(const SSL_SESSION *s); -__owur unsigned long SSL_SESSION_get_ticket_lifetime_hint(const SSL_SESSION *s); -void SSL_SESSION_get0_ticket(const SSL_SESSION *s, const unsigned char **tick, - size_t *len); -__owur int SSL_copy_session_id(SSL *to, const SSL *from); -__owur X509 *SSL_SESSION_get0_peer(SSL_SESSION *s); -__owur int SSL_SESSION_set1_id_context(SSL_SESSION *s, const unsigned char *sid_ctx, - unsigned int sid_ctx_len); -__owur int SSL_SESSION_set1_id(SSL_SESSION *s, const unsigned char *sid, - unsigned int sid_len); - -__owur SSL_SESSION *SSL_SESSION_new(void); -const unsigned char *SSL_SESSION_get_id(const SSL_SESSION *s, - unsigned int *len); -const unsigned char *SSL_SESSION_get0_id_context(const SSL_SESSION *s, - unsigned int *len); -__owur unsigned int SSL_SESSION_get_compress_id(const SSL_SESSION *s); -# ifndef OPENSSL_NO_STDIO -int SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *ses); -# endif -int SSL_SESSION_print(BIO *fp, const SSL_SESSION *ses); -int SSL_SESSION_print_keylog(BIO *bp, const SSL_SESSION *x); -int SSL_SESSION_up_ref(SSL_SESSION *ses); -void SSL_SESSION_free(SSL_SESSION *ses); -__owur int i2d_SSL_SESSION(SSL_SESSION *in, unsigned char **pp); -__owur int SSL_set_session(SSL *to, SSL_SESSION *session); -__owur int SSL_CTX_add_session(SSL_CTX *s, SSL_SESSION *c); -int SSL_CTX_remove_session(SSL_CTX *, SSL_SESSION *c); -__owur int SSL_CTX_set_generate_session_id(SSL_CTX *, GEN_SESSION_CB); -__owur int SSL_set_generate_session_id(SSL *, GEN_SESSION_CB); -__owur int SSL_has_matching_session_id(const SSL *ssl, const unsigned char *id, - unsigned int id_len); -SSL_SESSION *d2i_SSL_SESSION(SSL_SESSION **a, const unsigned char **pp, - long length); - -# ifdef HEADER_X509_H -__owur X509 *SSL_get_peer_certificate(const SSL *s); -# endif - -__owur STACK_OF(X509) *SSL_get_peer_cert_chain(const SSL *s); - -__owur int SSL_CTX_get_verify_mode(const SSL_CTX *ctx); -__owur int SSL_CTX_get_verify_depth(const SSL_CTX *ctx); -__owur int (*SSL_CTX_get_verify_callback(const SSL_CTX *ctx)) (int, - X509_STORE_CTX *); -void SSL_CTX_set_verify(SSL_CTX *ctx, int mode, - int (*callback) (int, X509_STORE_CTX *)); -void SSL_CTX_set_verify_depth(SSL_CTX *ctx, int depth); -void SSL_CTX_set_cert_verify_callback(SSL_CTX *ctx, - int (*cb) (X509_STORE_CTX *, void *), - void *arg); -void SSL_CTX_set_cert_cb(SSL_CTX *c, int (*cb) (SSL *ssl, void *arg), - void *arg); -# ifndef OPENSSL_NO_RSA -__owur int SSL_CTX_use_RSAPrivateKey(SSL_CTX *ctx, RSA *rsa); -__owur int SSL_CTX_use_RSAPrivateKey_ASN1(SSL_CTX *ctx, const unsigned char *d, - long len); -# endif -__owur int SSL_CTX_use_PrivateKey(SSL_CTX *ctx, EVP_PKEY *pkey); -__owur int SSL_CTX_use_PrivateKey_ASN1(int pk, SSL_CTX *ctx, - const unsigned char *d, long len); -__owur int SSL_CTX_use_certificate(SSL_CTX *ctx, X509 *x); -__owur int SSL_CTX_use_certificate_ASN1(SSL_CTX *ctx, int len, - const unsigned char *d); - -void SSL_CTX_set_default_passwd_cb(SSL_CTX *ctx, pem_password_cb *cb); -void SSL_CTX_set_default_passwd_cb_userdata(SSL_CTX *ctx, void *u); -pem_password_cb *SSL_CTX_get_default_passwd_cb(SSL_CTX *ctx); -void *SSL_CTX_get_default_passwd_cb_userdata(SSL_CTX *ctx); -void SSL_set_default_passwd_cb(SSL *s, pem_password_cb *cb); -void SSL_set_default_passwd_cb_userdata(SSL *s, void *u); -pem_password_cb *SSL_get_default_passwd_cb(SSL *s); -void *SSL_get_default_passwd_cb_userdata(SSL *s); - -__owur int SSL_CTX_check_private_key(const SSL_CTX *ctx); -__owur int SSL_check_private_key(const SSL *ctx); - -__owur int SSL_CTX_set_session_id_context(SSL_CTX *ctx, const unsigned char *sid_ctx, - unsigned int sid_ctx_len); - -SSL *SSL_new(SSL_CTX *ctx); -int SSL_up_ref(SSL *s); -int SSL_is_dtls(const SSL *s); -__owur int SSL_set_session_id_context(SSL *ssl, const unsigned char *sid_ctx, - unsigned int sid_ctx_len); - -__owur int SSL_CTX_set_purpose(SSL_CTX *s, int purpose); -__owur int SSL_set_purpose(SSL *s, int purpose); -__owur int SSL_CTX_set_trust(SSL_CTX *s, int trust); -__owur int SSL_set_trust(SSL *s, int trust); - -__owur int SSL_set1_host(SSL *s, const char *hostname); -__owur int SSL_add1_host(SSL *s, const char *hostname); -__owur const char *SSL_get0_peername(SSL *s); -void SSL_set_hostflags(SSL *s, unsigned int flags); - -__owur int SSL_CTX_dane_enable(SSL_CTX *ctx); -__owur int SSL_CTX_dane_mtype_set(SSL_CTX *ctx, const EVP_MD *md, - uint8_t mtype, uint8_t ord); -__owur int SSL_dane_enable(SSL *s, const char *basedomain); -__owur int SSL_dane_tlsa_add(SSL *s, uint8_t usage, uint8_t selector, - uint8_t mtype, unsigned char *data, size_t dlen); -__owur int SSL_get0_dane_authority(SSL *s, X509 **mcert, EVP_PKEY **mspki); -__owur int SSL_get0_dane_tlsa(SSL *s, uint8_t *usage, uint8_t *selector, - uint8_t *mtype, unsigned const char **data, - size_t *dlen); -/* - * Bridge opacity barrier between libcrypt and libssl, also needed to support - * offline testing in test/danetest.c - */ -SSL_DANE *SSL_get0_dane(SSL *ssl); -/* - * DANE flags - */ -unsigned long SSL_CTX_dane_set_flags(SSL_CTX *ctx, unsigned long flags); -unsigned long SSL_CTX_dane_clear_flags(SSL_CTX *ctx, unsigned long flags); -unsigned long SSL_dane_set_flags(SSL *ssl, unsigned long flags); -unsigned long SSL_dane_clear_flags(SSL *ssl, unsigned long flags); - -__owur int SSL_CTX_set1_param(SSL_CTX *ctx, X509_VERIFY_PARAM *vpm); -__owur int SSL_set1_param(SSL *ssl, X509_VERIFY_PARAM *vpm); - -__owur X509_VERIFY_PARAM *SSL_CTX_get0_param(SSL_CTX *ctx); -__owur X509_VERIFY_PARAM *SSL_get0_param(SSL *ssl); - -# ifndef OPENSSL_NO_SRP -int SSL_CTX_set_srp_username(SSL_CTX *ctx, char *name); -int SSL_CTX_set_srp_password(SSL_CTX *ctx, char *password); -int SSL_CTX_set_srp_strength(SSL_CTX *ctx, int strength); -int SSL_CTX_set_srp_client_pwd_callback(SSL_CTX *ctx, - char *(*cb) (SSL *, void *)); -int SSL_CTX_set_srp_verify_param_callback(SSL_CTX *ctx, - int (*cb) (SSL *, void *)); -int SSL_CTX_set_srp_username_callback(SSL_CTX *ctx, - int (*cb) (SSL *, int *, void *)); -int SSL_CTX_set_srp_cb_arg(SSL_CTX *ctx, void *arg); - -int SSL_set_srp_server_param(SSL *s, const BIGNUM *N, const BIGNUM *g, - BIGNUM *sa, BIGNUM *v, char *info); -int SSL_set_srp_server_param_pw(SSL *s, const char *user, const char *pass, - const char *grp); - -__owur BIGNUM *SSL_get_srp_g(SSL *s); -__owur BIGNUM *SSL_get_srp_N(SSL *s); - -__owur char *SSL_get_srp_username(SSL *s); -__owur char *SSL_get_srp_userinfo(SSL *s); -# endif - -void SSL_certs_clear(SSL *s); -void SSL_free(SSL *ssl); -# ifdef OSSL_ASYNC_FD -/* - * Windows application developer has to include windows.h to use these. - */ -__owur int SSL_waiting_for_async(SSL *s); -__owur int SSL_get_all_async_fds(SSL *s, OSSL_ASYNC_FD *fds, size_t *numfds); -__owur int SSL_get_changed_async_fds(SSL *s, OSSL_ASYNC_FD *addfd, - size_t *numaddfds, OSSL_ASYNC_FD *delfd, - size_t *numdelfds); -# endif -__owur int SSL_accept(SSL *ssl); -__owur int SSL_connect(SSL *ssl); -__owur int SSL_read(SSL *ssl, void *buf, int num); -__owur int SSL_peek(SSL *ssl, void *buf, int num); -__owur int SSL_write(SSL *ssl, const void *buf, int num); -long SSL_ctrl(SSL *ssl, int cmd, long larg, void *parg); -long SSL_callback_ctrl(SSL *, int, void (*)(void)); -long SSL_CTX_ctrl(SSL_CTX *ctx, int cmd, long larg, void *parg); -long SSL_CTX_callback_ctrl(SSL_CTX *, int, void (*)(void)); - -__owur int SSL_get_error(const SSL *s, int ret_code); -__owur const char *SSL_get_version(const SSL *s); - -/* This sets the 'default' SSL version that SSL_new() will create */ -__owur int SSL_CTX_set_ssl_version(SSL_CTX *ctx, const SSL_METHOD *meth); - -# ifndef OPENSSL_NO_SSL3_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_method(void)) /* SSLv3 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_server_method(void)) /* SSLv3 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *SSLv3_client_method(void)) /* SSLv3 */ -# endif - -#define SSLv23_method TLS_method -#define SSLv23_server_method TLS_server_method -#define SSLv23_client_method TLS_client_method - -/* Negotiate highest available SSL/TLS version */ -__owur const SSL_METHOD *TLS_method(void); -__owur const SSL_METHOD *TLS_server_method(void); -__owur const SSL_METHOD *TLS_client_method(void); - -# ifndef OPENSSL_NO_TLS1_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_method(void)) /* TLSv1.0 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_server_method(void)) /* TLSv1.0 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_client_method(void)) /* TLSv1.0 */ -# endif - -# ifndef OPENSSL_NO_TLS1_1_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_method(void)) /* TLSv1.1 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_server_method(void)) /* TLSv1.1 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_1_client_method(void)) /* TLSv1.1 */ -# endif - -# ifndef OPENSSL_NO_TLS1_2_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_method(void)) /* TLSv1.2 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_server_method(void)) /* TLSv1.2 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *TLSv1_2_client_method(void)) /* TLSv1.2 */ -# endif - -# ifndef OPENSSL_NO_DTLS1_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_method(void)) /* DTLSv1.0 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_server_method(void)) /* DTLSv1.0 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_client_method(void)) /* DTLSv1.0 */ -# endif - -# ifndef OPENSSL_NO_DTLS1_2_METHOD -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_method(void)) /* DTLSv1.2 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_server_method(void)) /* DTLSv1.2 */ -DEPRECATEDIN_1_1_0(__owur const SSL_METHOD *DTLSv1_2_client_method(void)) /* DTLSv1.2 */ -#endif - -__owur const SSL_METHOD *DTLS_method(void); /* DTLS 1.0 and 1.2 */ -__owur const SSL_METHOD *DTLS_server_method(void); /* DTLS 1.0 and 1.2 */ -__owur const SSL_METHOD *DTLS_client_method(void); /* DTLS 1.0 and 1.2 */ - -__owur STACK_OF(SSL_CIPHER) *SSL_get_ciphers(const SSL *s); -__owur STACK_OF(SSL_CIPHER) *SSL_CTX_get_ciphers(const SSL_CTX *ctx); -__owur STACK_OF(SSL_CIPHER) *SSL_get_client_ciphers(const SSL *s); -__owur STACK_OF(SSL_CIPHER) *SSL_get1_supported_ciphers(SSL *s); - -__owur int SSL_do_handshake(SSL *s); -int SSL_renegotiate(SSL *s); -__owur int SSL_renegotiate_abbreviated(SSL *s); -__owur int SSL_renegotiate_pending(SSL *s); -int SSL_shutdown(SSL *s); - -__owur const SSL_METHOD *SSL_CTX_get_ssl_method(SSL_CTX *ctx); -__owur const SSL_METHOD *SSL_get_ssl_method(SSL *s); -__owur int SSL_set_ssl_method(SSL *s, const SSL_METHOD *method); -__owur const char *SSL_alert_type_string_long(int value); -__owur const char *SSL_alert_type_string(int value); -__owur const char *SSL_alert_desc_string_long(int value); -__owur const char *SSL_alert_desc_string(int value); - -void SSL_set_client_CA_list(SSL *s, STACK_OF(X509_NAME) *name_list); -void SSL_CTX_set_client_CA_list(SSL_CTX *ctx, STACK_OF(X509_NAME) *name_list); -__owur STACK_OF(X509_NAME) *SSL_get_client_CA_list(const SSL *s); -__owur STACK_OF(X509_NAME) *SSL_CTX_get_client_CA_list(const SSL_CTX *s); -__owur int SSL_add_client_CA(SSL *ssl, X509 *x); -__owur int SSL_CTX_add_client_CA(SSL_CTX *ctx, X509 *x); - -void SSL_set_connect_state(SSL *s); -void SSL_set_accept_state(SSL *s); - -__owur long SSL_get_default_timeout(const SSL *s); - -#if OPENSSL_API_COMPAT < 0x10100000L -# define SSL_library_init() OPENSSL_init_ssl(0, NULL) -#endif - -__owur char *SSL_CIPHER_description(const SSL_CIPHER *, char *buf, int size); -__owur STACK_OF(X509_NAME) *SSL_dup_CA_list(STACK_OF(X509_NAME) *sk); - -__owur SSL *SSL_dup(SSL *ssl); - -__owur X509 *SSL_get_certificate(const SSL *ssl); -/* - * EVP_PKEY - */ struct evp_pkey_st *SSL_get_privatekey(const SSL *ssl); - -__owur X509 *SSL_CTX_get0_certificate(const SSL_CTX *ctx); -__owur EVP_PKEY *SSL_CTX_get0_privatekey(const SSL_CTX *ctx); - -void SSL_CTX_set_quiet_shutdown(SSL_CTX *ctx, int mode); -__owur int SSL_CTX_get_quiet_shutdown(const SSL_CTX *ctx); -void SSL_set_quiet_shutdown(SSL *ssl, int mode); -__owur int SSL_get_quiet_shutdown(const SSL *ssl); -void SSL_set_shutdown(SSL *ssl, int mode); -__owur int SSL_get_shutdown(const SSL *ssl); -__owur int SSL_version(const SSL *ssl); -__owur int SSL_client_version(const SSL *s); -__owur int SSL_CTX_set_default_verify_paths(SSL_CTX *ctx); -__owur int SSL_CTX_set_default_verify_dir(SSL_CTX *ctx); -__owur int SSL_CTX_set_default_verify_file(SSL_CTX *ctx); -__owur int SSL_CTX_load_verify_locations(SSL_CTX *ctx, const char *CAfile, - const char *CApath); -# define SSL_get0_session SSL_get_session/* just peek at pointer */ -__owur SSL_SESSION *SSL_get_session(const SSL *ssl); -__owur SSL_SESSION *SSL_get1_session(SSL *ssl); /* obtain a reference count */ -__owur SSL_CTX *SSL_get_SSL_CTX(const SSL *ssl); -SSL_CTX *SSL_set_SSL_CTX(SSL *ssl, SSL_CTX *ctx); -void SSL_set_info_callback(SSL *ssl, - void (*cb) (const SSL *ssl, int type, int val)); -void (*SSL_get_info_callback(const SSL *ssl)) (const SSL *ssl, int type, - int val); -__owur OSSL_HANDSHAKE_STATE SSL_get_state(const SSL *ssl); - -void SSL_set_verify_result(SSL *ssl, long v); -__owur long SSL_get_verify_result(const SSL *ssl); -__owur STACK_OF(X509) *SSL_get0_verified_chain(const SSL *s); - -__owur size_t SSL_get_client_random(const SSL *ssl, unsigned char *out, - size_t outlen); -__owur size_t SSL_get_server_random(const SSL *ssl, unsigned char *out, - size_t outlen); -__owur size_t SSL_SESSION_get_master_key(const SSL_SESSION *ssl, - unsigned char *out, size_t outlen); - -#define SSL_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL, l, p, newf, dupf, freef) -__owur int SSL_set_ex_data(SSL *ssl, int idx, void *data); -void *SSL_get_ex_data(const SSL *ssl, int idx); -#define SSL_SESSION_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_SESSION, l, p, newf, dupf, freef) -__owur int SSL_SESSION_set_ex_data(SSL_SESSION *ss, int idx, void *data); -void *SSL_SESSION_get_ex_data(const SSL_SESSION *ss, int idx); -#define SSL_CTX_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_SSL_CTX, l, p, newf, dupf, freef) -__owur int SSL_CTX_set_ex_data(SSL_CTX *ssl, int idx, void *data); -void *SSL_CTX_get_ex_data(const SSL_CTX *ssl, int idx); - -__owur int SSL_get_ex_data_X509_STORE_CTX_idx(void); - -# define SSL_CTX_sess_set_cache_size(ctx,t) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_SIZE,t,NULL) -# define SSL_CTX_sess_get_cache_size(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_SIZE,0,NULL) -# define SSL_CTX_set_session_cache_mode(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SESS_CACHE_MODE,m,NULL) -# define SSL_CTX_get_session_cache_mode(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_SESS_CACHE_MODE,0,NULL) - -# define SSL_CTX_get_default_read_ahead(ctx) SSL_CTX_get_read_ahead(ctx) -# define SSL_CTX_set_default_read_ahead(ctx,m) SSL_CTX_set_read_ahead(ctx,m) -# define SSL_CTX_get_read_ahead(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_READ_AHEAD,0,NULL) -# define SSL_CTX_set_read_ahead(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_READ_AHEAD,m,NULL) -# define SSL_CTX_get_max_cert_list(ctx) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) -# define SSL_CTX_set_max_cert_list(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) -# define SSL_get_max_cert_list(ssl) \ - SSL_ctrl(ssl,SSL_CTRL_GET_MAX_CERT_LIST,0,NULL) -# define SSL_set_max_cert_list(ssl,m) \ - SSL_ctrl(ssl,SSL_CTRL_SET_MAX_CERT_LIST,m,NULL) - -# define SSL_CTX_set_max_send_fragment(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL) -# define SSL_set_max_send_fragment(ssl,m) \ - SSL_ctrl(ssl,SSL_CTRL_SET_MAX_SEND_FRAGMENT,m,NULL) -# define SSL_CTX_set_split_send_fragment(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL) -# define SSL_set_split_send_fragment(ssl,m) \ - SSL_ctrl(ssl,SSL_CTRL_SET_SPLIT_SEND_FRAGMENT,m,NULL) -# define SSL_CTX_set_max_pipelines(ctx,m) \ - SSL_CTX_ctrl(ctx,SSL_CTRL_SET_MAX_PIPELINES,m,NULL) -# define SSL_set_max_pipelines(ssl,m) \ - SSL_ctrl(ssl,SSL_CTRL_SET_MAX_PIPELINES,m,NULL) - -void SSL_CTX_set_default_read_buffer_len(SSL_CTX *ctx, size_t len); -void SSL_set_default_read_buffer_len(SSL *s, size_t len); - -# ifndef OPENSSL_NO_DH -/* NB: the |keylength| is only applicable when is_export is true */ -void SSL_CTX_set_tmp_dh_callback(SSL_CTX *ctx, - DH *(*dh) (SSL *ssl, int is_export, - int keylength)); -void SSL_set_tmp_dh_callback(SSL *ssl, - DH *(*dh) (SSL *ssl, int is_export, - int keylength)); -# endif - -__owur const COMP_METHOD *SSL_get_current_compression(SSL *s); -__owur const COMP_METHOD *SSL_get_current_expansion(SSL *s); -__owur const char *SSL_COMP_get_name(const COMP_METHOD *comp); -STACK_OF(SSL_COMP) *SSL_COMP_get_compression_methods(void); -__owur STACK_OF(SSL_COMP) *SSL_COMP_set0_compression_methods(STACK_OF(SSL_COMP) - *meths); -#if OPENSSL_API_COMPAT < 0x10100000L -# define SSL_COMP_free_compression_methods() while(0) continue -#endif -__owur int SSL_COMP_add_compression_method(int id, COMP_METHOD *cm); - -const SSL_CIPHER *SSL_CIPHER_find(SSL *ssl, const unsigned char *ptr); -int SSL_CIPHER_get_cipher_nid(const SSL_CIPHER *c); -int SSL_CIPHER_get_digest_nid(const SSL_CIPHER *c); - -/* TLS extensions functions */ -__owur int SSL_set_session_ticket_ext(SSL *s, void *ext_data, int ext_len); - -__owur int SSL_set_session_ticket_ext_cb(SSL *s, tls_session_ticket_ext_cb_fn cb, - void *arg); - -/* Pre-shared secret session resumption functions */ -__owur int SSL_set_session_secret_cb(SSL *s, - tls_session_secret_cb_fn tls_session_secret_cb, - void *arg); - -void SSL_CTX_set_not_resumable_session_callback(SSL_CTX *ctx, - int (*cb) (SSL *ssl, - int - is_forward_secure)); - -void SSL_set_not_resumable_session_callback(SSL *ssl, - int (*cb) (SSL *ssl, - int - is_forward_secure)); -# if OPENSSL_API_COMPAT < 0x10100000L -# define SSL_cache_hit(s) SSL_session_reused(s) -# endif - -__owur int SSL_session_reused(SSL *s); -__owur int SSL_is_server(SSL *s); - -__owur __owur SSL_CONF_CTX *SSL_CONF_CTX_new(void); -int SSL_CONF_CTX_finish(SSL_CONF_CTX *cctx); -void SSL_CONF_CTX_free(SSL_CONF_CTX *cctx); -unsigned int SSL_CONF_CTX_set_flags(SSL_CONF_CTX *cctx, unsigned int flags); -__owur unsigned int SSL_CONF_CTX_clear_flags(SSL_CONF_CTX *cctx, unsigned int flags); -__owur int SSL_CONF_CTX_set1_prefix(SSL_CONF_CTX *cctx, const char *pre); - -void SSL_CONF_CTX_set_ssl(SSL_CONF_CTX *cctx, SSL *ssl); -void SSL_CONF_CTX_set_ssl_ctx(SSL_CONF_CTX *cctx, SSL_CTX *ctx); - -__owur int SSL_CONF_cmd(SSL_CONF_CTX *cctx, const char *cmd, const char *value); -__owur int SSL_CONF_cmd_argv(SSL_CONF_CTX *cctx, int *pargc, char ***pargv); -__owur int SSL_CONF_cmd_value_type(SSL_CONF_CTX *cctx, const char *cmd); - -void SSL_add_ssl_module(void); -int SSL_config(SSL *s, const char *name); -int SSL_CTX_config(SSL_CTX *ctx, const char *name); - -# ifndef OPENSSL_NO_SSL_TRACE -void SSL_trace(int write_p, int version, int content_type, - const void *buf, size_t len, SSL *ssl, void *arg); -__owur const char *SSL_CIPHER_standard_name(const SSL_CIPHER *c); -# endif - -# ifndef OPENSSL_NO_SOCK -int DTLSv1_listen(SSL *s, BIO_ADDR *client); -# endif - -# ifndef OPENSSL_NO_CT - -/* - * A callback for verifying that the received SCTs are sufficient. - * Expected to return 1 if they are sufficient, otherwise 0. - * May return a negative integer if an error occurs. - * A connection should be aborted if the SCTs are deemed insufficient. - */ -typedef int(*ssl_ct_validation_cb)(const CT_POLICY_EVAL_CTX *ctx, - const STACK_OF(SCT) *scts, void *arg); - -/* - * Sets a |callback| that is invoked upon receipt of ServerHelloDone to validate - * the received SCTs. - * If the callback returns a non-positive result, the connection is terminated. - * Call this function before beginning a handshake. - * If a NULL |callback| is provided, SCT validation is disabled. - * |arg| is arbitrary userdata that will be passed to the callback whenever it - * is invoked. Ownership of |arg| remains with the caller. - * - * NOTE: A side-effect of setting a CT callback is that an OCSP stapled response - * will be requested. - */ -int SSL_set_ct_validation_callback(SSL *s, ssl_ct_validation_cb callback, - void *arg); -int SSL_CTX_set_ct_validation_callback(SSL_CTX *ctx, - ssl_ct_validation_cb callback, - void *arg); -#define SSL_disable_ct(s) \ - ((void) SSL_set_validation_callback((s), NULL, NULL)) -#define SSL_CTX_disable_ct(ctx) \ - ((void) SSL_CTX_set_validation_callback((ctx), NULL, NULL)) - -/* - * The validation type enumerates the available behaviours of the built-in SSL - * CT validation callback selected via SSL_enable_ct() and SSL_CTX_enable_ct(). - * The underlying callback is a static function in libssl. - */ -enum { - SSL_CT_VALIDATION_PERMISSIVE = 0, - SSL_CT_VALIDATION_STRICT -}; - -/* - * Enable CT by setting up a callback that implements one of the built-in - * validation variants. The SSL_CT_VALIDATION_PERMISSIVE variant always - * continues the handshake, the application can make appropriate decisions at - * handshake completion. The SSL_CT_VALIDATION_STRICT variant requires at - * least one valid SCT, or else handshake termination will be requested. The - * handshake may continue anyway if SSL_VERIFY_NONE is in effect. - */ -int SSL_enable_ct(SSL *s, int validation_mode); -int SSL_CTX_enable_ct(SSL_CTX *ctx, int validation_mode); - -/* - * Report whether a non-NULL callback is enabled. - */ -int SSL_ct_is_enabled(const SSL *s); -int SSL_CTX_ct_is_enabled(const SSL_CTX *ctx); - -/* Gets the SCTs received from a connection */ -const STACK_OF(SCT) *SSL_get0_peer_scts(SSL *s); - -/* - * Loads the CT log list from the default location. - * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store, - * the log information loaded from this file will be appended to the - * CTLOG_STORE. - * Returns 1 on success, 0 otherwise. - */ -int SSL_CTX_set_default_ctlog_list_file(SSL_CTX *ctx); - -/* - * Loads the CT log list from the specified file path. - * If a CTLOG_STORE has previously been set using SSL_CTX_set_ctlog_store, - * the log information loaded from this file will be appended to the - * CTLOG_STORE. - * Returns 1 on success, 0 otherwise. - */ -int SSL_CTX_set_ctlog_list_file(SSL_CTX *ctx, const char *path); - -/* - * Sets the CT log list used by all SSL connections created from this SSL_CTX. - * Ownership of the CTLOG_STORE is transferred to the SSL_CTX. - */ -void SSL_CTX_set0_ctlog_store(SSL_CTX *ctx, CTLOG_STORE *logs); - -/* - * Gets the CT log list used by all SSL connections created from this SSL_CTX. - * This will be NULL unless one of the following functions has been called: - * - SSL_CTX_set_default_ctlog_list_file - * - SSL_CTX_set_ctlog_list_file - * - SSL_CTX_set_ctlog_store - */ -const CTLOG_STORE *SSL_CTX_get0_ctlog_store(const SSL_CTX *ctx); - -# endif /* OPENSSL_NO_CT */ - -/* What the "other" parameter contains in security callback */ -/* Mask for type */ -# define SSL_SECOP_OTHER_TYPE 0xffff0000 -# define SSL_SECOP_OTHER_NONE 0 -# define SSL_SECOP_OTHER_CIPHER (1 << 16) -# define SSL_SECOP_OTHER_CURVE (2 << 16) -# define SSL_SECOP_OTHER_DH (3 << 16) -# define SSL_SECOP_OTHER_PKEY (4 << 16) -# define SSL_SECOP_OTHER_SIGALG (5 << 16) -# define SSL_SECOP_OTHER_CERT (6 << 16) - -/* Indicated operation refers to peer key or certificate */ -# define SSL_SECOP_PEER 0x1000 - -/* Values for "op" parameter in security callback */ - -/* Called to filter ciphers */ -/* Ciphers client supports */ -# define SSL_SECOP_CIPHER_SUPPORTED (1 | SSL_SECOP_OTHER_CIPHER) -/* Cipher shared by client/server */ -# define SSL_SECOP_CIPHER_SHARED (2 | SSL_SECOP_OTHER_CIPHER) -/* Sanity check of cipher server selects */ -# define SSL_SECOP_CIPHER_CHECK (3 | SSL_SECOP_OTHER_CIPHER) -/* Curves supported by client */ -# define SSL_SECOP_CURVE_SUPPORTED (4 | SSL_SECOP_OTHER_CURVE) -/* Curves shared by client/server */ -# define SSL_SECOP_CURVE_SHARED (5 | SSL_SECOP_OTHER_CURVE) -/* Sanity check of curve server selects */ -# define SSL_SECOP_CURVE_CHECK (6 | SSL_SECOP_OTHER_CURVE) -/* Temporary DH key */ -# define SSL_SECOP_TMP_DH (7 | SSL_SECOP_OTHER_PKEY) -/* SSL/TLS version */ -# define SSL_SECOP_VERSION (9 | SSL_SECOP_OTHER_NONE) -/* Session tickets */ -# define SSL_SECOP_TICKET (10 | SSL_SECOP_OTHER_NONE) -/* Supported signature algorithms sent to peer */ -# define SSL_SECOP_SIGALG_SUPPORTED (11 | SSL_SECOP_OTHER_SIGALG) -/* Shared signature algorithm */ -# define SSL_SECOP_SIGALG_SHARED (12 | SSL_SECOP_OTHER_SIGALG) -/* Sanity check signature algorithm allowed */ -# define SSL_SECOP_SIGALG_CHECK (13 | SSL_SECOP_OTHER_SIGALG) -/* Used to get mask of supported public key signature algorithms */ -# define SSL_SECOP_SIGALG_MASK (14 | SSL_SECOP_OTHER_SIGALG) -/* Use to see if compression is allowed */ -# define SSL_SECOP_COMPRESSION (15 | SSL_SECOP_OTHER_NONE) -/* EE key in certificate */ -# define SSL_SECOP_EE_KEY (16 | SSL_SECOP_OTHER_CERT) -/* CA key in certificate */ -# define SSL_SECOP_CA_KEY (17 | SSL_SECOP_OTHER_CERT) -/* CA digest algorithm in certificate */ -# define SSL_SECOP_CA_MD (18 | SSL_SECOP_OTHER_CERT) -/* Peer EE key in certificate */ -# define SSL_SECOP_PEER_EE_KEY (SSL_SECOP_EE_KEY | SSL_SECOP_PEER) -/* Peer CA key in certificate */ -# define SSL_SECOP_PEER_CA_KEY (SSL_SECOP_CA_KEY | SSL_SECOP_PEER) -/* Peer CA digest algorithm in certificate */ -# define SSL_SECOP_PEER_CA_MD (SSL_SECOP_CA_MD | SSL_SECOP_PEER) - -void SSL_set_security_level(SSL *s, int level); -__owur int SSL_get_security_level(const SSL *s); -void SSL_set_security_callback(SSL *s, - int (*cb) (const SSL *s, const SSL_CTX *ctx, int op, - int bits, int nid, void *other, - void *ex)); -int (*SSL_get_security_callback(const SSL *s)) (const SSL *s, const SSL_CTX *ctx, int op, - int bits, int nid, - void *other, void *ex); -void SSL_set0_security_ex_data(SSL *s, void *ex); -__owur void *SSL_get0_security_ex_data(const SSL *s); - -void SSL_CTX_set_security_level(SSL_CTX *ctx, int level); -__owur int SSL_CTX_get_security_level(const SSL_CTX *ctx); -void SSL_CTX_set_security_callback(SSL_CTX *ctx, - int (*cb) (const SSL *s, const SSL_CTX *ctx, int op, - int bits, int nid, void *other, - void *ex)); -int (*SSL_CTX_get_security_callback(const SSL_CTX *ctx)) (const SSL *s, - const SSL_CTX *ctx, - int op, int bits, - int nid, - void *other, - void *ex); -void SSL_CTX_set0_security_ex_data(SSL_CTX *ctx, void *ex); -__owur void *SSL_CTX_get0_security_ex_data(const SSL_CTX *ctx); - -/* OPENSSL_INIT flag 0x010000 reserved for internal use */ -#define OPENSSL_INIT_NO_LOAD_SSL_STRINGS 0x00100000L -#define OPENSSL_INIT_LOAD_SSL_STRINGS 0x00200000L - -#define OPENSSL_INIT_SSL_DEFAULT \ - (OPENSSL_INIT_LOAD_SSL_STRINGS | OPENSSL_INIT_LOAD_CRYPTO_STRINGS) - -int OPENSSL_init_ssl(uint64_t opts, const OPENSSL_INIT_SETTINGS *settings); - -# ifndef OPENSSL_NO_UNIT_TEST -__owur const struct openssl_ssl_test_functions *SSL_test_functions(void); -# endif - -extern const char SSL_version_str[]; - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_SSL_strings(void); - -/* Error codes for the SSL functions. */ - -/* Function codes. */ -# define SSL_F_CHECK_SUITEB_CIPHER_LIST 331 -# define SSL_F_CT_MOVE_SCTS 345 -# define SSL_F_CT_STRICT 349 -# define SSL_F_D2I_SSL_SESSION 103 -# define SSL_F_DANE_CTX_ENABLE 347 -# define SSL_F_DANE_MTYPE_SET 393 -# define SSL_F_DANE_TLSA_ADD 394 -# define SSL_F_DO_DTLS1_WRITE 245 -# define SSL_F_DO_SSL3_WRITE 104 -# define SSL_F_DTLS1_BUFFER_RECORD 247 -# define SSL_F_DTLS1_CHECK_TIMEOUT_NUM 318 -# define SSL_F_DTLS1_HEARTBEAT 305 -# define SSL_F_DTLS1_PREPROCESS_FRAGMENT 288 -# define SSL_F_DTLS1_PROCESS_BUFFERED_RECORDS 424 -# define SSL_F_DTLS1_PROCESS_RECORD 257 -# define SSL_F_DTLS1_READ_BYTES 258 -# define SSL_F_DTLS1_READ_FAILED 339 -# define SSL_F_DTLS1_RETRANSMIT_MESSAGE 390 -# define SSL_F_DTLS1_WRITE_APP_DATA_BYTES 268 -# define SSL_F_DTLSV1_LISTEN 350 -# define SSL_F_DTLS_CONSTRUCT_CHANGE_CIPHER_SPEC 371 -# define SSL_F_DTLS_CONSTRUCT_HELLO_VERIFY_REQUEST 385 -# define SSL_F_DTLS_GET_REASSEMBLED_MESSAGE 370 -# define SSL_F_DTLS_PROCESS_HELLO_VERIFY 386 -# define SSL_F_OPENSSL_INIT_SSL 342 -# define SSL_F_OSSL_STATEM_CLIENT_READ_TRANSITION 417 -# define SSL_F_OSSL_STATEM_SERVER_READ_TRANSITION 418 -# define SSL_F_READ_STATE_MACHINE 352 -# define SSL_F_SSL3_CHANGE_CIPHER_STATE 129 -# define SSL_F_SSL3_CHECK_CERT_AND_ALGORITHM 130 -# define SSL_F_SSL3_CTRL 213 -# define SSL_F_SSL3_CTX_CTRL 133 -# define SSL_F_SSL3_DIGEST_CACHED_RECORDS 293 -# define SSL_F_SSL3_DO_CHANGE_CIPHER_SPEC 292 -# define SSL_F_SSL3_FINAL_FINISH_MAC 285 -# define SSL_F_SSL3_GENERATE_KEY_BLOCK 238 -# define SSL_F_SSL3_GENERATE_MASTER_SECRET 388 -# define SSL_F_SSL3_GET_RECORD 143 -# define SSL_F_SSL3_INIT_FINISHED_MAC 397 -# define SSL_F_SSL3_OUTPUT_CERT_CHAIN 147 -# define SSL_F_SSL3_READ_BYTES 148 -# define SSL_F_SSL3_READ_N 149 -# define SSL_F_SSL3_SETUP_KEY_BLOCK 157 -# define SSL_F_SSL3_SETUP_READ_BUFFER 156 -# define SSL_F_SSL3_SETUP_WRITE_BUFFER 291 -# define SSL_F_SSL3_WRITE_BYTES 158 -# define SSL_F_SSL3_WRITE_PENDING 159 -# define SSL_F_SSL_ADD_CERT_CHAIN 316 -# define SSL_F_SSL_ADD_CERT_TO_BUF 319 -# define SSL_F_SSL_ADD_CLIENTHELLO_RENEGOTIATE_EXT 298 -# define SSL_F_SSL_ADD_CLIENTHELLO_TLSEXT 277 -# define SSL_F_SSL_ADD_CLIENTHELLO_USE_SRTP_EXT 307 -# define SSL_F_SSL_ADD_DIR_CERT_SUBJECTS_TO_STACK 215 -# define SSL_F_SSL_ADD_FILE_CERT_SUBJECTS_TO_STACK 216 -# define SSL_F_SSL_ADD_SERVERHELLO_RENEGOTIATE_EXT 299 -# define SSL_F_SSL_ADD_SERVERHELLO_TLSEXT 278 -# define SSL_F_SSL_ADD_SERVERHELLO_USE_SRTP_EXT 308 -# define SSL_F_SSL_BAD_METHOD 160 -# define SSL_F_SSL_BUILD_CERT_CHAIN 332 -# define SSL_F_SSL_BYTES_TO_CIPHER_LIST 161 -# define SSL_F_SSL_CERT_ADD0_CHAIN_CERT 346 -# define SSL_F_SSL_CERT_DUP 221 -# define SSL_F_SSL_CERT_NEW 162 -# define SSL_F_SSL_CERT_SET0_CHAIN 340 -# define SSL_F_SSL_CHECK_PRIVATE_KEY 163 -# define SSL_F_SSL_CHECK_SERVERHELLO_TLSEXT 280 -# define SSL_F_SSL_CHECK_SRVR_ECC_CERT_AND_ALG 279 -# define SSL_F_SSL_CIPHER_PROCESS_RULESTR 230 -# define SSL_F_SSL_CIPHER_STRENGTH_SORT 231 -# define SSL_F_SSL_CLEAR 164 -# define SSL_F_SSL_COMP_ADD_COMPRESSION_METHOD 165 -# define SSL_F_SSL_CONF_CMD 334 -# define SSL_F_SSL_CREATE_CIPHER_LIST 166 -# define SSL_F_SSL_CTRL 232 -# define SSL_F_SSL_CTX_CHECK_PRIVATE_KEY 168 -# define SSL_F_SSL_CTX_ENABLE_CT 398 -# define SSL_F_SSL_CTX_MAKE_PROFILES 309 -# define SSL_F_SSL_CTX_NEW 169 -# define SSL_F_SSL_CTX_SET_ALPN_PROTOS 343 -# define SSL_F_SSL_CTX_SET_CIPHER_LIST 269 -# define SSL_F_SSL_CTX_SET_CLIENT_CERT_ENGINE 290 -# define SSL_F_SSL_CTX_SET_CT_VALIDATION_CALLBACK 396 -# define SSL_F_SSL_CTX_SET_SESSION_ID_CONTEXT 219 -# define SSL_F_SSL_CTX_SET_SSL_VERSION 170 -# define SSL_F_SSL_CTX_USE_CERTIFICATE 171 -# define SSL_F_SSL_CTX_USE_CERTIFICATE_ASN1 172 -# define SSL_F_SSL_CTX_USE_CERTIFICATE_FILE 173 -# define SSL_F_SSL_CTX_USE_PRIVATEKEY 174 -# define SSL_F_SSL_CTX_USE_PRIVATEKEY_ASN1 175 -# define SSL_F_SSL_CTX_USE_PRIVATEKEY_FILE 176 -# define SSL_F_SSL_CTX_USE_PSK_IDENTITY_HINT 272 -# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY 177 -# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_ASN1 178 -# define SSL_F_SSL_CTX_USE_RSAPRIVATEKEY_FILE 179 -# define SSL_F_SSL_CTX_USE_SERVERINFO 336 -# define SSL_F_SSL_CTX_USE_SERVERINFO_FILE 337 -# define SSL_F_SSL_DANE_DUP 403 -# define SSL_F_SSL_DANE_ENABLE 395 -# define SSL_F_SSL_DO_CONFIG 391 -# define SSL_F_SSL_DO_HANDSHAKE 180 -# define SSL_F_SSL_DUP_CA_LIST 408 -# define SSL_F_SSL_ENABLE_CT 402 -# define SSL_F_SSL_GET_NEW_SESSION 181 -# define SSL_F_SSL_GET_PREV_SESSION 217 -# define SSL_F_SSL_GET_SERVER_CERT_INDEX 322 -# define SSL_F_SSL_GET_SIGN_PKEY 183 -# define SSL_F_SSL_INIT_WBIO_BUFFER 184 -# define SSL_F_SSL_LOAD_CLIENT_CA_FILE 185 -# define SSL_F_SSL_MODULE_INIT 392 -# define SSL_F_SSL_NEW 186 -# define SSL_F_SSL_PARSE_CLIENTHELLO_RENEGOTIATE_EXT 300 -# define SSL_F_SSL_PARSE_CLIENTHELLO_TLSEXT 302 -# define SSL_F_SSL_PARSE_CLIENTHELLO_USE_SRTP_EXT 310 -# define SSL_F_SSL_PARSE_SERVERHELLO_RENEGOTIATE_EXT 301 -# define SSL_F_SSL_PARSE_SERVERHELLO_TLSEXT 303 -# define SSL_F_SSL_PARSE_SERVERHELLO_USE_SRTP_EXT 311 -# define SSL_F_SSL_PEEK 270 -# define SSL_F_SSL_READ 223 -# define SSL_F_SSL_SCAN_CLIENTHELLO_TLSEXT 320 -# define SSL_F_SSL_SCAN_SERVERHELLO_TLSEXT 321 -# define SSL_F_SSL_SESSION_DUP 348 -# define SSL_F_SSL_SESSION_NEW 189 -# define SSL_F_SSL_SESSION_PRINT_FP 190 -# define SSL_F_SSL_SESSION_SET1_ID 423 -# define SSL_F_SSL_SESSION_SET1_ID_CONTEXT 312 -# define SSL_F_SSL_SET_ALPN_PROTOS 344 -# define SSL_F_SSL_SET_CERT 191 -# define SSL_F_SSL_SET_CIPHER_LIST 271 -# define SSL_F_SSL_SET_CT_VALIDATION_CALLBACK 399 -# define SSL_F_SSL_SET_FD 192 -# define SSL_F_SSL_SET_PKEY 193 -# define SSL_F_SSL_SET_RFD 194 -# define SSL_F_SSL_SET_SESSION 195 -# define SSL_F_SSL_SET_SESSION_ID_CONTEXT 218 -# define SSL_F_SSL_SET_SESSION_TICKET_EXT 294 -# define SSL_F_SSL_SET_WFD 196 -# define SSL_F_SSL_SHUTDOWN 224 -# define SSL_F_SSL_SRP_CTX_INIT 313 -# define SSL_F_SSL_START_ASYNC_JOB 389 -# define SSL_F_SSL_UNDEFINED_FUNCTION 197 -# define SSL_F_SSL_UNDEFINED_VOID_FUNCTION 244 -# define SSL_F_SSL_USE_CERTIFICATE 198 -# define SSL_F_SSL_USE_CERTIFICATE_ASN1 199 -# define SSL_F_SSL_USE_CERTIFICATE_FILE 200 -# define SSL_F_SSL_USE_PRIVATEKEY 201 -# define SSL_F_SSL_USE_PRIVATEKEY_ASN1 202 -# define SSL_F_SSL_USE_PRIVATEKEY_FILE 203 -# define SSL_F_SSL_USE_PSK_IDENTITY_HINT 273 -# define SSL_F_SSL_USE_RSAPRIVATEKEY 204 -# define SSL_F_SSL_USE_RSAPRIVATEKEY_ASN1 205 -# define SSL_F_SSL_USE_RSAPRIVATEKEY_FILE 206 -# define SSL_F_SSL_VALIDATE_CT 400 -# define SSL_F_SSL_VERIFY_CERT_CHAIN 207 -# define SSL_F_SSL_WRITE 208 -# define SSL_F_STATE_MACHINE 353 -# define SSL_F_TLS12_CHECK_PEER_SIGALG 333 -# define SSL_F_TLS1_CHANGE_CIPHER_STATE 209 -# define SSL_F_TLS1_CHECK_DUPLICATE_EXTENSIONS 341 -# define SSL_F_TLS1_ENC 401 -# define SSL_F_TLS1_EXPORT_KEYING_MATERIAL 314 -# define SSL_F_TLS1_GET_CURVELIST 338 -# define SSL_F_TLS1_PRF 284 -# define SSL_F_TLS1_SETUP_KEY_BLOCK 211 -# define SSL_F_TLS1_SET_SERVER_SIGALGS 335 -# define SSL_F_TLS_CLIENT_KEY_EXCHANGE_POST_WORK 354 -# define SSL_F_TLS_CONSTRUCT_CERTIFICATE_REQUEST 372 -# define SSL_F_TLS_CONSTRUCT_CKE_DHE 404 -# define SSL_F_TLS_CONSTRUCT_CKE_ECDHE 405 -# define SSL_F_TLS_CONSTRUCT_CKE_GOST 406 -# define SSL_F_TLS_CONSTRUCT_CKE_PSK_PREAMBLE 407 -# define SSL_F_TLS_CONSTRUCT_CKE_RSA 409 -# define SSL_F_TLS_CONSTRUCT_CKE_SRP 410 -# define SSL_F_TLS_CONSTRUCT_CLIENT_CERTIFICATE 355 -# define SSL_F_TLS_CONSTRUCT_CLIENT_HELLO 356 -# define SSL_F_TLS_CONSTRUCT_CLIENT_KEY_EXCHANGE 357 -# define SSL_F_TLS_CONSTRUCT_CLIENT_VERIFY 358 -# define SSL_F_TLS_CONSTRUCT_FINISHED 359 -# define SSL_F_TLS_CONSTRUCT_HELLO_REQUEST 373 -# define SSL_F_TLS_CONSTRUCT_NEW_SESSION_TICKET 428 -# define SSL_F_TLS_CONSTRUCT_SERVER_CERTIFICATE 374 -# define SSL_F_TLS_CONSTRUCT_SERVER_DONE 375 -# define SSL_F_TLS_CONSTRUCT_SERVER_HELLO 376 -# define SSL_F_TLS_CONSTRUCT_SERVER_KEY_EXCHANGE 377 -# define SSL_F_TLS_GET_MESSAGE_BODY 351 -# define SSL_F_TLS_GET_MESSAGE_HEADER 387 -# define SSL_F_TLS_POST_PROCESS_CLIENT_HELLO 378 -# define SSL_F_TLS_POST_PROCESS_CLIENT_KEY_EXCHANGE 384 -# define SSL_F_TLS_PREPARE_CLIENT_CERTIFICATE 360 -# define SSL_F_TLS_PROCESS_CERTIFICATE_REQUEST 361 -# define SSL_F_TLS_PROCESS_CERT_STATUS 362 -# define SSL_F_TLS_PROCESS_CERT_VERIFY 379 -# define SSL_F_TLS_PROCESS_CHANGE_CIPHER_SPEC 363 -# define SSL_F_TLS_PROCESS_CKE_DHE 411 -# define SSL_F_TLS_PROCESS_CKE_ECDHE 412 -# define SSL_F_TLS_PROCESS_CKE_GOST 413 -# define SSL_F_TLS_PROCESS_CKE_PSK_PREAMBLE 414 -# define SSL_F_TLS_PROCESS_CKE_RSA 415 -# define SSL_F_TLS_PROCESS_CKE_SRP 416 -# define SSL_F_TLS_PROCESS_CLIENT_CERTIFICATE 380 -# define SSL_F_TLS_PROCESS_CLIENT_HELLO 381 -# define SSL_F_TLS_PROCESS_CLIENT_KEY_EXCHANGE 382 -# define SSL_F_TLS_PROCESS_FINISHED 364 -# define SSL_F_TLS_PROCESS_KEY_EXCHANGE 365 -# define SSL_F_TLS_PROCESS_NEW_SESSION_TICKET 366 -# define SSL_F_TLS_PROCESS_NEXT_PROTO 383 -# define SSL_F_TLS_PROCESS_SERVER_CERTIFICATE 367 -# define SSL_F_TLS_PROCESS_SERVER_DONE 368 -# define SSL_F_TLS_PROCESS_SERVER_HELLO 369 -# define SSL_F_TLS_PROCESS_SKE_DHE 419 -# define SSL_F_TLS_PROCESS_SKE_ECDHE 420 -# define SSL_F_TLS_PROCESS_SKE_PSK_PREAMBLE 421 -# define SSL_F_TLS_PROCESS_SKE_SRP 422 -# define SSL_F_USE_CERTIFICATE_CHAIN_FILE 220 - -/* Reason codes. */ -# define SSL_R_APP_DATA_IN_HANDSHAKE 100 -# define SSL_R_ATTEMPT_TO_REUSE_SESSION_IN_DIFFERENT_CONTEXT 272 -# define SSL_R_AT_LEAST_TLS_1_0_NEEDED_IN_FIPS_MODE 143 -# define SSL_R_AT_LEAST_TLS_1_2_NEEDED_IN_SUITEB_MODE 158 -# define SSL_R_BAD_CHANGE_CIPHER_SPEC 103 -# define SSL_R_BAD_DATA 390 -# define SSL_R_BAD_DATA_RETURNED_BY_CALLBACK 106 -# define SSL_R_BAD_DECOMPRESSION 107 -# define SSL_R_BAD_DH_VALUE 102 -# define SSL_R_BAD_DIGEST_LENGTH 111 -# define SSL_R_BAD_ECC_CERT 304 -# define SSL_R_BAD_ECPOINT 306 -# define SSL_R_BAD_HANDSHAKE_LENGTH 332 -# define SSL_R_BAD_HELLO_REQUEST 105 -# define SSL_R_BAD_LENGTH 271 -# define SSL_R_BAD_PACKET_LENGTH 115 -# define SSL_R_BAD_PROTOCOL_VERSION_NUMBER 116 -# define SSL_R_BAD_RSA_ENCRYPT 119 -# define SSL_R_BAD_SIGNATURE 123 -# define SSL_R_BAD_SRP_A_LENGTH 347 -# define SSL_R_BAD_SRP_PARAMETERS 371 -# define SSL_R_BAD_SRTP_MKI_VALUE 352 -# define SSL_R_BAD_SRTP_PROTECTION_PROFILE_LIST 353 -# define SSL_R_BAD_SSL_FILETYPE 124 -# define SSL_R_BAD_VALUE 384 -# define SSL_R_BAD_WRITE_RETRY 127 -# define SSL_R_BIO_NOT_SET 128 -# define SSL_R_BLOCK_CIPHER_PAD_IS_WRONG 129 -# define SSL_R_BN_LIB 130 -# define SSL_R_CA_DN_LENGTH_MISMATCH 131 -# define SSL_R_CA_KEY_TOO_SMALL 397 -# define SSL_R_CA_MD_TOO_WEAK 398 -# define SSL_R_CCS_RECEIVED_EARLY 133 -# define SSL_R_CERTIFICATE_VERIFY_FAILED 134 -# define SSL_R_CERT_CB_ERROR 377 -# define SSL_R_CERT_LENGTH_MISMATCH 135 -# define SSL_R_CIPHER_CODE_WRONG_LENGTH 137 -# define SSL_R_CIPHER_OR_HASH_UNAVAILABLE 138 -# define SSL_R_CLIENTHELLO_TLSEXT 226 -# define SSL_R_COMPRESSED_LENGTH_TOO_LONG 140 -# define SSL_R_COMPRESSION_DISABLED 343 -# define SSL_R_COMPRESSION_FAILURE 141 -# define SSL_R_COMPRESSION_ID_NOT_WITHIN_PRIVATE_RANGE 307 -# define SSL_R_COMPRESSION_LIBRARY_ERROR 142 -# define SSL_R_CONNECTION_TYPE_NOT_SET 144 -# define SSL_R_CONTEXT_NOT_DANE_ENABLED 167 -# define SSL_R_COOKIE_GEN_CALLBACK_FAILURE 400 -# define SSL_R_COOKIE_MISMATCH 308 -# define SSL_R_CUSTOM_EXT_HANDLER_ALREADY_INSTALLED 206 -# define SSL_R_DANE_ALREADY_ENABLED 172 -# define SSL_R_DANE_CANNOT_OVERRIDE_MTYPE_FULL 173 -# define SSL_R_DANE_NOT_ENABLED 175 -# define SSL_R_DANE_TLSA_BAD_CERTIFICATE 180 -# define SSL_R_DANE_TLSA_BAD_CERTIFICATE_USAGE 184 -# define SSL_R_DANE_TLSA_BAD_DATA_LENGTH 189 -# define SSL_R_DANE_TLSA_BAD_DIGEST_LENGTH 192 -# define SSL_R_DANE_TLSA_BAD_MATCHING_TYPE 200 -# define SSL_R_DANE_TLSA_BAD_PUBLIC_KEY 201 -# define SSL_R_DANE_TLSA_BAD_SELECTOR 202 -# define SSL_R_DANE_TLSA_NULL_DATA 203 -# define SSL_R_DATA_BETWEEN_CCS_AND_FINISHED 145 -# define SSL_R_DATA_LENGTH_TOO_LONG 146 -# define SSL_R_DECRYPTION_FAILED 147 -# define SSL_R_DECRYPTION_FAILED_OR_BAD_RECORD_MAC 281 -# define SSL_R_DH_KEY_TOO_SMALL 394 -# define SSL_R_DH_PUBLIC_VALUE_LENGTH_IS_WRONG 148 -# define SSL_R_DIGEST_CHECK_FAILED 149 -# define SSL_R_DTLS_MESSAGE_TOO_BIG 334 -# define SSL_R_DUPLICATE_COMPRESSION_ID 309 -# define SSL_R_ECC_CERT_NOT_FOR_SIGNING 318 -# define SSL_R_ECDH_REQUIRED_FOR_SUITEB_MODE 374 -# define SSL_R_EE_KEY_TOO_SMALL 399 -# define SSL_R_EMPTY_SRTP_PROTECTION_PROFILE_LIST 354 -# define SSL_R_ENCRYPTED_LENGTH_TOO_LONG 150 -# define SSL_R_ERROR_IN_RECEIVED_CIPHER_LIST 151 -# define SSL_R_ERROR_SETTING_TLSA_BASE_DOMAIN 204 -# define SSL_R_EXCESSIVE_MESSAGE_SIZE 152 -# define SSL_R_EXTRA_DATA_IN_MESSAGE 153 -# define SSL_R_FAILED_TO_INIT_ASYNC 405 -# define SSL_R_FRAGMENTED_CLIENT_HELLO 401 -# define SSL_R_GOT_A_FIN_BEFORE_A_CCS 154 -# define SSL_R_HTTPS_PROXY_REQUEST 155 -# define SSL_R_HTTP_REQUEST 156 -# define SSL_R_ILLEGAL_SUITEB_DIGEST 380 -# define SSL_R_INAPPROPRIATE_FALLBACK 373 -# define SSL_R_INCONSISTENT_COMPRESSION 340 -# define SSL_R_INCONSISTENT_EXTMS 104 -# define SSL_R_INVALID_COMMAND 280 -# define SSL_R_INVALID_COMPRESSION_ALGORITHM 341 -# define SSL_R_INVALID_CONFIGURATION_NAME 113 -# define SSL_R_INVALID_CT_VALIDATION_TYPE 212 -# define SSL_R_INVALID_NULL_CMD_NAME 385 -# define SSL_R_INVALID_SEQUENCE_NUMBER 402 -# define SSL_R_INVALID_SERVERINFO_DATA 388 -# define SSL_R_INVALID_SRP_USERNAME 357 -# define SSL_R_INVALID_STATUS_RESPONSE 328 -# define SSL_R_INVALID_TICKET_KEYS_LENGTH 325 -# define SSL_R_LENGTH_MISMATCH 159 -# define SSL_R_LENGTH_TOO_LONG 404 -# define SSL_R_LENGTH_TOO_SHORT 160 -# define SSL_R_LIBRARY_BUG 274 -# define SSL_R_LIBRARY_HAS_NO_CIPHERS 161 -# define SSL_R_MISSING_DSA_SIGNING_CERT 165 -# define SSL_R_MISSING_ECDSA_SIGNING_CERT 381 -# define SSL_R_MISSING_RSA_CERTIFICATE 168 -# define SSL_R_MISSING_RSA_ENCRYPTING_CERT 169 -# define SSL_R_MISSING_RSA_SIGNING_CERT 170 -# define SSL_R_MISSING_SRP_PARAM 358 -# define SSL_R_MISSING_TMP_DH_KEY 171 -# define SSL_R_MISSING_TMP_ECDH_KEY 311 -# define SSL_R_NO_CERTIFICATES_RETURNED 176 -# define SSL_R_NO_CERTIFICATE_ASSIGNED 177 -# define SSL_R_NO_CERTIFICATE_SET 179 -# define SSL_R_NO_CIPHERS_AVAILABLE 181 -# define SSL_R_NO_CIPHERS_SPECIFIED 183 -# define SSL_R_NO_CIPHER_MATCH 185 -# define SSL_R_NO_CLIENT_CERT_METHOD 331 -# define SSL_R_NO_COMPRESSION_SPECIFIED 187 -# define SSL_R_NO_GOST_CERTIFICATE_SENT_BY_PEER 330 -# define SSL_R_NO_METHOD_SPECIFIED 188 -# define SSL_R_NO_PEM_EXTENSIONS 389 -# define SSL_R_NO_PRIVATE_KEY_ASSIGNED 190 -# define SSL_R_NO_PROTOCOLS_AVAILABLE 191 -# define SSL_R_NO_RENEGOTIATION 339 -# define SSL_R_NO_REQUIRED_DIGEST 324 -# define SSL_R_NO_SHARED_CIPHER 193 -# define SSL_R_NO_SHARED_SIGNATURE_ALGORITHMS 376 -# define SSL_R_NO_SRTP_PROFILES 359 -# define SSL_R_NO_VALID_SCTS 216 -# define SSL_R_NO_VERIFY_COOKIE_CALLBACK 403 -# define SSL_R_NULL_SSL_CTX 195 -# define SSL_R_NULL_SSL_METHOD_PASSED 196 -# define SSL_R_OLD_SESSION_CIPHER_NOT_RETURNED 197 -# define SSL_R_OLD_SESSION_COMPRESSION_ALGORITHM_NOT_RETURNED 344 -# define SSL_R_PACKET_LENGTH_TOO_LONG 198 -# define SSL_R_PARSE_TLSEXT 227 -# define SSL_R_PATH_TOO_LONG 270 -# define SSL_R_PEER_DID_NOT_RETURN_A_CERTIFICATE 199 -# define SSL_R_PEM_NAME_BAD_PREFIX 391 -# define SSL_R_PEM_NAME_TOO_SHORT 392 -# define SSL_R_PIPELINE_FAILURE 406 -# define SSL_R_PROTOCOL_IS_SHUTDOWN 207 -# define SSL_R_PSK_IDENTITY_NOT_FOUND 223 -# define SSL_R_PSK_NO_CLIENT_CB 224 -# define SSL_R_PSK_NO_SERVER_CB 225 -# define SSL_R_READ_BIO_NOT_SET 211 -# define SSL_R_READ_TIMEOUT_EXPIRED 312 -# define SSL_R_RECORD_LENGTH_MISMATCH 213 -# define SSL_R_RECORD_TOO_SMALL 298 -# define SSL_R_RENEGOTIATE_EXT_TOO_LONG 335 -# define SSL_R_RENEGOTIATION_ENCODING_ERR 336 -# define SSL_R_RENEGOTIATION_MISMATCH 337 -# define SSL_R_REQUIRED_CIPHER_MISSING 215 -# define SSL_R_REQUIRED_COMPRESSION_ALGORITHM_MISSING 342 -# define SSL_R_SCSV_RECEIVED_WHEN_RENEGOTIATING 345 -# define SSL_R_SCT_VERIFICATION_FAILED 208 -# define SSL_R_SERVERHELLO_TLSEXT 275 -# define SSL_R_SESSION_ID_CONTEXT_UNINITIALIZED 277 -# define SSL_R_SHUTDOWN_WHILE_IN_INIT 407 -# define SSL_R_SIGNATURE_ALGORITHMS_ERROR 360 -# define SSL_R_SIGNATURE_FOR_NON_SIGNING_CERTIFICATE 220 -# define SSL_R_SRP_A_CALC 361 -# define SSL_R_SRTP_COULD_NOT_ALLOCATE_PROFILES 362 -# define SSL_R_SRTP_PROTECTION_PROFILE_LIST_TOO_LONG 363 -# define SSL_R_SRTP_UNKNOWN_PROTECTION_PROFILE 364 -# define SSL_R_SSL3_EXT_INVALID_SERVERNAME 319 -# define SSL_R_SSL3_EXT_INVALID_SERVERNAME_TYPE 320 -# define SSL_R_SSL3_SESSION_ID_TOO_LONG 300 -# define SSL_R_SSLV3_ALERT_BAD_CERTIFICATE 1042 -# define SSL_R_SSLV3_ALERT_BAD_RECORD_MAC 1020 -# define SSL_R_SSLV3_ALERT_CERTIFICATE_EXPIRED 1045 -# define SSL_R_SSLV3_ALERT_CERTIFICATE_REVOKED 1044 -# define SSL_R_SSLV3_ALERT_CERTIFICATE_UNKNOWN 1046 -# define SSL_R_SSLV3_ALERT_DECOMPRESSION_FAILURE 1030 -# define SSL_R_SSLV3_ALERT_HANDSHAKE_FAILURE 1040 -# define SSL_R_SSLV3_ALERT_ILLEGAL_PARAMETER 1047 -# define SSL_R_SSLV3_ALERT_NO_CERTIFICATE 1041 -# define SSL_R_SSLV3_ALERT_UNEXPECTED_MESSAGE 1010 -# define SSL_R_SSLV3_ALERT_UNSUPPORTED_CERTIFICATE 1043 -# define SSL_R_SSL_COMMAND_SECTION_EMPTY 117 -# define SSL_R_SSL_COMMAND_SECTION_NOT_FOUND 125 -# define SSL_R_SSL_CTX_HAS_NO_DEFAULT_SSL_VERSION 228 -# define SSL_R_SSL_HANDSHAKE_FAILURE 229 -# define SSL_R_SSL_LIBRARY_HAS_NO_CIPHERS 230 -# define SSL_R_SSL_NEGATIVE_LENGTH 372 -# define SSL_R_SSL_SECTION_EMPTY 126 -# define SSL_R_SSL_SECTION_NOT_FOUND 136 -# define SSL_R_SSL_SESSION_ID_CALLBACK_FAILED 301 -# define SSL_R_SSL_SESSION_ID_CONFLICT 302 -# define SSL_R_SSL_SESSION_ID_TOO_LONG 408 -# define SSL_R_SSL_SESSION_ID_CONTEXT_TOO_LONG 273 -# define SSL_R_SSL_SESSION_ID_HAS_BAD_LENGTH 303 -# define SSL_R_SSL_SESSION_VERSION_MISMATCH 210 -# define SSL_R_TLSV1_ALERT_ACCESS_DENIED 1049 -# define SSL_R_TLSV1_ALERT_DECODE_ERROR 1050 -# define SSL_R_TLSV1_ALERT_DECRYPTION_FAILED 1021 -# define SSL_R_TLSV1_ALERT_DECRYPT_ERROR 1051 -# define SSL_R_TLSV1_ALERT_EXPORT_RESTRICTION 1060 -# define SSL_R_TLSV1_ALERT_INAPPROPRIATE_FALLBACK 1086 -# define SSL_R_TLSV1_ALERT_INSUFFICIENT_SECURITY 1071 -# define SSL_R_TLSV1_ALERT_INTERNAL_ERROR 1080 -# define SSL_R_TLSV1_ALERT_NO_RENEGOTIATION 1100 -# define SSL_R_TLSV1_ALERT_PROTOCOL_VERSION 1070 -# define SSL_R_TLSV1_ALERT_RECORD_OVERFLOW 1022 -# define SSL_R_TLSV1_ALERT_UNKNOWN_CA 1048 -# define SSL_R_TLSV1_ALERT_USER_CANCELLED 1090 -# define SSL_R_TLSV1_BAD_CERTIFICATE_HASH_VALUE 1114 -# define SSL_R_TLSV1_BAD_CERTIFICATE_STATUS_RESPONSE 1113 -# define SSL_R_TLSV1_CERTIFICATE_UNOBTAINABLE 1111 -# define SSL_R_TLSV1_UNRECOGNIZED_NAME 1112 -# define SSL_R_TLSV1_UNSUPPORTED_EXTENSION 1110 -# define SSL_R_TLS_HEARTBEAT_PEER_DOESNT_ACCEPT 365 -# define SSL_R_TLS_HEARTBEAT_PENDING 366 -# define SSL_R_TLS_ILLEGAL_EXPORTER_LABEL 367 -# define SSL_R_TLS_INVALID_ECPOINTFORMAT_LIST 157 -# define SSL_R_TOO_MANY_WARN_ALERTS 409 -# define SSL_R_UNABLE_TO_FIND_ECDH_PARAMETERS 314 -# define SSL_R_UNABLE_TO_FIND_PUBLIC_KEY_PARAMETERS 239 -# define SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES 242 -# define SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES 243 -# define SSL_R_UNEXPECTED_MESSAGE 244 -# define SSL_R_UNEXPECTED_RECORD 245 -# define SSL_R_UNINITIALIZED 276 -# define SSL_R_UNKNOWN_ALERT_TYPE 246 -# define SSL_R_UNKNOWN_CERTIFICATE_TYPE 247 -# define SSL_R_UNKNOWN_CIPHER_RETURNED 248 -# define SSL_R_UNKNOWN_CIPHER_TYPE 249 -# define SSL_R_UNKNOWN_CMD_NAME 386 -# define SSL_R_UNKNOWN_COMMAND 139 -# define SSL_R_UNKNOWN_DIGEST 368 -# define SSL_R_UNKNOWN_KEY_EXCHANGE_TYPE 250 -# define SSL_R_UNKNOWN_PKEY_TYPE 251 -# define SSL_R_UNKNOWN_PROTOCOL 252 -# define SSL_R_UNKNOWN_SSL_VERSION 254 -# define SSL_R_UNKNOWN_STATE 255 -# define SSL_R_UNSAFE_LEGACY_RENEGOTIATION_DISABLED 338 -# define SSL_R_UNSUPPORTED_COMPRESSION_ALGORITHM 257 -# define SSL_R_UNSUPPORTED_ELLIPTIC_CURVE 315 -# define SSL_R_UNSUPPORTED_PROTOCOL 258 -# define SSL_R_UNSUPPORTED_SSL_VERSION 259 -# define SSL_R_UNSUPPORTED_STATUS_TYPE 329 -# define SSL_R_USE_SRTP_NOT_NEGOTIATED 369 -# define SSL_R_VERSION_TOO_HIGH 166 -# define SSL_R_VERSION_TOO_LOW 396 -# define SSL_R_WRONG_CERTIFICATE_TYPE 383 -# define SSL_R_WRONG_CIPHER_RETURNED 261 -# define SSL_R_WRONG_CURVE 378 -# define SSL_R_WRONG_SIGNATURE_LENGTH 264 -# define SSL_R_WRONG_SIGNATURE_SIZE 265 -# define SSL_R_WRONG_SIGNATURE_TYPE 370 -# define SSL_R_WRONG_SSL_VERSION 266 -# define SSL_R_WRONG_VERSION_NUMBER 267 -# define SSL_R_X509_LIB 268 -# define SSL_R_X509_VERIFICATION_SETUP_PROBLEMS 269 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/ssl2.h b/android/armeabi/include/openssl/ssl2.h deleted file mode 100644 index 5321bd27..00000000 --- a/android/armeabi/include/openssl/ssl2.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SSL2_H -# define HEADER_SSL2_H - -#ifdef __cplusplus -extern "C" { -#endif - -# define SSL2_VERSION 0x0002 - -# define SSL2_MT_CLIENT_HELLO 1 - -#ifdef __cplusplus -} -#endif -#endif diff --git a/android/armeabi/include/openssl/ssl3.h b/android/armeabi/include/openssl/ssl3.h deleted file mode 100644 index aca19223..00000000 --- a/android/armeabi/include/openssl/ssl3.h +++ /dev/null @@ -1,307 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECC cipher suite support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_SSL3_H -# define HEADER_SSL3_H - -# include <openssl/comp.h> -# include <openssl/buffer.h> -# include <openssl/evp.h> -# include <openssl/ssl.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Signalling cipher suite value from RFC 5746 - * (TLS_EMPTY_RENEGOTIATION_INFO_SCSV) - */ -# define SSL3_CK_SCSV 0x030000FF - -/* - * Signalling cipher suite value from draft-ietf-tls-downgrade-scsv-00 - * (TLS_FALLBACK_SCSV) - */ -# define SSL3_CK_FALLBACK_SCSV 0x03005600 - -# define SSL3_CK_RSA_NULL_MD5 0x03000001 -# define SSL3_CK_RSA_NULL_SHA 0x03000002 -# define SSL3_CK_RSA_RC4_40_MD5 0x03000003 -# define SSL3_CK_RSA_RC4_128_MD5 0x03000004 -# define SSL3_CK_RSA_RC4_128_SHA 0x03000005 -# define SSL3_CK_RSA_RC2_40_MD5 0x03000006 -# define SSL3_CK_RSA_IDEA_128_SHA 0x03000007 -# define SSL3_CK_RSA_DES_40_CBC_SHA 0x03000008 -# define SSL3_CK_RSA_DES_64_CBC_SHA 0x03000009 -# define SSL3_CK_RSA_DES_192_CBC3_SHA 0x0300000A - -# define SSL3_CK_DH_DSS_DES_40_CBC_SHA 0x0300000B -# define SSL3_CK_DH_DSS_DES_64_CBC_SHA 0x0300000C -# define SSL3_CK_DH_DSS_DES_192_CBC3_SHA 0x0300000D -# define SSL3_CK_DH_RSA_DES_40_CBC_SHA 0x0300000E -# define SSL3_CK_DH_RSA_DES_64_CBC_SHA 0x0300000F -# define SSL3_CK_DH_RSA_DES_192_CBC3_SHA 0x03000010 - -# define SSL3_CK_DHE_DSS_DES_40_CBC_SHA 0x03000011 -# define SSL3_CK_EDH_DSS_DES_40_CBC_SHA SSL3_CK_DHE_DSS_DES_40_CBC_SHA -# define SSL3_CK_DHE_DSS_DES_64_CBC_SHA 0x03000012 -# define SSL3_CK_EDH_DSS_DES_64_CBC_SHA SSL3_CK_DHE_DSS_DES_64_CBC_SHA -# define SSL3_CK_DHE_DSS_DES_192_CBC3_SHA 0x03000013 -# define SSL3_CK_EDH_DSS_DES_192_CBC3_SHA SSL3_CK_DHE_DSS_DES_192_CBC3_SHA -# define SSL3_CK_DHE_RSA_DES_40_CBC_SHA 0x03000014 -# define SSL3_CK_EDH_RSA_DES_40_CBC_SHA SSL3_CK_DHE_RSA_DES_40_CBC_SHA -# define SSL3_CK_DHE_RSA_DES_64_CBC_SHA 0x03000015 -# define SSL3_CK_EDH_RSA_DES_64_CBC_SHA SSL3_CK_DHE_RSA_DES_64_CBC_SHA -# define SSL3_CK_DHE_RSA_DES_192_CBC3_SHA 0x03000016 -# define SSL3_CK_EDH_RSA_DES_192_CBC3_SHA SSL3_CK_DHE_RSA_DES_192_CBC3_SHA - -# define SSL3_CK_ADH_RC4_40_MD5 0x03000017 -# define SSL3_CK_ADH_RC4_128_MD5 0x03000018 -# define SSL3_CK_ADH_DES_40_CBC_SHA 0x03000019 -# define SSL3_CK_ADH_DES_64_CBC_SHA 0x0300001A -# define SSL3_CK_ADH_DES_192_CBC_SHA 0x0300001B - -# define SSL3_TXT_RSA_NULL_MD5 "NULL-MD5" -# define SSL3_TXT_RSA_NULL_SHA "NULL-SHA" -# define SSL3_TXT_RSA_RC4_40_MD5 "EXP-RC4-MD5" -# define SSL3_TXT_RSA_RC4_128_MD5 "RC4-MD5" -# define SSL3_TXT_RSA_RC4_128_SHA "RC4-SHA" -# define SSL3_TXT_RSA_RC2_40_MD5 "EXP-RC2-CBC-MD5" -# define SSL3_TXT_RSA_IDEA_128_SHA "IDEA-CBC-SHA" -# define SSL3_TXT_RSA_DES_40_CBC_SHA "EXP-DES-CBC-SHA" -# define SSL3_TXT_RSA_DES_64_CBC_SHA "DES-CBC-SHA" -# define SSL3_TXT_RSA_DES_192_CBC3_SHA "DES-CBC3-SHA" - -# define SSL3_TXT_DH_DSS_DES_40_CBC_SHA "EXP-DH-DSS-DES-CBC-SHA" -# define SSL3_TXT_DH_DSS_DES_64_CBC_SHA "DH-DSS-DES-CBC-SHA" -# define SSL3_TXT_DH_DSS_DES_192_CBC3_SHA "DH-DSS-DES-CBC3-SHA" -# define SSL3_TXT_DH_RSA_DES_40_CBC_SHA "EXP-DH-RSA-DES-CBC-SHA" -# define SSL3_TXT_DH_RSA_DES_64_CBC_SHA "DH-RSA-DES-CBC-SHA" -# define SSL3_TXT_DH_RSA_DES_192_CBC3_SHA "DH-RSA-DES-CBC3-SHA" - -# define SSL3_TXT_DHE_DSS_DES_40_CBC_SHA "EXP-DHE-DSS-DES-CBC-SHA" -# define SSL3_TXT_DHE_DSS_DES_64_CBC_SHA "DHE-DSS-DES-CBC-SHA" -# define SSL3_TXT_DHE_DSS_DES_192_CBC3_SHA "DHE-DSS-DES-CBC3-SHA" -# define SSL3_TXT_DHE_RSA_DES_40_CBC_SHA "EXP-DHE-RSA-DES-CBC-SHA" -# define SSL3_TXT_DHE_RSA_DES_64_CBC_SHA "DHE-RSA-DES-CBC-SHA" -# define SSL3_TXT_DHE_RSA_DES_192_CBC3_SHA "DHE-RSA-DES-CBC3-SHA" - -/* - * This next block of six "EDH" labels is for backward compatibility with - * older versions of OpenSSL. New code should use the six "DHE" labels above - * instead: - */ -# define SSL3_TXT_EDH_DSS_DES_40_CBC_SHA "EXP-EDH-DSS-DES-CBC-SHA" -# define SSL3_TXT_EDH_DSS_DES_64_CBC_SHA "EDH-DSS-DES-CBC-SHA" -# define SSL3_TXT_EDH_DSS_DES_192_CBC3_SHA "EDH-DSS-DES-CBC3-SHA" -# define SSL3_TXT_EDH_RSA_DES_40_CBC_SHA "EXP-EDH-RSA-DES-CBC-SHA" -# define SSL3_TXT_EDH_RSA_DES_64_CBC_SHA "EDH-RSA-DES-CBC-SHA" -# define SSL3_TXT_EDH_RSA_DES_192_CBC3_SHA "EDH-RSA-DES-CBC3-SHA" - -# define SSL3_TXT_ADH_RC4_40_MD5 "EXP-ADH-RC4-MD5" -# define SSL3_TXT_ADH_RC4_128_MD5 "ADH-RC4-MD5" -# define SSL3_TXT_ADH_DES_40_CBC_SHA "EXP-ADH-DES-CBC-SHA" -# define SSL3_TXT_ADH_DES_64_CBC_SHA "ADH-DES-CBC-SHA" -# define SSL3_TXT_ADH_DES_192_CBC_SHA "ADH-DES-CBC3-SHA" - -# define SSL3_SSL_SESSION_ID_LENGTH 32 -# define SSL3_MAX_SSL_SESSION_ID_LENGTH 32 - -# define SSL3_MASTER_SECRET_SIZE 48 -# define SSL3_RANDOM_SIZE 32 -# define SSL3_SESSION_ID_SIZE 32 -# define SSL3_RT_HEADER_LENGTH 5 - -# define SSL3_HM_HEADER_LENGTH 4 - -# ifndef SSL3_ALIGN_PAYLOAD - /* - * Some will argue that this increases memory footprint, but it's not - * actually true. Point is that malloc has to return at least 64-bit aligned - * pointers, meaning that allocating 5 bytes wastes 3 bytes in either case. - * Suggested pre-gaping simply moves these wasted bytes from the end of - * allocated region to its front, but makes data payload aligned, which - * improves performance:-) - */ -# define SSL3_ALIGN_PAYLOAD 8 -# else -# if (SSL3_ALIGN_PAYLOAD&(SSL3_ALIGN_PAYLOAD-1))!=0 -# error "insane SSL3_ALIGN_PAYLOAD" -# undef SSL3_ALIGN_PAYLOAD -# endif -# endif - -/* - * This is the maximum MAC (digest) size used by the SSL library. Currently - * maximum of 20 is used by SHA1, but we reserve for future extension for - * 512-bit hashes. - */ - -# define SSL3_RT_MAX_MD_SIZE 64 - -/* - * Maximum block size used in all ciphersuites. Currently 16 for AES. - */ - -# define SSL_RT_MAX_CIPHER_BLOCK_SIZE 16 - -# define SSL3_RT_MAX_EXTRA (16384) - -/* Maximum plaintext length: defined by SSL/TLS standards */ -# define SSL3_RT_MAX_PLAIN_LENGTH 16384 -/* Maximum compression overhead: defined by SSL/TLS standards */ -# define SSL3_RT_MAX_COMPRESSED_OVERHEAD 1024 - -/* - * The standards give a maximum encryption overhead of 1024 bytes. In - * practice the value is lower than this. The overhead is the maximum number - * of padding bytes (256) plus the mac size. - */ -# define SSL3_RT_MAX_ENCRYPTED_OVERHEAD (256 + SSL3_RT_MAX_MD_SIZE) - -/* - * OpenSSL currently only uses a padding length of at most one block so the - * send overhead is smaller. - */ - -# define SSL3_RT_SEND_MAX_ENCRYPTED_OVERHEAD \ - (SSL_RT_MAX_CIPHER_BLOCK_SIZE + SSL3_RT_MAX_MD_SIZE) - -/* If compression isn't used don't include the compression overhead */ - -# ifdef OPENSSL_NO_COMP -# define SSL3_RT_MAX_COMPRESSED_LENGTH SSL3_RT_MAX_PLAIN_LENGTH -# else -# define SSL3_RT_MAX_COMPRESSED_LENGTH \ - (SSL3_RT_MAX_PLAIN_LENGTH+SSL3_RT_MAX_COMPRESSED_OVERHEAD) -# endif -# define SSL3_RT_MAX_ENCRYPTED_LENGTH \ - (SSL3_RT_MAX_ENCRYPTED_OVERHEAD+SSL3_RT_MAX_COMPRESSED_LENGTH) -# define SSL3_RT_MAX_PACKET_SIZE \ - (SSL3_RT_MAX_ENCRYPTED_LENGTH+SSL3_RT_HEADER_LENGTH) - -# define SSL3_MD_CLIENT_FINISHED_CONST "\x43\x4C\x4E\x54" -# define SSL3_MD_SERVER_FINISHED_CONST "\x53\x52\x56\x52" - -# define SSL3_VERSION 0x0300 -# define SSL3_VERSION_MAJOR 0x03 -# define SSL3_VERSION_MINOR 0x00 - -# define SSL3_RT_CHANGE_CIPHER_SPEC 20 -# define SSL3_RT_ALERT 21 -# define SSL3_RT_HANDSHAKE 22 -# define SSL3_RT_APPLICATION_DATA 23 -# define DTLS1_RT_HEARTBEAT 24 - -/* Pseudo content types to indicate additional parameters */ -# define TLS1_RT_CRYPTO 0x1000 -# define TLS1_RT_CRYPTO_PREMASTER (TLS1_RT_CRYPTO | 0x1) -# define TLS1_RT_CRYPTO_CLIENT_RANDOM (TLS1_RT_CRYPTO | 0x2) -# define TLS1_RT_CRYPTO_SERVER_RANDOM (TLS1_RT_CRYPTO | 0x3) -# define TLS1_RT_CRYPTO_MASTER (TLS1_RT_CRYPTO | 0x4) - -# define TLS1_RT_CRYPTO_READ 0x0000 -# define TLS1_RT_CRYPTO_WRITE 0x0100 -# define TLS1_RT_CRYPTO_MAC (TLS1_RT_CRYPTO | 0x5) -# define TLS1_RT_CRYPTO_KEY (TLS1_RT_CRYPTO | 0x6) -# define TLS1_RT_CRYPTO_IV (TLS1_RT_CRYPTO | 0x7) -# define TLS1_RT_CRYPTO_FIXED_IV (TLS1_RT_CRYPTO | 0x8) - -/* Pseudo content type for SSL/TLS header info */ -# define SSL3_RT_HEADER 0x100 - -# define SSL3_AL_WARNING 1 -# define SSL3_AL_FATAL 2 - -# define SSL3_AD_CLOSE_NOTIFY 0 -# define SSL3_AD_UNEXPECTED_MESSAGE 10/* fatal */ -# define SSL3_AD_BAD_RECORD_MAC 20/* fatal */ -# define SSL3_AD_DECOMPRESSION_FAILURE 30/* fatal */ -# define SSL3_AD_HANDSHAKE_FAILURE 40/* fatal */ -# define SSL3_AD_NO_CERTIFICATE 41 -# define SSL3_AD_BAD_CERTIFICATE 42 -# define SSL3_AD_UNSUPPORTED_CERTIFICATE 43 -# define SSL3_AD_CERTIFICATE_REVOKED 44 -# define SSL3_AD_CERTIFICATE_EXPIRED 45 -# define SSL3_AD_CERTIFICATE_UNKNOWN 46 -# define SSL3_AD_ILLEGAL_PARAMETER 47/* fatal */ - -# define TLS1_HB_REQUEST 1 -# define TLS1_HB_RESPONSE 2 - - -# define SSL3_CT_RSA_SIGN 1 -# define SSL3_CT_DSS_SIGN 2 -# define SSL3_CT_RSA_FIXED_DH 3 -# define SSL3_CT_DSS_FIXED_DH 4 -# define SSL3_CT_RSA_EPHEMERAL_DH 5 -# define SSL3_CT_DSS_EPHEMERAL_DH 6 -# define SSL3_CT_FORTEZZA_DMS 20 -/* - * SSL3_CT_NUMBER is used to size arrays and it must be large enough to - * contain all of the cert types defined either for SSLv3 and TLSv1. - */ -# define SSL3_CT_NUMBER 9 - -# define SSL3_FLAGS_NO_RENEGOTIATE_CIPHERS 0x0001 - -/* Removed from OpenSSL 1.1.0 */ -# define TLS1_FLAGS_TLS_PADDING_BUG 0x0 - -# define TLS1_FLAGS_SKIP_CERT_VERIFY 0x0010 - -/* Set if we encrypt then mac instead of usual mac then encrypt */ -# define TLS1_FLAGS_ENCRYPT_THEN_MAC 0x0100 - -/* Set if extended master secret extension received from peer */ -# define TLS1_FLAGS_RECEIVED_EXTMS 0x0200 - -# define SSL3_MT_HELLO_REQUEST 0 -# define SSL3_MT_CLIENT_HELLO 1 -# define SSL3_MT_SERVER_HELLO 2 -# define SSL3_MT_NEWSESSION_TICKET 4 -# define SSL3_MT_CERTIFICATE 11 -# define SSL3_MT_SERVER_KEY_EXCHANGE 12 -# define SSL3_MT_CERTIFICATE_REQUEST 13 -# define SSL3_MT_SERVER_DONE 14 -# define SSL3_MT_CERTIFICATE_VERIFY 15 -# define SSL3_MT_CLIENT_KEY_EXCHANGE 16 -# define SSL3_MT_FINISHED 20 -# define SSL3_MT_CERTIFICATE_STATUS 22 -# ifndef OPENSSL_NO_NEXTPROTONEG -# define SSL3_MT_NEXT_PROTO 67 -# endif -# define DTLS1_MT_HELLO_VERIFY_REQUEST 3 - -/* Dummy message type for handling CCS like a normal handshake message */ -# define SSL3_MT_CHANGE_CIPHER_SPEC 0x0101 - -# define SSL3_MT_CCS 1 - -/* These are used when changing over to a new cipher */ -# define SSL3_CC_READ 0x01 -# define SSL3_CC_WRITE 0x02 -# define SSL3_CC_CLIENT 0x10 -# define SSL3_CC_SERVER 0x20 -# define SSL3_CHANGE_CIPHER_CLIENT_WRITE (SSL3_CC_CLIENT|SSL3_CC_WRITE) -# define SSL3_CHANGE_CIPHER_SERVER_READ (SSL3_CC_SERVER|SSL3_CC_READ) -# define SSL3_CHANGE_CIPHER_CLIENT_READ (SSL3_CC_CLIENT|SSL3_CC_READ) -# define SSL3_CHANGE_CIPHER_SERVER_WRITE (SSL3_CC_SERVER|SSL3_CC_WRITE) - -#ifdef __cplusplus -} -#endif -#endif diff --git a/android/armeabi/include/openssl/stack.h b/android/armeabi/include/openssl/stack.h deleted file mode 100644 index 23ad3b89..00000000 --- a/android/armeabi/include/openssl/stack.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_STACK_H -# define HEADER_STACK_H - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct stack_st OPENSSL_STACK; /* Use STACK_OF(...) instead */ - -typedef int (*OPENSSL_sk_compfunc)(const void *, const void *); -typedef void (*OPENSSL_sk_freefunc)(void *); -typedef void *(*OPENSSL_sk_copyfunc)(const void *); - -int OPENSSL_sk_num(const OPENSSL_STACK *); -void *OPENSSL_sk_value(const OPENSSL_STACK *, int); - -void *OPENSSL_sk_set(OPENSSL_STACK *st, int i, const void *data); - -OPENSSL_STACK *OPENSSL_sk_new(OPENSSL_sk_compfunc cmp); -OPENSSL_STACK *OPENSSL_sk_new_null(void); -void OPENSSL_sk_free(OPENSSL_STACK *); -void OPENSSL_sk_pop_free(OPENSSL_STACK *st, void (*func) (void *)); -OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *, OPENSSL_sk_copyfunc c, OPENSSL_sk_freefunc f); -int OPENSSL_sk_insert(OPENSSL_STACK *sk, const void *data, int where); -void *OPENSSL_sk_delete(OPENSSL_STACK *st, int loc); -void *OPENSSL_sk_delete_ptr(OPENSSL_STACK *st, const void *p); -int OPENSSL_sk_find(OPENSSL_STACK *st, const void *data); -int OPENSSL_sk_find_ex(OPENSSL_STACK *st, const void *data); -int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data); -int OPENSSL_sk_unshift(OPENSSL_STACK *st, const void *data); -void *OPENSSL_sk_shift(OPENSSL_STACK *st); -void *OPENSSL_sk_pop(OPENSSL_STACK *st); -void OPENSSL_sk_zero(OPENSSL_STACK *st); -OPENSSL_sk_compfunc OPENSSL_sk_set_cmp_func(OPENSSL_STACK *sk, OPENSSL_sk_compfunc cmp); -OPENSSL_STACK *OPENSSL_sk_dup(const OPENSSL_STACK *st); -void OPENSSL_sk_sort(OPENSSL_STACK *st); -int OPENSSL_sk_is_sorted(const OPENSSL_STACK *st); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define _STACK OPENSSL_STACK -# define sk_num OPENSSL_sk_num -# define sk_value OPENSSL_sk_value -# define sk_set OPENSSL_sk_set -# define sk_new OPENSSL_sk_new -# define sk_new_null OPENSSL_sk_new_null -# define sk_free OPENSSL_sk_free -# define sk_pop_free OPENSSL_sk_pop_free -# define sk_deep_copy OPENSSL_sk_deep_copy -# define sk_insert OPENSSL_sk_insert -# define sk_delete OPENSSL_sk_delete -# define sk_delete_ptr OPENSSL_sk_delete_ptr -# define sk_find OPENSSL_sk_find -# define sk_find_ex OPENSSL_sk_find_ex -# define sk_push OPENSSL_sk_push -# define sk_unshift OPENSSL_sk_unshift -# define sk_shift OPENSSL_sk_shift -# define sk_pop OPENSSL_sk_pop -# define sk_zero OPENSSL_sk_zero -# define sk_set_cmp_func OPENSSL_sk_set_cmp_func -# define sk_dup OPENSSL_sk_dup -# define sk_sort OPENSSL_sk_sort -# define sk_is_sorted OPENSSL_sk_is_sorted -# endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android/armeabi/include/openssl/symhacks.h b/android/armeabi/include/openssl/symhacks.h deleted file mode 100644 index caf1f1a7..00000000 --- a/android/armeabi/include/openssl/symhacks.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_SYMHACKS_H -# define HEADER_SYMHACKS_H - -# include <openssl/e_os2.h> - -/* Case insensitive linking causes problems.... */ -# if defined(OPENSSL_SYS_VMS) -# undef ERR_load_CRYPTO_strings -# define ERR_load_CRYPTO_strings ERR_load_CRYPTOlib_strings -# undef OCSP_crlID_new -# define OCSP_crlID_new OCSP_crlID2_new - -# undef d2i_ECPARAMETERS -# define d2i_ECPARAMETERS d2i_UC_ECPARAMETERS -# undef i2d_ECPARAMETERS -# define i2d_ECPARAMETERS i2d_UC_ECPARAMETERS -# undef d2i_ECPKPARAMETERS -# define d2i_ECPKPARAMETERS d2i_UC_ECPKPARAMETERS -# undef i2d_ECPKPARAMETERS -# define i2d_ECPKPARAMETERS i2d_UC_ECPKPARAMETERS - -/* - * These functions do not seem to exist! However, I'm paranoid... Original - * command in x509v3.h: These functions are being redefined in another - * directory, and clash when the linker is case-insensitive, so let's hide - * them a little, by giving them an extra 'o' at the beginning of the name... - */ -# undef X509v3_cleanup_extensions -# define X509v3_cleanup_extensions oX509v3_cleanup_extensions -# undef X509v3_add_extension -# define X509v3_add_extension oX509v3_add_extension -# undef X509v3_add_netscape_extensions -# define X509v3_add_netscape_extensions oX509v3_add_netscape_extensions -# undef X509v3_add_standard_extensions -# define X509v3_add_standard_extensions oX509v3_add_standard_extensions - -/* This one clashes with CMS_data_create */ -# undef cms_Data_create -# define cms_Data_create priv_cms_Data_create - -# endif - -#endif /* ! defined HEADER_VMS_IDHACKS_H */ diff --git a/android/armeabi/include/openssl/tls1.h b/android/armeabi/include/openssl/tls1.h deleted file mode 100644 index 23e382cd..00000000 --- a/android/armeabi/include/openssl/tls1.h +++ /dev/null @@ -1,972 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * - * Portions of the attached software ("Contribution") are developed by - * SUN MICROSYSTEMS, INC., and are contributed to the OpenSSL project. - * - * The Contribution is licensed pursuant to the OpenSSL open source - * license provided above. - * - * ECC cipher suite support in OpenSSL originally written by - * Vipul Gupta and Sumit Gupta of Sun Microsystems Laboratories. - * - */ -/* ==================================================================== - * Copyright 2005 Nokia. All rights reserved. - * - * The portions of the attached software ("Contribution") is developed by - * Nokia Corporation and is licensed pursuant to the OpenSSL open source - * license. - * - * The Contribution, originally written by Mika Kousa and Pasi Eronen of - * Nokia Corporation, consists of the "PSK" (Pre-Shared Key) ciphersuites - * support (see RFC 4279) to OpenSSL. - * - * No patent licenses or other rights except those expressly stated in - * the OpenSSL open source license shall be deemed granted or received - * expressly, by implication, estoppel, or otherwise. - * - * No assurances are provided by Nokia that the Contribution does not - * infringe the patent or other intellectual property rights of any third - * party or that the license provides you with all the necessary rights - * to make use of the Contribution. - * - * THE SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. IN - * ADDITION TO THE DISCLAIMERS INCLUDED IN THE LICENSE, NOKIA - * SPECIFICALLY DISCLAIMS ANY LIABILITY FOR CLAIMS BROUGHT BY YOU OR ANY - * OTHER ENTITY BASED ON INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS OR - * OTHERWISE. - */ - -#ifndef HEADER_TLS1_H -# define HEADER_TLS1_H - -# include <openssl/buffer.h> -# include <openssl/x509.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* Default security level if not overridden at config time */ -# ifndef OPENSSL_TLS_SECURITY_LEVEL -# define OPENSSL_TLS_SECURITY_LEVEL 1 -# endif - -# define TLS1_VERSION 0x0301 -# define TLS1_1_VERSION 0x0302 -# define TLS1_2_VERSION 0x0303 -# define TLS_MAX_VERSION TLS1_2_VERSION - -/* Special value for method supporting multiple versions */ -# define TLS_ANY_VERSION 0x10000 - -# define TLS1_VERSION_MAJOR 0x03 -# define TLS1_VERSION_MINOR 0x01 - -# define TLS1_1_VERSION_MAJOR 0x03 -# define TLS1_1_VERSION_MINOR 0x02 - -# define TLS1_2_VERSION_MAJOR 0x03 -# define TLS1_2_VERSION_MINOR 0x03 - -# define TLS1_get_version(s) \ - ((SSL_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_version(s) : 0) - -# define TLS1_get_client_version(s) \ - ((SSL_client_version(s) >> 8) == TLS1_VERSION_MAJOR ? SSL_client_version(s) : 0) - -# define TLS1_AD_DECRYPTION_FAILED 21 -# define TLS1_AD_RECORD_OVERFLOW 22 -# define TLS1_AD_UNKNOWN_CA 48/* fatal */ -# define TLS1_AD_ACCESS_DENIED 49/* fatal */ -# define TLS1_AD_DECODE_ERROR 50/* fatal */ -# define TLS1_AD_DECRYPT_ERROR 51 -# define TLS1_AD_EXPORT_RESTRICTION 60/* fatal */ -# define TLS1_AD_PROTOCOL_VERSION 70/* fatal */ -# define TLS1_AD_INSUFFICIENT_SECURITY 71/* fatal */ -# define TLS1_AD_INTERNAL_ERROR 80/* fatal */ -# define TLS1_AD_INAPPROPRIATE_FALLBACK 86/* fatal */ -# define TLS1_AD_USER_CANCELLED 90 -# define TLS1_AD_NO_RENEGOTIATION 100 -/* codes 110-114 are from RFC3546 */ -# define TLS1_AD_UNSUPPORTED_EXTENSION 110 -# define TLS1_AD_CERTIFICATE_UNOBTAINABLE 111 -# define TLS1_AD_UNRECOGNIZED_NAME 112 -# define TLS1_AD_BAD_CERTIFICATE_STATUS_RESPONSE 113 -# define TLS1_AD_BAD_CERTIFICATE_HASH_VALUE 114 -# define TLS1_AD_UNKNOWN_PSK_IDENTITY 115/* fatal */ -# define TLS1_AD_NO_APPLICATION_PROTOCOL 120 /* fatal */ - -/* ExtensionType values from RFC3546 / RFC4366 / RFC6066 */ -# define TLSEXT_TYPE_server_name 0 -# define TLSEXT_TYPE_max_fragment_length 1 -# define TLSEXT_TYPE_client_certificate_url 2 -# define TLSEXT_TYPE_trusted_ca_keys 3 -# define TLSEXT_TYPE_truncated_hmac 4 -# define TLSEXT_TYPE_status_request 5 -/* ExtensionType values from RFC4681 */ -# define TLSEXT_TYPE_user_mapping 6 -/* ExtensionType values from RFC5878 */ -# define TLSEXT_TYPE_client_authz 7 -# define TLSEXT_TYPE_server_authz 8 -/* ExtensionType values from RFC6091 */ -# define TLSEXT_TYPE_cert_type 9 - -/* ExtensionType values from RFC4492 */ -# define TLSEXT_TYPE_elliptic_curves 10 -# define TLSEXT_TYPE_ec_point_formats 11 - -/* ExtensionType value from RFC5054 */ -# define TLSEXT_TYPE_srp 12 - -/* ExtensionType values from RFC5246 */ -# define TLSEXT_TYPE_signature_algorithms 13 - -/* ExtensionType value from RFC5764 */ -# define TLSEXT_TYPE_use_srtp 14 - -/* ExtensionType value from RFC5620 */ -# define TLSEXT_TYPE_heartbeat 15 - -/* ExtensionType value from RFC7301 */ -# define TLSEXT_TYPE_application_layer_protocol_negotiation 16 - -/* - * Extension type for Certificate Transparency - * https://tools.ietf.org/html/rfc6962#section-3.3.1 - */ -# define TLSEXT_TYPE_signed_certificate_timestamp 18 - -/* - * ExtensionType value for TLS padding extension. - * http://tools.ietf.org/html/draft-agl-tls-padding - */ -# define TLSEXT_TYPE_padding 21 - -/* ExtensionType value from RFC7366 */ -# define TLSEXT_TYPE_encrypt_then_mac 22 - -/* ExtensionType value from RFC7627 */ -# define TLSEXT_TYPE_extended_master_secret 23 - -/* ExtensionType value from RFC4507 */ -# define TLSEXT_TYPE_session_ticket 35 - -/* Temporary extension type */ -# define TLSEXT_TYPE_renegotiate 0xff01 - -# ifndef OPENSSL_NO_NEXTPROTONEG -/* This is not an IANA defined extension number */ -# define TLSEXT_TYPE_next_proto_neg 13172 -# endif - -/* NameType value from RFC3546 */ -# define TLSEXT_NAMETYPE_host_name 0 -/* status request value from RFC3546 */ -# define TLSEXT_STATUSTYPE_ocsp 1 - -/* ECPointFormat values from RFC4492 */ -# define TLSEXT_ECPOINTFORMAT_first 0 -# define TLSEXT_ECPOINTFORMAT_uncompressed 0 -# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_prime 1 -# define TLSEXT_ECPOINTFORMAT_ansiX962_compressed_char2 2 -# define TLSEXT_ECPOINTFORMAT_last 2 - -/* Signature and hash algorithms from RFC5246 */ -# define TLSEXT_signature_anonymous 0 -# define TLSEXT_signature_rsa 1 -# define TLSEXT_signature_dsa 2 -# define TLSEXT_signature_ecdsa 3 -# define TLSEXT_signature_gostr34102001 237 -# define TLSEXT_signature_gostr34102012_256 238 -# define TLSEXT_signature_gostr34102012_512 239 - -/* Total number of different signature algorithms */ -# define TLSEXT_signature_num 7 - -# define TLSEXT_hash_none 0 -# define TLSEXT_hash_md5 1 -# define TLSEXT_hash_sha1 2 -# define TLSEXT_hash_sha224 3 -# define TLSEXT_hash_sha256 4 -# define TLSEXT_hash_sha384 5 -# define TLSEXT_hash_sha512 6 -# define TLSEXT_hash_gostr3411 237 -# define TLSEXT_hash_gostr34112012_256 238 -# define TLSEXT_hash_gostr34112012_512 239 - -/* Total number of different digest algorithms */ - -# define TLSEXT_hash_num 10 - -/* Flag set for unrecognised algorithms */ -# define TLSEXT_nid_unknown 0x1000000 - -/* ECC curves */ - -# define TLSEXT_curve_P_256 23 -# define TLSEXT_curve_P_384 24 - -# define TLSEXT_MAXLEN_host_name 255 - -__owur const char *SSL_get_servername(const SSL *s, const int type); -__owur int SSL_get_servername_type(const SSL *s); -/* - * SSL_export_keying_material exports a value derived from the master secret, - * as specified in RFC 5705. It writes |olen| bytes to |out| given a label and - * optional context. (Since a zero length context is allowed, the |use_context| - * flag controls whether a context is included.) It returns 1 on success and - * zero otherwise. - */ -__owur int SSL_export_keying_material(SSL *s, unsigned char *out, size_t olen, - const char *label, size_t llen, - const unsigned char *p, size_t plen, - int use_context); - -int SSL_get_sigalgs(SSL *s, int idx, - int *psign, int *phash, int *psignandhash, - unsigned char *rsig, unsigned char *rhash); - -int SSL_get_shared_sigalgs(SSL *s, int idx, - int *psign, int *phash, int *psignandhash, - unsigned char *rsig, unsigned char *rhash); - -__owur int SSL_check_chain(SSL *s, X509 *x, EVP_PKEY *pk, STACK_OF(X509) *chain); - -# define SSL_set_tlsext_host_name(s,name) \ -SSL_ctrl(s,SSL_CTRL_SET_TLSEXT_HOSTNAME,TLSEXT_NAMETYPE_host_name,(char *)name) - -# define SSL_set_tlsext_debug_callback(ssl, cb) \ -SSL_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_CB,(void (*)(void))cb) - -# define SSL_set_tlsext_debug_arg(ssl, arg) \ -SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_DEBUG_ARG,0, (void *)arg) - -# define SSL_get_tlsext_status_type(ssl) \ -SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE,0, NULL) - -# define SSL_set_tlsext_status_type(ssl, type) \ -SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE,type, NULL) - -# define SSL_get_tlsext_status_exts(ssl, arg) \ -SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg) - -# define SSL_set_tlsext_status_exts(ssl, arg) \ -SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_EXTS,0, (void *)arg) - -# define SSL_get_tlsext_status_ids(ssl, arg) \ -SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg) - -# define SSL_set_tlsext_status_ids(ssl, arg) \ -SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_IDS,0, (void *)arg) - -# define SSL_get_tlsext_status_ocsp_resp(ssl, arg) \ -SSL_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_OCSP_RESP,0, (void *)arg) - -# define SSL_set_tlsext_status_ocsp_resp(ssl, arg, arglen) \ -SSL_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_OCSP_RESP,arglen, (void *)arg) - -# define SSL_CTX_set_tlsext_servername_callback(ctx, cb) \ -SSL_CTX_callback_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_CB,(void (*)(void))cb) - -# define SSL_TLSEXT_ERR_OK 0 -# define SSL_TLSEXT_ERR_ALERT_WARNING 1 -# define SSL_TLSEXT_ERR_ALERT_FATAL 2 -# define SSL_TLSEXT_ERR_NOACK 3 - -# define SSL_CTX_set_tlsext_servername_arg(ctx, arg) \ -SSL_CTX_ctrl(ctx,SSL_CTRL_SET_TLSEXT_SERVERNAME_ARG,0, (void *)arg) - -# define SSL_CTX_get_tlsext_ticket_keys(ctx, keys, keylen) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_GET_TLSEXT_TICKET_KEYS,(keylen),(keys)) -# define SSL_CTX_set_tlsext_ticket_keys(ctx, keys, keylen) \ - SSL_CTX_ctrl((ctx),SSL_CTRL_SET_TLSEXT_TICKET_KEYS,(keylen),(keys)) - -# define SSL_CTX_get_tlsext_status_cb(ssl, cb) \ -SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB,0, (void (**)(void))cb) -# define SSL_CTX_set_tlsext_status_cb(ssl, cb) \ -SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB,(void (*)(void))cb) - -# define SSL_CTX_get_tlsext_status_arg(ssl, arg) \ -SSL_CTX_ctrl(ssl,SSL_CTRL_GET_TLSEXT_STATUS_REQ_CB_ARG,0, (void *)arg -# define SSL_CTX_set_tlsext_status_arg(ssl, arg) \ -SSL_CTX_ctrl(ssl,SSL_CTRL_SET_TLSEXT_STATUS_REQ_CB_ARG,0, (void *)arg) - -#define SSL_CTX_set_tlsext_status_type(ssl, type) \ - SSL_CTX_ctrl(ssl, SSL_CTRL_SET_TLSEXT_STATUS_REQ_TYPE, type, NULL) - -#define SSL_CTX_get_tlsext_status_type(ssl) \ - SSL_CTX_ctrl(ssl, SSL_CTRL_GET_TLSEXT_STATUS_REQ_TYPE, 0, NULL) - -# define SSL_CTX_set_tlsext_ticket_key_cb(ssl, cb) \ -SSL_CTX_callback_ctrl(ssl,SSL_CTRL_SET_TLSEXT_TICKET_KEY_CB,(void (*)(void))cb) - -# ifndef OPENSSL_NO_HEARTBEATS -# define SSL_DTLSEXT_HB_ENABLED 0x01 -# define SSL_DTLSEXT_HB_DONT_SEND_REQUESTS 0x02 -# define SSL_DTLSEXT_HB_DONT_RECV_REQUESTS 0x04 -# define SSL_get_dtlsext_heartbeat_pending(ssl) \ - SSL_ctrl((ssl),SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING,0,NULL) -# define SSL_set_dtlsext_heartbeat_no_requests(ssl, arg) \ - SSL_ctrl((ssl),SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS,arg,NULL) - -# if OPENSSL_API_COMPAT < 0x10100000L -# define SSL_CTRL_TLS_EXT_SEND_HEARTBEAT \ - SSL_CTRL_DTLS_EXT_SEND_HEARTBEAT -# define SSL_CTRL_GET_TLS_EXT_HEARTBEAT_PENDING \ - SSL_CTRL_GET_DTLS_EXT_HEARTBEAT_PENDING -# define SSL_CTRL_SET_TLS_EXT_HEARTBEAT_NO_REQUESTS \ - SSL_CTRL_SET_DTLS_EXT_HEARTBEAT_NO_REQUESTS -# define SSL_TLSEXT_HB_ENABLED \ - SSL_DTLSEXT_HB_ENABLED -# define SSL_TLSEXT_HB_DONT_SEND_REQUESTS \ - SSL_DTLSEXT_HB_DONT_SEND_REQUESTS -# define SSL_TLSEXT_HB_DONT_RECV_REQUESTS \ - SSL_DTLSEXT_HB_DONT_RECV_REQUESTS -# define SSL_get_tlsext_heartbeat_pending(ssl) \ - SSL_get_dtlsext_heartbeat_pending(ssl) -# define SSL_set_tlsext_heartbeat_no_requests(ssl, arg) \ - SSL_set_dtlsext_heartbeat_no_requests(ssl, arg) -# endif -# endif - -/* PSK ciphersuites from 4279 */ -# define TLS1_CK_PSK_WITH_RC4_128_SHA 0x0300008A -# define TLS1_CK_PSK_WITH_3DES_EDE_CBC_SHA 0x0300008B -# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA 0x0300008C -# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA 0x0300008D - -# define TLS1_CK_DHE_PSK_WITH_RC4_128_SHA 0x0300008E -# define TLS1_CK_DHE_PSK_WITH_3DES_EDE_CBC_SHA 0x0300008F -# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA 0x03000090 -# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA 0x03000091 - -# define TLS1_CK_RSA_PSK_WITH_RC4_128_SHA 0x03000092 -# define TLS1_CK_RSA_PSK_WITH_3DES_EDE_CBC_SHA 0x03000093 -# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA 0x03000094 -# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA 0x03000095 - -/* PSK ciphersuites from 5487 */ -# define TLS1_CK_PSK_WITH_AES_128_GCM_SHA256 0x030000A8 -# define TLS1_CK_PSK_WITH_AES_256_GCM_SHA384 0x030000A9 -# define TLS1_CK_DHE_PSK_WITH_AES_128_GCM_SHA256 0x030000AA -# define TLS1_CK_DHE_PSK_WITH_AES_256_GCM_SHA384 0x030000AB -# define TLS1_CK_RSA_PSK_WITH_AES_128_GCM_SHA256 0x030000AC -# define TLS1_CK_RSA_PSK_WITH_AES_256_GCM_SHA384 0x030000AD - -# define TLS1_CK_PSK_WITH_AES_128_CBC_SHA256 0x030000AE -# define TLS1_CK_PSK_WITH_AES_256_CBC_SHA384 0x030000AF -# define TLS1_CK_PSK_WITH_NULL_SHA256 0x030000B0 -# define TLS1_CK_PSK_WITH_NULL_SHA384 0x030000B1 - -# define TLS1_CK_DHE_PSK_WITH_AES_128_CBC_SHA256 0x030000B2 -# define TLS1_CK_DHE_PSK_WITH_AES_256_CBC_SHA384 0x030000B3 -# define TLS1_CK_DHE_PSK_WITH_NULL_SHA256 0x030000B4 -# define TLS1_CK_DHE_PSK_WITH_NULL_SHA384 0x030000B5 - -# define TLS1_CK_RSA_PSK_WITH_AES_128_CBC_SHA256 0x030000B6 -# define TLS1_CK_RSA_PSK_WITH_AES_256_CBC_SHA384 0x030000B7 -# define TLS1_CK_RSA_PSK_WITH_NULL_SHA256 0x030000B8 -# define TLS1_CK_RSA_PSK_WITH_NULL_SHA384 0x030000B9 - -/* NULL PSK ciphersuites from RFC4785 */ -# define TLS1_CK_PSK_WITH_NULL_SHA 0x0300002C -# define TLS1_CK_DHE_PSK_WITH_NULL_SHA 0x0300002D -# define TLS1_CK_RSA_PSK_WITH_NULL_SHA 0x0300002E - -/* AES ciphersuites from RFC3268 */ -# define TLS1_CK_RSA_WITH_AES_128_SHA 0x0300002F -# define TLS1_CK_DH_DSS_WITH_AES_128_SHA 0x03000030 -# define TLS1_CK_DH_RSA_WITH_AES_128_SHA 0x03000031 -# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA 0x03000032 -# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA 0x03000033 -# define TLS1_CK_ADH_WITH_AES_128_SHA 0x03000034 - -# define TLS1_CK_RSA_WITH_AES_256_SHA 0x03000035 -# define TLS1_CK_DH_DSS_WITH_AES_256_SHA 0x03000036 -# define TLS1_CK_DH_RSA_WITH_AES_256_SHA 0x03000037 -# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA 0x03000038 -# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA 0x03000039 -# define TLS1_CK_ADH_WITH_AES_256_SHA 0x0300003A - -/* TLS v1.2 ciphersuites */ -# define TLS1_CK_RSA_WITH_NULL_SHA256 0x0300003B -# define TLS1_CK_RSA_WITH_AES_128_SHA256 0x0300003C -# define TLS1_CK_RSA_WITH_AES_256_SHA256 0x0300003D -# define TLS1_CK_DH_DSS_WITH_AES_128_SHA256 0x0300003E -# define TLS1_CK_DH_RSA_WITH_AES_128_SHA256 0x0300003F -# define TLS1_CK_DHE_DSS_WITH_AES_128_SHA256 0x03000040 - -/* Camellia ciphersuites from RFC4132 */ -# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000041 -# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000042 -# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000043 -# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA 0x03000044 -# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA 0x03000045 -# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA 0x03000046 - -/* TLS v1.2 ciphersuites */ -# define TLS1_CK_DHE_RSA_WITH_AES_128_SHA256 0x03000067 -# define TLS1_CK_DH_DSS_WITH_AES_256_SHA256 0x03000068 -# define TLS1_CK_DH_RSA_WITH_AES_256_SHA256 0x03000069 -# define TLS1_CK_DHE_DSS_WITH_AES_256_SHA256 0x0300006A -# define TLS1_CK_DHE_RSA_WITH_AES_256_SHA256 0x0300006B -# define TLS1_CK_ADH_WITH_AES_128_SHA256 0x0300006C -# define TLS1_CK_ADH_WITH_AES_256_SHA256 0x0300006D - -/* Camellia ciphersuites from RFC4132 */ -# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000084 -# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000085 -# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000086 -# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA 0x03000087 -# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA 0x03000088 -# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA 0x03000089 - -/* SEED ciphersuites from RFC4162 */ -# define TLS1_CK_RSA_WITH_SEED_SHA 0x03000096 -# define TLS1_CK_DH_DSS_WITH_SEED_SHA 0x03000097 -# define TLS1_CK_DH_RSA_WITH_SEED_SHA 0x03000098 -# define TLS1_CK_DHE_DSS_WITH_SEED_SHA 0x03000099 -# define TLS1_CK_DHE_RSA_WITH_SEED_SHA 0x0300009A -# define TLS1_CK_ADH_WITH_SEED_SHA 0x0300009B - -/* TLS v1.2 GCM ciphersuites from RFC5288 */ -# define TLS1_CK_RSA_WITH_AES_128_GCM_SHA256 0x0300009C -# define TLS1_CK_RSA_WITH_AES_256_GCM_SHA384 0x0300009D -# define TLS1_CK_DHE_RSA_WITH_AES_128_GCM_SHA256 0x0300009E -# define TLS1_CK_DHE_RSA_WITH_AES_256_GCM_SHA384 0x0300009F -# define TLS1_CK_DH_RSA_WITH_AES_128_GCM_SHA256 0x030000A0 -# define TLS1_CK_DH_RSA_WITH_AES_256_GCM_SHA384 0x030000A1 -# define TLS1_CK_DHE_DSS_WITH_AES_128_GCM_SHA256 0x030000A2 -# define TLS1_CK_DHE_DSS_WITH_AES_256_GCM_SHA384 0x030000A3 -# define TLS1_CK_DH_DSS_WITH_AES_128_GCM_SHA256 0x030000A4 -# define TLS1_CK_DH_DSS_WITH_AES_256_GCM_SHA384 0x030000A5 -# define TLS1_CK_ADH_WITH_AES_128_GCM_SHA256 0x030000A6 -# define TLS1_CK_ADH_WITH_AES_256_GCM_SHA384 0x030000A7 - -/* CCM ciphersuites from RFC6655 */ -# define TLS1_CK_RSA_WITH_AES_128_CCM 0x0300C09C -# define TLS1_CK_RSA_WITH_AES_256_CCM 0x0300C09D -# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM 0x0300C09E -# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM 0x0300C09F -# define TLS1_CK_RSA_WITH_AES_128_CCM_8 0x0300C0A0 -# define TLS1_CK_RSA_WITH_AES_256_CCM_8 0x0300C0A1 -# define TLS1_CK_DHE_RSA_WITH_AES_128_CCM_8 0x0300C0A2 -# define TLS1_CK_DHE_RSA_WITH_AES_256_CCM_8 0x0300C0A3 -# define TLS1_CK_PSK_WITH_AES_128_CCM 0x0300C0A4 -# define TLS1_CK_PSK_WITH_AES_256_CCM 0x0300C0A5 -# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM 0x0300C0A6 -# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM 0x0300C0A7 -# define TLS1_CK_PSK_WITH_AES_128_CCM_8 0x0300C0A8 -# define TLS1_CK_PSK_WITH_AES_256_CCM_8 0x0300C0A9 -# define TLS1_CK_DHE_PSK_WITH_AES_128_CCM_8 0x0300C0AA -# define TLS1_CK_DHE_PSK_WITH_AES_256_CCM_8 0x0300C0AB - -/* CCM ciphersuites from RFC7251 */ -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM 0x0300C0AC -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM 0x0300C0AD -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CCM_8 0x0300C0AE -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CCM_8 0x0300C0AF - -/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */ -# define TLS1_CK_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BA -# define TLS1_CK_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 0x030000BB -# define TLS1_CK_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BC -# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 0x030000BD -# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x030000BE -# define TLS1_CK_ADH_WITH_CAMELLIA_128_CBC_SHA256 0x030000BF - -# define TLS1_CK_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C0 -# define TLS1_CK_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 0x030000C1 -# define TLS1_CK_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C2 -# define TLS1_CK_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 0x030000C3 -# define TLS1_CK_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 0x030000C4 -# define TLS1_CK_ADH_WITH_CAMELLIA_256_CBC_SHA256 0x030000C5 - -/* ECC ciphersuites from RFC4492 */ -# define TLS1_CK_ECDH_ECDSA_WITH_NULL_SHA 0x0300C001 -# define TLS1_CK_ECDH_ECDSA_WITH_RC4_128_SHA 0x0300C002 -# define TLS1_CK_ECDH_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C003 -# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_CBC_SHA 0x0300C004 -# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_CBC_SHA 0x0300C005 - -# define TLS1_CK_ECDHE_ECDSA_WITH_NULL_SHA 0x0300C006 -# define TLS1_CK_ECDHE_ECDSA_WITH_RC4_128_SHA 0x0300C007 -# define TLS1_CK_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA 0x0300C008 -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_CBC_SHA 0x0300C009 -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_CBC_SHA 0x0300C00A - -# define TLS1_CK_ECDH_RSA_WITH_NULL_SHA 0x0300C00B -# define TLS1_CK_ECDH_RSA_WITH_RC4_128_SHA 0x0300C00C -# define TLS1_CK_ECDH_RSA_WITH_DES_192_CBC3_SHA 0x0300C00D -# define TLS1_CK_ECDH_RSA_WITH_AES_128_CBC_SHA 0x0300C00E -# define TLS1_CK_ECDH_RSA_WITH_AES_256_CBC_SHA 0x0300C00F - -# define TLS1_CK_ECDHE_RSA_WITH_NULL_SHA 0x0300C010 -# define TLS1_CK_ECDHE_RSA_WITH_RC4_128_SHA 0x0300C011 -# define TLS1_CK_ECDHE_RSA_WITH_DES_192_CBC3_SHA 0x0300C012 -# define TLS1_CK_ECDHE_RSA_WITH_AES_128_CBC_SHA 0x0300C013 -# define TLS1_CK_ECDHE_RSA_WITH_AES_256_CBC_SHA 0x0300C014 - -# define TLS1_CK_ECDH_anon_WITH_NULL_SHA 0x0300C015 -# define TLS1_CK_ECDH_anon_WITH_RC4_128_SHA 0x0300C016 -# define TLS1_CK_ECDH_anon_WITH_DES_192_CBC3_SHA 0x0300C017 -# define TLS1_CK_ECDH_anon_WITH_AES_128_CBC_SHA 0x0300C018 -# define TLS1_CK_ECDH_anon_WITH_AES_256_CBC_SHA 0x0300C019 - -/* SRP ciphersuites from RFC 5054 */ -# define TLS1_CK_SRP_SHA_WITH_3DES_EDE_CBC_SHA 0x0300C01A -# define TLS1_CK_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA 0x0300C01B -# define TLS1_CK_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA 0x0300C01C -# define TLS1_CK_SRP_SHA_WITH_AES_128_CBC_SHA 0x0300C01D -# define TLS1_CK_SRP_SHA_RSA_WITH_AES_128_CBC_SHA 0x0300C01E -# define TLS1_CK_SRP_SHA_DSS_WITH_AES_128_CBC_SHA 0x0300C01F -# define TLS1_CK_SRP_SHA_WITH_AES_256_CBC_SHA 0x0300C020 -# define TLS1_CK_SRP_SHA_RSA_WITH_AES_256_CBC_SHA 0x0300C021 -# define TLS1_CK_SRP_SHA_DSS_WITH_AES_256_CBC_SHA 0x0300C022 - -/* ECDH HMAC based ciphersuites from RFC5289 */ - -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_SHA256 0x0300C023 -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_SHA384 0x0300C024 -# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_SHA256 0x0300C025 -# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_SHA384 0x0300C026 -# define TLS1_CK_ECDHE_RSA_WITH_AES_128_SHA256 0x0300C027 -# define TLS1_CK_ECDHE_RSA_WITH_AES_256_SHA384 0x0300C028 -# define TLS1_CK_ECDH_RSA_WITH_AES_128_SHA256 0x0300C029 -# define TLS1_CK_ECDH_RSA_WITH_AES_256_SHA384 0x0300C02A - -/* ECDH GCM based ciphersuites from RFC5289 */ -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02B -# define TLS1_CK_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02C -# define TLS1_CK_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 0x0300C02D -# define TLS1_CK_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 0x0300C02E -# define TLS1_CK_ECDHE_RSA_WITH_AES_128_GCM_SHA256 0x0300C02F -# define TLS1_CK_ECDHE_RSA_WITH_AES_256_GCM_SHA384 0x0300C030 -# define TLS1_CK_ECDH_RSA_WITH_AES_128_GCM_SHA256 0x0300C031 -# define TLS1_CK_ECDH_RSA_WITH_AES_256_GCM_SHA384 0x0300C032 - -/* ECDHE PSK ciphersuites from RFC5489 */ -# define TLS1_CK_ECDHE_PSK_WITH_RC4_128_SHA 0x0300C033 -# define TLS1_CK_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA 0x0300C034 -# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA 0x0300C035 -# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA 0x0300C036 - -# define TLS1_CK_ECDHE_PSK_WITH_AES_128_CBC_SHA256 0x0300C037 -# define TLS1_CK_ECDHE_PSK_WITH_AES_256_CBC_SHA384 0x0300C038 - -/* NULL PSK ciphersuites from RFC4785 */ - -# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA 0x0300C039 -# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA256 0x0300C03A -# define TLS1_CK_ECDHE_PSK_WITH_NULL_SHA384 0x0300C03B - -/* Camellia-CBC ciphersuites from RFC6367 */ -# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C072 -# define TLS1_CK_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C073 -# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C074 -# define TLS1_CK_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C075 -# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C076 -# define TLS1_CK_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C077 -# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 0x0300C078 -# define TLS1_CK_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 0x0300C079 - -# define TLS1_CK_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C094 -# define TLS1_CK_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C095 -# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C096 -# define TLS1_CK_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C097 -# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C098 -# define TLS1_CK_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C099 -# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 0x0300C09A -# define TLS1_CK_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 0x0300C09B - -/* draft-ietf-tls-chacha20-poly1305-03 */ -# define TLS1_CK_ECDHE_RSA_WITH_CHACHA20_POLY1305 0x0300CCA8 -# define TLS1_CK_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 0x0300CCA9 -# define TLS1_CK_DHE_RSA_WITH_CHACHA20_POLY1305 0x0300CCAA -# define TLS1_CK_PSK_WITH_CHACHA20_POLY1305 0x0300CCAB -# define TLS1_CK_ECDHE_PSK_WITH_CHACHA20_POLY1305 0x0300CCAC -# define TLS1_CK_DHE_PSK_WITH_CHACHA20_POLY1305 0x0300CCAD -# define TLS1_CK_RSA_PSK_WITH_CHACHA20_POLY1305 0x0300CCAE - -/* - * XXX Backward compatibility alert: Older versions of OpenSSL gave some DHE - * ciphers names with "EDH" instead of "DHE". Going forward, we should be - * using DHE everywhere, though we may indefinitely maintain aliases for - * users or configurations that used "EDH" - */ -# define TLS1_TXT_DHE_DSS_WITH_RC4_128_SHA "DHE-DSS-RC4-SHA" - -# define TLS1_TXT_PSK_WITH_NULL_SHA "PSK-NULL-SHA" -# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA "DHE-PSK-NULL-SHA" -# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA "RSA-PSK-NULL-SHA" - -/* AES ciphersuites from RFC3268 */ -# define TLS1_TXT_RSA_WITH_AES_128_SHA "AES128-SHA" -# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA "DH-DSS-AES128-SHA" -# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA "DH-RSA-AES128-SHA" -# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA "DHE-DSS-AES128-SHA" -# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA "DHE-RSA-AES128-SHA" -# define TLS1_TXT_ADH_WITH_AES_128_SHA "ADH-AES128-SHA" - -# define TLS1_TXT_RSA_WITH_AES_256_SHA "AES256-SHA" -# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA "DH-DSS-AES256-SHA" -# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA "DH-RSA-AES256-SHA" -# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA "DHE-DSS-AES256-SHA" -# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA "DHE-RSA-AES256-SHA" -# define TLS1_TXT_ADH_WITH_AES_256_SHA "ADH-AES256-SHA" - -/* ECC ciphersuites from RFC4492 */ -# define TLS1_TXT_ECDH_ECDSA_WITH_NULL_SHA "ECDH-ECDSA-NULL-SHA" -# define TLS1_TXT_ECDH_ECDSA_WITH_RC4_128_SHA "ECDH-ECDSA-RC4-SHA" -# define TLS1_TXT_ECDH_ECDSA_WITH_DES_192_CBC3_SHA "ECDH-ECDSA-DES-CBC3-SHA" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_CBC_SHA "ECDH-ECDSA-AES128-SHA" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_CBC_SHA "ECDH-ECDSA-AES256-SHA" - -# define TLS1_TXT_ECDHE_ECDSA_WITH_NULL_SHA "ECDHE-ECDSA-NULL-SHA" -# define TLS1_TXT_ECDHE_ECDSA_WITH_RC4_128_SHA "ECDHE-ECDSA-RC4-SHA" -# define TLS1_TXT_ECDHE_ECDSA_WITH_DES_192_CBC3_SHA "ECDHE-ECDSA-DES-CBC3-SHA" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CBC_SHA "ECDHE-ECDSA-AES128-SHA" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CBC_SHA "ECDHE-ECDSA-AES256-SHA" - -# define TLS1_TXT_ECDH_RSA_WITH_NULL_SHA "ECDH-RSA-NULL-SHA" -# define TLS1_TXT_ECDH_RSA_WITH_RC4_128_SHA "ECDH-RSA-RC4-SHA" -# define TLS1_TXT_ECDH_RSA_WITH_DES_192_CBC3_SHA "ECDH-RSA-DES-CBC3-SHA" -# define TLS1_TXT_ECDH_RSA_WITH_AES_128_CBC_SHA "ECDH-RSA-AES128-SHA" -# define TLS1_TXT_ECDH_RSA_WITH_AES_256_CBC_SHA "ECDH-RSA-AES256-SHA" - -# define TLS1_TXT_ECDHE_RSA_WITH_NULL_SHA "ECDHE-RSA-NULL-SHA" -# define TLS1_TXT_ECDHE_RSA_WITH_RC4_128_SHA "ECDHE-RSA-RC4-SHA" -# define TLS1_TXT_ECDHE_RSA_WITH_DES_192_CBC3_SHA "ECDHE-RSA-DES-CBC3-SHA" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_CBC_SHA "ECDHE-RSA-AES128-SHA" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_CBC_SHA "ECDHE-RSA-AES256-SHA" - -# define TLS1_TXT_ECDH_anon_WITH_NULL_SHA "AECDH-NULL-SHA" -# define TLS1_TXT_ECDH_anon_WITH_RC4_128_SHA "AECDH-RC4-SHA" -# define TLS1_TXT_ECDH_anon_WITH_DES_192_CBC3_SHA "AECDH-DES-CBC3-SHA" -# define TLS1_TXT_ECDH_anon_WITH_AES_128_CBC_SHA "AECDH-AES128-SHA" -# define TLS1_TXT_ECDH_anon_WITH_AES_256_CBC_SHA "AECDH-AES256-SHA" - -/* PSK ciphersuites from RFC 4279 */ -# define TLS1_TXT_PSK_WITH_RC4_128_SHA "PSK-RC4-SHA" -# define TLS1_TXT_PSK_WITH_3DES_EDE_CBC_SHA "PSK-3DES-EDE-CBC-SHA" -# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA "PSK-AES128-CBC-SHA" -# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA "PSK-AES256-CBC-SHA" - -# define TLS1_TXT_DHE_PSK_WITH_RC4_128_SHA "DHE-PSK-RC4-SHA" -# define TLS1_TXT_DHE_PSK_WITH_3DES_EDE_CBC_SHA "DHE-PSK-3DES-EDE-CBC-SHA" -# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA "DHE-PSK-AES128-CBC-SHA" -# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA "DHE-PSK-AES256-CBC-SHA" -# define TLS1_TXT_RSA_PSK_WITH_RC4_128_SHA "RSA-PSK-RC4-SHA" -# define TLS1_TXT_RSA_PSK_WITH_3DES_EDE_CBC_SHA "RSA-PSK-3DES-EDE-CBC-SHA" -# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA "RSA-PSK-AES128-CBC-SHA" -# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA "RSA-PSK-AES256-CBC-SHA" - -/* PSK ciphersuites from RFC 5487 */ -# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256 "PSK-AES128-GCM-SHA256" -# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384 "PSK-AES256-GCM-SHA384" -# define TLS1_TXT_DHE_PSK_WITH_AES_128_GCM_SHA256 "DHE-PSK-AES128-GCM-SHA256" -# define TLS1_TXT_DHE_PSK_WITH_AES_256_GCM_SHA384 "DHE-PSK-AES256-GCM-SHA384" -# define TLS1_TXT_RSA_PSK_WITH_AES_128_GCM_SHA256 "RSA-PSK-AES128-GCM-SHA256" -# define TLS1_TXT_RSA_PSK_WITH_AES_256_GCM_SHA384 "RSA-PSK-AES256-GCM-SHA384" - -# define TLS1_TXT_PSK_WITH_AES_128_CBC_SHA256 "PSK-AES128-CBC-SHA256" -# define TLS1_TXT_PSK_WITH_AES_256_CBC_SHA384 "PSK-AES256-CBC-SHA384" -# define TLS1_TXT_PSK_WITH_NULL_SHA256 "PSK-NULL-SHA256" -# define TLS1_TXT_PSK_WITH_NULL_SHA384 "PSK-NULL-SHA384" - -# define TLS1_TXT_DHE_PSK_WITH_AES_128_CBC_SHA256 "DHE-PSK-AES128-CBC-SHA256" -# define TLS1_TXT_DHE_PSK_WITH_AES_256_CBC_SHA384 "DHE-PSK-AES256-CBC-SHA384" -# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA256 "DHE-PSK-NULL-SHA256" -# define TLS1_TXT_DHE_PSK_WITH_NULL_SHA384 "DHE-PSK-NULL-SHA384" - -# define TLS1_TXT_RSA_PSK_WITH_AES_128_CBC_SHA256 "RSA-PSK-AES128-CBC-SHA256" -# define TLS1_TXT_RSA_PSK_WITH_AES_256_CBC_SHA384 "RSA-PSK-AES256-CBC-SHA384" -# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA256 "RSA-PSK-NULL-SHA256" -# define TLS1_TXT_RSA_PSK_WITH_NULL_SHA384 "RSA-PSK-NULL-SHA384" - -/* SRP ciphersuite from RFC 5054 */ -# define TLS1_TXT_SRP_SHA_WITH_3DES_EDE_CBC_SHA "SRP-3DES-EDE-CBC-SHA" -# define TLS1_TXT_SRP_SHA_RSA_WITH_3DES_EDE_CBC_SHA "SRP-RSA-3DES-EDE-CBC-SHA" -# define TLS1_TXT_SRP_SHA_DSS_WITH_3DES_EDE_CBC_SHA "SRP-DSS-3DES-EDE-CBC-SHA" -# define TLS1_TXT_SRP_SHA_WITH_AES_128_CBC_SHA "SRP-AES-128-CBC-SHA" -# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_128_CBC_SHA "SRP-RSA-AES-128-CBC-SHA" -# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_128_CBC_SHA "SRP-DSS-AES-128-CBC-SHA" -# define TLS1_TXT_SRP_SHA_WITH_AES_256_CBC_SHA "SRP-AES-256-CBC-SHA" -# define TLS1_TXT_SRP_SHA_RSA_WITH_AES_256_CBC_SHA "SRP-RSA-AES-256-CBC-SHA" -# define TLS1_TXT_SRP_SHA_DSS_WITH_AES_256_CBC_SHA "SRP-DSS-AES-256-CBC-SHA" - -/* Camellia ciphersuites from RFC4132 */ -# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA "CAMELLIA128-SHA" -# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA "DH-DSS-CAMELLIA128-SHA" -# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA "DH-RSA-CAMELLIA128-SHA" -# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA "DHE-DSS-CAMELLIA128-SHA" -# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA "DHE-RSA-CAMELLIA128-SHA" -# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA "ADH-CAMELLIA128-SHA" - -# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA "CAMELLIA256-SHA" -# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA "DH-DSS-CAMELLIA256-SHA" -# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA "DH-RSA-CAMELLIA256-SHA" -# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA "DHE-DSS-CAMELLIA256-SHA" -# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA "DHE-RSA-CAMELLIA256-SHA" -# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA "ADH-CAMELLIA256-SHA" - -/* TLS 1.2 Camellia SHA-256 ciphersuites from RFC5932 */ -# define TLS1_TXT_RSA_WITH_CAMELLIA_128_CBC_SHA256 "CAMELLIA128-SHA256" -# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_128_CBC_SHA256 "DH-DSS-CAMELLIA128-SHA256" -# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "DH-RSA-CAMELLIA128-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_128_CBC_SHA256 "DHE-DSS-CAMELLIA128-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "DHE-RSA-CAMELLIA128-SHA256" -# define TLS1_TXT_ADH_WITH_CAMELLIA_128_CBC_SHA256 "ADH-CAMELLIA128-SHA256" - -# define TLS1_TXT_RSA_WITH_CAMELLIA_256_CBC_SHA256 "CAMELLIA256-SHA256" -# define TLS1_TXT_DH_DSS_WITH_CAMELLIA_256_CBC_SHA256 "DH-DSS-CAMELLIA256-SHA256" -# define TLS1_TXT_DH_RSA_WITH_CAMELLIA_256_CBC_SHA256 "DH-RSA-CAMELLIA256-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_CAMELLIA_256_CBC_SHA256 "DHE-DSS-CAMELLIA256-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_CAMELLIA_256_CBC_SHA256 "DHE-RSA-CAMELLIA256-SHA256" -# define TLS1_TXT_ADH_WITH_CAMELLIA_256_CBC_SHA256 "ADH-CAMELLIA256-SHA256" - -# define TLS1_TXT_PSK_WITH_CAMELLIA_128_CBC_SHA256 "PSK-CAMELLIA128-SHA256" -# define TLS1_TXT_PSK_WITH_CAMELLIA_256_CBC_SHA384 "PSK-CAMELLIA256-SHA384" -# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "DHE-PSK-CAMELLIA128-SHA256" -# define TLS1_TXT_DHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "DHE-PSK-CAMELLIA256-SHA384" -# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_128_CBC_SHA256 "RSA-PSK-CAMELLIA128-SHA256" -# define TLS1_TXT_RSA_PSK_WITH_CAMELLIA_256_CBC_SHA384 "RSA-PSK-CAMELLIA256-SHA384" -# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-PSK-CAMELLIA128-SHA256" -# define TLS1_TXT_ECDHE_PSK_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-PSK-CAMELLIA256-SHA384" - -/* SEED ciphersuites from RFC4162 */ -# define TLS1_TXT_RSA_WITH_SEED_SHA "SEED-SHA" -# define TLS1_TXT_DH_DSS_WITH_SEED_SHA "DH-DSS-SEED-SHA" -# define TLS1_TXT_DH_RSA_WITH_SEED_SHA "DH-RSA-SEED-SHA" -# define TLS1_TXT_DHE_DSS_WITH_SEED_SHA "DHE-DSS-SEED-SHA" -# define TLS1_TXT_DHE_RSA_WITH_SEED_SHA "DHE-RSA-SEED-SHA" -# define TLS1_TXT_ADH_WITH_SEED_SHA "ADH-SEED-SHA" - -/* TLS v1.2 ciphersuites */ -# define TLS1_TXT_RSA_WITH_NULL_SHA256 "NULL-SHA256" -# define TLS1_TXT_RSA_WITH_AES_128_SHA256 "AES128-SHA256" -# define TLS1_TXT_RSA_WITH_AES_256_SHA256 "AES256-SHA256" -# define TLS1_TXT_DH_DSS_WITH_AES_128_SHA256 "DH-DSS-AES128-SHA256" -# define TLS1_TXT_DH_RSA_WITH_AES_128_SHA256 "DH-RSA-AES128-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_AES_128_SHA256 "DHE-DSS-AES128-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_AES_128_SHA256 "DHE-RSA-AES128-SHA256" -# define TLS1_TXT_DH_DSS_WITH_AES_256_SHA256 "DH-DSS-AES256-SHA256" -# define TLS1_TXT_DH_RSA_WITH_AES_256_SHA256 "DH-RSA-AES256-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_AES_256_SHA256 "DHE-DSS-AES256-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_AES_256_SHA256 "DHE-RSA-AES256-SHA256" -# define TLS1_TXT_ADH_WITH_AES_128_SHA256 "ADH-AES128-SHA256" -# define TLS1_TXT_ADH_WITH_AES_256_SHA256 "ADH-AES256-SHA256" - -/* TLS v1.2 GCM ciphersuites from RFC5288 */ -# define TLS1_TXT_RSA_WITH_AES_128_GCM_SHA256 "AES128-GCM-SHA256" -# define TLS1_TXT_RSA_WITH_AES_256_GCM_SHA384 "AES256-GCM-SHA384" -# define TLS1_TXT_DHE_RSA_WITH_AES_128_GCM_SHA256 "DHE-RSA-AES128-GCM-SHA256" -# define TLS1_TXT_DHE_RSA_WITH_AES_256_GCM_SHA384 "DHE-RSA-AES256-GCM-SHA384" -# define TLS1_TXT_DH_RSA_WITH_AES_128_GCM_SHA256 "DH-RSA-AES128-GCM-SHA256" -# define TLS1_TXT_DH_RSA_WITH_AES_256_GCM_SHA384 "DH-RSA-AES256-GCM-SHA384" -# define TLS1_TXT_DHE_DSS_WITH_AES_128_GCM_SHA256 "DHE-DSS-AES128-GCM-SHA256" -# define TLS1_TXT_DHE_DSS_WITH_AES_256_GCM_SHA384 "DHE-DSS-AES256-GCM-SHA384" -# define TLS1_TXT_DH_DSS_WITH_AES_128_GCM_SHA256 "DH-DSS-AES128-GCM-SHA256" -# define TLS1_TXT_DH_DSS_WITH_AES_256_GCM_SHA384 "DH-DSS-AES256-GCM-SHA384" -# define TLS1_TXT_ADH_WITH_AES_128_GCM_SHA256 "ADH-AES128-GCM-SHA256" -# define TLS1_TXT_ADH_WITH_AES_256_GCM_SHA384 "ADH-AES256-GCM-SHA384" - -/* CCM ciphersuites from RFC6655 */ - -# define TLS1_TXT_RSA_WITH_AES_128_CCM "AES128-CCM" -# define TLS1_TXT_RSA_WITH_AES_256_CCM "AES256-CCM" -# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM "DHE-RSA-AES128-CCM" -# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM "DHE-RSA-AES256-CCM" - -# define TLS1_TXT_RSA_WITH_AES_128_CCM_8 "AES128-CCM8" -# define TLS1_TXT_RSA_WITH_AES_256_CCM_8 "AES256-CCM8" -# define TLS1_TXT_DHE_RSA_WITH_AES_128_CCM_8 "DHE-RSA-AES128-CCM8" -# define TLS1_TXT_DHE_RSA_WITH_AES_256_CCM_8 "DHE-RSA-AES256-CCM8" - -# define TLS1_TXT_PSK_WITH_AES_128_CCM "PSK-AES128-CCM" -# define TLS1_TXT_PSK_WITH_AES_256_CCM "PSK-AES256-CCM" -# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM "DHE-PSK-AES128-CCM" -# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM "DHE-PSK-AES256-CCM" - -# define TLS1_TXT_PSK_WITH_AES_128_CCM_8 "PSK-AES128-CCM8" -# define TLS1_TXT_PSK_WITH_AES_256_CCM_8 "PSK-AES256-CCM8" -# define TLS1_TXT_DHE_PSK_WITH_AES_128_CCM_8 "DHE-PSK-AES128-CCM8" -# define TLS1_TXT_DHE_PSK_WITH_AES_256_CCM_8 "DHE-PSK-AES256-CCM8" - -/* CCM ciphersuites from RFC7251 */ - -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM "ECDHE-ECDSA-AES128-CCM" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM "ECDHE-ECDSA-AES256-CCM" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_CCM_8 "ECDHE-ECDSA-AES128-CCM8" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_CCM_8 "ECDHE-ECDSA-AES256-CCM8" - -/* ECDH HMAC based ciphersuites from RFC5289 */ - -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_SHA256 "ECDHE-ECDSA-AES128-SHA256" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_SHA384 "ECDHE-ECDSA-AES256-SHA384" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_SHA256 "ECDH-ECDSA-AES128-SHA256" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_SHA384 "ECDH-ECDSA-AES256-SHA384" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_SHA256 "ECDHE-RSA-AES128-SHA256" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_SHA384 "ECDHE-RSA-AES256-SHA384" -# define TLS1_TXT_ECDH_RSA_WITH_AES_128_SHA256 "ECDH-RSA-AES128-SHA256" -# define TLS1_TXT_ECDH_RSA_WITH_AES_256_SHA384 "ECDH-RSA-AES256-SHA384" - -/* ECDH GCM based ciphersuites from RFC5289 */ -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 "ECDHE-ECDSA-AES128-GCM-SHA256" -# define TLS1_TXT_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 "ECDHE-ECDSA-AES256-GCM-SHA384" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_128_GCM_SHA256 "ECDH-ECDSA-AES128-GCM-SHA256" -# define TLS1_TXT_ECDH_ECDSA_WITH_AES_256_GCM_SHA384 "ECDH-ECDSA-AES256-GCM-SHA384" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_128_GCM_SHA256 "ECDHE-RSA-AES128-GCM-SHA256" -# define TLS1_TXT_ECDHE_RSA_WITH_AES_256_GCM_SHA384 "ECDHE-RSA-AES256-GCM-SHA384" -# define TLS1_TXT_ECDH_RSA_WITH_AES_128_GCM_SHA256 "ECDH-RSA-AES128-GCM-SHA256" -# define TLS1_TXT_ECDH_RSA_WITH_AES_256_GCM_SHA384 "ECDH-RSA-AES256-GCM-SHA384" - -/* TLS v1.2 PSK GCM ciphersuites from RFC5487 */ -# define TLS1_TXT_PSK_WITH_AES_128_GCM_SHA256 "PSK-AES128-GCM-SHA256" -# define TLS1_TXT_PSK_WITH_AES_256_GCM_SHA384 "PSK-AES256-GCM-SHA384" - -/* ECDHE PSK ciphersuites from RFC 5489 */ -# define TLS1_TXT_ECDHE_PSK_WITH_RC4_128_SHA "ECDHE-PSK-RC4-SHA" -# define TLS1_TXT_ECDHE_PSK_WITH_3DES_EDE_CBC_SHA "ECDHE-PSK-3DES-EDE-CBC-SHA" -# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA "ECDHE-PSK-AES128-CBC-SHA" -# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA "ECDHE-PSK-AES256-CBC-SHA" - -# define TLS1_TXT_ECDHE_PSK_WITH_AES_128_CBC_SHA256 "ECDHE-PSK-AES128-CBC-SHA256" -# define TLS1_TXT_ECDHE_PSK_WITH_AES_256_CBC_SHA384 "ECDHE-PSK-AES256-CBC-SHA384" - -# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA "ECDHE-PSK-NULL-SHA" -# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA256 "ECDHE-PSK-NULL-SHA256" -# define TLS1_TXT_ECDHE_PSK_WITH_NULL_SHA384 "ECDHE-PSK-NULL-SHA384" - -/* Camellia-CBC ciphersuites from RFC6367 */ -# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-ECDSA-CAMELLIA128-SHA256" -# define TLS1_TXT_ECDHE_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-ECDSA-CAMELLIA256-SHA384" -# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-ECDSA-CAMELLIA128-SHA256" -# define TLS1_TXT_ECDH_ECDSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-ECDSA-CAMELLIA256-SHA384" -# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDHE-RSA-CAMELLIA128-SHA256" -# define TLS1_TXT_ECDHE_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDHE-RSA-CAMELLIA256-SHA384" -# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_128_CBC_SHA256 "ECDH-RSA-CAMELLIA128-SHA256" -# define TLS1_TXT_ECDH_RSA_WITH_CAMELLIA_256_CBC_SHA384 "ECDH-RSA-CAMELLIA256-SHA384" - -/* draft-ietf-tls-chacha20-poly1305-03 */ -# define TLS1_TXT_ECDHE_RSA_WITH_CHACHA20_POLY1305 "ECDHE-RSA-CHACHA20-POLY1305" -# define TLS1_TXT_ECDHE_ECDSA_WITH_CHACHA20_POLY1305 "ECDHE-ECDSA-CHACHA20-POLY1305" -# define TLS1_TXT_DHE_RSA_WITH_CHACHA20_POLY1305 "DHE-RSA-CHACHA20-POLY1305" -# define TLS1_TXT_PSK_WITH_CHACHA20_POLY1305 "PSK-CHACHA20-POLY1305" -# define TLS1_TXT_ECDHE_PSK_WITH_CHACHA20_POLY1305 "ECDHE-PSK-CHACHA20-POLY1305" -# define TLS1_TXT_DHE_PSK_WITH_CHACHA20_POLY1305 "DHE-PSK-CHACHA20-POLY1305" -# define TLS1_TXT_RSA_PSK_WITH_CHACHA20_POLY1305 "RSA-PSK-CHACHA20-POLY1305" - -# define TLS_CT_RSA_SIGN 1 -# define TLS_CT_DSS_SIGN 2 -# define TLS_CT_RSA_FIXED_DH 3 -# define TLS_CT_DSS_FIXED_DH 4 -# define TLS_CT_ECDSA_SIGN 64 -# define TLS_CT_RSA_FIXED_ECDH 65 -# define TLS_CT_ECDSA_FIXED_ECDH 66 -# define TLS_CT_GOST01_SIGN 22 -# define TLS_CT_GOST12_SIGN 238 -# define TLS_CT_GOST12_512_SIGN 239 - -/* - * when correcting this number, correct also SSL3_CT_NUMBER in ssl3.h (see - * comment there) - */ -# define TLS_CT_NUMBER 9 - -# define TLS1_FINISH_MAC_LENGTH 12 - -# define TLS_MD_MAX_CONST_SIZE 22 -# define TLS_MD_CLIENT_FINISH_CONST "client finished" -# define TLS_MD_CLIENT_FINISH_CONST_SIZE 15 -# define TLS_MD_SERVER_FINISH_CONST "server finished" -# define TLS_MD_SERVER_FINISH_CONST_SIZE 15 -# define TLS_MD_KEY_EXPANSION_CONST "key expansion" -# define TLS_MD_KEY_EXPANSION_CONST_SIZE 13 -# define TLS_MD_CLIENT_WRITE_KEY_CONST "client write key" -# define TLS_MD_CLIENT_WRITE_KEY_CONST_SIZE 16 -# define TLS_MD_SERVER_WRITE_KEY_CONST "server write key" -# define TLS_MD_SERVER_WRITE_KEY_CONST_SIZE 16 -# define TLS_MD_IV_BLOCK_CONST "IV block" -# define TLS_MD_IV_BLOCK_CONST_SIZE 8 -# define TLS_MD_MASTER_SECRET_CONST "master secret" -# define TLS_MD_MASTER_SECRET_CONST_SIZE 13 -# define TLS_MD_EXTENDED_MASTER_SECRET_CONST "extended master secret" -# define TLS_MD_EXTENDED_MASTER_SECRET_CONST_SIZE 22 - -# ifdef CHARSET_EBCDIC -# undef TLS_MD_CLIENT_FINISH_CONST -/* - * client finished - */ -# define TLS_MD_CLIENT_FINISH_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x66\x69\x6e\x69\x73\x68\x65\x64" - -# undef TLS_MD_SERVER_FINISH_CONST -/* - * server finished - */ -# define TLS_MD_SERVER_FINISH_CONST "\x73\x65\x72\x76\x65\x72\x20\x66\x69\x6e\x69\x73\x68\x65\x64" - -# undef TLS_MD_SERVER_WRITE_KEY_CONST -/* - * server write key - */ -# define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" - -# undef TLS_MD_KEY_EXPANSION_CONST -/* - * key expansion - */ -# define TLS_MD_KEY_EXPANSION_CONST "\x6b\x65\x79\x20\x65\x78\x70\x61\x6e\x73\x69\x6f\x6e" - -# undef TLS_MD_CLIENT_WRITE_KEY_CONST -/* - * client write key - */ -# define TLS_MD_CLIENT_WRITE_KEY_CONST "\x63\x6c\x69\x65\x6e\x74\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" - -# undef TLS_MD_SERVER_WRITE_KEY_CONST -/* - * server write key - */ -# define TLS_MD_SERVER_WRITE_KEY_CONST "\x73\x65\x72\x76\x65\x72\x20\x77\x72\x69\x74\x65\x20\x6b\x65\x79" - -# undef TLS_MD_IV_BLOCK_CONST -/* - * IV block - */ -# define TLS_MD_IV_BLOCK_CONST "\x49\x56\x20\x62\x6c\x6f\x63\x6b" - -# undef TLS_MD_MASTER_SECRET_CONST -/* - * master secret - */ -# define TLS_MD_MASTER_SECRET_CONST "\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" -# undef TLS_MD_EXTENDED_MASTER_SECRET_CONST -/* - * extended master secret - */ -# define TLS_MD_EXTENDED_MASTER_SECRET_CONST "\x65\x78\x74\x65\x63\x64\x65\x64\x20\x6d\x61\x73\x74\x65\x72\x20\x73\x65\x63\x72\x65\x74" -# endif - -/* TLS Session Ticket extension struct */ -struct tls_session_ticket_ext_st { - unsigned short length; - void *data; -}; - -#ifdef __cplusplus -} -#endif -#endif diff --git a/android/armeabi/include/openssl/ts.h b/android/armeabi/include/openssl/ts.h deleted file mode 100644 index a5659825..00000000 --- a/android/armeabi/include/openssl/ts.h +++ /dev/null @@ -1,643 +0,0 @@ -/* - * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_TS_H -# define HEADER_TS_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_TS -# include <openssl/symhacks.h> -# include <openssl/buffer.h> -# include <openssl/evp.h> -# include <openssl/bio.h> -# include <openssl/stack.h> -# include <openssl/asn1.h> -# include <openssl/safestack.h> -# include <openssl/rsa.h> -# include <openssl/dsa.h> -# include <openssl/dh.h> -# ifdef __cplusplus -extern "C" { -# endif - -# include <openssl/x509.h> -# include <openssl/x509v3.h> - -typedef struct TS_msg_imprint_st TS_MSG_IMPRINT; -typedef struct TS_req_st TS_REQ; -typedef struct TS_accuracy_st TS_ACCURACY; -typedef struct TS_tst_info_st TS_TST_INFO; - -/* Possible values for status. */ -# define TS_STATUS_GRANTED 0 -# define TS_STATUS_GRANTED_WITH_MODS 1 -# define TS_STATUS_REJECTION 2 -# define TS_STATUS_WAITING 3 -# define TS_STATUS_REVOCATION_WARNING 4 -# define TS_STATUS_REVOCATION_NOTIFICATION 5 - -/* Possible values for failure_info. */ -# define TS_INFO_BAD_ALG 0 -# define TS_INFO_BAD_REQUEST 2 -# define TS_INFO_BAD_DATA_FORMAT 5 -# define TS_INFO_TIME_NOT_AVAILABLE 14 -# define TS_INFO_UNACCEPTED_POLICY 15 -# define TS_INFO_UNACCEPTED_EXTENSION 16 -# define TS_INFO_ADD_INFO_NOT_AVAILABLE 17 -# define TS_INFO_SYSTEM_FAILURE 25 - - -typedef struct TS_status_info_st TS_STATUS_INFO; -typedef struct ESS_issuer_serial ESS_ISSUER_SERIAL; -typedef struct ESS_cert_id ESS_CERT_ID; -typedef struct ESS_signing_cert ESS_SIGNING_CERT; - -DEFINE_STACK_OF(ESS_CERT_ID) - -typedef struct TS_resp_st TS_RESP; - -TS_REQ *TS_REQ_new(void); -void TS_REQ_free(TS_REQ *a); -int i2d_TS_REQ(const TS_REQ *a, unsigned char **pp); -TS_REQ *d2i_TS_REQ(TS_REQ **a, const unsigned char **pp, long length); - -TS_REQ *TS_REQ_dup(TS_REQ *a); - -#ifndef OPENSSL_NO_STDIO -TS_REQ *d2i_TS_REQ_fp(FILE *fp, TS_REQ **a); -int i2d_TS_REQ_fp(FILE *fp, TS_REQ *a); -#endif -TS_REQ *d2i_TS_REQ_bio(BIO *fp, TS_REQ **a); -int i2d_TS_REQ_bio(BIO *fp, TS_REQ *a); - -TS_MSG_IMPRINT *TS_MSG_IMPRINT_new(void); -void TS_MSG_IMPRINT_free(TS_MSG_IMPRINT *a); -int i2d_TS_MSG_IMPRINT(const TS_MSG_IMPRINT *a, unsigned char **pp); -TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT(TS_MSG_IMPRINT **a, - const unsigned char **pp, long length); - -TS_MSG_IMPRINT *TS_MSG_IMPRINT_dup(TS_MSG_IMPRINT *a); - -#ifndef OPENSSL_NO_STDIO -TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT **a); -int i2d_TS_MSG_IMPRINT_fp(FILE *fp, TS_MSG_IMPRINT *a); -#endif -TS_MSG_IMPRINT *d2i_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT **a); -int i2d_TS_MSG_IMPRINT_bio(BIO *bio, TS_MSG_IMPRINT *a); - -TS_RESP *TS_RESP_new(void); -void TS_RESP_free(TS_RESP *a); -int i2d_TS_RESP(const TS_RESP *a, unsigned char **pp); -TS_RESP *d2i_TS_RESP(TS_RESP **a, const unsigned char **pp, long length); -TS_TST_INFO *PKCS7_to_TS_TST_INFO(PKCS7 *token); -TS_RESP *TS_RESP_dup(TS_RESP *a); - -#ifndef OPENSSL_NO_STDIO -TS_RESP *d2i_TS_RESP_fp(FILE *fp, TS_RESP **a); -int i2d_TS_RESP_fp(FILE *fp, TS_RESP *a); -#endif -TS_RESP *d2i_TS_RESP_bio(BIO *bio, TS_RESP **a); -int i2d_TS_RESP_bio(BIO *bio, TS_RESP *a); - -TS_STATUS_INFO *TS_STATUS_INFO_new(void); -void TS_STATUS_INFO_free(TS_STATUS_INFO *a); -int i2d_TS_STATUS_INFO(const TS_STATUS_INFO *a, unsigned char **pp); -TS_STATUS_INFO *d2i_TS_STATUS_INFO(TS_STATUS_INFO **a, - const unsigned char **pp, long length); -TS_STATUS_INFO *TS_STATUS_INFO_dup(TS_STATUS_INFO *a); - -TS_TST_INFO *TS_TST_INFO_new(void); -void TS_TST_INFO_free(TS_TST_INFO *a); -int i2d_TS_TST_INFO(const TS_TST_INFO *a, unsigned char **pp); -TS_TST_INFO *d2i_TS_TST_INFO(TS_TST_INFO **a, const unsigned char **pp, - long length); -TS_TST_INFO *TS_TST_INFO_dup(TS_TST_INFO *a); - -#ifndef OPENSSL_NO_STDIO -TS_TST_INFO *d2i_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO **a); -int i2d_TS_TST_INFO_fp(FILE *fp, TS_TST_INFO *a); -#endif -TS_TST_INFO *d2i_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO **a); -int i2d_TS_TST_INFO_bio(BIO *bio, TS_TST_INFO *a); - -TS_ACCURACY *TS_ACCURACY_new(void); -void TS_ACCURACY_free(TS_ACCURACY *a); -int i2d_TS_ACCURACY(const TS_ACCURACY *a, unsigned char **pp); -TS_ACCURACY *d2i_TS_ACCURACY(TS_ACCURACY **a, const unsigned char **pp, - long length); -TS_ACCURACY *TS_ACCURACY_dup(TS_ACCURACY *a); - -ESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_new(void); -void ESS_ISSUER_SERIAL_free(ESS_ISSUER_SERIAL *a); -int i2d_ESS_ISSUER_SERIAL(const ESS_ISSUER_SERIAL *a, unsigned char **pp); -ESS_ISSUER_SERIAL *d2i_ESS_ISSUER_SERIAL(ESS_ISSUER_SERIAL **a, - const unsigned char **pp, - long length); -ESS_ISSUER_SERIAL *ESS_ISSUER_SERIAL_dup(ESS_ISSUER_SERIAL *a); - -ESS_CERT_ID *ESS_CERT_ID_new(void); -void ESS_CERT_ID_free(ESS_CERT_ID *a); -int i2d_ESS_CERT_ID(const ESS_CERT_ID *a, unsigned char **pp); -ESS_CERT_ID *d2i_ESS_CERT_ID(ESS_CERT_ID **a, const unsigned char **pp, - long length); -ESS_CERT_ID *ESS_CERT_ID_dup(ESS_CERT_ID *a); - -ESS_SIGNING_CERT *ESS_SIGNING_CERT_new(void); -void ESS_SIGNING_CERT_free(ESS_SIGNING_CERT *a); -int i2d_ESS_SIGNING_CERT(const ESS_SIGNING_CERT *a, unsigned char **pp); -ESS_SIGNING_CERT *d2i_ESS_SIGNING_CERT(ESS_SIGNING_CERT **a, - const unsigned char **pp, long length); -ESS_SIGNING_CERT *ESS_SIGNING_CERT_dup(ESS_SIGNING_CERT *a); - -int TS_REQ_set_version(TS_REQ *a, long version); -long TS_REQ_get_version(const TS_REQ *a); - -int TS_STATUS_INFO_set_status(TS_STATUS_INFO *a, int i); -const ASN1_INTEGER *TS_STATUS_INFO_get0_status(const TS_STATUS_INFO *a); - -const STACK_OF(ASN1_UTF8STRING) * -TS_STATUS_INFO_get0_text(const TS_STATUS_INFO *a); - -const ASN1_BIT_STRING * -TS_STATUS_INFO_get0_failure_info(const TS_STATUS_INFO *a); - -int TS_REQ_set_msg_imprint(TS_REQ *a, TS_MSG_IMPRINT *msg_imprint); -TS_MSG_IMPRINT *TS_REQ_get_msg_imprint(TS_REQ *a); - -int TS_MSG_IMPRINT_set_algo(TS_MSG_IMPRINT *a, X509_ALGOR *alg); -X509_ALGOR *TS_MSG_IMPRINT_get_algo(TS_MSG_IMPRINT *a); - -int TS_MSG_IMPRINT_set_msg(TS_MSG_IMPRINT *a, unsigned char *d, int len); -ASN1_OCTET_STRING *TS_MSG_IMPRINT_get_msg(TS_MSG_IMPRINT *a); - -int TS_REQ_set_policy_id(TS_REQ *a, const ASN1_OBJECT *policy); -ASN1_OBJECT *TS_REQ_get_policy_id(TS_REQ *a); - -int TS_REQ_set_nonce(TS_REQ *a, const ASN1_INTEGER *nonce); -const ASN1_INTEGER *TS_REQ_get_nonce(const TS_REQ *a); - -int TS_REQ_set_cert_req(TS_REQ *a, int cert_req); -int TS_REQ_get_cert_req(const TS_REQ *a); - -STACK_OF(X509_EXTENSION) *TS_REQ_get_exts(TS_REQ *a); -void TS_REQ_ext_free(TS_REQ *a); -int TS_REQ_get_ext_count(TS_REQ *a); -int TS_REQ_get_ext_by_NID(TS_REQ *a, int nid, int lastpos); -int TS_REQ_get_ext_by_OBJ(TS_REQ *a, const ASN1_OBJECT *obj, int lastpos); -int TS_REQ_get_ext_by_critical(TS_REQ *a, int crit, int lastpos); -X509_EXTENSION *TS_REQ_get_ext(TS_REQ *a, int loc); -X509_EXTENSION *TS_REQ_delete_ext(TS_REQ *a, int loc); -int TS_REQ_add_ext(TS_REQ *a, X509_EXTENSION *ex, int loc); -void *TS_REQ_get_ext_d2i(TS_REQ *a, int nid, int *crit, int *idx); - -/* Function declarations for TS_REQ defined in ts/ts_req_print.c */ - -int TS_REQ_print_bio(BIO *bio, TS_REQ *a); - -/* Function declarations for TS_RESP defined in ts/ts_resp_utils.c */ - -int TS_RESP_set_status_info(TS_RESP *a, TS_STATUS_INFO *info); -TS_STATUS_INFO *TS_RESP_get_status_info(TS_RESP *a); - -/* Caller loses ownership of PKCS7 and TS_TST_INFO objects. */ -void TS_RESP_set_tst_info(TS_RESP *a, PKCS7 *p7, TS_TST_INFO *tst_info); -PKCS7 *TS_RESP_get_token(TS_RESP *a); -TS_TST_INFO *TS_RESP_get_tst_info(TS_RESP *a); - -int TS_TST_INFO_set_version(TS_TST_INFO *a, long version); -long TS_TST_INFO_get_version(const TS_TST_INFO *a); - -int TS_TST_INFO_set_policy_id(TS_TST_INFO *a, ASN1_OBJECT *policy_id); -ASN1_OBJECT *TS_TST_INFO_get_policy_id(TS_TST_INFO *a); - -int TS_TST_INFO_set_msg_imprint(TS_TST_INFO *a, TS_MSG_IMPRINT *msg_imprint); -TS_MSG_IMPRINT *TS_TST_INFO_get_msg_imprint(TS_TST_INFO *a); - -int TS_TST_INFO_set_serial(TS_TST_INFO *a, const ASN1_INTEGER *serial); -const ASN1_INTEGER *TS_TST_INFO_get_serial(const TS_TST_INFO *a); - -int TS_TST_INFO_set_time(TS_TST_INFO *a, const ASN1_GENERALIZEDTIME *gtime); -const ASN1_GENERALIZEDTIME *TS_TST_INFO_get_time(const TS_TST_INFO *a); - -int TS_TST_INFO_set_accuracy(TS_TST_INFO *a, TS_ACCURACY *accuracy); -TS_ACCURACY *TS_TST_INFO_get_accuracy(TS_TST_INFO *a); - -int TS_ACCURACY_set_seconds(TS_ACCURACY *a, const ASN1_INTEGER *seconds); -const ASN1_INTEGER *TS_ACCURACY_get_seconds(const TS_ACCURACY *a); - -int TS_ACCURACY_set_millis(TS_ACCURACY *a, const ASN1_INTEGER *millis); -const ASN1_INTEGER *TS_ACCURACY_get_millis(const TS_ACCURACY *a); - -int TS_ACCURACY_set_micros(TS_ACCURACY *a, const ASN1_INTEGER *micros); -const ASN1_INTEGER *TS_ACCURACY_get_micros(const TS_ACCURACY *a); - -int TS_TST_INFO_set_ordering(TS_TST_INFO *a, int ordering); -int TS_TST_INFO_get_ordering(const TS_TST_INFO *a); - -int TS_TST_INFO_set_nonce(TS_TST_INFO *a, const ASN1_INTEGER *nonce); -const ASN1_INTEGER *TS_TST_INFO_get_nonce(const TS_TST_INFO *a); - -int TS_TST_INFO_set_tsa(TS_TST_INFO *a, GENERAL_NAME *tsa); -GENERAL_NAME *TS_TST_INFO_get_tsa(TS_TST_INFO *a); - -STACK_OF(X509_EXTENSION) *TS_TST_INFO_get_exts(TS_TST_INFO *a); -void TS_TST_INFO_ext_free(TS_TST_INFO *a); -int TS_TST_INFO_get_ext_count(TS_TST_INFO *a); -int TS_TST_INFO_get_ext_by_NID(TS_TST_INFO *a, int nid, int lastpos); -int TS_TST_INFO_get_ext_by_OBJ(TS_TST_INFO *a, const ASN1_OBJECT *obj, - int lastpos); -int TS_TST_INFO_get_ext_by_critical(TS_TST_INFO *a, int crit, int lastpos); -X509_EXTENSION *TS_TST_INFO_get_ext(TS_TST_INFO *a, int loc); -X509_EXTENSION *TS_TST_INFO_delete_ext(TS_TST_INFO *a, int loc); -int TS_TST_INFO_add_ext(TS_TST_INFO *a, X509_EXTENSION *ex, int loc); -void *TS_TST_INFO_get_ext_d2i(TS_TST_INFO *a, int nid, int *crit, int *idx); - -/* - * Declarations related to response generation, defined in ts/ts_resp_sign.c. - */ - -/* Optional flags for response generation. */ - -/* Don't include the TSA name in response. */ -# define TS_TSA_NAME 0x01 - -/* Set ordering to true in response. */ -# define TS_ORDERING 0x02 - -/* - * Include the signer certificate and the other specified certificates in - * the ESS signing certificate attribute beside the PKCS7 signed data. - * Only the signer certificates is included by default. - */ -# define TS_ESS_CERT_ID_CHAIN 0x04 - -/* Forward declaration. */ -struct TS_resp_ctx; - -/* This must return a unique number less than 160 bits long. */ -typedef ASN1_INTEGER *(*TS_serial_cb) (struct TS_resp_ctx *, void *); - -/* - * This must return the seconds and microseconds since Jan 1, 1970 in the sec - * and usec variables allocated by the caller. Return non-zero for success - * and zero for failure. - */ -typedef int (*TS_time_cb) (struct TS_resp_ctx *, void *, long *sec, - long *usec); - -/* - * This must process the given extension. It can modify the TS_TST_INFO - * object of the context. Return values: !0 (processed), 0 (error, it must - * set the status info/failure info of the response). - */ -typedef int (*TS_extension_cb) (struct TS_resp_ctx *, X509_EXTENSION *, - void *); - -typedef struct TS_resp_ctx TS_RESP_CTX; - -DEFINE_STACK_OF_CONST(EVP_MD) - -/* Creates a response context that can be used for generating responses. */ -TS_RESP_CTX *TS_RESP_CTX_new(void); -void TS_RESP_CTX_free(TS_RESP_CTX *ctx); - -/* This parameter must be set. */ -int TS_RESP_CTX_set_signer_cert(TS_RESP_CTX *ctx, X509 *signer); - -/* This parameter must be set. */ -int TS_RESP_CTX_set_signer_key(TS_RESP_CTX *ctx, EVP_PKEY *key); - -int TS_RESP_CTX_set_signer_digest(TS_RESP_CTX *ctx, - const EVP_MD *signer_digest); - -/* This parameter must be set. */ -int TS_RESP_CTX_set_def_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *def_policy); - -/* No additional certs are included in the response by default. */ -int TS_RESP_CTX_set_certs(TS_RESP_CTX *ctx, STACK_OF(X509) *certs); - -/* - * Adds a new acceptable policy, only the default policy is accepted by - * default. - */ -int TS_RESP_CTX_add_policy(TS_RESP_CTX *ctx, const ASN1_OBJECT *policy); - -/* - * Adds a new acceptable message digest. Note that no message digests are - * accepted by default. The md argument is shared with the caller. - */ -int TS_RESP_CTX_add_md(TS_RESP_CTX *ctx, const EVP_MD *md); - -/* Accuracy is not included by default. */ -int TS_RESP_CTX_set_accuracy(TS_RESP_CTX *ctx, - int secs, int millis, int micros); - -/* - * Clock precision digits, i.e. the number of decimal digits: '0' means sec, - * '3' msec, '6' usec, and so on. Default is 0. - */ -int TS_RESP_CTX_set_clock_precision_digits(TS_RESP_CTX *ctx, - unsigned clock_precision_digits); -/* At most we accept usec precision. */ -# define TS_MAX_CLOCK_PRECISION_DIGITS 6 - -/* Maximum status message length */ -# define TS_MAX_STATUS_LENGTH (1024 * 1024) - -/* No flags are set by default. */ -void TS_RESP_CTX_add_flags(TS_RESP_CTX *ctx, int flags); - -/* Default callback always returns a constant. */ -void TS_RESP_CTX_set_serial_cb(TS_RESP_CTX *ctx, TS_serial_cb cb, void *data); - -/* Default callback uses the gettimeofday() and gmtime() system calls. */ -void TS_RESP_CTX_set_time_cb(TS_RESP_CTX *ctx, TS_time_cb cb, void *data); - -/* - * Default callback rejects all extensions. The extension callback is called - * when the TS_TST_INFO object is already set up and not signed yet. - */ -/* FIXME: extension handling is not tested yet. */ -void TS_RESP_CTX_set_extension_cb(TS_RESP_CTX *ctx, - TS_extension_cb cb, void *data); - -/* The following methods can be used in the callbacks. */ -int TS_RESP_CTX_set_status_info(TS_RESP_CTX *ctx, - int status, const char *text); - -/* Sets the status info only if it is still TS_STATUS_GRANTED. */ -int TS_RESP_CTX_set_status_info_cond(TS_RESP_CTX *ctx, - int status, const char *text); - -int TS_RESP_CTX_add_failure_info(TS_RESP_CTX *ctx, int failure); - -/* The get methods below can be used in the extension callback. */ -TS_REQ *TS_RESP_CTX_get_request(TS_RESP_CTX *ctx); - -TS_TST_INFO *TS_RESP_CTX_get_tst_info(TS_RESP_CTX *ctx); - -/* - * Creates the signed TS_TST_INFO and puts it in TS_RESP. - * In case of errors it sets the status info properly. - * Returns NULL only in case of memory allocation/fatal error. - */ -TS_RESP *TS_RESP_create_response(TS_RESP_CTX *ctx, BIO *req_bio); - -/* - * Declarations related to response verification, - * they are defined in ts/ts_resp_verify.c. - */ - -int TS_RESP_verify_signature(PKCS7 *token, STACK_OF(X509) *certs, - X509_STORE *store, X509 **signer_out); - -/* Context structure for the generic verify method. */ - -/* Verify the signer's certificate and the signature of the response. */ -# define TS_VFY_SIGNATURE (1u << 0) -/* Verify the version number of the response. */ -# define TS_VFY_VERSION (1u << 1) -/* Verify if the policy supplied by the user matches the policy of the TSA. */ -# define TS_VFY_POLICY (1u << 2) -/* - * Verify the message imprint provided by the user. This flag should not be - * specified with TS_VFY_DATA. - */ -# define TS_VFY_IMPRINT (1u << 3) -/* - * Verify the message imprint computed by the verify method from the user - * provided data and the MD algorithm of the response. This flag should not - * be specified with TS_VFY_IMPRINT. - */ -# define TS_VFY_DATA (1u << 4) -/* Verify the nonce value. */ -# define TS_VFY_NONCE (1u << 5) -/* Verify if the TSA name field matches the signer certificate. */ -# define TS_VFY_SIGNER (1u << 6) -/* Verify if the TSA name field equals to the user provided name. */ -# define TS_VFY_TSA_NAME (1u << 7) - -/* You can use the following convenience constants. */ -# define TS_VFY_ALL_IMPRINT (TS_VFY_SIGNATURE \ - | TS_VFY_VERSION \ - | TS_VFY_POLICY \ - | TS_VFY_IMPRINT \ - | TS_VFY_NONCE \ - | TS_VFY_SIGNER \ - | TS_VFY_TSA_NAME) -# define TS_VFY_ALL_DATA (TS_VFY_SIGNATURE \ - | TS_VFY_VERSION \ - | TS_VFY_POLICY \ - | TS_VFY_DATA \ - | TS_VFY_NONCE \ - | TS_VFY_SIGNER \ - | TS_VFY_TSA_NAME) - -typedef struct TS_verify_ctx TS_VERIFY_CTX; - -int TS_RESP_verify_response(TS_VERIFY_CTX *ctx, TS_RESP *response); -int TS_RESP_verify_token(TS_VERIFY_CTX *ctx, PKCS7 *token); - -/* - * Declarations related to response verification context, - */ -TS_VERIFY_CTX *TS_VERIFY_CTX_new(void); -void TS_VERIFY_CTX_init(TS_VERIFY_CTX *ctx); -void TS_VERIFY_CTX_free(TS_VERIFY_CTX *ctx); -void TS_VERIFY_CTX_cleanup(TS_VERIFY_CTX *ctx); -int TS_VERIFY_CTX_set_flags(TS_VERIFY_CTX *ctx, int f); -int TS_VERIFY_CTX_add_flags(TS_VERIFY_CTX *ctx, int f); -BIO *TS_VERIFY_CTX_set_data(TS_VERIFY_CTX *ctx, BIO *b); -unsigned char *TS_VERIFY_CTX_set_imprint(TS_VERIFY_CTX *ctx, - unsigned char *hexstr, long len); -X509_STORE *TS_VERIFY_CTX_set_store(TS_VERIFY_CTX *ctx, X509_STORE *s); -STACK_OF(X509) *TS_VERIFY_CTS_set_certs(TS_VERIFY_CTX *ctx, STACK_OF(X509) *certs); - -/*- - * If ctx is NULL, it allocates and returns a new object, otherwise - * it returns ctx. It initialises all the members as follows: - * flags = TS_VFY_ALL_IMPRINT & ~(TS_VFY_TSA_NAME | TS_VFY_SIGNATURE) - * certs = NULL - * store = NULL - * policy = policy from the request or NULL if absent (in this case - * TS_VFY_POLICY is cleared from flags as well) - * md_alg = MD algorithm from request - * imprint, imprint_len = imprint from request - * data = NULL - * nonce, nonce_len = nonce from the request or NULL if absent (in this case - * TS_VFY_NONCE is cleared from flags as well) - * tsa_name = NULL - * Important: after calling this method TS_VFY_SIGNATURE should be added! - */ -TS_VERIFY_CTX *TS_REQ_to_TS_VERIFY_CTX(TS_REQ *req, TS_VERIFY_CTX *ctx); - -/* Function declarations for TS_RESP defined in ts/ts_resp_print.c */ - -int TS_RESP_print_bio(BIO *bio, TS_RESP *a); -int TS_STATUS_INFO_print_bio(BIO *bio, TS_STATUS_INFO *a); -int TS_TST_INFO_print_bio(BIO *bio, TS_TST_INFO *a); - -/* Common utility functions defined in ts/ts_lib.c */ - -int TS_ASN1_INTEGER_print_bio(BIO *bio, const ASN1_INTEGER *num); -int TS_OBJ_print_bio(BIO *bio, const ASN1_OBJECT *obj); -int TS_ext_print_bio(BIO *bio, const STACK_OF(X509_EXTENSION) *extensions); -int TS_X509_ALGOR_print_bio(BIO *bio, const X509_ALGOR *alg); -int TS_MSG_IMPRINT_print_bio(BIO *bio, TS_MSG_IMPRINT *msg); - -/* - * Function declarations for handling configuration options, defined in - * ts/ts_conf.c - */ - -X509 *TS_CONF_load_cert(const char *file); -STACK_OF(X509) *TS_CONF_load_certs(const char *file); -EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass); -const char *TS_CONF_get_tsa_section(CONF *conf, const char *section); -int TS_CONF_set_serial(CONF *conf, const char *section, TS_serial_cb cb, - TS_RESP_CTX *ctx); -#ifndef OPENSSL_NO_ENGINE -int TS_CONF_set_crypto_device(CONF *conf, const char *section, - const char *device); -int TS_CONF_set_default_engine(const char *name); -#endif -int TS_CONF_set_signer_cert(CONF *conf, const char *section, - const char *cert, TS_RESP_CTX *ctx); -int TS_CONF_set_certs(CONF *conf, const char *section, const char *certs, - TS_RESP_CTX *ctx); -int TS_CONF_set_signer_key(CONF *conf, const char *section, - const char *key, const char *pass, - TS_RESP_CTX *ctx); -int TS_CONF_set_signer_digest(CONF *conf, const char *section, - const char *md, TS_RESP_CTX *ctx); -int TS_CONF_set_def_policy(CONF *conf, const char *section, - const char *policy, TS_RESP_CTX *ctx); -int TS_CONF_set_policies(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_digests(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_accuracy(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_clock_precision_digits(CONF *conf, const char *section, - TS_RESP_CTX *ctx); -int TS_CONF_set_ordering(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_tsa_name(CONF *conf, const char *section, TS_RESP_CTX *ctx); -int TS_CONF_set_ess_cert_id_chain(CONF *conf, const char *section, - TS_RESP_CTX *ctx); - -/* -------------------------------------------------- */ -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_TS_strings(void); - -/* Error codes for the TS functions. */ - -/* Function codes. */ -# define TS_F_DEF_SERIAL_CB 110 -# define TS_F_DEF_TIME_CB 111 -# define TS_F_ESS_ADD_SIGNING_CERT 112 -# define TS_F_ESS_CERT_ID_NEW_INIT 113 -# define TS_F_ESS_SIGNING_CERT_NEW_INIT 114 -# define TS_F_INT_TS_RESP_VERIFY_TOKEN 149 -# define TS_F_PKCS7_TO_TS_TST_INFO 148 -# define TS_F_TS_ACCURACY_SET_MICROS 115 -# define TS_F_TS_ACCURACY_SET_MILLIS 116 -# define TS_F_TS_ACCURACY_SET_SECONDS 117 -# define TS_F_TS_CHECK_IMPRINTS 100 -# define TS_F_TS_CHECK_NONCES 101 -# define TS_F_TS_CHECK_POLICY 102 -# define TS_F_TS_CHECK_SIGNING_CERTS 103 -# define TS_F_TS_CHECK_STATUS_INFO 104 -# define TS_F_TS_COMPUTE_IMPRINT 145 -# define TS_F_TS_CONF_INVALID 151 -# define TS_F_TS_CONF_LOAD_CERT 153 -# define TS_F_TS_CONF_LOAD_CERTS 154 -# define TS_F_TS_CONF_LOAD_KEY 155 -# define TS_F_TS_CONF_LOOKUP_FAIL 152 -# define TS_F_TS_CONF_SET_DEFAULT_ENGINE 146 -# define TS_F_TS_GET_STATUS_TEXT 105 -# define TS_F_TS_MSG_IMPRINT_SET_ALGO 118 -# define TS_F_TS_REQ_SET_MSG_IMPRINT 119 -# define TS_F_TS_REQ_SET_NONCE 120 -# define TS_F_TS_REQ_SET_POLICY_ID 121 -# define TS_F_TS_RESP_CREATE_RESPONSE 122 -# define TS_F_TS_RESP_CREATE_TST_INFO 123 -# define TS_F_TS_RESP_CTX_ADD_FAILURE_INFO 124 -# define TS_F_TS_RESP_CTX_ADD_MD 125 -# define TS_F_TS_RESP_CTX_ADD_POLICY 126 -# define TS_F_TS_RESP_CTX_NEW 127 -# define TS_F_TS_RESP_CTX_SET_ACCURACY 128 -# define TS_F_TS_RESP_CTX_SET_CERTS 129 -# define TS_F_TS_RESP_CTX_SET_DEF_POLICY 130 -# define TS_F_TS_RESP_CTX_SET_SIGNER_CERT 131 -# define TS_F_TS_RESP_CTX_SET_STATUS_INFO 132 -# define TS_F_TS_RESP_GET_POLICY 133 -# define TS_F_TS_RESP_SET_GENTIME_WITH_PRECISION 134 -# define TS_F_TS_RESP_SET_STATUS_INFO 135 -# define TS_F_TS_RESP_SET_TST_INFO 150 -# define TS_F_TS_RESP_SIGN 136 -# define TS_F_TS_RESP_VERIFY_SIGNATURE 106 -# define TS_F_TS_TST_INFO_SET_ACCURACY 137 -# define TS_F_TS_TST_INFO_SET_MSG_IMPRINT 138 -# define TS_F_TS_TST_INFO_SET_NONCE 139 -# define TS_F_TS_TST_INFO_SET_POLICY_ID 140 -# define TS_F_TS_TST_INFO_SET_SERIAL 141 -# define TS_F_TS_TST_INFO_SET_TIME 142 -# define TS_F_TS_TST_INFO_SET_TSA 143 -# define TS_F_TS_VERIFY 108 -# define TS_F_TS_VERIFY_CERT 109 -# define TS_F_TS_VERIFY_CTX_NEW 144 - -/* Reason codes. */ -# define TS_R_BAD_PKCS7_TYPE 132 -# define TS_R_BAD_TYPE 133 -# define TS_R_CANNOT_LOAD_CERT 137 -# define TS_R_CANNOT_LOAD_KEY 138 -# define TS_R_CERTIFICATE_VERIFY_ERROR 100 -# define TS_R_COULD_NOT_SET_ENGINE 127 -# define TS_R_COULD_NOT_SET_TIME 115 -# define TS_R_DETACHED_CONTENT 134 -# define TS_R_ESS_ADD_SIGNING_CERT_ERROR 116 -# define TS_R_ESS_SIGNING_CERTIFICATE_ERROR 101 -# define TS_R_INVALID_NULL_POINTER 102 -# define TS_R_INVALID_SIGNER_CERTIFICATE_PURPOSE 117 -# define TS_R_MESSAGE_IMPRINT_MISMATCH 103 -# define TS_R_NONCE_MISMATCH 104 -# define TS_R_NONCE_NOT_RETURNED 105 -# define TS_R_NO_CONTENT 106 -# define TS_R_NO_TIME_STAMP_TOKEN 107 -# define TS_R_PKCS7_ADD_SIGNATURE_ERROR 118 -# define TS_R_PKCS7_ADD_SIGNED_ATTR_ERROR 119 -# define TS_R_PKCS7_TO_TS_TST_INFO_FAILED 129 -# define TS_R_POLICY_MISMATCH 108 -# define TS_R_PRIVATE_KEY_DOES_NOT_MATCH_CERTIFICATE 120 -# define TS_R_RESPONSE_SETUP_ERROR 121 -# define TS_R_SIGNATURE_FAILURE 109 -# define TS_R_THERE_MUST_BE_ONE_SIGNER 110 -# define TS_R_TIME_SYSCALL_ERROR 122 -# define TS_R_TOKEN_NOT_PRESENT 130 -# define TS_R_TOKEN_PRESENT 131 -# define TS_R_TSA_NAME_MISMATCH 111 -# define TS_R_TSA_UNTRUSTED 112 -# define TS_R_TST_INFO_SETUP_ERROR 123 -# define TS_R_TS_DATASIGN 124 -# define TS_R_UNACCEPTABLE_POLICY 125 -# define TS_R_UNSUPPORTED_MD_ALGORITHM 126 -# define TS_R_UNSUPPORTED_VERSION 113 -# define TS_R_VAR_BAD_VALUE 135 -# define TS_R_VAR_LOOKUP_FAILURE 136 -# define TS_R_WRONG_CONTENT_TYPE 114 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/txt_db.h b/android/armeabi/include/openssl/txt_db.h deleted file mode 100644 index 0e6c943e..00000000 --- a/android/armeabi/include/openssl/txt_db.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_TXT_DB_H -# define HEADER_TXT_DB_H - -# include <openssl/opensslconf.h> -# include <openssl/bio.h> -# include <openssl/stack.h> -# include <openssl/lhash.h> - -# define DB_ERROR_OK 0 -# define DB_ERROR_MALLOC 1 -# define DB_ERROR_INDEX_CLASH 2 -# define DB_ERROR_INDEX_OUT_OF_RANGE 3 -# define DB_ERROR_NO_INDEX 4 -# define DB_ERROR_INSERT_INDEX_CLASH 5 -# define DB_ERROR_WRONG_NUM_FIELDS 6 - -#ifdef __cplusplus -extern "C" { -#endif - -typedef OPENSSL_STRING *OPENSSL_PSTRING; -DEFINE_SPECIAL_STACK_OF(OPENSSL_PSTRING, OPENSSL_STRING) - -typedef struct txt_db_st { - int num_fields; - STACK_OF(OPENSSL_PSTRING) *data; - LHASH_OF(OPENSSL_STRING) **index; - int (**qual) (OPENSSL_STRING *); - long error; - long arg1; - long arg2; - OPENSSL_STRING *arg_row; -} TXT_DB; - -TXT_DB *TXT_DB_read(BIO *in, int num); -long TXT_DB_write(BIO *out, TXT_DB *db); -int TXT_DB_create_index(TXT_DB *db, int field, int (*qual) (OPENSSL_STRING *), - OPENSSL_LH_HASHFUNC hash, OPENSSL_LH_COMPFUNC cmp); -void TXT_DB_free(TXT_DB *db); -OPENSSL_STRING *TXT_DB_get_by_index(TXT_DB *db, int idx, - OPENSSL_STRING *value); -int TXT_DB_insert(TXT_DB *db, OPENSSL_STRING *value); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android/armeabi/include/openssl/ui.h b/android/armeabi/include/openssl/ui.h deleted file mode 100644 index 26f4f044..00000000 --- a/android/armeabi/include/openssl/ui.h +++ /dev/null @@ -1,368 +0,0 @@ -/* - * Copyright 2001-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_UI_H -# define HEADER_UI_H - -# include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_UI - -# if OPENSSL_API_COMPAT < 0x10100000L -# include <openssl/crypto.h> -# endif -# include <openssl/safestack.h> -# include <openssl/ossl_typ.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * All the following functions return -1 or NULL on error and in some cases - * (UI_process()) -2 if interrupted or in some other way cancelled. When - * everything is fine, they return 0, a positive value or a non-NULL pointer, - * all depending on their purpose. - */ - -/* Creators and destructor. */ -UI *UI_new(void); -UI *UI_new_method(const UI_METHOD *method); -void UI_free(UI *ui); - -/*- - The following functions are used to add strings to be printed and prompt - strings to prompt for data. The names are UI_{add,dup}_<function>_string - and UI_{add,dup}_input_boolean. - - UI_{add,dup}_<function>_string have the following meanings: - add add a text or prompt string. The pointers given to these - functions are used verbatim, no copying is done. - dup make a copy of the text or prompt string, then add the copy - to the collection of strings in the user interface. - <function> - The function is a name for the functionality that the given - string shall be used for. It can be one of: - input use the string as data prompt. - verify use the string as verification prompt. This - is used to verify a previous input. - info use the string for informational output. - error use the string for error output. - Honestly, there's currently no difference between info and error for the - moment. - - UI_{add,dup}_input_boolean have the same semantics for "add" and "dup", - and are typically used when one wants to prompt for a yes/no response. - - All of the functions in this group take a UI and a prompt string. - The string input and verify addition functions also take a flag argument, - a buffer for the result to end up with, a minimum input size and a maximum - input size (the result buffer MUST be large enough to be able to contain - the maximum number of characters). Additionally, the verify addition - functions takes another buffer to compare the result against. - The boolean input functions take an action description string (which should - be safe to ignore if the expected user action is obvious, for example with - a dialog box with an OK button and a Cancel button), a string of acceptable - characters to mean OK and to mean Cancel. The two last strings are checked - to make sure they don't have common characters. Additionally, the same - flag argument as for the string input is taken, as well as a result buffer. - The result buffer is required to be at least one byte long. Depending on - the answer, the first character from the OK or the Cancel character strings - will be stored in the first byte of the result buffer. No NUL will be - added, so the result is *not* a string. - - On success, the all return an index of the added information. That index - is useful when retrieving results with UI_get0_result(). */ -int UI_add_input_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize); -int UI_dup_input_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize); -int UI_add_verify_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize, - const char *test_buf); -int UI_dup_verify_string(UI *ui, const char *prompt, int flags, - char *result_buf, int minsize, int maxsize, - const char *test_buf); -int UI_add_input_boolean(UI *ui, const char *prompt, const char *action_desc, - const char *ok_chars, const char *cancel_chars, - int flags, char *result_buf); -int UI_dup_input_boolean(UI *ui, const char *prompt, const char *action_desc, - const char *ok_chars, const char *cancel_chars, - int flags, char *result_buf); -int UI_add_info_string(UI *ui, const char *text); -int UI_dup_info_string(UI *ui, const char *text); -int UI_add_error_string(UI *ui, const char *text); -int UI_dup_error_string(UI *ui, const char *text); - -/* These are the possible flags. They can be or'ed together. */ -/* Use to have echoing of input */ -# define UI_INPUT_FLAG_ECHO 0x01 -/* - * Use a default password. Where that password is found is completely up to - * the application, it might for example be in the user data set with - * UI_add_user_data(). It is not recommended to have more than one input in - * each UI being marked with this flag, or the application might get - * confused. - */ -# define UI_INPUT_FLAG_DEFAULT_PWD 0x02 - -/*- - * The user of these routines may want to define flags of their own. The core - * UI won't look at those, but will pass them on to the method routines. They - * must use higher bits so they don't get confused with the UI bits above. - * UI_INPUT_FLAG_USER_BASE tells which is the lowest bit to use. A good - * example of use is this: - * - * #define MY_UI_FLAG1 (0x01 << UI_INPUT_FLAG_USER_BASE) - * -*/ -# define UI_INPUT_FLAG_USER_BASE 16 - -/*- - * The following function helps construct a prompt. object_desc is a - * textual short description of the object, for example "pass phrase", - * and object_name is the name of the object (might be a card name or - * a file name. - * The returned string shall always be allocated on the heap with - * OPENSSL_malloc(), and need to be free'd with OPENSSL_free(). - * - * If the ui_method doesn't contain a pointer to a user-defined prompt - * constructor, a default string is built, looking like this: - * - * "Enter {object_desc} for {object_name}:" - * - * So, if object_desc has the value "pass phrase" and object_name has - * the value "foo.key", the resulting string is: - * - * "Enter pass phrase for foo.key:" -*/ -char *UI_construct_prompt(UI *ui_method, - const char *object_desc, const char *object_name); - -/* - * The following function is used to store a pointer to user-specific data. - * Any previous such pointer will be returned and replaced. - * - * For callback purposes, this function makes a lot more sense than using - * ex_data, since the latter requires that different parts of OpenSSL or - * applications share the same ex_data index. - * - * Note that the UI_OpenSSL() method completely ignores the user data. Other - * methods may not, however. - */ -void *UI_add_user_data(UI *ui, void *user_data); -/* We need a user data retrieving function as well. */ -void *UI_get0_user_data(UI *ui); - -/* Return the result associated with a prompt given with the index i. */ -const char *UI_get0_result(UI *ui, int i); - -/* When all strings have been added, process the whole thing. */ -int UI_process(UI *ui); - -/* - * Give a user interface parametrised control commands. This can be used to - * send down an integer, a data pointer or a function pointer, as well as be - * used to get information from a UI. - */ -int UI_ctrl(UI *ui, int cmd, long i, void *p, void (*f) (void)); - -/* The commands */ -/* - * Use UI_CONTROL_PRINT_ERRORS with the value 1 to have UI_process print the - * OpenSSL error stack before printing any info or added error messages and - * before any prompting. - */ -# define UI_CTRL_PRINT_ERRORS 1 -/* - * Check if a UI_process() is possible to do again with the same instance of - * a user interface. This makes UI_ctrl() return 1 if it is redoable, and 0 - * if not. - */ -# define UI_CTRL_IS_REDOABLE 2 - -/* Some methods may use extra data */ -# define UI_set_app_data(s,arg) UI_set_ex_data(s,0,arg) -# define UI_get_app_data(s) UI_get_ex_data(s,0) - -#define UI_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_UI, l, p, newf, dupf, freef) -int UI_set_ex_data(UI *r, int idx, void *arg); -void *UI_get_ex_data(UI *r, int idx); - -/* Use specific methods instead of the built-in one */ -void UI_set_default_method(const UI_METHOD *meth); -const UI_METHOD *UI_get_default_method(void); -const UI_METHOD *UI_get_method(UI *ui); -const UI_METHOD *UI_set_method(UI *ui, const UI_METHOD *meth); - -/* The method with all the built-in thingies */ -UI_METHOD *UI_OpenSSL(void); - -/* ---------- For method writers ---------- */ -/*- - A method contains a number of functions that implement the low level - of the User Interface. The functions are: - - an opener This function starts a session, maybe by opening - a channel to a tty, or by opening a window. - a writer This function is called to write a given string, - maybe to the tty, maybe as a field label in a - window. - a flusher This function is called to flush everything that - has been output so far. It can be used to actually - display a dialog box after it has been built. - a reader This function is called to read a given prompt, - maybe from the tty, maybe from a field in a - window. Note that it's called with all string - structures, not only the prompt ones, so it must - check such things itself. - a closer This function closes the session, maybe by closing - the channel to the tty, or closing the window. - - All these functions are expected to return: - - 0 on error. - 1 on success. - -1 on out-of-band events, for example if some prompting has - been canceled (by pressing Ctrl-C, for example). This is - only checked when returned by the flusher or the reader. - - The way this is used, the opener is first called, then the writer for all - strings, then the flusher, then the reader for all strings and finally the - closer. Note that if you want to prompt from a terminal or other command - line interface, the best is to have the reader also write the prompts - instead of having the writer do it. If you want to prompt from a dialog - box, the writer can be used to build up the contents of the box, and the - flusher to actually display the box and run the event loop until all data - has been given, after which the reader only grabs the given data and puts - them back into the UI strings. - - All method functions take a UI as argument. Additionally, the writer and - the reader take a UI_STRING. -*/ - -/* - * The UI_STRING type is the data structure that contains all the needed info - * about a string or a prompt, including test data for a verification prompt. - */ -typedef struct ui_string_st UI_STRING; -DEFINE_STACK_OF(UI_STRING) - -/* - * The different types of strings that are currently supported. This is only - * needed by method authors. - */ -enum UI_string_types { - UIT_NONE = 0, - UIT_PROMPT, /* Prompt for a string */ - UIT_VERIFY, /* Prompt for a string and verify */ - UIT_BOOLEAN, /* Prompt for a yes/no response */ - UIT_INFO, /* Send info to the user */ - UIT_ERROR /* Send an error message to the user */ -}; - -/* Create and manipulate methods */ -UI_METHOD *UI_create_method(const char *name); -void UI_destroy_method(UI_METHOD *ui_method); -int UI_method_set_opener(UI_METHOD *method, int (*opener) (UI *ui)); -int UI_method_set_writer(UI_METHOD *method, - int (*writer) (UI *ui, UI_STRING *uis)); -int UI_method_set_flusher(UI_METHOD *method, int (*flusher) (UI *ui)); -int UI_method_set_reader(UI_METHOD *method, - int (*reader) (UI *ui, UI_STRING *uis)); -int UI_method_set_closer(UI_METHOD *method, int (*closer) (UI *ui)); -int UI_method_set_prompt_constructor(UI_METHOD *method, - char *(*prompt_constructor) (UI *ui, - const char - *object_desc, - const char - *object_name)); -int (*UI_method_get_opener(UI_METHOD *method)) (UI *); -int (*UI_method_get_writer(UI_METHOD *method)) (UI *, UI_STRING *); -int (*UI_method_get_flusher(UI_METHOD *method)) (UI *); -int (*UI_method_get_reader(UI_METHOD *method)) (UI *, UI_STRING *); -int (*UI_method_get_closer(UI_METHOD *method)) (UI *); -char *(*UI_method_get_prompt_constructor(UI_METHOD *method)) (UI *, - const char *, - const char *); - -/* - * The following functions are helpers for method writers to access relevant - * data from a UI_STRING. - */ - -/* Return type of the UI_STRING */ -enum UI_string_types UI_get_string_type(UI_STRING *uis); -/* Return input flags of the UI_STRING */ -int UI_get_input_flags(UI_STRING *uis); -/* Return the actual string to output (the prompt, info or error) */ -const char *UI_get0_output_string(UI_STRING *uis); -/* - * Return the optional action string to output (the boolean prompt - * instruction) - */ -const char *UI_get0_action_string(UI_STRING *uis); -/* Return the result of a prompt */ -const char *UI_get0_result_string(UI_STRING *uis); -/* - * Return the string to test the result against. Only useful with verifies. - */ -const char *UI_get0_test_string(UI_STRING *uis); -/* Return the required minimum size of the result */ -int UI_get_result_minsize(UI_STRING *uis); -/* Return the required maximum size of the result */ -int UI_get_result_maxsize(UI_STRING *uis); -/* Set the result of a UI_STRING. */ -int UI_set_result(UI *ui, UI_STRING *uis, const char *result); - -/* A couple of popular utility functions */ -int UI_UTIL_read_pw_string(char *buf, int length, const char *prompt, - int verify); -int UI_UTIL_read_pw(char *buf, char *buff, int size, const char *prompt, - int verify); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_UI_strings(void); - -/* Error codes for the UI functions. */ - -/* Function codes. */ -# define UI_F_GENERAL_ALLOCATE_BOOLEAN 108 -# define UI_F_GENERAL_ALLOCATE_PROMPT 109 -# define UI_F_UI_CREATE_METHOD 112 -# define UI_F_UI_CTRL 111 -# define UI_F_UI_DUP_ERROR_STRING 101 -# define UI_F_UI_DUP_INFO_STRING 102 -# define UI_F_UI_DUP_INPUT_BOOLEAN 110 -# define UI_F_UI_DUP_INPUT_STRING 103 -# define UI_F_UI_DUP_VERIFY_STRING 106 -# define UI_F_UI_GET0_RESULT 107 -# define UI_F_UI_NEW_METHOD 104 -# define UI_F_UI_SET_RESULT 105 - -/* Reason codes. */ -# define UI_R_COMMON_OK_AND_CANCEL_CHARACTERS 104 -# define UI_R_INDEX_TOO_LARGE 102 -# define UI_R_INDEX_TOO_SMALL 103 -# define UI_R_NO_RESULT_BUFFER 105 -# define UI_R_RESULT_TOO_LARGE 100 -# define UI_R_RESULT_TOO_SMALL 101 -# define UI_R_UNKNOWN_CONTROL_COMMAND 106 - -# ifdef __cplusplus -} -# endif -# endif -#endif diff --git a/android/armeabi/include/openssl/whrlpool.h b/android/armeabi/include/openssl/whrlpool.h deleted file mode 100644 index 20ea3503..00000000 --- a/android/armeabi/include/openssl/whrlpool.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2005-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_WHRLPOOL_H -# define HEADER_WHRLPOOL_H - -#include <openssl/opensslconf.h> - -# ifndef OPENSSL_NO_WHIRLPOOL -# include <openssl/e_os2.h> -# include <stddef.h> -# ifdef __cplusplus -extern "C" { -# endif - -# define WHIRLPOOL_DIGEST_LENGTH (512/8) -# define WHIRLPOOL_BBLOCK 512 -# define WHIRLPOOL_COUNTER (256/8) - -typedef struct { - union { - unsigned char c[WHIRLPOOL_DIGEST_LENGTH]; - /* double q is here to ensure 64-bit alignment */ - double q[WHIRLPOOL_DIGEST_LENGTH / sizeof(double)]; - } H; - unsigned char data[WHIRLPOOL_BBLOCK / 8]; - unsigned int bitoff; - size_t bitlen[WHIRLPOOL_COUNTER / sizeof(size_t)]; -} WHIRLPOOL_CTX; - -int WHIRLPOOL_Init(WHIRLPOOL_CTX *c); -int WHIRLPOOL_Update(WHIRLPOOL_CTX *c, const void *inp, size_t bytes); -void WHIRLPOOL_BitUpdate(WHIRLPOOL_CTX *c, const void *inp, size_t bits); -int WHIRLPOOL_Final(unsigned char *md, WHIRLPOOL_CTX *c); -unsigned char *WHIRLPOOL(const void *inp, size_t bytes, unsigned char *md); - -# ifdef __cplusplus -} -# endif -# endif - -#endif diff --git a/android/armeabi/include/openssl/x509.h b/android/armeabi/include/openssl/x509.h deleted file mode 100644 index c8996f35..00000000 --- a/android/armeabi/include/openssl/x509.h +++ /dev/null @@ -1,1123 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -/* ==================================================================== - * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. - * ECDH support in OpenSSL originally developed by - * SUN MICROSYSTEMS, INC., and contributed to the OpenSSL project. - */ - -#ifndef HEADER_X509_H -# define HEADER_X509_H - -# include <openssl/e_os2.h> -# include <openssl/ossl_typ.h> -# include <openssl/symhacks.h> -# include <openssl/buffer.h> -# include <openssl/evp.h> -# include <openssl/bio.h> -# include <openssl/stack.h> -# include <openssl/asn1.h> -# include <openssl/safestack.h> -# include <openssl/ec.h> - -# if OPENSSL_API_COMPAT < 0x10100000L -# include <openssl/rsa.h> -# include <openssl/dsa.h> -# include <openssl/dh.h> -# endif - -# include <openssl/sha.h> - -#ifdef __cplusplus -extern "C" { -#endif - -# define X509_FILETYPE_PEM 1 -# define X509_FILETYPE_ASN1 2 -# define X509_FILETYPE_DEFAULT 3 - -# define X509v3_KU_DIGITAL_SIGNATURE 0x0080 -# define X509v3_KU_NON_REPUDIATION 0x0040 -# define X509v3_KU_KEY_ENCIPHERMENT 0x0020 -# define X509v3_KU_DATA_ENCIPHERMENT 0x0010 -# define X509v3_KU_KEY_AGREEMENT 0x0008 -# define X509v3_KU_KEY_CERT_SIGN 0x0004 -# define X509v3_KU_CRL_SIGN 0x0002 -# define X509v3_KU_ENCIPHER_ONLY 0x0001 -# define X509v3_KU_DECIPHER_ONLY 0x8000 -# define X509v3_KU_UNDEF 0xffff - -struct X509_algor_st { - ASN1_OBJECT *algorithm; - ASN1_TYPE *parameter; -} /* X509_ALGOR */ ; - -typedef STACK_OF(X509_ALGOR) X509_ALGORS; - -typedef struct X509_val_st { - ASN1_TIME *notBefore; - ASN1_TIME *notAfter; -} X509_VAL; - -typedef struct X509_sig_st X509_SIG; - -typedef struct X509_name_entry_st X509_NAME_ENTRY; - -DEFINE_STACK_OF(X509_NAME_ENTRY) - -DEFINE_STACK_OF(X509_NAME) - -# define X509_EX_V_NETSCAPE_HACK 0x8000 -# define X509_EX_V_INIT 0x0001 -typedef struct X509_extension_st X509_EXTENSION; - -typedef STACK_OF(X509_EXTENSION) X509_EXTENSIONS; - -DEFINE_STACK_OF(X509_EXTENSION) - -typedef struct x509_attributes_st X509_ATTRIBUTE; - -DEFINE_STACK_OF(X509_ATTRIBUTE) - -typedef struct X509_req_info_st X509_REQ_INFO; - -typedef struct X509_req_st X509_REQ; - -typedef struct x509_cert_aux_st X509_CERT_AUX; - -typedef struct x509_cinf_st X509_CINF; - -DEFINE_STACK_OF(X509) - -/* This is used for a table of trust checking functions */ - -typedef struct x509_trust_st { - int trust; - int flags; - int (*check_trust) (struct x509_trust_st *, X509 *, int); - char *name; - int arg1; - void *arg2; -} X509_TRUST; - -DEFINE_STACK_OF(X509_TRUST) - -/* standard trust ids */ - -# define X509_TRUST_DEFAULT 0 /* Only valid in purpose settings */ - -# define X509_TRUST_COMPAT 1 -# define X509_TRUST_SSL_CLIENT 2 -# define X509_TRUST_SSL_SERVER 3 -# define X509_TRUST_EMAIL 4 -# define X509_TRUST_OBJECT_SIGN 5 -# define X509_TRUST_OCSP_SIGN 6 -# define X509_TRUST_OCSP_REQUEST 7 -# define X509_TRUST_TSA 8 - -/* Keep these up to date! */ -# define X509_TRUST_MIN 1 -# define X509_TRUST_MAX 8 - -/* trust_flags values */ -# define X509_TRUST_DYNAMIC (1U << 0) -# define X509_TRUST_DYNAMIC_NAME (1U << 1) -/* No compat trust if self-signed, preempts "DO_SS" */ -# define X509_TRUST_NO_SS_COMPAT (1U << 2) -/* Compat trust if no explicit accepted trust EKUs */ -# define X509_TRUST_DO_SS_COMPAT (1U << 3) -/* Accept "anyEKU" as a wildcard trust OID */ -# define X509_TRUST_OK_ANY_EKU (1U << 4) - -/* check_trust return codes */ - -# define X509_TRUST_TRUSTED 1 -# define X509_TRUST_REJECTED 2 -# define X509_TRUST_UNTRUSTED 3 - -/* Flags for X509_print_ex() */ - -# define X509_FLAG_COMPAT 0 -# define X509_FLAG_NO_HEADER 1L -# define X509_FLAG_NO_VERSION (1L << 1) -# define X509_FLAG_NO_SERIAL (1L << 2) -# define X509_FLAG_NO_SIGNAME (1L << 3) -# define X509_FLAG_NO_ISSUER (1L << 4) -# define X509_FLAG_NO_VALIDITY (1L << 5) -# define X509_FLAG_NO_SUBJECT (1L << 6) -# define X509_FLAG_NO_PUBKEY (1L << 7) -# define X509_FLAG_NO_EXTENSIONS (1L << 8) -# define X509_FLAG_NO_SIGDUMP (1L << 9) -# define X509_FLAG_NO_AUX (1L << 10) -# define X509_FLAG_NO_ATTRIBUTES (1L << 11) -# define X509_FLAG_NO_IDS (1L << 12) - -/* Flags specific to X509_NAME_print_ex() */ - -/* The field separator information */ - -# define XN_FLAG_SEP_MASK (0xf << 16) - -# define XN_FLAG_COMPAT 0/* Traditional; use old X509_NAME_print */ -# define XN_FLAG_SEP_COMMA_PLUS (1 << 16)/* RFC2253 ,+ */ -# define XN_FLAG_SEP_CPLUS_SPC (2 << 16)/* ,+ spaced: more readable */ -# define XN_FLAG_SEP_SPLUS_SPC (3 << 16)/* ;+ spaced */ -# define XN_FLAG_SEP_MULTILINE (4 << 16)/* One line per field */ - -# define XN_FLAG_DN_REV (1 << 20)/* Reverse DN order */ - -/* How the field name is shown */ - -# define XN_FLAG_FN_MASK (0x3 << 21) - -# define XN_FLAG_FN_SN 0/* Object short name */ -# define XN_FLAG_FN_LN (1 << 21)/* Object long name */ -# define XN_FLAG_FN_OID (2 << 21)/* Always use OIDs */ -# define XN_FLAG_FN_NONE (3 << 21)/* No field names */ - -# define XN_FLAG_SPC_EQ (1 << 23)/* Put spaces round '=' */ - -/* - * This determines if we dump fields we don't recognise: RFC2253 requires - * this. - */ - -# define XN_FLAG_DUMP_UNKNOWN_FIELDS (1 << 24) - -# define XN_FLAG_FN_ALIGN (1 << 25)/* Align field names to 20 - * characters */ - -/* Complete set of RFC2253 flags */ - -# define XN_FLAG_RFC2253 (ASN1_STRFLGS_RFC2253 | \ - XN_FLAG_SEP_COMMA_PLUS | \ - XN_FLAG_DN_REV | \ - XN_FLAG_FN_SN | \ - XN_FLAG_DUMP_UNKNOWN_FIELDS) - -/* readable oneline form */ - -# define XN_FLAG_ONELINE (ASN1_STRFLGS_RFC2253 | \ - ASN1_STRFLGS_ESC_QUOTE | \ - XN_FLAG_SEP_CPLUS_SPC | \ - XN_FLAG_SPC_EQ | \ - XN_FLAG_FN_SN) - -/* readable multiline form */ - -# define XN_FLAG_MULTILINE (ASN1_STRFLGS_ESC_CTRL | \ - ASN1_STRFLGS_ESC_MSB | \ - XN_FLAG_SEP_MULTILINE | \ - XN_FLAG_SPC_EQ | \ - XN_FLAG_FN_LN | \ - XN_FLAG_FN_ALIGN) - -DEFINE_STACK_OF(X509_REVOKED) - -typedef struct X509_crl_info_st X509_CRL_INFO; - -DEFINE_STACK_OF(X509_CRL) - -typedef struct private_key_st { - int version; - /* The PKCS#8 data types */ - X509_ALGOR *enc_algor; - ASN1_OCTET_STRING *enc_pkey; /* encrypted pub key */ - /* When decrypted, the following will not be NULL */ - EVP_PKEY *dec_pkey; - /* used to encrypt and decrypt */ - int key_length; - char *key_data; - int key_free; /* true if we should auto free key_data */ - /* expanded version of 'enc_algor' */ - EVP_CIPHER_INFO cipher; -} X509_PKEY; - -typedef struct X509_info_st { - X509 *x509; - X509_CRL *crl; - X509_PKEY *x_pkey; - EVP_CIPHER_INFO enc_cipher; - int enc_len; - char *enc_data; -} X509_INFO; - -DEFINE_STACK_OF(X509_INFO) - -/* - * The next 2 structures and their 8 routines were sent to me by Pat Richard - * <patr@x509.com> and are used to manipulate Netscapes spki structures - - * useful if you are writing a CA web page - */ -typedef struct Netscape_spkac_st { - X509_PUBKEY *pubkey; - ASN1_IA5STRING *challenge; /* challenge sent in atlas >= PR2 */ -} NETSCAPE_SPKAC; - -typedef struct Netscape_spki_st { - NETSCAPE_SPKAC *spkac; /* signed public key and challenge */ - X509_ALGOR sig_algor; - ASN1_BIT_STRING *signature; -} NETSCAPE_SPKI; - -/* Netscape certificate sequence structure */ -typedef struct Netscape_certificate_sequence { - ASN1_OBJECT *type; - STACK_OF(X509) *certs; -} NETSCAPE_CERT_SEQUENCE; - -/*- Unused (and iv length is wrong) -typedef struct CBCParameter_st - { - unsigned char iv[8]; - } CBC_PARAM; -*/ - -/* Password based encryption structure */ - -typedef struct PBEPARAM_st { - ASN1_OCTET_STRING *salt; - ASN1_INTEGER *iter; -} PBEPARAM; - -/* Password based encryption V2 structures */ - -typedef struct PBE2PARAM_st { - X509_ALGOR *keyfunc; - X509_ALGOR *encryption; -} PBE2PARAM; - -typedef struct PBKDF2PARAM_st { -/* Usually OCTET STRING but could be anything */ - ASN1_TYPE *salt; - ASN1_INTEGER *iter; - ASN1_INTEGER *keylength; - X509_ALGOR *prf; -} PBKDF2PARAM; - -#ifdef __cplusplus -} -#endif - -# include <openssl/x509_vfy.h> -# include <openssl/pkcs7.h> - -#ifdef __cplusplus -extern "C" { -#endif - -# define X509_EXT_PACK_UNKNOWN 1 -# define X509_EXT_PACK_STRING 2 - -# define X509_extract_key(x) X509_get_pubkey(x)/*****/ -# define X509_REQ_extract_key(a) X509_REQ_get_pubkey(a) -# define X509_name_cmp(a,b) X509_NAME_cmp((a),(b)) - -void X509_CRL_set_default_method(const X509_CRL_METHOD *meth); -X509_CRL_METHOD *X509_CRL_METHOD_new(int (*crl_init) (X509_CRL *crl), - int (*crl_free) (X509_CRL *crl), - int (*crl_lookup) (X509_CRL *crl, - X509_REVOKED **ret, - ASN1_INTEGER *ser, - X509_NAME *issuer), - int (*crl_verify) (X509_CRL *crl, - EVP_PKEY *pk)); -void X509_CRL_METHOD_free(X509_CRL_METHOD *m); - -void X509_CRL_set_meth_data(X509_CRL *crl, void *dat); -void *X509_CRL_get_meth_data(X509_CRL *crl); - -const char *X509_verify_cert_error_string(long n); - -int X509_verify(X509 *a, EVP_PKEY *r); - -int X509_REQ_verify(X509_REQ *a, EVP_PKEY *r); -int X509_CRL_verify(X509_CRL *a, EVP_PKEY *r); -int NETSCAPE_SPKI_verify(NETSCAPE_SPKI *a, EVP_PKEY *r); - -NETSCAPE_SPKI *NETSCAPE_SPKI_b64_decode(const char *str, int len); -char *NETSCAPE_SPKI_b64_encode(NETSCAPE_SPKI *x); -EVP_PKEY *NETSCAPE_SPKI_get_pubkey(NETSCAPE_SPKI *x); -int NETSCAPE_SPKI_set_pubkey(NETSCAPE_SPKI *x, EVP_PKEY *pkey); - -int NETSCAPE_SPKI_print(BIO *out, NETSCAPE_SPKI *spki); - -int X509_signature_dump(BIO *bp, const ASN1_STRING *sig, int indent); -int X509_signature_print(BIO *bp, const X509_ALGOR *alg, - const ASN1_STRING *sig); - -int X509_sign(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); -int X509_sign_ctx(X509 *x, EVP_MD_CTX *ctx); -# ifndef OPENSSL_NO_OCSP -int X509_http_nbio(OCSP_REQ_CTX *rctx, X509 **pcert); -# endif -int X509_REQ_sign(X509_REQ *x, EVP_PKEY *pkey, const EVP_MD *md); -int X509_REQ_sign_ctx(X509_REQ *x, EVP_MD_CTX *ctx); -int X509_CRL_sign(X509_CRL *x, EVP_PKEY *pkey, const EVP_MD *md); -int X509_CRL_sign_ctx(X509_CRL *x, EVP_MD_CTX *ctx); -# ifndef OPENSSL_NO_OCSP -int X509_CRL_http_nbio(OCSP_REQ_CTX *rctx, X509_CRL **pcrl); -# endif -int NETSCAPE_SPKI_sign(NETSCAPE_SPKI *x, EVP_PKEY *pkey, const EVP_MD *md); - -int X509_pubkey_digest(const X509 *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_digest(const X509 *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_REQ_digest(const X509_REQ *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); -int X509_NAME_digest(const X509_NAME *data, const EVP_MD *type, - unsigned char *md, unsigned int *len); - -# ifndef OPENSSL_NO_STDIO -X509 *d2i_X509_fp(FILE *fp, X509 **x509); -int i2d_X509_fp(FILE *fp, X509 *x509); -X509_CRL *d2i_X509_CRL_fp(FILE *fp, X509_CRL **crl); -int i2d_X509_CRL_fp(FILE *fp, X509_CRL *crl); -X509_REQ *d2i_X509_REQ_fp(FILE *fp, X509_REQ **req); -int i2d_X509_REQ_fp(FILE *fp, X509_REQ *req); -# ifndef OPENSSL_NO_RSA -RSA *d2i_RSAPrivateKey_fp(FILE *fp, RSA **rsa); -int i2d_RSAPrivateKey_fp(FILE *fp, RSA *rsa); -RSA *d2i_RSAPublicKey_fp(FILE *fp, RSA **rsa); -int i2d_RSAPublicKey_fp(FILE *fp, RSA *rsa); -RSA *d2i_RSA_PUBKEY_fp(FILE *fp, RSA **rsa); -int i2d_RSA_PUBKEY_fp(FILE *fp, RSA *rsa); -# endif -# ifndef OPENSSL_NO_DSA -DSA *d2i_DSA_PUBKEY_fp(FILE *fp, DSA **dsa); -int i2d_DSA_PUBKEY_fp(FILE *fp, DSA *dsa); -DSA *d2i_DSAPrivateKey_fp(FILE *fp, DSA **dsa); -int i2d_DSAPrivateKey_fp(FILE *fp, DSA *dsa); -# endif -# ifndef OPENSSL_NO_EC -EC_KEY *d2i_EC_PUBKEY_fp(FILE *fp, EC_KEY **eckey); -int i2d_EC_PUBKEY_fp(FILE *fp, EC_KEY *eckey); -EC_KEY *d2i_ECPrivateKey_fp(FILE *fp, EC_KEY **eckey); -int i2d_ECPrivateKey_fp(FILE *fp, EC_KEY *eckey); -# endif -X509_SIG *d2i_PKCS8_fp(FILE *fp, X509_SIG **p8); -int i2d_PKCS8_fp(FILE *fp, X509_SIG *p8); -PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, - PKCS8_PRIV_KEY_INFO **p8inf); -int i2d_PKCS8_PRIV_KEY_INFO_fp(FILE *fp, PKCS8_PRIV_KEY_INFO *p8inf); -int i2d_PKCS8PrivateKeyInfo_fp(FILE *fp, EVP_PKEY *key); -int i2d_PrivateKey_fp(FILE *fp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PrivateKey_fp(FILE *fp, EVP_PKEY **a); -int i2d_PUBKEY_fp(FILE *fp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PUBKEY_fp(FILE *fp, EVP_PKEY **a); -# endif - -X509 *d2i_X509_bio(BIO *bp, X509 **x509); -int i2d_X509_bio(BIO *bp, X509 *x509); -X509_CRL *d2i_X509_CRL_bio(BIO *bp, X509_CRL **crl); -int i2d_X509_CRL_bio(BIO *bp, X509_CRL *crl); -X509_REQ *d2i_X509_REQ_bio(BIO *bp, X509_REQ **req); -int i2d_X509_REQ_bio(BIO *bp, X509_REQ *req); -# ifndef OPENSSL_NO_RSA -RSA *d2i_RSAPrivateKey_bio(BIO *bp, RSA **rsa); -int i2d_RSAPrivateKey_bio(BIO *bp, RSA *rsa); -RSA *d2i_RSAPublicKey_bio(BIO *bp, RSA **rsa); -int i2d_RSAPublicKey_bio(BIO *bp, RSA *rsa); -RSA *d2i_RSA_PUBKEY_bio(BIO *bp, RSA **rsa); -int i2d_RSA_PUBKEY_bio(BIO *bp, RSA *rsa); -# endif -# ifndef OPENSSL_NO_DSA -DSA *d2i_DSA_PUBKEY_bio(BIO *bp, DSA **dsa); -int i2d_DSA_PUBKEY_bio(BIO *bp, DSA *dsa); -DSA *d2i_DSAPrivateKey_bio(BIO *bp, DSA **dsa); -int i2d_DSAPrivateKey_bio(BIO *bp, DSA *dsa); -# endif -# ifndef OPENSSL_NO_EC -EC_KEY *d2i_EC_PUBKEY_bio(BIO *bp, EC_KEY **eckey); -int i2d_EC_PUBKEY_bio(BIO *bp, EC_KEY *eckey); -EC_KEY *d2i_ECPrivateKey_bio(BIO *bp, EC_KEY **eckey); -int i2d_ECPrivateKey_bio(BIO *bp, EC_KEY *eckey); -# endif -X509_SIG *d2i_PKCS8_bio(BIO *bp, X509_SIG **p8); -int i2d_PKCS8_bio(BIO *bp, X509_SIG *p8); -PKCS8_PRIV_KEY_INFO *d2i_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, - PKCS8_PRIV_KEY_INFO **p8inf); -int i2d_PKCS8_PRIV_KEY_INFO_bio(BIO *bp, PKCS8_PRIV_KEY_INFO *p8inf); -int i2d_PKCS8PrivateKeyInfo_bio(BIO *bp, EVP_PKEY *key); -int i2d_PrivateKey_bio(BIO *bp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PrivateKey_bio(BIO *bp, EVP_PKEY **a); -int i2d_PUBKEY_bio(BIO *bp, EVP_PKEY *pkey); -EVP_PKEY *d2i_PUBKEY_bio(BIO *bp, EVP_PKEY **a); - -X509 *X509_dup(X509 *x509); -X509_ATTRIBUTE *X509_ATTRIBUTE_dup(X509_ATTRIBUTE *xa); -X509_EXTENSION *X509_EXTENSION_dup(X509_EXTENSION *ex); -X509_CRL *X509_CRL_dup(X509_CRL *crl); -X509_REVOKED *X509_REVOKED_dup(X509_REVOKED *rev); -X509_REQ *X509_REQ_dup(X509_REQ *req); -X509_ALGOR *X509_ALGOR_dup(X509_ALGOR *xn); -int X509_ALGOR_set0(X509_ALGOR *alg, ASN1_OBJECT *aobj, int ptype, - void *pval); -void X509_ALGOR_get0(const ASN1_OBJECT **paobj, int *pptype, - const void **ppval, const X509_ALGOR *algor); -void X509_ALGOR_set_md(X509_ALGOR *alg, const EVP_MD *md); -int X509_ALGOR_cmp(const X509_ALGOR *a, const X509_ALGOR *b); - -X509_NAME *X509_NAME_dup(X509_NAME *xn); -X509_NAME_ENTRY *X509_NAME_ENTRY_dup(X509_NAME_ENTRY *ne); - -int X509_cmp_time(const ASN1_TIME *s, time_t *t); -int X509_cmp_current_time(const ASN1_TIME *s); -ASN1_TIME *X509_time_adj(ASN1_TIME *s, long adj, time_t *t); -ASN1_TIME *X509_time_adj_ex(ASN1_TIME *s, - int offset_day, long offset_sec, time_t *t); -ASN1_TIME *X509_gmtime_adj(ASN1_TIME *s, long adj); - -const char *X509_get_default_cert_area(void); -const char *X509_get_default_cert_dir(void); -const char *X509_get_default_cert_file(void); -const char *X509_get_default_cert_dir_env(void); -const char *X509_get_default_cert_file_env(void); -const char *X509_get_default_private_dir(void); - -X509_REQ *X509_to_X509_REQ(X509 *x, EVP_PKEY *pkey, const EVP_MD *md); -X509 *X509_REQ_to_X509(X509_REQ *r, int days, EVP_PKEY *pkey); - -DECLARE_ASN1_FUNCTIONS(X509_ALGOR) -DECLARE_ASN1_ENCODE_FUNCTIONS(X509_ALGORS, X509_ALGORS, X509_ALGORS) -DECLARE_ASN1_FUNCTIONS(X509_VAL) - -DECLARE_ASN1_FUNCTIONS(X509_PUBKEY) - -int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey); -EVP_PKEY *X509_PUBKEY_get0(X509_PUBKEY *key); -EVP_PKEY *X509_PUBKEY_get(X509_PUBKEY *key); -int X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain); -long X509_get_pathlen(X509 *x); -int i2d_PUBKEY(EVP_PKEY *a, unsigned char **pp); -EVP_PKEY *d2i_PUBKEY(EVP_PKEY **a, const unsigned char **pp, long length); -# ifndef OPENSSL_NO_RSA -int i2d_RSA_PUBKEY(RSA *a, unsigned char **pp); -RSA *d2i_RSA_PUBKEY(RSA **a, const unsigned char **pp, long length); -# endif -# ifndef OPENSSL_NO_DSA -int i2d_DSA_PUBKEY(DSA *a, unsigned char **pp); -DSA *d2i_DSA_PUBKEY(DSA **a, const unsigned char **pp, long length); -# endif -# ifndef OPENSSL_NO_EC -int i2d_EC_PUBKEY(EC_KEY *a, unsigned char **pp); -EC_KEY *d2i_EC_PUBKEY(EC_KEY **a, const unsigned char **pp, long length); -# endif - -DECLARE_ASN1_FUNCTIONS(X509_SIG) -void X509_SIG_get0(const X509_SIG *sig, const X509_ALGOR **palg, - const ASN1_OCTET_STRING **pdigest); -void X509_SIG_getm(X509_SIG *sig, X509_ALGOR **palg, - ASN1_OCTET_STRING **pdigest); - -DECLARE_ASN1_FUNCTIONS(X509_REQ_INFO) -DECLARE_ASN1_FUNCTIONS(X509_REQ) - -DECLARE_ASN1_FUNCTIONS(X509_ATTRIBUTE) -X509_ATTRIBUTE *X509_ATTRIBUTE_create(int nid, int atrtype, void *value); - -DECLARE_ASN1_FUNCTIONS(X509_EXTENSION) -DECLARE_ASN1_ENCODE_FUNCTIONS(X509_EXTENSIONS, X509_EXTENSIONS, X509_EXTENSIONS) - -DECLARE_ASN1_FUNCTIONS(X509_NAME_ENTRY) - -DECLARE_ASN1_FUNCTIONS(X509_NAME) - -int X509_NAME_set(X509_NAME **xn, X509_NAME *name); - -DECLARE_ASN1_FUNCTIONS(X509_CINF) - -DECLARE_ASN1_FUNCTIONS(X509) -DECLARE_ASN1_FUNCTIONS(X509_CERT_AUX) - -#define X509_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509, l, p, newf, dupf, freef) -int X509_set_ex_data(X509 *r, int idx, void *arg); -void *X509_get_ex_data(X509 *r, int idx); -int i2d_X509_AUX(X509 *a, unsigned char **pp); -X509 *d2i_X509_AUX(X509 **a, const unsigned char **pp, long length); - -int i2d_re_X509_tbs(X509 *x, unsigned char **pp); - -void X509_get0_signature(const ASN1_BIT_STRING **psig, - const X509_ALGOR **palg, const X509 *x); -int X509_get_signature_nid(const X509 *x); - -int X509_trusted(const X509 *x); -int X509_alias_set1(X509 *x, const unsigned char *name, int len); -int X509_keyid_set1(X509 *x, const unsigned char *id, int len); -unsigned char *X509_alias_get0(X509 *x, int *len); -unsigned char *X509_keyid_get0(X509 *x, int *len); -int (*X509_TRUST_set_default(int (*trust) (int, X509 *, int))) (int, X509 *, - int); -int X509_TRUST_set(int *t, int trust); -int X509_add1_trust_object(X509 *x, const ASN1_OBJECT *obj); -int X509_add1_reject_object(X509 *x, const ASN1_OBJECT *obj); -void X509_trust_clear(X509 *x); -void X509_reject_clear(X509 *x); - -STACK_OF(ASN1_OBJECT) *X509_get0_trust_objects(X509 *x); -STACK_OF(ASN1_OBJECT) *X509_get0_reject_objects(X509 *x); - -DECLARE_ASN1_FUNCTIONS(X509_REVOKED) -DECLARE_ASN1_FUNCTIONS(X509_CRL_INFO) -DECLARE_ASN1_FUNCTIONS(X509_CRL) - -int X509_CRL_add0_revoked(X509_CRL *crl, X509_REVOKED *rev); -int X509_CRL_get0_by_serial(X509_CRL *crl, - X509_REVOKED **ret, ASN1_INTEGER *serial); -int X509_CRL_get0_by_cert(X509_CRL *crl, X509_REVOKED **ret, X509 *x); - -X509_PKEY *X509_PKEY_new(void); -void X509_PKEY_free(X509_PKEY *a); - -DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKI) -DECLARE_ASN1_FUNCTIONS(NETSCAPE_SPKAC) -DECLARE_ASN1_FUNCTIONS(NETSCAPE_CERT_SEQUENCE) - -X509_INFO *X509_INFO_new(void); -void X509_INFO_free(X509_INFO *a); -char *X509_NAME_oneline(const X509_NAME *a, char *buf, int size); - -int ASN1_verify(i2d_of_void *i2d, X509_ALGOR *algor1, - ASN1_BIT_STRING *signature, char *data, EVP_PKEY *pkey); - -int ASN1_digest(i2d_of_void *i2d, const EVP_MD *type, char *data, - unsigned char *md, unsigned int *len); - -int ASN1_sign(i2d_of_void *i2d, X509_ALGOR *algor1, - X509_ALGOR *algor2, ASN1_BIT_STRING *signature, - char *data, EVP_PKEY *pkey, const EVP_MD *type); - -int ASN1_item_digest(const ASN1_ITEM *it, const EVP_MD *type, void *data, - unsigned char *md, unsigned int *len); - -int ASN1_item_verify(const ASN1_ITEM *it, X509_ALGOR *algor1, - ASN1_BIT_STRING *signature, void *data, EVP_PKEY *pkey); - -int ASN1_item_sign(const ASN1_ITEM *it, X509_ALGOR *algor1, - X509_ALGOR *algor2, ASN1_BIT_STRING *signature, void *data, - EVP_PKEY *pkey, const EVP_MD *type); -int ASN1_item_sign_ctx(const ASN1_ITEM *it, X509_ALGOR *algor1, - X509_ALGOR *algor2, ASN1_BIT_STRING *signature, - void *asn, EVP_MD_CTX *ctx); - -long X509_get_version(const X509 *x); -int X509_set_version(X509 *x, long version); -int X509_set_serialNumber(X509 *x, ASN1_INTEGER *serial); -ASN1_INTEGER *X509_get_serialNumber(X509 *x); -const ASN1_INTEGER *X509_get0_serialNumber(const X509 *x); -int X509_set_issuer_name(X509 *x, X509_NAME *name); -X509_NAME *X509_get_issuer_name(const X509 *a); -int X509_set_subject_name(X509 *x, X509_NAME *name); -X509_NAME *X509_get_subject_name(const X509 *a); -const ASN1_TIME * X509_get0_notBefore(const X509 *x); -ASN1_TIME *X509_getm_notBefore(const X509 *x); -int X509_set1_notBefore(X509 *x, const ASN1_TIME *tm); -const ASN1_TIME *X509_get0_notAfter(const X509 *x); -ASN1_TIME *X509_getm_notAfter(const X509 *x); -int X509_set1_notAfter(X509 *x, const ASN1_TIME *tm); -int X509_set_pubkey(X509 *x, EVP_PKEY *pkey); -int X509_up_ref(X509 *x); -int X509_get_signature_type(const X509 *x); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define X509_get_notBefore X509_getm_notBefore -# define X509_get_notAfter X509_getm_notAfter -# define X509_set_notBefore X509_set1_notBefore -# define X509_set_notAfter X509_set1_notAfter -#endif - - -/* - * This one is only used so that a binary form can output, as in - * i2d_X509_NAME(X509_get_X509_PUBKEY(x),&buf) - */ -X509_PUBKEY *X509_get_X509_PUBKEY(const X509 *x); -const STACK_OF(X509_EXTENSION) *X509_get0_extensions(const X509 *x); -void X509_get0_uids(const X509 *x, const ASN1_BIT_STRING **piuid, - const ASN1_BIT_STRING **psuid); -const X509_ALGOR *X509_get0_tbs_sigalg(const X509 *x); - -EVP_PKEY *X509_get0_pubkey(const X509 *x); -EVP_PKEY *X509_get_pubkey(X509 *x); -ASN1_BIT_STRING *X509_get0_pubkey_bitstr(const X509 *x); -int X509_certificate_type(const X509 *x, const EVP_PKEY *pubkey); - -long X509_REQ_get_version(const X509_REQ *req); -int X509_REQ_set_version(X509_REQ *x, long version); -X509_NAME *X509_REQ_get_subject_name(const X509_REQ *req); -int X509_REQ_set_subject_name(X509_REQ *req, X509_NAME *name); -void X509_REQ_get0_signature(const X509_REQ *req, const ASN1_BIT_STRING **psig, - const X509_ALGOR **palg); -int X509_REQ_get_signature_nid(const X509_REQ *req); -int i2d_re_X509_REQ_tbs(X509_REQ *req, unsigned char **pp); -int X509_REQ_set_pubkey(X509_REQ *x, EVP_PKEY *pkey); -EVP_PKEY *X509_REQ_get_pubkey(X509_REQ *req); -EVP_PKEY *X509_REQ_get0_pubkey(X509_REQ *req); -X509_PUBKEY *X509_REQ_get_X509_PUBKEY(X509_REQ *req); -int X509_REQ_extension_nid(int nid); -int *X509_REQ_get_extension_nids(void); -void X509_REQ_set_extension_nids(int *nids); -STACK_OF(X509_EXTENSION) *X509_REQ_get_extensions(X509_REQ *req); -int X509_REQ_add_extensions_nid(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts, - int nid); -int X509_REQ_add_extensions(X509_REQ *req, STACK_OF(X509_EXTENSION) *exts); -int X509_REQ_get_attr_count(const X509_REQ *req); -int X509_REQ_get_attr_by_NID(const X509_REQ *req, int nid, int lastpos); -int X509_REQ_get_attr_by_OBJ(const X509_REQ *req, const ASN1_OBJECT *obj, - int lastpos); -X509_ATTRIBUTE *X509_REQ_get_attr(const X509_REQ *req, int loc); -X509_ATTRIBUTE *X509_REQ_delete_attr(X509_REQ *req, int loc); -int X509_REQ_add1_attr(X509_REQ *req, X509_ATTRIBUTE *attr); -int X509_REQ_add1_attr_by_OBJ(X509_REQ *req, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); -int X509_REQ_add1_attr_by_NID(X509_REQ *req, - int nid, int type, - const unsigned char *bytes, int len); -int X509_REQ_add1_attr_by_txt(X509_REQ *req, - const char *attrname, int type, - const unsigned char *bytes, int len); - -int X509_CRL_set_version(X509_CRL *x, long version); -int X509_CRL_set_issuer_name(X509_CRL *x, X509_NAME *name); -int X509_CRL_set1_lastUpdate(X509_CRL *x, const ASN1_TIME *tm); -int X509_CRL_set1_nextUpdate(X509_CRL *x, const ASN1_TIME *tm); -int X509_CRL_sort(X509_CRL *crl); -int X509_CRL_up_ref(X509_CRL *crl); - -# if OPENSSL_API_COMPAT < 0x10100000L -# define X509_CRL_set_lastUpdate X509_CRL_set1_lastUpdate -# define X509_CRL_set_nextUpdate X509_CRL_set1_nextUpdate -#endif - -long X509_CRL_get_version(const X509_CRL *crl); -const ASN1_TIME *X509_CRL_get0_lastUpdate(const X509_CRL *crl); -const ASN1_TIME *X509_CRL_get0_nextUpdate(const X509_CRL *crl); -DEPRECATEDIN_1_1_0(ASN1_TIME *X509_CRL_get_lastUpdate(X509_CRL *crl)) -DEPRECATEDIN_1_1_0(ASN1_TIME *X509_CRL_get_nextUpdate(X509_CRL *crl)) -X509_NAME *X509_CRL_get_issuer(const X509_CRL *crl); -const STACK_OF(X509_EXTENSION) *X509_CRL_get0_extensions(const X509_CRL *crl); -STACK_OF(X509_REVOKED) *X509_CRL_get_REVOKED(X509_CRL *crl); -void X509_CRL_get0_signature(const X509_CRL *crl, const ASN1_BIT_STRING **psig, - const X509_ALGOR **palg); -int X509_CRL_get_signature_nid(const X509_CRL *crl); -int i2d_re_X509_CRL_tbs(X509_CRL *req, unsigned char **pp); - -const ASN1_INTEGER *X509_REVOKED_get0_serialNumber(const X509_REVOKED *x); -int X509_REVOKED_set_serialNumber(X509_REVOKED *x, ASN1_INTEGER *serial); -const ASN1_TIME *X509_REVOKED_get0_revocationDate(const X509_REVOKED *x); -int X509_REVOKED_set_revocationDate(X509_REVOKED *r, ASN1_TIME *tm); -const STACK_OF(X509_EXTENSION) * -X509_REVOKED_get0_extensions(const X509_REVOKED *r); - -X509_CRL *X509_CRL_diff(X509_CRL *base, X509_CRL *newer, - EVP_PKEY *skey, const EVP_MD *md, unsigned int flags); - -int X509_REQ_check_private_key(X509_REQ *x509, EVP_PKEY *pkey); - -int X509_check_private_key(const X509 *x509, const EVP_PKEY *pkey); -int X509_chain_check_suiteb(int *perror_depth, - X509 *x, STACK_OF(X509) *chain, - unsigned long flags); -int X509_CRL_check_suiteb(X509_CRL *crl, EVP_PKEY *pk, unsigned long flags); -STACK_OF(X509) *X509_chain_up_ref(STACK_OF(X509) *chain); - -int X509_issuer_and_serial_cmp(const X509 *a, const X509 *b); -unsigned long X509_issuer_and_serial_hash(X509 *a); - -int X509_issuer_name_cmp(const X509 *a, const X509 *b); -unsigned long X509_issuer_name_hash(X509 *a); - -int X509_subject_name_cmp(const X509 *a, const X509 *b); -unsigned long X509_subject_name_hash(X509 *x); - -# ifndef OPENSSL_NO_MD5 -unsigned long X509_issuer_name_hash_old(X509 *a); -unsigned long X509_subject_name_hash_old(X509 *x); -# endif - -int X509_cmp(const X509 *a, const X509 *b); -int X509_NAME_cmp(const X509_NAME *a, const X509_NAME *b); -unsigned long X509_NAME_hash(X509_NAME *x); -unsigned long X509_NAME_hash_old(X509_NAME *x); - -int X509_CRL_cmp(const X509_CRL *a, const X509_CRL *b); -int X509_CRL_match(const X509_CRL *a, const X509_CRL *b); -int X509_aux_print(BIO *out, X509 *x, int indent); -# ifndef OPENSSL_NO_STDIO -int X509_print_ex_fp(FILE *bp, X509 *x, unsigned long nmflag, - unsigned long cflag); -int X509_print_fp(FILE *bp, X509 *x); -int X509_CRL_print_fp(FILE *bp, X509_CRL *x); -int X509_REQ_print_fp(FILE *bp, X509_REQ *req); -int X509_NAME_print_ex_fp(FILE *fp, const X509_NAME *nm, int indent, - unsigned long flags); -# endif - -int X509_NAME_print(BIO *bp, const X509_NAME *name, int obase); -int X509_NAME_print_ex(BIO *out, const X509_NAME *nm, int indent, - unsigned long flags); -int X509_print_ex(BIO *bp, X509 *x, unsigned long nmflag, - unsigned long cflag); -int X509_print(BIO *bp, X509 *x); -int X509_ocspid_print(BIO *bp, X509 *x); -int X509_CRL_print(BIO *bp, X509_CRL *x); -int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflag, - unsigned long cflag); -int X509_REQ_print(BIO *bp, X509_REQ *req); - -int X509_NAME_entry_count(const X509_NAME *name); -int X509_NAME_get_text_by_NID(X509_NAME *name, int nid, char *buf, int len); -int X509_NAME_get_text_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, - char *buf, int len); - -/* - * NOTE: you should be passing -1, not 0 as lastpos. The functions that use - * lastpos, search after that position on. - */ -int X509_NAME_get_index_by_NID(X509_NAME *name, int nid, int lastpos); -int X509_NAME_get_index_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, - int lastpos); -X509_NAME_ENTRY *X509_NAME_get_entry(const X509_NAME *name, int loc); -X509_NAME_ENTRY *X509_NAME_delete_entry(X509_NAME *name, int loc); -int X509_NAME_add_entry(X509_NAME *name, const X509_NAME_ENTRY *ne, - int loc, int set); -int X509_NAME_add_entry_by_OBJ(X509_NAME *name, const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len, int loc, - int set); -int X509_NAME_add_entry_by_NID(X509_NAME *name, int nid, int type, - const unsigned char *bytes, int len, int loc, - int set); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, - const char *field, int type, - const unsigned char *bytes, - int len); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_NID(X509_NAME_ENTRY **ne, int nid, - int type, - const unsigned char *bytes, - int len); -int X509_NAME_add_entry_by_txt(X509_NAME *name, const char *field, int type, - const unsigned char *bytes, int len, int loc, - int set); -X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_OBJ(X509_NAME_ENTRY **ne, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, - int len); -int X509_NAME_ENTRY_set_object(X509_NAME_ENTRY *ne, const ASN1_OBJECT *obj); -int X509_NAME_ENTRY_set_data(X509_NAME_ENTRY *ne, int type, - const unsigned char *bytes, int len); -ASN1_OBJECT *X509_NAME_ENTRY_get_object(const X509_NAME_ENTRY *ne); -ASN1_STRING * X509_NAME_ENTRY_get_data(const X509_NAME_ENTRY *ne); -int X509_NAME_ENTRY_set(const X509_NAME_ENTRY *ne); - -int X509_NAME_get0_der(X509_NAME *nm, const unsigned char **pder, - size_t *pderlen); - -int X509v3_get_ext_count(const STACK_OF(X509_EXTENSION) *x); -int X509v3_get_ext_by_NID(const STACK_OF(X509_EXTENSION) *x, - int nid, int lastpos); -int X509v3_get_ext_by_OBJ(const STACK_OF(X509_EXTENSION) *x, - const ASN1_OBJECT *obj, int lastpos); -int X509v3_get_ext_by_critical(const STACK_OF(X509_EXTENSION) *x, - int crit, int lastpos); -X509_EXTENSION *X509v3_get_ext(const STACK_OF(X509_EXTENSION) *x, int loc); -X509_EXTENSION *X509v3_delete_ext(STACK_OF(X509_EXTENSION) *x, int loc); -STACK_OF(X509_EXTENSION) *X509v3_add_ext(STACK_OF(X509_EXTENSION) **x, - X509_EXTENSION *ex, int loc); - -int X509_get_ext_count(const X509 *x); -int X509_get_ext_by_NID(const X509 *x, int nid, int lastpos); -int X509_get_ext_by_OBJ(const X509 *x, const ASN1_OBJECT *obj, int lastpos); -int X509_get_ext_by_critical(const X509 *x, int crit, int lastpos); -X509_EXTENSION *X509_get_ext(const X509 *x, int loc); -X509_EXTENSION *X509_delete_ext(X509 *x, int loc); -int X509_add_ext(X509 *x, X509_EXTENSION *ex, int loc); -void *X509_get_ext_d2i(const X509 *x, int nid, int *crit, int *idx); -int X509_add1_ext_i2d(X509 *x, int nid, void *value, int crit, - unsigned long flags); - -int X509_CRL_get_ext_count(const X509_CRL *x); -int X509_CRL_get_ext_by_NID(const X509_CRL *x, int nid, int lastpos); -int X509_CRL_get_ext_by_OBJ(const X509_CRL *x, const ASN1_OBJECT *obj, - int lastpos); -int X509_CRL_get_ext_by_critical(const X509_CRL *x, int crit, int lastpos); -X509_EXTENSION *X509_CRL_get_ext(const X509_CRL *x, int loc); -X509_EXTENSION *X509_CRL_delete_ext(X509_CRL *x, int loc); -int X509_CRL_add_ext(X509_CRL *x, X509_EXTENSION *ex, int loc); -void *X509_CRL_get_ext_d2i(const X509_CRL *x, int nid, int *crit, int *idx); -int X509_CRL_add1_ext_i2d(X509_CRL *x, int nid, void *value, int crit, - unsigned long flags); - -int X509_REVOKED_get_ext_count(const X509_REVOKED *x); -int X509_REVOKED_get_ext_by_NID(const X509_REVOKED *x, int nid, int lastpos); -int X509_REVOKED_get_ext_by_OBJ(const X509_REVOKED *x, const ASN1_OBJECT *obj, - int lastpos); -int X509_REVOKED_get_ext_by_critical(const X509_REVOKED *x, int crit, - int lastpos); -X509_EXTENSION *X509_REVOKED_get_ext(const X509_REVOKED *x, int loc); -X509_EXTENSION *X509_REVOKED_delete_ext(X509_REVOKED *x, int loc); -int X509_REVOKED_add_ext(X509_REVOKED *x, X509_EXTENSION *ex, int loc); -void *X509_REVOKED_get_ext_d2i(const X509_REVOKED *x, int nid, int *crit, - int *idx); -int X509_REVOKED_add1_ext_i2d(X509_REVOKED *x, int nid, void *value, int crit, - unsigned long flags); - -X509_EXTENSION *X509_EXTENSION_create_by_NID(X509_EXTENSION **ex, - int nid, int crit, - ASN1_OCTET_STRING *data); -X509_EXTENSION *X509_EXTENSION_create_by_OBJ(X509_EXTENSION **ex, - const ASN1_OBJECT *obj, int crit, - ASN1_OCTET_STRING *data); -int X509_EXTENSION_set_object(X509_EXTENSION *ex, const ASN1_OBJECT *obj); -int X509_EXTENSION_set_critical(X509_EXTENSION *ex, int crit); -int X509_EXTENSION_set_data(X509_EXTENSION *ex, ASN1_OCTET_STRING *data); -ASN1_OBJECT *X509_EXTENSION_get_object(X509_EXTENSION *ex); -ASN1_OCTET_STRING *X509_EXTENSION_get_data(X509_EXTENSION *ne); -int X509_EXTENSION_get_critical(const X509_EXTENSION *ex); - -int X509at_get_attr_count(const STACK_OF(X509_ATTRIBUTE) *x); -int X509at_get_attr_by_NID(const STACK_OF(X509_ATTRIBUTE) *x, int nid, - int lastpos); -int X509at_get_attr_by_OBJ(const STACK_OF(X509_ATTRIBUTE) *sk, - const ASN1_OBJECT *obj, int lastpos); -X509_ATTRIBUTE *X509at_get_attr(const STACK_OF(X509_ATTRIBUTE) *x, int loc); -X509_ATTRIBUTE *X509at_delete_attr(STACK_OF(X509_ATTRIBUTE) *x, int loc); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr(STACK_OF(X509_ATTRIBUTE) **x, - X509_ATTRIBUTE *attr); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_OBJ(STACK_OF(X509_ATTRIBUTE) - **x, const ASN1_OBJECT *obj, - int type, - const unsigned char *bytes, - int len); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_NID(STACK_OF(X509_ATTRIBUTE) - **x, int nid, int type, - const unsigned char *bytes, - int len); -STACK_OF(X509_ATTRIBUTE) *X509at_add1_attr_by_txt(STACK_OF(X509_ATTRIBUTE) - **x, const char *attrname, - int type, - const unsigned char *bytes, - int len); -void *X509at_get0_data_by_OBJ(STACK_OF(X509_ATTRIBUTE) *x, - const ASN1_OBJECT *obj, int lastpos, int type); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_NID(X509_ATTRIBUTE **attr, int nid, - int atrtype, const void *data, - int len); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_OBJ(X509_ATTRIBUTE **attr, - const ASN1_OBJECT *obj, - int atrtype, const void *data, - int len); -X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, - const char *atrname, int type, - const unsigned char *bytes, - int len); -int X509_ATTRIBUTE_set1_object(X509_ATTRIBUTE *attr, const ASN1_OBJECT *obj); -int X509_ATTRIBUTE_set1_data(X509_ATTRIBUTE *attr, int attrtype, - const void *data, int len); -void *X509_ATTRIBUTE_get0_data(X509_ATTRIBUTE *attr, int idx, int atrtype, - void *data); -int X509_ATTRIBUTE_count(const X509_ATTRIBUTE *attr); -ASN1_OBJECT *X509_ATTRIBUTE_get0_object(X509_ATTRIBUTE *attr); -ASN1_TYPE *X509_ATTRIBUTE_get0_type(X509_ATTRIBUTE *attr, int idx); - -int EVP_PKEY_get_attr_count(const EVP_PKEY *key); -int EVP_PKEY_get_attr_by_NID(const EVP_PKEY *key, int nid, int lastpos); -int EVP_PKEY_get_attr_by_OBJ(const EVP_PKEY *key, const ASN1_OBJECT *obj, - int lastpos); -X509_ATTRIBUTE *EVP_PKEY_get_attr(const EVP_PKEY *key, int loc); -X509_ATTRIBUTE *EVP_PKEY_delete_attr(EVP_PKEY *key, int loc); -int EVP_PKEY_add1_attr(EVP_PKEY *key, X509_ATTRIBUTE *attr); -int EVP_PKEY_add1_attr_by_OBJ(EVP_PKEY *key, - const ASN1_OBJECT *obj, int type, - const unsigned char *bytes, int len); -int EVP_PKEY_add1_attr_by_NID(EVP_PKEY *key, - int nid, int type, - const unsigned char *bytes, int len); -int EVP_PKEY_add1_attr_by_txt(EVP_PKEY *key, - const char *attrname, int type, - const unsigned char *bytes, int len); - -int X509_verify_cert(X509_STORE_CTX *ctx); - -/* lookup a cert from a X509 STACK */ -X509 *X509_find_by_issuer_and_serial(STACK_OF(X509) *sk, X509_NAME *name, - ASN1_INTEGER *serial); -X509 *X509_find_by_subject(STACK_OF(X509) *sk, X509_NAME *name); - -DECLARE_ASN1_FUNCTIONS(PBEPARAM) -DECLARE_ASN1_FUNCTIONS(PBE2PARAM) -DECLARE_ASN1_FUNCTIONS(PBKDF2PARAM) - -int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter, - const unsigned char *salt, int saltlen); - -X509_ALGOR *PKCS5_pbe_set(int alg, int iter, - const unsigned char *salt, int saltlen); -X509_ALGOR *PKCS5_pbe2_set(const EVP_CIPHER *cipher, int iter, - unsigned char *salt, int saltlen); -X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter, - unsigned char *salt, int saltlen, - unsigned char *aiv, int prf_nid); - -#ifndef OPENSSL_NO_SCRYPT -X509_ALGOR *PKCS5_pbe2_set_scrypt(const EVP_CIPHER *cipher, - const unsigned char *salt, int saltlen, - unsigned char *aiv, uint64_t N, uint64_t r, - uint64_t p); -#endif - -X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen, - int prf_nid, int keylen); - -/* PKCS#8 utilities */ - -DECLARE_ASN1_FUNCTIONS(PKCS8_PRIV_KEY_INFO) - -EVP_PKEY *EVP_PKCS82PKEY(const PKCS8_PRIV_KEY_INFO *p8); -PKCS8_PRIV_KEY_INFO *EVP_PKEY2PKCS8(EVP_PKEY *pkey); - -int PKCS8_pkey_set0(PKCS8_PRIV_KEY_INFO *priv, ASN1_OBJECT *aobj, - int version, int ptype, void *pval, - unsigned char *penc, int penclen); -int PKCS8_pkey_get0(const ASN1_OBJECT **ppkalg, - const unsigned char **pk, int *ppklen, - const X509_ALGOR **pa, const PKCS8_PRIV_KEY_INFO *p8); - -const STACK_OF(X509_ATTRIBUTE) * -PKCS8_pkey_get0_attrs(const PKCS8_PRIV_KEY_INFO *p8); -int PKCS8_pkey_add1_attr_by_NID(PKCS8_PRIV_KEY_INFO *p8, int nid, int type, - const unsigned char *bytes, int len); - -int X509_PUBKEY_set0_param(X509_PUBKEY *pub, ASN1_OBJECT *aobj, - int ptype, void *pval, - unsigned char *penc, int penclen); -int X509_PUBKEY_get0_param(ASN1_OBJECT **ppkalg, - const unsigned char **pk, int *ppklen, - X509_ALGOR **pa, X509_PUBKEY *pub); - -int X509_check_trust(X509 *x, int id, int flags); -int X509_TRUST_get_count(void); -X509_TRUST *X509_TRUST_get0(int idx); -int X509_TRUST_get_by_id(int id); -int X509_TRUST_add(int id, int flags, int (*ck) (X509_TRUST *, X509 *, int), - const char *name, int arg1, void *arg2); -void X509_TRUST_cleanup(void); -int X509_TRUST_get_flags(const X509_TRUST *xp); -char *X509_TRUST_get0_name(const X509_TRUST *xp); -int X509_TRUST_get_trust(const X509_TRUST *xp); - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_X509_strings(void); - -/* Error codes for the X509 functions. */ - -/* Function codes. */ -# define X509_F_ADD_CERT_DIR 100 -# define X509_F_BUILD_CHAIN 106 -# define X509_F_BY_FILE_CTRL 101 -# define X509_F_CHECK_NAME_CONSTRAINTS 149 -# define X509_F_CHECK_POLICY 145 -# define X509_F_DANE_I2D 107 -# define X509_F_DIR_CTRL 102 -# define X509_F_GET_CERT_BY_SUBJECT 103 -# define X509_F_NETSCAPE_SPKI_B64_DECODE 129 -# define X509_F_NETSCAPE_SPKI_B64_ENCODE 130 -# define X509_F_X509AT_ADD1_ATTR 135 -# define X509_F_X509V3_ADD_EXT 104 -# define X509_F_X509_ATTRIBUTE_CREATE_BY_NID 136 -# define X509_F_X509_ATTRIBUTE_CREATE_BY_OBJ 137 -# define X509_F_X509_ATTRIBUTE_CREATE_BY_TXT 140 -# define X509_F_X509_ATTRIBUTE_GET0_DATA 139 -# define X509_F_X509_ATTRIBUTE_SET1_DATA 138 -# define X509_F_X509_CHECK_PRIVATE_KEY 128 -# define X509_F_X509_CRL_DIFF 105 -# define X509_F_X509_CRL_PRINT_FP 147 -# define X509_F_X509_EXTENSION_CREATE_BY_NID 108 -# define X509_F_X509_EXTENSION_CREATE_BY_OBJ 109 -# define X509_F_X509_GET_PUBKEY_PARAMETERS 110 -# define X509_F_X509_LOAD_CERT_CRL_FILE 132 -# define X509_F_X509_LOAD_CERT_FILE 111 -# define X509_F_X509_LOAD_CRL_FILE 112 -# define X509_F_X509_NAME_ADD_ENTRY 113 -# define X509_F_X509_NAME_ENTRY_CREATE_BY_NID 114 -# define X509_F_X509_NAME_ENTRY_CREATE_BY_TXT 131 -# define X509_F_X509_NAME_ENTRY_SET_OBJECT 115 -# define X509_F_X509_NAME_ONELINE 116 -# define X509_F_X509_NAME_PRINT 117 -# define X509_F_X509_OBJECT_NEW 150 -# define X509_F_X509_PRINT_EX_FP 118 -# define X509_F_X509_PUBKEY_DECODE 148 -# define X509_F_X509_PUBKEY_GET0 119 -# define X509_F_X509_PUBKEY_SET 120 -# define X509_F_X509_REQ_CHECK_PRIVATE_KEY 144 -# define X509_F_X509_REQ_PRINT_EX 121 -# define X509_F_X509_REQ_PRINT_FP 122 -# define X509_F_X509_REQ_TO_X509 123 -# define X509_F_X509_STORE_ADD_CERT 124 -# define X509_F_X509_STORE_ADD_CRL 125 -# define X509_F_X509_STORE_CTX_GET1_ISSUER 146 -# define X509_F_X509_STORE_CTX_INIT 143 -# define X509_F_X509_STORE_CTX_NEW 142 -# define X509_F_X509_STORE_CTX_PURPOSE_INHERIT 134 -# define X509_F_X509_TO_X509_REQ 126 -# define X509_F_X509_TRUST_ADD 133 -# define X509_F_X509_TRUST_SET 141 -# define X509_F_X509_VERIFY_CERT 127 - -/* Reason codes. */ -# define X509_R_AKID_MISMATCH 110 -# define X509_R_BAD_SELECTOR 133 -# define X509_R_BAD_X509_FILETYPE 100 -# define X509_R_BASE64_DECODE_ERROR 118 -# define X509_R_CANT_CHECK_DH_KEY 114 -# define X509_R_CERT_ALREADY_IN_HASH_TABLE 101 -# define X509_R_CRL_ALREADY_DELTA 127 -# define X509_R_CRL_VERIFY_FAILURE 131 -# define X509_R_IDP_MISMATCH 128 -# define X509_R_INVALID_DIRECTORY 113 -# define X509_R_INVALID_FIELD_NAME 119 -# define X509_R_INVALID_TRUST 123 -# define X509_R_ISSUER_MISMATCH 129 -# define X509_R_KEY_TYPE_MISMATCH 115 -# define X509_R_KEY_VALUES_MISMATCH 116 -# define X509_R_LOADING_CERT_DIR 103 -# define X509_R_LOADING_DEFAULTS 104 -# define X509_R_METHOD_NOT_SUPPORTED 124 -# define X509_R_NAME_TOO_LONG 134 -# define X509_R_NEWER_CRL_NOT_NEWER 132 -# define X509_R_NO_CERT_SET_FOR_US_TO_VERIFY 105 -# define X509_R_NO_CRL_NUMBER 130 -# define X509_R_PUBLIC_KEY_DECODE_ERROR 125 -# define X509_R_PUBLIC_KEY_ENCODE_ERROR 126 -# define X509_R_SHOULD_RETRY 106 -# define X509_R_UNABLE_TO_FIND_PARAMETERS_IN_CHAIN 107 -# define X509_R_UNABLE_TO_GET_CERTS_PUBLIC_KEY 108 -# define X509_R_UNKNOWN_KEY_TYPE 117 -# define X509_R_UNKNOWN_NID 109 -# define X509_R_UNKNOWN_PURPOSE_ID 121 -# define X509_R_UNKNOWN_TRUST_ID 120 -# define X509_R_UNSUPPORTED_ALGORITHM 111 -# define X509_R_WRONG_LOOKUP_TYPE 112 -# define X509_R_WRONG_TYPE 122 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/openssl/x509_vfy.h b/android/armeabi/include/openssl/x509_vfy.h deleted file mode 100644 index cab8005e..00000000 --- a/android/armeabi/include/openssl/x509_vfy.h +++ /dev/null @@ -1,539 +0,0 @@ -/* - * Copyright 1995-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_X509_VFY_H -# define HEADER_X509_VFY_H - -/* - * Protect against recursion, x509.h and x509_vfy.h each include the other. - */ -# ifndef HEADER_X509_H -# include <openssl/x509.h> -# endif - -# include <openssl/opensslconf.h> -# include <openssl/lhash.h> -# include <openssl/bio.h> -# include <openssl/crypto.h> -# include <openssl/symhacks.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/*- -SSL_CTX -> X509_STORE - -> X509_LOOKUP - ->X509_LOOKUP_METHOD - -> X509_LOOKUP - ->X509_LOOKUP_METHOD - -SSL -> X509_STORE_CTX - ->X509_STORE - -The X509_STORE holds the tables etc for verification stuff. -A X509_STORE_CTX is used while validating a single certificate. -The X509_STORE has X509_LOOKUPs for looking up certs. -The X509_STORE then calls a function to actually verify the -certificate chain. -*/ - -typedef enum { - X509_LU_NONE = 0, - X509_LU_X509, X509_LU_CRL -} X509_LOOKUP_TYPE; - -#if OPENSSL_API_COMPAT < 0x10100000L -#define X509_LU_RETRY -1 -#define X509_LU_FAIL 0 -#endif - -DEFINE_STACK_OF(X509_LOOKUP) -DEFINE_STACK_OF(X509_OBJECT) -DEFINE_STACK_OF(X509_VERIFY_PARAM) - -int X509_STORE_set_depth(X509_STORE *store, int depth); - -typedef int (*X509_STORE_CTX_verify_cb)(int, X509_STORE_CTX *); -typedef int (*X509_STORE_CTX_verify_fn)(X509_STORE_CTX *); -typedef int (*X509_STORE_CTX_get_issuer_fn)(X509 **issuer, - X509_STORE_CTX *ctx, X509 *x); -typedef int (*X509_STORE_CTX_check_issued_fn)(X509_STORE_CTX *ctx, - X509 *x, X509 *issuer); -typedef int (*X509_STORE_CTX_check_revocation_fn)(X509_STORE_CTX *ctx); -typedef int (*X509_STORE_CTX_get_crl_fn)(X509_STORE_CTX *ctx, - X509_CRL **crl, X509 *x); -typedef int (*X509_STORE_CTX_check_crl_fn)(X509_STORE_CTX *ctx, X509_CRL *crl); -typedef int (*X509_STORE_CTX_cert_crl_fn)(X509_STORE_CTX *ctx, - X509_CRL *crl, X509 *x); -typedef int (*X509_STORE_CTX_check_policy_fn)(X509_STORE_CTX *ctx); -typedef STACK_OF(X509) *(*X509_STORE_CTX_lookup_certs_fn)(X509_STORE_CTX *ctx, - X509_NAME *nm); -typedef STACK_OF(X509_CRL) *(*X509_STORE_CTX_lookup_crls_fn)(X509_STORE_CTX *ctx, - X509_NAME *nm); -typedef int (*X509_STORE_CTX_cleanup_fn)(X509_STORE_CTX *ctx); - - -void X509_STORE_CTX_set_depth(X509_STORE_CTX *ctx, int depth); - -# define X509_STORE_CTX_set_app_data(ctx,data) \ - X509_STORE_CTX_set_ex_data(ctx,0,data) -# define X509_STORE_CTX_get_app_data(ctx) \ - X509_STORE_CTX_get_ex_data(ctx,0) - -# define X509_L_FILE_LOAD 1 -# define X509_L_ADD_DIR 2 - -# define X509_LOOKUP_load_file(x,name,type) \ - X509_LOOKUP_ctrl((x),X509_L_FILE_LOAD,(name),(long)(type),NULL) - -# define X509_LOOKUP_add_dir(x,name,type) \ - X509_LOOKUP_ctrl((x),X509_L_ADD_DIR,(name),(long)(type),NULL) - -# define X509_V_OK 0 -# define X509_V_ERR_UNSPECIFIED 1 -# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT 2 -# define X509_V_ERR_UNABLE_TO_GET_CRL 3 -# define X509_V_ERR_UNABLE_TO_DECRYPT_CERT_SIGNATURE 4 -# define X509_V_ERR_UNABLE_TO_DECRYPT_CRL_SIGNATURE 5 -# define X509_V_ERR_UNABLE_TO_DECODE_ISSUER_PUBLIC_KEY 6 -# define X509_V_ERR_CERT_SIGNATURE_FAILURE 7 -# define X509_V_ERR_CRL_SIGNATURE_FAILURE 8 -# define X509_V_ERR_CERT_NOT_YET_VALID 9 -# define X509_V_ERR_CERT_HAS_EXPIRED 10 -# define X509_V_ERR_CRL_NOT_YET_VALID 11 -# define X509_V_ERR_CRL_HAS_EXPIRED 12 -# define X509_V_ERR_ERROR_IN_CERT_NOT_BEFORE_FIELD 13 -# define X509_V_ERR_ERROR_IN_CERT_NOT_AFTER_FIELD 14 -# define X509_V_ERR_ERROR_IN_CRL_LAST_UPDATE_FIELD 15 -# define X509_V_ERR_ERROR_IN_CRL_NEXT_UPDATE_FIELD 16 -# define X509_V_ERR_OUT_OF_MEM 17 -# define X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT 18 -# define X509_V_ERR_SELF_SIGNED_CERT_IN_CHAIN 19 -# define X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY 20 -# define X509_V_ERR_UNABLE_TO_VERIFY_LEAF_SIGNATURE 21 -# define X509_V_ERR_CERT_CHAIN_TOO_LONG 22 -# define X509_V_ERR_CERT_REVOKED 23 -# define X509_V_ERR_INVALID_CA 24 -# define X509_V_ERR_PATH_LENGTH_EXCEEDED 25 -# define X509_V_ERR_INVALID_PURPOSE 26 -# define X509_V_ERR_CERT_UNTRUSTED 27 -# define X509_V_ERR_CERT_REJECTED 28 -/* These are 'informational' when looking for issuer cert */ -# define X509_V_ERR_SUBJECT_ISSUER_MISMATCH 29 -# define X509_V_ERR_AKID_SKID_MISMATCH 30 -# define X509_V_ERR_AKID_ISSUER_SERIAL_MISMATCH 31 -# define X509_V_ERR_KEYUSAGE_NO_CERTSIGN 32 -# define X509_V_ERR_UNABLE_TO_GET_CRL_ISSUER 33 -# define X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION 34 -# define X509_V_ERR_KEYUSAGE_NO_CRL_SIGN 35 -# define X509_V_ERR_UNHANDLED_CRITICAL_CRL_EXTENSION 36 -# define X509_V_ERR_INVALID_NON_CA 37 -# define X509_V_ERR_PROXY_PATH_LENGTH_EXCEEDED 38 -# define X509_V_ERR_KEYUSAGE_NO_DIGITAL_SIGNATURE 39 -# define X509_V_ERR_PROXY_CERTIFICATES_NOT_ALLOWED 40 -# define X509_V_ERR_INVALID_EXTENSION 41 -# define X509_V_ERR_INVALID_POLICY_EXTENSION 42 -# define X509_V_ERR_NO_EXPLICIT_POLICY 43 -# define X509_V_ERR_DIFFERENT_CRL_SCOPE 44 -# define X509_V_ERR_UNSUPPORTED_EXTENSION_FEATURE 45 -# define X509_V_ERR_UNNESTED_RESOURCE 46 -# define X509_V_ERR_PERMITTED_VIOLATION 47 -# define X509_V_ERR_EXCLUDED_VIOLATION 48 -# define X509_V_ERR_SUBTREE_MINMAX 49 -/* The application is not happy */ -# define X509_V_ERR_APPLICATION_VERIFICATION 50 -# define X509_V_ERR_UNSUPPORTED_CONSTRAINT_TYPE 51 -# define X509_V_ERR_UNSUPPORTED_CONSTRAINT_SYNTAX 52 -# define X509_V_ERR_UNSUPPORTED_NAME_SYNTAX 53 -# define X509_V_ERR_CRL_PATH_VALIDATION_ERROR 54 -/* Another issuer check debug option */ -# define X509_V_ERR_PATH_LOOP 55 -/* Suite B mode algorithm violation */ -# define X509_V_ERR_SUITE_B_INVALID_VERSION 56 -# define X509_V_ERR_SUITE_B_INVALID_ALGORITHM 57 -# define X509_V_ERR_SUITE_B_INVALID_CURVE 58 -# define X509_V_ERR_SUITE_B_INVALID_SIGNATURE_ALGORITHM 59 -# define X509_V_ERR_SUITE_B_LOS_NOT_ALLOWED 60 -# define X509_V_ERR_SUITE_B_CANNOT_SIGN_P_384_WITH_P_256 61 -/* Host, email and IP check errors */ -# define X509_V_ERR_HOSTNAME_MISMATCH 62 -# define X509_V_ERR_EMAIL_MISMATCH 63 -# define X509_V_ERR_IP_ADDRESS_MISMATCH 64 -/* DANE TLSA errors */ -# define X509_V_ERR_DANE_NO_MATCH 65 -/* security level errors */ -# define X509_V_ERR_EE_KEY_TOO_SMALL 66 -# define X509_V_ERR_CA_KEY_TOO_SMALL 67 -# define X509_V_ERR_CA_MD_TOO_WEAK 68 -/* Caller error */ -# define X509_V_ERR_INVALID_CALL 69 -/* Issuer lookup error */ -# define X509_V_ERR_STORE_LOOKUP 70 -/* Certificate transparency */ -# define X509_V_ERR_NO_VALID_SCTS 71 - -# define X509_V_ERR_PROXY_SUBJECT_NAME_VIOLATION 72 - -/* Certificate verify flags */ - -# if OPENSSL_API_COMPAT < 0x10100000L -# define X509_V_FLAG_CB_ISSUER_CHECK 0x0 /* Deprecated */ -# endif -/* Use check time instead of current time */ -# define X509_V_FLAG_USE_CHECK_TIME 0x2 -/* Lookup CRLs */ -# define X509_V_FLAG_CRL_CHECK 0x4 -/* Lookup CRLs for whole chain */ -# define X509_V_FLAG_CRL_CHECK_ALL 0x8 -/* Ignore unhandled critical extensions */ -# define X509_V_FLAG_IGNORE_CRITICAL 0x10 -/* Disable workarounds for broken certificates */ -# define X509_V_FLAG_X509_STRICT 0x20 -/* Enable proxy certificate validation */ -# define X509_V_FLAG_ALLOW_PROXY_CERTS 0x40 -/* Enable policy checking */ -# define X509_V_FLAG_POLICY_CHECK 0x80 -/* Policy variable require-explicit-policy */ -# define X509_V_FLAG_EXPLICIT_POLICY 0x100 -/* Policy variable inhibit-any-policy */ -# define X509_V_FLAG_INHIBIT_ANY 0x200 -/* Policy variable inhibit-policy-mapping */ -# define X509_V_FLAG_INHIBIT_MAP 0x400 -/* Notify callback that policy is OK */ -# define X509_V_FLAG_NOTIFY_POLICY 0x800 -/* Extended CRL features such as indirect CRLs, alternate CRL signing keys */ -# define X509_V_FLAG_EXTENDED_CRL_SUPPORT 0x1000 -/* Delta CRL support */ -# define X509_V_FLAG_USE_DELTAS 0x2000 -/* Check self-signed CA signature */ -# define X509_V_FLAG_CHECK_SS_SIGNATURE 0x4000 -/* Use trusted store first */ -# define X509_V_FLAG_TRUSTED_FIRST 0x8000 -/* Suite B 128 bit only mode: not normally used */ -# define X509_V_FLAG_SUITEB_128_LOS_ONLY 0x10000 -/* Suite B 192 bit only mode */ -# define X509_V_FLAG_SUITEB_192_LOS 0x20000 -/* Suite B 128 bit mode allowing 192 bit algorithms */ -# define X509_V_FLAG_SUITEB_128_LOS 0x30000 -/* Allow partial chains if at least one certificate is in trusted store */ -# define X509_V_FLAG_PARTIAL_CHAIN 0x80000 -/* - * If the initial chain is not trusted, do not attempt to build an alternative - * chain. Alternate chain checking was introduced in 1.1.0. Setting this flag - * will force the behaviour to match that of previous versions. - */ -# define X509_V_FLAG_NO_ALT_CHAINS 0x100000 -/* Do not check certificate/CRL validity against current time */ -# define X509_V_FLAG_NO_CHECK_TIME 0x200000 - -# define X509_VP_FLAG_DEFAULT 0x1 -# define X509_VP_FLAG_OVERWRITE 0x2 -# define X509_VP_FLAG_RESET_FLAGS 0x4 -# define X509_VP_FLAG_LOCKED 0x8 -# define X509_VP_FLAG_ONCE 0x10 - -/* Internal use: mask of policy related options */ -# define X509_V_FLAG_POLICY_MASK (X509_V_FLAG_POLICY_CHECK \ - | X509_V_FLAG_EXPLICIT_POLICY \ - | X509_V_FLAG_INHIBIT_ANY \ - | X509_V_FLAG_INHIBIT_MAP) - -int X509_OBJECT_idx_by_subject(STACK_OF(X509_OBJECT) *h, X509_LOOKUP_TYPE type, - X509_NAME *name); -X509_OBJECT *X509_OBJECT_retrieve_by_subject(STACK_OF(X509_OBJECT) *h, - X509_LOOKUP_TYPE type, - X509_NAME *name); -X509_OBJECT *X509_OBJECT_retrieve_match(STACK_OF(X509_OBJECT) *h, - X509_OBJECT *x); -int X509_OBJECT_up_ref_count(X509_OBJECT *a); -X509_OBJECT *X509_OBJECT_new(void); -void X509_OBJECT_free(X509_OBJECT *a); -X509_LOOKUP_TYPE X509_OBJECT_get_type(const X509_OBJECT *a); -X509 *X509_OBJECT_get0_X509(const X509_OBJECT *a); -X509_CRL *X509_OBJECT_get0_X509_CRL(X509_OBJECT *a); -X509_STORE *X509_STORE_new(void); -void X509_STORE_free(X509_STORE *v); -int X509_STORE_lock(X509_STORE *ctx); -int X509_STORE_unlock(X509_STORE *ctx); -int X509_STORE_up_ref(X509_STORE *v); -STACK_OF(X509_OBJECT) *X509_STORE_get0_objects(X509_STORE *v); - -STACK_OF(X509) *X509_STORE_CTX_get1_certs(X509_STORE_CTX *st, X509_NAME *nm); -STACK_OF(X509_CRL) *X509_STORE_CTX_get1_crls(X509_STORE_CTX *st, X509_NAME *nm); -int X509_STORE_set_flags(X509_STORE *ctx, unsigned long flags); -int X509_STORE_set_purpose(X509_STORE *ctx, int purpose); -int X509_STORE_set_trust(X509_STORE *ctx, int trust); -int X509_STORE_set1_param(X509_STORE *ctx, X509_VERIFY_PARAM *pm); -X509_VERIFY_PARAM *X509_STORE_get0_param(X509_STORE *ctx); - -void X509_STORE_set_verify(X509_STORE *ctx, X509_STORE_CTX_verify_fn verify); -#define X509_STORE_set_verify_func(ctx, func) \ - X509_STORE_set_verify((ctx),(func)) -void X509_STORE_CTX_set_verify(X509_STORE_CTX *ctx, - X509_STORE_CTX_verify_fn verify); -X509_STORE_CTX_verify_fn X509_STORE_get_verify(X509_STORE *ctx); -void X509_STORE_set_verify_cb(X509_STORE *ctx, - X509_STORE_CTX_verify_cb verify_cb); -# define X509_STORE_set_verify_cb_func(ctx,func) \ - X509_STORE_set_verify_cb((ctx),(func)) -X509_STORE_CTX_verify_cb X509_STORE_get_verify_cb(X509_STORE *ctx); -void X509_STORE_set_get_issuer(X509_STORE *ctx, - X509_STORE_CTX_get_issuer_fn get_issuer); -X509_STORE_CTX_get_issuer_fn X509_STORE_get_get_issuer(X509_STORE *ctx); -void X509_STORE_set_check_issued(X509_STORE *ctx, - X509_STORE_CTX_check_issued_fn check_issued); -X509_STORE_CTX_check_issued_fn X509_STORE_get_check_issued(X509_STORE *ctx); -void X509_STORE_set_check_revocation(X509_STORE *ctx, - X509_STORE_CTX_check_revocation_fn check_revocation); -X509_STORE_CTX_check_revocation_fn X509_STORE_get_check_revocation(X509_STORE *ctx); -void X509_STORE_set_get_crl(X509_STORE *ctx, - X509_STORE_CTX_get_crl_fn get_crl); -X509_STORE_CTX_get_crl_fn X509_STORE_get_get_crl(X509_STORE *ctx); -void X509_STORE_set_check_crl(X509_STORE *ctx, - X509_STORE_CTX_check_crl_fn check_crl); -X509_STORE_CTX_check_crl_fn X509_STORE_get_check_crl(X509_STORE *ctx); -void X509_STORE_set_cert_crl(X509_STORE *ctx, - X509_STORE_CTX_cert_crl_fn cert_crl); -X509_STORE_CTX_cert_crl_fn X509_STORE_get_cert_crl(X509_STORE *ctx); -void X509_STORE_set_check_policy(X509_STORE *ctx, - X509_STORE_CTX_check_policy_fn check_policy); -X509_STORE_CTX_check_policy_fn X509_STORE_get_check_policy(X509_STORE *ctx); -void X509_STORE_set_lookup_certs(X509_STORE *ctx, - X509_STORE_CTX_lookup_certs_fn lookup_certs); -X509_STORE_CTX_lookup_certs_fn X509_STORE_get_lookup_certs(X509_STORE *ctx); -void X509_STORE_set_lookup_crls(X509_STORE *ctx, - X509_STORE_CTX_lookup_crls_fn lookup_crls); -#define X509_STORE_set_lookup_crls_cb(ctx, func) \ - X509_STORE_set_lookup_crls((ctx), (func)) -X509_STORE_CTX_lookup_crls_fn X509_STORE_get_lookup_crls(X509_STORE *ctx); -void X509_STORE_set_cleanup(X509_STORE *ctx, - X509_STORE_CTX_cleanup_fn cleanup); -X509_STORE_CTX_cleanup_fn X509_STORE_get_cleanup(X509_STORE *ctx); - -#define X509_STORE_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE, l, p, newf, dupf, freef) -int X509_STORE_set_ex_data(X509_STORE *ctx, int idx, void *data); -void *X509_STORE_get_ex_data(X509_STORE *ctx, int idx); - -X509_STORE_CTX *X509_STORE_CTX_new(void); - -int X509_STORE_CTX_get1_issuer(X509 **issuer, X509_STORE_CTX *ctx, X509 *x); - -void X509_STORE_CTX_free(X509_STORE_CTX *ctx); -int X509_STORE_CTX_init(X509_STORE_CTX *ctx, X509_STORE *store, - X509 *x509, STACK_OF(X509) *chain); -void X509_STORE_CTX_set0_trusted_stack(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); -void X509_STORE_CTX_cleanup(X509_STORE_CTX *ctx); - -X509_STORE *X509_STORE_CTX_get0_store(X509_STORE_CTX *ctx); -X509 *X509_STORE_CTX_get0_cert(X509_STORE_CTX *ctx); -STACK_OF(X509)* X509_STORE_CTX_get0_untrusted(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set0_untrusted(X509_STORE_CTX *ctx, STACK_OF(X509) *sk); -void X509_STORE_CTX_set_verify_cb(X509_STORE_CTX *ctx, - X509_STORE_CTX_verify_cb verify); -X509_STORE_CTX_verify_cb X509_STORE_CTX_get_verify_cb(X509_STORE_CTX *ctx); -X509_STORE_CTX_verify_fn X509_STORE_CTX_get_verify(X509_STORE_CTX *ctx); -X509_STORE_CTX_get_issuer_fn X509_STORE_CTX_get_get_issuer(X509_STORE_CTX *ctx); -X509_STORE_CTX_check_issued_fn X509_STORE_CTX_get_check_issued(X509_STORE_CTX *ctx); -X509_STORE_CTX_check_revocation_fn X509_STORE_CTX_get_check_revocation(X509_STORE_CTX *ctx); -X509_STORE_CTX_get_crl_fn X509_STORE_CTX_get_get_crl(X509_STORE_CTX *ctx); -X509_STORE_CTX_check_crl_fn X509_STORE_CTX_get_check_crl(X509_STORE_CTX *ctx); -X509_STORE_CTX_cert_crl_fn X509_STORE_CTX_get_cert_crl(X509_STORE_CTX *ctx); -X509_STORE_CTX_check_policy_fn X509_STORE_CTX_get_check_policy(X509_STORE_CTX *ctx); -X509_STORE_CTX_lookup_certs_fn X509_STORE_CTX_get_lookup_certs(X509_STORE_CTX *ctx); -X509_STORE_CTX_lookup_crls_fn X509_STORE_CTX_get_lookup_crls(X509_STORE_CTX *ctx); -X509_STORE_CTX_cleanup_fn X509_STORE_CTX_get_cleanup(X509_STORE_CTX *ctx); - -#if OPENSSL_API_COMPAT < 0x10100000L -# define X509_STORE_CTX_get_chain X509_STORE_CTX_get0_chain -# define X509_STORE_CTX_set_chain X509_STORE_CTX_set0_untrusted -# define X509_STORE_CTX_trusted_stack X509_STORE_CTX_set0_trusted_stack -# define X509_STORE_get_by_subject X509_STORE_CTX_get_by_subject -# define X509_STORE_get1_cert X509_STORE_CTX_get1_certs -# define X509_STORE_get1_crl X509_STORE_CTX_get1_crls -#endif - -X509_LOOKUP *X509_STORE_add_lookup(X509_STORE *v, X509_LOOKUP_METHOD *m); -X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(void); -X509_LOOKUP_METHOD *X509_LOOKUP_file(void); - -int X509_STORE_add_cert(X509_STORE *ctx, X509 *x); -int X509_STORE_add_crl(X509_STORE *ctx, X509_CRL *x); - -int X509_STORE_CTX_get_by_subject(X509_STORE_CTX *vs, X509_LOOKUP_TYPE type, - X509_NAME *name, X509_OBJECT *ret); -X509_OBJECT *X509_STORE_CTX_get_obj_by_subject(X509_STORE_CTX *vs, - X509_LOOKUP_TYPE type, - X509_NAME *name); - -int X509_LOOKUP_ctrl(X509_LOOKUP *ctx, int cmd, const char *argc, - long argl, char **ret); - -int X509_load_cert_file(X509_LOOKUP *ctx, const char *file, int type); -int X509_load_crl_file(X509_LOOKUP *ctx, const char *file, int type); -int X509_load_cert_crl_file(X509_LOOKUP *ctx, const char *file, int type); - -X509_LOOKUP *X509_LOOKUP_new(X509_LOOKUP_METHOD *method); -void X509_LOOKUP_free(X509_LOOKUP *ctx); -int X509_LOOKUP_init(X509_LOOKUP *ctx); -int X509_LOOKUP_by_subject(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - X509_NAME *name, X509_OBJECT *ret); -int X509_LOOKUP_by_issuer_serial(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - X509_NAME *name, ASN1_INTEGER *serial, - X509_OBJECT *ret); -int X509_LOOKUP_by_fingerprint(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - const unsigned char *bytes, int len, - X509_OBJECT *ret); -int X509_LOOKUP_by_alias(X509_LOOKUP *ctx, X509_LOOKUP_TYPE type, - const char *str, int len, X509_OBJECT *ret); -int X509_LOOKUP_shutdown(X509_LOOKUP *ctx); - -int X509_STORE_load_locations(X509_STORE *ctx, - const char *file, const char *dir); -int X509_STORE_set_default_paths(X509_STORE *ctx); - -#define X509_STORE_CTX_get_ex_new_index(l, p, newf, dupf, freef) \ - CRYPTO_get_ex_new_index(CRYPTO_EX_INDEX_X509_STORE_CTX, l, p, newf, dupf, freef) -int X509_STORE_CTX_set_ex_data(X509_STORE_CTX *ctx, int idx, void *data); -void *X509_STORE_CTX_get_ex_data(X509_STORE_CTX *ctx, int idx); -int X509_STORE_CTX_get_error(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set_error(X509_STORE_CTX *ctx, int s); -int X509_STORE_CTX_get_error_depth(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set_error_depth(X509_STORE_CTX *ctx, int depth); -X509 *X509_STORE_CTX_get_current_cert(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set_current_cert(X509_STORE_CTX *ctx, X509 *x); -X509 *X509_STORE_CTX_get0_current_issuer(X509_STORE_CTX *ctx); -X509_CRL *X509_STORE_CTX_get0_current_crl(X509_STORE_CTX *ctx); -X509_STORE_CTX *X509_STORE_CTX_get0_parent_ctx(X509_STORE_CTX *ctx); -STACK_OF(X509) *X509_STORE_CTX_get0_chain(X509_STORE_CTX *ctx); -STACK_OF(X509) *X509_STORE_CTX_get1_chain(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set_cert(X509_STORE_CTX *c, X509 *x); -void X509_STORE_CTX_set0_verified_chain(X509_STORE_CTX *c, STACK_OF(X509) *sk); -void X509_STORE_CTX_set0_crls(X509_STORE_CTX *c, STACK_OF(X509_CRL) *sk); -int X509_STORE_CTX_set_purpose(X509_STORE_CTX *ctx, int purpose); -int X509_STORE_CTX_set_trust(X509_STORE_CTX *ctx, int trust); -int X509_STORE_CTX_purpose_inherit(X509_STORE_CTX *ctx, int def_purpose, - int purpose, int trust); -void X509_STORE_CTX_set_flags(X509_STORE_CTX *ctx, unsigned long flags); -void X509_STORE_CTX_set_time(X509_STORE_CTX *ctx, unsigned long flags, - time_t t); - -X509_POLICY_TREE *X509_STORE_CTX_get0_policy_tree(X509_STORE_CTX *ctx); -int X509_STORE_CTX_get_explicit_policy(X509_STORE_CTX *ctx); -int X509_STORE_CTX_get_num_untrusted(X509_STORE_CTX *ctx); - -X509_VERIFY_PARAM *X509_STORE_CTX_get0_param(X509_STORE_CTX *ctx); -void X509_STORE_CTX_set0_param(X509_STORE_CTX *ctx, X509_VERIFY_PARAM *param); -int X509_STORE_CTX_set_default(X509_STORE_CTX *ctx, const char *name); - -/* - * Bridge opacity barrier between libcrypt and libssl, also needed to support - * offline testing in test/danetest.c - */ -void X509_STORE_CTX_set0_dane(X509_STORE_CTX *ctx, SSL_DANE *dane); -#define DANE_FLAG_NO_DANE_EE_NAMECHECKS (1L << 0) - -/* X509_VERIFY_PARAM functions */ - -X509_VERIFY_PARAM *X509_VERIFY_PARAM_new(void); -void X509_VERIFY_PARAM_free(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_inherit(X509_VERIFY_PARAM *to, - const X509_VERIFY_PARAM *from); -int X509_VERIFY_PARAM_set1(X509_VERIFY_PARAM *to, - const X509_VERIFY_PARAM *from); -int X509_VERIFY_PARAM_set1_name(X509_VERIFY_PARAM *param, const char *name); -int X509_VERIFY_PARAM_set_flags(X509_VERIFY_PARAM *param, - unsigned long flags); -int X509_VERIFY_PARAM_clear_flags(X509_VERIFY_PARAM *param, - unsigned long flags); -unsigned long X509_VERIFY_PARAM_get_flags(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_set_purpose(X509_VERIFY_PARAM *param, int purpose); -int X509_VERIFY_PARAM_set_trust(X509_VERIFY_PARAM *param, int trust); -void X509_VERIFY_PARAM_set_depth(X509_VERIFY_PARAM *param, int depth); -void X509_VERIFY_PARAM_set_auth_level(X509_VERIFY_PARAM *param, int auth_level); -void X509_VERIFY_PARAM_set_time(X509_VERIFY_PARAM *param, time_t t); -int X509_VERIFY_PARAM_add0_policy(X509_VERIFY_PARAM *param, - ASN1_OBJECT *policy); -int X509_VERIFY_PARAM_set1_policies(X509_VERIFY_PARAM *param, - STACK_OF(ASN1_OBJECT) *policies); - -int X509_VERIFY_PARAM_set1_host(X509_VERIFY_PARAM *param, - const char *name, size_t namelen); -int X509_VERIFY_PARAM_add1_host(X509_VERIFY_PARAM *param, - const char *name, size_t namelen); -void X509_VERIFY_PARAM_set_hostflags(X509_VERIFY_PARAM *param, - unsigned int flags); -char *X509_VERIFY_PARAM_get0_peername(X509_VERIFY_PARAM *); -void X509_VERIFY_PARAM_move_peername(X509_VERIFY_PARAM *, X509_VERIFY_PARAM *); -int X509_VERIFY_PARAM_set1_email(X509_VERIFY_PARAM *param, - const char *email, size_t emaillen); -int X509_VERIFY_PARAM_set1_ip(X509_VERIFY_PARAM *param, - const unsigned char *ip, size_t iplen); -int X509_VERIFY_PARAM_set1_ip_asc(X509_VERIFY_PARAM *param, - const char *ipasc); - -int X509_VERIFY_PARAM_get_depth(const X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_get_auth_level(const X509_VERIFY_PARAM *param); -const char *X509_VERIFY_PARAM_get0_name(const X509_VERIFY_PARAM *param); - -int X509_VERIFY_PARAM_add0_table(X509_VERIFY_PARAM *param); -int X509_VERIFY_PARAM_get_count(void); -const X509_VERIFY_PARAM *X509_VERIFY_PARAM_get0(int id); -const X509_VERIFY_PARAM *X509_VERIFY_PARAM_lookup(const char *name); -void X509_VERIFY_PARAM_table_cleanup(void); - -/* Non positive return values are errors */ -#define X509_PCY_TREE_FAILURE -2 /* Failure to satisfy explicit policy */ -#define X509_PCY_TREE_INVALID -1 /* Inconsistent or invalid extensions */ -#define X509_PCY_TREE_INTERNAL 0 /* Internal error, most likely malloc */ - -/* - * Positive return values form a bit mask, all but the first are internal to - * the library and don't appear in results from X509_policy_check(). - */ -#define X509_PCY_TREE_VALID 1 /* The policy tree is valid */ -#define X509_PCY_TREE_EMPTY 2 /* The policy tree is empty */ -#define X509_PCY_TREE_EXPLICIT 4 /* Explicit policy required */ - -int X509_policy_check(X509_POLICY_TREE **ptree, int *pexplicit_policy, - STACK_OF(X509) *certs, - STACK_OF(ASN1_OBJECT) *policy_oids, unsigned int flags); - -void X509_policy_tree_free(X509_POLICY_TREE *tree); - -int X509_policy_tree_level_count(const X509_POLICY_TREE *tree); -X509_POLICY_LEVEL *X509_policy_tree_get0_level(const X509_POLICY_TREE *tree, - int i); - -STACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_policies(const - X509_POLICY_TREE - *tree); - -STACK_OF(X509_POLICY_NODE) *X509_policy_tree_get0_user_policies(const - X509_POLICY_TREE - *tree); - -int X509_policy_level_node_count(X509_POLICY_LEVEL *level); - -X509_POLICY_NODE *X509_policy_level_get0_node(X509_POLICY_LEVEL *level, - int i); - -const ASN1_OBJECT *X509_policy_node_get0_policy(const X509_POLICY_NODE *node); - -STACK_OF(POLICYQUALINFO) *X509_policy_node_get0_qualifiers(const - X509_POLICY_NODE - *node); -const X509_POLICY_NODE *X509_policy_node_get0_parent(const X509_POLICY_NODE - *node); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/android/armeabi/include/openssl/x509v3.h b/android/armeabi/include/openssl/x509v3.h deleted file mode 100644 index f21ce7c1..00000000 --- a/android/armeabi/include/openssl/x509v3.h +++ /dev/null @@ -1,1005 +0,0 @@ -/* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. - * - * Licensed under the OpenSSL license (the "License"). You may not use - * this file except in compliance with the License. You can obtain a copy - * in the file LICENSE in the source distribution or at - * https://www.openssl.org/source/license.html - */ - -#ifndef HEADER_X509V3_H -# define HEADER_X509V3_H - -# include <openssl/bio.h> -# include <openssl/x509.h> -# include <openssl/conf.h> - -#ifdef __cplusplus -extern "C" { -#endif - -/* Forward reference */ -struct v3_ext_method; -struct v3_ext_ctx; - -/* Useful typedefs */ - -typedef void *(*X509V3_EXT_NEW)(void); -typedef void (*X509V3_EXT_FREE) (void *); -typedef void *(*X509V3_EXT_D2I)(void *, const unsigned char **, long); -typedef int (*X509V3_EXT_I2D) (void *, unsigned char **); -typedef STACK_OF(CONF_VALUE) * - (*X509V3_EXT_I2V) (const struct v3_ext_method *method, void *ext, - STACK_OF(CONF_VALUE) *extlist); -typedef void *(*X509V3_EXT_V2I)(const struct v3_ext_method *method, - struct v3_ext_ctx *ctx, - STACK_OF(CONF_VALUE) *values); -typedef char *(*X509V3_EXT_I2S)(const struct v3_ext_method *method, - void *ext); -typedef void *(*X509V3_EXT_S2I)(const struct v3_ext_method *method, - struct v3_ext_ctx *ctx, const char *str); -typedef int (*X509V3_EXT_I2R) (const struct v3_ext_method *method, void *ext, - BIO *out, int indent); -typedef void *(*X509V3_EXT_R2I)(const struct v3_ext_method *method, - struct v3_ext_ctx *ctx, const char *str); - -/* V3 extension structure */ - -struct v3_ext_method { - int ext_nid; - int ext_flags; -/* If this is set the following four fields are ignored */ - ASN1_ITEM_EXP *it; -/* Old style ASN1 calls */ - X509V3_EXT_NEW ext_new; - X509V3_EXT_FREE ext_free; - X509V3_EXT_D2I d2i; - X509V3_EXT_I2D i2d; -/* The following pair is used for string extensions */ - X509V3_EXT_I2S i2s; - X509V3_EXT_S2I s2i; -/* The following pair is used for multi-valued extensions */ - X509V3_EXT_I2V i2v; - X509V3_EXT_V2I v2i; -/* The following are used for raw extensions */ - X509V3_EXT_I2R i2r; - X509V3_EXT_R2I r2i; - void *usr_data; /* Any extension specific data */ -}; - -typedef struct X509V3_CONF_METHOD_st { - char *(*get_string) (void *db, const char *section, const char *value); - STACK_OF(CONF_VALUE) *(*get_section) (void *db, const char *section); - void (*free_string) (void *db, char *string); - void (*free_section) (void *db, STACK_OF(CONF_VALUE) *section); -} X509V3_CONF_METHOD; - -/* Context specific info */ -struct v3_ext_ctx { -# define CTX_TEST 0x1 -# define X509V3_CTX_REPLACE 0x2 - int flags; - X509 *issuer_cert; - X509 *subject_cert; - X509_REQ *subject_req; - X509_CRL *crl; - X509V3_CONF_METHOD *db_meth; - void *db; -/* Maybe more here */ -}; - -typedef struct v3_ext_method X509V3_EXT_METHOD; - -DEFINE_STACK_OF(X509V3_EXT_METHOD) - -/* ext_flags values */ -# define X509V3_EXT_DYNAMIC 0x1 -# define X509V3_EXT_CTX_DEP 0x2 -# define X509V3_EXT_MULTILINE 0x4 - -typedef BIT_STRING_BITNAME ENUMERATED_NAMES; - -typedef struct BASIC_CONSTRAINTS_st { - int ca; - ASN1_INTEGER *pathlen; -} BASIC_CONSTRAINTS; - -typedef struct PKEY_USAGE_PERIOD_st { - ASN1_GENERALIZEDTIME *notBefore; - ASN1_GENERALIZEDTIME *notAfter; -} PKEY_USAGE_PERIOD; - -typedef struct otherName_st { - ASN1_OBJECT *type_id; - ASN1_TYPE *value; -} OTHERNAME; - -typedef struct EDIPartyName_st { - ASN1_STRING *nameAssigner; - ASN1_STRING *partyName; -} EDIPARTYNAME; - -typedef struct GENERAL_NAME_st { -# define GEN_OTHERNAME 0 -# define GEN_EMAIL 1 -# define GEN_DNS 2 -# define GEN_X400 3 -# define GEN_DIRNAME 4 -# define GEN_EDIPARTY 5 -# define GEN_URI 6 -# define GEN_IPADD 7 -# define GEN_RID 8 - int type; - union { - char *ptr; - OTHERNAME *otherName; /* otherName */ - ASN1_IA5STRING *rfc822Name; - ASN1_IA5STRING *dNSName; - ASN1_TYPE *x400Address; - X509_NAME *directoryName; - EDIPARTYNAME *ediPartyName; - ASN1_IA5STRING *uniformResourceIdentifier; - ASN1_OCTET_STRING *iPAddress; - ASN1_OBJECT *registeredID; - /* Old names */ - ASN1_OCTET_STRING *ip; /* iPAddress */ - X509_NAME *dirn; /* dirn */ - ASN1_IA5STRING *ia5; /* rfc822Name, dNSName, - * uniformResourceIdentifier */ - ASN1_OBJECT *rid; /* registeredID */ - ASN1_TYPE *other; /* x400Address */ - } d; -} GENERAL_NAME; - -typedef struct ACCESS_DESCRIPTION_st { - ASN1_OBJECT *method; - GENERAL_NAME *location; -} ACCESS_DESCRIPTION; - -typedef STACK_OF(ACCESS_DESCRIPTION) AUTHORITY_INFO_ACCESS; - -typedef STACK_OF(ASN1_OBJECT) EXTENDED_KEY_USAGE; - -typedef STACK_OF(ASN1_INTEGER) TLS_FEATURE; - -DEFINE_STACK_OF(GENERAL_NAME) -typedef STACK_OF(GENERAL_NAME) GENERAL_NAMES; -DEFINE_STACK_OF(GENERAL_NAMES) - -DEFINE_STACK_OF(ACCESS_DESCRIPTION) - -typedef struct DIST_POINT_NAME_st { - int type; - union { - GENERAL_NAMES *fullname; - STACK_OF(X509_NAME_ENTRY) *relativename; - } name; -/* If relativename then this contains the full distribution point name */ - X509_NAME *dpname; -} DIST_POINT_NAME; -/* All existing reasons */ -# define CRLDP_ALL_REASONS 0x807f - -# define CRL_REASON_NONE -1 -# define CRL_REASON_UNSPECIFIED 0 -# define CRL_REASON_KEY_COMPROMISE 1 -# define CRL_REASON_CA_COMPROMISE 2 -# define CRL_REASON_AFFILIATION_CHANGED 3 -# define CRL_REASON_SUPERSEDED 4 -# define CRL_REASON_CESSATION_OF_OPERATION 5 -# define CRL_REASON_CERTIFICATE_HOLD 6 -# define CRL_REASON_REMOVE_FROM_CRL 8 -# define CRL_REASON_PRIVILEGE_WITHDRAWN 9 -# define CRL_REASON_AA_COMPROMISE 10 - -struct DIST_POINT_st { - DIST_POINT_NAME *distpoint; - ASN1_BIT_STRING *reasons; - GENERAL_NAMES *CRLissuer; - int dp_reasons; -}; - -typedef STACK_OF(DIST_POINT) CRL_DIST_POINTS; - -DEFINE_STACK_OF(DIST_POINT) - -struct AUTHORITY_KEYID_st { - ASN1_OCTET_STRING *keyid; - GENERAL_NAMES *issuer; - ASN1_INTEGER *serial; -}; - -/* Strong extranet structures */ - -typedef struct SXNET_ID_st { - ASN1_INTEGER *zone; - ASN1_OCTET_STRING *user; -} SXNETID; - -DEFINE_STACK_OF(SXNETID) - -typedef struct SXNET_st { - ASN1_INTEGER *version; - STACK_OF(SXNETID) *ids; -} SXNET; - -typedef struct NOTICEREF_st { - ASN1_STRING *organization; - STACK_OF(ASN1_INTEGER) *noticenos; -} NOTICEREF; - -typedef struct USERNOTICE_st { - NOTICEREF *noticeref; - ASN1_STRING *exptext; -} USERNOTICE; - -typedef struct POLICYQUALINFO_st { - ASN1_OBJECT *pqualid; - union { - ASN1_IA5STRING *cpsuri; - USERNOTICE *usernotice; - ASN1_TYPE *other; - } d; -} POLICYQUALINFO; - -DEFINE_STACK_OF(POLICYQUALINFO) - -typedef struct POLICYINFO_st { - ASN1_OBJECT *policyid; - STACK_OF(POLICYQUALINFO) *qualifiers; -} POLICYINFO; - -typedef STACK_OF(POLICYINFO) CERTIFICATEPOLICIES; - -DEFINE_STACK_OF(POLICYINFO) - -typedef struct POLICY_MAPPING_st { - ASN1_OBJECT *issuerDomainPolicy; - ASN1_OBJECT *subjectDomainPolicy; -} POLICY_MAPPING; - -DEFINE_STACK_OF(POLICY_MAPPING) - -typedef STACK_OF(POLICY_MAPPING) POLICY_MAPPINGS; - -typedef struct GENERAL_SUBTREE_st { - GENERAL_NAME *base; - ASN1_INTEGER *minimum; - ASN1_INTEGER *maximum; -} GENERAL_SUBTREE; - -DEFINE_STACK_OF(GENERAL_SUBTREE) - -struct NAME_CONSTRAINTS_st { - STACK_OF(GENERAL_SUBTREE) *permittedSubtrees; - STACK_OF(GENERAL_SUBTREE) *excludedSubtrees; -}; - -typedef struct POLICY_CONSTRAINTS_st { - ASN1_INTEGER *requireExplicitPolicy; - ASN1_INTEGER *inhibitPolicyMapping; -} POLICY_CONSTRAINTS; - -/* Proxy certificate structures, see RFC 3820 */ -typedef struct PROXY_POLICY_st { - ASN1_OBJECT *policyLanguage; - ASN1_OCTET_STRING *policy; -} PROXY_POLICY; - -typedef struct PROXY_CERT_INFO_EXTENSION_st { - ASN1_INTEGER *pcPathLengthConstraint; - PROXY_POLICY *proxyPolicy; -} PROXY_CERT_INFO_EXTENSION; - -DECLARE_ASN1_FUNCTIONS(PROXY_POLICY) -DECLARE_ASN1_FUNCTIONS(PROXY_CERT_INFO_EXTENSION) - -struct ISSUING_DIST_POINT_st { - DIST_POINT_NAME *distpoint; - int onlyuser; - int onlyCA; - ASN1_BIT_STRING *onlysomereasons; - int indirectCRL; - int onlyattr; -}; - -/* Values in idp_flags field */ -/* IDP present */ -# define IDP_PRESENT 0x1 -/* IDP values inconsistent */ -# define IDP_INVALID 0x2 -/* onlyuser true */ -# define IDP_ONLYUSER 0x4 -/* onlyCA true */ -# define IDP_ONLYCA 0x8 -/* onlyattr true */ -# define IDP_ONLYATTR 0x10 -/* indirectCRL true */ -# define IDP_INDIRECT 0x20 -/* onlysomereasons present */ -# define IDP_REASONS 0x40 - -# define X509V3_conf_err(val) ERR_add_error_data(6, "section:", val->section, \ -",name:", val->name, ",value:", val->value); - -# define X509V3_set_ctx_test(ctx) \ - X509V3_set_ctx(ctx, NULL, NULL, NULL, NULL, CTX_TEST) -# define X509V3_set_ctx_nodb(ctx) (ctx)->db = NULL; - -# define EXT_BITSTRING(nid, table) { nid, 0, ASN1_ITEM_ref(ASN1_BIT_STRING), \ - 0,0,0,0, \ - 0,0, \ - (X509V3_EXT_I2V)i2v_ASN1_BIT_STRING, \ - (X509V3_EXT_V2I)v2i_ASN1_BIT_STRING, \ - NULL, NULL, \ - table} - -# define EXT_IA5STRING(nid) { nid, 0, ASN1_ITEM_ref(ASN1_IA5STRING), \ - 0,0,0,0, \ - (X509V3_EXT_I2S)i2s_ASN1_IA5STRING, \ - (X509V3_EXT_S2I)s2i_ASN1_IA5STRING, \ - 0,0,0,0, \ - NULL} - -# define EXT_END { -1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0} - -/* X509_PURPOSE stuff */ - -# define EXFLAG_BCONS 0x1 -# define EXFLAG_KUSAGE 0x2 -# define EXFLAG_XKUSAGE 0x4 -# define EXFLAG_NSCERT 0x8 - -# define EXFLAG_CA 0x10 -/* Really self issued not necessarily self signed */ -# define EXFLAG_SI 0x20 -# define EXFLAG_V1 0x40 -# define EXFLAG_INVALID 0x80 -# define EXFLAG_SET 0x100 -# define EXFLAG_CRITICAL 0x200 -# define EXFLAG_PROXY 0x400 - -# define EXFLAG_INVALID_POLICY 0x800 -# define EXFLAG_FRESHEST 0x1000 -/* Self signed */ -# define EXFLAG_SS 0x2000 - -# define KU_DIGITAL_SIGNATURE 0x0080 -# define KU_NON_REPUDIATION 0x0040 -# define KU_KEY_ENCIPHERMENT 0x0020 -# define KU_DATA_ENCIPHERMENT 0x0010 -# define KU_KEY_AGREEMENT 0x0008 -# define KU_KEY_CERT_SIGN 0x0004 -# define KU_CRL_SIGN 0x0002 -# define KU_ENCIPHER_ONLY 0x0001 -# define KU_DECIPHER_ONLY 0x8000 - -# define NS_SSL_CLIENT 0x80 -# define NS_SSL_SERVER 0x40 -# define NS_SMIME 0x20 -# define NS_OBJSIGN 0x10 -# define NS_SSL_CA 0x04 -# define NS_SMIME_CA 0x02 -# define NS_OBJSIGN_CA 0x01 -# define NS_ANY_CA (NS_SSL_CA|NS_SMIME_CA|NS_OBJSIGN_CA) - -# define XKU_SSL_SERVER 0x1 -# define XKU_SSL_CLIENT 0x2 -# define XKU_SMIME 0x4 -# define XKU_CODE_SIGN 0x8 -# define XKU_SGC 0x10 -# define XKU_OCSP_SIGN 0x20 -# define XKU_TIMESTAMP 0x40 -# define XKU_DVCS 0x80 -# define XKU_ANYEKU 0x100 - -# define X509_PURPOSE_DYNAMIC 0x1 -# define X509_PURPOSE_DYNAMIC_NAME 0x2 - -typedef struct x509_purpose_st { - int purpose; - int trust; /* Default trust ID */ - int flags; - int (*check_purpose) (const struct x509_purpose_st *, const X509 *, int); - char *name; - char *sname; - void *usr_data; -} X509_PURPOSE; - -# define X509_PURPOSE_SSL_CLIENT 1 -# define X509_PURPOSE_SSL_SERVER 2 -# define X509_PURPOSE_NS_SSL_SERVER 3 -# define X509_PURPOSE_SMIME_SIGN 4 -# define X509_PURPOSE_SMIME_ENCRYPT 5 -# define X509_PURPOSE_CRL_SIGN 6 -# define X509_PURPOSE_ANY 7 -# define X509_PURPOSE_OCSP_HELPER 8 -# define X509_PURPOSE_TIMESTAMP_SIGN 9 - -# define X509_PURPOSE_MIN 1 -# define X509_PURPOSE_MAX 9 - -/* Flags for X509V3_EXT_print() */ - -# define X509V3_EXT_UNKNOWN_MASK (0xfL << 16) -/* Return error for unknown extensions */ -# define X509V3_EXT_DEFAULT 0 -/* Print error for unknown extensions */ -# define X509V3_EXT_ERROR_UNKNOWN (1L << 16) -/* ASN1 parse unknown extensions */ -# define X509V3_EXT_PARSE_UNKNOWN (2L << 16) -/* BIO_dump unknown extensions */ -# define X509V3_EXT_DUMP_UNKNOWN (3L << 16) - -/* Flags for X509V3_add1_i2d */ - -# define X509V3_ADD_OP_MASK 0xfL -# define X509V3_ADD_DEFAULT 0L -# define X509V3_ADD_APPEND 1L -# define X509V3_ADD_REPLACE 2L -# define X509V3_ADD_REPLACE_EXISTING 3L -# define X509V3_ADD_KEEP_EXISTING 4L -# define X509V3_ADD_DELETE 5L -# define X509V3_ADD_SILENT 0x10 - -DEFINE_STACK_OF(X509_PURPOSE) - -DECLARE_ASN1_FUNCTIONS(BASIC_CONSTRAINTS) - -DECLARE_ASN1_FUNCTIONS(SXNET) -DECLARE_ASN1_FUNCTIONS(SXNETID) - -int SXNET_add_id_asc(SXNET **psx, const char *zone, const char *user, int userlen); -int SXNET_add_id_ulong(SXNET **psx, unsigned long lzone, const char *user, - int userlen); -int SXNET_add_id_INTEGER(SXNET **psx, ASN1_INTEGER *izone, const char *user, - int userlen); - -ASN1_OCTET_STRING *SXNET_get_id_asc(SXNET *sx, const char *zone); -ASN1_OCTET_STRING *SXNET_get_id_ulong(SXNET *sx, unsigned long lzone); -ASN1_OCTET_STRING *SXNET_get_id_INTEGER(SXNET *sx, ASN1_INTEGER *zone); - -DECLARE_ASN1_FUNCTIONS(AUTHORITY_KEYID) - -DECLARE_ASN1_FUNCTIONS(PKEY_USAGE_PERIOD) - -DECLARE_ASN1_FUNCTIONS(GENERAL_NAME) -GENERAL_NAME *GENERAL_NAME_dup(GENERAL_NAME *a); -int GENERAL_NAME_cmp(GENERAL_NAME *a, GENERAL_NAME *b); - -ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, - STACK_OF(CONF_VALUE) *nval); -STACK_OF(CONF_VALUE) *i2v_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, - ASN1_BIT_STRING *bits, - STACK_OF(CONF_VALUE) *extlist); -char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method, ASN1_IA5STRING *ia5); -ASN1_IA5STRING *s2i_ASN1_IA5STRING(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, const char *str); - -STACK_OF(CONF_VALUE) *i2v_GENERAL_NAME(X509V3_EXT_METHOD *method, - GENERAL_NAME *gen, - STACK_OF(CONF_VALUE) *ret); -int GENERAL_NAME_print(BIO *out, GENERAL_NAME *gen); - -DECLARE_ASN1_FUNCTIONS(GENERAL_NAMES) - -STACK_OF(CONF_VALUE) *i2v_GENERAL_NAMES(X509V3_EXT_METHOD *method, - GENERAL_NAMES *gen, - STACK_OF(CONF_VALUE) *extlist); -GENERAL_NAMES *v2i_GENERAL_NAMES(const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *nval); - -DECLARE_ASN1_FUNCTIONS(OTHERNAME) -DECLARE_ASN1_FUNCTIONS(EDIPARTYNAME) -int OTHERNAME_cmp(OTHERNAME *a, OTHERNAME *b); -void GENERAL_NAME_set0_value(GENERAL_NAME *a, int type, void *value); -void *GENERAL_NAME_get0_value(GENERAL_NAME *a, int *ptype); -int GENERAL_NAME_set0_othername(GENERAL_NAME *gen, - ASN1_OBJECT *oid, ASN1_TYPE *value); -int GENERAL_NAME_get0_otherName(GENERAL_NAME *gen, - ASN1_OBJECT **poid, ASN1_TYPE **pvalue); - -char *i2s_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, - const ASN1_OCTET_STRING *ia5); -ASN1_OCTET_STRING *s2i_ASN1_OCTET_STRING(X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, const char *str); - -DECLARE_ASN1_FUNCTIONS(EXTENDED_KEY_USAGE) -int i2a_ACCESS_DESCRIPTION(BIO *bp, const ACCESS_DESCRIPTION *a); - -DECLARE_ASN1_ALLOC_FUNCTIONS(TLS_FEATURE) - -DECLARE_ASN1_FUNCTIONS(CERTIFICATEPOLICIES) -DECLARE_ASN1_FUNCTIONS(POLICYINFO) -DECLARE_ASN1_FUNCTIONS(POLICYQUALINFO) -DECLARE_ASN1_FUNCTIONS(USERNOTICE) -DECLARE_ASN1_FUNCTIONS(NOTICEREF) - -DECLARE_ASN1_FUNCTIONS(CRL_DIST_POINTS) -DECLARE_ASN1_FUNCTIONS(DIST_POINT) -DECLARE_ASN1_FUNCTIONS(DIST_POINT_NAME) -DECLARE_ASN1_FUNCTIONS(ISSUING_DIST_POINT) - -int DIST_POINT_set_dpname(DIST_POINT_NAME *dpn, X509_NAME *iname); - -int NAME_CONSTRAINTS_check(X509 *x, NAME_CONSTRAINTS *nc); -int NAME_CONSTRAINTS_check_CN(X509 *x, NAME_CONSTRAINTS *nc); - -DECLARE_ASN1_FUNCTIONS(ACCESS_DESCRIPTION) -DECLARE_ASN1_FUNCTIONS(AUTHORITY_INFO_ACCESS) - -DECLARE_ASN1_ITEM(POLICY_MAPPING) -DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_MAPPING) -DECLARE_ASN1_ITEM(POLICY_MAPPINGS) - -DECLARE_ASN1_ITEM(GENERAL_SUBTREE) -DECLARE_ASN1_ALLOC_FUNCTIONS(GENERAL_SUBTREE) - -DECLARE_ASN1_ITEM(NAME_CONSTRAINTS) -DECLARE_ASN1_ALLOC_FUNCTIONS(NAME_CONSTRAINTS) - -DECLARE_ASN1_ALLOC_FUNCTIONS(POLICY_CONSTRAINTS) -DECLARE_ASN1_ITEM(POLICY_CONSTRAINTS) - -GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, - const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, int gen_type, - const char *value, int is_nc); - -# ifdef HEADER_CONF_H -GENERAL_NAME *v2i_GENERAL_NAME(const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, CONF_VALUE *cnf); -GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, - const X509V3_EXT_METHOD *method, - X509V3_CTX *ctx, CONF_VALUE *cnf, - int is_nc); -void X509V3_conf_free(CONF_VALUE *val); - -X509_EXTENSION *X509V3_EXT_nconf_nid(CONF *conf, X509V3_CTX *ctx, int ext_nid, - const char *value); -X509_EXTENSION *X509V3_EXT_nconf(CONF *conf, X509V3_CTX *ctx, const char *name, - const char *value); -int X509V3_EXT_add_nconf_sk(CONF *conf, X509V3_CTX *ctx, const char *section, - STACK_OF(X509_EXTENSION) **sk); -int X509V3_EXT_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, - X509 *cert); -int X509V3_EXT_REQ_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, - X509_REQ *req); -int X509V3_EXT_CRL_add_nconf(CONF *conf, X509V3_CTX *ctx, const char *section, - X509_CRL *crl); - -X509_EXTENSION *X509V3_EXT_conf_nid(LHASH_OF(CONF_VALUE) *conf, - X509V3_CTX *ctx, int ext_nid, - const char *value); -X509_EXTENSION *X509V3_EXT_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - const char *name, const char *value); -int X509V3_EXT_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - const char *section, X509 *cert); -int X509V3_EXT_REQ_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - const char *section, X509_REQ *req); -int X509V3_EXT_CRL_add_conf(LHASH_OF(CONF_VALUE) *conf, X509V3_CTX *ctx, - const char *section, X509_CRL *crl); - -int X509V3_add_value_bool_nf(const char *name, int asn1_bool, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_get_value_bool(const CONF_VALUE *value, int *asn1_bool); -int X509V3_get_value_int(const CONF_VALUE *value, ASN1_INTEGER **aint); -void X509V3_set_nconf(X509V3_CTX *ctx, CONF *conf); -void X509V3_set_conf_lhash(X509V3_CTX *ctx, LHASH_OF(CONF_VALUE) *lhash); -# endif - -char *X509V3_get_string(X509V3_CTX *ctx, const char *name, const char *section); -STACK_OF(CONF_VALUE) *X509V3_get_section(X509V3_CTX *ctx, const char *section); -void X509V3_string_free(X509V3_CTX *ctx, char *str); -void X509V3_section_free(X509V3_CTX *ctx, STACK_OF(CONF_VALUE) *section); -void X509V3_set_ctx(X509V3_CTX *ctx, X509 *issuer, X509 *subject, - X509_REQ *req, X509_CRL *crl, int flags); - -int X509V3_add_value(const char *name, const char *value, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_add_value_uchar(const char *name, const unsigned char *value, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_add_value_bool(const char *name, int asn1_bool, - STACK_OF(CONF_VALUE) **extlist); -int X509V3_add_value_int(const char *name, const ASN1_INTEGER *aint, - STACK_OF(CONF_VALUE) **extlist); -char *i2s_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const ASN1_INTEGER *aint); -ASN1_INTEGER *s2i_ASN1_INTEGER(X509V3_EXT_METHOD *meth, const char *value); -char *i2s_ASN1_ENUMERATED(X509V3_EXT_METHOD *meth, const ASN1_ENUMERATED *aint); -char *i2s_ASN1_ENUMERATED_TABLE(X509V3_EXT_METHOD *meth, - const ASN1_ENUMERATED *aint); -int X509V3_EXT_add(X509V3_EXT_METHOD *ext); -int X509V3_EXT_add_list(X509V3_EXT_METHOD *extlist); -int X509V3_EXT_add_alias(int nid_to, int nid_from); -void X509V3_EXT_cleanup(void); - -const X509V3_EXT_METHOD *X509V3_EXT_get(X509_EXTENSION *ext); -const X509V3_EXT_METHOD *X509V3_EXT_get_nid(int nid); -int X509V3_add_standard_extensions(void); -STACK_OF(CONF_VALUE) *X509V3_parse_list(const char *line); -void *X509V3_EXT_d2i(X509_EXTENSION *ext); -void *X509V3_get_d2i(const STACK_OF(X509_EXTENSION) *x, int nid, int *crit, - int *idx); - -X509_EXTENSION *X509V3_EXT_i2d(int ext_nid, int crit, void *ext_struc); -int X509V3_add1_i2d(STACK_OF(X509_EXTENSION) **x, int nid, void *value, - int crit, unsigned long flags); - -#if OPENSSL_API_COMPAT < 0x10100000L -/* The new declarations are in crypto.h, but the old ones were here. */ -# define hex_to_string OPENSSL_buf2hexstr -# define string_to_hex OPENSSL_hexstr2buf -#endif - -void X509V3_EXT_val_prn(BIO *out, STACK_OF(CONF_VALUE) *val, int indent, - int ml); -int X509V3_EXT_print(BIO *out, X509_EXTENSION *ext, unsigned long flag, - int indent); -#ifndef OPENSSL_NO_STDIO -int X509V3_EXT_print_fp(FILE *out, X509_EXTENSION *ext, int flag, int indent); -#endif -int X509V3_extensions_print(BIO *out, const char *title, - const STACK_OF(X509_EXTENSION) *exts, - unsigned long flag, int indent); - -int X509_check_ca(X509 *x); -int X509_check_purpose(X509 *x, int id, int ca); -int X509_supported_extension(X509_EXTENSION *ex); -int X509_PURPOSE_set(int *p, int purpose); -int X509_check_issued(X509 *issuer, X509 *subject); -int X509_check_akid(X509 *issuer, AUTHORITY_KEYID *akid); -void X509_set_proxy_flag(X509 *x); -void X509_set_proxy_pathlen(X509 *x, long l); -long X509_get_proxy_pathlen(X509 *x); - -uint32_t X509_get_extension_flags(X509 *x); -uint32_t X509_get_key_usage(X509 *x); -uint32_t X509_get_extended_key_usage(X509 *x); -const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x); - -int X509_PURPOSE_get_count(void); -X509_PURPOSE *X509_PURPOSE_get0(int idx); -int X509_PURPOSE_get_by_sname(const char *sname); -int X509_PURPOSE_get_by_id(int id); -int X509_PURPOSE_add(int id, int trust, int flags, - int (*ck) (const X509_PURPOSE *, const X509 *, int), - const char *name, const char *sname, void *arg); -char *X509_PURPOSE_get0_name(const X509_PURPOSE *xp); -char *X509_PURPOSE_get0_sname(const X509_PURPOSE *xp); -int X509_PURPOSE_get_trust(const X509_PURPOSE *xp); -void X509_PURPOSE_cleanup(void); -int X509_PURPOSE_get_id(const X509_PURPOSE *); - -STACK_OF(OPENSSL_STRING) *X509_get1_email(X509 *x); -STACK_OF(OPENSSL_STRING) *X509_REQ_get1_email(X509_REQ *x); -void X509_email_free(STACK_OF(OPENSSL_STRING) *sk); -STACK_OF(OPENSSL_STRING) *X509_get1_ocsp(X509 *x); -/* Flags for X509_check_* functions */ - -/* - * Always check subject name for host match even if subject alt names present - */ -# define X509_CHECK_FLAG_ALWAYS_CHECK_SUBJECT 0x1 -/* Disable wildcard matching for dnsName fields and common name. */ -# define X509_CHECK_FLAG_NO_WILDCARDS 0x2 -/* Wildcards must not match a partial label. */ -# define X509_CHECK_FLAG_NO_PARTIAL_WILDCARDS 0x4 -/* Allow (non-partial) wildcards to match multiple labels. */ -# define X509_CHECK_FLAG_MULTI_LABEL_WILDCARDS 0x8 -/* Constraint verifier subdomain patterns to match a single labels. */ -# define X509_CHECK_FLAG_SINGLE_LABEL_SUBDOMAINS 0x10 -/* Never check the subject CN */ -# define X509_CHECK_FLAG_NEVER_CHECK_SUBJECT 0x20 -/* - * Match reference identifiers starting with "." to any sub-domain. - * This is a non-public flag, turned on implicitly when the subject - * reference identity is a DNS name. - */ -# define _X509_CHECK_FLAG_DOT_SUBDOMAINS 0x8000 - -int X509_check_host(X509 *x, const char *chk, size_t chklen, - unsigned int flags, char **peername); -int X509_check_email(X509 *x, const char *chk, size_t chklen, - unsigned int flags); -int X509_check_ip(X509 *x, const unsigned char *chk, size_t chklen, - unsigned int flags); -int X509_check_ip_asc(X509 *x, const char *ipasc, unsigned int flags); - -ASN1_OCTET_STRING *a2i_IPADDRESS(const char *ipasc); -ASN1_OCTET_STRING *a2i_IPADDRESS_NC(const char *ipasc); -int X509V3_NAME_from_section(X509_NAME *nm, STACK_OF(CONF_VALUE) *dn_sk, - unsigned long chtype); - -void X509_POLICY_NODE_print(BIO *out, X509_POLICY_NODE *node, int indent); -DEFINE_STACK_OF(X509_POLICY_NODE) - -#ifndef OPENSSL_NO_RFC3779 -typedef struct ASRange_st { - ASN1_INTEGER *min, *max; -} ASRange; - -# define ASIdOrRange_id 0 -# define ASIdOrRange_range 1 - -typedef struct ASIdOrRange_st { - int type; - union { - ASN1_INTEGER *id; - ASRange *range; - } u; -} ASIdOrRange; - -typedef STACK_OF(ASIdOrRange) ASIdOrRanges; -DEFINE_STACK_OF(ASIdOrRange) - -# define ASIdentifierChoice_inherit 0 -# define ASIdentifierChoice_asIdsOrRanges 1 - -typedef struct ASIdentifierChoice_st { - int type; - union { - ASN1_NULL *inherit; - ASIdOrRanges *asIdsOrRanges; - } u; -} ASIdentifierChoice; - -typedef struct ASIdentifiers_st { - ASIdentifierChoice *asnum, *rdi; -} ASIdentifiers; - -DECLARE_ASN1_FUNCTIONS(ASRange) -DECLARE_ASN1_FUNCTIONS(ASIdOrRange) -DECLARE_ASN1_FUNCTIONS(ASIdentifierChoice) -DECLARE_ASN1_FUNCTIONS(ASIdentifiers) - -typedef struct IPAddressRange_st { - ASN1_BIT_STRING *min, *max; -} IPAddressRange; - -# define IPAddressOrRange_addressPrefix 0 -# define IPAddressOrRange_addressRange 1 - -typedef struct IPAddressOrRange_st { - int type; - union { - ASN1_BIT_STRING *addressPrefix; - IPAddressRange *addressRange; - } u; -} IPAddressOrRange; - -typedef STACK_OF(IPAddressOrRange) IPAddressOrRanges; -DEFINE_STACK_OF(IPAddressOrRange) - -# define IPAddressChoice_inherit 0 -# define IPAddressChoice_addressesOrRanges 1 - -typedef struct IPAddressChoice_st { - int type; - union { - ASN1_NULL *inherit; - IPAddressOrRanges *addressesOrRanges; - } u; -} IPAddressChoice; - -typedef struct IPAddressFamily_st { - ASN1_OCTET_STRING *addressFamily; - IPAddressChoice *ipAddressChoice; -} IPAddressFamily; - -typedef STACK_OF(IPAddressFamily) IPAddrBlocks; -DEFINE_STACK_OF(IPAddressFamily) - -DECLARE_ASN1_FUNCTIONS(IPAddressRange) -DECLARE_ASN1_FUNCTIONS(IPAddressOrRange) -DECLARE_ASN1_FUNCTIONS(IPAddressChoice) -DECLARE_ASN1_FUNCTIONS(IPAddressFamily) - -/* - * API tag for elements of the ASIdentifer SEQUENCE. - */ -# define V3_ASID_ASNUM 0 -# define V3_ASID_RDI 1 - -/* - * AFI values, assigned by IANA. It'd be nice to make the AFI - * handling code totally generic, but there are too many little things - * that would need to be defined for other address families for it to - * be worth the trouble. - */ -# define IANA_AFI_IPV4 1 -# define IANA_AFI_IPV6 2 - -/* - * Utilities to construct and extract values from RFC3779 extensions, - * since some of the encodings (particularly for IP address prefixes - * and ranges) are a bit tedious to work with directly. - */ -int X509v3_asid_add_inherit(ASIdentifiers *asid, int which); -int X509v3_asid_add_id_or_range(ASIdentifiers *asid, int which, - ASN1_INTEGER *min, ASN1_INTEGER *max); -int X509v3_addr_add_inherit(IPAddrBlocks *addr, - const unsigned afi, const unsigned *safi); -int X509v3_addr_add_prefix(IPAddrBlocks *addr, - const unsigned afi, const unsigned *safi, - unsigned char *a, const int prefixlen); -int X509v3_addr_add_range(IPAddrBlocks *addr, - const unsigned afi, const unsigned *safi, - unsigned char *min, unsigned char *max); -unsigned X509v3_addr_get_afi(const IPAddressFamily *f); -int X509v3_addr_get_range(IPAddressOrRange *aor, const unsigned afi, - unsigned char *min, unsigned char *max, - const int length); - -/* - * Canonical forms. - */ -int X509v3_asid_is_canonical(ASIdentifiers *asid); -int X509v3_addr_is_canonical(IPAddrBlocks *addr); -int X509v3_asid_canonize(ASIdentifiers *asid); -int X509v3_addr_canonize(IPAddrBlocks *addr); - -/* - * Tests for inheritance and containment. - */ -int X509v3_asid_inherits(ASIdentifiers *asid); -int X509v3_addr_inherits(IPAddrBlocks *addr); -int X509v3_asid_subset(ASIdentifiers *a, ASIdentifiers *b); -int X509v3_addr_subset(IPAddrBlocks *a, IPAddrBlocks *b); - -/* - * Check whether RFC 3779 extensions nest properly in chains. - */ -int X509v3_asid_validate_path(X509_STORE_CTX *); -int X509v3_addr_validate_path(X509_STORE_CTX *); -int X509v3_asid_validate_resource_set(STACK_OF(X509) *chain, - ASIdentifiers *ext, - int allow_inheritance); -int X509v3_addr_validate_resource_set(STACK_OF(X509) *chain, - IPAddrBlocks *ext, int allow_inheritance); - -#endif /* OPENSSL_NO_RFC3779 */ - -/* BEGIN ERROR CODES */ -/* - * The following lines are auto generated by the script mkerr.pl. Any changes - * made after this point may be overwritten when the script is next run. - */ - -int ERR_load_X509V3_strings(void); - -/* Error codes for the X509V3 functions. */ - -/* Function codes. */ -# define X509V3_F_A2I_GENERAL_NAME 164 -# define X509V3_F_ADDR_VALIDATE_PATH_INTERNAL 166 -# define X509V3_F_ASIDENTIFIERCHOICE_CANONIZE 161 -# define X509V3_F_ASIDENTIFIERCHOICE_IS_CANONICAL 162 -# define X509V3_F_COPY_EMAIL 122 -# define X509V3_F_COPY_ISSUER 123 -# define X509V3_F_DO_DIRNAME 144 -# define X509V3_F_DO_EXT_I2D 135 -# define X509V3_F_DO_EXT_NCONF 151 -# define X509V3_F_GNAMES_FROM_SECTNAME 156 -# define X509V3_F_I2S_ASN1_ENUMERATED 121 -# define X509V3_F_I2S_ASN1_IA5STRING 149 -# define X509V3_F_I2S_ASN1_INTEGER 120 -# define X509V3_F_I2V_AUTHORITY_INFO_ACCESS 138 -# define X509V3_F_NOTICE_SECTION 132 -# define X509V3_F_NREF_NOS 133 -# define X509V3_F_POLICY_SECTION 131 -# define X509V3_F_PROCESS_PCI_VALUE 150 -# define X509V3_F_R2I_CERTPOL 130 -# define X509V3_F_R2I_PCI 155 -# define X509V3_F_S2I_ASN1_IA5STRING 100 -# define X509V3_F_S2I_ASN1_INTEGER 108 -# define X509V3_F_S2I_ASN1_OCTET_STRING 112 -# define X509V3_F_S2I_SKEY_ID 115 -# define X509V3_F_SET_DIST_POINT_NAME 158 -# define X509V3_F_SXNET_ADD_ID_ASC 125 -# define X509V3_F_SXNET_ADD_ID_INTEGER 126 -# define X509V3_F_SXNET_ADD_ID_ULONG 127 -# define X509V3_F_SXNET_GET_ID_ASC 128 -# define X509V3_F_SXNET_GET_ID_ULONG 129 -# define X509V3_F_V2I_ASIDENTIFIERS 163 -# define X509V3_F_V2I_ASN1_BIT_STRING 101 -# define X509V3_F_V2I_AUTHORITY_INFO_ACCESS 139 -# define X509V3_F_V2I_AUTHORITY_KEYID 119 -# define X509V3_F_V2I_BASIC_CONSTRAINTS 102 -# define X509V3_F_V2I_CRLD 134 -# define X509V3_F_V2I_EXTENDED_KEY_USAGE 103 -# define X509V3_F_V2I_GENERAL_NAMES 118 -# define X509V3_F_V2I_GENERAL_NAME_EX 117 -# define X509V3_F_V2I_IDP 157 -# define X509V3_F_V2I_IPADDRBLOCKS 159 -# define X509V3_F_V2I_ISSUER_ALT 153 -# define X509V3_F_V2I_NAME_CONSTRAINTS 147 -# define X509V3_F_V2I_POLICY_CONSTRAINTS 146 -# define X509V3_F_V2I_POLICY_MAPPINGS 145 -# define X509V3_F_V2I_SUBJECT_ALT 154 -# define X509V3_F_V2I_TLS_FEATURE 165 -# define X509V3_F_V3_GENERIC_EXTENSION 116 -# define X509V3_F_X509V3_ADD1_I2D 140 -# define X509V3_F_X509V3_ADD_VALUE 105 -# define X509V3_F_X509V3_EXT_ADD 104 -# define X509V3_F_X509V3_EXT_ADD_ALIAS 106 -# define X509V3_F_X509V3_EXT_I2D 136 -# define X509V3_F_X509V3_EXT_NCONF 152 -# define X509V3_F_X509V3_GET_SECTION 142 -# define X509V3_F_X509V3_GET_STRING 143 -# define X509V3_F_X509V3_GET_VALUE_BOOL 110 -# define X509V3_F_X509V3_PARSE_LIST 109 -# define X509V3_F_X509_PURPOSE_ADD 137 -# define X509V3_F_X509_PURPOSE_SET 141 - -/* Reason codes. */ -# define X509V3_R_BAD_IP_ADDRESS 118 -# define X509V3_R_BAD_OBJECT 119 -# define X509V3_R_BN_DEC2BN_ERROR 100 -# define X509V3_R_BN_TO_ASN1_INTEGER_ERROR 101 -# define X509V3_R_DIRNAME_ERROR 149 -# define X509V3_R_DISTPOINT_ALREADY_SET 160 -# define X509V3_R_DUPLICATE_ZONE_ID 133 -# define X509V3_R_ERROR_CONVERTING_ZONE 131 -# define X509V3_R_ERROR_CREATING_EXTENSION 144 -# define X509V3_R_ERROR_IN_EXTENSION 128 -# define X509V3_R_EXPECTED_A_SECTION_NAME 137 -# define X509V3_R_EXTENSION_EXISTS 145 -# define X509V3_R_EXTENSION_NAME_ERROR 115 -# define X509V3_R_EXTENSION_NOT_FOUND 102 -# define X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED 103 -# define X509V3_R_EXTENSION_VALUE_ERROR 116 -# define X509V3_R_ILLEGAL_EMPTY_EXTENSION 151 -# define X509V3_R_INCORRECT_POLICY_SYNTAX_TAG 152 -# define X509V3_R_INVALID_ASNUMBER 162 -# define X509V3_R_INVALID_ASRANGE 163 -# define X509V3_R_INVALID_BOOLEAN_STRING 104 -# define X509V3_R_INVALID_EXTENSION_STRING 105 -# define X509V3_R_INVALID_INHERITANCE 165 -# define X509V3_R_INVALID_IPADDRESS 166 -# define X509V3_R_INVALID_MULTIPLE_RDNS 161 -# define X509V3_R_INVALID_NAME 106 -# define X509V3_R_INVALID_NULL_ARGUMENT 107 -# define X509V3_R_INVALID_NULL_NAME 108 -# define X509V3_R_INVALID_NULL_VALUE 109 -# define X509V3_R_INVALID_NUMBER 140 -# define X509V3_R_INVALID_NUMBERS 141 -# define X509V3_R_INVALID_OBJECT_IDENTIFIER 110 -# define X509V3_R_INVALID_OPTION 138 -# define X509V3_R_INVALID_POLICY_IDENTIFIER 134 -# define X509V3_R_INVALID_PROXY_POLICY_SETTING 153 -# define X509V3_R_INVALID_PURPOSE 146 -# define X509V3_R_INVALID_SAFI 164 -# define X509V3_R_INVALID_SECTION 135 -# define X509V3_R_INVALID_SYNTAX 143 -# define X509V3_R_ISSUER_DECODE_ERROR 126 -# define X509V3_R_MISSING_VALUE 124 -# define X509V3_R_NEED_ORGANIZATION_AND_NUMBERS 142 -# define X509V3_R_NO_CONFIG_DATABASE 136 -# define X509V3_R_NO_ISSUER_CERTIFICATE 121 -# define X509V3_R_NO_ISSUER_DETAILS 127 -# define X509V3_R_NO_POLICY_IDENTIFIER 139 -# define X509V3_R_NO_PROXY_CERT_POLICY_LANGUAGE_DEFINED 154 -# define X509V3_R_NO_PUBLIC_KEY 114 -# define X509V3_R_NO_SUBJECT_DETAILS 125 -# define X509V3_R_OPERATION_NOT_DEFINED 148 -# define X509V3_R_OTHERNAME_ERROR 147 -# define X509V3_R_POLICY_LANGUAGE_ALREADY_DEFINED 155 -# define X509V3_R_POLICY_PATH_LENGTH 156 -# define X509V3_R_POLICY_PATH_LENGTH_ALREADY_DEFINED 157 -# define X509V3_R_POLICY_WHEN_PROXY_LANGUAGE_REQUIRES_NO_POLICY 159 -# define X509V3_R_SECTION_NOT_FOUND 150 -# define X509V3_R_UNABLE_TO_GET_ISSUER_DETAILS 122 -# define X509V3_R_UNABLE_TO_GET_ISSUER_KEYID 123 -# define X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT 111 -# define X509V3_R_UNKNOWN_EXTENSION 129 -# define X509V3_R_UNKNOWN_EXTENSION_NAME 130 -# define X509V3_R_UNKNOWN_OPTION 120 -# define X509V3_R_UNSUPPORTED_OPTION 117 -# define X509V3_R_UNSUPPORTED_TYPE 167 -# define X509V3_R_USER_TOO_LONG 132 - -# ifdef __cplusplus -} -# endif -#endif diff --git a/android/armeabi/include/png/png.h b/android/armeabi/include/png/png.h deleted file mode 100644 index 123201d3..00000000 --- a/android/armeabi/include/png/png.h +++ /dev/null @@ -1,3130 +0,0 @@ - -/* png.h - header file for PNG reference library - * - * libpng version 1.6.21, January 15, 2016 - * - * Copyright (c) 1998-2002,2004,2006-2016 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license (See LICENSE, below) - * - * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.6.21, January 15, 2016: - * Glenn Randers-Pehrson. - * See also "Contributing Authors", below. - */ - -/* - * COPYRIGHT NOTICE, DISCLAIMER, and LICENSE: - * - * If you modify libpng you may insert additional notices immediately following - * this sentence. - * - * This code is released under the libpng license. - * - * libpng versions 1.0.7, July 1, 2000, through 1.6.21, January 15, 2016, are - * Copyright (c) 2000-2002, 2004, 2006-2016 Glenn Randers-Pehrson, are - * derived from libpng-1.0.6, and are distributed according to the same - * disclaimer and license as libpng-1.0.6 with the following individuals - * added to the list of Contributing Authors: - * - * Simon-Pierre Cadieux - * Eric S. Raymond - * Mans Rullgard - * Cosmin Truta - * Gilles Vollant - * James Yu - * - * and with the following additions to the disclaimer: - * - * There is no warranty against interference with your enjoyment of the - * library or against infringement. There is no warranty that our - * efforts or the library will fulfill any of your particular purposes - * or needs. This library is provided with all faults, and the entire - * risk of satisfactory quality, performance, accuracy, and effort is with - * the user. - * - * libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are - * Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from - * libpng-0.96, and are distributed according to the same disclaimer and - * license as libpng-0.96, with the following individuals added to the list - * of Contributing Authors: - * - * Tom Lane - * Glenn Randers-Pehrson - * Willem van Schaik - * - * libpng versions 0.89, June 1996, through 0.96, May 1997, are - * Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88, - * and are distributed according to the same disclaimer and license as - * libpng-0.88, with the following individuals added to the list of - * Contributing Authors: - * - * John Bowler - * Kevin Bracey - * Sam Bushell - * Magnus Holmgren - * Greg Roelofs - * Tom Tanner - * - * libpng versions 0.5, May 1995, through 0.88, January 1996, are - * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc. - * - * For the purposes of this copyright and license, "Contributing Authors" - * is defined as the following set of individuals: - * - * Andreas Dilger - * Dave Martindale - * Guy Eric Schalnat - * Paul Schmidt - * Tim Wegner - * - * The PNG Reference Library is supplied "AS IS". The Contributing Authors - * and Group 42, Inc. disclaim all warranties, expressed or implied, - * including, without limitation, the warranties of merchantability and of - * fitness for any purpose. The Contributing Authors and Group 42, Inc. - * assume no liability for direct, indirect, incidental, special, exemplary, - * or consequential damages, which may result from the use of the PNG - * Reference Library, even if advised of the possibility of such damage. - * - * Permission is hereby granted to use, copy, modify, and distribute this - * source code, or portions hereof, for any purpose, without fee, subject - * to the following restrictions: - * - * 1. The origin of this source code must not be misrepresented. - * - * 2. Altered versions must be plainly marked as such and must not - * be misrepresented as being the original source. - * - * 3. This Copyright notice may not be removed or altered from any - * source or altered source distribution. - * - * The Contributing Authors and Group 42, Inc. specifically permit, without - * fee, and encourage the use of this source code as a component to - * supporting the PNG file format in commercial products. If you use this - * source code in a product, acknowledgment is not required but would be - * appreciated. - * - * END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE. - */ - -/* - * A "png_get_copyright" function is available, for convenient use in "about" - * boxes and the like: - * - * printf("%s", png_get_copyright(NULL)); - * - * Also, the PNG logo (in PNG format, of course) is supplied in the - * files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31). - */ - -/* - * Libpng is OSI Certified Open Source Software. OSI Certified Open Source is - * a certification mark of the Open Source Initiative. OSI has not addressed - * the additional disclaimers inserted at version 1.0.7. - */ - -/* - * The contributing authors would like to thank all those who helped - * with testing, bug fixes, and patience. This wouldn't have been - * possible without all of you. - * - * Thanks to Frank J. T. Wojcik for helping with the documentation. - */ - -/* Note about libpng version numbers: - * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: - * - * source png.h png.h shared-lib - * version string int version - * ------- ------ ----- ---------- - * 0.89c "1.0 beta 3" 0.89 89 1.0.89 - * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] - * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] - * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] - * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] - * 0.97c 0.97 97 2.0.97 - * 0.98 0.98 98 2.0.98 - * 0.99 0.99 98 2.0.99 - * 0.99a-m 0.99 99 2.0.99 - * 1.00 1.00 100 2.1.0 [100 should be 10000] - * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] - * 1.0.1 png.h string is 10001 2.1.0 - * 1.0.1a-e identical to the 10002 from here on, the shared library - * 1.0.2 source version) 10002 is 2.V where V is the source code - * 1.0.2a-b 10003 version, except as noted. - * 1.0.3 10003 - * 1.0.3a-d 10004 - * 1.0.4 10004 - * 1.0.4a-f 10005 - * 1.0.5 (+ 2 patches) 10005 - * 1.0.5a-d 10006 - * 1.0.5e-r 10100 (not source compatible) - * 1.0.5s-v 10006 (not binary compatible) - * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) - * 1.0.6d-f 10007 (still binary incompatible) - * 1.0.6g 10007 - * 1.0.6h 10007 10.6h (testing xy.z so-numbering) - * 1.0.6i 10007 10.6i - * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) - * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) - * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) - * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) - * 1.0.7 1 10007 (still compatible) - * ... - * 1.0.19 10 10019 10.so.0.19[.0] - * ... - * 1.2.53 13 10253 12.so.0.53[.0] - * ... - * 1.5.23 15 10523 15.so.15.23[.0] - * ... - * 1.6.21 16 10621 16.so.16.21[.0] - * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcNN". - * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. - * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). - * - * See libpng.txt or libpng.3 for more information. The PNG specification - * is available as a W3C Recommendation and as an ISO Specification, - * <http://www.w3.org/TR/2003/REC-PNG-20031110/ - */ - -/* - * Y2K compliance in libpng: - * ========================= - * - * January 15, 2016 - * - * Since the PNG Development group is an ad-hoc body, we can't make - * an official declaration. - * - * This is your unofficial assurance that libpng from version 0.71 and - * upward through 1.6.21 are Y2K compliant. It is my belief that - * earlier versions were also Y2K compliant. - * - * Libpng only has two year fields. One is a 2-byte unsigned integer - * that will hold years up to 65535. The other, which is deprecated, - * holds the date in text format, and will hold years up to 9999. - * - * The integer is - * "png_uint_16 year" in png_time_struct. - * - * The string is - * "char time_buffer[29]" in png_struct. This is no longer used - * in libpng-1.6.x and will be removed from libpng-1.7.0. - * - * There are seven time-related functions: - * png.c: png_convert_to_rfc_1123_buffer() in png.c - * (formerly png_convert_to_rfc_1123() prior to libpng-1.5.x and - * png_convert_to_rfc_1152() in error prior to libpng-0.98) - * png_convert_from_struct_tm() in pngwrite.c, called in pngwrite.c - * png_convert_from_time_t() in pngwrite.c - * png_get_tIME() in pngget.c - * png_handle_tIME() in pngrutil.c, called in pngread.c - * png_set_tIME() in pngset.c - * png_write_tIME() in pngwutil.c, called in pngwrite.c - * - * All handle dates properly in a Y2K environment. The - * png_convert_from_time_t() function calls gmtime() to convert from system - * clock time, which returns (year - 1900), which we properly convert to - * the full 4-digit year. There is a possibility that libpng applications - * are not passing 4-digit years into the png_convert_to_rfc_1123_buffer() - * function, or that they are incorrectly passing only a 2-digit year - * instead of "year - 1900" into the png_convert_from_struct_tm() function, - * but this is not under our control. The libpng documentation has always - * stated that it works with 4-digit years, and the APIs have been - * documented as such. - * - * The tIME chunk itself is also Y2K compliant. It uses a 2-byte unsigned - * integer to hold the year, and can hold years as large as 65535. - * - * zlib, upon which libpng depends, is also Y2K compliant. It contains - * no date-related code. - * - * Glenn Randers-Pehrson - * libpng maintainer - * PNG Development Group - */ - -#ifndef PNG_H -#define PNG_H - -/* This is not the place to learn how to use libpng. The file libpng-manual.txt - * describes how to use libpng, and the file example.c summarizes it - * with some code on which to build. This file is useful for looking - * at the actual function definitions and structure components. If that - * file has been stripped from your copy of libpng, you can find it at - * <http://www.libpng.org/pub/png/libpng-manual.txt> - * - * If you just need to read a PNG file and don't want to read the documentation - * skip to the end of this file and read the section entitled 'simplified API'. - */ - -/* Version information for png.h - this should match the version in png.c */ -#define PNG_LIBPNG_VER_STRING "1.6.21" -#define PNG_HEADER_VERSION_STRING \ - " libpng version 1.6.21 - January 15, 2016\n" - -#define PNG_LIBPNG_VER_SONUM 16 -#define PNG_LIBPNG_VER_DLLNUM 16 - -/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */ -#define PNG_LIBPNG_VER_MAJOR 1 -#define PNG_LIBPNG_VER_MINOR 6 -#define PNG_LIBPNG_VER_RELEASE 21 - -/* This should match the numeric part of the final component of - * PNG_LIBPNG_VER_STRING, omitting any leading zero: - */ - -#define PNG_LIBPNG_VER_BUILD 0 - -/* Release Status */ -#define PNG_LIBPNG_BUILD_ALPHA 1 -#define PNG_LIBPNG_BUILD_BETA 2 -#define PNG_LIBPNG_BUILD_RC 3 -#define PNG_LIBPNG_BUILD_STABLE 4 -#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7 - -/* Release-Specific Flags */ -#define PNG_LIBPNG_BUILD_PATCH 8 /* Can be OR'ed with - PNG_LIBPNG_BUILD_STABLE only */ -#define PNG_LIBPNG_BUILD_PRIVATE 16 /* Cannot be OR'ed with - PNG_LIBPNG_BUILD_SPECIAL */ -#define PNG_LIBPNG_BUILD_SPECIAL 32 /* Cannot be OR'ed with - PNG_LIBPNG_BUILD_PRIVATE */ - -#define PNG_LIBPNG_BUILD_BASE_TYPE PNG_LIBPNG_BUILD_STABLE - -/* Careful here. At one time, Guy wanted to use 082, but that would be octal. - * We must not include leading zeros. - * Versions 0.7 through 1.0.0 were in the range 0 to 100 here (only - * version 1.0.0 was mis-numbered 100 instead of 10000). From - * version 1.0.1 it's xxyyzz, where x=major, y=minor, z=release - */ -#define PNG_LIBPNG_VER 10621 /* 1.6.21 */ - -/* Library configuration: these options cannot be changed after - * the library has been built. - */ -#ifndef PNGLCONF_H - /* If pnglibconf.h is missing, you can - * copy scripts/pnglibconf.h.prebuilt to pnglibconf.h - */ -# include "pnglibconf.h" -#endif - -#ifndef PNG_VERSION_INFO_ONLY - /* Machine specific configuration. */ -# include "pngconf.h" -#endif - -/* - * Added at libpng-1.2.8 - * - * Ref MSDN: Private as priority over Special - * VS_FF_PRIVATEBUILD File *was not* built using standard release - * procedures. If this value is given, the StringFileInfo block must - * contain a PrivateBuild string. - * - * VS_FF_SPECIALBUILD File *was* built by the original company using - * standard release procedures but is a variation of the standard - * file of the same version number. If this value is given, the - * StringFileInfo block must contain a SpecialBuild string. - */ - -#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */ -# define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) -#else -# ifdef PNG_LIBPNG_SPECIALBUILD -# define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) -# else -# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) -# endif -#endif - -#ifndef PNG_VERSION_INFO_ONLY - -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Version information for C files, stored in png.c. This had better match - * the version above. - */ -#define png_libpng_ver png_get_header_ver(NULL) - -/* This file is arranged in several sections: - * - * 1. [omitted] - * 2. Any configuration options that can be specified by for the application - * code when it is built. (Build time configuration is in pnglibconf.h) - * 3. Type definitions (base types are defined in pngconf.h), structure - * definitions. - * 4. Exported library functions. - * 5. Simplified API. - * 6. Implementation options. - * - * The library source code has additional files (principally pngpriv.h) that - * allow configuration of the library. - */ - -/* Section 1: [omitted] */ - -/* Section 2: run time configuration - * See pnglibconf.h for build time configuration - * - * Run time configuration allows the application to choose between - * implementations of certain arithmetic APIs. The default is set - * at build time and recorded in pnglibconf.h, but it is safe to - * override these (and only these) settings. Note that this won't - * change what the library does, only application code, and the - * settings can (and probably should) be made on a per-file basis - * by setting the #defines before including png.h - * - * Use macros to read integers from PNG data or use the exported - * functions? - * PNG_USE_READ_MACROS: use the macros (see below) Note that - * the macros evaluate their argument multiple times. - * PNG_NO_USE_READ_MACROS: call the relevant library function. - * - * Use the alternative algorithm for compositing alpha samples that - * does not use division? - * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division' - * algorithm. - * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm. - * - * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is - * false? - * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error - * APIs to png_warning. - * Otherwise the calls are mapped to png_error. - */ - -/* Section 3: type definitions, including structures and compile time - * constants. - * See pngconf.h for base types that vary by machine/system - */ - -/* This triggers a compiler error in png.c, if png.c and png.h - * do not agree upon the version number. - */ -typedef char* png_libpng_version_1_6_21; - -/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info. - * - * png_struct is the cache of information used while reading or writing a single - * PNG file. One of these is always required, although the simplified API - * (below) hides the creation and destruction of it. - */ -typedef struct png_struct_def png_struct; -typedef const png_struct * png_const_structp; -typedef png_struct * png_structp; -typedef png_struct * * png_structpp; - -/* png_info contains information read from or to be written to a PNG file. One - * or more of these must exist while reading or creating a PNG file. The - * information is not used by libpng during read but is used to control what - * gets written when a PNG file is created. "png_get_" function calls read - * information during read and "png_set_" functions calls write information - * when creating a PNG. - * been moved into a separate header file that is not accessible to - * applications. Read libpng-manual.txt or libpng.3 for more info. - */ -typedef struct png_info_def png_info; -typedef png_info * png_infop; -typedef const png_info * png_const_infop; -typedef png_info * * png_infopp; - -/* Types with names ending 'p' are pointer types. The corresponding types with - * names ending 'rp' are identical pointer types except that the pointer is - * marked 'restrict', which means that it is the only pointer to the object - * passed to the function. Applications should not use the 'restrict' types; - * it is always valid to pass 'p' to a pointer with a function argument of the - * corresponding 'rp' type. Different compilers have different rules with - * regard to type matching in the presence of 'restrict'. For backward - * compatibility libpng callbacks never have 'restrict' in their parameters and, - * consequentially, writing portable application code is extremely difficult if - * an attempt is made to use 'restrict'. - */ -typedef png_struct * PNG_RESTRICT png_structrp; -typedef const png_struct * PNG_RESTRICT png_const_structrp; -typedef png_info * PNG_RESTRICT png_inforp; -typedef const png_info * PNG_RESTRICT png_const_inforp; - -/* Three color definitions. The order of the red, green, and blue, (and the - * exact size) is not important, although the size of the fields need to - * be png_byte or png_uint_16 (as defined below). - */ -typedef struct png_color_struct -{ - png_byte red; - png_byte green; - png_byte blue; -} png_color; -typedef png_color * png_colorp; -typedef const png_color * png_const_colorp; -typedef png_color * * png_colorpp; - -typedef struct png_color_16_struct -{ - png_byte index; /* used for palette files */ - png_uint_16 red; /* for use in red green blue files */ - png_uint_16 green; - png_uint_16 blue; - png_uint_16 gray; /* for use in grayscale files */ -} png_color_16; -typedef png_color_16 * png_color_16p; -typedef const png_color_16 * png_const_color_16p; -typedef png_color_16 * * png_color_16pp; - -typedef struct png_color_8_struct -{ - png_byte red; /* for use in red green blue files */ - png_byte green; - png_byte blue; - png_byte gray; /* for use in grayscale files */ - png_byte alpha; /* for alpha channel files */ -} png_color_8; -typedef png_color_8 * png_color_8p; -typedef const png_color_8 * png_const_color_8p; -typedef png_color_8 * * png_color_8pp; - -/* - * The following two structures are used for the in-core representation - * of sPLT chunks. - */ -typedef struct png_sPLT_entry_struct -{ - png_uint_16 red; - png_uint_16 green; - png_uint_16 blue; - png_uint_16 alpha; - png_uint_16 frequency; -} png_sPLT_entry; -typedef png_sPLT_entry * png_sPLT_entryp; -typedef const png_sPLT_entry * png_const_sPLT_entryp; -typedef png_sPLT_entry * * png_sPLT_entrypp; - -/* When the depth of the sPLT palette is 8 bits, the color and alpha samples - * occupy the LSB of their respective members, and the MSB of each member - * is zero-filled. The frequency member always occupies the full 16 bits. - */ - -typedef struct png_sPLT_struct -{ - png_charp name; /* palette name */ - png_byte depth; /* depth of palette samples */ - png_sPLT_entryp entries; /* palette entries */ - png_int_32 nentries; /* number of palette entries */ -} png_sPLT_t; -typedef png_sPLT_t * png_sPLT_tp; -typedef const png_sPLT_t * png_const_sPLT_tp; -typedef png_sPLT_t * * png_sPLT_tpp; - -#ifdef PNG_TEXT_SUPPORTED -/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, - * and whether that contents is compressed or not. The "key" field - * points to a regular zero-terminated C string. The "text" fields can be a - * regular C string, an empty string, or a NULL pointer. - * However, the structure returned by png_get_text() will always contain - * the "text" field as a regular zero-terminated C string (possibly - * empty), never a NULL pointer, so it can be safely used in printf() and - * other string-handling functions. Note that the "itxt_length", "lang", and - * "lang_key" members of the structure only exist when the library is built - * with iTXt chunk support. Prior to libpng-1.4.0 the library was built by - * default without iTXt support. Also note that when iTXt *is* supported, - * the "lang" and "lang_key" fields contain NULL pointers when the - * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or - * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the - * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag" - * which is always 0 or 1, or its "compression method" which is always 0. - */ -typedef struct png_text_struct -{ - int compression; /* compression value: - -1: tEXt, none - 0: zTXt, deflate - 1: iTXt, none - 2: iTXt, deflate */ - png_charp key; /* keyword, 1-79 character description of "text" */ - png_charp text; /* comment, may be an empty string (ie "") - or a NULL pointer */ - png_size_t text_length; /* length of the text string */ - png_size_t itxt_length; /* length of the itxt string */ - png_charp lang; /* language code, 0-79 characters - or a NULL pointer */ - png_charp lang_key; /* keyword translated UTF-8 string, 0 or more - chars or a NULL pointer */ -} png_text; -typedef png_text * png_textp; -typedef const png_text * png_const_textp; -typedef png_text * * png_textpp; -#endif - -/* Supported compression types for text in PNG files (tEXt, and zTXt). - * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ -#define PNG_TEXT_COMPRESSION_NONE_WR -3 -#define PNG_TEXT_COMPRESSION_zTXt_WR -2 -#define PNG_TEXT_COMPRESSION_NONE -1 -#define PNG_TEXT_COMPRESSION_zTXt 0 -#define PNG_ITXT_COMPRESSION_NONE 1 -#define PNG_ITXT_COMPRESSION_zTXt 2 -#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ - -/* png_time is a way to hold the time in an machine independent way. - * Two conversions are provided, both from time_t and struct tm. There - * is no portable way to convert to either of these structures, as far - * as I know. If you know of a portable way, send it to me. As a side - * note - PNG has always been Year 2000 compliant! - */ -typedef struct png_time_struct -{ - png_uint_16 year; /* full year, as in, 1995 */ - png_byte month; /* month of year, 1 - 12 */ - png_byte day; /* day of month, 1 - 31 */ - png_byte hour; /* hour of day, 0 - 23 */ - png_byte minute; /* minute of hour, 0 - 59 */ - png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ -} png_time; -typedef png_time * png_timep; -typedef const png_time * png_const_timep; -typedef png_time * * png_timepp; - -#if defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED) ||\ - defined(PNG_USER_CHUNKS_SUPPORTED) -/* png_unknown_chunk is a structure to hold queued chunks for which there is - * no specific support. The idea is that we can use this to queue - * up private chunks for output even though the library doesn't actually - * know about their semantics. - * - * The data in the structure is set by libpng on read and used on write. - */ -typedef struct png_unknown_chunk_t -{ - png_byte name[5]; /* Textual chunk name with '\0' terminator */ - png_byte *data; /* Data, should not be modified on read! */ - png_size_t size; - - /* On write 'location' must be set using the flag values listed below. - * Notice that on read it is set by libpng however the values stored have - * more bits set than are listed below. Always treat the value as a - * bitmask. On write set only one bit - setting multiple bits may cause the - * chunk to be written in multiple places. - */ - png_byte location; /* mode of operation at read time */ -} -png_unknown_chunk; - -typedef png_unknown_chunk * png_unknown_chunkp; -typedef const png_unknown_chunk * png_const_unknown_chunkp; -typedef png_unknown_chunk * * png_unknown_chunkpp; -#endif - -/* Flag values for the unknown chunk location byte. */ -#define PNG_HAVE_IHDR 0x01 -#define PNG_HAVE_PLTE 0x02 -#define PNG_AFTER_IDAT 0x08 - -/* Maximum positive integer used in PNG is (2^31)-1 */ -#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) -#define PNG_UINT_32_MAX ((png_uint_32)(-1)) -#define PNG_SIZE_MAX ((png_size_t)(-1)) - -/* These are constants for fixed point values encoded in the - * PNG specification manner (x100000) - */ -#define PNG_FP_1 100000 -#define PNG_FP_HALF 50000 -#define PNG_FP_MAX ((png_fixed_point)0x7fffffffL) -#define PNG_FP_MIN (-PNG_FP_MAX) - -/* These describe the color_type field in png_info. */ -/* color type masks */ -#define PNG_COLOR_MASK_PALETTE 1 -#define PNG_COLOR_MASK_COLOR 2 -#define PNG_COLOR_MASK_ALPHA 4 - -/* color types. Note that not all combinations are legal */ -#define PNG_COLOR_TYPE_GRAY 0 -#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) -#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) -#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) -#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) -/* aliases */ -#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA -#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA - -/* This is for compression type. PNG 1.0-1.2 only define the single type. */ -#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ -#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE - -/* This is for filter type. PNG 1.0-1.2 only define the single type. */ -#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ -#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ -#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE - -/* These are for the interlacing type. These values should NOT be changed. */ -#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ -#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ -#define PNG_INTERLACE_LAST 2 /* Not a valid value */ - -/* These are for the oFFs chunk. These values should NOT be changed. */ -#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ -#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ -#define PNG_OFFSET_LAST 2 /* Not a valid value */ - -/* These are for the pCAL chunk. These values should NOT be changed. */ -#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ -#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ -#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ -#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ -#define PNG_EQUATION_LAST 4 /* Not a valid value */ - -/* These are for the sCAL chunk. These values should NOT be changed. */ -#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ -#define PNG_SCALE_METER 1 /* meters per pixel */ -#define PNG_SCALE_RADIAN 2 /* radians per pixel */ -#define PNG_SCALE_LAST 3 /* Not a valid value */ - -/* These are for the pHYs chunk. These values should NOT be changed. */ -#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ -#define PNG_RESOLUTION_METER 1 /* pixels/meter */ -#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ - -/* These are for the sRGB chunk. These values should NOT be changed. */ -#define PNG_sRGB_INTENT_PERCEPTUAL 0 -#define PNG_sRGB_INTENT_RELATIVE 1 -#define PNG_sRGB_INTENT_SATURATION 2 -#define PNG_sRGB_INTENT_ABSOLUTE 3 -#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ - -/* This is for text chunks */ -#define PNG_KEYWORD_MAX_LENGTH 79 - -/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ -#define PNG_MAX_PALETTE_LENGTH 256 - -/* These determine if an ancillary chunk's data has been successfully read - * from the PNG header, or if the application has filled in the corresponding - * data in the info_struct to be written into the output file. The values - * of the PNG_INFO_<chunk> defines should NOT be changed. - */ -#define PNG_INFO_gAMA 0x0001 -#define PNG_INFO_sBIT 0x0002 -#define PNG_INFO_cHRM 0x0004 -#define PNG_INFO_PLTE 0x0008 -#define PNG_INFO_tRNS 0x0010 -#define PNG_INFO_bKGD 0x0020 -#define PNG_INFO_hIST 0x0040 -#define PNG_INFO_pHYs 0x0080 -#define PNG_INFO_oFFs 0x0100 -#define PNG_INFO_tIME 0x0200 -#define PNG_INFO_pCAL 0x0400 -#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ -#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ -#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ -#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ -#if INT_MAX >= 0x8000 /* else this might break */ -#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */ -#endif - -/* This is used for the transformation routines, as some of them - * change these values for the row. It also should enable using - * the routines for other purposes. - */ -typedef struct png_row_info_struct -{ - png_uint_32 width; /* width of row */ - png_size_t rowbytes; /* number of bytes in row */ - png_byte color_type; /* color type of row */ - png_byte bit_depth; /* bit depth of row */ - png_byte channels; /* number of channels (1, 2, 3, or 4) */ - png_byte pixel_depth; /* bits per pixel (depth * channels) */ -} png_row_info; - -typedef png_row_info * png_row_infop; -typedef png_row_info * * png_row_infopp; - -/* These are the function types for the I/O functions and for the functions - * that allow the user to override the default I/O functions with his or her - * own. The png_error_ptr type should match that of user-supplied warning - * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. Note that the 'write' function must not - * modify the buffer it is passed. The 'read' function, on the other hand, is - * expected to return the read data in the buffer. - */ -typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); -typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t)); -typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); -typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, - int)); -typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, - int)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); -typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); - -/* The following callback receives png_uint_32 row_number, int pass for the - * png_bytep data of the row. When transforming an interlaced image the - * row number is the row number within the sub-image of the interlace pass, so - * the value will increase to the height of the sub-image (not the full image) - * then reset to 0 for the next pass. - * - * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to - * find the output pixel (x,y) given an interlaced sub-image pixel - * (row,col,pass). (See below for these macros.) - */ -typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, - png_uint_32, int)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, - png_bytep)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, - png_unknown_chunkp)); -#endif -#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED -/* not used anywhere */ -/* typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); */ -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This must match the function definition in <setjmp.h>, and the application - * must include this before png.h to obtain the definition of jmp_buf. The - * function is required to be PNG_NORETURN, but this is not checked. If the - * function does return the application will crash via an abort() or similar - * system level call. - * - * If you get a warning here while building the library you may need to make - * changes to ensure that pnglibconf.h records the calling convention used by - * your compiler. This may be very difficult - try using a different compiler - * to build the library! - */ -PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); -#endif - -/* Transform masks for the high-level interface */ -#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ -#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ -#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ -#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ -#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ -#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ -#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ -#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ -#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ -#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ -#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ -#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ -/* Added to libpng-1.2.34 */ -#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER -#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ -/* Added to libpng-1.4.0 */ -#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ -/* Added to libpng-1.5.4 */ -#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ -#if INT_MAX >= 0x8000 /* else this might break */ -#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ -#endif - -/* Flags for MNG supported features */ -#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 -#define PNG_FLAG_MNG_FILTER_64 0x04 -#define PNG_ALL_MNG_FEATURES 0x05 - -/* NOTE: prior to 1.5 these functions had no 'API' style declaration, - * this allowed the zlib default functions to be used on Windows - * platforms. In 1.5 the zlib default malloc (which just calls malloc and - * ignores the first argument) should be completely compatible with the - * following. - */ -typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, - png_alloc_size_t)); -typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); - -/* Section 4: exported functions - * Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng-manual.txt for the - * full explanation, see example.c for the summary. This just provides - * a simple one line description of the use of each function. - * - * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in - * pngconf.h and in the *.dfn files in the scripts directory. - * - * PNG_EXPORT(ordinal, type, name, (args)); - * - * ordinal: ordinal that is used while building - * *.def files. The ordinal value is only - * relevant when preprocessing png.h with - * the *.dfn files for building symbol table - * entries, and are removed by pngconf.h. - * type: return type of the function - * name: function name - * args: function arguments, with types - * - * When we wish to append attributes to a function prototype we use - * the PNG_EXPORTA() macro instead. - * - * PNG_EXPORTA(ordinal, type, name, (args), attributes); - * - * ordinal, type, name, and args: same as in PNG_EXPORT(). - * attributes: function attributes - */ - -/* Returns the version number of the library */ -PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); - -/* Tell lib we have already handled the first <num_bytes> magic bytes. - * Handling more than 8 bytes from the beginning of the file is an error. - */ -PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes)); - -/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a - * PNG file. Returns zero if the supplied bytes match the 8-byte PNG - * signature, and non-zero otherwise. Having num_to_check == 0 or - * start > 7 will always fail (ie return non-zero). - */ -PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start, - png_size_t num_to_check)); - -/* Simple signature checking function. This is the same as calling - * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). - */ -#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) - -/* Allocate and initialize png_ptr struct for reading, and any other memory. */ -PNG_EXPORTA(4, png_structp, png_create_read_struct, - (png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn), - PNG_ALLOCATED); - -/* Allocate and initialize png_ptr struct for writing, and any other memory */ -PNG_EXPORTA(5, png_structp, png_create_write_struct, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn), - PNG_ALLOCATED); - -PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size, - (png_const_structrp png_ptr)); - -PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr, - png_size_t size)); - -/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp - * match up. - */ -#ifdef PNG_SETJMP_SUPPORTED -/* This function returns the jmp_buf built in to *png_ptr. It must be - * supplied with an appropriate 'longjmp' function to use on that jmp_buf - * unless the default error function is overridden in which case NULL is - * acceptable. The size of the jmp_buf is checked against the actual size - * allocated by the library - the call will return NULL on a mismatch - * indicating an ABI mismatch. - */ -PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr, - png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); -# define png_jmpbuf(png_ptr) \ - (*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf)))) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) -#endif -/* This function should be used by libpng applications in place of - * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it - * will use it; otherwise it will call PNG_ABORT(). This function was - * added in libpng-1.5.0. - */ -PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val), - PNG_NORETURN); - -#ifdef PNG_READ_SUPPORTED -/* Reset the compression stream */ -PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED); -#endif - -/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ -#ifdef PNG_USER_MEM_SUPPORTED -PNG_EXPORTA(11, png_structp, png_create_read_struct_2, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), - PNG_ALLOCATED); -PNG_EXPORTA(12, png_structp, png_create_write_struct_2, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), - PNG_ALLOCATED); -#endif - -/* Write the PNG file signature. */ -PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr)); - -/* Write a PNG chunk - size, type, (optional) data, CRC. */ -PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep - chunk_name, png_const_bytep data, png_size_t length)); - -/* Write the start of a PNG chunk - length and chunk name. */ -PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr, - png_const_bytep chunk_name, png_uint_32 length)); - -/* Write the data of a PNG chunk started with png_write_chunk_start(). */ -PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr, - png_const_bytep data, png_size_t length)); - -/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr)); - -/* Allocate and initialize the info structure */ -PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr), - PNG_ALLOCATED); - -/* DEPRECATED: this function allowed init structures to be created using the - * default allocation method (typically malloc). Use is deprecated in 1.6.0 and - * the API will be removed in the future. - */ -PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr, - png_size_t png_info_struct_size), PNG_DEPRECATED); - -/* Writes all the PNG information before the image. */ -PNG_EXPORT(20, void, png_write_info_before_PLTE, - (png_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(21, void, png_write_info, - (png_structrp png_ptr, png_const_inforp info_ptr)); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the information before the actual image data. */ -PNG_EXPORT(22, void, png_read_info, - (png_structrp png_ptr, png_inforp info_ptr)); -#endif - -#ifdef PNG_TIME_RFC1123_SUPPORTED - /* Convert to a US string format: there is no localization support in this - * routine. The original implementation used a 29 character buffer in - * png_struct, this will be removed in future versions. - */ -#if PNG_LIBPNG_VER < 10700 -/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */ -PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr, - png_const_timep ptime),PNG_DEPRECATED); -#endif -PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29], - png_const_timep ptime)); -#endif - -#ifdef PNG_CONVERT_tIME_SUPPORTED -/* Convert from a struct tm to png_time */ -PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, - const struct tm * ttime)); - -/* Convert from time_t to png_time. Uses gmtime() */ -PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime)); -#endif /* CONVERT_tIME */ - -#ifdef PNG_READ_EXPAND_SUPPORTED -/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr)); -PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr)); -PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr)); -PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_EXPAND_16_SUPPORTED -/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion - * of a tRNS chunk if present. - */ -PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Use blue, green, red order for pixels. */ -PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -/* Expand the grayscale to 24-bit RGB if necessary. */ -PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -/* Reduce RGB to grayscale. */ -#define PNG_ERROR_ACTION_NONE 1 -#define PNG_ERROR_ACTION_WARN 2 -#define PNG_ERROR_ACTION_ERROR 3 -#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ - -PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr, - int error_action, double red, double green)) -PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green)) - -PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp - png_ptr)); -#endif - -#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED -PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, - png_colorp palette)); -#endif - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED -/* How the alpha channel is interpreted - this affects how the color channels - * of a PNG file are returned to the calling application when an alpha channel, - * or a tRNS chunk in a palette file, is present. - * - * This has no effect on the way pixels are written into a PNG output - * datastream. The color samples in a PNG datastream are never premultiplied - * with the alpha samples. - * - * The default is to return data according to the PNG specification: the alpha - * channel is a linear measure of the contribution of the pixel to the - * corresponding composited pixel, and the color channels are unassociated - * (not premultiplied). The gamma encoded color channels must be scaled - * according to the contribution and to do this it is necessary to undo - * the encoding, scale the color values, perform the composition and reencode - * the values. This is the 'PNG' mode. - * - * The alternative is to 'associate' the alpha with the color information by - * storing color channel values that have been scaled by the alpha. - * image. These are the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' modes - * (the latter being the two common names for associated alpha color channels). - * - * For the 'OPTIMIZED' mode, a pixel is treated as opaque only if the alpha - * value is equal to the maximum value. - * - * The final choice is to gamma encode the alpha channel as well. This is - * broken because, in practice, no implementation that uses this choice - * correctly undoes the encoding before handling alpha composition. Use this - * choice only if other serious errors in the software or hardware you use - * mandate it; the typical serious error is for dark halos to appear around - * opaque areas of the composited PNG image because of arithmetic overflow. - * - * The API function png_set_alpha_mode specifies which of these choices to use - * with an enumerated 'mode' value and the gamma of the required output: - */ -#define PNG_ALPHA_PNG 0 /* according to the PNG standard */ -#define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ -#define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ -#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ -#define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ -#define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ - -PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode, - double output_gamma)) -PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr, - int mode, png_fixed_point output_gamma)) -#endif - -#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) -/* The output_gamma value is a screen gamma in libpng terminology: it expresses - * how to decode the output values, not how they are encoded. - */ -#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ -#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ -#define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ -#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ -#endif - -/* The following are examples of calls to png_set_alpha_mode to achieve the - * required overall gamma correction and, where necessary, alpha - * premultiplication. - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); - * This is the default libpng handling of the alpha channel - it is not - * pre-multiplied into the color components. In addition the call states - * that the output is for a sRGB system and causes all PNG files without gAMA - * chunks to be assumed to be encoded using sRGB. - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); - * In this case the output is assumed to be something like an sRGB conformant - * display preceeded by a power-law lookup table of power 1.45. This is how - * early Mac systems behaved. - * - * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); - * This is the classic Jim Blinn approach and will work in academic - * environments where everything is done by the book. It has the shortcoming - * of assuming that input PNG data with no gamma information is linear - this - * is unlikely to be correct unless the PNG files where generated locally. - * Most of the time the output precision will be so low as to show - * significant banding in dark areas of the image. - * - * png_set_expand_16(pp); - * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); - * This is a somewhat more realistic Jim Blinn inspired approach. PNG files - * are assumed to have the sRGB encoding if not marked with a gamma value and - * the output is always 16 bits per component. This permits accurate scaling - * and processing of the data. If you know that your input PNG files were - * generated locally you might need to replace PNG_DEFAULT_sRGB with the - * correct value for your system. - * - * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); - * If you just need to composite the PNG image onto an existing background - * and if you control the code that does this you can use the optimization - * setting. In this case you just copy completely opaque pixels to the - * output. For pixels that are not completely transparent (you just skip - * those) you do the composition math using png_composite or png_composite_16 - * below then encode the resultant 8-bit or 16-bit values to match the output - * encoding. - * - * Other cases - * If neither the PNG nor the standard linear encoding work for you because - * of the software or hardware you use then you have a big problem. The PNG - * case will probably result in halos around the image. The linear encoding - * will probably result in a washed out, too bright, image (it's actually too - * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably - * substantially reduce the halos. Alternatively try: - * - * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); - * This option will also reduce the halos, but there will be slight dark - * halos round the opaque parts of the image where the background is light. - * In the OPTIMIZED mode the halos will be light halos where the background - * is dark. Take your pick - the halos are unavoidable unless you can get - * your hardware/software fixed! (The OPTIMIZED approach is slightly - * faster.) - * - * When the default gamma of PNG files doesn't match the output gamma. - * If you have PNG files with no gamma information png_set_alpha_mode allows - * you to provide a default gamma, but it also sets the ouput gamma to the - * matching value. If you know your PNG files have a gamma that doesn't - * match the output you can take advantage of the fact that - * png_set_alpha_mode always sets the output gamma but only sets the PNG - * default if it is not already set: - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); - * The first call sets both the default and the output gamma values, the - * second call overrides the output gamma without changing the default. This - * is easier than achieving the same effect with png_set_gamma. You must use - * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will - * fire if more than one call to png_set_alpha_mode and png_set_background is - * made in the same read operation, however multiple calls with PNG_ALPHA_PNG - * are ignored. - */ - -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED -PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */ -PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler, - int flags)); -/* The values of the PNG_FILLER_ defines should NOT be changed */ -# define PNG_FILLER_BEFORE 0 -# define PNG_FILLER_AFTER 1 -/* Add an alpha byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */ -PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr, - png_uint_32 filler, int flags)); -#endif /* READ_FILLER || WRITE_FILLER */ - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swap bytes in 16-bit depth files. */ -PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ - defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Swap packing order of pixels in bytes. */ -PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Converts files to legal bit depths. */ -PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p - true_bits)); -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. - * MUST be called before png_read_update_info or png_start_read_image, - * otherwise it will not have the desired effect. Note that it is still - * necessary to call png_read_row or png_read_rows png_get_image_height - * times for each pass. -*/ -PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -/* Invert monochrome files */ -PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_BACKGROUND_SUPPORTED -/* Handle alpha and tRNS by replacing with a background color. Prior to - * libpng-1.5.4 this API must not be called before the PNG file header has been - * read. Doing so will result in unexpected behavior and possible warnings or - * errors if the PNG file contains a bKGD chunk. - */ -PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)) -PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, png_fixed_point background_gamma)) -#endif -#ifdef PNG_READ_BACKGROUND_SUPPORTED -# define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -# define PNG_BACKGROUND_GAMMA_SCREEN 1 -# define PNG_BACKGROUND_GAMMA_FILE 2 -# define PNG_BACKGROUND_GAMMA_UNIQUE 3 -#endif - -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED -/* Scale a 16-bit depth file down to 8-bit, accurately. */ -PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED -#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */ -/* Strip the second byte of information from a 16-bit depth file. */ -PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr)); -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -/* Turn on quantizing, and reduce the palette to the number of colors - * available. - */ -PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr, - png_colorp palette, int num_palette, int maximum_colors, - png_const_uint_16p histogram, int full_quantize)); -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED -/* The threshold on gamma processing is configurable but hard-wired into the - * library. The following is the floating point variant. - */ -#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) - -/* Handle gamma correction. Screen_gamma=(display_exponent). - * NOTE: this API simply sets the screen and file gamma values. It will - * therefore override the value for gamma in a PNG file if it is called after - * the file header has been read - use with care - call before reading the PNG - * file for best results! - * - * These routines accept the same gamma values as png_set_alpha_mode (described - * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either - * API (floating point or fixed.) Notice, however, that the 'file_gamma' value - * is the inverse of a 'screen gamma' value. - */ -PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr, - double screen_gamma, double override_file_gamma)) -PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr, - png_fixed_point screen_gamma, png_fixed_point override_file_gamma)) -#endif - -#ifdef PNG_WRITE_FLUSH_SUPPORTED -/* Set how many lines between output flushes - 0 for no flushing */ -PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows)); -/* Flush the current PNG output buffer */ -PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr)); -#endif - -/* Optional update palette with requested transformations */ -PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr)); - -/* Optional call to update the users info structure */ -PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr, - png_inforp info_ptr)); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read one or more rows of image data. */ -PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows)); -#endif - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read a row of data. */ -PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row, - png_bytep display_row)); -#endif - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the whole image into memory at once. */ -PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image)); -#endif - -/* Write a row of image data */ -PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr, - png_const_bytep row)); - -/* Write a few rows of image data: (*row) is not written; however, the type - * is declared as writeable to maintain compatibility with previous versions - * of libpng and to allow the 'display_row' array from read_rows to be passed - * unchanged to write_rows. - */ -PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row, - png_uint_32 num_rows)); - -/* Write the image data */ -PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image)); - -/* Write the end of the PNG file. */ -PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr, - png_inforp info_ptr)); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the end of the PNG file. */ -PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr)); -#endif - -/* Free any memory associated with the png_info_struct */ -PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr, - png_infopp info_ptr_ptr)); - -/* Free any memory associated with the png_struct and the png_info_structs */ -PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, - png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); - -/* Free any memory associated with the png_struct and the png_info_structs */ -PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, - png_infopp info_ptr_ptr)); - -/* Set the libpng method of handling chunk CRC errors */ -PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action, - int ancil_action)); - -/* Values for png_set_crc_action() say how to handle CRC errors in - * ancillary and critical chunks, and whether to use the data contained - * therein. Note that it is impossible to "discard" data in a critical - * chunk. For versions prior to 0.90, the action was always error/quit, - * whereas in version 0.90 and later, the action for CRC errors in ancillary - * chunks is warn/discard. These values should NOT be changed. - * - * value action:critical action:ancillary - */ -#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ -#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ -#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ -#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ -#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ -#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ - -#ifdef PNG_WRITE_SUPPORTED -/* These functions give the user control over the scan-line filtering in - * libpng and the compression methods used by zlib. These functions are - * mainly useful for testing, as the defaults should work with most users. - * Those users who are tight on memory or want faster performance at the - * expense of compression can modify them. See the compression library - * header file (zlib.h) for an explination of the compression functions. - */ - -/* Set the filtering method(s) used by libpng. Currently, the only valid - * value for "method" is 0. - */ -PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method, - int filters)); -#endif /* WRITE */ - -/* Flags for png_set_filter() to say which filters to use. The flags - * are chosen so that they don't conflict with real filter types - * below, in case they are supplied instead of the #defined constants. - * These values should NOT be changed. - */ -#define PNG_NO_FILTERS 0x00 -#define PNG_FILTER_NONE 0x08 -#define PNG_FILTER_SUB 0x10 -#define PNG_FILTER_UP 0x20 -#define PNG_FILTER_AVG 0x40 -#define PNG_FILTER_PAETH 0x80 -#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ - PNG_FILTER_AVG | PNG_FILTER_PAETH) - -/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. - * These defines should NOT be changed. - */ -#define PNG_FILTER_VALUE_NONE 0 -#define PNG_FILTER_VALUE_SUB 1 -#define PNG_FILTER_VALUE_UP 2 -#define PNG_FILTER_VALUE_AVG 3 -#define PNG_FILTER_VALUE_PAETH 4 -#define PNG_FILTER_VALUE_LAST 5 - -#ifdef PNG_WRITE_SUPPORTED -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */ -PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr, - int heuristic_method, int num_weights, png_const_doublep filter_weights, - png_const_doublep filter_costs)) -PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, - (png_structrp png_ptr, int heuristic_method, int num_weights, - png_const_fixed_point_p filter_weights, - png_const_fixed_point_p filter_costs)) -#endif /* WRITE_WEIGHTED_FILTER */ - -/* The following are no longer used and will be removed from libpng-1.7: */ -#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ -#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ -#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ -#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ - -/* Set the library compression level. Currently, valid values range from - * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 - * (0 - no compression, 9 - "maximal" compression). Note that tests have - * shown that zlib compression levels 3-6 usually perform as well as level 9 - * for PNG images, and do considerably fewer caclulations. In the future, - * these values may not correspond directly to the zlib compression levels. - */ -#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED -PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr, - int level)); - -PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr, - int mem_level)); - -PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr, - int strategy)); - -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr, - int window_bits)); - -PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr, - int method)); -#endif /* WRITE_CUSTOMIZE_COMPRESSION */ - -#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED -/* Also set zlib parameters for compressing non-IDAT chunks */ -PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr, - int level)); - -PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr, - int mem_level)); - -PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr, - int strategy)); - -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -PNG_EXPORT(225, void, png_set_text_compression_window_bits, - (png_structrp png_ptr, int window_bits)); - -PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr, - int method)); -#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */ -#endif /* WRITE */ - -/* These next functions are called for input/output, memory, and error - * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, - * and call standard C I/O routines such as fread(), fwrite(), and - * fprintf(). These functions can be made to use other I/O routines - * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng-manual.txt for - * more information. - */ - -#ifdef PNG_STDIO_SUPPORTED -/* Initialize the input/output for the PNG file to the default functions. */ -PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp)); -#endif - -/* Replace the (error and abort), and warning functions with user - * supplied functions. If no messages are to be printed you must still - * write and use replacement functions. The replacement error_fn should - * still do a longjmp to the last setjmp location if you are using this - * method of error handling. If error_fn or warning_fn is NULL, the - * default function will be used. - */ - -PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr, - png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn)); - -/* Return the user pointer associated with the error functions */ -PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr)); - -/* Replace the default data output functions with a user supplied one(s). - * If buffered output is not used, then output_flush_fn can be set to NULL. - * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time - * output_flush_fn will be ignored (and thus can be NULL). - * It is probably a mistake to use NULL for output_flush_fn if - * write_data_fn is not also NULL unless you have built libpng with - * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's - * default flush function, which uses the standard *FILE structure, will - * be used. - */ -PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); - -/* Replace the default data input function with a user supplied one. */ -PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn)); - -/* Return the user pointer associated with the I/O functions */ -PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr)); - -PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr, - png_read_status_ptr read_row_fn)); - -PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr, - png_write_status_ptr write_row_fn)); - -#ifdef PNG_USER_MEM_SUPPORTED -/* Replace the default memory allocation functions with user supplied one(s). */ -PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -/* Return the user pointer associated with the memory functions */ -PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr)); -#endif - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED -PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr, - png_user_transform_ptr read_user_transform_fn)); -#endif - -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED -PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr, - png_user_transform_ptr write_user_transform_fn)); -#endif - -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED -PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr, - png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); -/* Return the user pointer associated with the user transform functions */ -PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, - (png_const_structrp png_ptr)); -#endif - -#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED -/* Return information about the row currently being processed. Note that these - * APIs do not fail but will return unexpected results if called outside a user - * transform callback. Also note that when transforming an interlaced image the - * row number is the row number within the sub-image of the interlace pass, so - * the value will increase to the height of the sub-image (not the full image) - * then reset to 0 for the next pass. - * - * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to - * find the output pixel (x,y) given an interlaced sub-image pixel - * (row,col,pass). (See below for these macros.) - */ -PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp)); -PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp)); -#endif - -#ifdef PNG_READ_USER_CHUNKS_SUPPORTED -/* This callback is called only for *unknown* chunks. If - * PNG_HANDLE_AS_UNKNOWN_SUPPORTED is set then it is possible to set known - * chunks to be treated as unknown, however in this case the callback must do - * any processing required by the chunk (e.g. by calling the appropriate - * png_set_ APIs.) - * - * There is no write support - on write, by default, all the chunks in the - * 'unknown' list are written in the specified position. - * - * The integer return from the callback function is interpreted thus: - * - * negative: An error occurred; png_chunk_error will be called. - * zero: The chunk was not handled, the chunk will be saved. A critical - * chunk will cause an error at this point unless it is to be saved. - * positive: The chunk was handled, libpng will ignore/discard it. - * - * See "INTERACTION WTIH USER CHUNK CALLBACKS" below for important notes about - * how this behavior will change in libpng 1.7 - */ -PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr)); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* Sets the function callbacks for the push reader, and a pointer to a - * user-defined structure available to the callback functions. - */ -PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr, - png_voidp progressive_ptr, png_progressive_info_ptr info_fn, - png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); - -/* Returns the user pointer associated with the push read functions */ -PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, - (png_const_structrp png_ptr)); - -/* Function to be called when data becomes available */ -PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr, - png_inforp info_ptr, png_bytep buffer, png_size_t buffer_size)); - -/* A function which may be called *only* within png_process_data to stop the - * processing of any more data. The function returns the number of bytes - * remaining, excluding any that libpng has cached internally. A subsequent - * call to png_process_data must supply these bytes again. If the argument - * 'save' is set to true the routine will first save all the pending data and - * will always return 0. - */ -PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structrp, int save)); - -/* A function which may be called *only* outside (after) a call to - * png_process_data. It returns the number of bytes of data to skip in the - * input. Normally it will return 0, but if it returns a non-zero value the - * application must skip than number of bytes of input data and pass the - * following data to the next call to png_process_data. - */ -PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp)); - -/* Function that combines rows. 'new_row' is a flag that should come from - * the callback and be non-NULL if anything needs to be done; the library - * stores its own version of the new data internally and ignores the passed - * in value. - */ -PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr, - png_bytep old_row, png_const_bytep new_row)); -#endif /* PROGRESSIVE_READ */ - -PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); -/* Added at libpng version 1.4.0 */ -PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); - -/* Added at libpng version 1.2.4 */ -PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); - -/* Frees a pointer allocated by png_malloc() */ -PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr)); - -/* Free data that was allocated internally */ -PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 free_me, int num)); - -/* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application; this works on the png_info structure passed - * in, it does not change the state for other png_info structures. - * - * It is unlikely that this function works correctly as of 1.6.0 and using it - * may result either in memory leaks or double free of allocated data. - */ -PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr, - png_inforp info_ptr, int freer, png_uint_32 mask)); - -/* Assignments for png_data_freer */ -#define PNG_DESTROY_WILL_FREE_DATA 1 -#define PNG_SET_WILL_FREE_DATA 1 -#define PNG_USER_WILL_FREE_DATA 2 -/* Flags for png_ptr->free_me and info_ptr->free_me */ -#define PNG_FREE_HIST 0x0008 -#define PNG_FREE_ICCP 0x0010 -#define PNG_FREE_SPLT 0x0020 -#define PNG_FREE_ROWS 0x0040 -#define PNG_FREE_PCAL 0x0080 -#define PNG_FREE_SCAL 0x0100 -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -# define PNG_FREE_UNKN 0x0200 -#endif -/* PNG_FREE_LIST 0x0400 removed in 1.6.0 because it is ignored */ -#define PNG_FREE_PLTE 0x1000 -#define PNG_FREE_TRNS 0x2000 -#define PNG_FREE_TEXT 0x4000 -#define PNG_FREE_ALL 0x7fff -#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ - -#ifdef PNG_USER_MEM_SUPPORTED -PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED); -PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr, - png_voidp ptr), PNG_DEPRECATED); -#endif - -#ifdef PNG_ERROR_TEXT_SUPPORTED -/* Fatal error in PNG image of libpng - can't continue */ -PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr, - png_const_charp error_message), PNG_NORETURN); - -/* The same, but the chunk name is prepended to the error string. */ -PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr, - png_const_charp error_message), PNG_NORETURN); - -#else -/* Fatal error in PNG image of libpng - can't continue */ -PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN); -# define png_error(s1,s2) png_err(s1) -# define png_chunk_error(s1,s2) png_err(s1) -#endif - -#ifdef PNG_WARNINGS_SUPPORTED -/* Non-fatal error in libpng. Can continue, but may have a problem. */ -PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr, - png_const_charp warning_message)); - -/* Non-fatal error in libpng, chunk name is prepended to message. */ -PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr, - png_const_charp warning_message)); -#else -# define png_warning(s1,s2) ((void)(s1)) -# define png_chunk_warning(s1,s2) ((void)(s1)) -#endif - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -/* Benign error in libpng. Can continue, but may have a problem. - * User can choose whether to handle as a fatal error or as a warning. */ -PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr, - png_const_charp warning_message)); - -#ifdef PNG_READ_SUPPORTED -/* Same, chunk name is prepended to message (only during read) */ -PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr, - png_const_charp warning_message)); -#endif - -PNG_EXPORT(109, void, png_set_benign_errors, - (png_structrp png_ptr, int allowed)); -#else -# ifdef PNG_ALLOW_BENIGN_ERRORS -# define png_benign_error png_warning -# define png_chunk_benign_error png_chunk_warning -# else -# define png_benign_error png_error -# define png_chunk_benign_error png_chunk_error -# endif -#endif - -/* The png_set_<chunk> functions are for storing values in the png_info_struct. - * Similarly, the png_get_<chunk> calls are used to read values from the - * png_info_struct, either storing the parameters in the passed variables, or - * setting pointers into the png_info_struct where the data is stored. The - * png_get_<chunk> functions return a non-zero value if the data was available - * in info_ptr, or return zero and do not change any of the parameters if the - * data was not available. - * - * These functions should be used instead of directly accessing png_info - * to avoid problems with future changes in the size and internal layout of - * png_info_struct. - */ -/* Returns "flag" if chunk data is valid in info_ptr. */ -PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 flag)); - -/* Returns number of bytes needed to hold a transformed row. */ -PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -#ifdef PNG_INFO_IMAGE_SUPPORTED -/* Returns row_pointers, which is an array of pointers to scanlines that was - * returned from png_read_png(). - */ -PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Set row_pointers, which is an array of pointers to scanlines for use - * by png_write_png(). - */ -PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr, - png_inforp info_ptr, png_bytepp row_pointers)); -#endif - -/* Returns number of color channels in image. */ -PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* Returns image width in pixels. */ -PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image height in pixels. */ -PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image bit_depth. */ -PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image color_type. */ -PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image filter_type. */ -PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image interlace_type. */ -PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image compression_type. */ -PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); - -/* Returns image resolution in pixels per meter, from pHYs chunk data. */ -PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -/* Returns pixel aspect ratio, computed from pHYs chunk data. */ -PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) - -/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); -PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -#endif /* EASY_ACCESS */ - -#ifdef PNG_READ_SUPPORTED -/* Returns pointer to signature string read from PNG header */ -PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr, - png_const_inforp info_ptr)); -#endif - -#ifdef PNG_bKGD_SUPPORTED -PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr, - png_inforp info_ptr, png_color_16p *background)); -#endif - -#ifdef PNG_bKGD_SUPPORTED -PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_color_16p background)); -#endif - -#ifdef PNG_cHRM_SUPPORTED -PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structrp png_ptr, - png_const_inforp info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)) -PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr, - png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z, - double *green_X, double *green_Y, double *green_Z, double *blue_X, - double *blue_Y, double *blue_Z)) -PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_white_x, png_fixed_point *int_white_y, - png_fixed_point *int_red_x, png_fixed_point *int_red_y, - png_fixed_point *int_green_x, png_fixed_point *int_green_y, - png_fixed_point *int_blue_x, png_fixed_point *int_blue_y)) -PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_red_X, png_fixed_point *int_red_Y, - png_fixed_point *int_red_Z, png_fixed_point *int_green_X, - png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, - png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, - png_fixed_point *int_blue_Z)) -#endif - -#ifdef PNG_cHRM_SUPPORTED -PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr, - png_inforp info_ptr, - double white_x, double white_y, double red_x, double red_y, double green_x, - double green_y, double blue_x, double blue_y)) -PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr, - png_inforp info_ptr, double red_X, double red_Y, double red_Z, - double green_X, double green_Y, double green_Z, double blue_X, - double blue_Y, double blue_Z)) -PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, png_fixed_point int_white_x, - png_fixed_point int_white_y, png_fixed_point int_red_x, - png_fixed_point int_red_y, png_fixed_point int_green_x, - png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)) -PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, - png_fixed_point int_red_Z, png_fixed_point int_green_X, - png_fixed_point int_green_Y, png_fixed_point int_green_Z, - png_fixed_point int_blue_X, png_fixed_point int_blue_Y, - png_fixed_point int_blue_Z)) -#endif - -#ifdef PNG_gAMA_SUPPORTED -PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr, - png_const_inforp info_ptr, double *file_gamma)) -PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, - png_fixed_point *int_file_gamma)) -#endif - -#ifdef PNG_gAMA_SUPPORTED -PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr, - png_inforp info_ptr, double file_gamma)) -PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, png_fixed_point int_file_gamma)) -#endif - -#ifdef PNG_hIST_SUPPORTED -PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_16p *hist)); -#endif - -#ifdef PNG_hIST_SUPPORTED -PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_uint_16p hist)); -#endif - -PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height, - int *bit_depth, int *color_type, int *interlace_method, - int *compression_method, int *filter_method)); - -PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth, - int color_type, int interlace_method, int compression_method, - int filter_method)); - -#ifdef PNG_oFFs_SUPPORTED -PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y, - int *unit_type)); -#endif - -#ifdef PNG_oFFs_SUPPORTED -PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr, - png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y, - int unit_type)); -#endif - -#ifdef PNG_pCAL_SUPPORTED -PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr, - png_inforp info_ptr, png_charp *purpose, png_int_32 *X0, - png_int_32 *X1, int *type, int *nparams, png_charp *units, - png_charpp *params)); -#endif - -#ifdef PNG_pCAL_SUPPORTED -PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1, - int type, int nparams, png_const_charp units, png_charpp params)); -#endif - -#ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, - int *unit_type)); -#endif - -#ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr, - png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type)); -#endif - -PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr, - png_inforp info_ptr, png_colorp *palette, int *num_palette)); - -PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr, - png_inforp info_ptr, png_const_colorp palette, int num_palette)); - -#ifdef PNG_sBIT_SUPPORTED -PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_color_8p *sig_bit)); -#endif - -#ifdef PNG_sBIT_SUPPORTED -PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_color_8p sig_bit)); -#endif - -#ifdef PNG_sRGB_SUPPORTED -PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr, - png_const_inforp info_ptr, int *file_srgb_intent)); -#endif - -#ifdef PNG_sRGB_SUPPORTED -PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr, - png_inforp info_ptr, int srgb_intent)); -PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr, - png_inforp info_ptr, int srgb_intent)); -#endif - -#ifdef PNG_iCCP_SUPPORTED -PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr, - png_inforp info_ptr, png_charpp name, int *compression_type, - png_bytepp profile, png_uint_32 *proflen)); -#endif - -#ifdef PNG_iCCP_SUPPORTED -PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_charp name, int compression_type, - png_const_bytep profile, png_uint_32 proflen)); -#endif - -#ifdef PNG_sPLT_SUPPORTED -PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_sPLT_tpp entries)); -#endif - -#ifdef PNG_sPLT_SUPPORTED -PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_sPLT_tp entries, int nentries)); -#endif - -#ifdef PNG_TEXT_SUPPORTED -/* png_get_text also returns the number of text chunks in *num_text */ -PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr, - png_inforp info_ptr, png_textp *text_ptr, int *num_text)); -#endif - -/* Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. - */ - -#ifdef PNG_TEXT_SUPPORTED -PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_textp text_ptr, int num_text)); -#endif - -#ifdef PNG_tIME_SUPPORTED -PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr, - png_inforp info_ptr, png_timep *mod_time)); -#endif - -#ifdef PNG_tIME_SUPPORTED -PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_timep mod_time)); -#endif - -#ifdef PNG_tRNS_SUPPORTED -PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr, - png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans, - png_color_16p *trans_color)); -#endif - -#ifdef PNG_tRNS_SUPPORTED -PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr, - png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans, - png_const_color_16p trans_color)); -#endif - -#ifdef PNG_sCAL_SUPPORTED -PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr, - png_const_inforp info_ptr, int *unit, double *width, double *height)) -#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \ - defined(PNG_FLOATING_POINT_SUPPORTED) -/* NOTE: this API is currently implemented using floating point arithmetic, - * consequently it can only be used on systems with floating point support. - * In any case the range of values supported by png_fixed_point is small and it - * is highly recommended that png_get_sCAL_s be used instead. - */ -PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, - png_fixed_point *width, png_fixed_point *height)) -#endif -PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, - (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit, - png_charpp swidth, png_charpp sheight)); - -PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr, - png_inforp info_ptr, int unit, double width, double height)) -PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr, - png_inforp info_ptr, int unit, png_fixed_point width, - png_fixed_point height)) -PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr, - png_inforp info_ptr, int unit, - png_const_charp swidth, png_const_charp sheight)); -#endif /* sCAL */ - -#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED -/* Provide the default handling for all unknown chunks or, optionally, for - * specific unknown chunks. - * - * NOTE: prior to 1.6.0 the handling specified for particular chunks on read was - * ignored and the default was used, the per-chunk setting only had an effect on - * write. If you wish to have chunk-specific handling on read in code that must - * work on earlier versions you must use a user chunk callback to specify the - * desired handling (keep or discard.) - * - * The 'keep' parameter is a PNG_HANDLE_CHUNK_ value as listed below. The - * parameter is interpreted as follows: - * - * READ: - * PNG_HANDLE_CHUNK_AS_DEFAULT: - * Known chunks: do normal libpng processing, do not keep the chunk (but - * see the comments below about PNG_HANDLE_AS_UNKNOWN_SUPPORTED) - * Unknown chunks: for a specific chunk use the global default, when used - * as the default discard the chunk data. - * PNG_HANDLE_CHUNK_NEVER: - * Discard the chunk data. - * PNG_HANDLE_CHUNK_IF_SAFE: - * Keep the chunk data if the chunk is not critical else raise a chunk - * error. - * PNG_HANDLE_CHUNK_ALWAYS: - * Keep the chunk data. - * - * If the chunk data is saved it can be retrieved using png_get_unknown_chunks, - * below. Notice that specifying "AS_DEFAULT" as a global default is equivalent - * to specifying "NEVER", however when "AS_DEFAULT" is used for specific chunks - * it simply resets the behavior to the libpng default. - * - * INTERACTION WTIH USER CHUNK CALLBACKS: - * The per-chunk handling is always used when there is a png_user_chunk_ptr - * callback and the callback returns 0; the chunk is then always stored *unless* - * it is critical and the per-chunk setting is other than ALWAYS. Notice that - * the global default is *not* used in this case. (In effect the per-chunk - * value is incremented to at least IF_SAFE.) - * - * IMPORTANT NOTE: this behavior will change in libpng 1.7 - the global and - * per-chunk defaults will be honored. If you want to preserve the current - * behavior when your callback returns 0 you must set PNG_HANDLE_CHUNK_IF_SAFE - * as the default - if you don't do this libpng 1.6 will issue a warning. - * - * If you want unhandled unknown chunks to be discarded in libpng 1.6 and - * earlier simply return '1' (handled). - * - * PNG_HANDLE_AS_UNKNOWN_SUPPORTED: - * If this is *not* set known chunks will always be handled by libpng and - * will never be stored in the unknown chunk list. Known chunks listed to - * png_set_keep_unknown_chunks will have no effect. If it is set then known - * chunks listed with a keep other than AS_DEFAULT will *never* be processed - * by libpng, in addition critical chunks must either be processed by the - * callback or saved. - * - * The IHDR and IEND chunks must not be listed. Because this turns off the - * default handling for chunks that would otherwise be recognized the - * behavior of libpng transformations may well become incorrect! - * - * WRITE: - * When writing chunks the options only apply to the chunks specified by - * png_set_unknown_chunks (below), libpng will *always* write known chunks - * required by png_set_ calls and will always write the core critical chunks - * (as required for PLTE). - * - * Each chunk in the png_set_unknown_chunks list is looked up in the - * png_set_keep_unknown_chunks list to find the keep setting, this is then - * interpreted as follows: - * - * PNG_HANDLE_CHUNK_AS_DEFAULT: - * Write safe-to-copy chunks and write other chunks if the global - * default is set to _ALWAYS, otherwise don't write this chunk. - * PNG_HANDLE_CHUNK_NEVER: - * Do not write the chunk. - * PNG_HANDLE_CHUNK_IF_SAFE: - * Write the chunk if it is safe-to-copy, otherwise do not write it. - * PNG_HANDLE_CHUNK_ALWAYS: - * Write the chunk. - * - * Note that the default behavior is effectively the opposite of the read case - - * in read unknown chunks are not stored by default, in write they are written - * by default. Also the behavior of PNG_HANDLE_CHUNK_IF_SAFE is very different - * - on write the safe-to-copy bit is checked, on read the critical bit is - * checked and on read if the chunk is critical an error will be raised. - * - * num_chunks: - * =========== - * If num_chunks is positive, then the "keep" parameter specifies the manner - * for handling only those chunks appearing in the chunk_list array, - * otherwise the chunk list array is ignored. - * - * If num_chunks is 0 the "keep" parameter specifies the default behavior for - * unknown chunks, as described above. - * - * If num_chunks is negative, then the "keep" parameter specifies the manner - * for handling all unknown chunks plus all chunks recognized by libpng - * except for the IHDR, PLTE, tRNS, IDAT, and IEND chunks (which continue to - * be processed by libpng. - */ -PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr, - int keep, png_const_bytep chunk_list, int num_chunks)); - -/* The "keep" PNG_HANDLE_CHUNK_ parameter for the specified chunk is returned; - * the result is therefore true (non-zero) if special handling is required, - * false for the default handling. - */ -PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr, - png_const_bytep chunk_name)); -#endif - -#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr, - png_inforp info_ptr, png_const_unknown_chunkp unknowns, - int num_unknowns)); - /* NOTE: prior to 1.6.0 this routine set the 'location' field of the added - * unknowns to the location currently stored in the png_struct. This is - * invariably the wrong value on write. To fix this call the following API - * for each chunk in the list with the correct location. If you know your - * code won't be compiled on earlier versions you can rely on - * png_set_unknown_chunks(write-ptr, png_get_unknown_chunks(read-ptr)) doing - * the correct thing. - */ - -PNG_EXPORT(175, void, png_set_unknown_chunk_location, - (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location)); - -PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr, - png_inforp info_ptr, png_unknown_chunkpp entries)); -#endif - -/* Png_free_data() will turn off the "valid" flag for anything it frees. - * If you need to turn it off for a chunk that your application has freed, - * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); - */ -PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr, - png_inforp info_ptr, int mask)); - -#ifdef PNG_INFO_IMAGE_SUPPORTED -/* The "params" pointer is currently not used and is for future expansion. */ -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr, - int transforms, png_voidp params)); -#endif -#ifdef PNG_WRITE_SUPPORTED -PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr, - int transforms, png_voidp params)); -#endif -#endif - -PNG_EXPORT(180, png_const_charp, png_get_copyright, - (png_const_structrp png_ptr)); -PNG_EXPORT(181, png_const_charp, png_get_header_ver, - (png_const_structrp png_ptr)); -PNG_EXPORT(182, png_const_charp, png_get_header_version, - (png_const_structrp png_ptr)); -PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, - (png_const_structrp png_ptr)); - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr, - png_uint_32 mng_features_permitted)); -#endif - -/* For use in png_set_keep_unknown, added to version 1.2.6 */ -#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 -#define PNG_HANDLE_CHUNK_NEVER 1 -#define PNG_HANDLE_CHUNK_IF_SAFE 2 -#define PNG_HANDLE_CHUNK_ALWAYS 3 -#define PNG_HANDLE_CHUNK_LAST 4 - -/* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. - */ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr, - png_uint_32 strip_mode)); -#endif - -/* Added in libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr, - png_uint_32 user_width_max, png_uint_32 user_height_max)); -PNG_EXPORT(187, png_uint_32, png_get_user_width_max, - (png_const_structrp png_ptr)); -PNG_EXPORT(188, png_uint_32, png_get_user_height_max, - (png_const_structrp png_ptr)); -/* Added in libpng-1.4.0 */ -PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr, - png_uint_32 user_chunk_cache_max)); -PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, - (png_const_structrp png_ptr)); -/* Added in libpng-1.4.1 */ -PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr, - png_alloc_size_t user_chunk_cache_max)); -PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, - (png_const_structrp png_ptr)); -#endif - -#if defined(PNG_INCH_CONVERSIONS_SUPPORTED) -PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, - (png_const_structrp png_ptr, png_const_inforp info_ptr)); - -PNG_FP_EXPORT(196, float, png_get_x_offset_inches, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ -PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -#endif - -PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr, - png_const_inforp info_ptr)) -#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ -PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, - (png_const_structrp png_ptr, png_const_inforp info_ptr)) -#endif - -# ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr, - png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, - int *unit_type)); -# endif /* pHYs */ -#endif /* INCH_CONVERSIONS */ - -/* Added in libpng-1.4.0 */ -#ifdef PNG_IO_STATE_SUPPORTED -PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr)); - -/* Removed from libpng 1.6; use png_get_io_chunk_type. */ -PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr), - PNG_DEPRECATED) - -PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, - (png_const_structrp png_ptr)); - -/* The flags returned by png_get_io_state() are the following: */ -# define PNG_IO_NONE 0x0000 /* no I/O at this moment */ -# define PNG_IO_READING 0x0001 /* currently reading */ -# define PNG_IO_WRITING 0x0002 /* currently writing */ -# define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ -# define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ -# define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ -# define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ -# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ -# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ -#endif /* IO_STATE */ - -/* Interlace support. The following macros are always defined so that if - * libpng interlace handling is turned off the macros may be used to handle - * interlaced images within the application. - */ -#define PNG_INTERLACE_ADAM7_PASSES 7 - -/* Two macros to return the first row and first column of the original, - * full, image which appears in a given pass. 'pass' is in the range 0 - * to 6 and the result is in the range 0 to 7. - */ -#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) -#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) - -/* A macro to return the offset between pixels in the output row for a pair of - * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that - * follows. Note that ROW_OFFSET is the offset from one row to the next whereas - * COL_OFFSET is from one column to the next, within a row. - */ -#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) -#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) - -/* Two macros to help evaluate the number of rows or columns in each - * pass. This is expressed as a shift - effectively log2 of the number or - * rows or columns in each 8x8 tile of the original image. - */ -#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) -#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) - -/* Hence two macros to determine the number of rows or columns in a given - * pass of an image given its height or width. In fact these macros may - * return non-zero even though the sub-image is empty, because the other - * dimension may be empty for a small image. - */ -#define PNG_PASS_ROWS(height, pass) (((height)+(((1<<PNG_PASS_ROW_SHIFT(pass))\ - -1)-PNG_PASS_START_ROW(pass)))>>PNG_PASS_ROW_SHIFT(pass)) -#define PNG_PASS_COLS(width, pass) (((width)+(((1<<PNG_PASS_COL_SHIFT(pass))\ - -1)-PNG_PASS_START_COL(pass)))>>PNG_PASS_COL_SHIFT(pass)) - -/* For the reader row callbacks (both progressive and sequential) it is - * necessary to find the row in the output image given a row in an interlaced - * image, so two more macros: - */ -#define PNG_ROW_FROM_PASS_ROW(y_in, pass) \ - (((y_in)<<PNG_PASS_ROW_SHIFT(pass))+PNG_PASS_START_ROW(pass)) -#define PNG_COL_FROM_PASS_COL(x_in, pass) \ - (((x_in)<<PNG_PASS_COL_SHIFT(pass))+PNG_PASS_START_COL(pass)) - -/* Two macros which return a boolean (0 or 1) saying whether the given row - * or column is in a particular pass. These use a common utility macro that - * returns a mask for a given pass - the offset 'off' selects the row or - * column version. The mask has the appropriate bit set for each column in - * the tile. - */ -#define PNG_PASS_MASK(pass,off) ( \ - ((0x110145AF>>(((7-(off))-(pass))<<2)) & 0xF) | \ - ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) - -#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ - ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) -#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ - ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) - -#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED -/* With these routines we avoid an integer divide, which will be slower on - * most machines. However, it does take more operations than the corresponding - * divide method, so it may be slower on a few RISC systems. There are two - * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. - * - * Note that the rounding factors are NOT supposed to be the same! 128 and - * 32768 are correct for the NODIV code; 127 and 32767 are correct for the - * standard method. - * - * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] - */ - - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ - -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ - * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 \ - - (png_uint_16)(alpha)) + 128); \ - (composite) = (png_byte)(((temp + (temp >> 8)) >> 8) & 0xff); } - -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ - * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(65535 \ - - (png_uint_32)(alpha)) + 32768); \ - (composite) = (png_uint_16)(0xffff & ((temp + (temp >> 16)) >> 16)); } - -#else /* Standard method using integer division */ - -# define png_composite(composite, fg, alpha, bg) \ - (composite) = \ - (png_byte)(0xff & (((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - 127) / 255)) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = \ - (png_uint_16)(0xffff & (((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ - 32767) / 65535)) -#endif /* READ_COMPOSITE_NODIV */ - -#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); -PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); -PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); -#endif - -PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr, - png_const_bytep buf)); -/* No png_get_int_16 -- may be added if there's a real need for it. */ - -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ -#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); -#endif -#ifdef PNG_SAVE_INT_32_SUPPORTED -PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); -#endif - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); -/* No png_save_int_16 -- may be added if there's a real need for it. */ -#endif - -#ifdef PNG_USE_READ_MACROS -/* Inline macros to do direct reads of bytes from the input buffer. - * The png_get_int_32() routine assumes we are using two's complement - * format for negative values, which is almost certainly true. - */ -# define PNG_get_uint_32(buf) \ - (((png_uint_32)(*(buf)) << 24) + \ - ((png_uint_32)(*((buf) + 1)) << 16) + \ - ((png_uint_32)(*((buf) + 2)) << 8) + \ - ((png_uint_32)(*((buf) + 3)))) - - /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the - * function) incorrectly returned a value of type png_uint_32. - */ -# define PNG_get_uint_16(buf) \ - ((png_uint_16) \ - (((unsigned int)(*(buf)) << 8) + \ - ((unsigned int)(*((buf) + 1))))) - -# define PNG_get_int_32(buf) \ - ((png_int_32)((*(buf) & 0x80) \ - ? -((png_int_32)(((png_get_uint_32(buf)^0xffffffffU)+1U)&0x7fffffffU)) \ - : (png_int_32)png_get_uint_32(buf))) - - /* If PNG_PREFIX is defined the same thing as below happens in pnglibconf.h, - * but defining a macro name prefixed with PNG_PREFIX. - */ -# ifndef PNG_PREFIX -# define png_get_uint_32(buf) PNG_get_uint_32(buf) -# define png_get_uint_16(buf) PNG_get_uint_16(buf) -# define png_get_int_32(buf) PNG_get_int_32(buf) -# endif -#else -# ifdef PNG_PREFIX - /* No macros; revert to the (redefined) function */ -# define PNG_get_uint_32 (png_get_uint_32) -# define PNG_get_uint_16 (png_get_uint_16) -# define PNG_get_int_32 (png_get_int_32) -# endif -#endif - -#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED -PNG_EXPORT(242, void, png_set_check_for_invalid_index, - (png_structrp png_ptr, int allowed)); -# ifdef PNG_GET_PALETTE_MAX_SUPPORTED -PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr, - png_const_infop info_ptr)); -# endif -#endif /* CHECK_FOR_INVALID_INDEX */ - -/******************************************************************************* - * Section 5: SIMPLIFIED API - ******************************************************************************* - * - * Please read the documentation in libpng-manual.txt (TODO: write said - * documentation) if you don't understand what follows. - * - * The simplified API hides the details of both libpng and the PNG file format - * itself. It allows PNG files to be read into a very limited number of - * in-memory bitmap formats or to be written from the same formats. If these - * formats do not accomodate your needs then you can, and should, use the more - * sophisticated APIs above - these support a wide variety of in-memory formats - * and a wide variety of sophisticated transformations to those formats as well - * as a wide variety of APIs to manipulate ancillary information. - * - * To read a PNG file using the simplified API: - * - * 1) Declare a 'png_image' structure (see below) on the stack, set the - * version field to PNG_IMAGE_VERSION and the 'opaque' pointer to NULL - * (this is REQUIRED, your program may crash if you don't do it.) - * 2) Call the appropriate png_image_begin_read... function. - * 3) Set the png_image 'format' member to the required sample format. - * 4) Allocate a buffer for the image and, if required, the color-map. - * 5) Call png_image_finish_read to read the image and, if required, the - * color-map into your buffers. - * - * There are no restrictions on the format of the PNG input itself; all valid - * color types, bit depths, and interlace methods are acceptable, and the - * input image is transformed as necessary to the requested in-memory format - * during the png_image_finish_read() step. The only caveat is that if you - * request a color-mapped image from a PNG that is full-color or makes - * complex use of an alpha channel the transformation is extremely lossy and the - * result may look terrible. - * - * To write a PNG file using the simplified API: - * - * 1) Declare a 'png_image' structure on the stack and memset() it to all zero. - * 2) Initialize the members of the structure that describe the image, setting - * the 'format' member to the format of the image samples. - * 3) Call the appropriate png_image_write... function with a pointer to the - * image and, if necessary, the color-map to write the PNG data. - * - * png_image is a structure that describes the in-memory format of an image - * when it is being read or defines the in-memory format of an image that you - * need to write: - */ -#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) || \ - defined(PNG_SIMPLIFIED_WRITE_SUPPORTED) - -#define PNG_IMAGE_VERSION 1 - -typedef struct png_control *png_controlp; -typedef struct -{ - png_controlp opaque; /* Initialize to NULL, free with png_image_free */ - png_uint_32 version; /* Set to PNG_IMAGE_VERSION */ - png_uint_32 width; /* Image width in pixels (columns) */ - png_uint_32 height; /* Image height in pixels (rows) */ - png_uint_32 format; /* Image format as defined below */ - png_uint_32 flags; /* A bit mask containing informational flags */ - png_uint_32 colormap_entries; - /* Number of entries in the color-map */ - - /* In the event of an error or warning the following field will be set to a - * non-zero value and the 'message' field will contain a '\0' terminated - * string with the libpng error or warning message. If both warnings and - * an error were encountered, only the error is recorded. If there - * are multiple warnings, only the first one is recorded. - * - * The upper 30 bits of this value are reserved, the low two bits contain - * a value as follows: - */ -# define PNG_IMAGE_WARNING 1 -# define PNG_IMAGE_ERROR 2 - /* - * The result is a two-bit code such that a value more than 1 indicates - * a failure in the API just called: - * - * 0 - no warning or error - * 1 - warning - * 2 - error - * 3 - error preceded by warning - */ -# define PNG_IMAGE_FAILED(png_cntrl) ((((png_cntrl).warning_or_error)&0x03)>1) - - png_uint_32 warning_or_error; - - char message[64]; -} png_image, *png_imagep; - -/* The samples of the image have one to four channels whose components have - * original values in the range 0 to 1.0: - * - * 1: A single gray or luminance channel (G). - * 2: A gray/luminance channel and an alpha channel (GA). - * 3: Three red, green, blue color channels (RGB). - * 4: Three color channels and an alpha channel (RGBA). - * - * The components are encoded in one of two ways: - * - * a) As a small integer, value 0..255, contained in a single byte. For the - * alpha channel the original value is simply value/255. For the color or - * luminance channels the value is encoded according to the sRGB specification - * and matches the 8-bit format expected by typical display devices. - * - * The color/gray channels are not scaled (pre-multiplied) by the alpha - * channel and are suitable for passing to color management software. - * - * b) As a value in the range 0..65535, contained in a 2-byte integer. All - * channels can be converted to the original value by dividing by 65535; all - * channels are linear. Color channels use the RGB encoding (RGB end-points) of - * the sRGB specification. This encoding is identified by the - * PNG_FORMAT_FLAG_LINEAR flag below. - * - * When the simplified API needs to convert between sRGB and linear colorspaces, - * the actual sRGB transfer curve defined in the sRGB specification (see the - * article at http://en.wikipedia.org/wiki/SRGB) is used, not the gamma=1/2.2 - * approximation used elsewhere in libpng. - * - * When an alpha channel is present it is expected to denote pixel coverage - * of the color or luminance channels and is returned as an associated alpha - * channel: the color/gray channels are scaled (pre-multiplied) by the alpha - * value. - * - * The samples are either contained directly in the image data, between 1 and 8 - * bytes per pixel according to the encoding, or are held in a color-map indexed - * by bytes in the image data. In the case of a color-map the color-map entries - * are individual samples, encoded as above, and the image data has one byte per - * pixel to select the relevant sample from the color-map. - */ - -/* PNG_FORMAT_* - * - * #defines to be used in png_image::format. Each #define identifies a - * particular layout of sample data and, if present, alpha values. There are - * separate defines for each of the two component encodings. - * - * A format is built up using single bit flag values. All combinations are - * valid. Formats can be built up from the flag values or you can use one of - * the predefined values below. When testing formats always use the FORMAT_FLAG - * macros to test for individual features - future versions of the library may - * add new flags. - * - * When reading or writing color-mapped images the format should be set to the - * format of the entries in the color-map then png_image_{read,write}_colormap - * called to read or write the color-map and set the format correctly for the - * image data. Do not set the PNG_FORMAT_FLAG_COLORMAP bit directly! - * - * NOTE: libpng can be built with particular features disabled. If you see - * compiler errors because the definition of one of the following flags has been - * compiled out it is because libpng does not have the required support. It is - * possible, however, for the libpng configuration to enable the format on just - * read or just write; in that case you may see an error at run time. You can - * guard against this by checking for the definition of the appropriate - * "_SUPPORTED" macro, one of: - * - * PNG_SIMPLIFIED_{READ,WRITE}_{BGR,AFIRST}_SUPPORTED - */ -#define PNG_FORMAT_FLAG_ALPHA 0x01U /* format with an alpha channel */ -#define PNG_FORMAT_FLAG_COLOR 0x02U /* color format: otherwise grayscale */ -#define PNG_FORMAT_FLAG_LINEAR 0x04U /* 2-byte channels else 1-byte */ -#define PNG_FORMAT_FLAG_COLORMAP 0x08U /* image data is color-mapped */ - -#ifdef PNG_FORMAT_BGR_SUPPORTED -# define PNG_FORMAT_FLAG_BGR 0x10U /* BGR colors, else order is RGB */ -#endif - -#ifdef PNG_FORMAT_AFIRST_SUPPORTED -# define PNG_FORMAT_FLAG_AFIRST 0x20U /* alpha channel comes first */ -#endif - -/* Commonly used formats have predefined macros. - * - * First the single byte (sRGB) formats: - */ -#define PNG_FORMAT_GRAY 0 -#define PNG_FORMAT_GA PNG_FORMAT_FLAG_ALPHA -#define PNG_FORMAT_AG (PNG_FORMAT_GA|PNG_FORMAT_FLAG_AFIRST) -#define PNG_FORMAT_RGB PNG_FORMAT_FLAG_COLOR -#define PNG_FORMAT_BGR (PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_BGR) -#define PNG_FORMAT_RGBA (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_ALPHA) -#define PNG_FORMAT_ARGB (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_AFIRST) -#define PNG_FORMAT_BGRA (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_ALPHA) -#define PNG_FORMAT_ABGR (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_AFIRST) - -/* Then the linear 2-byte formats. When naming these "Y" is used to - * indicate a luminance (gray) channel. - */ -#define PNG_FORMAT_LINEAR_Y PNG_FORMAT_FLAG_LINEAR -#define PNG_FORMAT_LINEAR_Y_ALPHA (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_ALPHA) -#define PNG_FORMAT_LINEAR_RGB (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR) -#define PNG_FORMAT_LINEAR_RGB_ALPHA \ - (PNG_FORMAT_FLAG_LINEAR|PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA) - -/* With color-mapped formats the image data is one byte for each pixel, the byte - * is an index into the color-map which is formatted as above. To obtain a - * color-mapped format it is sufficient just to add the PNG_FOMAT_FLAG_COLORMAP - * to one of the above definitions, or you can use one of the definitions below. - */ -#define PNG_FORMAT_RGB_COLORMAP (PNG_FORMAT_RGB|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_BGR_COLORMAP (PNG_FORMAT_BGR|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_RGBA_COLORMAP (PNG_FORMAT_RGBA|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_ARGB_COLORMAP (PNG_FORMAT_ARGB|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_BGRA_COLORMAP (PNG_FORMAT_BGRA|PNG_FORMAT_FLAG_COLORMAP) -#define PNG_FORMAT_ABGR_COLORMAP (PNG_FORMAT_ABGR|PNG_FORMAT_FLAG_COLORMAP) - -/* PNG_IMAGE macros - * - * These are convenience macros to derive information from a png_image - * structure. The PNG_IMAGE_SAMPLE_ macros return values appropriate to the - * actual image sample values - either the entries in the color-map or the - * pixels in the image. The PNG_IMAGE_PIXEL_ macros return corresponding values - * for the pixels and will always return 1 for color-mapped formats. The - * remaining macros return information about the rows in the image and the - * complete image. - * - * NOTE: All the macros that take a png_image::format parameter are compile time - * constants if the format parameter is, itself, a constant. Therefore these - * macros can be used in array declarations and case labels where required. - * Similarly the macros are also pre-processor constants (sizeof is not used) so - * they can be used in #if tests. - * - * First the information about the samples. - */ -#define PNG_IMAGE_SAMPLE_CHANNELS(fmt)\ - (((fmt)&(PNG_FORMAT_FLAG_COLOR|PNG_FORMAT_FLAG_ALPHA))+1) - /* Return the total number of channels in a given format: 1..4 */ - -#define PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)\ - ((((fmt) & PNG_FORMAT_FLAG_LINEAR) >> 2)+1) - /* Return the size in bytes of a single component of a pixel or color-map - * entry (as appropriate) in the image: 1 or 2. - */ - -#define PNG_IMAGE_SAMPLE_SIZE(fmt)\ - (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * PNG_IMAGE_SAMPLE_COMPONENT_SIZE(fmt)) - /* This is the size of the sample data for one sample. If the image is - * color-mapped it is the size of one color-map entry (and image pixels are - * one byte in size), otherwise it is the size of one image pixel. - */ - -#define PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(fmt)\ - (PNG_IMAGE_SAMPLE_CHANNELS(fmt) * 256) - /* The maximum size of the color-map required by the format expressed in a - * count of components. This can be used to compile-time allocate a - * color-map: - * - * png_uint_16 colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(linear_fmt)]; - * - * png_byte colormap[PNG_IMAGE_MAXIMUM_COLORMAP_COMPONENTS(sRGB_fmt)]; - * - * Alternatively use the PNG_IMAGE_COLORMAP_SIZE macro below to use the - * information from one of the png_image_begin_read_ APIs and dynamically - * allocate the required memory. - */ - -/* Corresponding information about the pixels */ -#define PNG_IMAGE_PIXEL_(test,fmt)\ - (((fmt)&PNG_FORMAT_FLAG_COLORMAP)?1:test(fmt)) - -#define PNG_IMAGE_PIXEL_CHANNELS(fmt)\ - PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_CHANNELS,fmt) - /* The number of separate channels (components) in a pixel; 1 for a - * color-mapped image. - */ - -#define PNG_IMAGE_PIXEL_COMPONENT_SIZE(fmt)\ - PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_COMPONENT_SIZE,fmt) - /* The size, in bytes, of each component in a pixel; 1 for a color-mapped - * image. - */ - -#define PNG_IMAGE_PIXEL_SIZE(fmt) PNG_IMAGE_PIXEL_(PNG_IMAGE_SAMPLE_SIZE,fmt) - /* The size, in bytes, of a complete pixel; 1 for a color-mapped image. */ - -/* Information about the whole row, or whole image */ -#define PNG_IMAGE_ROW_STRIDE(image)\ - (PNG_IMAGE_PIXEL_CHANNELS((image).format) * (image).width) - /* Return the total number of components in a single row of the image; this - * is the minimum 'row stride', the minimum count of components between each - * row. For a color-mapped image this is the minimum number of bytes in a - * row. - */ - -#define PNG_IMAGE_BUFFER_SIZE(image, row_stride)\ - (PNG_IMAGE_PIXEL_COMPONENT_SIZE((image).format)*(image).height*(row_stride)) - /* Return the size, in bytes, of an image buffer given a png_image and a row - * stride - the number of components to leave space for in each row. - */ - -#define PNG_IMAGE_SIZE(image)\ - PNG_IMAGE_BUFFER_SIZE(image, PNG_IMAGE_ROW_STRIDE(image)) - /* Return the size, in bytes, of the image in memory given just a png_image; - * the row stride is the minimum stride required for the image. - */ - -#define PNG_IMAGE_COLORMAP_SIZE(image)\ - (PNG_IMAGE_SAMPLE_SIZE((image).format) * (image).colormap_entries) - /* Return the size, in bytes, of the color-map of this image. If the image - * format is not a color-map format this will return a size sufficient for - * 256 entries in the given format; check PNG_FORMAT_FLAG_COLORMAP if - * you don't want to allocate a color-map in this case. - */ - -/* PNG_IMAGE_FLAG_* - * - * Flags containing additional information about the image are held in the - * 'flags' field of png_image. - */ -#define PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB 0x01 - /* This indicates the the RGB values of the in-memory bitmap do not - * correspond to the red, green and blue end-points defined by sRGB. - */ - -#define PNG_IMAGE_FLAG_FAST 0x02 - /* On write emphasise speed over compression; the resultant PNG file will be - * larger but will be produced significantly faster, particular for large - * images. Do not use this option for images which will be distributed, only - * used it when producing intermediate files that will be read back in - * repeatedly. For a typical 24-bit image the option will double the read - * speed at the cost of increasing the image size by 25%, however for many - * more compressible images the PNG file can be 10 times larger with only a - * slight speed gain. - */ - -#define PNG_IMAGE_FLAG_16BIT_sRGB 0x04 - /* On read if the image is a 16-bit per component image and there is no gAMA - * or sRGB chunk assume that the components are sRGB encoded. Notice that - * images output by the simplified API always have gamma information; setting - * this flag only affects the interpretation of 16-bit images from an - * external source. It is recommended that the application expose this flag - * to the user; the user can normally easily recognize the difference between - * linear and sRGB encoding. This flag has no effect on write - the data - * passed to the write APIs must have the correct encoding (as defined - * above.) - * - * If the flag is not set (the default) input 16-bit per component data is - * assumed to be linear. - * - * NOTE: the flag can only be set after the png_image_begin_read_ call, - * because that call initializes the 'flags' field. - */ - -#ifdef PNG_SIMPLIFIED_READ_SUPPORTED -/* READ APIs - * --------- - * - * The png_image passed to the read APIs must have been initialized by setting - * the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.) - */ -#ifdef PNG_STDIO_SUPPORTED -PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image, - const char *file_name)); - /* The named file is opened for read and the image header is filled in - * from the PNG header in the file. - */ - -PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image, - FILE* file)); - /* The PNG header is read from the stdio FILE object. */ -#endif /* STDIO */ - -PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image, - png_const_voidp memory, png_size_t size)); - /* The PNG header is read from the given memory buffer. */ - -PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image, - png_const_colorp background, void *buffer, png_int_32 row_stride, - void *colormap)); - /* Finish reading the image into the supplied buffer and clean up the - * png_image structure. - * - * row_stride is the step, in byte or 2-byte units as appropriate, - * between adjacent rows. A positive stride indicates that the top-most row - * is first in the buffer - the normal top-down arrangement. A negative - * stride indicates that the bottom-most row is first in the buffer. - * - * background need only be supplied if an alpha channel must be removed from - * a png_byte format and the removal is to be done by compositing on a solid - * color; otherwise it may be NULL and any composition will be done directly - * onto the buffer. The value is an sRGB color to use for the background, - * for grayscale output the green channel is used. - * - * background must be supplied when an alpha channel must be removed from a - * single byte color-mapped output format, in other words if: - * - * 1) The original format from png_image_begin_read_from_* had - * PNG_FORMAT_FLAG_ALPHA set. - * 2) The format set by the application does not. - * 3) The format set by the application has PNG_FORMAT_FLAG_COLORMAP set and - * PNG_FORMAT_FLAG_LINEAR *not* set. - * - * For linear output removing the alpha channel is always done by compositing - * on black and background is ignored. - * - * colormap must be supplied when PNG_FORMAT_FLAG_COLORMAP is set. It must - * be at least the size (in bytes) returned by PNG_IMAGE_COLORMAP_SIZE. - * image->colormap_entries will be updated to the actual number of entries - * written to the colormap; this may be less than the original value. - */ - -PNG_EXPORT(238, void, png_image_free, (png_imagep image)); - /* Free any data allocated by libpng in image->opaque, setting the pointer to - * NULL. May be called at any time after the structure is initialized. - */ -#endif /* SIMPLIFIED_READ */ - -#ifdef PNG_SIMPLIFIED_WRITE_SUPPORTED -#ifdef PNG_STDIO_SUPPORTED -/* WRITE APIS - * ---------- - * For write you must initialize a png_image structure to describe the image to - * be written. To do this use memset to set the whole structure to 0 then - * initialize fields describing your image. - * - * version: must be set to PNG_IMAGE_VERSION - * opaque: must be initialized to NULL - * width: image width in pixels - * height: image height in rows - * format: the format of the data (image and color-map) you wish to write - * flags: set to 0 unless one of the defined flags applies; set - * PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB for color format images where the RGB - * values do not correspond to the colors in sRGB. - * colormap_entries: set to the number of entries in the color-map (0 to 256) - */ -PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image, - const char *file, int convert_to_8bit, const void *buffer, - png_int_32 row_stride, const void *colormap)); - /* Write the image to the named file. */ - -PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file, - int convert_to_8_bit, const void *buffer, png_int_32 row_stride, - const void *colormap)); - /* Write the image to the given (FILE*). */ - -/* With both write APIs if image is in one of the linear formats with 16-bit - * data then setting convert_to_8_bit will cause the output to be an 8-bit PNG - * gamma encoded according to the sRGB specification, otherwise a 16-bit linear - * encoded PNG file is written. - * - * With color-mapped data formats the colormap parameter point to a color-map - * with at least image->colormap_entries encoded in the specified format. If - * the format is linear the written PNG color-map will be converted to sRGB - * regardless of the convert_to_8_bit flag. - * - * With all APIs row_stride is handled as in the read APIs - it is the spacing - * from one row to the next in component sized units (1 or 2 bytes) and if - * negative indicates a bottom-up row layout in the buffer. If row_stride is zero, - * libpng will calculate it for you from the image width and number of channels. - * - * Note that the write API does not support interlacing, sub-8-bit pixels, indexed - * PNG (color_type 3) or most ancillary chunks. - */ -#endif /* STDIO */ -#endif /* SIMPLIFIED_WRITE */ -/******************************************************************************* - * END OF SIMPLIFIED API - ******************************************************************************/ -#endif /* SIMPLIFIED_{READ|WRITE} */ - -/******************************************************************************* - * Section 6: IMPLEMENTATION OPTIONS - ******************************************************************************* - * - * Support for arbitrary implementation-specific optimizations. The API allows - * particular options to be turned on or off. 'Option' is the number of the - * option and 'onoff' is 0 (off) or non-0 (on). The value returned is given - * by the PNG_OPTION_ defines below. - * - * HARDWARE: normally hardware capabilites, such as the Intel SSE instructions, - * are detected at run time, however sometimes it may be impossible - * to do this in user mode, in which case it is necessary to discover - * the capabilities in an OS specific way. Such capabilities are - * listed here when libpng has support for them and must be turned - * ON by the application if present. - * - * SOFTWARE: sometimes software optimizations actually result in performance - * decrease on some architectures or systems, or with some sets of - * PNG images. 'Software' options allow such optimizations to be - * selected at run time. - */ -#ifdef PNG_SET_OPTION_SUPPORTED -#ifdef PNG_ARM_NEON_API_SUPPORTED -# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */ -#endif -#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */ -#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */ -#define PNG_OPTION_NEXT 6 /* Next option - numbers must be even */ - -/* Return values: NOTE: there are four values and 'off' is *not* zero */ -#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */ -#define PNG_OPTION_INVALID 1 /* Option number out of range */ -#define PNG_OPTION_OFF 2 -#define PNG_OPTION_ON 3 - -PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option, - int onoff)); -#endif /* SET_OPTION */ - -/******************************************************************************* - * END OF HARDWARE AND SOFTWARE OPTIONS - ******************************************************************************/ - -/* Maintainer: Put new public prototypes here ^, in libpng.3, in project - * defs, and in scripts/symbols.def. - */ - -/* The last ordinal number (this is the *last* one already used; the next - * one to use is one more than this.) - */ -#ifdef PNG_EXPORT_LAST_ORDINAL - PNG_EXPORT_LAST_ORDINAL(244); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -/* Do not put anything past this line */ -#endif /* PNG_H */ diff --git a/android/armeabi/include/png/pngconf.h b/android/armeabi/include/png/pngconf.h deleted file mode 100644 index 93446545..00000000 --- a/android/armeabi/include/png/pngconf.h +++ /dev/null @@ -1,622 +0,0 @@ - -/* pngconf.h - machine configurable file for libpng - * - * libpng version 1.6.21, January 15, 2016 - * - * Copyright (c) 1998-2002,2004,2006-2015 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - * Any machine specific code is near the front of this file, so if you - * are configuring libpng for a machine, you may want to read the section - * starting here down to where it starts to typedef png_color, png_text, - * and png_info. - */ - -#ifndef PNGCONF_H -#define PNGCONF_H - -#ifndef PNG_BUILDING_SYMBOL_TABLE /* else includes may cause problems */ - -/* From libpng 1.6.0 libpng requires an ANSI X3.159-1989 ("ISOC90") compliant C - * compiler for correct compilation. The following header files are required by - * the standard. If your compiler doesn't provide these header files, or they - * do not match the standard, you will need to provide/improve them. - */ -#include <limits.h> -#include <stddef.h> - -/* Library header files. These header files are all defined by ISOC90; libpng - * expects conformant implementations, however, an ISOC90 conformant system need - * not provide these header files if the functionality cannot be implemented. - * In this case it will be necessary to disable the relevant parts of libpng in - * the build of pnglibconf.h. - * - * Prior to 1.6.0 string.h was included here; the API changes in 1.6.0 to not - * include this unnecessary header file. - */ - -#ifdef PNG_STDIO_SUPPORTED - /* Required for the definition of FILE: */ -# include <stdio.h> -#endif - -#ifdef PNG_SETJMP_SUPPORTED - /* Required for the definition of jmp_buf and the declaration of longjmp: */ -# include <setjmp.h> -#endif - -#ifdef PNG_CONVERT_tIME_SUPPORTED - /* Required for struct tm: */ -# include <time.h> -#endif - -#endif /* PNG_BUILDING_SYMBOL_TABLE */ - -/* Prior to 1.6.0 it was possible to turn off 'const' in declarations using - * PNG_NO_CONST; this is no longer supported except for data declarations which - * apparently still cause problems in 2011 on some compilers. - */ -#define PNG_CONST const /* backward compatibility only */ - -/* This controls optimization of the reading of 16-bit and 32-bit values - * from PNG files. It can be set on a per-app-file basis - it - * just changes whether a macro is used when the function is called. - * The library builder sets the default; if read functions are not - * built into the library the macro implementation is forced on. - */ -#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED -# define PNG_USE_READ_MACROS -#endif -#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) -# if PNG_DEFAULT_READ_MACROS -# define PNG_USE_READ_MACROS -# endif -#endif - -/* COMPILER SPECIFIC OPTIONS. - * - * These options are provided so that a variety of difficult compilers - * can be used. Some are fixed at build time (e.g. PNG_API_RULE - * below) but still have compiler specific implementations, others - * may be changed on a per-file basis when compiling against libpng. - */ - -/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect - * against legacy (pre ISOC90) compilers that did not understand function - * prototypes. It is not required for modern C compilers. - */ -#ifndef PNGARG -# define PNGARG(arglist) arglist -#endif - -/* Function calling conventions. - * ============================= - * Normally it is not necessary to specify to the compiler how to call - * a function - it just does it - however on x86 systems derived from - * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems - * and some others) there are multiple ways to call a function and the - * default can be changed on the compiler command line. For this reason - * libpng specifies the calling convention of every exported function and - * every function called via a user supplied function pointer. This is - * done in this file by defining the following macros: - * - * PNGAPI Calling convention for exported functions. - * PNGCBAPI Calling convention for user provided (callback) functions. - * PNGCAPI Calling convention used by the ANSI-C library (required - * for longjmp callbacks and sometimes used internally to - * specify the calling convention for zlib). - * - * These macros should never be overridden. If it is necessary to - * change calling convention in a private build this can be done - * by setting PNG_API_RULE (which defaults to 0) to one of the values - * below to select the correct 'API' variants. - * - * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. - * This is correct in every known environment. - * PNG_API_RULE=1 Use the operating system convention for PNGAPI and - * the 'C' calling convention (from PNGCAPI) for - * callbacks (PNGCBAPI). This is no longer required - * in any known environment - if it has to be used - * please post an explanation of the problem to the - * libpng mailing list. - * - * These cases only differ if the operating system does not use the C - * calling convention, at present this just means the above cases - * (x86 DOS/Windows sytems) and, even then, this does not apply to - * Cygwin running on those systems. - * - * Note that the value must be defined in pnglibconf.h so that what - * the application uses to call the library matches the conventions - * set when building the library. - */ - -/* Symbol export - * ============= - * When building a shared library it is almost always necessary to tell - * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' - * is used to mark the symbols. On some systems these symbols can be - * extracted at link time and need no special processing by the compiler, - * on other systems the symbols are flagged by the compiler and just - * the declaration requires a special tag applied (unfortunately) in a - * compiler dependent way. Some systems can do either. - * - * A small number of older systems also require a symbol from a DLL to - * be flagged to the program that calls it. This is a problem because - * we do not know in the header file included by application code that - * the symbol will come from a shared library, as opposed to a statically - * linked one. For this reason the application must tell us by setting - * the magic flag PNG_USE_DLL to turn on the special processing before - * it includes png.h. - * - * Four additional macros are used to make this happen: - * - * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from - * the build or imported if PNG_USE_DLL is set - compiler - * and system specific. - * - * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to - * 'type', compiler specific. - * - * PNG_DLL_EXPORT Set to the magic to use during a libpng build to - * make a symbol exported from the DLL. Not used in the - * public header files; see pngpriv.h for how it is used - * in the libpng build. - * - * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come - * from a DLL - used to define PNG_IMPEXP when - * PNG_USE_DLL is set. - */ - -/* System specific discovery. - * ========================== - * This code is used at build time to find PNG_IMPEXP, the API settings - * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL - * import processing is possible. On Windows systems it also sets - * compiler-specific macros to the values required to change the calling - * conventions of the various functions. - */ -#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ - defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) - /* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or - * MinGW on any architecture currently supported by Windows. Also includes - * Watcom builds but these need special treatment because they are not - * compatible with GCC or Visual C because of different calling conventions. - */ -# if PNG_API_RULE == 2 - /* If this line results in an error, either because __watcall is not - * understood or because of a redefine just below you cannot use *this* - * build of the library with the compiler you are using. *This* build was - * build using Watcom and applications must also be built using Watcom! - */ -# define PNGCAPI __watcall -# endif - -# if defined(__GNUC__) || (defined(_MSC_VER) && (_MSC_VER >= 800)) -# define PNGCAPI __cdecl -# if PNG_API_RULE == 1 - /* If this line results in an error __stdcall is not understood and - * PNG_API_RULE should not have been set to '1'. - */ -# define PNGAPI __stdcall -# endif -# else - /* An older compiler, or one not detected (erroneously) above, - * if necessary override on the command line to get the correct - * variants for the compiler. - */ -# ifndef PNGCAPI -# define PNGCAPI _cdecl -# endif -# if PNG_API_RULE == 1 && !defined(PNGAPI) -# define PNGAPI _stdcall -# endif -# endif /* compiler/api */ - - /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ - -# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) -# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed" -# endif - -# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ - (defined(__BORLANDC__) && __BORLANDC__ < 0x500) - /* older Borland and MSC - * compilers used '__export' and required this to be after - * the type. - */ -# ifndef PNG_EXPORT_TYPE -# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP -# endif -# define PNG_DLL_EXPORT __export -# else /* newer compiler */ -# define PNG_DLL_EXPORT __declspec(dllexport) -# ifndef PNG_DLL_IMPORT -# define PNG_DLL_IMPORT __declspec(dllimport) -# endif -# endif /* compiler */ - -#else /* !Windows */ -# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) -# define PNGAPI _System -# else /* !Windows/x86 && !OS/2 */ - /* Use the defaults, or define PNG*API on the command line (but - * this will have to be done for every compile!) - */ -# endif /* other system, !OS/2 */ -#endif /* !Windows/x86 */ - -/* Now do all the defaulting . */ -#ifndef PNGCAPI -# define PNGCAPI -#endif -#ifndef PNGCBAPI -# define PNGCBAPI PNGCAPI -#endif -#ifndef PNGAPI -# define PNGAPI PNGCAPI -#endif - -/* PNG_IMPEXP may be set on the compilation system command line or (if not set) - * then in an internal header file when building the library, otherwise (when - * using the library) it is set here. - */ -#ifndef PNG_IMPEXP -# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) - /* This forces use of a DLL, disallowing static linking */ -# define PNG_IMPEXP PNG_DLL_IMPORT -# endif - -# ifndef PNG_IMPEXP -# define PNG_IMPEXP -# endif -#endif - -/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat - * 'attributes' as a storage class - the attributes go at the start of the - * function definition, and attributes are always appended regardless of the - * compiler. This considerably simplifies these macros but may cause problems - * if any compilers both need function attributes and fail to handle them as - * a storage class (this is unlikely.) - */ -#ifndef PNG_FUNCTION -# define PNG_FUNCTION(type, name, args, attributes) attributes type name args -#endif - -#ifndef PNG_EXPORT_TYPE -# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type -#endif - - /* The ordinal value is only relevant when preprocessing png.h for symbol - * table entries, so we discard it here. See the .dfn files in the - * scripts directory. - */ - -#ifndef PNG_EXPORTA -# define PNG_EXPORTA(ordinal, type, name, args, attributes) \ - PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \ - PNG_LINKAGE_API attributes) -#endif - -/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, - * so make something non-empty to satisfy the requirement: - */ -#define PNG_EMPTY /*empty list*/ - -#define PNG_EXPORT(ordinal, type, name, args) \ - PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) - -/* Use PNG_REMOVED to comment out a removed interface. */ -#ifndef PNG_REMOVED -# define PNG_REMOVED(ordinal, type, name, args, attributes) -#endif - -#ifndef PNG_CALLBACK -# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) -#endif - -/* Support for compiler specific function attributes. These are used - * so that where compiler support is available incorrect use of API - * functions in png.h will generate compiler warnings. - * - * Added at libpng-1.2.41. - */ - -#ifndef PNG_NO_PEDANTIC_WARNINGS -# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED -# define PNG_PEDANTIC_WARNINGS_SUPPORTED -# endif -#endif - -#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED - /* Support for compiler specific function attributes. These are used - * so that where compiler support is available, incorrect use of API - * functions in png.h will generate compiler warnings. Added at libpng - * version 1.2.41. Disabling these removes the warnings but may also produce - * less efficient code. - */ -# if defined(__clang__) && defined(__has_attribute) - /* Clang defines both __clang__ and __GNUC__. Check __clang__ first. */ -# if !defined(PNG_USE_RESULT) && __has_attribute(__warn_unused_result__) -# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) -# endif -# if !defined(PNG_NORETURN) && __has_attribute(__noreturn__) -# define PNG_NORETURN __attribute__((__noreturn__)) -# endif -# if !defined(PNG_ALLOCATED) && __has_attribute(__malloc__) -# define PNG_ALLOCATED __attribute__((__malloc__)) -# endif -# if !defined(PNG_DEPRECATED) && __has_attribute(__deprecated__) -# define PNG_DEPRECATED __attribute__((__deprecated__)) -# endif -# if !defined(PNG_PRIVATE) -# ifdef __has_extension -# if __has_extension(attribute_unavailable_with_message) -# define PNG_PRIVATE __attribute__((__unavailable__(\ - "This function is not exported by libpng."))) -# endif -# endif -# endif -# ifndef PNG_RESTRICT -# define PNG_RESTRICT __restrict -# endif - -# elif defined(__GNUC__) -# ifndef PNG_USE_RESULT -# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) -# endif -# ifndef PNG_NORETURN -# define PNG_NORETURN __attribute__((__noreturn__)) -# endif -# if __GNUC__ >= 3 -# ifndef PNG_ALLOCATED -# define PNG_ALLOCATED __attribute__((__malloc__)) -# endif -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __attribute__((__deprecated__)) -# endif -# ifndef PNG_PRIVATE -# if 0 /* Doesn't work so we use deprecated instead*/ -# define PNG_PRIVATE \ - __attribute__((warning("This function is not exported by libpng."))) -# else -# define PNG_PRIVATE \ - __attribute__((__deprecated__)) -# endif -# endif -# if ((__GNUC__ > 3) || !defined(__GNUC_MINOR__) || (__GNUC_MINOR__ >= 1)) -# ifndef PNG_RESTRICT -# define PNG_RESTRICT __restrict -# endif -# endif /* __GNUC__.__GNUC_MINOR__ > 3.0 */ -# endif /* __GNUC__ >= 3 */ - -# elif defined(_MSC_VER) && (_MSC_VER >= 1300) -# ifndef PNG_USE_RESULT -# define PNG_USE_RESULT /* not supported */ -# endif -# ifndef PNG_NORETURN -# define PNG_NORETURN __declspec(noreturn) -# endif -# ifndef PNG_ALLOCATED -# if (_MSC_VER >= 1400) -# define PNG_ALLOCATED __declspec(restrict) -# endif -# endif -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __declspec(deprecated) -# endif -# ifndef PNG_PRIVATE -# define PNG_PRIVATE __declspec(deprecated) -# endif -# ifndef PNG_RESTRICT -# if (_MSC_VER >= 1400) -# define PNG_RESTRICT __restrict -# endif -# endif - -# elif defined(__WATCOMC__) -# ifndef PNG_RESTRICT -# define PNG_RESTRICT __restrict -# endif -# endif -#endif /* PNG_PEDANTIC_WARNINGS */ - -#ifndef PNG_DEPRECATED -# define PNG_DEPRECATED /* Use of this function is deprecated */ -#endif -#ifndef PNG_USE_RESULT -# define PNG_USE_RESULT /* The result of this function must be checked */ -#endif -#ifndef PNG_NORETURN -# define PNG_NORETURN /* This function does not return */ -#endif -#ifndef PNG_ALLOCATED -# define PNG_ALLOCATED /* The result of the function is new memory */ -#endif -#ifndef PNG_PRIVATE -# define PNG_PRIVATE /* This is a private libpng function */ -#endif -#ifndef PNG_RESTRICT -# define PNG_RESTRICT /* The C99 "restrict" feature */ -#endif - -#ifndef PNG_FP_EXPORT /* A floating point API. */ -# ifdef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FP_EXPORT(ordinal, type, name, args)\ - PNG_EXPORT(ordinal, type, name, args); -# else /* No floating point APIs */ -# define PNG_FP_EXPORT(ordinal, type, name, args) -# endif -#endif -#ifndef PNG_FIXED_EXPORT /* A fixed point API. */ -# ifdef PNG_FIXED_POINT_SUPPORTED -# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ - PNG_EXPORT(ordinal, type, name, args); -# else /* No fixed point APIs */ -# define PNG_FIXED_EXPORT(ordinal, type, name, args) -# endif -#endif - -#ifndef PNG_BUILDING_SYMBOL_TABLE -/* Some typedefs to get us started. These should be safe on most of the common - * platforms. - * - * png_uint_32 and png_int_32 may, currently, be larger than required to hold a - * 32-bit value however this is not normally advisable. - * - * png_uint_16 and png_int_16 should always be two bytes in size - this is - * verified at library build time. - * - * png_byte must always be one byte in size. - * - * The checks below use constants from limits.h, as defined by the ISOC90 - * standard. - */ -#if CHAR_BIT == 8 && UCHAR_MAX == 255 - typedef unsigned char png_byte; -#else -# error "libpng requires 8-bit bytes" -#endif - -#if INT_MIN == -32768 && INT_MAX == 32767 - typedef int png_int_16; -#elif SHRT_MIN == -32768 && SHRT_MAX == 32767 - typedef short png_int_16; -#else -# error "libpng requires a signed 16-bit type" -#endif - -#if UINT_MAX == 65535 - typedef unsigned int png_uint_16; -#elif USHRT_MAX == 65535 - typedef unsigned short png_uint_16; -#else -# error "libpng requires an unsigned 16-bit type" -#endif - -#if INT_MIN < -2147483646 && INT_MAX > 2147483646 - typedef int png_int_32; -#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646 - typedef long int png_int_32; -#else -# error "libpng requires a signed 32-bit (or more) type" -#endif - -#if UINT_MAX > 4294967294 - typedef unsigned int png_uint_32; -#elif ULONG_MAX > 4294967294 - typedef unsigned long int png_uint_32; -#else -# error "libpng requires an unsigned 32-bit (or more) type" -#endif - -/* Prior to 1.6.0 it was possible to disable the use of size_t, 1.6.0, however, - * requires an ISOC90 compiler and relies on consistent behavior of sizeof. - */ -typedef size_t png_size_t; -typedef ptrdiff_t png_ptrdiff_t; - -/* libpng needs to know the maximum value of 'size_t' and this controls the - * definition of png_alloc_size_t, below. This maximum value of size_t limits - * but does not control the maximum allocations the library makes - there is - * direct application control of this through png_set_user_limits(). - */ -#ifndef PNG_SMALL_SIZE_T - /* Compiler specific tests for systems where size_t is known to be less than - * 32 bits (some of these systems may no longer work because of the lack of - * 'far' support; see above.) - */ -# if (defined(__TURBOC__) && !defined(__FLAT__)) ||\ - (defined(_MSC_VER) && defined(MAXSEG_64K)) -# define PNG_SMALL_SIZE_T -# endif -#endif - -/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, and no - * smaller than png_uint_32. Casts from png_size_t or png_uint_32 to - * png_alloc_size_t are not necessary; in fact, it is recommended not to use - * them at all so that the compiler can complain when something turns out to be - * problematic. - * - * Casts in the other direction (from png_alloc_size_t to png_size_t or - * png_uint_32) should be explicitly applied; however, we do not expect to - * encounter practical situations that require such conversions. - * - * PNG_SMALL_SIZE_T must be defined if the maximum value of size_t is less than - * 4294967295 - i.e. less than the maximum value of png_uint_32. - */ -#ifdef PNG_SMALL_SIZE_T - typedef png_uint_32 png_alloc_size_t; -#else - typedef png_size_t png_alloc_size_t; -#endif - -/* Prior to 1.6.0 libpng offered limited support for Microsoft C compiler - * implementations of Intel CPU specific support of user-mode segmented address - * spaces, where 16-bit pointers address more than 65536 bytes of memory using - * separate 'segment' registers. The implementation requires two different - * types of pointer (only one of which includes the segment value.) - * - * If required this support is available in version 1.2 of libpng and may be - * available in versions through 1.5, although the correctness of the code has - * not been verified recently. - */ - -/* Typedef for floating-point numbers that are converted to fixed-point with a - * multiple of 100,000, e.g., gamma - */ -typedef png_int_32 png_fixed_point; - -/* Add typedefs for pointers */ -typedef void * png_voidp; -typedef const void * png_const_voidp; -typedef png_byte * png_bytep; -typedef const png_byte * png_const_bytep; -typedef png_uint_32 * png_uint_32p; -typedef const png_uint_32 * png_const_uint_32p; -typedef png_int_32 * png_int_32p; -typedef const png_int_32 * png_const_int_32p; -typedef png_uint_16 * png_uint_16p; -typedef const png_uint_16 * png_const_uint_16p; -typedef png_int_16 * png_int_16p; -typedef const png_int_16 * png_const_int_16p; -typedef char * png_charp; -typedef const char * png_const_charp; -typedef png_fixed_point * png_fixed_point_p; -typedef const png_fixed_point * png_const_fixed_point_p; -typedef png_size_t * png_size_tp; -typedef const png_size_t * png_const_size_tp; - -#ifdef PNG_STDIO_SUPPORTED -typedef FILE * png_FILE_p; -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double * png_doublep; -typedef const double * png_const_doublep; -#endif - -/* Pointers to pointers; i.e. arrays */ -typedef png_byte * * png_bytepp; -typedef png_uint_32 * * png_uint_32pp; -typedef png_int_32 * * png_int_32pp; -typedef png_uint_16 * * png_uint_16pp; -typedef png_int_16 * * png_int_16pp; -typedef const char * * png_const_charpp; -typedef char * * png_charpp; -typedef png_fixed_point * * png_fixed_point_pp; -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double * * png_doublepp; -#endif - -/* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char * * * png_charppp; - -#endif /* PNG_BUILDING_SYMBOL_TABLE */ - -#endif /* PNGCONF_H */ diff --git a/android/armeabi/include/png/pnglibconf.h b/android/armeabi/include/png/pnglibconf.h deleted file mode 100644 index c0005678..00000000 --- a/android/armeabi/include/png/pnglibconf.h +++ /dev/null @@ -1,212 +0,0 @@ -/* pnglibconf.h - library build configuration */ - -/* libpng version 1.6.21, January 15, 2016 */ - -/* Copyright (c) 1998-2016 Glenn Randers-Pehrson */ - -/* This code is released under the libpng license. */ -/* For conditions of distribution and use, see the disclaimer */ -/* and license in png.h */ - -/* pnglibconf.h */ -/* Machine generated file: DO NOT EDIT */ -/* Derived from: scripts/pnglibconf.dfa */ -#ifndef PNGLCONF_H -#define PNGLCONF_H -/* options */ -#define PNG_16BIT_SUPPORTED -#define PNG_ALIGNED_MEMORY_SUPPORTED -/*#undef PNG_ARM_NEON_API_SUPPORTED*/ -/*#undef PNG_ARM_NEON_CHECK_SUPPORTED*/ -#define PNG_BENIGN_ERRORS_SUPPORTED -#define PNG_BENIGN_READ_ERRORS_SUPPORTED -/*#undef PNG_BENIGN_WRITE_ERRORS_SUPPORTED*/ -#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED -#define PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_COLORSPACE_SUPPORTED -#define PNG_CONSOLE_IO_SUPPORTED -#define PNG_CONVERT_tIME_SUPPORTED -#define PNG_EASY_ACCESS_SUPPORTED -/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ -#define PNG_ERROR_TEXT_SUPPORTED -#define PNG_FIXED_POINT_SUPPORTED -#define PNG_FLOATING_ARITHMETIC_SUPPORTED -#define PNG_FLOATING_POINT_SUPPORTED -#define PNG_FORMAT_AFIRST_SUPPORTED -#define PNG_FORMAT_BGR_SUPPORTED -#define PNG_GAMMA_SUPPORTED -#define PNG_GET_PALETTE_MAX_SUPPORTED -#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -#define PNG_INCH_CONVERSIONS_SUPPORTED -#define PNG_INFO_IMAGE_SUPPORTED -#define PNG_IO_STATE_SUPPORTED -#define PNG_MNG_FEATURES_SUPPORTED -#define PNG_POINTER_INDEXING_SUPPORTED -#define PNG_PROGRESSIVE_READ_SUPPORTED -#define PNG_READ_16BIT_SUPPORTED -#define PNG_READ_ALPHA_MODE_SUPPORTED -#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#define PNG_READ_BACKGROUND_SUPPORTED -#define PNG_READ_BGR_SUPPORTED -#define PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_READ_COMPOSITE_NODIV_SUPPORTED -#define PNG_READ_COMPRESSED_TEXT_SUPPORTED -#define PNG_READ_EXPAND_16_SUPPORTED -#define PNG_READ_EXPAND_SUPPORTED -#define PNG_READ_FILLER_SUPPORTED -#define PNG_READ_GAMMA_SUPPORTED -#define PNG_READ_GET_PALETTE_MAX_SUPPORTED -#define PNG_READ_GRAY_TO_RGB_SUPPORTED -#define PNG_READ_INTERLACING_SUPPORTED -#define PNG_READ_INT_FUNCTIONS_SUPPORTED -#define PNG_READ_INVERT_ALPHA_SUPPORTED -#define PNG_READ_INVERT_SUPPORTED -#define PNG_READ_OPT_PLTE_SUPPORTED -#define PNG_READ_PACKSWAP_SUPPORTED -#define PNG_READ_PACK_SUPPORTED -#define PNG_READ_QUANTIZE_SUPPORTED -#define PNG_READ_RGB_TO_GRAY_SUPPORTED -#define PNG_READ_SCALE_16_TO_8_SUPPORTED -#define PNG_READ_SHIFT_SUPPORTED -#define PNG_READ_STRIP_16_TO_8_SUPPORTED -#define PNG_READ_STRIP_ALPHA_SUPPORTED -#define PNG_READ_SUPPORTED -#define PNG_READ_SWAP_ALPHA_SUPPORTED -#define PNG_READ_SWAP_SUPPORTED -#define PNG_READ_TEXT_SUPPORTED -#define PNG_READ_TRANSFORMS_SUPPORTED -#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_READ_USER_CHUNKS_SUPPORTED -#define PNG_READ_USER_TRANSFORM_SUPPORTED -#define PNG_READ_bKGD_SUPPORTED -#define PNG_READ_cHRM_SUPPORTED -#define PNG_READ_gAMA_SUPPORTED -#define PNG_READ_hIST_SUPPORTED -#define PNG_READ_iCCP_SUPPORTED -#define PNG_READ_iTXt_SUPPORTED -#define PNG_READ_oFFs_SUPPORTED -#define PNG_READ_pCAL_SUPPORTED -#define PNG_READ_pHYs_SUPPORTED -#define PNG_READ_sBIT_SUPPORTED -#define PNG_READ_sCAL_SUPPORTED -#define PNG_READ_sPLT_SUPPORTED -#define PNG_READ_sRGB_SUPPORTED -#define PNG_READ_tEXt_SUPPORTED -#define PNG_READ_tIME_SUPPORTED -#define PNG_READ_tRNS_SUPPORTED -#define PNG_READ_zTXt_SUPPORTED -#define PNG_SAVE_INT_32_SUPPORTED -#define PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_SEQUENTIAL_READ_SUPPORTED -#define PNG_SETJMP_SUPPORTED -#define PNG_SET_OPTION_SUPPORTED -#define PNG_SET_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_SET_USER_LIMITS_SUPPORTED -#define PNG_SIMPLIFIED_READ_AFIRST_SUPPORTED -#define PNG_SIMPLIFIED_READ_BGR_SUPPORTED -#define PNG_SIMPLIFIED_READ_SUPPORTED -#define PNG_SIMPLIFIED_WRITE_AFIRST_SUPPORTED -#define PNG_SIMPLIFIED_WRITE_BGR_SUPPORTED -#define PNG_SIMPLIFIED_WRITE_SUPPORTED -#define PNG_STDIO_SUPPORTED -#define PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_TEXT_SUPPORTED -#define PNG_TIME_RFC1123_SUPPORTED -#define PNG_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_USER_CHUNKS_SUPPORTED -#define PNG_USER_LIMITS_SUPPORTED -#define PNG_USER_MEM_SUPPORTED -#define PNG_USER_TRANSFORM_INFO_SUPPORTED -#define PNG_USER_TRANSFORM_PTR_SUPPORTED -#define PNG_WARNINGS_SUPPORTED -#define PNG_WRITE_16BIT_SUPPORTED -#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#define PNG_WRITE_BGR_SUPPORTED -#define PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED -#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED -#define PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED -#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED -#define PNG_WRITE_FILLER_SUPPORTED -#define PNG_WRITE_FILTER_SUPPORTED -#define PNG_WRITE_FLUSH_SUPPORTED -#define PNG_WRITE_GET_PALETTE_MAX_SUPPORTED -#define PNG_WRITE_INTERLACING_SUPPORTED -#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED -#define PNG_WRITE_INVERT_ALPHA_SUPPORTED -#define PNG_WRITE_INVERT_SUPPORTED -#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED -#define PNG_WRITE_PACKSWAP_SUPPORTED -#define PNG_WRITE_PACK_SUPPORTED -#define PNG_WRITE_SHIFT_SUPPORTED -#define PNG_WRITE_SUPPORTED -#define PNG_WRITE_SWAP_ALPHA_SUPPORTED -#define PNG_WRITE_SWAP_SUPPORTED -#define PNG_WRITE_TEXT_SUPPORTED -#define PNG_WRITE_TRANSFORMS_SUPPORTED -#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_WRITE_USER_TRANSFORM_SUPPORTED -#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#define PNG_WRITE_bKGD_SUPPORTED -#define PNG_WRITE_cHRM_SUPPORTED -#define PNG_WRITE_gAMA_SUPPORTED -#define PNG_WRITE_hIST_SUPPORTED -#define PNG_WRITE_iCCP_SUPPORTED -#define PNG_WRITE_iTXt_SUPPORTED -#define PNG_WRITE_oFFs_SUPPORTED -#define PNG_WRITE_pCAL_SUPPORTED -#define PNG_WRITE_pHYs_SUPPORTED -#define PNG_WRITE_sBIT_SUPPORTED -#define PNG_WRITE_sCAL_SUPPORTED -#define PNG_WRITE_sPLT_SUPPORTED -#define PNG_WRITE_sRGB_SUPPORTED -#define PNG_WRITE_tEXt_SUPPORTED -#define PNG_WRITE_tIME_SUPPORTED -#define PNG_WRITE_tRNS_SUPPORTED -#define PNG_WRITE_zTXt_SUPPORTED -#define PNG_bKGD_SUPPORTED -#define PNG_cHRM_SUPPORTED -#define PNG_gAMA_SUPPORTED -#define PNG_hIST_SUPPORTED -#define PNG_iCCP_SUPPORTED -#define PNG_iTXt_SUPPORTED -#define PNG_oFFs_SUPPORTED -#define PNG_pCAL_SUPPORTED -#define PNG_pHYs_SUPPORTED -#define PNG_sBIT_SUPPORTED -#define PNG_sCAL_SUPPORTED -#define PNG_sPLT_SUPPORTED -#define PNG_sRGB_SUPPORTED -#define PNG_tEXt_SUPPORTED -#define PNG_tIME_SUPPORTED -#define PNG_tRNS_SUPPORTED -#define PNG_zTXt_SUPPORTED -/* end of options */ -/* settings */ -#define PNG_API_RULE 0 -#define PNG_DEFAULT_READ_MACROS 1 -#define PNG_GAMMA_THRESHOLD_FIXED 5000 -#define PNG_IDAT_READ_SIZE PNG_ZBUF_SIZE -#define PNG_INFLATE_BUF_SIZE 1024 -#define PNG_LINKAGE_API extern -#define PNG_LINKAGE_CALLBACK extern -#define PNG_LINKAGE_DATA extern -#define PNG_LINKAGE_FUNCTION extern -#define PNG_MAX_GAMMA_8 11 -#define PNG_QUANTIZE_BLUE_BITS 5 -#define PNG_QUANTIZE_GREEN_BITS 5 -#define PNG_QUANTIZE_RED_BITS 5 -#define PNG_TEXT_Z_DEFAULT_COMPRESSION (-1) -#define PNG_TEXT_Z_DEFAULT_STRATEGY 0 -#define PNG_USER_CHUNK_CACHE_MAX 1000 -#define PNG_USER_CHUNK_MALLOC_MAX 8000000 -#define PNG_USER_HEIGHT_MAX 1000000 -#define PNG_USER_WIDTH_MAX 1000000 -#define PNG_ZBUF_SIZE 8192 -#define PNG_ZLIB_VERNUM 0x1280 -#define PNG_Z_DEFAULT_COMPRESSION (-1) -#define PNG_Z_DEFAULT_NOFILTER_STRATEGY 0 -#define PNG_Z_DEFAULT_STRATEGY 1 -#define PNG_sCAL_PRECISION 5 -#define PNG_sRGB_PROFILE_CHECKS 2 -/* end of settings */ -#endif /* PNGLCONF_H */ diff --git a/android/armeabi/include/spidermonkey/fdlibm.h b/android/armeabi/include/spidermonkey/fdlibm.h deleted file mode 100644 index 0ad21591..00000000 --- a/android/armeabi/include/spidermonkey/fdlibm.h +++ /dev/null @@ -1,65 +0,0 @@ -/* - * ==================================================== - * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - * - * Developed at SunPro, a Sun Microsystems, Inc. business. - * Permission to use, copy, modify, and distribute this - * software is freely granted, provided that this notice - * is preserved. - * ==================================================== - */ - -/* - * from: @(#)fdlibm.h 5.1 93/09/24 - * $FreeBSD$ - */ - -#ifndef mozilla_imported_fdlibm_h -#define mozilla_imported_fdlibm_h - -namespace fdlibm { - -double acos(double); -double asin(double); -double atan(double); -double atan2(double, double); - -double cosh(double); -double sinh(double); -double tanh(double); - -double exp(double); -double log(double); -double log10(double); - -double pow(double, double); -double sqrt(double); -double fabs(double); - -double floor(double); -double trunc(double); -double ceil(double); - -double acosh(double); -double asinh(double); -double atanh(double); -double cbrt(double); -double expm1(double); -double hypot(double, double); -double log1p(double); -double log2(double); -double rint(double); -double copysign(double, double); -double nearbyint(double); -double scalbn(double, int); - -float ceilf(float); -float floorf(float); - -float nearbyintf(float); -float rintf(float); -float truncf(float); - -} /* namespace fdlibm */ - -#endif /* mozilla_imported_fdlibm_h */ diff --git a/android/armeabi/include/spidermonkey/jemalloc_types.h b/android/armeabi/include/spidermonkey/jemalloc_types.h deleted file mode 100644 index ae8dc441..00000000 --- a/android/armeabi/include/spidermonkey/jemalloc_types.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C; tab-width: 8; c-basic-offset: 8 -*- */ -/* vim:set softtabstop=8 shiftwidth=8: */ -/*- - * Copyright (C) 2006-2008 Jason Evans <jasone@FreeBSD.org>. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice(s), this list of conditions and the following disclaimer as - * the first lines of this file unmodified other than the possible - * addition of one or more copyright notices. - * 2. Redistributions in binary form must reproduce the above copyright - * notice(s), this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S) BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR - * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT 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 _JEMALLOC_TYPES_H_ -#define _JEMALLOC_TYPES_H_ - -/* grab size_t */ -#ifdef _MSC_VER -#include <crtdefs.h> -#else -#include <stddef.h> -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef unsigned char jemalloc_bool; - -/* - * jemalloc_stats() is not a stable interface. When using jemalloc_stats_t, be - * sure that the compiled results of jemalloc.c are in sync with this header - * file. - */ -typedef struct { - /* - * Run-time configuration settings. - */ - jemalloc_bool opt_abort; /* abort(3) on error? */ - jemalloc_bool opt_junk; /* Fill allocated memory with 0xe4? */ - jemalloc_bool opt_poison; /* Fill free memory with 0xe5? */ - jemalloc_bool opt_utrace; /* Trace all allocation events? */ - jemalloc_bool opt_sysv; /* SysV semantics? */ - jemalloc_bool opt_xmalloc; /* abort(3) on OOM? */ - jemalloc_bool opt_zero; /* Fill allocated memory with 0x0? */ - size_t narenas; /* Number of arenas. */ - size_t balance_threshold; /* Arena contention rebalance threshold. */ - size_t quantum; /* Allocation quantum. */ - size_t small_max; /* Max quantum-spaced allocation size. */ - size_t large_max; /* Max sub-chunksize allocation size. */ - size_t chunksize; /* Size of each virtual memory mapping. */ - size_t dirty_max; /* Max dirty pages per arena. */ - - /* - * Current memory usage statistics. - */ - size_t mapped; /* Bytes mapped (not necessarily committed). */ - size_t allocated; /* Bytes allocated (committed, in use by application). */ - size_t waste; /* Bytes committed, not in use by the - application, and not intentionally left - unused (i.e., not dirty). */ - size_t page_cache; /* Committed, unused pages kept around as a - cache. (jemalloc calls these "dirty".) */ - size_t bookkeeping; /* Committed bytes used internally by the - allocator. */ - size_t bin_unused; /* Bytes committed to a bin but currently unused. */ -} jemalloc_stats_t; - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -#endif /* _JEMALLOC_TYPES_H_ */ diff --git a/android/armeabi/include/spidermonkey/js-config.h b/android/armeabi/include/spidermonkey/js-config.h deleted file mode 100644 index f21bdf41..00000000 --- a/android/armeabi/include/spidermonkey/js-config.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sw=4 et tw=78: - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_config_h -#define js_config_h - -/* Definitions set at build time that affect SpiderMonkey's public API. - This header file is generated by the SpiderMonkey configure script, - and installed along with jsapi.h. */ - -/* Define to 1 if SpiderMonkey is in debug mode. */ -/* #undef JS_DEBUG */ - -/* - * NB: We have a special case for rust-bindgen, which wants to be able to - * generate both debug and release bindings on a single objdir. - */ -#ifdef JS_DEBUG -#if !defined(DEBUG) && !defined(RUST_BINDGEN) -# error "SpiderMonkey was configured with --enable-debug, so DEBUG must be defined when including this header" -# endif -#else -# if defined(DEBUG) && !defined(RUST_BINDGEN) -# error "SpiderMonkey was configured with --disable-debug, so DEBUG must be not defined when including this header" -# endif -#endif - -/* Define to 1 if SpiderMonkey should not use struct types in debug builds. */ -/* #undef JS_NO_JSVAL_JSID_STRUCT_TYPES */ - -/* Define to 1 if SpiderMonkey should support multi-threaded clients. */ -/* #undef JS_THREADSAFE */ - -/* Define to 1 if SpiderMonkey should include ctypes support. */ -/* #undef JS_HAS_CTYPES */ - -/* Define to 1 if SpiderMonkey should support the ability to perform - entirely too much GC. */ -/* #undef JS_GC_ZEAL */ - -/* Define to 1 if SpiderMonkey should use small chunks. */ -/* #undef JS_GC_SMALL_CHUNK_SIZE */ - -/* Define to 1 to perform extra assertions and heap poisoning. */ -/* #undef JS_CRASH_DIAGNOSTICS */ - -/* Define to 1 if SpiderMonkey is in NUNBOX32 mode. */ -#define JS_NUNBOX32 1 - -/* Define to 1 if SpiderMonkey is in PUNBOX64 mode. */ -/* #undef JS_PUNBOX64 */ - -/* MOZILLA JSAPI version number components */ -#define MOZJS_MAJOR_VERSION 52 -#define MOZJS_MINOR_VERSION 0 - -#endif /* js_config_h */ diff --git a/android/armeabi/include/spidermonkey/js.msg b/android/armeabi/include/spidermonkey/js.msg deleted file mode 100644 index 246e363c..00000000 --- a/android/armeabi/include/spidermonkey/js.msg +++ /dev/null @@ -1,581 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * This is the JavaScript error message file. - * - * The format for each JS error message is: - * - * MSG_DEF(<SYMBOLIC_NAME>, <ARGUMENT_COUNT>, <EXCEPTION_NAME>, - * <FORMAT_STRING>) - * - * where ; - * <SYMBOLIC_NAME> is a legal C identifer that will be used in the - * JS engine source. - * - * <ARGUMENT_COUNT> is an integer literal specifying the total number of - * replaceable arguments in the following format string. - * - * <EXCEPTION_NAME> is an exception index from the enum in jsexn.c; - * JSEXN_NONE for none. The given exception index will be raised by the - * engine when the corresponding error occurs. - * - * <FORMAT_STRING> is a string literal, optionally containing sequences - * {X} where X is an integer representing the argument number that will - * be replaced with a string value when the error is reported. - * - * e.g. - * - * MSG_DEF(JSMSG_NOT_A_SUBSPECIES, 2, JSEXN_NONE, - * "{0} is not a member of the {1} family") - * - * can be used: - * - * JS_ReportErrorNumberASCII(JSMSG_NOT_A_SUBSPECIES, "Rhino", "Monkey"); - * - * to report: - * - * "Rhino is not a member of the Monkey family" - */ - -MSG_DEF(JSMSG_NOT_AN_ERROR, 0, JSEXN_ERR, "<Error #0 is reserved>") -MSG_DEF(JSMSG_NOT_DEFINED, 1, JSEXN_REFERENCEERR, "{0} is not defined") -MSG_DEF(JSMSG_MORE_ARGS_NEEDED, 3, JSEXN_TYPEERR, "{0} requires more than {1} argument{2}") -MSG_DEF(JSMSG_INCOMPATIBLE_PROTO, 3, JSEXN_TYPEERR, "{0}.prototype.{1} called on incompatible {2}") -MSG_DEF(JSMSG_NO_CONSTRUCTOR, 1, JSEXN_TYPEERR, "{0} has no constructor") -MSG_DEF(JSMSG_BAD_SORT_ARG, 0, JSEXN_TYPEERR, "invalid Array.prototype.sort argument") -MSG_DEF(JSMSG_CANT_WATCH, 1, JSEXN_TYPEERR, "can't watch non-native objects of class {0}") -MSG_DEF(JSMSG_READ_ONLY, 1, JSEXN_TYPEERR, "{0} is read-only") -MSG_DEF(JSMSG_CANT_DELETE, 1, JSEXN_TYPEERR, "property {0} is non-configurable and can't be deleted") -MSG_DEF(JSMSG_CANT_TRUNCATE_ARRAY, 0, JSEXN_TYPEERR, "can't delete non-configurable array element") -MSG_DEF(JSMSG_NOT_FUNCTION, 1, JSEXN_TYPEERR, "{0} is not a function") -MSG_DEF(JSMSG_NOT_CONSTRUCTOR, 1, JSEXN_TYPEERR, "{0} is not a constructor") -MSG_DEF(JSMSG_CANT_CONVERT_TO, 2, JSEXN_TYPEERR, "can't convert {0} to {1}") -MSG_DEF(JSMSG_TOPRIMITIVE_NOT_CALLABLE, 2, JSEXN_TYPEERR, "can't convert {0} to {1}: its [Symbol.toPrimitive] property is not a function") -MSG_DEF(JSMSG_TOPRIMITIVE_RETURNED_OBJECT, 2, JSEXN_TYPEERR, "can't convert {0} to {1}: its [Symbol.toPrimitive] method returned an object") -MSG_DEF(JSMSG_NO_PROPERTIES, 1, JSEXN_TYPEERR, "{0} has no properties") -MSG_DEF(JSMSG_BAD_REGEXP_FLAG, 1, JSEXN_SYNTAXERR, "invalid regular expression flag {0}") -MSG_DEF(JSMSG_ARG_INDEX_OUT_OF_RANGE, 1, JSEXN_RANGEERR, "argument {0} accesses an index that is out of range") -MSG_DEF(JSMSG_SPREAD_TOO_LARGE, 0, JSEXN_RANGEERR, "array too large due to spread operand(s)") -MSG_DEF(JSMSG_BAD_WEAKMAP_KEY, 0, JSEXN_TYPEERR, "cannot use the given object as a weak map key") -MSG_DEF(JSMSG_BAD_GETTER_OR_SETTER, 1, JSEXN_TYPEERR, "invalid {0} usage") -MSG_DEF(JSMSG_BAD_ARRAY_LENGTH, 0, JSEXN_RANGEERR, "invalid array length") -MSG_DEF(JSMSG_REDECLARED_VAR, 2, JSEXN_SYNTAXERR, "redeclaration of {0} {1}") -MSG_DEF(JSMSG_UNDECLARED_VAR, 1, JSEXN_REFERENCEERR, "assignment to undeclared variable {0}") -MSG_DEF(JSMSG_GETTER_ONLY, 0, JSEXN_TYPEERR, "setting a property that has only a getter") -MSG_DEF(JSMSG_OVERWRITING_ACCESSOR, 1, JSEXN_TYPEERR, "can't overwrite accessor property {0}") -MSG_DEF(JSMSG_UNDEFINED_PROP, 1, JSEXN_REFERENCEERR, "reference to undefined property {0}") -MSG_DEF(JSMSG_INVALID_MAP_ITERABLE, 1, JSEXN_TYPEERR, "iterable for {0} should have array-like objects") -MSG_DEF(JSMSG_NESTING_GENERATOR, 0, JSEXN_TYPEERR, "already executing generator") -MSG_DEF(JSMSG_INCOMPATIBLE_METHOD, 3, JSEXN_TYPEERR, "{0} {1} called on incompatible {2}") -MSG_DEF(JSMSG_OBJECT_WATCH_DEPRECATED, 0, JSEXN_WARN, "Object.prototype.watch and unwatch are very slow, non-standard, and deprecated; use a getter/setter instead") -MSG_DEF(JSMSG_ARRAYBUFFER_SLICE_DEPRECATED, 0, JSEXN_WARN, "ArrayBuffer.slice is deprecated; use ArrayBuffer.prototype.slice instead") -MSG_DEF(JSMSG_BAD_SURROGATE_CHAR, 1, JSEXN_TYPEERR, "bad surrogate character {0}") -MSG_DEF(JSMSG_UTF8_CHAR_TOO_LARGE, 1, JSEXN_TYPEERR, "UTF-8 character {0} too large") -MSG_DEF(JSMSG_MALFORMED_UTF8_CHAR, 1, JSEXN_TYPEERR, "malformed UTF-8 character sequence at offset {0}") -MSG_DEF(JSMSG_BUILTIN_CTOR_NO_NEW, 1, JSEXN_TYPEERR, "calling a builtin {0} constructor without new is forbidden") -MSG_DEF(JSMSG_BAD_GENERATOR_YIELD, 1, JSEXN_TYPEERR, "yield from closing generator {0}") -MSG_DEF(JSMSG_EMPTY_ARRAY_REDUCE, 0, JSEXN_TYPEERR, "reduce of empty array with no initial value") -MSG_DEF(JSMSG_UNEXPECTED_TYPE, 2, JSEXN_TYPEERR, "{0} is {1}") -MSG_DEF(JSMSG_MISSING_FUN_ARG, 2, JSEXN_TYPEERR, "missing argument {0} when calling function {1}") -MSG_DEF(JSMSG_NOT_NONNULL_OBJECT, 1, JSEXN_TYPEERR, "{0} is not a non-null object") -MSG_DEF(JSMSG_SET_NON_OBJECT_RECEIVER, 1, JSEXN_TYPEERR, "can't assign to properties of {0}: not an object") -MSG_DEF(JSMSG_INVALID_DESCRIPTOR, 0, JSEXN_TYPEERR, "property descriptors must not specify a value or be writable when a getter or setter has been specified") -MSG_DEF(JSMSG_OBJECT_NOT_EXTENSIBLE, 1, JSEXN_TYPEERR, "{0}: Object is not extensible") -MSG_DEF(JSMSG_CANT_DEFINE_PROP_OBJECT_NOT_EXTENSIBLE, 2, JSEXN_TYPEERR, "can't define property {1}: {0} is not extensible") -MSG_DEF(JSMSG_CANT_REDEFINE_PROP, 1, JSEXN_TYPEERR, "can't redefine non-configurable property {0}") -MSG_DEF(JSMSG_CANT_REDEFINE_ARRAY_LENGTH, 0, JSEXN_TYPEERR, "can't redefine array length") -MSG_DEF(JSMSG_CANT_DEFINE_PAST_ARRAY_LENGTH, 0, JSEXN_TYPEERR, "can't define array index property past the end of an array with non-writable length") -MSG_DEF(JSMSG_BAD_GET_SET_FIELD, 1, JSEXN_TYPEERR, "property descriptor's {0} field is neither undefined nor a function") -MSG_DEF(JSMSG_THROW_TYPE_ERROR, 0, JSEXN_TYPEERR, "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them") -MSG_DEF(JSMSG_NOT_EXPECTED_TYPE, 3, JSEXN_TYPEERR, "{0}: expected {1}, got {2}") -MSG_DEF(JSMSG_NOT_ITERABLE, 1, JSEXN_TYPEERR, "{0} is not iterable") -MSG_DEF(JSMSG_NOT_ITERATOR, 1, JSEXN_TYPEERR, "{0} is not iterator") -MSG_DEF(JSMSG_ALREADY_HAS_PRAGMA, 2, JSEXN_WARN, "{0} is being assigned a {1}, but already has one") -MSG_DEF(JSMSG_GET_ITER_RETURNED_PRIMITIVE, 0, JSEXN_TYPEERR, "[Symbol.iterator]() returned a non-object value") -MSG_DEF(JSMSG_NEXT_RETURNED_PRIMITIVE, 0, JSEXN_TYPEERR, "iterator.next() returned a non-object value") -MSG_DEF(JSMSG_CANT_SET_PROTO, 0, JSEXN_TYPEERR, "can't set prototype of this object") -MSG_DEF(JSMSG_CANT_SET_PROTO_OF, 1, JSEXN_TYPEERR, "can't set prototype of {0}") -MSG_DEF(JSMSG_CANT_SET_PROTO_CYCLE, 0, JSEXN_TYPEERR, "can't set prototype: it would cause a prototype chain cycle") -MSG_DEF(JSMSG_INVALID_ARG_TYPE, 3, JSEXN_TYPEERR, "Invalid type: {0} can't be a{1} {2}") -MSG_DEF(JSMSG_TERMINATED, 1, JSEXN_ERR, "Script terminated by timeout at:\n{0}") -MSG_DEF(JSMSG_PROTO_NOT_OBJORNULL, 1, JSEXN_TYPEERR, "{0}.prototype is not an object or null") -MSG_DEF(JSMSG_CANT_CALL_CLASS_CONSTRUCTOR, 0, JSEXN_TYPEERR, "class constructors must be invoked with |new|") -MSG_DEF(JSMSG_UNINITIALIZED_THIS, 1, JSEXN_REFERENCEERR, "|this| used uninitialized in {0} class constructor") -MSG_DEF(JSMSG_UNINITIALIZED_THIS_ARROW, 0, JSEXN_REFERENCEERR, "|this| used uninitialized in arrow function in class constructor") -MSG_DEF(JSMSG_BAD_DERIVED_RETURN, 1, JSEXN_TYPEERR, "derived class constructor returned invalid value {0}") - -// JSON -MSG_DEF(JSMSG_JSON_BAD_PARSE, 3, JSEXN_SYNTAXERR, "JSON.parse: {0} at line {1} column {2} of the JSON data") -MSG_DEF(JSMSG_JSON_CYCLIC_VALUE, 0, JSEXN_TYPEERR, "cyclic object value") - -// Runtime errors -MSG_DEF(JSMSG_BAD_INSTANCEOF_RHS, 1, JSEXN_TYPEERR, "invalid 'instanceof' operand {0}") -MSG_DEF(JSMSG_BAD_LEFTSIDE_OF_ASS, 0, JSEXN_REFERENCEERR, "invalid assignment left-hand side") -MSG_DEF(JSMSG_BAD_PROTOTYPE, 1, JSEXN_TYPEERR, "'prototype' property of {0} is not an object") -MSG_DEF(JSMSG_IN_NOT_OBJECT, 1, JSEXN_TYPEERR, "invalid 'in' operand {0}") -MSG_DEF(JSMSG_TOO_MANY_CON_SPREADARGS, 0, JSEXN_RANGEERR, "too many constructor arguments") -MSG_DEF(JSMSG_TOO_MANY_FUN_SPREADARGS, 0, JSEXN_RANGEERR, "too many function arguments") -MSG_DEF(JSMSG_UNINITIALIZED_LEXICAL, 1, JSEXN_REFERENCEERR, "can't access lexical declaration `{0}' before initialization") -MSG_DEF(JSMSG_BAD_CONST_ASSIGN, 1, JSEXN_TYPEERR, "invalid assignment to const `{0}'") -MSG_DEF(JSMSG_CANT_DECLARE_GLOBAL_BINDING, 2, JSEXN_TYPEERR, "cannot declare global binding `{0}': {1}") - -// Date -MSG_DEF(JSMSG_INVALID_DATE, 0, JSEXN_RANGEERR, "invalid date") -MSG_DEF(JSMSG_BAD_TOISOSTRING_PROP, 0, JSEXN_TYPEERR, "toISOString property is not callable") - -// String -MSG_DEF(JSMSG_BAD_URI, 0, JSEXN_URIERR, "malformed URI sequence") -MSG_DEF(JSMSG_INVALID_NORMALIZE_FORM, 0, JSEXN_RANGEERR, "form must be one of 'NFC', 'NFD', 'NFKC', or 'NFKD'") -MSG_DEF(JSMSG_NEGATIVE_REPETITION_COUNT, 0, JSEXN_RANGEERR, "repeat count must be non-negative") -MSG_DEF(JSMSG_NOT_A_CODEPOINT, 1, JSEXN_RANGEERR, "{0} is not a valid code point") -MSG_DEF(JSMSG_RESULTING_STRING_TOO_LARGE, 0, JSEXN_RANGEERR, "repeat count must be less than infinity and not overflow maximum string size") - -// Number -MSG_DEF(JSMSG_BAD_RADIX, 0, JSEXN_RANGEERR, "radix must be an integer at least 2 and no greater than 36") -MSG_DEF(JSMSG_PRECISION_RANGE, 1, JSEXN_RANGEERR, "precision {0} out of range") - -// Function -MSG_DEF(JSMSG_BAD_APPLY_ARGS, 1, JSEXN_TYPEERR, "second argument to Function.prototype.{0} must be an array") -MSG_DEF(JSMSG_BAD_FORMAL, 0, JSEXN_SYNTAXERR, "malformed formal parameter") -MSG_DEF(JSMSG_CALLER_IS_STRICT, 0, JSEXN_TYPEERR, "access to strict mode caller function is censored") -MSG_DEF(JSMSG_DEPRECATED_USAGE, 1, JSEXN_REFERENCEERR, "deprecated {0} usage") -MSG_DEF(JSMSG_NOT_SCRIPTED_FUNCTION, 1, JSEXN_TYPEERR, "{0} is not a scripted function") -MSG_DEF(JSMSG_NO_REST_NAME, 0, JSEXN_SYNTAXERR, "no parameter name after ...") -MSG_DEF(JSMSG_PARAMETER_AFTER_REST, 0, JSEXN_SYNTAXERR, "parameter after rest parameter") -MSG_DEF(JSMSG_TOO_MANY_ARGUMENTS, 0, JSEXN_RANGEERR, "too many arguments provided for a function call") - -// CSP -MSG_DEF(JSMSG_CSP_BLOCKED_EVAL, 0, JSEXN_ERR, "call to eval() blocked by CSP") -MSG_DEF(JSMSG_CSP_BLOCKED_FUNCTION, 0, JSEXN_ERR, "call to Function() blocked by CSP") - -// Wrappers -MSG_DEF(JSMSG_ACCESSOR_DEF_DENIED, 1, JSEXN_ERR, "Permission denied to define accessor property {0}") -MSG_DEF(JSMSG_DEAD_OBJECT, 0, JSEXN_TYPEERR, "can't access dead object") -MSG_DEF(JSMSG_UNWRAP_DENIED, 0, JSEXN_ERR, "permission denied to unwrap object") - -// JSAPI-only (Not thrown as JS exceptions) -MSG_DEF(JSMSG_BAD_CLONE_FUNOBJ_SCOPE, 0, JSEXN_TYPEERR, "bad cloned function scope chain") -MSG_DEF(JSMSG_CANT_CLONE_OBJECT, 0, JSEXN_TYPEERR, "can't clone object") -MSG_DEF(JSMSG_CANT_OPEN, 2, JSEXN_ERR, "can't open {0}: {1}") -MSG_DEF(JSMSG_USER_DEFINED_ERROR, 0, JSEXN_ERR, "JS_ReportError was called") - -// Internal errors -MSG_DEF(JSMSG_ALLOC_OVERFLOW, 0, JSEXN_INTERNALERR, "allocation size overflow") -MSG_DEF(JSMSG_BAD_BYTECODE, 1, JSEXN_INTERNALERR, "unimplemented JavaScript bytecode {0}") -MSG_DEF(JSMSG_BUFFER_TOO_SMALL, 0, JSEXN_INTERNALERR, "buffer too small") -MSG_DEF(JSMSG_BUILD_ID_NOT_AVAILABLE, 0, JSEXN_INTERNALERR, "build ID is not available") -MSG_DEF(JSMSG_BYTECODE_TOO_BIG, 2, JSEXN_INTERNALERR, "bytecode {0} too large (limit {1})") -MSG_DEF(JSMSG_ERR_DURING_THROW, 0, JSEXN_INTERNALERR, "an internal error occurred while throwing an exception") -MSG_DEF(JSMSG_NEED_DIET, 1, JSEXN_INTERNALERR, "{0} too large") -MSG_DEF(JSMSG_OUT_OF_MEMORY, 0, JSEXN_INTERNALERR, "out of memory") -MSG_DEF(JSMSG_OVER_RECURSED, 0, JSEXN_INTERNALERR, "too much recursion") -MSG_DEF(JSMSG_TOO_BIG_TO_ENCODE, 0, JSEXN_INTERNALERR, "data are to big to encode") -MSG_DEF(JSMSG_TOO_DEEP, 1, JSEXN_INTERNALERR, "{0} nested too deeply") -MSG_DEF(JSMSG_UNCAUGHT_EXCEPTION, 1, JSEXN_INTERNALERR, "uncaught exception: {0}") -MSG_DEF(JSMSG_UNKNOWN_FORMAT, 1, JSEXN_INTERNALERR, "unknown bytecode format {0}") - -// Frontend -MSG_DEF(JSMSG_ACCESSOR_WRONG_ARGS, 3, JSEXN_SYNTAXERR, "{0} functions must have {1} argument{2}") -MSG_DEF(JSMSG_ARRAY_COMP_LEFTSIDE, 0, JSEXN_SYNTAXERR, "invalid array comprehension left-hand side") -MSG_DEF(JSMSG_ARRAY_INIT_TOO_BIG, 0, JSEXN_INTERNALERR, "array initializer too large") -MSG_DEF(JSMSG_AS_AFTER_IMPORT_STAR, 0, JSEXN_SYNTAXERR, "missing keyword 'as' after import *") -MSG_DEF(JSMSG_AS_AFTER_RESERVED_WORD, 1, JSEXN_SYNTAXERR, "missing keyword 'as' after reserved word '{0}'") -MSG_DEF(JSMSG_ASYNC_GENERATOR, 0, JSEXN_SYNTAXERR, "generator function or method can't be async") -MSG_DEF(JSMSG_AWAIT_IN_DEFAULT, 0, JSEXN_SYNTAXERR, "await can't be used in default expression") -MSG_DEF(JSMSG_BAD_ANON_GENERATOR_RETURN, 0, JSEXN_TYPEERR, "anonymous generator function returns a value") -MSG_DEF(JSMSG_BAD_ARROW_ARGS, 0, JSEXN_SYNTAXERR, "invalid arrow-function arguments (parentheses around the arrow-function may help)") -MSG_DEF(JSMSG_BAD_BINDING, 1, JSEXN_SYNTAXERR, "redefining {0} is deprecated") -MSG_DEF(JSMSG_BAD_CONST_DECL, 0, JSEXN_SYNTAXERR, "missing = in const declaration") -MSG_DEF(JSMSG_BAD_CONTINUE, 0, JSEXN_SYNTAXERR, "continue must be inside loop") -MSG_DEF(JSMSG_BAD_DESTRUCT_ASS, 0, JSEXN_REFERENCEERR, "invalid destructuring assignment operator") -MSG_DEF(JSMSG_BAD_DESTRUCT_TARGET, 0, JSEXN_SYNTAXERR, "invalid destructuring target") -MSG_DEF(JSMSG_BAD_DESTRUCT_PARENS, 0, JSEXN_SYNTAXERR, "destructuring patterns in assignments can't be parenthesized") -MSG_DEF(JSMSG_BAD_DESTRUCT_DECL, 0, JSEXN_SYNTAXERR, "missing = in destructuring declaration") -MSG_DEF(JSMSG_BAD_DUP_ARGS, 0, JSEXN_SYNTAXERR, "duplicate argument names not allowed in this context") -MSG_DEF(JSMSG_BAD_FOR_EACH_LOOP, 0, JSEXN_SYNTAXERR, "invalid for each loop") -MSG_DEF(JSMSG_BAD_FOR_LEFTSIDE, 0, JSEXN_SYNTAXERR, "invalid for-in/of left-hand side") -MSG_DEF(JSMSG_LEXICAL_DECL_DEFINES_LET,0, JSEXN_SYNTAXERR, "a lexical declaration can't define a 'let' binding") -MSG_DEF(JSMSG_LET_STARTING_FOROF_LHS, 0, JSEXN_SYNTAXERR, "an expression X in 'for (X of Y)' must not start with 'let'") -MSG_DEF(JSMSG_BAD_GENERATOR_RETURN, 1, JSEXN_TYPEERR, "generator function {0} returns a value") -MSG_DEF(JSMSG_BAD_GENEXP_BODY, 1, JSEXN_SYNTAXERR, "illegal use of {0} in generator expression") -MSG_DEF(JSMSG_BAD_INCOP_OPERAND, 0, JSEXN_REFERENCEERR, "invalid increment/decrement operand") -MSG_DEF(JSMSG_BAD_METHOD_DEF, 0, JSEXN_SYNTAXERR, "bad method definition") -MSG_DEF(JSMSG_BAD_OCTAL, 1, JSEXN_SYNTAXERR, "{0} is not a legal ECMA-262 octal constant") -MSG_DEF(JSMSG_BAD_OPERAND, 1, JSEXN_SYNTAXERR, "invalid {0} operand") -MSG_DEF(JSMSG_BAD_POW_LEFTSIDE, 0, JSEXN_SYNTAXERR, "unparenthesized unary expression can't appear on the left-hand side of '**'") -MSG_DEF(JSMSG_BAD_PROP_ID, 0, JSEXN_SYNTAXERR, "invalid property id") -MSG_DEF(JSMSG_BAD_RETURN_OR_YIELD, 1, JSEXN_SYNTAXERR, "{0} not in function") -MSG_DEF(JSMSG_BAD_STRICT_ASSIGN, 1, JSEXN_SYNTAXERR, "'{0}' can't be defined or assigned to in strict mode code") -MSG_DEF(JSMSG_BAD_SWITCH, 0, JSEXN_SYNTAXERR, "invalid switch statement") -MSG_DEF(JSMSG_BAD_SUPER, 0, JSEXN_SYNTAXERR, "invalid use of keyword 'super'") -MSG_DEF(JSMSG_BAD_SUPERPROP, 1, JSEXN_SYNTAXERR, "use of super {0} accesses only valid within methods or eval code within methods") -MSG_DEF(JSMSG_BAD_SUPERCALL, 0, JSEXN_SYNTAXERR, "super() is only valid in derived class constructors") -MSG_DEF(JSMSG_BRACKET_AFTER_ARRAY_COMPREHENSION, 0, JSEXN_SYNTAXERR, "missing ] after array comprehension") -MSG_DEF(JSMSG_BRACKET_AFTER_LIST, 0, JSEXN_SYNTAXERR, "missing ] after element list") -MSG_DEF(JSMSG_BRACKET_IN_INDEX, 0, JSEXN_SYNTAXERR, "missing ] in index expression") -MSG_DEF(JSMSG_CATCH_AFTER_GENERAL, 0, JSEXN_SYNTAXERR, "catch after unconditional catch") -MSG_DEF(JSMSG_CATCH_IDENTIFIER, 0, JSEXN_SYNTAXERR, "missing identifier in catch") -MSG_DEF(JSMSG_CATCH_OR_FINALLY, 0, JSEXN_SYNTAXERR, "missing catch or finally after try") -MSG_DEF(JSMSG_CATCH_WITHOUT_TRY, 0, JSEXN_SYNTAXERR, "catch without try") -MSG_DEF(JSMSG_COLON_AFTER_CASE, 0, JSEXN_SYNTAXERR, "missing : after case label") -MSG_DEF(JSMSG_COLON_AFTER_ID, 0, JSEXN_SYNTAXERR, "missing : after property id") -MSG_DEF(JSMSG_COLON_IN_COND, 0, JSEXN_SYNTAXERR, "missing : in conditional expression") -MSG_DEF(JSMSG_COMP_PROP_UNTERM_EXPR, 0, JSEXN_SYNTAXERR, "missing ] in computed property name") -MSG_DEF(JSMSG_CONTRARY_NONDIRECTIVE, 1, JSEXN_SYNTAXERR, "'{0}' statement won't be enforced as a directive because it isn't in directive prologue position") -MSG_DEF(JSMSG_CURLY_AFTER_BODY, 0, JSEXN_SYNTAXERR, "missing } after function body") -MSG_DEF(JSMSG_CURLY_AFTER_CATCH, 0, JSEXN_SYNTAXERR, "missing } after catch block") -MSG_DEF(JSMSG_CURLY_AFTER_FINALLY, 0, JSEXN_SYNTAXERR, "missing } after finally block") -MSG_DEF(JSMSG_CURLY_AFTER_LIST, 0, JSEXN_SYNTAXERR, "missing } after property list") -MSG_DEF(JSMSG_CURLY_AFTER_TRY, 0, JSEXN_SYNTAXERR, "missing } after try block") -MSG_DEF(JSMSG_CURLY_BEFORE_BODY, 0, JSEXN_SYNTAXERR, "missing { before function body") -MSG_DEF(JSMSG_CURLY_BEFORE_CATCH, 0, JSEXN_SYNTAXERR, "missing { before catch block") -MSG_DEF(JSMSG_CURLY_BEFORE_CLASS, 0, JSEXN_SYNTAXERR, "missing { before class body") -MSG_DEF(JSMSG_CURLY_BEFORE_FINALLY, 0, JSEXN_SYNTAXERR, "missing { before finally block") -MSG_DEF(JSMSG_CURLY_BEFORE_SWITCH, 0, JSEXN_SYNTAXERR, "missing { before switch body") -MSG_DEF(JSMSG_CURLY_BEFORE_TRY, 0, JSEXN_SYNTAXERR, "missing { before try block") -MSG_DEF(JSMSG_CURLY_IN_COMPOUND, 0, JSEXN_SYNTAXERR, "missing } in compound statement") -MSG_DEF(JSMSG_DECLARATION_AFTER_EXPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'export' keyword") -MSG_DEF(JSMSG_DECLARATION_AFTER_IMPORT,0, JSEXN_SYNTAXERR, "missing declaration after 'import' keyword") -MSG_DEF(JSMSG_DEPRECATED_DELETE_OPERAND, 0, JSEXN_SYNTAXERR, "applying the 'delete' operator to an unqualified name is deprecated") -MSG_DEF(JSMSG_DEPRECATED_EXPR_CLOSURE, 0, JSEXN_WARN, "expression closures are deprecated") -MSG_DEF(JSMSG_DEPRECATED_FOR_EACH, 0, JSEXN_WARN, "JavaScript 1.6's for-each-in loops are deprecated; consider using ES6 for-of instead") -MSG_DEF(JSMSG_DEPRECATED_OCTAL, 0, JSEXN_SYNTAXERR, "\"0\"-prefixed octal literals and octal escape sequences are deprecated; for octal literals use the \"0o\" prefix instead") -MSG_DEF(JSMSG_DEPRECATED_PRAGMA, 1, JSEXN_WARN, "Using //@ to indicate {0} pragmas is deprecated. Use //# instead") -MSG_DEF(JSMSG_DEPRECATED_BLOCK_SCOPE_FUN_REDECL, 1, JSEXN_WARN, "redeclaration of block-scoped function `{0}' is deprecated") -MSG_DEF(JSMSG_DUPLICATE_EXPORT_NAME, 1, JSEXN_SYNTAXERR, "duplicate export name '{0}'") -MSG_DEF(JSMSG_DUPLICATE_FORMAL, 1, JSEXN_SYNTAXERR, "duplicate formal argument {0}") -MSG_DEF(JSMSG_DUPLICATE_LABEL, 0, JSEXN_SYNTAXERR, "duplicate label") -MSG_DEF(JSMSG_DUPLICATE_PROPERTY, 1, JSEXN_SYNTAXERR, "property name {0} appears more than once in object literal") -MSG_DEF(JSMSG_DUPLICATE_PROTO_PROPERTY, 0, JSEXN_SYNTAXERR, "property name __proto__ appears more than once in object literal") -MSG_DEF(JSMSG_EMPTY_CONSEQUENT, 0, JSEXN_SYNTAXERR, "mistyped ; after conditional?") -MSG_DEF(JSMSG_EQUAL_AS_ASSIGN, 0, JSEXN_SYNTAXERR, "test for equality (==) mistyped as assignment (=)?") -MSG_DEF(JSMSG_EXPORT_DECL_AT_TOP_LEVEL,0, JSEXN_SYNTAXERR, "export declarations may only appear at top level of a module") -MSG_DEF(JSMSG_FINALLY_WITHOUT_TRY, 0, JSEXN_SYNTAXERR, "finally without try") -MSG_DEF(JSMSG_FORBIDDEN_AS_STATEMENT, 1, JSEXN_SYNTAXERR, "{0} can't appear in single-statement context") -MSG_DEF(JSMSG_FROM_AFTER_IMPORT_CLAUSE, 0, JSEXN_SYNTAXERR, "missing keyword 'from' after import clause") -MSG_DEF(JSMSG_FROM_AFTER_EXPORT_STAR, 0, JSEXN_SYNTAXERR, "missing keyword 'from' after export *") -MSG_DEF(JSMSG_GARBAGE_AFTER_INPUT, 2, JSEXN_SYNTAXERR, "unexpected garbage after {0}, starting with {1}") -MSG_DEF(JSMSG_IDSTART_AFTER_NUMBER, 0, JSEXN_SYNTAXERR, "identifier starts immediately after numeric literal") -MSG_DEF(JSMSG_ILLEGAL_CHARACTER, 0, JSEXN_SYNTAXERR, "illegal character") -MSG_DEF(JSMSG_IMPORT_DECL_AT_TOP_LEVEL, 0, JSEXN_SYNTAXERR, "import declarations may only appear at top level of a module") -MSG_DEF(JSMSG_INVALID_FOR_IN_DECL_WITH_INIT,0,JSEXN_SYNTAXERR,"for-in loop head declarations may not have initializers") -MSG_DEF(JSMSG_LABEL_NOT_FOUND, 0, JSEXN_SYNTAXERR, "label not found") -MSG_DEF(JSMSG_LET_COMP_BINDING, 0, JSEXN_SYNTAXERR, "'let' is not a valid name for a comprehension variable") -MSG_DEF(JSMSG_LEXICAL_DECL_NOT_IN_BLOCK, 1, JSEXN_SYNTAXERR, "{0} declaration not directly within block") -MSG_DEF(JSMSG_LEXICAL_DECL_LABEL, 1, JSEXN_SYNTAXERR, "{0} declarations cannot be labelled") -MSG_DEF(JSMSG_GENERATOR_LABEL, 0, JSEXN_SYNTAXERR, "generator functions cannot be labelled") -MSG_DEF(JSMSG_FUNCTION_LABEL, 0, JSEXN_SYNTAXERR, "functions cannot be labelled") -MSG_DEF(JSMSG_SLOPPY_FUNCTION_LABEL, 0, JSEXN_SYNTAXERR, "functions can only be labelled inside blocks") -MSG_DEF(JSMSG_LINE_BREAK_AFTER_THROW, 0, JSEXN_SYNTAXERR, "no line break is allowed between 'throw' and its expression") -MSG_DEF(JSMSG_LINE_BREAK_BEFORE_ARROW, 0, JSEXN_SYNTAXERR, "no line break is allowed before '=>'") -MSG_DEF(JSMSG_MALFORMED_ESCAPE, 1, JSEXN_SYNTAXERR, "malformed {0} character escape sequence") -MSG_DEF(JSMSG_MISSING_BINARY_DIGITS, 0, JSEXN_SYNTAXERR, "missing binary digits after '0b'") -MSG_DEF(JSMSG_MISSING_EXPONENT, 0, JSEXN_SYNTAXERR, "missing exponent") -MSG_DEF(JSMSG_MISSING_EXPR_AFTER_THROW,0, JSEXN_SYNTAXERR, "throw statement is missing an expression") -MSG_DEF(JSMSG_MISSING_FORMAL, 0, JSEXN_SYNTAXERR, "missing formal parameter") -MSG_DEF(JSMSG_MISSING_HEXDIGITS, 0, JSEXN_SYNTAXERR, "missing hexadecimal digits after '0x'") -MSG_DEF(JSMSG_MISSING_OCTAL_DIGITS, 0, JSEXN_SYNTAXERR, "missing octal digits after '0o'") -MSG_DEF(JSMSG_MODULE_SPEC_AFTER_FROM, 0, JSEXN_SYNTAXERR, "missing module specifier after 'from' keyword") -MSG_DEF(JSMSG_NAME_AFTER_DOT, 0, JSEXN_SYNTAXERR, "missing name after . operator") -MSG_DEF(JSMSG_NAMED_IMPORTS_OR_NAMESPACE_IMPORT, 0, JSEXN_SYNTAXERR, "expected named imports or namespace import after comma") -MSG_DEF(JSMSG_NO_BINDING_NAME, 0, JSEXN_SYNTAXERR, "missing binding name") -MSG_DEF(JSMSG_NO_EXPORT_NAME, 0, JSEXN_SYNTAXERR, "missing export name") -MSG_DEF(JSMSG_NO_IMPORT_NAME, 0, JSEXN_SYNTAXERR, "missing import name") -MSG_DEF(JSMSG_NO_VARIABLE_NAME, 0, JSEXN_SYNTAXERR, "missing variable name") -MSG_DEF(JSMSG_OF_AFTER_FOR_NAME, 0, JSEXN_SYNTAXERR, "missing 'of' after for") -MSG_DEF(JSMSG_PAREN_AFTER_ARGS, 0, JSEXN_SYNTAXERR, "missing ) after argument list") -MSG_DEF(JSMSG_PAREN_AFTER_CATCH, 0, JSEXN_SYNTAXERR, "missing ) after catch") -MSG_DEF(JSMSG_PAREN_AFTER_COND, 0, JSEXN_SYNTAXERR, "missing ) after condition") -MSG_DEF(JSMSG_PAREN_AFTER_FOR, 0, JSEXN_SYNTAXERR, "missing ( after for") -MSG_DEF(JSMSG_PAREN_AFTER_FORMAL, 0, JSEXN_SYNTAXERR, "missing ) after formal parameters") -MSG_DEF(JSMSG_PAREN_AFTER_FOR_CTRL, 0, JSEXN_SYNTAXERR, "missing ) after for-loop control") -MSG_DEF(JSMSG_PAREN_AFTER_FOR_OF_ITERABLE, 0, JSEXN_SYNTAXERR, "missing ) after for-of iterable") -MSG_DEF(JSMSG_PAREN_AFTER_SWITCH, 0, JSEXN_SYNTAXERR, "missing ) after switch expression") -MSG_DEF(JSMSG_PAREN_AFTER_WITH, 0, JSEXN_SYNTAXERR, "missing ) after with-statement object") -MSG_DEF(JSMSG_PAREN_BEFORE_CATCH, 0, JSEXN_SYNTAXERR, "missing ( before catch") -MSG_DEF(JSMSG_PAREN_BEFORE_COND, 0, JSEXN_SYNTAXERR, "missing ( before condition") -MSG_DEF(JSMSG_PAREN_BEFORE_FORMAL, 0, JSEXN_SYNTAXERR, "missing ( before formal parameters") -MSG_DEF(JSMSG_PAREN_BEFORE_SWITCH, 0, JSEXN_SYNTAXERR, "missing ( before switch expression") -MSG_DEF(JSMSG_PAREN_BEFORE_WITH, 0, JSEXN_SYNTAXERR, "missing ( before with-statement object") -MSG_DEF(JSMSG_PAREN_IN_PAREN, 0, JSEXN_SYNTAXERR, "missing ) in parenthetical") -MSG_DEF(JSMSG_RC_AFTER_EXPORT_SPEC_LIST, 0, JSEXN_SYNTAXERR, "missing '}' after export specifier list") -MSG_DEF(JSMSG_RC_AFTER_IMPORT_SPEC_LIST, 0, JSEXN_SYNTAXERR, "missing '}' after module specifier list") -MSG_DEF(JSMSG_REDECLARED_CATCH_IDENTIFIER, 1, JSEXN_SYNTAXERR, "redeclaration of identifier '{0}' in catch") -MSG_DEF(JSMSG_RESERVED_ID, 1, JSEXN_SYNTAXERR, "{0} is a reserved identifier") -MSG_DEF(JSMSG_REST_WITH_COMMA, 0, JSEXN_SYNTAXERR, "rest element may not have a trailing comma") -MSG_DEF(JSMSG_REST_WITH_DEFAULT, 0, JSEXN_SYNTAXERR, "rest parameter may not have a default") -MSG_DEF(JSMSG_SELFHOSTED_TOP_LEVEL_LEXICAL, 1, JSEXN_SYNTAXERR, "self-hosted code cannot contain top-level {0} declarations") -MSG_DEF(JSMSG_SELFHOSTED_METHOD_CALL, 0, JSEXN_SYNTAXERR, "self-hosted code may not contain direct method calls. Use callFunction() or callContentFunction()") -MSG_DEF(JSMSG_SELFHOSTED_UNBOUND_NAME, 0, JSEXN_TYPEERR, "self-hosted code may not contain unbound name lookups") -MSG_DEF(JSMSG_SEMI_AFTER_FOR_COND, 0, JSEXN_SYNTAXERR, "missing ; after for-loop condition") -MSG_DEF(JSMSG_SEMI_AFTER_FOR_INIT, 0, JSEXN_SYNTAXERR, "missing ; after for-loop initializer") -MSG_DEF(JSMSG_SEMI_BEFORE_STMNT, 0, JSEXN_SYNTAXERR, "missing ; before statement") -MSG_DEF(JSMSG_SOURCE_TOO_LONG, 0, JSEXN_RANGEERR, "source is too long") -MSG_DEF(JSMSG_STMT_AFTER_RETURN, 0, JSEXN_WARN, "unreachable code after return statement") -MSG_DEF(JSMSG_STRICT_CODE_WITH, 0, JSEXN_SYNTAXERR, "strict mode code may not contain 'with' statements") -MSG_DEF(JSMSG_STRICT_NON_SIMPLE_PARAMS, 1, JSEXN_SYNTAXERR, "\"use strict\" not allowed in function with {0} parameter") -MSG_DEF(JSMSG_TEMPLSTR_UNTERM_EXPR, 0, JSEXN_SYNTAXERR, "missing } in template string") -MSG_DEF(JSMSG_SIMD_NOT_A_VECTOR, 2, JSEXN_TYPEERR, "expecting a SIMD {0} object as argument {1}") -MSG_DEF(JSMSG_TOO_MANY_CASES, 0, JSEXN_INTERNALERR, "too many switch cases") -MSG_DEF(JSMSG_TOO_MANY_CATCH_VARS, 0, JSEXN_SYNTAXERR, "too many catch variables") -MSG_DEF(JSMSG_TOO_MANY_CON_ARGS, 0, JSEXN_SYNTAXERR, "too many constructor arguments") -MSG_DEF(JSMSG_TOO_MANY_DEFAULTS, 0, JSEXN_SYNTAXERR, "more than one switch default") -MSG_DEF(JSMSG_TOO_MANY_FUN_ARGS, 0, JSEXN_SYNTAXERR, "too many function arguments") -MSG_DEF(JSMSG_TOO_MANY_LOCALS, 0, JSEXN_SYNTAXERR, "too many local variables") -MSG_DEF(JSMSG_TOO_MANY_YIELDS, 0, JSEXN_SYNTAXERR, "too many yield expressions") -MSG_DEF(JSMSG_TOUGH_BREAK, 0, JSEXN_SYNTAXERR, "unlabeled break must be inside loop or switch") -MSG_DEF(JSMSG_UNEXPECTED_TOKEN, 2, JSEXN_SYNTAXERR, "expected {0}, got {1}") -MSG_DEF(JSMSG_UNNAMED_CLASS_STMT, 0, JSEXN_SYNTAXERR, "class statement requires a name") -MSG_DEF(JSMSG_UNNAMED_FUNCTION_STMT, 0, JSEXN_SYNTAXERR, "function statement requires a name") -MSG_DEF(JSMSG_UNTERMINATED_COMMENT, 0, JSEXN_SYNTAXERR, "unterminated comment") -MSG_DEF(JSMSG_UNTERMINATED_REGEXP, 0, JSEXN_SYNTAXERR, "unterminated regular expression literal") -MSG_DEF(JSMSG_UNTERMINATED_STRING, 0, JSEXN_SYNTAXERR, "unterminated string literal") -MSG_DEF(JSMSG_USELESS_EXPR, 0, JSEXN_TYPEERR, "useless expression") -MSG_DEF(JSMSG_USE_ASM_DIRECTIVE_FAIL, 0, JSEXN_SYNTAXERR, "\"use asm\" is only meaningful in the Directive Prologue of a function body") -MSG_DEF(JSMSG_VAR_HIDES_ARG, 1, JSEXN_TYPEERR, "variable {0} redeclares argument") -MSG_DEF(JSMSG_WHILE_AFTER_DO, 0, JSEXN_SYNTAXERR, "missing while after do-loop body") -MSG_DEF(JSMSG_YIELD_IN_ARROW, 0, JSEXN_SYNTAXERR, "arrow function may not contain yield") -MSG_DEF(JSMSG_YIELD_IN_DEFAULT, 0, JSEXN_SYNTAXERR, "yield in default expression") -MSG_DEF(JSMSG_YIELD_IN_METHOD, 0, JSEXN_SYNTAXERR, "non-generator method definitions may not contain yield") -MSG_DEF(JSMSG_BAD_COLUMN_NUMBER, 0, JSEXN_RANGEERR, "column number out of range") -MSG_DEF(JSMSG_COMPUTED_NAME_IN_PATTERN,0, JSEXN_SYNTAXERR, "computed property names aren't supported in this destructuring declaration") -MSG_DEF(JSMSG_DEFAULT_IN_PATTERN, 0, JSEXN_SYNTAXERR, "destructuring defaults aren't supported in this destructuring declaration") -MSG_DEF(JSMSG_BAD_NEWTARGET, 0, JSEXN_SYNTAXERR, "new.target only allowed within functions") -MSG_DEF(JSMSG_ESCAPED_KEYWORD, 0, JSEXN_SYNTAXERR, "keywords must be written literally, without embedded escapes") - -// asm.js -MSG_DEF(JSMSG_USE_ASM_TYPE_FAIL, 1, JSEXN_TYPEERR, "asm.js type error: {0}") -MSG_DEF(JSMSG_USE_ASM_LINK_FAIL, 1, JSEXN_TYPEERR, "asm.js link error: {0}") -MSG_DEF(JSMSG_USE_ASM_TYPE_OK, 1, JSEXN_WARN, "Successfully compiled asm.js code ({0})") - -// wasm -MSG_DEF(JSMSG_WASM_COMPILE_ERROR, 1, JSEXN_WASMCOMPILEERROR, "{0}") -MSG_DEF(JSMSG_WASM_IND_CALL_TO_NULL, 0, JSEXN_WASMRUNTIMEERROR, "indirect call to null") -MSG_DEF(JSMSG_WASM_IND_CALL_BAD_SIG, 0, JSEXN_WASMRUNTIMEERROR, "indirect call signature mismatch") -MSG_DEF(JSMSG_WASM_UNREACHABLE, 0, JSEXN_WASMRUNTIMEERROR, "unreachable executed") -MSG_DEF(JSMSG_WASM_INTEGER_OVERFLOW, 0, JSEXN_WASMRUNTIMEERROR, "integer overflow") -MSG_DEF(JSMSG_WASM_INVALID_CONVERSION, 0, JSEXN_WASMRUNTIMEERROR, "invalid conversion to integer") -MSG_DEF(JSMSG_WASM_INT_DIVIDE_BY_ZERO, 0, JSEXN_WASMRUNTIMEERROR, "integer divide by zero") -MSG_DEF(JSMSG_WASM_OUT_OF_BOUNDS, 0, JSEXN_WASMRUNTIMEERROR, "index out of bounds") -MSG_DEF(JSMSG_WASM_UNALIGNED_ACCESS, 0, JSEXN_WASMRUNTIMEERROR, "unaligned memory access") -MSG_DEF(JSMSG_WASM_BAD_UINT32, 2, JSEXN_RANGEERR, "bad {0} {1}") -MSG_DEF(JSMSG_WASM_BAD_GROW, 1, JSEXN_RANGEERR, "failed to grow {0}") -MSG_DEF(JSMSG_WASM_BAD_FIT, 2, JSEXN_RANGEERR, "{0} segment does not fit in {1}") -MSG_DEF(JSMSG_WASM_BAD_BUF_ARG, 0, JSEXN_TYPEERR, "first argument must be an ArrayBuffer or typed array object") -MSG_DEF(JSMSG_WASM_BAD_MOD_ARG, 0, JSEXN_TYPEERR, "first argument must be a WebAssembly.Module") -MSG_DEF(JSMSG_WASM_BAD_BUF_MOD_ARG, 0, JSEXN_TYPEERR, "first argument must be a WebAssembly.Module, ArrayBuffer or typed array object") -MSG_DEF(JSMSG_WASM_BAD_DESC_ARG, 1, JSEXN_TYPEERR, "first argument must be a {0} descriptor") -MSG_DEF(JSMSG_WASM_BAD_IMP_SIZE, 1, JSEXN_TYPEERR, "imported {0} with incompatible size") -MSG_DEF(JSMSG_WASM_BAD_IMP_MAX, 1, JSEXN_TYPEERR, "imported {0} with incompatible maximum size") -MSG_DEF(JSMSG_WASM_BAD_ELEMENT, 0, JSEXN_TYPEERR, "\"element\" property of table descriptor must be \"anyfunc\"") -MSG_DEF(JSMSG_WASM_BAD_IMPORT_ARG, 0, JSEXN_TYPEERR, "second argument must be an object") -MSG_DEF(JSMSG_WASM_BAD_IMPORT_FIELD, 2, JSEXN_TYPEERR, "import object field '{0}' is not {1}") -MSG_DEF(JSMSG_WASM_BAD_IMPORT_SIG, 0, JSEXN_TYPEERR, "imported function signature mismatch") -MSG_DEF(JSMSG_WASM_BAD_TABLE_VALUE, 0, JSEXN_TYPEERR, "can only assign WebAssembly exported functions to Table") -MSG_DEF(JSMSG_WASM_BAD_I64, 0, JSEXN_TYPEERR, "cannot pass i64 to or from JS") -MSG_DEF(JSMSG_WASM_NO_TRANSFER, 0, JSEXN_TYPEERR, "cannot transfer WebAssembly/asm.js ArrayBuffer") -MSG_DEF(JSMSG_WASM_TEXT_FAIL, 1, JSEXN_SYNTAXERR, "wasm text error: {0}") - -// Proxy -MSG_DEF(JSMSG_BAD_TRAP_RETURN_VALUE, 2, JSEXN_TYPEERR,"trap {1} for {0} returned a primitive value") -MSG_DEF(JSMSG_BAD_GETPROTOTYPEOF_TRAP_RETURN,0,JSEXN_TYPEERR,"proxy getPrototypeOf handler returned a non-object, non-null value") -MSG_DEF(JSMSG_INCONSISTENT_GETPROTOTYPEOF_TRAP,0,JSEXN_TYPEERR,"proxy getPrototypeOf handler didn't return the target object's prototype") -MSG_DEF(JSMSG_PROXY_SETPROTOTYPEOF_RETURNED_FALSE, 0, JSEXN_TYPEERR, "proxy setPrototypeOf handler returned false") -MSG_DEF(JSMSG_PROXY_ISEXTENSIBLE_RETURNED_FALSE,0,JSEXN_TYPEERR,"proxy isExtensible handler must return the same extensibility as target") -MSG_DEF(JSMSG_INCONSISTENT_SETPROTOTYPEOF_TRAP,0,JSEXN_TYPEERR,"proxy setPrototypeOf handler returned true, even though the target's prototype is immutable because the target is non-extensible") -MSG_DEF(JSMSG_CANT_CHANGE_EXTENSIBILITY, 0, JSEXN_TYPEERR, "can't change object's extensibility") -MSG_DEF(JSMSG_CANT_DEFINE_INVALID, 0, JSEXN_TYPEERR, "proxy can't define an incompatible property descriptor") -MSG_DEF(JSMSG_CANT_DEFINE_NEW, 0, JSEXN_TYPEERR, "proxy can't define a new property on a non-extensible object") -MSG_DEF(JSMSG_CANT_DEFINE_NE_AS_NC, 0, JSEXN_TYPEERR, "proxy can't define a non-existent property as non-configurable") -MSG_DEF(JSMSG_PROXY_DEFINE_RETURNED_FALSE, 1, JSEXN_TYPEERR, "proxy defineProperty handler returned false for property '{0}'") -MSG_DEF(JSMSG_PROXY_DELETE_RETURNED_FALSE, 1, JSEXN_TYPEERR, "can't delete property '{0}': proxy deleteProperty handler returned false") -MSG_DEF(JSMSG_PROXY_PREVENTEXTENSIONS_RETURNED_FALSE, 0, JSEXN_TYPEERR, "proxy preventExtensions handler returned false") -MSG_DEF(JSMSG_PROXY_SET_RETURNED_FALSE, 1, JSEXN_TYPEERR, "proxy set handler returned false for property '{0}'") -MSG_DEF(JSMSG_CANT_REPORT_AS_NON_EXTENSIBLE, 0, JSEXN_TYPEERR, "proxy can't report an extensible object as non-extensible") -MSG_DEF(JSMSG_CANT_REPORT_C_AS_NC, 0, JSEXN_TYPEERR, "proxy can't report existing configurable property as non-configurable") -MSG_DEF(JSMSG_CANT_REPORT_E_AS_NE, 0, JSEXN_TYPEERR, "proxy can't report an existing own property as non-existent on a non-extensible object") -MSG_DEF(JSMSG_CANT_REPORT_INVALID, 0, JSEXN_TYPEERR, "proxy can't report an incompatible property descriptor") -MSG_DEF(JSMSG_CANT_REPORT_NC_AS_NE, 0, JSEXN_TYPEERR, "proxy can't report a non-configurable own property as non-existent") -MSG_DEF(JSMSG_CANT_REPORT_NEW, 0, JSEXN_TYPEERR, "proxy can't report a new property on a non-extensible object") -MSG_DEF(JSMSG_CANT_REPORT_NE_AS_NC, 0, JSEXN_TYPEERR, "proxy can't report a non-existent property as non-configurable") -MSG_DEF(JSMSG_CANT_SET_NW_NC, 0, JSEXN_TYPEERR, "proxy can't successfully set a non-writable, non-configurable property") -MSG_DEF(JSMSG_CANT_SET_WO_SETTER, 0, JSEXN_TYPEERR, "proxy can't succesfully set an accessor property without a setter") -MSG_DEF(JSMSG_CANT_SKIP_NC, 0, JSEXN_TYPEERR, "proxy can't skip a non-configurable property") -MSG_DEF(JSMSG_ONWKEYS_STR_SYM, 0, JSEXN_TYPEERR, "proxy [[OwnPropertyKeys]] must return an array with only string and symbol elements") -MSG_DEF(JSMSG_MUST_REPORT_SAME_VALUE, 0, JSEXN_TYPEERR, "proxy must report the same value for a non-writable, non-configurable property") -MSG_DEF(JSMSG_MUST_REPORT_UNDEFINED, 0, JSEXN_TYPEERR, "proxy must report undefined for a non-configurable accessor property without a getter") -MSG_DEF(JSMSG_OBJECT_ACCESS_DENIED, 0, JSEXN_ERR, "Permission denied to access object") -MSG_DEF(JSMSG_PROPERTY_ACCESS_DENIED, 1, JSEXN_ERR, "Permission denied to access property {0}") -MSG_DEF(JSMSG_PROXY_CONSTRUCT_OBJECT, 0, JSEXN_TYPEERR, "proxy [[Construct]] must return an object") -MSG_DEF(JSMSG_PROXY_EXTENSIBILITY, 0, JSEXN_TYPEERR, "proxy must report same extensiblitity as target") -MSG_DEF(JSMSG_PROXY_GETOWN_OBJORUNDEF, 0, JSEXN_TYPEERR, "proxy [[GetOwnProperty]] must return an object or undefined") -MSG_DEF(JSMSG_PROXY_REVOKED, 0, JSEXN_TYPEERR, "illegal operation attempted on a revoked proxy") -MSG_DEF(JSMSG_PROXY_ARG_REVOKED, 1, JSEXN_TYPEERR, "argument {0} cannot be a revoked proxy") -MSG_DEF(JSMSG_BAD_TRAP, 1, JSEXN_TYPEERR, "proxy handler's {0} trap wasn't undefined, null, or callable") - -// Structured cloning -MSG_DEF(JSMSG_SC_BAD_CLONE_VERSION, 0, JSEXN_ERR, "unsupported structured clone version") -MSG_DEF(JSMSG_SC_BAD_SERIALIZED_DATA, 1, JSEXN_INTERNALERR, "bad serialized structured data ({0})") -MSG_DEF(JSMSG_SC_DUP_TRANSFERABLE, 0, JSEXN_TYPEERR, "duplicate transferable for structured clone") -MSG_DEF(JSMSG_SC_NOT_TRANSFERABLE, 0, JSEXN_TYPEERR, "invalid transferable array for structured clone") -MSG_DEF(JSMSG_SC_UNSUPPORTED_TYPE, 0, JSEXN_TYPEERR, "unsupported type for structured data") -MSG_DEF(JSMSG_SC_NOT_CLONABLE, 1, JSEXN_TYPEERR, "{0} cannot be cloned in this context") -MSG_DEF(JSMSG_SC_SAB_TRANSFER, 0, JSEXN_WARN, "SharedArrayBuffer must not be in the transfer list") -MSG_DEF(JSMSG_SC_SAB_DISABLED, 0, JSEXN_TYPEERR, "SharedArrayBuffer not cloned - shared memory disabled in receiver") - -// Debugger -MSG_DEF(JSMSG_ASSIGN_FUNCTION_OR_NULL, 1, JSEXN_TYPEERR, "value assigned to {0} must be a function or null") -MSG_DEF(JSMSG_DEBUG_BAD_AWAIT, 0, JSEXN_TYPEERR, "await expression received invalid value") -MSG_DEF(JSMSG_DEBUG_BAD_LINE, 0, JSEXN_TYPEERR, "invalid line number") -MSG_DEF(JSMSG_DEBUG_BAD_OFFSET, 0, JSEXN_TYPEERR, "invalid script offset") -MSG_DEF(JSMSG_DEBUG_BAD_REFERENT, 2, JSEXN_TYPEERR, "{0} does not refer to {1}") -MSG_DEF(JSMSG_DEBUG_BAD_RESUMPTION, 0, JSEXN_TYPEERR, "debugger resumption value must be undefined, {throw: val}, {return: val}, or null") -MSG_DEF(JSMSG_DEBUG_BAD_YIELD, 0, JSEXN_TYPEERR, "generator yielded invalid value") -MSG_DEF(JSMSG_DEBUG_CANT_DEBUG_GLOBAL, 0, JSEXN_TYPEERR, "passing non-debuggable global to addDebuggee") -MSG_DEF(JSMSG_DEBUG_CCW_REQUIRED, 1, JSEXN_TYPEERR, "{0}: argument must be an object from a different compartment") -MSG_DEF(JSMSG_DEBUG_COMPARTMENT_MISMATCH, 2, JSEXN_TYPEERR, "{0}: descriptor .{1} property is an object in a different compartment than the target object") -MSG_DEF(JSMSG_DEBUG_LOOP, 0, JSEXN_TYPEERR, "cannot debug an object in same compartment as debugger or a compartment that is already debugging the debugger") -MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGEE, 2, JSEXN_ERR, "{0} is not a debuggee {1}") -MSG_DEF(JSMSG_DEBUG_NOT_DEBUGGING, 0, JSEXN_ERR, "can't set breakpoint: script global is not a debuggee") -MSG_DEF(JSMSG_DEBUG_NOT_IDLE, 0, JSEXN_ERR, "can't start debugging: a debuggee script is on the stack") -MSG_DEF(JSMSG_DEBUG_NOT_LIVE, 1, JSEXN_ERR, "{0} is not live") -MSG_DEF(JSMSG_DEBUG_NO_ENV_OBJECT, 0, JSEXN_TYPEERR, "declarative Environments don't have binding objects") -MSG_DEF(JSMSG_DEBUG_PROTO, 2, JSEXN_TYPEERR, "{0}.prototype is not a valid {1} instance") -MSG_DEF(JSMSG_DEBUG_WRONG_OWNER, 1, JSEXN_TYPEERR, "{0} belongs to a different Debugger") -MSG_DEF(JSMSG_DEBUG_OPTIMIZED_OUT, 1, JSEXN_ERR, "variable `{0}' has been optimized out") -MSG_DEF(JSMSG_DEBUG_RESUMPTION_VALUE_DISALLOWED, 0, JSEXN_TYPEERR, "resumption values are disallowed in this hook") -MSG_DEF(JSMSG_DEBUG_VARIABLE_NOT_FOUND,0, JSEXN_TYPEERR, "variable not found in environment") -MSG_DEF(JSMSG_DEBUG_WRAPPER_IN_WAY, 3, JSEXN_TYPEERR, "{0} is {1}{2}a global object, but a direct reference is required") -MSG_DEF(JSMSG_DEBUGGEE_WOULD_RUN, 2, JSEXN_DEBUGGEEWOULDRUN, "debuggee `{0}:{1}' would run") -MSG_DEF(JSMSG_NOT_CALLABLE_OR_UNDEFINED, 0, JSEXN_TYPEERR, "value is not a function or undefined") -MSG_DEF(JSMSG_NOT_TRACKING_ALLOCATIONS, 1, JSEXN_ERR, "Cannot call {0} without setting trackingAllocationSites to true") -MSG_DEF(JSMSG_OBJECT_METADATA_CALLBACK_ALREADY_SET, 0, JSEXN_ERR, "Cannot track object allocation, because other tools are already doing so") -MSG_DEF(JSMSG_QUERY_INNERMOST_WITHOUT_LINE_URL, 0, JSEXN_TYPEERR, "findScripts query object with 'innermost' property must have 'line' and either 'displayURL', 'url', or 'source'") -MSG_DEF(JSMSG_QUERY_LINE_WITHOUT_URL, 0, JSEXN_TYPEERR, "findScripts query object has 'line' property, but no 'displayURL', 'url', or 'source' property") -MSG_DEF(JSMSG_DEBUG_CANT_SET_OPT_ENV, 1, JSEXN_REFERENCEERR, "can't set `{0}' in an optimized-out environment") -MSG_DEF(JSMSG_DEBUG_INVISIBLE_COMPARTMENT, 0, JSEXN_TYPEERR, "object in compartment marked as invisible to Debugger") -MSG_DEF(JSMSG_DEBUG_CENSUS_BREAKDOWN, 1, JSEXN_TYPEERR, "unrecognized 'by' value in takeCensus breakdown: {0}") -MSG_DEF(JSMSG_DEBUG_PROMISE_NOT_RESOLVED, 0, JSEXN_TYPEERR, "Promise hasn't been resolved") -MSG_DEF(JSMSG_DEBUG_PROMISE_NOT_FULFILLED, 0, JSEXN_TYPEERR, "Promise hasn't been fulfilled") -MSG_DEF(JSMSG_DEBUG_PROMISE_NOT_REJECTED, 0, JSEXN_TYPEERR, "Promise hasn't been rejected") - -// Tracelogger -MSG_DEF(JSMSG_TRACELOGGER_ENABLE_FAIL, 1, JSEXN_ERR, "enabling tracelogger failed: {0}") - -// Intl -MSG_DEF(JSMSG_DATE_NOT_FINITE, 0, JSEXN_RANGEERR, "date value is not finite in DateTimeFormat.format()") -MSG_DEF(JSMSG_INTERNAL_INTL_ERROR, 0, JSEXN_ERR, "internal error while computing Intl data") -MSG_DEF(JSMSG_INTL_OBJECT_NOT_INITED, 3, JSEXN_TYPEERR, "Intl.{0}.prototype.{1} called on value that's not an object initialized as a {2}") -MSG_DEF(JSMSG_INTL_OBJECT_REINITED, 0, JSEXN_TYPEERR, "can't initialize object twice as an object of an Intl constructor") -MSG_DEF(JSMSG_INVALID_CURRENCY_CODE, 1, JSEXN_RANGEERR, "invalid currency code in NumberFormat(): {0}") -MSG_DEF(JSMSG_INVALID_DIGITS_VALUE, 1, JSEXN_RANGEERR, "invalid digits value: {0}") -MSG_DEF(JSMSG_INVALID_LANGUAGE_TAG, 1, JSEXN_RANGEERR, "invalid language tag: {0}") -MSG_DEF(JSMSG_INVALID_LOCALES_ELEMENT, 0, JSEXN_TYPEERR, "invalid element in locales argument") -MSG_DEF(JSMSG_INVALID_LOCALE_MATCHER, 1, JSEXN_RANGEERR, "invalid locale matcher in supportedLocalesOf(): {0}") -MSG_DEF(JSMSG_INVALID_OPTION_VALUE, 2, JSEXN_RANGEERR, "invalid value {1} for option {0}") -MSG_DEF(JSMSG_INVALID_TIME_ZONE, 1, JSEXN_RANGEERR, "invalid time zone in DateTimeFormat(): {0}") -MSG_DEF(JSMSG_UNDEFINED_CURRENCY, 0, JSEXN_TYPEERR, "undefined currency in NumberFormat() with currency style") - -// RegExp -MSG_DEF(JSMSG_BACK_REF_OUT_OF_RANGE, 0, JSEXN_SYNTAXERR, "back reference out of range in regular expression") -MSG_DEF(JSMSG_BAD_CLASS_RANGE, 0, JSEXN_SYNTAXERR, "invalid range in character class") -MSG_DEF(JSMSG_ESCAPE_AT_END_OF_REGEXP, 0, JSEXN_SYNTAXERR, "\\ at end of pattern") -MSG_DEF(JSMSG_EXEC_NOT_OBJORNULL, 0, JSEXN_TYPEERR, "RegExp exec method should return object or null") -MSG_DEF(JSMSG_INVALID_DECIMAL_ESCAPE, 0, JSEXN_SYNTAXERR, "invalid decimal escape in regular expression") -MSG_DEF(JSMSG_INVALID_GROUP, 0, JSEXN_SYNTAXERR, "invalid regexp group") -MSG_DEF(JSMSG_INVALID_IDENTITY_ESCAPE, 0, JSEXN_SYNTAXERR, "invalid identity escape in regular expression") -MSG_DEF(JSMSG_INVALID_UNICODE_ESCAPE, 0, JSEXN_SYNTAXERR, "invalid unicode escape in regular expression") -MSG_DEF(JSMSG_MISSING_PAREN, 0, JSEXN_SYNTAXERR, "unterminated parenthetical") -MSG_DEF(JSMSG_NEWREGEXP_FLAGGED, 0, JSEXN_TYPEERR, "can't supply flags when constructing one RegExp from another") -MSG_DEF(JSMSG_NOTHING_TO_REPEAT, 0, JSEXN_SYNTAXERR, "nothing to repeat") -MSG_DEF(JSMSG_NUMBERS_OUT_OF_ORDER, 0, JSEXN_SYNTAXERR, "numbers out of order in {} quantifier.") -MSG_DEF(JSMSG_RANGE_WITH_CLASS_ESCAPE, 0, JSEXN_SYNTAXERR, "character class escape cannot be used in class range in regular expression") -MSG_DEF(JSMSG_RAW_BRACE_IN_REGEP, 0, JSEXN_SYNTAXERR, "raw brace is not allowed in regular expression with unicode flag") -MSG_DEF(JSMSG_RAW_BRACKET_IN_REGEP, 0, JSEXN_SYNTAXERR, "raw bracket is not allowed in regular expression with unicode flag") -MSG_DEF(JSMSG_TOO_MANY_PARENS, 0, JSEXN_INTERNALERR, "too many parentheses in regular expression") -MSG_DEF(JSMSG_UNICODE_OVERFLOW, 0, JSEXN_SYNTAXERR, "unicode codepoint should not be greater than 0x10FFFF in regular expression") -MSG_DEF(JSMSG_UNMATCHED_RIGHT_PAREN, 0, JSEXN_SYNTAXERR, "unmatched ) in regular expression") -MSG_DEF(JSMSG_UNTERM_CLASS, 0, JSEXN_SYNTAXERR, "unterminated character class") - -// Self-hosting -MSG_DEF(JSMSG_DEFAULT_LOCALE_ERROR, 0, JSEXN_ERR, "internal error getting the default locale") -MSG_DEF(JSMSG_NO_SUCH_SELF_HOSTED_PROP,1, JSEXN_ERR, "No such property on self-hosted object: {0}") - -// Typed object / SIMD -MSG_DEF(JSMSG_INVALID_PROTOTYPE, 0, JSEXN_TYPEERR, "prototype field is not an object") -MSG_DEF(JSMSG_TYPEDOBJECT_BAD_ARGS, 0, JSEXN_TYPEERR, "invalid arguments") -MSG_DEF(JSMSG_TYPEDOBJECT_BINARYARRAY_BAD_INDEX, 0, JSEXN_RANGEERR, "invalid or out-of-range index") -MSG_DEF(JSMSG_TYPEDOBJECT_HANDLE_UNATTACHED, 0, JSEXN_TYPEERR, "handle unattached") -MSG_DEF(JSMSG_TYPEDOBJECT_STRUCTTYPE_BAD_ARGS, 0, JSEXN_RANGEERR, "invalid field descriptor") -MSG_DEF(JSMSG_TYPEDOBJECT_TOO_BIG, 0, JSEXN_ERR, "Type is too large to allocate") -MSG_DEF(JSMSG_SIMD_FAILED_CONVERSION, 0, JSEXN_RANGEERR, "SIMD conversion loses precision") -MSG_DEF(JSMSG_SIMD_TO_NUMBER, 0, JSEXN_TYPEERR, "can't convert SIMD value to number") - -// Array -MSG_DEF(JSMSG_TOO_LONG_ARRAY, 0, JSEXN_TYPEERR, "Too long array") - -// Typed array -MSG_DEF(JSMSG_BAD_INDEX, 0, JSEXN_RANGEERR, "invalid or out-of-range index") -MSG_DEF(JSMSG_NON_ARRAY_BUFFER_RETURNED, 0, JSEXN_TYPEERR, "expected ArrayBuffer, but species constructor returned non-ArrayBuffer") -MSG_DEF(JSMSG_SAME_ARRAY_BUFFER_RETURNED, 0, JSEXN_TYPEERR, "expected different ArrayBuffer, but species constructor returned same ArrayBuffer") -MSG_DEF(JSMSG_SHORT_ARRAY_BUFFER_RETURNED, 2, JSEXN_TYPEERR, "expected ArrayBuffer with at least {0} bytes, but species constructor returns ArrayBuffer with {1} bytes") -MSG_DEF(JSMSG_TYPED_ARRAY_BAD_ARGS, 0, JSEXN_TYPEERR, "invalid arguments") -MSG_DEF(JSMSG_TYPED_ARRAY_NEGATIVE_ARG,1, JSEXN_RANGEERR, "argument {0} must be >= 0") -MSG_DEF(JSMSG_TYPED_ARRAY_DETACHED, 0, JSEXN_TYPEERR, "attempting to access detached ArrayBuffer") -MSG_DEF(JSMSG_TYPED_ARRAY_CONSTRUCT_BOUNDS, 0, JSEXN_RANGEERR, "attempting to construct out-of-bounds TypedArray on ArrayBuffer") -MSG_DEF(JSMSG_TYPED_ARRAY_CALL_OR_CONSTRUCT, 1, JSEXN_TYPEERR, "cannot directly {0} builtin %TypedArray%") -MSG_DEF(JSMSG_NON_TYPED_ARRAY_RETURNED, 0, JSEXN_TYPEERR, "constructor didn't return TypedArray object") -MSG_DEF(JSMSG_SHORT_TYPED_ARRAY_RETURNED, 2, JSEXN_TYPEERR, "expected TypedArray of at least length {0}, but constructor returned TypedArray of length {1}") - -// Shared array buffer -MSG_DEF(JSMSG_SHARED_ARRAY_BAD_LENGTH, 0, JSEXN_RANGEERR, "length argument out of range") -MSG_DEF(JSMSG_NON_SHARED_ARRAY_BUFFER_RETURNED, 0, JSEXN_TYPEERR, "expected SharedArrayBuffer, but species constructor returned non-SharedArrayBuffer") -MSG_DEF(JSMSG_SAME_SHARED_ARRAY_BUFFER_RETURNED, 0, JSEXN_TYPEERR, "expected different SharedArrayBuffer, but species constructor returned same SharedArrayBuffer") -MSG_DEF(JSMSG_SHORT_SHARED_ARRAY_BUFFER_RETURNED, 2, JSEXN_TYPEERR, "expected SharedArrayBuffer with at least {0} bytes, but species constructor returns SharedArrayBuffer with {1} bytes") - -// Reflect -MSG_DEF(JSMSG_BAD_PARSE_NODE, 0, JSEXN_INTERNALERR, "bad parse node") - -// Symbol -MSG_DEF(JSMSG_SYMBOL_TO_STRING, 0, JSEXN_TYPEERR, "can't convert symbol to string") -MSG_DEF(JSMSG_SYMBOL_TO_NUMBER, 0, JSEXN_TYPEERR, "can't convert symbol to number") - -// Atomics and futexes -MSG_DEF(JSMSG_ATOMICS_BAD_ARRAY, 0, JSEXN_TYPEERR, "invalid array type for the operation") -MSG_DEF(JSMSG_ATOMICS_TOO_LONG, 0, JSEXN_RANGEERR, "timeout value too large") -MSG_DEF(JSMSG_ATOMICS_WAIT_NOT_ALLOWED, 0, JSEXN_ERR, "waiting is not allowed on this thread") - -// XPConnect wrappers and DOM bindings -MSG_DEF(JSMSG_CANT_SET_INTERPOSED, 1, JSEXN_TYPEERR, "unable to set interposed data property '{0}'") -MSG_DEF(JSMSG_CANT_DEFINE_WINDOW_ELEMENT, 0, JSEXN_TYPEERR, "can't define elements on a Window object") -MSG_DEF(JSMSG_CANT_DELETE_WINDOW_ELEMENT, 0, JSEXN_TYPEERR, "can't delete elements from a Window object") -MSG_DEF(JSMSG_CANT_DELETE_WINDOW_NAMED_PROPERTY, 1, JSEXN_TYPEERR, "can't delete property {0} from window's named properties object") -MSG_DEF(JSMSG_CANT_PREVENT_EXTENSIONS, 0, JSEXN_TYPEERR, "can't prevent extensions on this proxy object") -MSG_DEF(JSMSG_NO_NAMED_SETTER, 2, JSEXN_TYPEERR, "{0} doesn't have a named property setter for '{1}'") -MSG_DEF(JSMSG_NO_INDEXED_SETTER, 2, JSEXN_TYPEERR, "{0} doesn't have an indexed property setter for '{1}'") - -// Super -MSG_DEF(JSMSG_CANT_DELETE_SUPER, 0, JSEXN_REFERENCEERR, "invalid delete involving 'super'") -MSG_DEF(JSMSG_REINIT_THIS, 0, JSEXN_REFERENCEERR, "super() called twice in derived class constructor") - -// Modules -MSG_DEF(JSMSG_BAD_DEFAULT_EXPORT, 0, JSEXN_SYNTAXERR, "default export cannot be provided by export *") -MSG_DEF(JSMSG_MISSING_INDIRECT_EXPORT, 1, JSEXN_SYNTAXERR, "indirect export '{0}' not found") -MSG_DEF(JSMSG_AMBIGUOUS_INDIRECT_EXPORT, 1, JSEXN_SYNTAXERR, "ambiguous indirect export '{0}'") -MSG_DEF(JSMSG_MISSING_IMPORT, 1, JSEXN_SYNTAXERR, "import '{0}' not found") -MSG_DEF(JSMSG_AMBIGUOUS_IMPORT, 1, JSEXN_SYNTAXERR, "ambiguous import '{0}'") -MSG_DEF(JSMSG_MISSING_NAMESPACE_EXPORT, 0, JSEXN_SYNTAXERR, "export not found for namespace") -MSG_DEF(JSMSG_MISSING_EXPORT, 1, JSEXN_SYNTAXERR, "local binding for export '{0}' not found") -MSG_DEF(JSMSG_MODULE_INSTANTIATE_FAILED, 0, JSEXN_INTERNALERR, "attempt to re-instantiate module after failure") -MSG_DEF(JSMSG_BAD_MODULE_STATE, 0, JSEXN_INTERNALERR, "module record in unexpected state") - -// Promise -MSG_DEF(JSMSG_CANNOT_RESOLVE_PROMISE_WITH_ITSELF, 0, JSEXN_TYPEERR, "A promise cannot be resolved with itself.") -MSG_DEF(JSMSG_PROMISE_CAPABILITY_HAS_SOMETHING_ALREADY, 0, JSEXN_TYPEERR, "GetCapabilitiesExecutor function already invoked with non-undefined values.") -MSG_DEF(JSMSG_PROMISE_RESOLVE_FUNCTION_NOT_CALLABLE, 0, JSEXN_TYPEERR, "A Promise subclass passed a non-callable value as the resolve function.") -MSG_DEF(JSMSG_PROMISE_REJECT_FUNCTION_NOT_CALLABLE, 0, JSEXN_TYPEERR, "A Promise subclass passed a non-callable value as the reject function.") -MSG_DEF(JSMSG_PROMISE_ERROR_IN_WRAPPED_REJECTION_REASON,0, JSEXN_INTERNALERR, "Promise rejection value is a non-unwrappable cross-compartment wrapper.") diff --git a/android/armeabi/include/spidermonkey/js/CallArgs.h b/android/armeabi/include/spidermonkey/js/CallArgs.h deleted file mode 100644 index 1e0d909a..00000000 --- a/android/armeabi/include/spidermonkey/js/CallArgs.h +++ /dev/null @@ -1,369 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Helper classes encapsulating access to the callee, |this| value, arguments, - * and argument count for a call/construct operation. - * - * JS::CallArgs encapsulates access to a JSNative's un-abstracted - * |unsigned argc, Value* vp| arguments. The principal way to create a - * JS::CallArgs is using JS::CallArgsFromVp: - * - * // If provided no arguments or a non-numeric first argument, return zero. - * // Otherwise return |this| exactly as given, without boxing. - * static bool - * Func(JSContext* cx, unsigned argc, JS::Value* vp) - * { - * JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - * - * // Guard against no arguments or a non-numeric arg0. - * if (args.length() == 0 || !args[0].isNumber()) { - * args.rval().setInt32(0); - * return true; - * } - * - * // Access to the callee must occur before accessing/setting - * // the return value. - * JSObject& callee = args.callee(); - * args.rval().setObject(callee); - * - * // callee() and calleev() will now assert. - * - * // It's always fine to access thisv(). - * HandleValue thisv = args.thisv(); - * args.rval().set(thisv); - * - * // As the return value was last set to |this|, returns |this|. - * return true; - * } - * - * CallArgs is exposed publicly and used internally. Not all parts of its - * public interface are meant to be used by embedders! See inline comments to - * for details. - * - * It's possible (albeit deprecated) to manually index into |vp| to access the - * callee, |this|, and arguments of a function, and to set its return value. - * It's also possible to use the supported API of JS_CALLEE, JS_THIS, JS_ARGV, - * JS_RVAL, and JS_SET_RVAL to the same ends. - * - * But neither API has the error-handling or moving-GC correctness of CallArgs. - * New code should use CallArgs instead whenever possible. - * - * The eventual plan is to change JSNative to take |const CallArgs&| directly, - * for automatic assertion of correct use and to make calling functions more - * efficient. Embedders should start internally switching away from using - * |argc| and |vp| directly, except to create a |CallArgs|. Then, when an - * eventual release making that change occurs, porting efforts will require - * changing methods' signatures but won't require invasive changes to the - * methods' implementations, potentially under time pressure. - */ - -#ifndef js_CallArgs_h -#define js_CallArgs_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/TypeTraits.h" - -#include "jstypes.h" - -#include "js/RootingAPI.h" -#include "js/Value.h" - -/* Typedef for native functions called by the JS VM. */ -typedef bool -(* JSNative)(JSContext* cx, unsigned argc, JS::Value* vp); - -namespace JS { - -extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue; - -namespace detail { - -/* - * Compute |this| for the |vp| inside a JSNative, either boxing primitives or - * replacing with the global object as necessary. - */ -extern JS_PUBLIC_API(Value) -ComputeThis(JSContext* cx, JS::Value* vp); - -#ifdef JS_DEBUG -extern JS_PUBLIC_API(void) -CheckIsValidConstructible(const Value& v); -#endif - -class MOZ_STACK_CLASS IncludeUsedRval -{ - protected: -#ifdef JS_DEBUG - mutable bool usedRval_; - void setUsedRval() const { usedRval_ = true; } - void clearUsedRval() const { usedRval_ = false; } - void assertUnusedRval() const { MOZ_ASSERT(!usedRval_); } -#else - void setUsedRval() const {} - void clearUsedRval() const {} - void assertUnusedRval() const {} -#endif -}; - -class MOZ_STACK_CLASS NoUsedRval -{ - protected: - void setUsedRval() const {} - void clearUsedRval() const {} - void assertUnusedRval() const {} -}; - -template<class WantUsedRval> -class MOZ_STACK_CLASS CallArgsBase : public WantUsedRval -{ - static_assert(mozilla::IsSame<WantUsedRval, IncludeUsedRval>::value || - mozilla::IsSame<WantUsedRval, NoUsedRval>::value, - "WantUsedRval can only be IncludeUsedRval or NoUsedRval"); - - protected: - Value* argv_; - unsigned argc_; - bool constructing_; - - public: - // CALLEE ACCESS - - /* - * Returns the function being called, as a value. Must not be called after - * rval() has been used! - */ - HandleValue calleev() const { - this->assertUnusedRval(); - return HandleValue::fromMarkedLocation(&argv_[-2]); - } - - /* - * Returns the function being called, as an object. Must not be called - * after rval() has been used! - */ - JSObject& callee() const { - return calleev().toObject(); - } - - // CALLING/CONSTRUCTING-DIFFERENTIATIONS - - bool isConstructing() const { - if (!argv_[-1].isMagic()) - return false; - -#ifdef JS_DEBUG - if (!this->usedRval_) - CheckIsValidConstructible(calleev()); -#endif - - return true; - } - - MutableHandleValue newTarget() const { - MOZ_ASSERT(constructing_); - return MutableHandleValue::fromMarkedLocation(&this->argv_[argc_]); - } - - /* - * Returns the |this| value passed to the function. This method must not - * be called when the function is being called as a constructor via |new|. - * The value may or may not be an object: it is the individual function's - * responsibility to box the value if needed. - */ - HandleValue thisv() const { - // Some internal code uses thisv() in constructing cases, so don't do - // this yet. - // MOZ_ASSERT(!argv_[-1].isMagic(JS_IS_CONSTRUCTING)); - return HandleValue::fromMarkedLocation(&argv_[-1]); - } - - Value computeThis(JSContext* cx) const { - if (thisv().isObject()) - return thisv(); - - return ComputeThis(cx, base()); - } - - // ARGUMENTS - - /* Returns the number of arguments. */ - unsigned length() const { return argc_; } - - /* Returns the i-th zero-indexed argument. */ - MutableHandleValue operator[](unsigned i) const { - MOZ_ASSERT(i < argc_); - return MutableHandleValue::fromMarkedLocation(&this->argv_[i]); - } - - /* - * Returns the i-th zero-indexed argument, or |undefined| if there's no - * such argument. - */ - HandleValue get(unsigned i) const { - return i < length() - ? HandleValue::fromMarkedLocation(&this->argv_[i]) - : UndefinedHandleValue; - } - - /* - * Returns true if the i-th zero-indexed argument is present and is not - * |undefined|. - */ - bool hasDefined(unsigned i) const { - return i < argc_ && !this->argv_[i].isUndefined(); - } - - // RETURN VALUE - - /* - * Returns the currently-set return value. The initial contents of this - * value are unspecified. Once this method has been called, callee() and - * calleev() can no longer be used. (If you're compiling against a debug - * build of SpiderMonkey, these methods will assert to aid debugging.) - * - * If the method you're implementing succeeds by returning true, you *must* - * set this. (SpiderMonkey doesn't currently assert this, but it will do - * so eventually.) You don't need to use or change this if your method - * fails. - */ - MutableHandleValue rval() const { - this->setUsedRval(); - return MutableHandleValue::fromMarkedLocation(&argv_[-2]); - } - - public: - // These methods are publicly exposed, but they are *not* to be used when - // implementing a JSNative method and encapsulating access to |vp| within - // it. You probably don't want to use these! - - void setCallee(const Value& aCalleev) const { - this->clearUsedRval(); - argv_[-2] = aCalleev; - } - - void setThis(const Value& aThisv) const { - argv_[-1] = aThisv; - } - - MutableHandleValue mutableThisv() const { - return MutableHandleValue::fromMarkedLocation(&argv_[-1]); - } - - public: - // These methods are publicly exposed, but we're unsure of the interfaces - // (because they're hackish and drop assertions). Avoid using these if you - // can. - - Value* array() const { return argv_; } - Value* end() const { return argv_ + argc_ + constructing_; } - - public: - // These methods are only intended for internal use. Embedders shouldn't - // use them! - - Value* base() const { return argv_ - 2; } - - Value* spAfterCall() const { - this->setUsedRval(); - return argv_ - 1; - } -}; - -} // namespace detail - -class MOZ_STACK_CLASS CallArgs : public detail::CallArgsBase<detail::IncludeUsedRval> -{ - private: - friend CallArgs CallArgsFromVp(unsigned argc, Value* vp); - friend CallArgs CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing); - - static CallArgs create(unsigned argc, Value* argv, bool constructing) { - CallArgs args; - args.clearUsedRval(); - args.argv_ = argv; - args.argc_ = argc; - args.constructing_ = constructing; -#ifdef DEBUG - for (unsigned i = 0; i < argc; ++i) - MOZ_ASSERT_IF(argv[i].isMarkable(), !GCThingIsMarkedGray(GCCellPtr(argv[i]))); -#endif - return args; - } - - public: - /* - * Returns true if there are at least |required| arguments passed in. If - * false, it reports an error message on the context. - */ - bool requireAtLeast(JSContext* cx, const char* fnname, unsigned required) const; - -}; - -MOZ_ALWAYS_INLINE CallArgs -CallArgsFromVp(unsigned argc, Value* vp) -{ - return CallArgs::create(argc, vp + 2, vp[1].isMagic(JS_IS_CONSTRUCTING)); -} - -// This method is only intended for internal use in SpiderMonkey. We may -// eventually move it to an internal header. Embedders should use -// JS::CallArgsFromVp! -MOZ_ALWAYS_INLINE CallArgs -CallArgsFromSp(unsigned stackSlots, Value* sp, bool constructing = false) -{ - return CallArgs::create(stackSlots - constructing, sp - stackSlots, constructing); -} - -} // namespace JS - -/* - * Macros to hide interpreter stack layout details from a JSNative using its - * JS::Value* vp parameter. DO NOT USE THESE! Instead use JS::CallArgs and - * friends, above. These macros will be removed when we change JSNative to - * take a const JS::CallArgs&. - */ - -/* - * Return |this| if |this| is an object. Otherwise, return the global object - * if |this| is null or undefined, and finally return a boxed version of any - * other primitive. - * - * Note: if this method returns null, an error has occurred and must be - * propagated or caught. - */ -MOZ_ALWAYS_INLINE JS::Value -JS_THIS(JSContext* cx, JS::Value* vp) -{ - return vp[1].isPrimitive() ? JS::detail::ComputeThis(cx, vp) : vp[1]; -} - -/* - * A note on JS_THIS_OBJECT: no equivalent method is part of the CallArgs - * interface, and we're unlikely to add one (functions shouldn't be implicitly - * exposing the global object to arbitrary callers). Continue using |vp| - * directly for this case, but be aware this API will eventually be replaced - * with a function that operates directly upon |args.thisv()|. - */ -#define JS_THIS_OBJECT(cx,vp) (JS_THIS(cx,vp).toObjectOrNull()) - -/* - * |this| is passed to functions in ES5 without change. Functions themselves - * do any post-processing they desire to box |this|, compute the global object, - * &c. This macro retrieves a function's unboxed |this| value. - * - * This macro must not be used in conjunction with JS_THIS or JS_THIS_OBJECT, - * or vice versa. Either use the provided this value with this macro, or - * compute the boxed |this| value using those. JS_THIS_VALUE must not be used - * if the function is being called as a constructor. - * - * But: DO NOT USE THIS! Instead use JS::CallArgs::thisv(), above. - * - */ -#define JS_THIS_VALUE(cx,vp) ((vp)[1]) - -#endif /* js_CallArgs_h */ diff --git a/android/armeabi/include/spidermonkey/js/CallNonGenericMethod.h b/android/armeabi/include/spidermonkey/js/CallNonGenericMethod.h deleted file mode 100644 index 9a1cf010..00000000 --- a/android/armeabi/include/spidermonkey/js/CallNonGenericMethod.h +++ /dev/null @@ -1,117 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_CallNonGenericMethod_h -#define js_CallNonGenericMethod_h - -#include "jstypes.h" - -#include "js/CallArgs.h" - -namespace JS { - -// Returns true if |v| is considered an acceptable this-value. -typedef bool (*IsAcceptableThis)(HandleValue v); - -// Implements the guts of a method; guaranteed to be provided an acceptable -// this-value, as determined by a corresponding IsAcceptableThis method. -typedef bool (*NativeImpl)(JSContext* cx, const CallArgs& args); - -namespace detail { - -// DON'T CALL THIS DIRECTLY. It's for use only by CallNonGenericMethod! -extern JS_PUBLIC_API(bool) -CallMethodIfWrapped(JSContext* cx, IsAcceptableThis test, NativeImpl impl, const CallArgs& args); - -} // namespace detail - -// Methods usually act upon |this| objects only from a single global object and -// compartment. Sometimes, however, a method must act upon |this| values from -// multiple global objects or compartments. In such cases the |this| value a -// method might see will be wrapped, such that various access to the object -- -// to its class, its private data, its reserved slots, and so on -- will not -// work properly without entering that object's compartment. This method -// implements a solution to this problem. -// -// To implement a method that accepts |this| values from multiple compartments, -// define two functions. The first function matches the IsAcceptableThis type -// and indicates whether the provided value is an acceptable |this| for the -// method; it must be a pure function only of its argument. -// -// static const JSClass AnswerClass = { ... }; -// -// static bool -// IsAnswerObject(const Value& v) -// { -// if (!v.isObject()) -// return false; -// return JS_GetClass(&v.toObject()) == &AnswerClass; -// } -// -// The second function implements the NativeImpl signature and defines the -// behavior of the method when it is provided an acceptable |this| value. -// Aside from some typing niceties -- see the CallArgs interface for details -- -// its interface is the same as that of JSNative. -// -// static bool -// answer_getAnswer_impl(JSContext* cx, JS::CallArgs args) -// { -// args.rval().setInt32(42); -// return true; -// } -// -// The implementation function is guaranteed to be called *only* with a |this| -// value which is considered acceptable. -// -// Now to implement the actual method, write a JSNative that calls the method -// declared below, passing the appropriate template and runtime arguments. -// -// static bool -// answer_getAnswer(JSContext* cx, unsigned argc, JS::Value* vp) -// { -// JS::CallArgs args = JS::CallArgsFromVp(argc, vp); -// return JS::CallNonGenericMethod<IsAnswerObject, answer_getAnswer_impl>(cx, args); -// } -// -// Note that, because they are used as template arguments, the predicate -// and implementation functions must have external linkage. (This is -// unfortunate, but GCC wasn't inlining things as one would hope when we -// passed them as function arguments.) -// -// JS::CallNonGenericMethod will test whether |args.thisv()| is acceptable. If -// it is, it will call the provided implementation function, which will return -// a value and indicate success. If it is not, it will attempt to unwrap -// |this| and call the implementation function on the unwrapped |this|. If -// that succeeds, all well and good. If it doesn't succeed, a TypeError will -// be thrown. -// -// Note: JS::CallNonGenericMethod will only work correctly if it's called in -// tail position in a JSNative. Do not call it from any other place. -// -template<IsAcceptableThis Test, NativeImpl Impl> -MOZ_ALWAYS_INLINE bool -CallNonGenericMethod(JSContext* cx, const CallArgs& args) -{ - HandleValue thisv = args.thisv(); - if (Test(thisv)) - return Impl(cx, args); - - return detail::CallMethodIfWrapped(cx, Test, Impl, args); -} - -MOZ_ALWAYS_INLINE bool -CallNonGenericMethod(JSContext* cx, IsAcceptableThis Test, NativeImpl Impl, const CallArgs& args) -{ - HandleValue thisv = args.thisv(); - if (Test(thisv)) - return Impl(cx, args); - - return detail::CallMethodIfWrapped(cx, Test, Impl, args); -} - -} // namespace JS - -#endif /* js_CallNonGenericMethod_h */ diff --git a/android/armeabi/include/spidermonkey/js/CharacterEncoding.h b/android/armeabi/include/spidermonkey/js/CharacterEncoding.h deleted file mode 100644 index fe39a415..00000000 --- a/android/armeabi/include/spidermonkey/js/CharacterEncoding.h +++ /dev/null @@ -1,338 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_CharacterEncoding_h -#define js_CharacterEncoding_h - -#include "mozilla/Range.h" - -#include "js/TypeDecls.h" -#include "js/Utility.h" - -namespace js { -class ExclusiveContext; -} // namespace js - -class JSFlatString; - -namespace JS { - -/* - * By default, all C/C++ 1-byte-per-character strings passed into the JSAPI - * are treated as ISO/IEC 8859-1, also known as Latin-1. That is, each - * byte is treated as a 2-byte character, and there is no way to pass in a - * string containing characters beyond U+00FF. - */ -class Latin1Chars : public mozilla::Range<Latin1Char> -{ - typedef mozilla::Range<Latin1Char> Base; - - public: - using CharT = Latin1Char; - - Latin1Chars() : Base() {} - Latin1Chars(char* aBytes, size_t aLength) : Base(reinterpret_cast<Latin1Char*>(aBytes), aLength) {} - Latin1Chars(const Latin1Char* aBytes, size_t aLength) - : Base(const_cast<Latin1Char*>(aBytes), aLength) - {} - Latin1Chars(const char* aBytes, size_t aLength) - : Base(reinterpret_cast<Latin1Char*>(const_cast<char*>(aBytes)), aLength) - {} -}; - -/* - * A Latin1Chars, but with \0 termination for C compatibility. - */ -class Latin1CharsZ : public mozilla::RangedPtr<Latin1Char> -{ - typedef mozilla::RangedPtr<Latin1Char> Base; - - public: - using CharT = Latin1Char; - - Latin1CharsZ() : Base(nullptr, 0) {} - - Latin1CharsZ(char* aBytes, size_t aLength) - : Base(reinterpret_cast<Latin1Char*>(aBytes), aLength) - { - MOZ_ASSERT(aBytes[aLength] == '\0'); - } - - Latin1CharsZ(Latin1Char* aBytes, size_t aLength) - : Base(aBytes, aLength) - { - MOZ_ASSERT(aBytes[aLength] == '\0'); - } - - using Base::operator=; - - char* c_str() { return reinterpret_cast<char*>(get()); } -}; - -class UTF8Chars : public mozilla::Range<unsigned char> -{ - typedef mozilla::Range<unsigned char> Base; - - public: - using CharT = unsigned char; - - UTF8Chars() : Base() {} - UTF8Chars(char* aBytes, size_t aLength) - : Base(reinterpret_cast<unsigned char*>(aBytes), aLength) - {} - UTF8Chars(const char* aBytes, size_t aLength) - : Base(reinterpret_cast<unsigned char*>(const_cast<char*>(aBytes)), aLength) - {} -}; - -/* - * SpiderMonkey also deals directly with UTF-8 encoded text in some places. - */ -class UTF8CharsZ : public mozilla::RangedPtr<unsigned char> -{ - typedef mozilla::RangedPtr<unsigned char> Base; - - public: - using CharT = unsigned char; - - UTF8CharsZ() : Base(nullptr, 0) {} - - UTF8CharsZ(char* aBytes, size_t aLength) - : Base(reinterpret_cast<unsigned char*>(aBytes), aLength) - { - MOZ_ASSERT(aBytes[aLength] == '\0'); - } - - UTF8CharsZ(unsigned char* aBytes, size_t aLength) - : Base(aBytes, aLength) - { - MOZ_ASSERT(aBytes[aLength] == '\0'); - } - - using Base::operator=; - - char* c_str() { return reinterpret_cast<char*>(get()); } -}; - -/* - * A wrapper for a "const char*" that is encoded using UTF-8. - * This class does not manage ownership of the data; that is left - * to others. This differs from UTF8CharsZ in that the chars are - * const and it allows assignment. - */ -class ConstUTF8CharsZ -{ - const char* data_; - - public: - using CharT = unsigned char; - - ConstUTF8CharsZ() : data_(nullptr) - {} - - ConstUTF8CharsZ(const char* aBytes, size_t aLength) - : data_(aBytes) - { - MOZ_ASSERT(aBytes[aLength] == '\0'); -#ifdef DEBUG - validate(aLength); -#endif - } - - const void* get() const { return data_; } - - const char* c_str() const { return data_; } - - explicit operator bool() const { return data_ != nullptr; } - - private: -#ifdef DEBUG - void validate(size_t aLength); -#endif -}; - -/* - * SpiderMonkey uses a 2-byte character representation: it is a - * 2-byte-at-a-time view of a UTF-16 byte stream. This is similar to UCS-2, - * but unlike UCS-2, we do not strip UTF-16 extension bytes. This allows a - * sufficiently dedicated JavaScript program to be fully unicode-aware by - * manually interpreting UTF-16 extension characters embedded in the JS - * string. - */ -class TwoByteChars : public mozilla::Range<char16_t> -{ - typedef mozilla::Range<char16_t> Base; - - public: - using CharT = char16_t; - - TwoByteChars() : Base() {} - TwoByteChars(char16_t* aChars, size_t aLength) : Base(aChars, aLength) {} - TwoByteChars(const char16_t* aChars, size_t aLength) : Base(const_cast<char16_t*>(aChars), aLength) {} -}; - -/* - * A TwoByteChars, but \0 terminated for compatibility with JSFlatString. - */ -class TwoByteCharsZ : public mozilla::RangedPtr<char16_t> -{ - typedef mozilla::RangedPtr<char16_t> Base; - - public: - using CharT = char16_t; - - TwoByteCharsZ() : Base(nullptr, 0) {} - - TwoByteCharsZ(char16_t* chars, size_t length) - : Base(chars, length) - { - MOZ_ASSERT(chars[length] == '\0'); - } - - using Base::operator=; -}; - -typedef mozilla::RangedPtr<const char16_t> ConstCharPtr; - -/* - * Like TwoByteChars, but the chars are const. - */ -class ConstTwoByteChars : public mozilla::Range<const char16_t> -{ - typedef mozilla::Range<const char16_t> Base; - - public: - using CharT = char16_t; - - ConstTwoByteChars() : Base() {} - ConstTwoByteChars(const char16_t* aChars, size_t aLength) : Base(aChars, aLength) {} -}; - -/* - * Convert a 2-byte character sequence to "ISO-Latin-1". This works by - * truncating each 2-byte pair in the sequence to a 1-byte pair. If the source - * contains any UTF-16 extension characters, then this may give invalid Latin1 - * output. The returned string is zero terminated. The returned string or the - * returned string's |start()| must be freed with JS_free or js_free, - * respectively. If allocation fails, an OOM error will be set and the method - * will return a nullptr chars (which can be tested for with the ! operator). - * This method cannot trigger GC. - */ -extern Latin1CharsZ -LossyTwoByteCharsToNewLatin1CharsZ(js::ExclusiveContext* cx, - const mozilla::Range<const char16_t> tbchars); - -inline Latin1CharsZ -LossyTwoByteCharsToNewLatin1CharsZ(js::ExclusiveContext* cx, const char16_t* begin, size_t length) -{ - const mozilla::Range<const char16_t> tbchars(begin, length); - return JS::LossyTwoByteCharsToNewLatin1CharsZ(cx, tbchars); -} - -template <typename CharT> -extern UTF8CharsZ -CharsToNewUTF8CharsZ(js::ExclusiveContext* maybeCx, const mozilla::Range<CharT> chars); - -uint32_t -Utf8ToOneUcs4Char(const uint8_t* utf8Buffer, int utf8Length); - -/* - * Inflate bytes in UTF-8 encoding to char16_t. - * - On error, returns an empty TwoByteCharsZ. - * - On success, returns a malloc'd TwoByteCharsZ, and updates |outlen| to hold - * its length; the length value excludes the trailing null. - */ -extern TwoByteCharsZ -UTF8CharsToNewTwoByteCharsZ(JSContext* cx, const UTF8Chars utf8, size_t* outlen); - -/* - * Like UTF8CharsToNewTwoByteCharsZ, but for ConstUTF8CharsZ. - */ -extern TwoByteCharsZ -UTF8CharsToNewTwoByteCharsZ(JSContext* cx, const ConstUTF8CharsZ& utf8, size_t* outlen); - -/* - * The same as UTF8CharsToNewTwoByteCharsZ(), except that any malformed UTF-8 characters - * will be replaced by \uFFFD. No exception will be thrown for malformed UTF-8 - * input. - */ -extern TwoByteCharsZ -LossyUTF8CharsToNewTwoByteCharsZ(JSContext* cx, const UTF8Chars utf8, size_t* outlen); - -extern TwoByteCharsZ -LossyUTF8CharsToNewTwoByteCharsZ(JSContext* cx, const ConstUTF8CharsZ& utf8, size_t* outlen); - -/* - * Returns the length of the char buffer required to encode |s| as UTF8. - * Does not include the null-terminator. - */ -JS_PUBLIC_API(size_t) -GetDeflatedUTF8StringLength(JSFlatString* s); - -/* - * Encode |src| as UTF8. The caller must either ensure |dst| has enough space - * to encode the entire string or pass the length of the buffer as |dstlenp|, - * in which case the function will encode characters from the string until - * the buffer is exhausted. Does not write the null terminator. - * - * If |dstlenp| is provided, it will be updated to hold the number of bytes - * written to the buffer. If |numcharsp| is provided, it will be updated to hold - * the number of Unicode characters written to the buffer (which can be less - * than the length of the string, if the buffer is exhausted before the string - * is fully encoded). - */ -JS_PUBLIC_API(void) -DeflateStringToUTF8Buffer(JSFlatString* src, mozilla::RangedPtr<char> dst, - size_t* dstlenp = nullptr, size_t* numcharsp = nullptr); - -/* - * The smallest character encoding capable of fully representing a particular - * string. - */ -enum class SmallestEncoding { - ASCII, - Latin1, - UTF16 -}; - -/* - * Returns the smallest encoding possible for the given string: if all - * codepoints are <128 then ASCII, otherwise if all codepoints are <256 - * Latin-1, else UTF16. - */ -JS_PUBLIC_API(SmallestEncoding) -FindSmallestEncoding(UTF8Chars utf8); - -/* - * Return a null-terminated Latin-1 string copied from the input string, - * storing its length (excluding null terminator) in |*outlen|. Fail and - * report an error if the string contains non-Latin-1 codepoints. Returns - * Latin1CharsZ() on failure. - */ -extern Latin1CharsZ -UTF8CharsToNewLatin1CharsZ(JSContext* cx, const UTF8Chars utf8, size_t* outlen); - -/* - * Return a null-terminated Latin-1 string copied from the input string, - * storing its length (excluding null terminator) in |*outlen|. Non-Latin-1 - * codepoints are replaced by '?'. Returns Latin1CharsZ() on failure. - */ -extern Latin1CharsZ -LossyUTF8CharsToNewLatin1CharsZ(JSContext* cx, const UTF8Chars utf8, size_t* outlen); - -/* - * Returns true if all characters in the given null-terminated string are - * ASCII, i.e. < 0x80, false otherwise. - */ -extern bool -StringIsASCII(const char* s); - -} // namespace JS - -inline void JS_free(JS::Latin1CharsZ& ptr) { js_free((void*)ptr.get()); } -inline void JS_free(JS::UTF8CharsZ& ptr) { js_free((void*)ptr.get()); } - -#endif /* js_CharacterEncoding_h */ diff --git a/android/armeabi/include/spidermonkey/js/Class.h b/android/armeabi/include/spidermonkey/js/Class.h deleted file mode 100644 index 3b502387..00000000 --- a/android/armeabi/include/spidermonkey/js/Class.h +++ /dev/null @@ -1,995 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* JSClass definition and its component types, plus related interfaces. */ - -#ifndef js_Class_h -#define js_Class_h - -#include "jstypes.h" - -#include "js/CallArgs.h" -#include "js/Id.h" -#include "js/TypeDecls.h" - -/* - * A JSClass acts as a vtable for JS objects that allows JSAPI clients to - * control various aspects of the behavior of an object like property lookup. - * js::Class is an engine-private extension that allows more control over - * object behavior and, e.g., allows custom slow layout. - */ - -struct JSAtomState; -struct JSFreeOp; -struct JSFunctionSpec; - -namespace js { - -struct Class; -class FreeOp; -class Shape; - -// This is equal to JSFunction::class_. Use it in places where you don't want -// to #include jsfun.h. -extern JS_FRIEND_DATA(const js::Class* const) FunctionClassPtr; - -} // namespace js - -namespace JS { - -class AutoIdVector; - -/** - * The answer to a successful query as to whether an object is an Array per - * ES6's internal |IsArray| operation (as exposed by |Array.isArray|). - */ -enum class IsArrayAnswer -{ - Array, - NotArray, - RevokedProxy -}; - -/** - * ES6 7.2.2. - * - * Returns false on failure, otherwise returns true and sets |*isArray| - * indicating whether the object passes ECMAScript's IsArray test. This is the - * same test performed by |Array.isArray|. - * - * This is NOT the same as asking whether |obj| is an Array or a wrapper around - * one. If |obj| is a proxy created by |Proxy.revocable()| and has been - * revoked, or if |obj| is a proxy whose target (at any number of hops) is a - * revoked proxy, this method throws a TypeError and returns false. - */ -extern JS_PUBLIC_API(bool) -IsArray(JSContext* cx, HandleObject obj, bool* isArray); - -/** - * Identical to IsArray above, but the nature of the object (if successfully - * determined) is communicated via |*answer|. In particular this method - * returns true and sets |*answer = IsArrayAnswer::RevokedProxy| when called on - * a revoked proxy. - * - * Most users will want the overload above, not this one. - */ -extern JS_PUBLIC_API(bool) -IsArray(JSContext* cx, HandleObject obj, IsArrayAnswer* answer); - -/** - * Per ES6, the [[DefineOwnProperty]] internal method has three different - * possible outcomes: - * - * - It can throw an exception (which we indicate by returning false). - * - * - It can return true, indicating unvarnished success. - * - * - It can return false, indicating "strict failure". The property could - * not be defined. It's an error, but no exception was thrown. - * - * It's not just [[DefineOwnProperty]]: all the mutating internal methods have - * the same three outcomes. (The other affected internal methods are [[Set]], - * [[Delete]], [[SetPrototypeOf]], and [[PreventExtensions]].) - * - * If you think this design is awful, you're not alone. But as it's the - * standard, we must represent these boolean "success" values somehow. - * ObjectOpSuccess is the class for this. It's like a bool, but when it's false - * it also stores an error code. - * - * Typical usage: - * - * ObjectOpResult result; - * if (!DefineProperty(cx, obj, id, ..., result)) - * return false; - * if (!result) - * return result.reportError(cx, obj, id); - * - * Users don't have to call `result.report()`; another possible ending is: - * - * argv.rval().setBoolean(bool(result)); - * return true; - */ -class ObjectOpResult -{ - private: - /** - * code_ is either one of the special codes OkCode or Uninitialized, or - * an error code. For now the error codes are private to the JS engine; - * they're defined in js/src/js.msg. - * - * code_ is uintptr_t (rather than uint32_t) for the convenience of the - * JITs, which would otherwise have to deal with either padding or stack - * alignment on 64-bit platforms. - */ - uintptr_t code_; - - public: - enum SpecialCodes : uintptr_t { - OkCode = 0, - Uninitialized = uintptr_t(-1) - }; - - ObjectOpResult() : code_(Uninitialized) {} - - /* Return true if succeed() was called. */ - bool ok() const { - MOZ_ASSERT(code_ != Uninitialized); - return code_ == OkCode; - } - - explicit operator bool() const { return ok(); } - - /* Set this ObjectOpResult to true and return true. */ - bool succeed() { - code_ = OkCode; - return true; - } - - /* - * Set this ObjectOpResult to false with an error code. - * - * Always returns true, as a convenience. Typical usage will be: - * - * if (funny condition) - * return result.fail(JSMSG_CANT_DO_THE_THINGS); - * - * The true return value indicates that no exception is pending, and it - * would be OK to ignore the failure and continue. - */ - bool fail(uint32_t msg) { - MOZ_ASSERT(msg != OkCode); - code_ = msg; - return true; - } - - JS_PUBLIC_API(bool) failCantRedefineProp(); - JS_PUBLIC_API(bool) failReadOnly(); - JS_PUBLIC_API(bool) failGetterOnly(); - JS_PUBLIC_API(bool) failCantDelete(); - - JS_PUBLIC_API(bool) failCantSetInterposed(); - JS_PUBLIC_API(bool) failCantDefineWindowElement(); - JS_PUBLIC_API(bool) failCantDeleteWindowElement(); - JS_PUBLIC_API(bool) failCantDeleteWindowNamedProperty(); - JS_PUBLIC_API(bool) failCantPreventExtensions(); - JS_PUBLIC_API(bool) failCantSetProto(); - JS_PUBLIC_API(bool) failNoNamedSetter(); - JS_PUBLIC_API(bool) failNoIndexedSetter(); - - uint32_t failureCode() const { - MOZ_ASSERT(!ok()); - return uint32_t(code_); - } - - /* - * Report an error or warning if necessary; return true to proceed and - * false if an error was reported. Call this when failure should cause - * a warning if extraWarnings are enabled. - * - * The precise rules are like this: - * - * - If ok(), then we succeeded. Do nothing and return true. - * - Otherwise, if |strict| is true, or if cx has both extraWarnings and - * werrorOption enabled, throw a TypeError and return false. - * - Otherwise, if cx has extraWarnings enabled, emit a warning and - * return true. - * - Otherwise, do nothing and return true. - */ - bool checkStrictErrorOrWarning(JSContext* cx, HandleObject obj, HandleId id, bool strict) { - if (ok()) - return true; - return reportStrictErrorOrWarning(cx, obj, id, strict); - } - - /* - * The same as checkStrictErrorOrWarning(cx, id, strict), except the - * operation is not associated with a particular property id. This is - * used for [[PreventExtensions]] and [[SetPrototypeOf]]. failureCode() - * must not be an error that has "{0}" in the error message. - */ - bool checkStrictErrorOrWarning(JSContext* cx, HandleObject obj, bool strict) { - return ok() || reportStrictErrorOrWarning(cx, obj, strict); - } - - /* Throw a TypeError. Call this only if !ok(). */ - bool reportError(JSContext* cx, HandleObject obj, HandleId id) { - return reportStrictErrorOrWarning(cx, obj, id, true); - } - - /* - * The same as reportError(cx, obj, id), except the operation is not - * associated with a particular property id. - */ - bool reportError(JSContext* cx, HandleObject obj) { - return reportStrictErrorOrWarning(cx, obj, true); - } - - /* Helper function for checkStrictErrorOrWarning's slow path. */ - JS_PUBLIC_API(bool) reportStrictErrorOrWarning(JSContext* cx, HandleObject obj, HandleId id, bool strict); - JS_PUBLIC_API(bool) reportStrictErrorOrWarning(JSContext* cx, HandleObject obj, bool strict); - - /* - * Convenience method. Return true if ok() or if strict is false; otherwise - * throw a TypeError and return false. - */ - bool checkStrict(JSContext* cx, HandleObject obj, HandleId id) { - return checkStrictErrorOrWarning(cx, obj, id, true); - } - - /* - * Convenience method. The same as checkStrict(cx, id), except the - * operation is not associated with a particular property id. - */ - bool checkStrict(JSContext* cx, HandleObject obj) { - return checkStrictErrorOrWarning(cx, obj, true); - } -}; - -} // namespace JS - -// JSClass operation signatures. - -/** - * Get a property named by id in obj. Note the jsid id type -- id may - * be a string (Unicode property identifier) or an int (element index). The - * *vp out parameter, on success, is the new property value after the action. - */ -typedef bool -(* JSGetterOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandleValue vp); - -/** Add a property named by id to obj. */ -typedef bool -(* JSAddPropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue v); - -/** - * Set a property named by id in obj, treating the assignment as strict - * mode code if strict is true. Note the jsid id type -- id may be a string - * (Unicode property identifier) or an int (element index). The *vp out - * parameter, on success, is the new property value after the - * set. - */ -typedef bool -(* JSSetterOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandleValue vp, JS::ObjectOpResult& result); - -/** - * Delete a property named by id in obj. - * - * If an error occurred, return false as per normal JSAPI error practice. - * - * If no error occurred, but the deletion attempt wasn't allowed (perhaps - * because the property was non-configurable), call result.fail() and - * return true. This will cause |delete obj[id]| to evaluate to false in - * non-strict mode code, and to throw a TypeError in strict mode code. - * - * If no error occurred and the deletion wasn't disallowed (this is *not* the - * same as saying that a deletion actually occurred -- deleting a non-existent - * property, or an inherited property, is allowed -- it's just pointless), - * call result.succeed() and return true. - */ -typedef bool -(* JSDeletePropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::ObjectOpResult& result); - -/** - * The type of ObjectOps::enumerate. This callback overrides a portion of - * SpiderMonkey's default [[Enumerate]] internal method. When an ordinary object - * is enumerated, that object and each object on its prototype chain is tested - * for an enumerate op, and those ops are called in order. The properties each - * op adds to the 'properties' vector are added to the set of values the for-in - * loop will iterate over. All of this is nonstandard. - * - * An object is "enumerated" when it's the target of a for-in loop or - * JS_Enumerate(). The callback's job is to populate 'properties' with the - * object's property keys. If `enumerableOnly` is true, the callback should only - * add enumerable properties. - */ -typedef bool -(* JSNewEnumerateOp)(JSContext* cx, JS::HandleObject obj, JS::AutoIdVector& properties, - bool enumerableOnly); - -/** - * The old-style JSClass.enumerate op should define all lazy properties not - * yet reflected in obj. - */ -typedef bool -(* JSEnumerateOp)(JSContext* cx, JS::HandleObject obj); - -/** - * The type of ObjectOps::funToString. This callback allows an object to - * provide a custom string to use when Function.prototype.toString is invoked on - * that object. A null return value means OOM. - */ -typedef JSString* -(* JSFunToStringOp)(JSContext* cx, JS::HandleObject obj, unsigned indent); - -/** - * Resolve a lazy property named by id in obj by defining it directly in obj. - * Lazy properties are those reflected from some peer native property space - * (e.g., the DOM attributes for a given node reflected as obj) on demand. - * - * JS looks for a property in an object, and if not found, tries to resolve - * the given id. *resolvedp should be set to true iff the property was defined - * on |obj|. - */ -typedef bool -(* JSResolveOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - bool* resolvedp); - -/** - * A class with a resolve hook can optionally have a mayResolve hook. This hook - * must have no side effects and must return true for a given id if the resolve - * hook may resolve this id. This is useful when we're doing a "pure" lookup: if - * mayResolve returns false, we know we don't have to call the effectful resolve - * hook. - * - * maybeObj, if non-null, is the object on which we're doing the lookup. This - * can be nullptr: during JIT compilation we sometimes know the Class but not - * the object. - */ -typedef bool -(* JSMayResolveOp)(const JSAtomState& names, jsid id, JSObject* maybeObj); - -/** - * Finalize obj, which the garbage collector has determined to be unreachable - * from other live objects or from GC roots. Obviously, finalizers must never - * store a reference to obj. - */ -typedef void -(* JSFinalizeOp)(JSFreeOp* fop, JSObject* obj); - -/** Finalizes external strings created by JS_NewExternalString. */ -struct JSStringFinalizer { - void (*finalize)(JS::Zone* zone, const JSStringFinalizer* fin, char16_t* chars); -}; - -/** - * Check whether v is an instance of obj. Return false on error or exception, - * true on success with true in *bp if v is an instance of obj, false in - * *bp otherwise. - */ -typedef bool -(* JSHasInstanceOp)(JSContext* cx, JS::HandleObject obj, JS::MutableHandleValue vp, - bool* bp); - -/** - * Function type for trace operation of the class called to enumerate all - * traceable things reachable from obj's private data structure. For each such - * thing, a trace implementation must call JS::TraceEdge on the thing's - * location. - * - * JSTraceOp implementation can assume that no other threads mutates object - * state. It must not change state of the object or corresponding native - * structures. The only exception for this rule is the case when the embedding - * needs a tight integration with GC. In that case the embedding can check if - * the traversal is a part of the marking phase through calling - * JS_IsGCMarkingTracer and apply a special code like emptying caches or - * marking its native structures. - */ -typedef void -(* JSTraceOp)(JSTracer* trc, JSObject* obj); - -typedef JSObject* -(* JSWeakmapKeyDelegateOp)(JSObject* obj); - -typedef void -(* JSObjectMovedOp)(JSObject* obj, const JSObject* old); - -/* js::Class operation signatures. */ - -namespace js { - -typedef bool -(* LookupPropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandleObject objp, JS::MutableHandle<Shape*> propp); -typedef bool -(* DefinePropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::Handle<JS::PropertyDescriptor> desc, - JS::ObjectOpResult& result); -typedef bool -(* HasPropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* foundp); -typedef bool -(* GetPropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleValue receiver, JS::HandleId id, - JS::MutableHandleValue vp); -typedef bool -(* SetPropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue v, - JS::HandleValue receiver, JS::ObjectOpResult& result); -typedef bool -(* GetOwnPropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandle<JS::PropertyDescriptor> desc); -typedef bool -(* DeletePropertyOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::ObjectOpResult& result); - -typedef bool -(* WatchOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject callable); - -typedef bool -(* UnwatchOp)(JSContext* cx, JS::HandleObject obj, JS::HandleId id); - -class JS_FRIEND_API(ElementAdder) -{ - public: - enum GetBehavior { - // Check if the element exists before performing the Get and preserve - // holes. - CheckHasElemPreserveHoles, - - // Perform a Get operation, like obj[index] in JS. - GetElement - }; - - private: - // Only one of these is used. - JS::RootedObject resObj_; - JS::Value* vp_; - - uint32_t index_; -#ifdef DEBUG - uint32_t length_; -#endif - GetBehavior getBehavior_; - - public: - ElementAdder(JSContext* cx, JSObject* obj, uint32_t length, GetBehavior behavior) - : resObj_(cx, obj), vp_(nullptr), index_(0), -#ifdef DEBUG - length_(length), -#endif - getBehavior_(behavior) - {} - ElementAdder(JSContext* cx, JS::Value* vp, uint32_t length, GetBehavior behavior) - : resObj_(cx), vp_(vp), index_(0), -#ifdef DEBUG - length_(length), -#endif - getBehavior_(behavior) - {} - - GetBehavior getBehavior() const { return getBehavior_; } - - bool append(JSContext* cx, JS::HandleValue v); - void appendHole(); -}; - -typedef bool -(* GetElementsOp)(JSContext* cx, JS::HandleObject obj, uint32_t begin, uint32_t end, - ElementAdder* adder); - -typedef void -(* FinalizeOp)(FreeOp* fop, JSObject* obj); - -// The special treatment of |finalize| and |trace| is necessary because if we -// assign either of those hooks to a local variable and then call it -- as is -// done with the other hooks -- the GC hazard analysis gets confused. -#define JS_CLASS_MEMBERS(ClassOpsType, FreeOpType) \ - const char* name; \ - uint32_t flags; \ - const ClassOpsType* cOps; \ - \ - JSAddPropertyOp getAddProperty() const { return cOps ? cOps->addProperty : nullptr; } \ - JSDeletePropertyOp getDelProperty() const { return cOps ? cOps->delProperty : nullptr; } \ - JSGetterOp getGetProperty() const { return cOps ? cOps->getProperty : nullptr; } \ - JSSetterOp getSetProperty() const { return cOps ? cOps->setProperty : nullptr; } \ - JSEnumerateOp getEnumerate() const { return cOps ? cOps->enumerate : nullptr; } \ - JSResolveOp getResolve() const { return cOps ? cOps->resolve : nullptr; } \ - JSMayResolveOp getMayResolve() const { return cOps ? cOps->mayResolve : nullptr; } \ - JSNative getCall() const { return cOps ? cOps->call : nullptr; } \ - JSHasInstanceOp getHasInstance() const { return cOps ? cOps->hasInstance : nullptr; } \ - JSNative getConstruct() const { return cOps ? cOps->construct : nullptr; } \ - \ - bool hasFinalize() const { return cOps && cOps->finalize; } \ - bool hasTrace() const { return cOps && cOps->trace; } \ - \ - bool isTrace(JSTraceOp trace) const { return cOps && cOps->trace == trace; } \ - \ - void doFinalize(FreeOpType* fop, JSObject* obj) const { \ - MOZ_ASSERT(cOps && cOps->finalize); \ - cOps->finalize(fop, obj); \ - } \ - void doTrace(JSTracer* trc, JSObject* obj) const { \ - MOZ_ASSERT(cOps && cOps->trace); \ - cOps->trace(trc, obj); \ - } - -struct ClassOps -{ - /* Function pointer members (may be null). */ - JSAddPropertyOp addProperty; - JSDeletePropertyOp delProperty; - JSGetterOp getProperty; - JSSetterOp setProperty; - JSEnumerateOp enumerate; - JSResolveOp resolve; - JSMayResolveOp mayResolve; - FinalizeOp finalize; - JSNative call; - JSHasInstanceOp hasInstance; - JSNative construct; - JSTraceOp trace; -}; - -/** Callback for the creation of constructor and prototype objects. */ -typedef JSObject* (*ClassObjectCreationOp)(JSContext* cx, JSProtoKey key); - -/** Callback for custom post-processing after class initialization via ClassSpec. */ -typedef bool (*FinishClassInitOp)(JSContext* cx, JS::HandleObject ctor, - JS::HandleObject proto); - -const size_t JSCLASS_CACHED_PROTO_WIDTH = 6; - -struct ClassSpec -{ - // All properties except flags should be accessed through accessor. - ClassObjectCreationOp createConstructor_; - ClassObjectCreationOp createPrototype_; - const JSFunctionSpec* constructorFunctions_; - const JSPropertySpec* constructorProperties_; - const JSFunctionSpec* prototypeFunctions_; - const JSPropertySpec* prototypeProperties_; - FinishClassInitOp finishInit_; - uintptr_t flags; - - static const size_t ProtoKeyWidth = JSCLASS_CACHED_PROTO_WIDTH; - - static const uintptr_t ProtoKeyMask = (1 << ProtoKeyWidth) - 1; - static const uintptr_t DontDefineConstructor = 1 << ProtoKeyWidth; - static const uintptr_t IsDelegated = 1 << (ProtoKeyWidth + 1); - - bool defined() const { return !!createConstructor_; } - - bool delegated() const { - return (flags & IsDelegated); - } - - // The ProtoKey this class inherits from. - JSProtoKey inheritanceProtoKey() const { - MOZ_ASSERT(defined()); - static_assert(JSProto_Null == 0, "zeroed key must be null"); - - // Default: Inherit from Object. - if (!(flags & ProtoKeyMask)) - return JSProto_Object; - - return JSProtoKey(flags & ProtoKeyMask); - } - - bool shouldDefineConstructor() const { - MOZ_ASSERT(defined()); - return !(flags & DontDefineConstructor); - } - - const ClassSpec* delegatedClassSpec() const { - MOZ_ASSERT(delegated()); - return reinterpret_cast<ClassSpec*>(createConstructor_); - } - - ClassObjectCreationOp createConstructorHook() const { - if (delegated()) - return delegatedClassSpec()->createConstructorHook(); - return createConstructor_; - } - ClassObjectCreationOp createPrototypeHook() const { - if (delegated()) - return delegatedClassSpec()->createPrototypeHook(); - return createPrototype_; - } - const JSFunctionSpec* constructorFunctions() const { - if (delegated()) - return delegatedClassSpec()->constructorFunctions(); - return constructorFunctions_; - } - const JSPropertySpec* constructorProperties() const { - if (delegated()) - return delegatedClassSpec()->constructorProperties(); - return constructorProperties_; - } - const JSFunctionSpec* prototypeFunctions() const { - if (delegated()) - return delegatedClassSpec()->prototypeFunctions(); - return prototypeFunctions_; - } - const JSPropertySpec* prototypeProperties() const { - if (delegated()) - return delegatedClassSpec()->prototypeProperties(); - return prototypeProperties_; - } - FinishClassInitOp finishInitHook() const { - if (delegated()) - return delegatedClassSpec()->finishInitHook(); - return finishInit_; - } -}; - -struct ClassExtension -{ - /** - * If an object is used as a key in a weakmap, it may be desirable for the - * garbage collector to keep that object around longer than it otherwise - * would. A common case is when the key is a wrapper around an object in - * another compartment, and we want to avoid collecting the wrapper (and - * removing the weakmap entry) as long as the wrapped object is alive. In - * that case, the wrapped object is returned by the wrapper's - * weakmapKeyDelegateOp hook. As long as the wrapper is used as a weakmap - * key, it will not be collected (and remain in the weakmap) until the - * wrapped object is collected. - */ - JSWeakmapKeyDelegateOp weakmapKeyDelegateOp; - - /** - * Optional hook called when an object is moved by a compacting GC. - * - * There may exist weak pointers to an object that are not traced through - * when the normal trace APIs are used, for example objects in the wrapper - * cache. This hook allows these pointers to be updated. - * - * Note that this hook can be called before JS_NewObject() returns if a GC - * is triggered during construction of the object. This can happen for - * global objects for example. - */ - JSObjectMovedOp objectMovedOp; -}; - -inline ClassObjectCreationOp DELEGATED_CLASSSPEC(const ClassSpec* spec) { - return reinterpret_cast<ClassObjectCreationOp>(const_cast<ClassSpec*>(spec)); -} - -#define JS_NULL_CLASS_SPEC nullptr -#define JS_NULL_CLASS_EXT nullptr - -struct ObjectOps -{ - LookupPropertyOp lookupProperty; - DefinePropertyOp defineProperty; - HasPropertyOp hasProperty; - GetPropertyOp getProperty; - SetPropertyOp setProperty; - GetOwnPropertyOp getOwnPropertyDescriptor; - DeletePropertyOp deleteProperty; - WatchOp watch; - UnwatchOp unwatch; - GetElementsOp getElements; - JSNewEnumerateOp enumerate; - JSFunToStringOp funToString; -}; - -#define JS_NULL_OBJECT_OPS nullptr - -} // namespace js - -// Classes, objects, and properties. - -typedef void (*JSClassInternal)(); - -struct JSClassOps -{ - /* Function pointer members (may be null). */ - JSAddPropertyOp addProperty; - JSDeletePropertyOp delProperty; - JSGetterOp getProperty; - JSSetterOp setProperty; - JSEnumerateOp enumerate; - JSResolveOp resolve; - JSMayResolveOp mayResolve; - JSFinalizeOp finalize; - JSNative call; - JSHasInstanceOp hasInstance; - JSNative construct; - JSTraceOp trace; -}; - -#define JS_NULL_CLASS_OPS nullptr - -struct JSClass { - JS_CLASS_MEMBERS(JSClassOps, JSFreeOp); - - void* reserved[3]; -}; - -#define JSCLASS_HAS_PRIVATE (1<<0) // objects have private slot -#define JSCLASS_DELAY_METADATA_BUILDER (1<<1) // class's initialization code - // will call - // SetNewObjectMetadata itself -#define JSCLASS_IS_WRAPPED_NATIVE (1<<2) // class is an XPCWrappedNative. - // WeakMaps use this to override - // the wrapper disposal - // mechanism. -#define JSCLASS_PRIVATE_IS_NSISUPPORTS (1<<3) // private is (nsISupports*) -#define JSCLASS_IS_DOMJSCLASS (1<<4) // objects are DOM -#define JSCLASS_HAS_XRAYED_CONSTRUCTOR (1<<5) // if wrapped by an xray - // wrapper, the builtin - // class's constructor won't - // be unwrapped and invoked. - // Instead, the constructor is - // resolved in the caller's - // compartment and invoked - // with a wrapped newTarget. - // The constructor has to - // detect and handle this - // situation. - // See PromiseConstructor for - // details. -#define JSCLASS_EMULATES_UNDEFINED (1<<6) // objects of this class act - // like the value undefined, - // in some contexts -#define JSCLASS_USERBIT1 (1<<7) // Reserved for embeddings. - -// To reserve slots fetched and stored via JS_Get/SetReservedSlot, bitwise-or -// JSCLASS_HAS_RESERVED_SLOTS(n) into the initializer for JSClass.flags, where -// n is a constant in [1, 255]. Reserved slots are indexed from 0 to n-1. -#define JSCLASS_RESERVED_SLOTS_SHIFT 8 // room for 8 flags below */ -#define JSCLASS_RESERVED_SLOTS_WIDTH 8 // and 16 above this field */ -#define JSCLASS_RESERVED_SLOTS_MASK JS_BITMASK(JSCLASS_RESERVED_SLOTS_WIDTH) -#define JSCLASS_HAS_RESERVED_SLOTS(n) (((n) & JSCLASS_RESERVED_SLOTS_MASK) \ - << JSCLASS_RESERVED_SLOTS_SHIFT) -#define JSCLASS_RESERVED_SLOTS(clasp) (((clasp)->flags \ - >> JSCLASS_RESERVED_SLOTS_SHIFT) \ - & JSCLASS_RESERVED_SLOTS_MASK) - -#define JSCLASS_HIGH_FLAGS_SHIFT (JSCLASS_RESERVED_SLOTS_SHIFT + \ - JSCLASS_RESERVED_SLOTS_WIDTH) - -#define JSCLASS_IS_ANONYMOUS (1<<(JSCLASS_HIGH_FLAGS_SHIFT+0)) -#define JSCLASS_IS_GLOBAL (1<<(JSCLASS_HIGH_FLAGS_SHIFT+1)) -#define JSCLASS_INTERNAL_FLAG2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+2)) -#define JSCLASS_INTERNAL_FLAG3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+3)) - -#define JSCLASS_IS_PROXY (1<<(JSCLASS_HIGH_FLAGS_SHIFT+4)) - -#define JSCLASS_SKIP_NURSERY_FINALIZE (1<<(JSCLASS_HIGH_FLAGS_SHIFT+5)) - -// Reserved for embeddings. -#define JSCLASS_USERBIT2 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+6)) -#define JSCLASS_USERBIT3 (1<<(JSCLASS_HIGH_FLAGS_SHIFT+7)) - -#define JSCLASS_BACKGROUND_FINALIZE (1<<(JSCLASS_HIGH_FLAGS_SHIFT+8)) -#define JSCLASS_FOREGROUND_FINALIZE (1<<(JSCLASS_HIGH_FLAGS_SHIFT+9)) - -// Bits 26 through 31 are reserved for the CACHED_PROTO_KEY mechanism, see -// below. - -// ECMA-262 requires that most constructors used internally create objects -// with "the original Foo.prototype value" as their [[Prototype]] (__proto__) -// member initial value. The "original ... value" verbiage is there because -// in ECMA-262, global properties naming class objects are read/write and -// deleteable, for the most part. -// -// Implementing this efficiently requires that global objects have classes -// with the following flags. Failure to use JSCLASS_GLOBAL_FLAGS was -// previously allowed, but is now an ES5 violation and thus unsupported. -// -// JSCLASS_GLOBAL_APPLICATION_SLOTS is the number of slots reserved at -// the beginning of every global object's slots for use by the -// application. -#define JSCLASS_GLOBAL_APPLICATION_SLOTS 5 -#define JSCLASS_GLOBAL_SLOT_COUNT \ - (JSCLASS_GLOBAL_APPLICATION_SLOTS + JSProto_LIMIT * 2 + 39) -#define JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(n) \ - (JSCLASS_IS_GLOBAL | JSCLASS_HAS_RESERVED_SLOTS(JSCLASS_GLOBAL_SLOT_COUNT + (n))) -#define JSCLASS_GLOBAL_FLAGS \ - JSCLASS_GLOBAL_FLAGS_WITH_SLOTS(0) -#define JSCLASS_HAS_GLOBAL_FLAG_AND_SLOTS(clasp) \ - (((clasp)->flags & JSCLASS_IS_GLOBAL) \ - && JSCLASS_RESERVED_SLOTS(clasp) >= JSCLASS_GLOBAL_SLOT_COUNT) - -// Fast access to the original value of each standard class's prototype. -#define JSCLASS_CACHED_PROTO_SHIFT (JSCLASS_HIGH_FLAGS_SHIFT + 10) -#define JSCLASS_CACHED_PROTO_MASK JS_BITMASK(js::JSCLASS_CACHED_PROTO_WIDTH) -#define JSCLASS_HAS_CACHED_PROTO(key) (uint32_t(key) << JSCLASS_CACHED_PROTO_SHIFT) -#define JSCLASS_CACHED_PROTO_KEY(clasp) ((JSProtoKey) \ - (((clasp)->flags \ - >> JSCLASS_CACHED_PROTO_SHIFT) \ - & JSCLASS_CACHED_PROTO_MASK)) - -// Initializer for unused members of statically initialized JSClass structs. -#define JSCLASS_NO_INTERNAL_MEMBERS {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} -#define JSCLASS_NO_OPTIONAL_MEMBERS 0,0,0,0,0,JSCLASS_NO_INTERNAL_MEMBERS - -namespace js { - -struct Class -{ - JS_CLASS_MEMBERS(js::ClassOps, FreeOp); - const ClassSpec* spec; - const ClassExtension* ext; - const ObjectOps* oOps; - - /* - * Objects of this class aren't native objects. They don't have Shapes that - * describe their properties and layout. Classes using this flag must - * provide their own property behavior, either by being proxy classes (do - * this) or by overriding all the ObjectOps except getElements, watch and - * unwatch (don't do this). - */ - static const uint32_t NON_NATIVE = JSCLASS_INTERNAL_FLAG2; - - bool isNative() const { - return !(flags & NON_NATIVE); - } - - bool hasPrivate() const { - return !!(flags & JSCLASS_HAS_PRIVATE); - } - - bool emulatesUndefined() const { - return flags & JSCLASS_EMULATES_UNDEFINED; - } - - bool isJSFunction() const { - return this == js::FunctionClassPtr; - } - - bool nonProxyCallable() const { - MOZ_ASSERT(!isProxy()); - return isJSFunction() || getCall(); - } - - bool isProxy() const { - return flags & JSCLASS_IS_PROXY; - } - - bool isDOMClass() const { - return flags & JSCLASS_IS_DOMJSCLASS; - } - - bool shouldDelayMetadataBuilder() const { - return flags & JSCLASS_DELAY_METADATA_BUILDER; - } - - bool isWrappedNative() const { - return flags & JSCLASS_IS_WRAPPED_NATIVE; - } - - static size_t offsetOfFlags() { return offsetof(Class, flags); } - - bool specDefined() const { return spec ? spec->defined() : false; } - JSProtoKey specInheritanceProtoKey() - const { return spec ? spec->inheritanceProtoKey() : JSProto_Null; } - bool specShouldDefineConstructor() - const { return spec ? spec->shouldDefineConstructor() : true; } - ClassObjectCreationOp specCreateConstructorHook() - const { return spec ? spec->createConstructorHook() : nullptr; } - ClassObjectCreationOp specCreatePrototypeHook() - const { return spec ? spec->createPrototypeHook() : nullptr; } - const JSFunctionSpec* specConstructorFunctions() - const { return spec ? spec->constructorFunctions() : nullptr; } - const JSPropertySpec* specConstructorProperties() - const { return spec ? spec->constructorProperties() : nullptr; } - const JSFunctionSpec* specPrototypeFunctions() - const { return spec ? spec->prototypeFunctions() : nullptr; } - const JSPropertySpec* specPrototypeProperties() - const { return spec ? spec->prototypeProperties() : nullptr; } - FinishClassInitOp specFinishInitHook() - const { return spec ? spec->finishInitHook() : nullptr; } - - JSWeakmapKeyDelegateOp extWeakmapKeyDelegateOp() - const { return ext ? ext->weakmapKeyDelegateOp : nullptr; } - JSObjectMovedOp extObjectMovedOp() - const { return ext ? ext->objectMovedOp : nullptr; } - - LookupPropertyOp getOpsLookupProperty() const { return oOps ? oOps->lookupProperty : nullptr; } - DefinePropertyOp getOpsDefineProperty() const { return oOps ? oOps->defineProperty : nullptr; } - HasPropertyOp getOpsHasProperty() const { return oOps ? oOps->hasProperty : nullptr; } - GetPropertyOp getOpsGetProperty() const { return oOps ? oOps->getProperty : nullptr; } - SetPropertyOp getOpsSetProperty() const { return oOps ? oOps->setProperty : nullptr; } - GetOwnPropertyOp getOpsGetOwnPropertyDescriptor() - const { return oOps ? oOps->getOwnPropertyDescriptor - : nullptr; } - DeletePropertyOp getOpsDeleteProperty() const { return oOps ? oOps->deleteProperty : nullptr; } - WatchOp getOpsWatch() const { return oOps ? oOps->watch : nullptr; } - UnwatchOp getOpsUnwatch() const { return oOps ? oOps->unwatch : nullptr; } - GetElementsOp getOpsGetElements() const { return oOps ? oOps->getElements : nullptr; } - JSNewEnumerateOp getOpsEnumerate() const { return oOps ? oOps->enumerate : nullptr; } - JSFunToStringOp getOpsFunToString() const { return oOps ? oOps->funToString : nullptr; } -}; - -static_assert(offsetof(JSClassOps, addProperty) == offsetof(ClassOps, addProperty), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, delProperty) == offsetof(ClassOps, delProperty), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, getProperty) == offsetof(ClassOps, getProperty), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, setProperty) == offsetof(ClassOps, setProperty), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, enumerate) == offsetof(ClassOps, enumerate), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, resolve) == offsetof(ClassOps, resolve), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, mayResolve) == offsetof(ClassOps, mayResolve), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, finalize) == offsetof(ClassOps, finalize), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, call) == offsetof(ClassOps, call), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, construct) == offsetof(ClassOps, construct), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, hasInstance) == offsetof(ClassOps, hasInstance), - "ClassOps and JSClassOps must be consistent"); -static_assert(offsetof(JSClassOps, trace) == offsetof(ClassOps, trace), - "ClassOps and JSClassOps must be consistent"); -static_assert(sizeof(JSClassOps) == sizeof(ClassOps), - "ClassOps and JSClassOps must be consistent"); - -static_assert(offsetof(JSClass, name) == offsetof(Class, name), - "Class and JSClass must be consistent"); -static_assert(offsetof(JSClass, flags) == offsetof(Class, flags), - "Class and JSClass must be consistent"); -static_assert(offsetof(JSClass, cOps) == offsetof(Class, cOps), - "Class and JSClass must be consistent"); -static_assert(sizeof(JSClass) == sizeof(Class), - "Class and JSClass must be consistent"); - -static MOZ_ALWAYS_INLINE const JSClass* -Jsvalify(const Class* c) -{ - return (const JSClass*)c; -} - -static MOZ_ALWAYS_INLINE const Class* -Valueify(const JSClass* c) -{ - return (const Class*)c; -} - -/** - * Enumeration describing possible values of the [[Class]] internal property - * value of objects. - */ -enum class ESClass { - Object, - Array, - Number, - String, - Boolean, - RegExp, - ArrayBuffer, - SharedArrayBuffer, - Date, - Set, - Map, - Promise, - MapIterator, - SetIterator, - Arguments, - Error, - - /** None of the above. */ - Other -}; - -/* Fills |vp| with the unboxed value for boxed types, or undefined otherwise. */ -bool -Unbox(JSContext* cx, JS::HandleObject obj, JS::MutableHandleValue vp); - -#ifdef DEBUG -JS_FRIEND_API(bool) -HasObjectMovedOp(JSObject* obj); -#endif - -} /* namespace js */ - -#endif /* js_Class_h */ diff --git a/android/armeabi/include/spidermonkey/js/Conversions.h b/android/armeabi/include/spidermonkey/js/Conversions.h deleted file mode 100644 index 1cee31c5..00000000 --- a/android/armeabi/include/spidermonkey/js/Conversions.h +++ /dev/null @@ -1,581 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* ECMAScript conversion operations. */ - -#ifndef js_Conversions_h -#define js_Conversions_h - -#include "mozilla/Casting.h" -#include "mozilla/FloatingPoint.h" -#include "mozilla/TypeTraits.h" - -#include <math.h> - -#include "jspubtd.h" - -#include "js/RootingAPI.h" -#include "js/Value.h" - -struct JSContext; - -namespace js { - -/* DO NOT CALL THIS. Use JS::ToBoolean. */ -extern JS_PUBLIC_API(bool) -ToBooleanSlow(JS::HandleValue v); - -/* DO NOT CALL THIS. Use JS::ToNumber. */ -extern JS_PUBLIC_API(bool) -ToNumberSlow(JSContext* cx, JS::HandleValue v, double* dp); - -/* DO NOT CALL THIS. Use JS::ToInt8. */ -extern JS_PUBLIC_API(bool) -ToInt8Slow(JSContext *cx, JS::HandleValue v, int8_t *out); - -/* DO NOT CALL THIS. Use JS::ToUint8. */ -extern JS_PUBLIC_API(bool) -ToUint8Slow(JSContext *cx, JS::HandleValue v, uint8_t *out); - -/* DO NOT CALL THIS. Use JS::ToInt16. */ -extern JS_PUBLIC_API(bool) -ToInt16Slow(JSContext *cx, JS::HandleValue v, int16_t *out); - -/* DO NOT CALL THIS. Use JS::ToInt32. */ -extern JS_PUBLIC_API(bool) -ToInt32Slow(JSContext* cx, JS::HandleValue v, int32_t* out); - -/* DO NOT CALL THIS. Use JS::ToUint32. */ -extern JS_PUBLIC_API(bool) -ToUint32Slow(JSContext* cx, JS::HandleValue v, uint32_t* out); - -/* DO NOT CALL THIS. Use JS::ToUint16. */ -extern JS_PUBLIC_API(bool) -ToUint16Slow(JSContext* cx, JS::HandleValue v, uint16_t* out); - -/* DO NOT CALL THIS. Use JS::ToInt64. */ -extern JS_PUBLIC_API(bool) -ToInt64Slow(JSContext* cx, JS::HandleValue v, int64_t* out); - -/* DO NOT CALL THIS. Use JS::ToUint64. */ -extern JS_PUBLIC_API(bool) -ToUint64Slow(JSContext* cx, JS::HandleValue v, uint64_t* out); - -/* DO NOT CALL THIS. Use JS::ToString. */ -extern JS_PUBLIC_API(JSString*) -ToStringSlow(JSContext* cx, JS::HandleValue v); - -/* DO NOT CALL THIS. Use JS::ToObject. */ -extern JS_PUBLIC_API(JSObject*) -ToObjectSlow(JSContext* cx, JS::HandleValue v, bool reportScanStack); - -} // namespace js - -namespace JS { - -namespace detail { - -#ifdef JS_DEBUG -/** - * Assert that we're not doing GC on cx, that we're in a request as - * needed, and that the compartments for cx and v are correct. - * Also check that GC would be safe at this point. - */ -extern JS_PUBLIC_API(void) -AssertArgumentsAreSane(JSContext* cx, HandleValue v); -#else -inline void AssertArgumentsAreSane(JSContext* cx, HandleValue v) -{} -#endif /* JS_DEBUG */ - -} // namespace detail - -/** - * ES6 draft 20141224, 7.1.1, second algorithm. - * - * Most users shouldn't call this -- use JS::ToBoolean, ToNumber, or ToString - * instead. This will typically only be called from custom convert hooks that - * wish to fall back to the ES6 default conversion behavior shared by most - * objects in JS, codified as OrdinaryToPrimitive. - */ -extern JS_PUBLIC_API(bool) -OrdinaryToPrimitive(JSContext* cx, HandleObject obj, JSType type, MutableHandleValue vp); - -/* ES6 draft 20141224, 7.1.2. */ -MOZ_ALWAYS_INLINE bool -ToBoolean(HandleValue v) -{ - if (v.isBoolean()) - return v.toBoolean(); - if (v.isInt32()) - return v.toInt32() != 0; - if (v.isNullOrUndefined()) - return false; - if (v.isDouble()) { - double d = v.toDouble(); - return !mozilla::IsNaN(d) && d != 0; - } - if (v.isSymbol()) - return true; - - /* The slow path handles strings and objects. */ - return js::ToBooleanSlow(v); -} - -/* ES6 draft 20141224, 7.1.3. */ -MOZ_ALWAYS_INLINE bool -ToNumber(JSContext* cx, HandleValue v, double* out) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isNumber()) { - *out = v.toNumber(); - return true; - } - return js::ToNumberSlow(cx, v, out); -} - -/* ES6 draft 20141224, ToInteger (specialized for doubles). */ -inline double -ToInteger(double d) -{ - if (d == 0) - return d; - - if (!mozilla::IsFinite(d)) { - if (mozilla::IsNaN(d)) - return 0; - return d; - } - - return d < 0 ? ceil(d) : floor(d); -} - -/* ES6 draft 20141224, 7.1.5. */ -MOZ_ALWAYS_INLINE bool -ToInt32(JSContext* cx, JS::HandleValue v, int32_t* out) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isInt32()) { - *out = v.toInt32(); - return true; - } - return js::ToInt32Slow(cx, v, out); -} - -/* ES6 draft 20141224, 7.1.6. */ -MOZ_ALWAYS_INLINE bool -ToUint32(JSContext* cx, HandleValue v, uint32_t* out) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isInt32()) { - *out = uint32_t(v.toInt32()); - return true; - } - return js::ToUint32Slow(cx, v, out); -} - -/* ES6 draft 20141224, 7.1.7. */ -MOZ_ALWAYS_INLINE bool -ToInt16(JSContext *cx, JS::HandleValue v, int16_t *out) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isInt32()) { - *out = int16_t(v.toInt32()); - return true; - } - return js::ToInt16Slow(cx, v, out); -} - -/* ES6 draft 20141224, 7.1.8. */ -MOZ_ALWAYS_INLINE bool -ToUint16(JSContext* cx, HandleValue v, uint16_t* out) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isInt32()) { - *out = uint16_t(v.toInt32()); - return true; - } - return js::ToUint16Slow(cx, v, out); -} - -/* ES6 draft 20141224, 7.1.9 */ -MOZ_ALWAYS_INLINE bool -ToInt8(JSContext *cx, JS::HandleValue v, int8_t *out) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isInt32()) { - *out = int8_t(v.toInt32()); - return true; - } - return js::ToInt8Slow(cx, v, out); -} - -/* ES6 ECMA-262, 7.1.10 */ -MOZ_ALWAYS_INLINE bool -ToUint8(JSContext *cx, JS::HandleValue v, uint8_t *out) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isInt32()) { - *out = uint8_t(v.toInt32()); - return true; - } - return js::ToUint8Slow(cx, v, out); -} - -/* - * Non-standard, with behavior similar to that of ToInt32, except in its - * producing an int64_t. - */ -MOZ_ALWAYS_INLINE bool -ToInt64(JSContext* cx, HandleValue v, int64_t* out) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isInt32()) { - *out = int64_t(v.toInt32()); - return true; - } - return js::ToInt64Slow(cx, v, out); -} - -/* - * Non-standard, with behavior similar to that of ToUint32, except in its - * producing a uint64_t. - */ -MOZ_ALWAYS_INLINE bool -ToUint64(JSContext* cx, HandleValue v, uint64_t* out) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isInt32()) { - *out = uint64_t(v.toInt32()); - return true; - } - return js::ToUint64Slow(cx, v, out); -} - -/* ES6 draft 20141224, 7.1.12. */ -MOZ_ALWAYS_INLINE JSString* -ToString(JSContext* cx, HandleValue v) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isString()) - return v.toString(); - return js::ToStringSlow(cx, v); -} - -/* ES6 draft 20141224, 7.1.13. */ -inline JSObject* -ToObject(JSContext* cx, HandleValue v) -{ - detail::AssertArgumentsAreSane(cx, v); - - if (v.isObject()) - return &v.toObject(); - return js::ToObjectSlow(cx, v, false); -} - -namespace detail { - -/* - * Convert a double value to ResultType (an unsigned integral type) using - * ECMAScript-style semantics (that is, in like manner to how ECMAScript's - * ToInt32 converts to int32_t). - * - * If d is infinite or NaN, return 0. - * Otherwise compute d2 = sign(d) * floor(abs(d)), and return the ResultType - * value congruent to d2 mod 2**(bit width of ResultType). - * - * The algorithm below is inspired by that found in - * <http://trac.webkit.org/changeset/67825/trunk/JavaScriptCore/runtime/JSValue.cpp> - * but has been generalized to all integer widths. - */ -template<typename ResultType> -inline ResultType -ToUintWidth(double d) -{ - static_assert(mozilla::IsUnsigned<ResultType>::value, - "ResultType must be an unsigned type"); - - uint64_t bits = mozilla::BitwiseCast<uint64_t>(d); - unsigned DoubleExponentShift = mozilla::FloatingPoint<double>::kExponentShift; - - // Extract the exponent component. (Be careful here! It's not technically - // the exponent in NaN, infinities, and subnormals.) - int_fast16_t exp = - int_fast16_t((bits & mozilla::FloatingPoint<double>::kExponentBits) >> DoubleExponentShift) - - int_fast16_t(mozilla::FloatingPoint<double>::kExponentBias); - - // If the exponent's less than zero, abs(d) < 1, so the result is 0. (This - // also handles subnormals.) - if (exp < 0) - return 0; - - uint_fast16_t exponent = mozilla::AssertedCast<uint_fast16_t>(exp); - - // If the exponent is greater than or equal to the bits of precision of a - // double plus ResultType's width, the number is either infinite, NaN, or - // too large to have lower-order bits in the congruent value. (Example: - // 2**84 is exactly representable as a double. The next exact double is - // 2**84 + 2**32. Thus if ResultType is int32_t, an exponent >= 84 implies - // floor(abs(d)) == 0 mod 2**32.) Return 0 in all these cases. - const size_t ResultWidth = CHAR_BIT * sizeof(ResultType); - if (exponent >= DoubleExponentShift + ResultWidth) - return 0; - - // The significand contains the bits that will determine the final result. - // Shift those bits left or right, according to the exponent, to their - // locations in the unsigned binary representation of floor(abs(d)). - static_assert(sizeof(ResultType) <= sizeof(uint64_t), - "Left-shifting below would lose upper bits"); - ResultType result = (exponent > DoubleExponentShift) - ? ResultType(bits << (exponent - DoubleExponentShift)) - : ResultType(bits >> (DoubleExponentShift - exponent)); - - // Two further complications remain. First, |result| may contain bogus - // sign/exponent bits. Second, IEEE-754 numbers' significands (excluding - // subnormals, but we already handled those) have an implicit leading 1 - // which may affect the final result. - // - // It may appear that there's complexity here depending on how ResultWidth - // and DoubleExponentShift relate, but it turns out there's not. - // - // Assume ResultWidth < DoubleExponentShift: - // Only right-shifts leave bogus bits in |result|. For this to happen, - // we must right-shift by > |DoubleExponentShift - ResultWidth|, implying - // |exponent < ResultWidth|. - // The implicit leading bit only matters if it appears in the final - // result -- if |2**exponent mod 2**ResultWidth != 0|. This implies - // |exponent < ResultWidth|. - // Otherwise assume ResultWidth >= DoubleExponentShift: - // Any left-shift less than |ResultWidth - DoubleExponentShift| leaves - // bogus bits in |result|. This implies |exponent < ResultWidth|. Any - // right-shift less than |ResultWidth| does too, which implies - // |DoubleExponentShift - ResultWidth < exponent|. By assumption, then, - // |exponent| is negative, but we excluded that above. So bogus bits - // need only |exponent < ResultWidth|. - // The implicit leading bit matters identically to the other case, so - // again, |exponent < ResultWidth|. - if (exponent < ResultWidth) { - ResultType implicitOne = ResultType(1) << exponent; - result &= implicitOne - 1; // remove bogus bits - result += implicitOne; // add the implicit bit - } - - // Compute the congruent value in the signed range. - return (bits & mozilla::FloatingPoint<double>::kSignBit) ? ~result + 1 : result; -} - -template<typename ResultType> -inline ResultType -ToIntWidth(double d) -{ - static_assert(mozilla::IsSigned<ResultType>::value, - "ResultType must be a signed type"); - - const ResultType MaxValue = (1ULL << (CHAR_BIT * sizeof(ResultType) - 1)) - 1; - const ResultType MinValue = -MaxValue - 1; - - typedef typename mozilla::MakeUnsigned<ResultType>::Type UnsignedResult; - UnsignedResult u = ToUintWidth<UnsignedResult>(d); - if (u <= UnsignedResult(MaxValue)) - return static_cast<ResultType>(u); - return (MinValue + static_cast<ResultType>(u - MaxValue)) - 1; -} - -} // namespace detail - -/* ES5 9.5 ToInt32 (specialized for doubles). */ -inline int32_t -ToInt32(double d) -{ - // clang crashes compiling this when targeting arm: - // https://llvm.org/bugs/show_bug.cgi?id=22974 -#if defined (__arm__) && defined (__GNUC__) && !defined(__clang__) - int32_t i; - uint32_t tmp0; - uint32_t tmp1; - uint32_t tmp2; - asm ( - // We use a pure integer solution here. In the 'softfp' ABI, the argument - // will start in r0 and r1, and VFP can't do all of the necessary ECMA - // conversions by itself so some integer code will be required anyway. A - // hybrid solution is faster on A9, but this pure integer solution is - // notably faster for A8. - - // %0 is the result register, and may alias either of the %[QR]1 registers. - // %Q4 holds the lower part of the mantissa. - // %R4 holds the sign, exponent, and the upper part of the mantissa. - // %1, %2 and %3 are used as temporary values. - - // Extract the exponent. -" mov %1, %R4, LSR #20\n" -" bic %1, %1, #(1 << 11)\n" // Clear the sign. - - // Set the implicit top bit of the mantissa. This clobbers a bit of the - // exponent, but we have already extracted that. -" orr %R4, %R4, #(1 << 20)\n" - - // Special Cases - // We should return zero in the following special cases: - // - Exponent is 0x000 - 1023: +/-0 or subnormal. - // - Exponent is 0x7ff - 1023: +/-INFINITY or NaN - // - This case is implicitly handled by the standard code path anyway, - // as shifting the mantissa up by the exponent will result in '0'. - // - // The result is composed of the mantissa, prepended with '1' and - // bit-shifted left by the (decoded) exponent. Note that because the r1[20] - // is the bit with value '1', r1 is effectively already shifted (left) by - // 20 bits, and r0 is already shifted by 52 bits. - - // Adjust the exponent to remove the encoding offset. If the decoded - // exponent is negative, quickly bail out with '0' as such values round to - // zero anyway. This also catches +/-0 and subnormals. -" sub %1, %1, #0xff\n" -" subs %1, %1, #0x300\n" -" bmi 8f\n" - - // %1 = (decoded) exponent >= 0 - // %R4 = upper mantissa and sign - - // ---- Lower Mantissa ---- -" subs %3, %1, #52\n" // Calculate exp-52 -" bmi 1f\n" - - // Shift r0 left by exp-52. - // Ensure that we don't overflow ARM's 8-bit shift operand range. - // We need to handle anything up to an 11-bit value here as we know that - // 52 <= exp <= 1024 (0x400). Any shift beyond 31 bits results in zero - // anyway, so as long as we don't touch the bottom 5 bits, we can use - // a logical OR to push long shifts into the 32 <= (exp&0xff) <= 255 range. -" bic %2, %3, #0xff\n" -" orr %3, %3, %2, LSR #3\n" - // We can now perform a straight shift, avoiding the need for any - // conditional instructions or extra branches. -" mov %Q4, %Q4, LSL %3\n" -" b 2f\n" -"1:\n" // Shift r0 right by 52-exp. - // We know that 0 <= exp < 52, and we can shift up to 255 bits so 52-exp - // will always be a valid shift and we can sk%3 the range check for this case. -" rsb %3, %1, #52\n" -" mov %Q4, %Q4, LSR %3\n" - - // %1 = (decoded) exponent - // %R4 = upper mantissa and sign - // %Q4 = partially-converted integer - -"2:\n" - // ---- Upper Mantissa ---- - // This is much the same as the lower mantissa, with a few different - // boundary checks and some masking to hide the exponent & sign bit in the - // upper word. - // Note that the upper mantissa is pre-shifted by 20 in %R4, but we shift - // it left more to remove the sign and exponent so it is effectively - // pre-shifted by 31 bits. -" subs %3, %1, #31\n" // Calculate exp-31 -" mov %1, %R4, LSL #11\n" // Re-use %1 as a temporary register. -" bmi 3f\n" - - // Shift %R4 left by exp-31. - // Avoid overflowing the 8-bit shift range, as before. -" bic %2, %3, #0xff\n" -" orr %3, %3, %2, LSR #3\n" - // Perform the shift. -" mov %2, %1, LSL %3\n" -" b 4f\n" -"3:\n" // Shift r1 right by 31-exp. - // We know that 0 <= exp < 31, and we can shift up to 255 bits so 31-exp - // will always be a valid shift and we can skip the range check for this case. -" rsb %3, %3, #0\n" // Calculate 31-exp from -(exp-31) -" mov %2, %1, LSR %3\n" // Thumb-2 can't do "LSR %3" in "orr". - - // %Q4 = partially-converted integer (lower) - // %R4 = upper mantissa and sign - // %2 = partially-converted integer (upper) - -"4:\n" - // Combine the converted parts. -" orr %Q4, %Q4, %2\n" - // Negate the result if we have to, and move it to %0 in the process. To - // avoid conditionals, we can do this by inverting on %R4[31], then adding - // %R4[31]>>31. -" eor %Q4, %Q4, %R4, ASR #31\n" -" add %0, %Q4, %R4, LSR #31\n" -" b 9f\n" -"8:\n" - // +/-INFINITY, +/-0, subnormals, NaNs, and anything else out-of-range that - // will result in a conversion of '0'. -" mov %0, #0\n" -"9:\n" - : "=r" (i), "=&r" (tmp0), "=&r" (tmp1), "=&r" (tmp2), "=&r" (d) - : "4" (d) - : "cc" - ); - return i; -#else - return detail::ToIntWidth<int32_t>(d); -#endif -} - -/* ES5 9.6 (specialized for doubles). */ -inline uint32_t -ToUint32(double d) -{ - return detail::ToUintWidth<uint32_t>(d); -} - -/* WEBIDL 4.2.4 */ -inline int8_t -ToInt8(double d) -{ - return detail::ToIntWidth<int8_t>(d); -} - -/* ECMA-262 7.1.10 ToUInt8() specialized for doubles. */ -inline int8_t -ToUint8(double d) -{ - return detail::ToUintWidth<uint8_t>(d); -} - -/* WEBIDL 4.2.6 */ -inline int16_t -ToInt16(double d) -{ - return detail::ToIntWidth<int16_t>(d); -} - -inline uint16_t -ToUint16(double d) -{ - return detail::ToUintWidth<uint16_t>(d); -} - -/* WEBIDL 4.2.10 */ -inline int64_t -ToInt64(double d) -{ - return detail::ToIntWidth<int64_t>(d); -} - -/* WEBIDL 4.2.11 */ -inline uint64_t -ToUint64(double d) -{ - return detail::ToUintWidth<uint64_t>(d); -} - -} // namespace JS - -#endif /* js_Conversions_h */ diff --git a/android/armeabi/include/spidermonkey/js/Date.h b/android/armeabi/include/spidermonkey/js/Date.h deleted file mode 100644 index cba0ea87..00000000 --- a/android/armeabi/include/spidermonkey/js/Date.h +++ /dev/null @@ -1,170 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* JavaScript date/time computation and creation functions. */ - -#ifndef js_Date_h -#define js_Date_h - -/* - * Dates in JavaScript are defined by IEEE-754 double precision numbers from - * the set: - * - * { t ∈ ℕ : -8.64e15 ≤ t ≤ +8.64e15 } ∪ { NaN } - * - * The single NaN value represents any invalid-date value. All other values - * represent idealized durations in milliseconds since the UTC epoch. (Leap - * seconds are ignored; leap days are not.) +0 is the only zero in this set. - * The limit represented by 8.64e15 milliseconds is 100 million days either - * side of 00:00 January 1, 1970 UTC. - * - * Dates in the above set are represented by the |ClippedTime| class. The - * double type is a superset of the above set, so it *may* (but need not) - * represent a date. Use ECMAScript's |TimeClip| method to produce a date from - * a double. - * - * Date *objects* are simply wrappers around |TimeClip|'d numbers, with a bunch - * of accessor methods to the various aspects of the represented date. - */ - -#include "mozilla/FloatingPoint.h" -#include "mozilla/MathAlgorithms.h" - -#include "js/Conversions.h" -#include "js/Value.h" - -struct JSContext; - -namespace JS { - -/** - * Re-query the system to determine the current time zone adjustment from UTC, - * including any component due to DST. If the time zone has changed, this will - * cause all Date object non-UTC methods and formatting functions to produce - * appropriately adjusted results. - * - * Left to its own devices, SpiderMonkey itself may occasionally call this - * method to attempt to keep up with system time changes. However, no - * particular frequency of checking is guaranteed. Embedders unable to accept - * occasional inaccuracies should call this method in response to system time - * changes, or immediately before operations requiring instantaneous - * correctness, to guarantee correct behavior. - */ -extern JS_PUBLIC_API(void) -ResetTimeZone(); - -class ClippedTime; -inline ClippedTime TimeClip(double time); - -/* - * |ClippedTime| represents the limited subset of dates/times described above. - * - * An invalid date/time may be created through the |ClippedTime::invalid| - * method. Otherwise, a |ClippedTime| may be created using the |TimeClip| - * method. - * - * In typical use, the user might wish to manipulate a timestamp. The user - * performs a series of operations on it, but the final value might not be a - * date as defined above -- it could have overflowed, acquired a fractional - * component, &c. So as a *final* step, the user passes that value through - * |TimeClip| to produce a number restricted to JavaScript's date range. - * - * APIs that accept a JavaScript date value thus accept a |ClippedTime|, not a - * double. This ensures that date/time APIs will only ever receive acceptable - * JavaScript dates. This also forces users to perform any desired clipping, - * as only the user knows what behavior is desired when clipping occurs. - */ -class ClippedTime -{ - double t; - - explicit ClippedTime(double time) : t(time) {} - friend ClippedTime TimeClip(double time); - - public: - // Create an invalid date. - ClippedTime() : t(mozilla::UnspecifiedNaN<double>()) {} - - // Create an invalid date/time, more explicitly; prefer this to the default - // constructor. - static ClippedTime invalid() { return ClippedTime(); } - - double toDouble() const { return t; } - - bool isValid() const { return !mozilla::IsNaN(t); } -}; - -// ES6 20.3.1.15. -// -// Clip a double to JavaScript's date range (or to an invalid date) using the -// ECMAScript TimeClip algorithm. -inline ClippedTime -TimeClip(double time) -{ - // Steps 1-2. - const double MaxTimeMagnitude = 8.64e15; - if (!mozilla::IsFinite(time) || mozilla::Abs(time) > MaxTimeMagnitude) - return ClippedTime(mozilla::UnspecifiedNaN<double>()); - - // Step 3. - return ClippedTime(ToInteger(time) + (+0.0)); -} - -// Produce a double Value from the given time. Because times may be NaN, -// prefer using this to manual canonicalization. -inline Value -TimeValue(ClippedTime time) -{ - return DoubleValue(JS::CanonicalizeNaN(time.toDouble())); -} - -// Create a new Date object whose [[DateValue]] internal slot contains the -// clipped |time|. (Users who must represent times outside that range must use -// another representation.) -extern JS_PUBLIC_API(JSObject*) -NewDateObject(JSContext* cx, ClippedTime time); - -// Year is a year, month is 0-11, day is 1-based. The return value is a number -// of milliseconds since the epoch. -// -// Consistent with the MakeDate algorithm defined in ECMAScript, this value is -// *not* clipped! Use JS::TimeClip if you need a clipped date. -JS_PUBLIC_API(double) -MakeDate(double year, unsigned month, unsigned day); - -// Takes an integer number of milliseconds since the epoch and returns the -// year. Can return NaN, and will do so if NaN is passed in. -JS_PUBLIC_API(double) -YearFromTime(double time); - -// Takes an integer number of milliseconds since the epoch and returns the -// month (0-11). Can return NaN, and will do so if NaN is passed in. -JS_PUBLIC_API(double) -MonthFromTime(double time); - -// Takes an integer number of milliseconds since the epoch and returns the -// day (1-based). Can return NaN, and will do so if NaN is passed in. -JS_PUBLIC_API(double) -DayFromTime(double time); - -// Takes an integer year and returns the number of days from epoch to the given -// year. -// NOTE: The calculation performed by this function is literally that given in -// the ECMAScript specification. Nonfinite years, years containing fractional -// components, and years outside ECMAScript's date range are not handled with -// any particular intelligence. Garbage in, garbage out. -JS_PUBLIC_API(double) -DayFromYear(double year); - -// Takes an integer number of milliseconds since the epoch and an integer year, -// returns the number of days in that year. If |time| is nonfinite, returns NaN. -// Otherwise |time| *must* correspond to a time within the valid year |year|. -// This should usually be ensured by computing |year| as |JS::DayFromYear(time)|. -JS_PUBLIC_API(double) -DayWithinYear(double time, double year); - -} // namespace JS - -#endif /* js_Date_h */ diff --git a/android/armeabi/include/spidermonkey/js/Debug.h b/android/armeabi/include/spidermonkey/js/Debug.h deleted file mode 100644 index 3e4183f0..00000000 --- a/android/armeabi/include/spidermonkey/js/Debug.h +++ /dev/null @@ -1,384 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// Interfaces by which the embedding can interact with the Debugger API. - -#ifndef js_Debug_h -#define js_Debug_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/MemoryReporting.h" - -#include "jsapi.h" -#include "jspubtd.h" - -#include "js/GCAPI.h" -#include "js/RootingAPI.h" -#include "js/TypeDecls.h" - -namespace js { -class Debugger; -} // namespace js - -namespace JS { -namespace dbg { - -// Helping embedding code build objects for Debugger -// ------------------------------------------------- -// -// Some Debugger API features lean on the embedding application to construct -// their result values. For example, Debugger.Frame.prototype.scriptEntryReason -// calls hooks provided by the embedding to construct values explaining why it -// invoked JavaScript; if F is a frame called from a mouse click event handler, -// F.scriptEntryReason would return an object of the form: -// -// { eventType: "mousedown", event: <object> } -// -// where <object> is a Debugger.Object whose referent is the event being -// dispatched. -// -// However, Debugger implements a trust boundary. Debuggee code may be -// considered untrusted; debugger code needs to be protected from debuggee -// getters, setters, proxies, Object.watch watchpoints, and any other feature -// that might accidentally cause debugger code to set the debuggee running. The -// Debugger API tries to make it easy to write safe debugger code by only -// offering access to debuggee objects via Debugger.Object instances, which -// ensure that only those operations whose explicit purpose is to invoke -// debuggee code do so. But this protective membrane is only helpful if we -// interpose Debugger.Object instances in all the necessary spots. -// -// SpiderMonkey's compartment system also implements a trust boundary. The -// debuggee and debugger are always in different compartments. Inter-compartment -// work requires carefully tracking which compartment each JSObject or JS::Value -// belongs to, and ensuring that is is correctly wrapped for each operation. -// -// It seems precarious to expect the embedding's hooks to implement these trust -// boundaries. Instead, the JS::dbg::Builder API segregates the code which -// constructs trusted objects from that which deals with untrusted objects. -// Trusted objects have an entirely different C++ type, so code that improperly -// mixes trusted and untrusted objects is caught at compile time. -// -// In the structure shown above, there are two trusted objects, and one -// untrusted object: -// -// - The overall object, with the 'eventType' and 'event' properties, is a -// trusted object. We're going to return it to D.F.p.scriptEntryReason's -// caller, which will handle it directly. -// -// - The Debugger.Object instance appearing as the value of the 'event' property -// is a trusted object. It belongs to the same Debugger instance as the -// Debugger.Frame instance whose scriptEntryReason accessor was called, and -// presents a safe reflection-oriented API for inspecting its referent, which -// is: -// -// - The actual event object, an untrusted object, and the referent of the -// Debugger.Object above. (Content can do things like replacing accessors on -// Event.prototype.) -// -// Using JS::dbg::Builder, all objects and values the embedding deals with -// directly are considered untrusted, and are assumed to be debuggee values. The -// only way to construct trusted objects is to use Builder's own methods, which -// return a separate Object type. The only way to set a property on a trusted -// object is through that Object type. The actual trusted object is never -// exposed to the embedding. -// -// So, for example, the embedding might use code like the following to construct -// the object shown above, given a Builder passed to it by Debugger: -// -// bool -// MyScriptEntryReason::explain(JSContext* cx, -// Builder& builder, -// Builder::Object& result) -// { -// JSObject* eventObject = ... obtain debuggee event object somehow ...; -// if (!eventObject) -// return false; -// result = builder.newObject(cx); -// return result && -// result.defineProperty(cx, "eventType", SafelyFetchType(eventObject)) && -// result.defineProperty(cx, "event", eventObject); -// } -// -// -// Object::defineProperty also accepts an Object as the value to store on the -// property. By its type, we know that the value is trusted, so we set it -// directly as the property's value, without interposing a Debugger.Object -// wrapper. This allows the embedding to builted nested structures of trusted -// objects. -// -// The Builder and Builder::Object methods take care of doing whatever -// compartment switching and wrapping are necessary to construct the trusted -// values in the Debugger's compartment. -// -// The Object type is self-rooting. Construction, assignment, and destruction -// all properly root the referent object. - -class BuilderOrigin; - -class Builder { - // The Debugger instance whose client we are building a value for. We build - // objects in this object's compartment. - PersistentRootedObject debuggerObject; - - // debuggerObject's Debugger structure, for convenience. - js::Debugger* debugger; - - // Check that |thing| is in the same compartment as our debuggerObject. Used - // for assertions when constructing BuiltThings. We can overload this as we - // add more instantiations of BuiltThing. -#if DEBUG - void assertBuilt(JSObject* obj); -#else - void assertBuilt(JSObject* obj) { } -#endif - - protected: - // A reference to a trusted object or value. At the moment, we only use it - // with JSObject*. - template<typename T> - class BuiltThing { - friend class BuilderOrigin; - - protected: - // The Builder to which this trusted thing belongs. - Builder& owner; - - // A rooted reference to our value. - PersistentRooted<T> value; - - BuiltThing(JSContext* cx, Builder& owner_, T value_ = GCPolicy<T>::initial()) - : owner(owner_), value(cx, value_) - { - owner.assertBuilt(value_); - } - - // Forward some things from our owner, for convenience. - js::Debugger* debugger() const { return owner.debugger; } - JSObject* debuggerObject() const { return owner.debuggerObject; } - - public: - BuiltThing(const BuiltThing& rhs) : owner(rhs.owner), value(rhs.value) { } - BuiltThing& operator=(const BuiltThing& rhs) { - MOZ_ASSERT(&owner == &rhs.owner); - owner.assertBuilt(rhs.value); - value = rhs.value; - return *this; - } - - explicit operator bool() const { - // If we ever instantiate BuiltThing<Value>, this might not suffice. - return value; - } - - private: - BuiltThing() = delete; - }; - - public: - // A reference to a trusted object, possibly null. Instances of Object are - // always properly rooted. They can be copied and assigned, as if they were - // pointers. - class Object: private BuiltThing<JSObject*> { - friend class Builder; // for construction - friend class BuilderOrigin; // for unwrapping - - typedef BuiltThing<JSObject*> Base; - - // This is private, because only Builders can create Objects that - // actually point to something (hence the 'friend' declaration). - Object(JSContext* cx, Builder& owner_, HandleObject obj) : Base(cx, owner_, obj.get()) { } - - bool definePropertyToTrusted(JSContext* cx, const char* name, - JS::MutableHandleValue value); - - public: - Object(JSContext* cx, Builder& owner_) : Base(cx, owner_, nullptr) { } - Object(const Object& rhs) : Base(rhs) { } - - // Our automatically-generated assignment operator can see our base - // class's assignment operator, so we don't need to write one out here. - - // Set the property named |name| on this object to |value|. - // - // If |value| is a string or primitive, re-wrap it for the debugger's - // compartment. - // - // If |value| is an object, assume it is a debuggee object and make a - // Debugger.Object instance referring to it. Set that as the propery's - // value. - // - // If |value| is another trusted object, store it directly as the - // property's value. - // - // On error, report the problem on cx and return false. - bool defineProperty(JSContext* cx, const char* name, JS::HandleValue value); - bool defineProperty(JSContext* cx, const char* name, JS::HandleObject value); - bool defineProperty(JSContext* cx, const char* name, Object& value); - - using Base::operator bool; - }; - - // Build an empty object for direct use by debugger code, owned by this - // Builder. If an error occurs, report it on cx and return a false Object. - Object newObject(JSContext* cx); - - protected: - Builder(JSContext* cx, js::Debugger* debugger); -}; - -// Debugger itself instantiates this subclass of Builder, which can unwrap -// BuiltThings that belong to it. -class BuilderOrigin : public Builder { - template<typename T> - T unwrapAny(const BuiltThing<T>& thing) { - MOZ_ASSERT(&thing.owner == this); - return thing.value.get(); - } - - public: - BuilderOrigin(JSContext* cx, js::Debugger* debugger_) - : Builder(cx, debugger_) - { } - - JSObject* unwrap(Object& object) { return unwrapAny(object); } -}; - - - -// Finding the size of blocks allocated with malloc -// ------------------------------------------------ -// -// Debugger.Memory wants to be able to report how many bytes items in memory are -// consuming. To do this, it needs a function that accepts a pointer to a block, -// and returns the number of bytes allocated to that block. SpiderMonkey itself -// doesn't know which function is appropriate to use, but the embedding does. - -// Tell Debuggers in |cx| to use |mallocSizeOf| to find the size of -// malloc'd blocks. -JS_PUBLIC_API(void) -SetDebuggerMallocSizeOf(JSContext* cx, mozilla::MallocSizeOf mallocSizeOf); - -// Get the MallocSizeOf function that the given context is using to find the -// size of malloc'd blocks. -JS_PUBLIC_API(mozilla::MallocSizeOf) -GetDebuggerMallocSizeOf(JSContext* cx); - - - -// Debugger and Garbage Collection Events -// -------------------------------------- -// -// The Debugger wants to report about its debuggees' GC cycles, however entering -// JS after a GC is troublesome since SpiderMonkey will often do something like -// force a GC and then rely on the nursery being empty. If we call into some -// Debugger's hook after the GC, then JS runs and the nursery won't be -// empty. Instead, we rely on embedders to call back into SpiderMonkey after a -// GC and notify Debuggers to call their onGarbageCollection hook. - - -// For each Debugger that observed a debuggee involved in the given GC event, -// call its `onGarbageCollection` hook. -JS_PUBLIC_API(bool) -FireOnGarbageCollectionHook(JSContext* cx, GarbageCollectionEvent::Ptr&& data); - - - -// Handlers for observing Promises -// ------------------------------- -// -// The Debugger wants to observe behavior of promises, which are implemented by -// Gecko with webidl and which SpiderMonkey knows nothing about. On the other -// hand, Gecko knows nothing about which (if any) debuggers are observing a -// promise's global. The compromise is that Gecko is responsible for calling -// these handlers at the appropriate times, and SpiderMonkey will handle -// notifying any Debugger instances that are observing the given promise's -// global. - -// Notify any Debugger instances observing this promise's global that a new -// promise was allocated. -JS_PUBLIC_API(void) -onNewPromise(JSContext* cx, HandleObject promise); - -// Notify any Debugger instances observing this promise's global that the -// promise has settled (ie, it has either been fulfilled or rejected). Note that -// this is *not* equivalent to the promise resolution (ie, the promise's fate -// getting locked in) because you can resolve a promise with another pending -// promise, in which case neither promise has settled yet. -// -// It is Gecko's responsibility to ensure that this is never called on the same -// promise more than once (because a promise can only make the transition from -// unsettled to settled once). -JS_PUBLIC_API(void) -onPromiseSettled(JSContext* cx, HandleObject promise); - - - -// Return true if the given value is a Debugger object, false otherwise. -JS_PUBLIC_API(bool) -IsDebugger(JSObject& obj); - -// Append each of the debuggee global objects observed by the Debugger object -// |dbgObj| to |vector|. Returns true on success, false on failure. -JS_PUBLIC_API(bool) -GetDebuggeeGlobals(JSContext* cx, JSObject& dbgObj, AutoObjectVector& vector); - - -// Hooks for reporting where JavaScript execution began. -// -// Our performance tools would like to be able to label blocks of JavaScript -// execution with the function name and source location where execution began: -// the event handler, the callback, etc. -// -// Construct an instance of this class on the stack, providing a JSContext -// belonging to the runtime in which execution will occur. Each time we enter -// JavaScript --- specifically, each time we push a JavaScript stack frame that -// has no older JS frames younger than this AutoEntryMonitor --- we will -// call the appropriate |Entry| member function to indicate where we've begun -// execution. - -class MOZ_STACK_CLASS AutoEntryMonitor { - JSRuntime* runtime_; - AutoEntryMonitor* savedMonitor_; - - public: - explicit AutoEntryMonitor(JSContext* cx); - ~AutoEntryMonitor(); - - // SpiderMonkey reports the JavaScript entry points occuring within this - // AutoEntryMonitor's scope to the following member functions, which the - // embedding is expected to override. - // - // It is important to note that |asyncCause| is owned by the caller and its - // lifetime must outlive the lifetime of the AutoEntryMonitor object. It is - // strongly encouraged that |asyncCause| be a string constant or similar - // statically allocated string. - - // We have begun executing |function|. Note that |function| may not be the - // actual closure we are running, but only the canonical function object to - // which the script refers. - virtual void Entry(JSContext* cx, JSFunction* function, - HandleValue asyncStack, - const char* asyncCause) = 0; - - // Execution has begun at the entry point of |script|, which is not a - // function body. (This is probably being executed by 'eval' or some - // JSAPI equivalent.) - virtual void Entry(JSContext* cx, JSScript* script, - HandleValue asyncStack, - const char* asyncCause) = 0; - - // Execution of the function or script has ended. - virtual void Exit(JSContext* cx) { } -}; - - - -} // namespace dbg -} // namespace JS - - -#endif /* js_Debug_h */ diff --git a/android/armeabi/include/spidermonkey/js/GCAPI.h b/android/armeabi/include/spidermonkey/js/GCAPI.h deleted file mode 100644 index 7a6675ca..00000000 --- a/android/armeabi/include/spidermonkey/js/GCAPI.h +++ /dev/null @@ -1,723 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_GCAPI_h -#define js_GCAPI_h - -#include "mozilla/Vector.h" - -#include "js/GCAnnotations.h" -#include "js/HeapAPI.h" -#include "js/UniquePtr.h" - -namespace js { -namespace gc { -class GCRuntime; -} // namespace gc -namespace gcstats { -struct Statistics; -} // namespace gcstats -} // namespace js - -typedef enum JSGCMode { - /** Perform only global GCs. */ - JSGC_MODE_GLOBAL = 0, - - /** Perform per-zone GCs until too much garbage has accumulated. */ - JSGC_MODE_ZONE = 1, - - /** - * Collect in short time slices rather than all at once. Implies - * JSGC_MODE_ZONE. - */ - JSGC_MODE_INCREMENTAL = 2 -} JSGCMode; - -/** - * Kinds of js_GC invocation. - */ -typedef enum JSGCInvocationKind { - /* Normal invocation. */ - GC_NORMAL = 0, - - /* Minimize GC triggers and release empty GC chunks right away. */ - GC_SHRINK = 1 -} JSGCInvocationKind; - -namespace JS { - -#define GCREASONS(D) \ - /* Reasons internal to the JS engine */ \ - D(API) \ - D(EAGER_ALLOC_TRIGGER) \ - D(DESTROY_RUNTIME) \ - D(UNUSED0) \ - D(LAST_DITCH) \ - D(TOO_MUCH_MALLOC) \ - D(ALLOC_TRIGGER) \ - D(DEBUG_GC) \ - D(COMPARTMENT_REVIVED) \ - D(RESET) \ - D(OUT_OF_NURSERY) \ - D(EVICT_NURSERY) \ - D(FULL_STORE_BUFFER) \ - D(SHARED_MEMORY_LIMIT) \ - D(UNUSED1) \ - D(INCREMENTAL_TOO_SLOW) \ - D(ABORT_GC) \ - \ - /* These are reserved for future use. */ \ - D(RESERVED0) \ - D(RESERVED1) \ - D(RESERVED2) \ - D(RESERVED3) \ - D(RESERVED4) \ - D(RESERVED5) \ - D(RESERVED6) \ - D(RESERVED7) \ - D(RESERVED8) \ - D(RESERVED9) \ - D(RESERVED10) \ - D(RESERVED11) \ - D(RESERVED12) \ - D(RESERVED13) \ - D(RESERVED14) \ - D(RESERVED15) \ - \ - /* Reasons from Firefox */ \ - D(DOM_WINDOW_UTILS) \ - D(COMPONENT_UTILS) \ - D(MEM_PRESSURE) \ - D(CC_WAITING) \ - D(CC_FORCED) \ - D(LOAD_END) \ - D(POST_COMPARTMENT) \ - D(PAGE_HIDE) \ - D(NSJSCONTEXT_DESTROY) \ - D(SET_NEW_DOCUMENT) \ - D(SET_DOC_SHELL) \ - D(DOM_UTILS) \ - D(DOM_IPC) \ - D(DOM_WORKER) \ - D(INTER_SLICE_GC) \ - D(REFRESH_FRAME) \ - D(FULL_GC_TIMER) \ - D(SHUTDOWN_CC) \ - D(FINISH_LARGE_EVALUATE) \ - D(USER_INACTIVE) \ - D(XPCONNECT_SHUTDOWN) - -namespace gcreason { - -/* GCReasons will end up looking like JSGC_MAYBEGC */ -enum Reason { -#define MAKE_REASON(name) name, - GCREASONS(MAKE_REASON) -#undef MAKE_REASON - NO_REASON, - NUM_REASONS, - - /* - * For telemetry, we want to keep a fixed max bucket size over time so we - * don't have to switch histograms. 100 is conservative; as of this writing - * there are 52. But the cost of extra buckets seems to be low while the - * cost of switching histograms is high. - */ - NUM_TELEMETRY_REASONS = 100 -}; - -/** - * Get a statically allocated C string explaining the given GC reason. - */ -extern JS_PUBLIC_API(const char*) -ExplainReason(JS::gcreason::Reason reason); - -} /* namespace gcreason */ - -/* - * Zone GC: - * - * SpiderMonkey's GC is capable of performing a collection on an arbitrary - * subset of the zones in the system. This allows an embedding to minimize - * collection time by only collecting zones that have run code recently, - * ignoring the parts of the heap that are unlikely to have changed. - * - * When triggering a GC using one of the functions below, it is first necessary - * to select the zones to be collected. To do this, you can call - * PrepareZoneForGC on each zone, or you can call PrepareForFullGC to select - * all zones. Failing to select any zone is an error. - */ - -/** - * Schedule the given zone to be collected as part of the next GC. - */ -extern JS_PUBLIC_API(void) -PrepareZoneForGC(Zone* zone); - -/** - * Schedule all zones to be collected in the next GC. - */ -extern JS_PUBLIC_API(void) -PrepareForFullGC(JSContext* cx); - -/** - * When performing an incremental GC, the zones that were selected for the - * previous incremental slice must be selected in subsequent slices as well. - * This function selects those slices automatically. - */ -extern JS_PUBLIC_API(void) -PrepareForIncrementalGC(JSContext* cx); - -/** - * Returns true if any zone in the system has been scheduled for GC with one of - * the functions above or by the JS engine. - */ -extern JS_PUBLIC_API(bool) -IsGCScheduled(JSContext* cx); - -/** - * Undoes the effect of the Prepare methods above. The given zone will not be - * collected in the next GC. - */ -extern JS_PUBLIC_API(void) -SkipZoneForGC(Zone* zone); - -/* - * Non-Incremental GC: - * - * The following functions perform a non-incremental GC. - */ - -/** - * Performs a non-incremental collection of all selected zones. - * - * If the gckind argument is GC_NORMAL, then some objects that are unreachable - * from the program may still be alive afterwards because of internal - * references; if GC_SHRINK is passed then caches and other temporary references - * to objects will be cleared and all unreferenced objects will be removed from - * the system. - */ -extern JS_PUBLIC_API(void) -GCForReason(JSContext* cx, JSGCInvocationKind gckind, gcreason::Reason reason); - -/* - * Incremental GC: - * - * Incremental GC divides the full mark-and-sweep collection into multiple - * slices, allowing client JavaScript code to run between each slice. This - * allows interactive apps to avoid long collection pauses. Incremental GC does - * not make collection take less time, it merely spreads that time out so that - * the pauses are less noticable. - * - * For a collection to be carried out incrementally the following conditions - * must be met: - * - The collection must be run by calling JS::IncrementalGC() rather than - * JS_GC(). - * - The GC mode must have been set to JSGC_MODE_INCREMENTAL with - * JS_SetGCParameter(). - * - * Note: Even if incremental GC is enabled and working correctly, - * non-incremental collections can still happen when low on memory. - */ - -/** - * Begin an incremental collection and perform one slice worth of work. When - * this function returns, the collection may not be complete. - * IncrementalGCSlice() must be called repeatedly until - * !IsIncrementalGCInProgress(cx). - * - * Note: SpiderMonkey's GC is not realtime. Slices in practice may be longer or - * shorter than the requested interval. - */ -extern JS_PUBLIC_API(void) -StartIncrementalGC(JSContext* cx, JSGCInvocationKind gckind, gcreason::Reason reason, - int64_t millis = 0); - -/** - * Perform a slice of an ongoing incremental collection. When this function - * returns, the collection may not be complete. It must be called repeatedly - * until !IsIncrementalGCInProgress(cx). - * - * Note: SpiderMonkey's GC is not realtime. Slices in practice may be longer or - * shorter than the requested interval. - */ -extern JS_PUBLIC_API(void) -IncrementalGCSlice(JSContext* cx, gcreason::Reason reason, int64_t millis = 0); - -/** - * If IsIncrementalGCInProgress(cx), this call finishes the ongoing collection - * by performing an arbitrarily long slice. If !IsIncrementalGCInProgress(cx), - * this is equivalent to GCForReason. When this function returns, - * IsIncrementalGCInProgress(cx) will always be false. - */ -extern JS_PUBLIC_API(void) -FinishIncrementalGC(JSContext* cx, gcreason::Reason reason); - -/** - * If IsIncrementalGCInProgress(cx), this call aborts the ongoing collection and - * performs whatever work needs to be done to return the collector to its idle - * state. This may take an arbitrarily long time. When this function returns, - * IsIncrementalGCInProgress(cx) will always be false. - */ -extern JS_PUBLIC_API(void) -AbortIncrementalGC(JSContext* cx); - -namespace dbg { - -// The `JS::dbg::GarbageCollectionEvent` class is essentially a view of the -// `js::gcstats::Statistics` data without the uber implementation-specific bits. -// It should generally be palatable for web developers. -class GarbageCollectionEvent -{ - // The major GC number of the GC cycle this data pertains to. - uint64_t majorGCNumber_; - - // Reference to a non-owned, statically allocated C string. This is a very - // short reason explaining why a GC was triggered. - const char* reason; - - // Reference to a nullable, non-owned, statically allocated C string. If the - // collection was forced to be non-incremental, this is a short reason of - // why the GC could not perform an incremental collection. - const char* nonincrementalReason; - - // Represents a single slice of a possibly multi-slice incremental garbage - // collection. - struct Collection { - double startTimestamp; - double endTimestamp; - }; - - // The set of garbage collection slices that made up this GC cycle. - mozilla::Vector<Collection> collections; - - GarbageCollectionEvent(const GarbageCollectionEvent& rhs) = delete; - GarbageCollectionEvent& operator=(const GarbageCollectionEvent& rhs) = delete; - - public: - explicit GarbageCollectionEvent(uint64_t majorGCNum) - : majorGCNumber_(majorGCNum) - , reason(nullptr) - , nonincrementalReason(nullptr) - , collections() - { } - - using Ptr = js::UniquePtr<GarbageCollectionEvent>; - static Ptr Create(JSRuntime* rt, ::js::gcstats::Statistics& stats, uint64_t majorGCNumber); - - JSObject* toJSObject(JSContext* cx) const; - - uint64_t majorGCNumber() const { return majorGCNumber_; } -}; - -} // namespace dbg - -enum GCProgress { - /* - * During non-incremental GC, the GC is bracketed by JSGC_CYCLE_BEGIN/END - * callbacks. During an incremental GC, the sequence of callbacks is as - * follows: - * JSGC_CYCLE_BEGIN, JSGC_SLICE_END (first slice) - * JSGC_SLICE_BEGIN, JSGC_SLICE_END (second slice) - * ... - * JSGC_SLICE_BEGIN, JSGC_CYCLE_END (last slice) - */ - - GC_CYCLE_BEGIN, - GC_SLICE_BEGIN, - GC_SLICE_END, - GC_CYCLE_END -}; - -struct JS_PUBLIC_API(GCDescription) { - bool isZone_; - JSGCInvocationKind invocationKind_; - gcreason::Reason reason_; - - GCDescription(bool isZone, JSGCInvocationKind kind, gcreason::Reason reason) - : isZone_(isZone), invocationKind_(kind), reason_(reason) {} - - char16_t* formatSliceMessage(JSContext* cx) const; - char16_t* formatSummaryMessage(JSContext* cx) const; - char16_t* formatJSON(JSContext* cx, uint64_t timestamp) const; - - JS::dbg::GarbageCollectionEvent::Ptr toGCEvent(JSContext* cx) const; -}; - -typedef void -(* GCSliceCallback)(JSContext* cx, GCProgress progress, const GCDescription& desc); - -/** - * The GC slice callback is called at the beginning and end of each slice. This - * callback may be used for GC notifications as well as to perform additional - * marking. - */ -extern JS_PUBLIC_API(GCSliceCallback) -SetGCSliceCallback(JSContext* cx, GCSliceCallback callback); - -/** - * Describes the progress of an observed nursery collection. - */ -enum class GCNurseryProgress { - /** - * The nursery collection is starting. - */ - GC_NURSERY_COLLECTION_START, - /** - * The nursery collection is ending. - */ - GC_NURSERY_COLLECTION_END -}; - -/** - * A nursery collection callback receives the progress of the nursery collection - * and the reason for the collection. - */ -using GCNurseryCollectionCallback = void(*)(JSContext* cx, GCNurseryProgress progress, - gcreason::Reason reason); - -/** - * Set the nursery collection callback for the given runtime. When set, it will - * be called at the start and end of every nursery collection. - */ -extern JS_PUBLIC_API(GCNurseryCollectionCallback) -SetGCNurseryCollectionCallback(JSContext* cx, GCNurseryCollectionCallback callback); - -typedef void -(* DoCycleCollectionCallback)(JSContext* cx); - -/** - * The purge gray callback is called after any COMPARTMENT_REVIVED GC in which - * the majority of compartments have been marked gray. - */ -extern JS_PUBLIC_API(DoCycleCollectionCallback) -SetDoCycleCollectionCallback(JSContext* cx, DoCycleCollectionCallback callback); - -/** - * Incremental GC defaults to enabled, but may be disabled for testing or in - * embeddings that have not yet implemented barriers on their native classes. - * There is not currently a way to re-enable incremental GC once it has been - * disabled on the runtime. - */ -extern JS_PUBLIC_API(void) -DisableIncrementalGC(JSContext* cx); - -/** - * Returns true if incremental GC is enabled. Simply having incremental GC - * enabled is not sufficient to ensure incremental collections are happening. - * See the comment "Incremental GC" above for reasons why incremental GC may be - * suppressed. Inspection of the "nonincremental reason" field of the - * GCDescription returned by GCSliceCallback may help narrow down the cause if - * collections are not happening incrementally when expected. - */ -extern JS_PUBLIC_API(bool) -IsIncrementalGCEnabled(JSContext* cx); - -/** - * Returns true while an incremental GC is ongoing, both when actively - * collecting and between slices. - */ -extern JS_PUBLIC_API(bool) -IsIncrementalGCInProgress(JSContext* cx); - -/* - * Returns true when writes to GC things must call an incremental (pre) barrier. - * This is generally only true when running mutator code in-between GC slices. - * At other times, the barrier may be elided for performance. - */ -extern JS_PUBLIC_API(bool) -IsIncrementalBarrierNeeded(JSContext* cx); - -/* - * Notify the GC that a reference to a GC thing is about to be overwritten. - * These methods must be called if IsIncrementalBarrierNeeded. - */ -extern JS_PUBLIC_API(void) -IncrementalReferenceBarrier(GCCellPtr thing); - -extern JS_PUBLIC_API(void) -IncrementalValueBarrier(const Value& v); - -extern JS_PUBLIC_API(void) -IncrementalObjectBarrier(JSObject* obj); - -/** - * Returns true if the most recent GC ran incrementally. - */ -extern JS_PUBLIC_API(bool) -WasIncrementalGC(JSContext* cx); - -/* - * Generational GC: - * - * Note: Generational GC is not yet enabled by default. The following class - * is non-functional unless SpiderMonkey was configured with - * --enable-gcgenerational. - */ - -/** Ensure that generational GC is disabled within some scope. */ -class JS_PUBLIC_API(AutoDisableGenerationalGC) -{ - js::gc::GCRuntime* gc; - - public: - explicit AutoDisableGenerationalGC(JSRuntime* rt); - ~AutoDisableGenerationalGC(); -}; - -/** - * Returns true if generational allocation and collection is currently enabled - * on the given runtime. - */ -extern JS_PUBLIC_API(bool) -IsGenerationalGCEnabled(JSRuntime* rt); - -/** - * Returns the GC's "number". This does not correspond directly to the number - * of GCs that have been run, but is guaranteed to be monotonically increasing - * with GC activity. - */ -extern JS_PUBLIC_API(size_t) -GetGCNumber(); - -/** - * Pass a subclass of this "abstract" class to callees to require that they - * never GC. Subclasses can use assertions or the hazard analysis to ensure no - * GC happens. - */ -class JS_PUBLIC_API(AutoRequireNoGC) -{ - protected: - AutoRequireNoGC() {} - ~AutoRequireNoGC() {} -}; - -/** - * Diagnostic assert (see MOZ_DIAGNOSTIC_ASSERT) that GC cannot occur while this - * class is live. This class does not disable the static rooting hazard - * analysis. - * - * This works by entering a GC unsafe region, which is checked on allocation and - * on GC. - */ -class JS_PUBLIC_API(AutoAssertNoGC) : public AutoRequireNoGC -{ - js::gc::GCRuntime* gc; - size_t gcNumber; - - public: - AutoAssertNoGC(); - explicit AutoAssertNoGC(JSRuntime* rt); - explicit AutoAssertNoGC(JSContext* cx); - ~AutoAssertNoGC(); -}; - -/** - * Assert if an allocation of a GC thing occurs while this class is live. This - * class does not disable the static rooting hazard analysis. - */ -class JS_PUBLIC_API(AutoAssertNoAlloc) -{ -#ifdef JS_DEBUG - js::gc::GCRuntime* gc; - - public: - AutoAssertNoAlloc() : gc(nullptr) {} - explicit AutoAssertNoAlloc(JSContext* cx); - void disallowAlloc(JSRuntime* rt); - ~AutoAssertNoAlloc(); -#else - public: - AutoAssertNoAlloc() {} - explicit AutoAssertNoAlloc(JSContext* cx) {} - void disallowAlloc(JSRuntime* rt) {} -#endif -}; - -/** - * Assert if a GC barrier is invoked while this class is live. This class does - * not disable the static rooting hazard analysis. - */ -class JS_PUBLIC_API(AutoAssertOnBarrier) -{ - JSContext* context; - bool prev; - - public: - explicit AutoAssertOnBarrier(JSContext* cx); - ~AutoAssertOnBarrier(); -}; - -/** - * Disable the static rooting hazard analysis in the live region and assert if - * any allocation that could potentially trigger a GC occurs while this guard - * object is live. This is most useful to help the exact rooting hazard analysis - * in complex regions, since it cannot understand dataflow. - * - * Note: GC behavior is unpredictable even when deterministic and is generally - * non-deterministic in practice. The fact that this guard has not - * asserted is not a guarantee that a GC cannot happen in the guarded - * region. As a rule, anyone performing a GC unsafe action should - * understand the GC properties of all code in that region and ensure - * that the hazard analysis is correct for that code, rather than relying - * on this class. - */ -class JS_PUBLIC_API(AutoSuppressGCAnalysis) : public AutoAssertNoAlloc -{ - public: - AutoSuppressGCAnalysis() : AutoAssertNoAlloc() {} - explicit AutoSuppressGCAnalysis(JSContext* cx) : AutoAssertNoAlloc(cx) {} -} JS_HAZ_GC_SUPPRESSED; - -/** - * Assert that code is only ever called from a GC callback, disable the static - * rooting hazard analysis and assert if any allocation that could potentially - * trigger a GC occurs while this guard object is live. - * - * This is useful to make the static analysis ignore code that runs in GC - * callbacks. - */ -class JS_PUBLIC_API(AutoAssertGCCallback) : public AutoSuppressGCAnalysis -{ - public: - explicit AutoAssertGCCallback(JSObject* obj); -}; - -/** - * Place AutoCheckCannotGC in scopes that you believe can never GC. These - * annotations will be verified both dynamically via AutoAssertNoGC, and - * statically with the rooting hazard analysis (implemented by making the - * analysis consider AutoCheckCannotGC to be a GC pointer, and therefore - * complain if it is live across a GC call.) It is useful when dealing with - * internal pointers to GC things where the GC thing itself may not be present - * for the static analysis: e.g. acquiring inline chars from a JSString* on the - * heap. - * - * We only do the assertion checking in DEBUG builds. - */ -#ifdef DEBUG -class JS_PUBLIC_API(AutoCheckCannotGC) : public AutoAssertNoGC -{ - public: - AutoCheckCannotGC() : AutoAssertNoGC() {} - explicit AutoCheckCannotGC(JSContext* cx) : AutoAssertNoGC(cx) {} -} JS_HAZ_GC_INVALIDATED; -#else -class JS_PUBLIC_API(AutoCheckCannotGC) : public AutoRequireNoGC -{ - public: - AutoCheckCannotGC() {} - explicit AutoCheckCannotGC(JSContext* cx) {} -} JS_HAZ_GC_INVALIDATED; -#endif - -/** - * Unsets the gray bit for anything reachable from |thing|. |kind| should not be - * JS::TraceKind::Shape. |thing| should be non-null. The return value indicates - * if anything was unmarked. - */ -extern JS_FRIEND_API(bool) -UnmarkGrayGCThingRecursively(GCCellPtr thing); - -} /* namespace JS */ - -namespace js { -namespace gc { - -static MOZ_ALWAYS_INLINE void -ExposeGCThingToActiveJS(JS::GCCellPtr thing) -{ - // GC things residing in the nursery cannot be gray: they have no mark bits. - // All live objects in the nursery are moved to tenured at the beginning of - // each GC slice, so the gray marker never sees nursery things. - if (IsInsideNursery(thing.asCell())) - return; - - // There's nothing to do for permanent GC things that might be owned by - // another runtime. - if (thing.mayBeOwnedByOtherRuntime()) - return; - - JS::shadow::Runtime* rt = detail::GetCellRuntime(thing.asCell()); - MOZ_DIAGNOSTIC_ASSERT(rt->allowGCBarriers()); - - if (IsIncrementalBarrierNeededOnTenuredGCThing(rt, thing)) - JS::IncrementalReferenceBarrier(thing); - else if (!thing.mayBeOwnedByOtherRuntime() && js::gc::detail::CellIsMarkedGray(thing.asCell())) - JS::UnmarkGrayGCThingRecursively(thing); -} - -static MOZ_ALWAYS_INLINE void -MarkGCThingAsLive(JSRuntime* aRt, JS::GCCellPtr thing) -{ - // Any object in the nursery will not be freed during any GC running at that - // time. - if (IsInsideNursery(thing.asCell())) - return; - - // There's nothing to do for permanent GC things that might be owned by - // another runtime. - if (thing.mayBeOwnedByOtherRuntime()) - return; - - JS::shadow::Runtime* rt = JS::shadow::Runtime::asShadowRuntime(aRt); - MOZ_DIAGNOSTIC_ASSERT(rt->allowGCBarriers()); - - if (IsIncrementalBarrierNeededOnTenuredGCThing(rt, thing)) - JS::IncrementalReferenceBarrier(thing); -} - -} /* namespace gc */ -} /* namespace js */ - -namespace JS { - -/* - * This should be called when an object that is marked gray is exposed to the JS - * engine (by handing it to running JS code or writing it into live JS - * data). During incremental GC, since the gray bits haven't been computed yet, - * we conservatively mark the object black. - */ -static MOZ_ALWAYS_INLINE void -ExposeObjectToActiveJS(JSObject* obj) -{ - MOZ_ASSERT(obj); - js::gc::ExposeGCThingToActiveJS(GCCellPtr(obj)); -} - -static MOZ_ALWAYS_INLINE void -ExposeScriptToActiveJS(JSScript* script) -{ - js::gc::ExposeGCThingToActiveJS(GCCellPtr(script)); -} - -/* - * If a GC is currently marking, mark the string black. - */ -static MOZ_ALWAYS_INLINE void -MarkStringAsLive(Zone* zone, JSString* string) -{ - JSRuntime* rt = JS::shadow::Zone::asShadowZone(zone)->runtimeFromMainThread(); - js::gc::MarkGCThingAsLive(rt, GCCellPtr(string)); -} - -/* - * Internal to Firefox. - * - * Note: this is not related to the PokeGC in nsJSEnvironment. - */ -extern JS_FRIEND_API(void) -PokeGC(JSContext* cx); - -/* - * Internal to Firefox. - */ -extern JS_FRIEND_API(void) -NotifyDidPaint(JSContext* cx); - -} /* namespace JS */ - -#endif /* js_GCAPI_h */ diff --git a/android/armeabi/include/spidermonkey/js/GCAnnotations.h b/android/armeabi/include/spidermonkey/js/GCAnnotations.h deleted file mode 100644 index 366d787b..00000000 --- a/android/armeabi/include/spidermonkey/js/GCAnnotations.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_GCAnnotations_h -#define js_GCAnnotations_h - -// Set of annotations for the rooting hazard analysis, used to categorize types -// and functions. -#ifdef XGILL_PLUGIN - -// Mark a type as being a GC thing (eg js::gc::Cell has this annotation). -# define JS_HAZ_GC_THING __attribute__((tag("GC Thing"))) - -// Mark a type as holding a pointer to a GC thing (eg JS::Value has this -// annotation.) -# define JS_HAZ_GC_POINTER __attribute__((tag("GC Pointer"))) - -// Mark a type as a rooted pointer, suitable for use on the stack (eg all -// Rooted<T> instantiations should have this.) -# define JS_HAZ_ROOTED __attribute__((tag("Rooted Pointer"))) - -// Mark a type as something that should not be held live across a GC, but which -// is not itself a GC pointer. -# define JS_HAZ_GC_INVALIDATED __attribute__((tag("Invalidated by GC"))) - -// Mark a type that would otherwise be considered a GC Pointer (eg because it -// contains a JS::Value field) as a non-GC pointer. It is handled almost the -// same in the analysis as a rooted pointer, except it will not be reported as -// an unnecessary root if used across a GC call. This should rarely be used, -// but makes sense for something like ErrorResult, which only contains a GC -// pointer when it holds an exception (and it does its own rooting, -// conditionally.) -# define JS_HAZ_NON_GC_POINTER __attribute__((tag("Suppressed GC Pointer"))) - -// Mark a function as something that runs a garbage collection, potentially -// invalidating GC pointers. -# define JS_HAZ_GC_CALL __attribute__((tag("GC Call"))) - -// Mark an RAII class as suppressing GC within its scope. -# define JS_HAZ_GC_SUPPRESSED __attribute__((tag("Suppress GC"))) - -#else - -# define JS_HAZ_GC_THING -# define JS_HAZ_GC_POINTER -# define JS_HAZ_ROOTED -# define JS_HAZ_GC_INVALIDATED -# define JS_HAZ_NON_GC_POINTER -# define JS_HAZ_GC_CALL -# define JS_HAZ_GC_SUPPRESSED - -#endif - -#endif /* js_GCAnnotations_h */ diff --git a/android/armeabi/include/spidermonkey/js/GCHashTable.h b/android/armeabi/include/spidermonkey/js/GCHashTable.h deleted file mode 100644 index d6c2ce75..00000000 --- a/android/armeabi/include/spidermonkey/js/GCHashTable.h +++ /dev/null @@ -1,399 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef GCHashTable_h -#define GCHashTable_h - -#include "js/GCPolicyAPI.h" -#include "js/HashTable.h" -#include "js/RootingAPI.h" -#include "js/SweepingAPI.h" -#include "js/TracingAPI.h" - -namespace JS { - -// Define a reasonable default GC policy for GC-aware Maps. -template <typename Key, typename Value> -struct DefaultMapSweepPolicy { - static bool needsSweep(Key* key, Value* value) { - return GCPolicy<Key>::needsSweep(key) || GCPolicy<Value>::needsSweep(value); - } -}; - -// A GCHashMap is a GC-aware HashMap, meaning that it has additional trace and -// sweep methods that know how to visit all keys and values in the table. -// HashMaps that contain GC pointers will generally want to use this GCHashMap -// specialization instead of HashMap, because this conveniently supports tracing -// keys and values, and cleaning up weak entries. -// -// GCHashMap::trace applies GCPolicy<T>::trace to each entry's key and value. -// Most types of GC pointers already have appropriate specializations of -// GCPolicy, so they should just work as keys and values. Any struct type with a -// default constructor and trace and sweep functions should work as well. If you -// need to define your own GCPolicy specialization, generic helpers can be found -// in js/public/TracingAPI.h. -// -// The MapSweepPolicy template parameter controls how the table drops entries -// when swept. GCHashMap::sweep applies MapSweepPolicy::needsSweep to each table -// entry; if it returns true, the entry is dropped. The default MapSweepPolicy -// drops the entry if either the key or value is about to be finalized, -// according to its GCPolicy<T>::needsSweep method. (This default is almost -// always fine: it's hard to imagine keeping such an entry around anyway.) -// -// Note that this HashMap only knows *how* to trace and sweep, but it does not -// itself cause tracing or sweeping to be invoked. For tracing, it must be used -// with Rooted or PersistentRooted, or barriered and traced manually. For -// sweeping, currently it requires an explicit call to <map>.sweep(). -template <typename Key, - typename Value, - typename HashPolicy = js::DefaultHasher<Key>, - typename AllocPolicy = js::TempAllocPolicy, - typename MapSweepPolicy = DefaultMapSweepPolicy<Key, Value>> -class GCHashMap : public js::HashMap<Key, Value, HashPolicy, AllocPolicy> -{ - using Base = js::HashMap<Key, Value, HashPolicy, AllocPolicy>; - - public: - explicit GCHashMap(AllocPolicy a = AllocPolicy()) : Base(a) {} - - static void trace(GCHashMap* map, JSTracer* trc) { map->trace(trc); } - void trace(JSTracer* trc) { - if (!this->initialized()) - return; - for (typename Base::Enum e(*this); !e.empty(); e.popFront()) { - GCPolicy<Value>::trace(trc, &e.front().value(), "hashmap value"); - GCPolicy<Key>::trace(trc, &e.front().mutableKey(), "hashmap key"); - } - } - - void sweep() { - if (!this->initialized()) - return; - - for (typename Base::Enum e(*this); !e.empty(); e.popFront()) { - if (MapSweepPolicy::needsSweep(&e.front().mutableKey(), &e.front().value())) - e.removeFront(); - } - } - - // GCHashMap is movable - GCHashMap(GCHashMap&& rhs) : Base(mozilla::Move(rhs)) {} - void operator=(GCHashMap&& rhs) { - MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited"); - Base::operator=(mozilla::Move(rhs)); - } - - private: - // GCHashMap is not copyable or assignable - GCHashMap(const GCHashMap& hm) = delete; - GCHashMap& operator=(const GCHashMap& hm) = delete; -}; - -} // namespace JS - -namespace js { - -// HashMap that supports rekeying. -// -// If your keys are pointers to something like JSObject that can be tenured or -// compacted, prefer to use GCHashMap with MovableCellHasher, which takes -// advantage of the Zone's stable id table to make rekeying unnecessary. -template <typename Key, - typename Value, - typename HashPolicy = DefaultHasher<Key>, - typename AllocPolicy = TempAllocPolicy, - typename MapSweepPolicy = JS::DefaultMapSweepPolicy<Key, Value>> -class GCRekeyableHashMap : public JS::GCHashMap<Key, Value, HashPolicy, AllocPolicy, MapSweepPolicy> -{ - using Base = JS::GCHashMap<Key, Value, HashPolicy, AllocPolicy>; - - public: - explicit GCRekeyableHashMap(AllocPolicy a = AllocPolicy()) : Base(a) {} - - void sweep() { - if (!this->initialized()) - return; - - for (typename Base::Enum e(*this); !e.empty(); e.popFront()) { - Key key(e.front().key()); - if (MapSweepPolicy::needsSweep(&key, &e.front().value())) - e.removeFront(); - else if (!HashPolicy::match(key, e.front().key())) - e.rekeyFront(key); - } - } - - // GCRekeyableHashMap is movable - GCRekeyableHashMap(GCRekeyableHashMap&& rhs) : Base(mozilla::Move(rhs)) {} - void operator=(GCRekeyableHashMap&& rhs) { - MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited"); - Base::operator=(mozilla::Move(rhs)); - } -}; - -template <typename Outer, typename... Args> -class GCHashMapOperations -{ - using Map = JS::GCHashMap<Args...>; - using Lookup = typename Map::Lookup; - - const Map& map() const { return static_cast<const Outer*>(this)->get(); } - - public: - using AddPtr = typename Map::AddPtr; - using Ptr = typename Map::Ptr; - using Range = typename Map::Range; - - bool initialized() const { return map().initialized(); } - Ptr lookup(const Lookup& l) const { return map().lookup(l); } - AddPtr lookupForAdd(const Lookup& l) const { return map().lookupForAdd(l); } - Range all() const { return map().all(); } - bool empty() const { return map().empty(); } - uint32_t count() const { return map().count(); } - size_t capacity() const { return map().capacity(); } - bool has(const Lookup& l) const { return map().lookup(l).found(); } - size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return map().sizeOfExcludingThis(mallocSizeOf); - } - size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return mallocSizeOf(this) + map().sizeOfExcludingThis(mallocSizeOf); - } -}; - -template <typename Outer, typename... Args> -class MutableGCHashMapOperations - : public GCHashMapOperations<Outer, Args...> -{ - using Map = JS::GCHashMap<Args...>; - using Lookup = typename Map::Lookup; - - Map& map() { return static_cast<Outer*>(this)->get(); } - - public: - using AddPtr = typename Map::AddPtr; - struct Enum : public Map::Enum { explicit Enum(Outer& o) : Map::Enum(o.map()) {} }; - using Ptr = typename Map::Ptr; - using Range = typename Map::Range; - - bool init(uint32_t len = 16) { return map().init(len); } - void clear() { map().clear(); } - void finish() { map().finish(); } - void remove(Ptr p) { map().remove(p); } - - template<typename KeyInput, typename ValueInput> - bool add(AddPtr& p, KeyInput&& k, ValueInput&& v) { - return map().add(p, mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v)); - } - - template<typename KeyInput> - bool add(AddPtr& p, KeyInput&& k) { - return map().add(p, mozilla::Forward<KeyInput>(k), Map::Value()); - } - - template<typename KeyInput, typename ValueInput> - bool relookupOrAdd(AddPtr& p, KeyInput&& k, ValueInput&& v) { - return map().relookupOrAdd(p, k, - mozilla::Forward<KeyInput>(k), - mozilla::Forward<ValueInput>(v)); - } - - template<typename KeyInput, typename ValueInput> - bool put(KeyInput&& k, ValueInput&& v) { - return map().put(mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v)); - } - - template<typename KeyInput, typename ValueInput> - bool putNew(KeyInput&& k, ValueInput&& v) { - return map().putNew(mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v)); - } -}; - -template <typename A, typename B, typename C, typename D, typename E> -class RootedBase<JS::GCHashMap<A,B,C,D,E>> - : public MutableGCHashMapOperations<JS::Rooted<JS::GCHashMap<A,B,C,D,E>>, A,B,C,D,E> -{}; - -template <typename A, typename B, typename C, typename D, typename E> -class MutableHandleBase<JS::GCHashMap<A,B,C,D,E>> - : public MutableGCHashMapOperations<JS::MutableHandle<JS::GCHashMap<A,B,C,D,E>>, A,B,C,D,E> -{}; - -template <typename A, typename B, typename C, typename D, typename E> -class HandleBase<JS::GCHashMap<A,B,C,D,E>> - : public GCHashMapOperations<JS::Handle<JS::GCHashMap<A,B,C,D,E>>, A,B,C,D,E> -{}; - -template <typename A, typename B, typename C, typename D, typename E> -class WeakCacheBase<JS::GCHashMap<A,B,C,D,E>> - : public MutableGCHashMapOperations<JS::WeakCache<JS::GCHashMap<A,B,C,D,E>>, A,B,C,D,E> -{}; - -} // namespace js - -namespace JS { - -// A GCHashSet is a HashSet with an additional trace method that knows -// be traced to be kept alive will generally want to use this GCHashSet -// specialization in lieu of HashSet. -// -// Most types of GC pointers can be traced with no extra infrastructure. For -// structs and non-gc-pointer members, ensure that there is a specialization of -// GCPolicy<T> with an appropriate trace method available to handle the custom -// type. Generic helpers can be found in js/public/TracingAPI.h. -// -// Note that although this HashSet's trace will deal correctly with moved -// elements, it does not itself know when to barrier or trace elements. To -// function properly it must either be used with Rooted or barriered and traced -// manually. -template <typename T, - typename HashPolicy = js::DefaultHasher<T>, - typename AllocPolicy = js::TempAllocPolicy> -class GCHashSet : public js::HashSet<T, HashPolicy, AllocPolicy> -{ - using Base = js::HashSet<T, HashPolicy, AllocPolicy>; - - public: - explicit GCHashSet(AllocPolicy a = AllocPolicy()) : Base(a) {} - - static void trace(GCHashSet* set, JSTracer* trc) { set->trace(trc); } - void trace(JSTracer* trc) { - if (!this->initialized()) - return; - for (typename Base::Enum e(*this); !e.empty(); e.popFront()) - GCPolicy<T>::trace(trc, &e.mutableFront(), "hashset element"); - } - - void sweep() { - if (!this->initialized()) - return; - for (typename Base::Enum e(*this); !e.empty(); e.popFront()) { - if (GCPolicy<T>::needsSweep(&e.mutableFront())) - e.removeFront(); - } - } - - // GCHashSet is movable - GCHashSet(GCHashSet&& rhs) : Base(mozilla::Move(rhs)) {} - void operator=(GCHashSet&& rhs) { - MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited"); - Base::operator=(mozilla::Move(rhs)); - } - - private: - // GCHashSet is not copyable or assignable - GCHashSet(const GCHashSet& hs) = delete; - GCHashSet& operator=(const GCHashSet& hs) = delete; -}; - -} // namespace JS - -namespace js { - -template <typename Outer, typename... Args> -class GCHashSetOperations -{ - using Set = JS::GCHashSet<Args...>; - using Lookup = typename Set::Lookup; - - const Set& set() const { return static_cast<const Outer*>(this)->get(); } - - public: - using AddPtr = typename Set::AddPtr; - using Entry = typename Set::Entry; - using Ptr = typename Set::Ptr; - using Range = typename Set::Range; - - bool initialized() const { return set().initialized(); } - Ptr lookup(const Lookup& l) const { return set().lookup(l); } - AddPtr lookupForAdd(const Lookup& l) const { return set().lookupForAdd(l); } - Range all() const { return set().all(); } - bool empty() const { return set().empty(); } - uint32_t count() const { return set().count(); } - size_t capacity() const { return set().capacity(); } - bool has(const Lookup& l) const { return set().lookup(l).found(); } - size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return set().sizeOfExcludingThis(mallocSizeOf); - } - size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return mallocSizeOf(this) + set().sizeOfExcludingThis(mallocSizeOf); - } -}; - -template <typename Outer, typename... Args> -class MutableGCHashSetOperations - : public GCHashSetOperations<Outer, Args...> -{ - using Set = JS::GCHashSet<Args...>; - using Lookup = typename Set::Lookup; - - Set& set() { return static_cast<Outer*>(this)->get(); } - - public: - using AddPtr = typename Set::AddPtr; - using Entry = typename Set::Entry; - struct Enum : public Set::Enum { explicit Enum(Outer& o) : Set::Enum(o.set()) {} }; - using Ptr = typename Set::Ptr; - using Range = typename Set::Range; - - bool init(uint32_t len = 16) { return set().init(len); } - void clear() { set().clear(); } - void finish() { set().finish(); } - void remove(Ptr p) { set().remove(p); } - void remove(const Lookup& l) { set().remove(l); } - - template<typename TInput> - bool add(AddPtr& p, TInput&& t) { - return set().add(p, mozilla::Forward<TInput>(t)); - } - - template<typename TInput> - bool relookupOrAdd(AddPtr& p, const Lookup& l, TInput&& t) { - return set().relookupOrAdd(p, l, mozilla::Forward<TInput>(t)); - } - - template<typename TInput> - bool put(TInput&& t) { - return set().put(mozilla::Forward<TInput>(t)); - } - - template<typename TInput> - bool putNew(TInput&& t) { - return set().putNew(mozilla::Forward<TInput>(t)); - } - - template<typename TInput> - bool putNew(const Lookup& l, TInput&& t) { - return set().putNew(l, mozilla::Forward<TInput>(t)); - } -}; - -template <typename T, typename HP, typename AP> -class RootedBase<JS::GCHashSet<T, HP, AP>> - : public MutableGCHashSetOperations<JS::Rooted<JS::GCHashSet<T, HP, AP>>, T, HP, AP> -{ -}; - -template <typename T, typename HP, typename AP> -class MutableHandleBase<JS::GCHashSet<T, HP, AP>> - : public MutableGCHashSetOperations<JS::MutableHandle<JS::GCHashSet<T, HP, AP>>, T, HP, AP> -{ -}; - -template <typename T, typename HP, typename AP> -class HandleBase<JS::GCHashSet<T, HP, AP>> - : public GCHashSetOperations<JS::Handle<JS::GCHashSet<T, HP, AP>>, T, HP, AP> -{ -}; - -template <typename T, typename HP, typename AP> -class WeakCacheBase<JS::GCHashSet<T, HP, AP>> - : public MutableGCHashSetOperations<JS::WeakCache<JS::GCHashSet<T, HP, AP>>, T, HP, AP> -{ -}; - -} /* namespace js */ - -#endif /* GCHashTable_h */ diff --git a/android/armeabi/include/spidermonkey/js/GCPolicyAPI.h b/android/armeabi/include/spidermonkey/js/GCPolicyAPI.h deleted file mode 100644 index 054e397a..00000000 --- a/android/armeabi/include/spidermonkey/js/GCPolicyAPI.h +++ /dev/null @@ -1,164 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// GC Policy Mechanism - -// A GCPolicy controls how the GC interacts with both direct pointers to GC -// things (e.g. JSObject* or JSString*), tagged and/or optional pointers to GC -// things (e.g. Value or jsid), and C++ container types (e.g. -// JSPropertyDescriptor or GCHashMap). -// -// The GCPolicy provides at a minimum: -// -// static T initial() -// - Construct and return an empty T. -// -// static void trace(JSTracer, T* tp, const char* name) -// - Trace the edge |*tp|, calling the edge |name|. Containers like -// GCHashMap and GCHashSet use this method to trace their children. -// -// static bool needsSweep(T* tp) -// - Return true if |*tp| is about to be finalized. Otherwise, update the -// edge for moving GC, and return false. Containers like GCHashMap and -// GCHashSet use this method to decide when to remove an entry: if this -// function returns true on a key/value/member/etc, its entry is dropped -// from the container. Specializing this method is the standard way to -// get custom weak behavior from a container type. -// -// The default GCPolicy<T> assumes that T has a default constructor and |trace| -// and |needsSweep| methods, and forwards to them. GCPolicy has appropriate -// specializations for pointers to GC things and pointer-like types like -// JS::Heap<T> and mozilla::UniquePtr<T>. -// -// There are some stock structs your specializations can inherit from. -// IgnoreGCPolicy<T> does nothing. StructGCPolicy<T> forwards the methods to the -// referent type T. - -#ifndef GCPolicyAPI_h -#define GCPolicyAPI_h - -#include "mozilla/UniquePtr.h" - -#include "js/TraceKind.h" -#include "js/TracingAPI.h" - -// Expand the given macro D for each public GC pointer. -#define FOR_EACH_PUBLIC_GC_POINTER_TYPE(D) \ - D(JS::Symbol*) \ - D(JSAtom*) \ - D(JSFunction*) \ - D(JSObject*) \ - D(JSScript*) \ - D(JSString*) - -// Expand the given macro D for each public tagged GC pointer type. -#define FOR_EACH_PUBLIC_TAGGED_GC_POINTER_TYPE(D) \ - D(JS::Value) \ - D(jsid) - -#define FOR_EACH_PUBLIC_AGGREGATE_GC_POINTER_TYPE(D) \ - D(JSPropertyDescriptor) - -class JSAtom; -class JSFunction; -class JSObject; -class JSScript; -class JSString; -namespace JS { -class Symbol; -} - -namespace JS { - -// Defines a policy for container types with non-GC, i.e. C storage. This -// policy dispatches to the underlying struct for GC interactions. -template <typename T> -struct StructGCPolicy -{ - static T initial() { - return T(); - } - - static void trace(JSTracer* trc, T* tp, const char* name) { - tp->trace(trc); - } - - static void sweep(T* tp) { - return tp->sweep(); - } - - static bool needsSweep(T* tp) { - return tp->needsSweep(); - } -}; - -// The default GC policy attempts to defer to methods on the underlying type. -// Most C++ structures that contain a default constructor, a trace function and -// a sweep function will work out of the box with Rooted, Handle, GCVector, -// and GCHash{Set,Map}. -template <typename T> struct GCPolicy : public StructGCPolicy<T> {}; - -// This policy ignores any GC interaction, e.g. for non-GC types. -template <typename T> -struct IgnoreGCPolicy { - static T initial() { return T(); } - static void trace(JSTracer* trc, T* t, const char* name) {} - static bool needsSweep(T* v) { return false; } -}; -template <> struct GCPolicy<uint32_t> : public IgnoreGCPolicy<uint32_t> {}; -template <> struct GCPolicy<uint64_t> : public IgnoreGCPolicy<uint64_t> {}; - -template <typename T> -struct GCPointerPolicy -{ - static T initial() { return nullptr; } - static void trace(JSTracer* trc, T* vp, const char* name) { - if (*vp) - js::UnsafeTraceManuallyBarrieredEdge(trc, vp, name); - } - static bool needsSweep(T* vp) { - if (*vp) - return js::gc::IsAboutToBeFinalizedUnbarriered(vp); - return false; - } -}; -template <> struct GCPolicy<JS::Symbol*> : public GCPointerPolicy<JS::Symbol*> {}; -template <> struct GCPolicy<JSAtom*> : public GCPointerPolicy<JSAtom*> {}; -template <> struct GCPolicy<JSFunction*> : public GCPointerPolicy<JSFunction*> {}; -template <> struct GCPolicy<JSObject*> : public GCPointerPolicy<JSObject*> {}; -template <> struct GCPolicy<JSScript*> : public GCPointerPolicy<JSScript*> {}; -template <> struct GCPolicy<JSString*> : public GCPointerPolicy<JSString*> {}; - -template <typename T> -struct GCPolicy<JS::Heap<T>> -{ - static void trace(JSTracer* trc, JS::Heap<T>* thingp, const char* name) { - TraceEdge(trc, thingp, name); - } - static bool needsSweep(JS::Heap<T>* thingp) { - return js::gc::EdgeNeedsSweep(thingp); - } -}; - -// GCPolicy<UniquePtr<T>> forwards the contained pointer to GCPolicy<T>. -template <typename T, typename D> -struct GCPolicy<mozilla::UniquePtr<T, D>> -{ - static mozilla::UniquePtr<T,D> initial() { return mozilla::UniquePtr<T,D>(); } - static void trace(JSTracer* trc, mozilla::UniquePtr<T,D>* tp, const char* name) { - if (tp->get()) - GCPolicy<T>::trace(trc, tp->get(), name); - } - static bool needsSweep(mozilla::UniquePtr<T,D>* tp) { - if (tp->get()) - return GCPolicy<T>::needsSweep(tp->get()); - return false; - } -}; - -} // namespace JS - -#endif // GCPolicyAPI_h diff --git a/android/armeabi/include/spidermonkey/js/GCVariant.h b/android/armeabi/include/spidermonkey/js/GCVariant.h deleted file mode 100644 index 31ab23f5..00000000 --- a/android/armeabi/include/spidermonkey/js/GCVariant.h +++ /dev/null @@ -1,198 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_GCVariant_h -#define js_GCVariant_h - -#include "mozilla/Variant.h" - -#include "js/GCPolicyAPI.h" -#include "js/RootingAPI.h" -#include "js/TracingAPI.h" - -namespace JS { - -// These template specializations allow Variant to be used inside GC wrappers. -// -// When matching on GC wrappers around Variants, matching should be done on -// the wrapper itself. The matcher class's methods should take Handles or -// MutableHandles. For example, -// -// struct MyMatcher -// { -// using ReturnType = const char*; -// ReturnType match(HandleObject o) { return "object"; } -// ReturnType match(HandleScript s) { return "script"; } -// }; -// -// Rooted<Variant<JSObject*, JSScript*>> v(cx, someScript); -// MyMatcher mm; -// v.match(mm); -// -// If you get compile errors about inability to upcast subclasses (e.g., from -// NativeObject* to JSObject*) and are inside js/src, be sure to also include -// "gc/Policy.h". - -namespace detail { - -template <typename... Ts> -struct GCVariantImplementation; - -// The base case. -template <typename T> -struct GCVariantImplementation<T> -{ - template <typename ConcreteVariant> - static void trace(JSTracer* trc, ConcreteVariant* v, const char* name) { - T& thing = v->template as<T>(); - if (!mozilla::IsPointer<T>::value || thing) - GCPolicy<T>::trace(trc, &thing, name); - } - - template <typename Matcher, typename ConcreteVariant> - static typename Matcher::ReturnType - match(Matcher& matcher, Handle<ConcreteVariant> v) { - const T& thing = v.get().template as<T>(); - return matcher.match(Handle<T>::fromMarkedLocation(&thing)); - } - - template <typename Matcher, typename ConcreteVariant> - static typename Matcher::ReturnType - match(Matcher& matcher, MutableHandle<ConcreteVariant> v) { - T& thing = v.get().template as<T>(); - return matcher.match(MutableHandle<T>::fromMarkedLocation(&thing)); - } -}; - -// The inductive case. -template <typename T, typename... Ts> -struct GCVariantImplementation<T, Ts...> -{ - using Next = GCVariantImplementation<Ts...>; - - template <typename ConcreteVariant> - static void trace(JSTracer* trc, ConcreteVariant* v, const char* name) { - if (v->template is<T>()) { - T& thing = v->template as<T>(); - if (!mozilla::IsPointer<T>::value || thing) - GCPolicy<T>::trace(trc, &thing, name); - } else { - Next::trace(trc, v, name); - } - } - - template <typename Matcher, typename ConcreteVariant> - static typename Matcher::ReturnType - match(Matcher& matcher, Handle<ConcreteVariant> v) { - if (v.get().template is<T>()) { - const T& thing = v.get().template as<T>(); - return matcher.match(Handle<T>::fromMarkedLocation(&thing)); - } - return Next::match(matcher, v); - } - - template <typename Matcher, typename ConcreteVariant> - static typename Matcher::ReturnType - match(Matcher& matcher, MutableHandle<ConcreteVariant> v) { - if (v.get().template is<T>()) { - T& thing = v.get().template as<T>(); - return matcher.match(MutableHandle<T>::fromMarkedLocation(&thing)); - } - return Next::match(matcher, v); - } -}; - -} // namespace detail - -template <typename... Ts> -struct GCPolicy<mozilla::Variant<Ts...>> -{ - using Impl = detail::GCVariantImplementation<Ts...>; - - // Variants do not provide initial(). They do not have a default initial - // value and one must be provided. - - static void trace(JSTracer* trc, mozilla::Variant<Ts...>* v, const char* name) { - Impl::trace(trc, v, name); - } -}; - -} // namespace JS - -namespace js { - -template <typename Outer, typename... Ts> -class GCVariantOperations -{ - using Impl = JS::detail::GCVariantImplementation<Ts...>; - using Variant = mozilla::Variant<Ts...>; - - const Variant& variant() const { return static_cast<const Outer*>(this)->get(); } - - public: - template <typename T> - bool is() const { - return variant().template is<T>(); - } - - template <typename T> - JS::Handle<T> as() const { - return Handle<T>::fromMarkedLocation(&variant().template as<T>()); - } - - template <typename Matcher> - typename Matcher::ReturnType - match(Matcher& matcher) const { - return Impl::match(matcher, JS::Handle<Variant>::fromMarkedLocation(&variant())); - } -}; - -template <typename Outer, typename... Ts> -class MutableGCVariantOperations - : public GCVariantOperations<Outer, Ts...> -{ - using Impl = JS::detail::GCVariantImplementation<Ts...>; - using Variant = mozilla::Variant<Ts...>; - - const Variant& variant() const { return static_cast<const Outer*>(this)->get(); } - Variant& variant() { return static_cast<Outer*>(this)->get(); } - - public: - template <typename T> - JS::MutableHandle<T> as() { - return JS::MutableHandle<T>::fromMarkedLocation(&variant().template as<T>()); - } - - template <typename Matcher> - typename Matcher::ReturnType - match(Matcher& matcher) { - return Impl::match(matcher, JS::MutableHandle<Variant>::fromMarkedLocation(&variant())); - } -}; - -template <typename... Ts> -class RootedBase<mozilla::Variant<Ts...>> - : public MutableGCVariantOperations<JS::Rooted<mozilla::Variant<Ts...>>, Ts...> -{ }; - -template <typename... Ts> -class MutableHandleBase<mozilla::Variant<Ts...>> - : public MutableGCVariantOperations<JS::MutableHandle<mozilla::Variant<Ts...>>, Ts...> -{ }; - -template <typename... Ts> -class HandleBase<mozilla::Variant<Ts...>> - : public GCVariantOperations<JS::Handle<mozilla::Variant<Ts...>>, Ts...> -{ }; - -template <typename... Ts> -class PersistentRootedBase<mozilla::Variant<Ts...>> - : public MutableGCVariantOperations<JS::PersistentRooted<mozilla::Variant<Ts...>>, Ts...> -{ }; - -} // namespace js - -#endif // js_GCVariant_h diff --git a/android/armeabi/include/spidermonkey/js/GCVector.h b/android/armeabi/include/spidermonkey/js/GCVector.h deleted file mode 100644 index 2668e65b..00000000 --- a/android/armeabi/include/spidermonkey/js/GCVector.h +++ /dev/null @@ -1,249 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_GCVector_h -#define js_GCVector_h - -#include "mozilla/Vector.h" - -#include "js/GCPolicyAPI.h" -#include "js/RootingAPI.h" -#include "js/TracingAPI.h" -#include "js/Vector.h" - -namespace JS { - -// A GCVector is a Vector with an additional trace method that knows how -// to visit all of the items stored in the Vector. For vectors that contain GC -// things, this is usually more convenient than manually iterating and marking -// the contents. -// -// Most types of GC pointers as keys and values can be traced with no extra -// infrastructure. For structs and non-gc-pointer members, ensure that there is -// a specialization of GCPolicy<T> with an appropriate trace method available -// to handle the custom type. Generic helpers can be found in -// js/public/TracingAPI.h. -// -// Note that although this Vector's trace will deal correctly with moved items, -// it does not itself know when to barrier or trace items. To function properly -// it must either be used with Rooted, or barriered and traced manually. -template <typename T, - size_t MinInlineCapacity = 0, - typename AllocPolicy = js::TempAllocPolicy> -class GCVector -{ - mozilla::Vector<T, MinInlineCapacity, AllocPolicy> vector; - - public: - explicit GCVector(AllocPolicy alloc = AllocPolicy()) - : vector(alloc) - {} - - GCVector(GCVector&& vec) - : vector(mozilla::Move(vec.vector)) - {} - - GCVector& operator=(GCVector&& vec) { - vector = mozilla::Move(vec.vector); - return *this; - } - - size_t length() const { return vector.length(); } - bool empty() const { return vector.empty(); } - size_t capacity() const { return vector.capacity(); } - - T* begin() { return vector.begin(); } - const T* begin() const { return vector.begin(); } - - T* end() { return vector.end(); } - const T* end() const { return vector.end(); } - - T& operator[](size_t i) { return vector[i]; } - const T& operator[](size_t i) const { return vector[i]; } - - T& back() { return vector.back(); } - const T& back() const { return vector.back(); } - - bool initCapacity(size_t cap) { return vector.initCapacity(cap); } - bool reserve(size_t req) { return vector.reserve(req); } - void shrinkBy(size_t amount) { return vector.shrinkBy(amount); } - bool growBy(size_t amount) { return vector.growBy(amount); } - bool resize(size_t newLen) { return vector.resize(newLen); } - - void clear() { return vector.clear(); } - - template<typename U> bool append(U&& item) { return vector.append(mozilla::Forward<U>(item)); } - - template<typename... Args> - bool - emplaceBack(Args&&... args) { - return vector.emplaceBack(mozilla::Forward<Args>(args)...); - } - - template<typename U> - void infallibleAppend(U&& aU) { - return vector.infallibleAppend(mozilla::Forward<U>(aU)); - } - void infallibleAppendN(const T& aT, size_t aN) { - return vector.infallibleAppendN(aT, aN); - } - template<typename U> void - infallibleAppend(const U* aBegin, const U* aEnd) { - return vector.infallibleAppend(aBegin, aEnd); - } - template<typename U> void infallibleAppend(const U* aBegin, size_t aLength) { - return vector.infallibleAppend(aBegin, aLength); - } - - template<typename U, size_t O, class BP> - bool appendAll(const mozilla::Vector<U, O, BP>& aU) { return vector.appendAll(aU); } - template<typename U, size_t O, class BP> - bool appendAll(const GCVector<U, O, BP>& aU) { return vector.append(aU.begin(), aU.length()); } - - bool appendN(const T& val, size_t count) { return vector.appendN(val, count); } - - template<typename U> bool append(const U* aBegin, const U* aEnd) { - return vector.append(aBegin, aEnd); - } - template<typename U> bool append(const U* aBegin, size_t aLength) { - return vector.append(aBegin, aLength); - } - - void popBack() { return vector.popBack(); } - T popCopy() { return vector.popCopy(); } - - size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return vector.sizeOfExcludingThis(mallocSizeOf); - } - - size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return vector.sizeOfIncludingThis(mallocSizeOf); - } - - static void trace(GCVector* vec, JSTracer* trc) { vec->trace(trc); } - - void trace(JSTracer* trc) { - for (auto& elem : vector) - GCPolicy<T>::trace(trc, &elem, "vector element"); - } -}; - -} // namespace JS - -namespace js { - -template <typename Outer, typename T, size_t Capacity, typename AllocPolicy> -class GCVectorOperations -{ - using Vec = JS::GCVector<T, Capacity, AllocPolicy>; - const Vec& vec() const { return static_cast<const Outer*>(this)->get(); } - - public: - const AllocPolicy& allocPolicy() const { return vec().allocPolicy(); } - size_t length() const { return vec().length(); } - bool empty() const { return vec().empty(); } - size_t capacity() const { return vec().capacity(); } - const T* begin() const { return vec().begin(); } - const T* end() const { return vec().end(); } - const T& back() const { return vec().back(); } - - JS::Handle<T> operator[](size_t aIndex) const { - return JS::Handle<T>::fromMarkedLocation(&vec().operator[](aIndex)); - } -}; - -template <typename Outer, typename T, size_t Capacity, typename AllocPolicy> -class MutableGCVectorOperations - : public GCVectorOperations<Outer, T, Capacity, AllocPolicy> -{ - using Vec = JS::GCVector<T, Capacity, AllocPolicy>; - const Vec& vec() const { return static_cast<const Outer*>(this)->get(); } - Vec& vec() { return static_cast<Outer*>(this)->get(); } - - public: - const AllocPolicy& allocPolicy() const { return vec().allocPolicy(); } - AllocPolicy& allocPolicy() { return vec().allocPolicy(); } - const T* begin() const { return vec().begin(); } - T* begin() { return vec().begin(); } - const T* end() const { return vec().end(); } - T* end() { return vec().end(); } - const T& back() const { return vec().back(); } - T& back() { return vec().back(); } - - JS::Handle<T> operator[](size_t aIndex) const { - return JS::Handle<T>::fromMarkedLocation(&vec().operator[](aIndex)); - } - JS::MutableHandle<T> operator[](size_t aIndex) { - return JS::MutableHandle<T>::fromMarkedLocation(&vec().operator[](aIndex)); - } - - bool initCapacity(size_t aRequest) { return vec().initCapacity(aRequest); } - bool reserve(size_t aRequest) { return vec().reserve(aRequest); } - void shrinkBy(size_t aIncr) { vec().shrinkBy(aIncr); } - bool growBy(size_t aIncr) { return vec().growBy(aIncr); } - bool resize(size_t aNewLength) { return vec().resize(aNewLength); } - bool growByUninitialized(size_t aIncr) { return vec().growByUninitialized(aIncr); } - void infallibleGrowByUninitialized(size_t aIncr) { vec().infallibleGrowByUninitialized(aIncr); } - bool resizeUninitialized(size_t aNewLength) { return vec().resizeUninitialized(aNewLength); } - void clear() { vec().clear(); } - void clearAndFree() { vec().clearAndFree(); } - template<typename U> bool append(U&& aU) { return vec().append(mozilla::Forward<U>(aU)); } - template<typename... Args> bool emplaceBack(Args&&... aArgs) { - return vec().emplaceBack(mozilla::Forward<Args...>(aArgs...)); - } - template<typename U, size_t O, class BP> - bool appendAll(const mozilla::Vector<U, O, BP>& aU) { return vec().appendAll(aU); } - template<typename U, size_t O, class BP> - bool appendAll(const JS::GCVector<U, O, BP>& aU) { return vec().appendAll(aU); } - bool appendN(const T& aT, size_t aN) { return vec().appendN(aT, aN); } - template<typename U> bool append(const U* aBegin, const U* aEnd) { - return vec().append(aBegin, aEnd); - } - template<typename U> bool append(const U* aBegin, size_t aLength) { - return vec().append(aBegin, aLength); - } - template<typename U> void infallibleAppend(U&& aU) { - vec().infallibleAppend(mozilla::Forward<U>(aU)); - } - void infallibleAppendN(const T& aT, size_t aN) { vec().infallibleAppendN(aT, aN); } - template<typename U> void infallibleAppend(const U* aBegin, const U* aEnd) { - vec().infallibleAppend(aBegin, aEnd); - } - template<typename U> void infallibleAppend(const U* aBegin, size_t aLength) { - vec().infallibleAppend(aBegin, aLength); - } - void popBack() { vec().popBack(); } - T popCopy() { return vec().popCopy(); } - template<typename U> T* insert(T* aP, U&& aVal) { - return vec().insert(aP, mozilla::Forward<U>(aVal)); - } - void erase(T* aT) { vec().erase(aT); } - void erase(T* aBegin, T* aEnd) { vec().erase(aBegin, aEnd); } -}; - -template <typename T, size_t N, typename AP> -class RootedBase<JS::GCVector<T,N,AP>> - : public MutableGCVectorOperations<JS::Rooted<JS::GCVector<T,N,AP>>, T,N,AP> -{}; - -template <typename T, size_t N, typename AP> -class MutableHandleBase<JS::GCVector<T,N,AP>> - : public MutableGCVectorOperations<JS::MutableHandle<JS::GCVector<T,N,AP>>, T,N,AP> -{}; - -template <typename T, size_t N, typename AP> -class HandleBase<JS::GCVector<T,N,AP>> - : public GCVectorOperations<JS::Handle<JS::GCVector<T,N,AP>>, T,N,AP> -{}; - -template <typename T, size_t N, typename AP> -class PersistentRootedBase<JS::GCVector<T,N,AP>> - : public MutableGCVectorOperations<JS::PersistentRooted<JS::GCVector<T,N,AP>>, T,N,AP> -{}; - -} // namespace js - -#endif // js_GCVector_h diff --git a/android/armeabi/include/spidermonkey/js/HashTable.h b/android/armeabi/include/spidermonkey/js/HashTable.h deleted file mode 100644 index 4ed73d94..00000000 --- a/android/armeabi/include/spidermonkey/js/HashTable.h +++ /dev/null @@ -1,1884 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_HashTable_h -#define js_HashTable_h - -#ifndef UINT64_C -#define UINT64_C(value) __CONCAT(value, ULL) -#endif - -#include "mozilla/Alignment.h" -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Casting.h" -#include "mozilla/HashFunctions.h" -#include "mozilla/MemoryReporting.h" -#include "mozilla/Move.h" -#include "mozilla/Opaque.h" -#include "mozilla/PodOperations.h" -#include "mozilla/ReentrancyGuard.h" -#include "mozilla/TemplateLib.h" -#include "mozilla/TypeTraits.h" -#include "mozilla/UniquePtr.h" - -#include "js/Utility.h" - -namespace js { - -class TempAllocPolicy; -template <class> struct DefaultHasher; -template <class, class> class HashMapEntry; -namespace detail { - template <class T> class HashTableEntry; - template <class T, class HashPolicy, class AllocPolicy> class HashTable; -} // namespace detail - -/*****************************************************************************/ - -// The "generation" of a hash table is an opaque value indicating the state of -// modification of the hash table through its lifetime. If the generation of -// a hash table compares equal at times T1 and T2, then lookups in the hash -// table, pointers to (or into) hash table entries, etc. at time T1 are valid -// at time T2. If the generation compares unequal, these computations are all -// invalid and must be performed again to be used. -// -// Generations are meaningfully comparable only with respect to a single hash -// table. It's always nonsensical to compare the generation of distinct hash -// tables H1 and H2. -using Generation = mozilla::Opaque<uint64_t>; - -// A JS-friendly, STL-like container providing a hash-based map from keys to -// values. In particular, HashMap calls constructors and destructors of all -// objects added so non-PODs may be used safely. -// -// Key/Value requirements: -// - movable, destructible, assignable -// HashPolicy requirements: -// - see Hash Policy section below -// AllocPolicy: -// - see jsalloc.h -// -// Note: -// - HashMap is not reentrant: Key/Value/HashPolicy/AllocPolicy members -// called by HashMap must not call back into the same HashMap object. -// - Due to the lack of exception handling, the user must call |init()|. -template <class Key, - class Value, - class HashPolicy = DefaultHasher<Key>, - class AllocPolicy = TempAllocPolicy> -class HashMap -{ - typedef HashMapEntry<Key, Value> TableEntry; - - struct MapHashPolicy : HashPolicy - { - using Base = HashPolicy; - typedef Key KeyType; - static const Key& getKey(TableEntry& e) { return e.key(); } - static void setKey(TableEntry& e, Key& k) { HashPolicy::rekey(e.mutableKey(), k); } - }; - - typedef detail::HashTable<TableEntry, MapHashPolicy, AllocPolicy> Impl; - Impl impl; - - public: - typedef typename HashPolicy::Lookup Lookup; - typedef TableEntry Entry; - - // HashMap construction is fallible (due to OOM); thus the user must call - // init after constructing a HashMap and check the return value. - explicit HashMap(AllocPolicy a = AllocPolicy()) : impl(a) {} - MOZ_MUST_USE bool init(uint32_t len = 16) { return impl.init(len); } - bool initialized() const { return impl.initialized(); } - - // Return whether the given lookup value is present in the map. E.g.: - // - // typedef HashMap<int,char> HM; - // HM h; - // if (HM::Ptr p = h.lookup(3)) { - // const HM::Entry& e = *p; // p acts like a pointer to Entry - // assert(p->key == 3); // Entry contains the key - // char val = p->value; // and value - // } - // - // Also see the definition of Ptr in HashTable above (with T = Entry). - typedef typename Impl::Ptr Ptr; - Ptr lookup(const Lookup& l) const { return impl.lookup(l); } - - // Like lookup, but does not assert if two threads call lookup at the same - // time. Only use this method when none of the threads will modify the map. - Ptr readonlyThreadsafeLookup(const Lookup& l) const { return impl.readonlyThreadsafeLookup(l); } - - // Assuming |p.found()|, remove |*p|. - void remove(Ptr p) { impl.remove(p); } - - // Like |lookup(l)|, but on miss, |p = lookupForAdd(l)| allows efficient - // insertion of Key |k| (where |HashPolicy::match(k,l) == true|) using - // |add(p,k,v)|. After |add(p,k,v)|, |p| points to the new Entry. E.g.: - // - // typedef HashMap<int,char> HM; - // HM h; - // HM::AddPtr p = h.lookupForAdd(3); - // if (!p) { - // if (!h.add(p, 3, 'a')) - // return false; - // } - // const HM::Entry& e = *p; // p acts like a pointer to Entry - // assert(p->key == 3); // Entry contains the key - // char val = p->value; // and value - // - // Also see the definition of AddPtr in HashTable above (with T = Entry). - // - // N.B. The caller must ensure that no mutating hash table operations - // occur between a pair of |lookupForAdd| and |add| calls. To avoid - // looking up the key a second time, the caller may use the more efficient - // relookupOrAdd method. This method reuses part of the hashing computation - // to more efficiently insert the key if it has not been added. For - // example, a mutation-handling version of the previous example: - // - // HM::AddPtr p = h.lookupForAdd(3); - // if (!p) { - // call_that_may_mutate_h(); - // if (!h.relookupOrAdd(p, 3, 'a')) - // return false; - // } - // const HM::Entry& e = *p; - // assert(p->key == 3); - // char val = p->value; - typedef typename Impl::AddPtr AddPtr; - AddPtr lookupForAdd(const Lookup& l) const { - return impl.lookupForAdd(l); - } - - template<typename KeyInput, typename ValueInput> - MOZ_MUST_USE bool add(AddPtr& p, KeyInput&& k, ValueInput&& v) { - return impl.add(p, - mozilla::Forward<KeyInput>(k), - mozilla::Forward<ValueInput>(v)); - } - - template<typename KeyInput> - MOZ_MUST_USE bool add(AddPtr& p, KeyInput&& k) { - return impl.add(p, mozilla::Forward<KeyInput>(k), Value()); - } - - template<typename KeyInput, typename ValueInput> - MOZ_MUST_USE bool relookupOrAdd(AddPtr& p, KeyInput&& k, ValueInput&& v) { - return impl.relookupOrAdd(p, k, - mozilla::Forward<KeyInput>(k), - mozilla::Forward<ValueInput>(v)); - } - - // |all()| returns a Range containing |count()| elements. E.g.: - // - // typedef HashMap<int,char> HM; - // HM h; - // for (HM::Range r = h.all(); !r.empty(); r.popFront()) - // char c = r.front().value(); - // - // Also see the definition of Range in HashTable above (with T = Entry). - typedef typename Impl::Range Range; - Range all() const { return impl.all(); } - - // Typedef for the enumeration class. An Enum may be used to examine and - // remove table entries: - // - // typedef HashMap<int,char> HM; - // HM s; - // for (HM::Enum e(s); !e.empty(); e.popFront()) - // if (e.front().value() == 'l') - // e.removeFront(); - // - // Table resize may occur in Enum's destructor. Also see the definition of - // Enum in HashTable above (with T = Entry). - typedef typename Impl::Enum Enum; - - // Remove all entries. This does not shrink the table. For that consider - // using the finish() method. - void clear() { impl.clear(); } - - // Remove all the entries and release all internal buffers. The map must - // be initialized again before any use. - void finish() { impl.finish(); } - - // Does the table contain any entries? - bool empty() const { return impl.empty(); } - - // Number of live elements in the map. - uint32_t count() const { return impl.count(); } - - // Total number of allocation in the dynamic table. Note: resize will - // happen well before count() == capacity(). - size_t capacity() const { return impl.capacity(); } - - // Don't just call |impl.sizeOfExcludingThis()| because there's no - // guarantee that |impl| is the first field in HashMap. - size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return impl.sizeOfExcludingThis(mallocSizeOf); - } - size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return mallocSizeOf(this) + impl.sizeOfExcludingThis(mallocSizeOf); - } - - Generation generation() const { - return impl.generation(); - } - - /************************************************** Shorthand operations */ - - bool has(const Lookup& l) const { - return impl.lookup(l).found(); - } - - // Overwrite existing value with v. Return false on oom. - template<typename KeyInput, typename ValueInput> - MOZ_MUST_USE bool put(KeyInput&& k, ValueInput&& v) { - AddPtr p = lookupForAdd(k); - if (p) { - p->value() = mozilla::Forward<ValueInput>(v); - return true; - } - return add(p, mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v)); - } - - // Like put, but assert that the given key is not already present. - template<typename KeyInput, typename ValueInput> - MOZ_MUST_USE bool putNew(KeyInput&& k, ValueInput&& v) { - return impl.putNew(k, mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v)); - } - - // Only call this to populate an empty map after reserving space with init(). - template<typename KeyInput, typename ValueInput> - void putNewInfallible(KeyInput&& k, ValueInput&& v) { - impl.putNewInfallible(k, mozilla::Forward<KeyInput>(k), mozilla::Forward<ValueInput>(v)); - } - - // Add (k,defaultValue) if |k| is not found. Return a false-y Ptr on oom. - Ptr lookupWithDefault(const Key& k, const Value& defaultValue) { - AddPtr p = lookupForAdd(k); - if (p) - return p; - bool ok = add(p, k, defaultValue); - MOZ_ASSERT_IF(!ok, !p); // p is left false-y on oom. - (void)ok; - return p; - } - - // Remove if present. - void remove(const Lookup& l) { - if (Ptr p = lookup(l)) - remove(p); - } - - // Infallibly rekey one entry, if necessary. - // Requires template parameters Key and HashPolicy::Lookup to be the same type. - void rekeyIfMoved(const Key& old_key, const Key& new_key) { - if (old_key != new_key) - rekeyAs(old_key, new_key, new_key); - } - - // Infallibly rekey one entry if present, and return whether that happened. - bool rekeyAs(const Lookup& old_lookup, const Lookup& new_lookup, const Key& new_key) { - if (Ptr p = lookup(old_lookup)) { - impl.rekeyAndMaybeRehash(p, new_lookup, new_key); - return true; - } - return false; - } - - // HashMap is movable - HashMap(HashMap&& rhs) : impl(mozilla::Move(rhs.impl)) {} - void operator=(HashMap&& rhs) { - MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited"); - impl = mozilla::Move(rhs.impl); - } - - private: - // HashMap is not copyable or assignable - HashMap(const HashMap& hm) = delete; - HashMap& operator=(const HashMap& hm) = delete; - - friend class Impl::Enum; -}; - -/*****************************************************************************/ - -// A JS-friendly, STL-like container providing a hash-based set of values. In -// particular, HashSet calls constructors and destructors of all objects added -// so non-PODs may be used safely. -// -// T requirements: -// - movable, destructible, assignable -// HashPolicy requirements: -// - see Hash Policy section below -// AllocPolicy: -// - see jsalloc.h -// -// Note: -// - HashSet is not reentrant: T/HashPolicy/AllocPolicy members called by -// HashSet must not call back into the same HashSet object. -// - Due to the lack of exception handling, the user must call |init()|. -template <class T, - class HashPolicy = DefaultHasher<T>, - class AllocPolicy = TempAllocPolicy> -class HashSet -{ - struct SetOps : HashPolicy - { - using Base = HashPolicy; - typedef T KeyType; - static const KeyType& getKey(const T& t) { return t; } - static void setKey(T& t, KeyType& k) { HashPolicy::rekey(t, k); } - }; - - typedef detail::HashTable<const T, SetOps, AllocPolicy> Impl; - Impl impl; - - public: - typedef typename HashPolicy::Lookup Lookup; - typedef T Entry; - - // HashSet construction is fallible (due to OOM); thus the user must call - // init after constructing a HashSet and check the return value. - explicit HashSet(AllocPolicy a = AllocPolicy()) : impl(a) {} - MOZ_MUST_USE bool init(uint32_t len = 16) { return impl.init(len); } - bool initialized() const { return impl.initialized(); } - - // Return whether the given lookup value is present in the map. E.g.: - // - // typedef HashSet<int> HS; - // HS h; - // if (HS::Ptr p = h.lookup(3)) { - // assert(*p == 3); // p acts like a pointer to int - // } - // - // Also see the definition of Ptr in HashTable above. - typedef typename Impl::Ptr Ptr; - Ptr lookup(const Lookup& l) const { return impl.lookup(l); } - - // Like lookup, but does not assert if two threads call lookup at the same - // time. Only use this method when none of the threads will modify the map. - Ptr readonlyThreadsafeLookup(const Lookup& l) const { return impl.readonlyThreadsafeLookup(l); } - - // Assuming |p.found()|, remove |*p|. - void remove(Ptr p) { impl.remove(p); } - - // Like |lookup(l)|, but on miss, |p = lookupForAdd(l)| allows efficient - // insertion of T value |t| (where |HashPolicy::match(t,l) == true|) using - // |add(p,t)|. After |add(p,t)|, |p| points to the new element. E.g.: - // - // typedef HashSet<int> HS; - // HS h; - // HS::AddPtr p = h.lookupForAdd(3); - // if (!p) { - // if (!h.add(p, 3)) - // return false; - // } - // assert(*p == 3); // p acts like a pointer to int - // - // Also see the definition of AddPtr in HashTable above. - // - // N.B. The caller must ensure that no mutating hash table operations - // occur between a pair of |lookupForAdd| and |add| calls. To avoid - // looking up the key a second time, the caller may use the more efficient - // relookupOrAdd method. This method reuses part of the hashing computation - // to more efficiently insert the key if it has not been added. For - // example, a mutation-handling version of the previous example: - // - // HS::AddPtr p = h.lookupForAdd(3); - // if (!p) { - // call_that_may_mutate_h(); - // if (!h.relookupOrAdd(p, 3, 3)) - // return false; - // } - // assert(*p == 3); - // - // Note that relookupOrAdd(p,l,t) performs Lookup using |l| and adds the - // entry |t|, where the caller ensures match(l,t). - typedef typename Impl::AddPtr AddPtr; - AddPtr lookupForAdd(const Lookup& l) const { return impl.lookupForAdd(l); } - - template <typename U> - MOZ_MUST_USE bool add(AddPtr& p, U&& u) { - return impl.add(p, mozilla::Forward<U>(u)); - } - - template <typename U> - MOZ_MUST_USE bool relookupOrAdd(AddPtr& p, const Lookup& l, U&& u) { - return impl.relookupOrAdd(p, l, mozilla::Forward<U>(u)); - } - - // |all()| returns a Range containing |count()| elements: - // - // typedef HashSet<int> HS; - // HS h; - // for (HS::Range r = h.all(); !r.empty(); r.popFront()) - // int i = r.front(); - // - // Also see the definition of Range in HashTable above. - typedef typename Impl::Range Range; - Range all() const { return impl.all(); } - - // Typedef for the enumeration class. An Enum may be used to examine and - // remove table entries: - // - // typedef HashSet<int> HS; - // HS s; - // for (HS::Enum e(s); !e.empty(); e.popFront()) - // if (e.front() == 42) - // e.removeFront(); - // - // Table resize may occur in Enum's destructor. Also see the definition of - // Enum in HashTable above. - typedef typename Impl::Enum Enum; - - // Remove all entries. This does not shrink the table. For that consider - // using the finish() method. - void clear() { impl.clear(); } - - // Remove all the entries and release all internal buffers. The set must - // be initialized again before any use. - void finish() { impl.finish(); } - - // Does the table contain any entries? - bool empty() const { return impl.empty(); } - - // Number of live elements in the map. - uint32_t count() const { return impl.count(); } - - // Total number of allocation in the dynamic table. Note: resize will - // happen well before count() == capacity(). - size_t capacity() const { return impl.capacity(); } - - // Don't just call |impl.sizeOfExcludingThis()| because there's no - // guarantee that |impl| is the first field in HashSet. - size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return impl.sizeOfExcludingThis(mallocSizeOf); - } - size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return mallocSizeOf(this) + impl.sizeOfExcludingThis(mallocSizeOf); - } - - Generation generation() const { - return impl.generation(); - } - - /************************************************** Shorthand operations */ - - bool has(const Lookup& l) const { - return impl.lookup(l).found(); - } - - // Add |u| if it is not present already. Return false on oom. - template <typename U> - MOZ_MUST_USE bool put(U&& u) { - AddPtr p = lookupForAdd(u); - return p ? true : add(p, mozilla::Forward<U>(u)); - } - - // Like put, but assert that the given key is not already present. - template <typename U> - MOZ_MUST_USE bool putNew(U&& u) { - return impl.putNew(u, mozilla::Forward<U>(u)); - } - - template <typename U> - MOZ_MUST_USE bool putNew(const Lookup& l, U&& u) { - return impl.putNew(l, mozilla::Forward<U>(u)); - } - - // Only call this to populate an empty set after reserving space with init(). - template <typename U> - void putNewInfallible(const Lookup& l, U&& u) { - impl.putNewInfallible(l, mozilla::Forward<U>(u)); - } - - void remove(const Lookup& l) { - if (Ptr p = lookup(l)) - remove(p); - } - - // Infallibly rekey one entry, if present. - // Requires template parameters T and HashPolicy::Lookup to be the same type. - void rekeyIfMoved(const Lookup& old_value, const T& new_value) { - if (old_value != new_value) - rekeyAs(old_value, new_value, new_value); - } - - // Infallibly rekey one entry if present, and return whether that happened. - bool rekeyAs(const Lookup& old_lookup, const Lookup& new_lookup, const T& new_value) { - if (Ptr p = lookup(old_lookup)) { - impl.rekeyAndMaybeRehash(p, new_lookup, new_value); - return true; - } - return false; - } - - // Infallibly replace the current key at |p| with an equivalent key. - // Specifically, both HashPolicy::hash and HashPolicy::match must return - // identical results for the new and old key when applied against all - // possible matching values. - void replaceKey(Ptr p, const T& new_value) { - MOZ_ASSERT(p.found()); - MOZ_ASSERT(*p != new_value); - MOZ_ASSERT(HashPolicy::hash(*p) == HashPolicy::hash(new_value)); - MOZ_ASSERT(HashPolicy::match(*p, new_value)); - const_cast<T&>(*p) = new_value; - } - - // HashSet is movable - HashSet(HashSet&& rhs) : impl(mozilla::Move(rhs.impl)) {} - void operator=(HashSet&& rhs) { - MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited"); - impl = mozilla::Move(rhs.impl); - } - - private: - // HashSet is not copyable or assignable - HashSet(const HashSet& hs) = delete; - HashSet& operator=(const HashSet& hs) = delete; - - friend class Impl::Enum; -}; - -/*****************************************************************************/ - -// Hash Policy -// -// A hash policy P for a hash table with key-type Key must provide: -// - a type |P::Lookup| to use to lookup table entries; -// - a static member function |P::hash| with signature -// -// static js::HashNumber hash(Lookup) -// -// to use to hash the lookup type; and -// - a static member function |P::match| with signature -// -// static bool match(Key, Lookup) -// -// to use to test equality of key and lookup values. -// -// Normally, Lookup = Key. In general, though, different values and types of -// values can be used to lookup and store. If a Lookup value |l| is != to the -// added Key value |k|, the user must ensure that |P::match(k,l)|. E.g.: -// -// js::HashSet<Key, P>::AddPtr p = h.lookup(l); -// if (!p) { -// assert(P::match(k, l)); // must hold -// h.add(p, k); -// } - -// Pointer hashing policy that strips the lowest zeroBits when calculating the -// hash to improve key distribution. -template <typename Key, size_t zeroBits> -struct PointerHasher -{ - typedef Key Lookup; - static HashNumber hash(const Lookup& l) { - size_t word = reinterpret_cast<size_t>(l) >> zeroBits; - static_assert(sizeof(HashNumber) == 4, - "subsequent code assumes a four-byte hash"); -#if JS_BITS_PER_WORD == 32 - return HashNumber(word); -#else - static_assert(sizeof(word) == 8, - "unexpected word size, new hashing strategy required to " - "properly incorporate all bits"); - return HashNumber((word >> 32) ^ word); -#endif - } - static bool match(const Key& k, const Lookup& l) { - return k == l; - } - static void rekey(Key& k, const Key& newKey) { - k = newKey; - } -}; - -// Default hash policy: just use the 'lookup' value. This of course only -// works if the lookup value is integral. HashTable applies ScrambleHashCode to -// the result of the 'hash' which means that it is 'ok' if the lookup value is -// not well distributed over the HashNumber domain. -template <class Key> -struct DefaultHasher -{ - typedef Key Lookup; - static HashNumber hash(const Lookup& l) { - // Hash if can implicitly cast to hash number type. - return l; - } - static bool match(const Key& k, const Lookup& l) { - // Use builtin or overloaded operator==. - return k == l; - } - static void rekey(Key& k, const Key& newKey) { - k = newKey; - } -}; - -// Specialize hashing policy for pointer types. It assumes that the type is -// at least word-aligned. For types with smaller size use PointerHasher. -template <class T> -struct DefaultHasher<T*> : PointerHasher<T*, mozilla::tl::FloorLog2<sizeof(void*)>::value> -{}; - -// Specialize hashing policy for mozilla::UniquePtr to proxy the UniquePtr's -// raw pointer to PointerHasher. -template <class T, class D> -struct DefaultHasher<mozilla::UniquePtr<T, D>> -{ - using Lookup = mozilla::UniquePtr<T, D>; - using PtrHasher = PointerHasher<T*, mozilla::tl::FloorLog2<sizeof(void*)>::value>; - - static HashNumber hash(const Lookup& l) { - return PtrHasher::hash(l.get()); - } - static bool match(const mozilla::UniquePtr<T, D>& k, const Lookup& l) { - return PtrHasher::match(k.get(), l.get()); - } - static void rekey(mozilla::UniquePtr<T, D>& k, mozilla::UniquePtr<T, D>&& newKey) { - k = mozilla::Move(newKey); - } -}; - -// For doubles, we can xor the two uint32s. -template <> -struct DefaultHasher<double> -{ - typedef double Lookup; - static HashNumber hash(double d) { - static_assert(sizeof(HashNumber) == 4, - "subsequent code assumes a four-byte hash"); - uint64_t u = mozilla::BitwiseCast<uint64_t>(d); - return HashNumber(u ^ (u >> 32)); - } - static bool match(double lhs, double rhs) { - return mozilla::BitwiseCast<uint64_t>(lhs) == mozilla::BitwiseCast<uint64_t>(rhs); - } -}; - -template <> -struct DefaultHasher<float> -{ - typedef float Lookup; - static HashNumber hash(float f) { - static_assert(sizeof(HashNumber) == 4, - "subsequent code assumes a four-byte hash"); - return HashNumber(mozilla::BitwiseCast<uint32_t>(f)); - } - static bool match(float lhs, float rhs) { - return mozilla::BitwiseCast<uint32_t>(lhs) == mozilla::BitwiseCast<uint32_t>(rhs); - } -}; - -// A hash policy that compares C strings. -struct CStringHasher -{ - typedef const char* Lookup; - static js::HashNumber hash(Lookup l) { - return mozilla::HashString(l); - } - static bool match(const char* key, Lookup lookup) { - return strcmp(key, lookup) == 0; - } -}; - -// Fallible hashing interface. -// -// Most of the time generating a hash code is infallible so this class provides -// default methods that always succeed. Specialize this class for your own hash -// policy to provide fallible hashing. -// -// This is used by MovableCellHasher to handle the fact that generating a unique -// ID for cell pointer may fail due to OOM. -template <typename HashPolicy> -struct FallibleHashMethods -{ - // Return true if a hashcode is already available for its argument. Once - // this returns true for a specific argument it must continue to do so. - template <typename Lookup> static bool hasHash(Lookup&& l) { return true; } - - // Fallible method to ensure a hashcode exists for its argument and create - // one if not. Returns false on error, e.g. out of memory. - template <typename Lookup> static bool ensureHash(Lookup&& l) { return true; } -}; - -template <typename HashPolicy, typename Lookup> -static bool -HasHash(Lookup&& l) { - return FallibleHashMethods<typename HashPolicy::Base>::hasHash(mozilla::Forward<Lookup>(l)); -} - -template <typename HashPolicy, typename Lookup> -static bool -EnsureHash(Lookup&& l) { - return FallibleHashMethods<typename HashPolicy::Base>::ensureHash(mozilla::Forward<Lookup>(l)); -} - -/*****************************************************************************/ - -// Both HashMap and HashSet are implemented by a single HashTable that is even -// more heavily parameterized than the other two. This leaves HashTable gnarly -// and extremely coupled to HashMap and HashSet; thus code should not use -// HashTable directly. - -template <class Key, class Value> -class HashMapEntry -{ - Key key_; - Value value_; - - template <class, class, class> friend class detail::HashTable; - template <class> friend class detail::HashTableEntry; - template <class, class, class, class> friend class HashMap; - - public: - template<typename KeyInput, typename ValueInput> - HashMapEntry(KeyInput&& k, ValueInput&& v) - : key_(mozilla::Forward<KeyInput>(k)), - value_(mozilla::Forward<ValueInput>(v)) - {} - - HashMapEntry(HashMapEntry&& rhs) - : key_(mozilla::Move(rhs.key_)), - value_(mozilla::Move(rhs.value_)) - {} - - void operator=(HashMapEntry&& rhs) { - key_ = mozilla::Move(rhs.key_); - value_ = mozilla::Move(rhs.value_); - } - - typedef Key KeyType; - typedef Value ValueType; - - const Key& key() const { return key_; } - Key& mutableKey() { return key_; } - const Value& value() const { return value_; } - Value& value() { return value_; } - - private: - HashMapEntry(const HashMapEntry&) = delete; - void operator=(const HashMapEntry&) = delete; -}; - -} // namespace js - -namespace mozilla { - -template <typename T> -struct IsPod<js::detail::HashTableEntry<T> > : IsPod<T> {}; - -template <typename K, typename V> -struct IsPod<js::HashMapEntry<K, V> > - : IntegralConstant<bool, IsPod<K>::value && IsPod<V>::value> -{}; - -} // namespace mozilla - -namespace js { - -namespace detail { - -template <class T, class HashPolicy, class AllocPolicy> -class HashTable; - -template <class T> -class HashTableEntry -{ - template <class, class, class> friend class HashTable; - typedef typename mozilla::RemoveConst<T>::Type NonConstT; - - HashNumber keyHash; - mozilla::AlignedStorage2<NonConstT> mem; - - static const HashNumber sFreeKey = 0; - static const HashNumber sRemovedKey = 1; - static const HashNumber sCollisionBit = 1; - - static bool isLiveHash(HashNumber hash) - { - return hash > sRemovedKey; - } - - HashTableEntry(const HashTableEntry&) = delete; - void operator=(const HashTableEntry&) = delete; - ~HashTableEntry() = delete; - - public: - // NB: HashTableEntry is treated as a POD: no constructor or destructor calls. - - void destroyIfLive() { - if (isLive()) - mem.addr()->~T(); - } - - void destroy() { - MOZ_ASSERT(isLive()); - mem.addr()->~T(); - } - - void swap(HashTableEntry* other) { - if (this == other) - return; - MOZ_ASSERT(isLive()); - if (other->isLive()) { - mozilla::Swap(*mem.addr(), *other->mem.addr()); - } else { - *other->mem.addr() = mozilla::Move(*mem.addr()); - destroy(); - } - mozilla::Swap(keyHash, other->keyHash); - } - - T& get() { MOZ_ASSERT(isLive()); return *mem.addr(); } - NonConstT& getMutable() { MOZ_ASSERT(isLive()); return *mem.addr(); } - - bool isFree() const { return keyHash == sFreeKey; } - void clearLive() { MOZ_ASSERT(isLive()); keyHash = sFreeKey; mem.addr()->~T(); } - void clear() { if (isLive()) mem.addr()->~T(); keyHash = sFreeKey; } - bool isRemoved() const { return keyHash == sRemovedKey; } - void removeLive() { MOZ_ASSERT(isLive()); keyHash = sRemovedKey; mem.addr()->~T(); } - bool isLive() const { return isLiveHash(keyHash); } - void setCollision() { MOZ_ASSERT(isLive()); keyHash |= sCollisionBit; } - void unsetCollision() { keyHash &= ~sCollisionBit; } - bool hasCollision() const { return keyHash & sCollisionBit; } - bool matchHash(HashNumber hn) { return (keyHash & ~sCollisionBit) == hn; } - HashNumber getKeyHash() const { return keyHash & ~sCollisionBit; } - - template <typename... Args> - void setLive(HashNumber hn, Args&&... args) - { - MOZ_ASSERT(!isLive()); - keyHash = hn; - new(mem.addr()) T(mozilla::Forward<Args>(args)...); - MOZ_ASSERT(isLive()); - } -}; - -template <class T, class HashPolicy, class AllocPolicy> -class HashTable : private AllocPolicy -{ - friend class mozilla::ReentrancyGuard; - - typedef typename mozilla::RemoveConst<T>::Type NonConstT; - typedef typename HashPolicy::KeyType Key; - typedef typename HashPolicy::Lookup Lookup; - - public: - typedef HashTableEntry<T> Entry; - - // A nullable pointer to a hash table element. A Ptr |p| can be tested - // either explicitly |if (p.found()) p->...| or using boolean conversion - // |if (p) p->...|. Ptr objects must not be used after any mutating hash - // table operations unless |generation()| is tested. - class Ptr - { - friend class HashTable; - - Entry* entry_; -#ifdef JS_DEBUG - const HashTable* table_; - Generation generation; -#endif - - protected: - Ptr(Entry& entry, const HashTable& tableArg) - : entry_(&entry) -#ifdef JS_DEBUG - , table_(&tableArg) - , generation(tableArg.generation()) -#endif - {} - - public: - Ptr() - : entry_(nullptr) -#ifdef JS_DEBUG - , table_(nullptr) - , generation(0) -#endif - {} - - bool isValid() const { - return !entry_; - } - - bool found() const { - if (isValid()) - return false; -#ifdef JS_DEBUG - MOZ_ASSERT(generation == table_->generation()); -#endif - return entry_->isLive(); - } - - explicit operator bool() const { - return found(); - } - - bool operator==(const Ptr& rhs) const { - MOZ_ASSERT(found() && rhs.found()); - return entry_ == rhs.entry_; - } - - bool operator!=(const Ptr& rhs) const { -#ifdef JS_DEBUG - MOZ_ASSERT(generation == table_->generation()); -#endif - return !(*this == rhs); - } - - T& operator*() const { -#ifdef JS_DEBUG - MOZ_ASSERT(found()); - MOZ_ASSERT(generation == table_->generation()); -#endif - return entry_->get(); - } - - T* operator->() const { -#ifdef JS_DEBUG - MOZ_ASSERT(found()); - MOZ_ASSERT(generation == table_->generation()); -#endif - return &entry_->get(); - } - }; - - // A Ptr that can be used to add a key after a failed lookup. - class AddPtr : public Ptr - { - friend class HashTable; - HashNumber keyHash; -#ifdef JS_DEBUG - uint64_t mutationCount; -#endif - - AddPtr(Entry& entry, const HashTable& tableArg, HashNumber hn) - : Ptr(entry, tableArg) - , keyHash(hn) -#ifdef JS_DEBUG - , mutationCount(tableArg.mutationCount) -#endif - {} - - public: - AddPtr() : keyHash(0) {} - }; - - // A collection of hash table entries. The collection is enumerated by - // calling |front()| followed by |popFront()| as long as |!empty()|. As - // with Ptr/AddPtr, Range objects must not be used after any mutating hash - // table operation unless the |generation()| is tested. - class Range - { - protected: - friend class HashTable; - - Range(const HashTable& tableArg, Entry* c, Entry* e) - : cur(c) - , end(e) -#ifdef JS_DEBUG - , table_(&tableArg) - , mutationCount(tableArg.mutationCount) - , generation(tableArg.generation()) - , validEntry(true) -#endif - { - while (cur < end && !cur->isLive()) - ++cur; - } - - Entry* cur; - Entry* end; -#ifdef JS_DEBUG - const HashTable* table_; - uint64_t mutationCount; - Generation generation; - bool validEntry; -#endif - - public: - Range() - : cur(nullptr) - , end(nullptr) -#ifdef JS_DEBUG - , table_(nullptr) - , mutationCount(0) - , generation(0) - , validEntry(false) -#endif - {} - - bool empty() const { -#ifdef JS_DEBUG - MOZ_ASSERT(generation == table_->generation()); - MOZ_ASSERT(mutationCount == table_->mutationCount); -#endif - return cur == end; - } - - T& front() const { - MOZ_ASSERT(!empty()); -#ifdef JS_DEBUG - MOZ_ASSERT(validEntry); - MOZ_ASSERT(generation == table_->generation()); - MOZ_ASSERT(mutationCount == table_->mutationCount); -#endif - return cur->get(); - } - - void popFront() { - MOZ_ASSERT(!empty()); -#ifdef JS_DEBUG - MOZ_ASSERT(generation == table_->generation()); - MOZ_ASSERT(mutationCount == table_->mutationCount); -#endif - while (++cur < end && !cur->isLive()) - continue; -#ifdef JS_DEBUG - validEntry = true; -#endif - } - }; - - // A Range whose lifetime delimits a mutating enumeration of a hash table. - // Since rehashing when elements were removed during enumeration would be - // bad, it is postponed until the Enum is destructed. Since the Enum's - // destructor touches the hash table, the user must ensure that the hash - // table is still alive when the destructor runs. - class Enum : public Range - { - friend class HashTable; - - HashTable& table_; - bool rekeyed; - bool removed; - - /* Not copyable. */ - Enum(const Enum&) = delete; - void operator=(const Enum&) = delete; - - public: - template<class Map> explicit - Enum(Map& map) : Range(map.all()), table_(map.impl), rekeyed(false), removed(false) {} - - // Removes the |front()| element from the table, leaving |front()| - // invalid until the next call to |popFront()|. For example: - // - // HashSet<int> s; - // for (HashSet<int>::Enum e(s); !e.empty(); e.popFront()) - // if (e.front() == 42) - // e.removeFront(); - void removeFront() { - table_.remove(*this->cur); - removed = true; -#ifdef JS_DEBUG - this->validEntry = false; - this->mutationCount = table_.mutationCount; -#endif - } - - NonConstT& mutableFront() { - MOZ_ASSERT(!this->empty()); -#ifdef JS_DEBUG - MOZ_ASSERT(this->validEntry); - MOZ_ASSERT(this->generation == this->Range::table_->generation()); - MOZ_ASSERT(this->mutationCount == this->Range::table_->mutationCount); -#endif - return this->cur->getMutable(); - } - - // Removes the |front()| element and re-inserts it into the table with - // a new key at the new Lookup position. |front()| is invalid after - // this operation until the next call to |popFront()|. - void rekeyFront(const Lookup& l, const Key& k) { - MOZ_ASSERT(&k != &HashPolicy::getKey(this->cur->get())); - Ptr p(*this->cur, table_); - table_.rekeyWithoutRehash(p, l, k); - rekeyed = true; -#ifdef JS_DEBUG - this->validEntry = false; - this->mutationCount = table_.mutationCount; -#endif - } - - void rekeyFront(const Key& k) { - rekeyFront(k, k); - } - - // Potentially rehashes the table. - ~Enum() { - if (rekeyed) { - table_.gen++; - table_.checkOverRemoved(); - } - - if (removed) - table_.compactIfUnderloaded(); - } - }; - - // HashTable is movable - HashTable(HashTable&& rhs) - : AllocPolicy(rhs) - { - mozilla::PodAssign(this, &rhs); - rhs.table = nullptr; - } - void operator=(HashTable&& rhs) { - MOZ_ASSERT(this != &rhs, "self-move assignment is prohibited"); - if (table) - destroyTable(*this, table, capacity()); - mozilla::PodAssign(this, &rhs); - rhs.table = nullptr; - } - - private: - // HashTable is not copyable or assignable - HashTable(const HashTable&) = delete; - void operator=(const HashTable&) = delete; - - private: - static const size_t CAP_BITS = 30; - - public: - uint64_t gen:56; // entry storage generation number - uint64_t hashShift:8; // multiplicative hash shift - Entry* table; // entry storage - uint32_t entryCount; // number of entries in table - uint32_t removedCount; // removed entry sentinels in table - -#ifdef JS_DEBUG - uint64_t mutationCount; - mutable bool mEntered; - // Note that some updates to these stats are not thread-safe. See the - // comment on the three-argument overloading of HashTable::lookup(). - mutable struct Stats - { - uint32_t searches; // total number of table searches - uint32_t steps; // hash chain links traversed - uint32_t hits; // searches that found key - uint32_t misses; // searches that didn't find key - uint32_t addOverRemoved; // adds that recycled a removed entry - uint32_t removes; // calls to remove - uint32_t removeFrees; // calls to remove that freed the entry - uint32_t grows; // table expansions - uint32_t shrinks; // table contractions - uint32_t compresses; // table compressions - uint32_t rehashes; // tombstone decontaminations - } stats; -# define METER(x) x -#else -# define METER(x) -#endif - - // The default initial capacity is 32 (enough to hold 16 elements), but it - // can be as low as 4. - static const unsigned sMinCapacityLog2 = 2; - static const unsigned sMinCapacity = 1 << sMinCapacityLog2; - static const unsigned sMaxInit = JS_BIT(CAP_BITS - 1); - static const unsigned sMaxCapacity = JS_BIT(CAP_BITS); - static const unsigned sHashBits = mozilla::tl::BitSize<HashNumber>::value; - - // Hash-table alpha is conceptually a fraction, but to avoid floating-point - // math we implement it as a ratio of integers. - static const uint8_t sAlphaDenominator = 4; - static const uint8_t sMinAlphaNumerator = 1; // min alpha: 1/4 - static const uint8_t sMaxAlphaNumerator = 3; // max alpha: 3/4 - - static const HashNumber sFreeKey = Entry::sFreeKey; - static const HashNumber sRemovedKey = Entry::sRemovedKey; - static const HashNumber sCollisionBit = Entry::sCollisionBit; - - void setTableSizeLog2(unsigned sizeLog2) - { - hashShift = sHashBits - sizeLog2; - } - - static bool isLiveHash(HashNumber hash) - { - return Entry::isLiveHash(hash); - } - - static HashNumber prepareHash(const Lookup& l) - { - HashNumber keyHash = ScrambleHashCode(HashPolicy::hash(l)); - - // Avoid reserved hash codes. - if (!isLiveHash(keyHash)) - keyHash -= (sRemovedKey + 1); - return keyHash & ~sCollisionBit; - } - - enum FailureBehavior { DontReportFailure = false, ReportFailure = true }; - - static Entry* createTable(AllocPolicy& alloc, uint32_t capacity, - FailureBehavior reportFailure = ReportFailure) - { - static_assert(sFreeKey == 0, - "newly-calloc'd tables have to be considered empty"); - if (reportFailure) - return alloc.template pod_calloc<Entry>(capacity); - - return alloc.template maybe_pod_calloc<Entry>(capacity); - } - - static Entry* maybeCreateTable(AllocPolicy& alloc, uint32_t capacity) - { - static_assert(sFreeKey == 0, - "newly-calloc'd tables have to be considered empty"); - return alloc.template maybe_pod_calloc<Entry>(capacity); - } - - static void destroyTable(AllocPolicy& alloc, Entry* oldTable, uint32_t capacity) - { - Entry* end = oldTable + capacity; - for (Entry* e = oldTable; e < end; ++e) - e->destroyIfLive(); - alloc.free_(oldTable); - } - - public: - explicit HashTable(AllocPolicy ap) - : AllocPolicy(ap) - , gen(0) - , hashShift(sHashBits) - , table(nullptr) - , entryCount(0) - , removedCount(0) -#ifdef JS_DEBUG - , mutationCount(0) - , mEntered(false) -#endif - {} - - MOZ_MUST_USE bool init(uint32_t length) - { - MOZ_ASSERT(!initialized()); - - // Reject all lengths whose initial computed capacity would exceed - // sMaxCapacity. Round that maximum length down to the nearest power - // of two for speedier code. - if (MOZ_UNLIKELY(length > sMaxInit)) { - this->reportAllocOverflow(); - return false; - } - - static_assert((sMaxInit * sAlphaDenominator) / sAlphaDenominator == sMaxInit, - "multiplication in numerator below could overflow"); - static_assert(sMaxInit * sAlphaDenominator <= UINT32_MAX - sMaxAlphaNumerator, - "numerator calculation below could potentially overflow"); - - // Compute the smallest capacity allowing |length| elements to be - // inserted without rehashing: ceil(length / max-alpha). (Ceiling - // integral division: <http://stackoverflow.com/a/2745086>.) - uint32_t newCapacity = - (length * sAlphaDenominator + sMaxAlphaNumerator - 1) / sMaxAlphaNumerator; - if (newCapacity < sMinCapacity) - newCapacity = sMinCapacity; - - // FIXME: use JS_CEILING_LOG2 when PGO stops crashing (bug 543034). - uint32_t roundUp = sMinCapacity, roundUpLog2 = sMinCapacityLog2; - while (roundUp < newCapacity) { - roundUp <<= 1; - ++roundUpLog2; - } - - newCapacity = roundUp; - MOZ_ASSERT(newCapacity >= length); - MOZ_ASSERT(newCapacity <= sMaxCapacity); - - table = createTable(*this, newCapacity); - if (!table) - return false; - - setTableSizeLog2(roundUpLog2); - METER(memset(&stats, 0, sizeof(stats))); - return true; - } - - bool initialized() const - { - return !!table; - } - - ~HashTable() - { - if (table) - destroyTable(*this, table, capacity()); - } - - private: - HashNumber hash1(HashNumber hash0) const - { - return hash0 >> hashShift; - } - - struct DoubleHash - { - HashNumber h2; - HashNumber sizeMask; - }; - - DoubleHash hash2(HashNumber curKeyHash) const - { - unsigned sizeLog2 = sHashBits - hashShift; - DoubleHash dh = { - ((curKeyHash << sizeLog2) >> hashShift) | 1, - (HashNumber(1) << sizeLog2) - 1 - }; - return dh; - } - - static HashNumber applyDoubleHash(HashNumber h1, const DoubleHash& dh) - { - return (h1 - dh.h2) & dh.sizeMask; - } - - bool overloaded() - { - static_assert(sMaxCapacity <= UINT32_MAX / sMaxAlphaNumerator, - "multiplication below could overflow"); - return entryCount + removedCount >= - capacity() * sMaxAlphaNumerator / sAlphaDenominator; - } - - // Would the table be underloaded if it had the given capacity and entryCount? - static bool wouldBeUnderloaded(uint32_t capacity, uint32_t entryCount) - { - static_assert(sMaxCapacity <= UINT32_MAX / sMinAlphaNumerator, - "multiplication below could overflow"); - return capacity > sMinCapacity && - entryCount <= capacity * sMinAlphaNumerator / sAlphaDenominator; - } - - bool underloaded() - { - return wouldBeUnderloaded(capacity(), entryCount); - } - - static bool match(Entry& e, const Lookup& l) - { - return HashPolicy::match(HashPolicy::getKey(e.get()), l); - } - - // Warning: in order for readonlyThreadsafeLookup() to be safe this - // function must not modify the table in any way when |collisionBit| is 0. - // (The use of the METER() macro to increment stats violates this - // restriction but we will live with that for now because it's enabled so - // rarely.) - Entry& lookup(const Lookup& l, HashNumber keyHash, unsigned collisionBit) const - { - MOZ_ASSERT(isLiveHash(keyHash)); - MOZ_ASSERT(!(keyHash & sCollisionBit)); - MOZ_ASSERT(collisionBit == 0 || collisionBit == sCollisionBit); - MOZ_ASSERT(table); - METER(stats.searches++); - - // Compute the primary hash address. - HashNumber h1 = hash1(keyHash); - Entry* entry = &table[h1]; - - // Miss: return space for a new entry. - if (entry->isFree()) { - METER(stats.misses++); - return *entry; - } - - // Hit: return entry. - if (entry->matchHash(keyHash) && match(*entry, l)) { - METER(stats.hits++); - return *entry; - } - - // Collision: double hash. - DoubleHash dh = hash2(keyHash); - - // Save the first removed entry pointer so we can recycle later. - Entry* firstRemoved = nullptr; - - while (true) { - if (MOZ_UNLIKELY(entry->isRemoved())) { - if (!firstRemoved) - firstRemoved = entry; - } else { - if (collisionBit == sCollisionBit) - entry->setCollision(); - } - - METER(stats.steps++); - h1 = applyDoubleHash(h1, dh); - - entry = &table[h1]; - if (entry->isFree()) { - METER(stats.misses++); - return firstRemoved ? *firstRemoved : *entry; - } - - if (entry->matchHash(keyHash) && match(*entry, l)) { - METER(stats.hits++); - return *entry; - } - } - } - - // This is a copy of lookup hardcoded to the assumptions: - // 1. the lookup is a lookupForAdd - // 2. the key, whose |keyHash| has been passed is not in the table, - // 3. no entries have been removed from the table. - // This specialized search avoids the need for recovering lookup values - // from entries, which allows more flexible Lookup/Key types. - Entry& findFreeEntry(HashNumber keyHash) - { - MOZ_ASSERT(!(keyHash & sCollisionBit)); - MOZ_ASSERT(table); - METER(stats.searches++); - - // We assume 'keyHash' has already been distributed. - - // Compute the primary hash address. - HashNumber h1 = hash1(keyHash); - Entry* entry = &table[h1]; - - // Miss: return space for a new entry. - if (!entry->isLive()) { - METER(stats.misses++); - return *entry; - } - - // Collision: double hash. - DoubleHash dh = hash2(keyHash); - - while (true) { - MOZ_ASSERT(!entry->isRemoved()); - entry->setCollision(); - - METER(stats.steps++); - h1 = applyDoubleHash(h1, dh); - - entry = &table[h1]; - if (!entry->isLive()) { - METER(stats.misses++); - return *entry; - } - } - } - - enum RebuildStatus { NotOverloaded, Rehashed, RehashFailed }; - - RebuildStatus changeTableSize(int deltaLog2, FailureBehavior reportFailure = ReportFailure) - { - // Look, but don't touch, until we succeed in getting new entry store. - Entry* oldTable = table; - uint32_t oldCap = capacity(); - uint32_t newLog2 = sHashBits - hashShift + deltaLog2; - uint32_t newCapacity = JS_BIT(newLog2); - if (MOZ_UNLIKELY(newCapacity > sMaxCapacity)) { - if (reportFailure) - this->reportAllocOverflow(); - return RehashFailed; - } - - Entry* newTable = createTable(*this, newCapacity, reportFailure); - if (!newTable) - return RehashFailed; - - // We can't fail from here on, so update table parameters. - setTableSizeLog2(newLog2); - removedCount = 0; - gen++; - table = newTable; - - // Copy only live entries, leaving removed ones behind. - Entry* end = oldTable + oldCap; - for (Entry* src = oldTable; src < end; ++src) { - if (src->isLive()) { - HashNumber hn = src->getKeyHash(); - findFreeEntry(hn).setLive( - hn, mozilla::Move(const_cast<typename Entry::NonConstT&>(src->get()))); - src->destroy(); - } - } - - // All entries have been destroyed, no need to destroyTable. - this->free_(oldTable); - return Rehashed; - } - - bool shouldCompressTable() - { - // Compress if a quarter or more of all entries are removed. - return removedCount >= (capacity() >> 2); - } - - RebuildStatus checkOverloaded(FailureBehavior reportFailure = ReportFailure) - { - if (!overloaded()) - return NotOverloaded; - - int deltaLog2; - if (shouldCompressTable()) { - METER(stats.compresses++); - deltaLog2 = 0; - } else { - METER(stats.grows++); - deltaLog2 = 1; - } - - return changeTableSize(deltaLog2, reportFailure); - } - - // Infallibly rehash the table if we are overloaded with removals. - void checkOverRemoved() - { - if (overloaded()) { - if (checkOverloaded(DontReportFailure) == RehashFailed) - rehashTableInPlace(); - } - } - - void remove(Entry& e) - { - MOZ_ASSERT(table); - METER(stats.removes++); - - if (e.hasCollision()) { - e.removeLive(); - removedCount++; - } else { - METER(stats.removeFrees++); - e.clearLive(); - } - entryCount--; -#ifdef JS_DEBUG - mutationCount++; -#endif - } - - void checkUnderloaded() - { - if (underloaded()) { - METER(stats.shrinks++); - (void) changeTableSize(-1, DontReportFailure); - } - } - - // Resize the table down to the largest capacity which doesn't underload the - // table. Since we call checkUnderloaded() on every remove, you only need - // to call this after a bulk removal of items done without calling remove(). - void compactIfUnderloaded() - { - int32_t resizeLog2 = 0; - uint32_t newCapacity = capacity(); - while (wouldBeUnderloaded(newCapacity, entryCount)) { - newCapacity = newCapacity >> 1; - resizeLog2--; - } - - if (resizeLog2 != 0) - (void) changeTableSize(resizeLog2, DontReportFailure); - } - - // This is identical to changeTableSize(currentSize), but without requiring - // a second table. We do this by recycling the collision bits to tell us if - // the element is already inserted or still waiting to be inserted. Since - // already-inserted elements win any conflicts, we get the same table as we - // would have gotten through random insertion order. - void rehashTableInPlace() - { - METER(stats.rehashes++); - removedCount = 0; - for (size_t i = 0; i < capacity(); ++i) - table[i].unsetCollision(); - - for (size_t i = 0; i < capacity();) { - Entry* src = &table[i]; - - if (!src->isLive() || src->hasCollision()) { - ++i; - continue; - } - - HashNumber keyHash = src->getKeyHash(); - HashNumber h1 = hash1(keyHash); - DoubleHash dh = hash2(keyHash); - Entry* tgt = &table[h1]; - while (true) { - if (!tgt->hasCollision()) { - src->swap(tgt); - tgt->setCollision(); - break; - } - - h1 = applyDoubleHash(h1, dh); - tgt = &table[h1]; - } - } - - // TODO: this algorithm leaves collision bits on *all* elements, even if - // they are on no collision path. We have the option of setting the - // collision bits correctly on a subsequent pass or skipping the rehash - // unless we are totally filled with tombstones: benchmark to find out - // which approach is best. - } - - // Note: |l| may be a reference to a piece of |u|, so this function - // must take care not to use |l| after moving |u|. - // - // Prefer to use putNewInfallible; this function does not check - // invariants. - template <typename... Args> - void putNewInfallibleInternal(const Lookup& l, Args&&... args) - { - MOZ_ASSERT(table); - - HashNumber keyHash = prepareHash(l); - Entry* entry = &findFreeEntry(keyHash); - MOZ_ASSERT(entry); - - if (entry->isRemoved()) { - METER(stats.addOverRemoved++); - removedCount--; - keyHash |= sCollisionBit; - } - - entry->setLive(keyHash, mozilla::Forward<Args>(args)...); - entryCount++; -#ifdef JS_DEBUG - mutationCount++; -#endif - } - - public: - void clear() - { - if (mozilla::IsPod<Entry>::value) { - memset(table, 0, sizeof(*table) * capacity()); - } else { - uint32_t tableCapacity = capacity(); - Entry* end = table + tableCapacity; - for (Entry* e = table; e < end; ++e) - e->clear(); - } - removedCount = 0; - entryCount = 0; -#ifdef JS_DEBUG - mutationCount++; -#endif - } - - void finish() - { -#ifdef JS_DEBUG - MOZ_ASSERT(!mEntered); -#endif - if (!table) - return; - - destroyTable(*this, table, capacity()); - table = nullptr; - gen++; - entryCount = 0; - removedCount = 0; -#ifdef JS_DEBUG - mutationCount++; -#endif - } - - Range all() const - { - MOZ_ASSERT(table); - return Range(*this, table, table + capacity()); - } - - bool empty() const - { - MOZ_ASSERT(table); - return !entryCount; - } - - uint32_t count() const - { - MOZ_ASSERT(table); - return entryCount; - } - - uint32_t capacity() const - { - MOZ_ASSERT(table); - return JS_BIT(sHashBits - hashShift); - } - - Generation generation() const - { - MOZ_ASSERT(table); - return Generation(gen); - } - - size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const - { - return mallocSizeOf(table); - } - - size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const - { - return mallocSizeOf(this) + sizeOfExcludingThis(mallocSizeOf); - } - - Ptr lookup(const Lookup& l) const - { - mozilla::ReentrancyGuard g(*this); - if (!HasHash<HashPolicy>(l)) - return Ptr(); - HashNumber keyHash = prepareHash(l); - return Ptr(lookup(l, keyHash, 0), *this); - } - - Ptr readonlyThreadsafeLookup(const Lookup& l) const - { - if (!HasHash<HashPolicy>(l)) - return Ptr(); - HashNumber keyHash = prepareHash(l); - return Ptr(lookup(l, keyHash, 0), *this); - } - - AddPtr lookupForAdd(const Lookup& l) const - { - mozilla::ReentrancyGuard g(*this); - if (!EnsureHash<HashPolicy>(l)) - return AddPtr(); - HashNumber keyHash = prepareHash(l); - Entry& entry = lookup(l, keyHash, sCollisionBit); - AddPtr p(entry, *this, keyHash); - return p; - } - - template <typename... Args> - MOZ_MUST_USE bool add(AddPtr& p, Args&&... args) - { - mozilla::ReentrancyGuard g(*this); - MOZ_ASSERT(table); - MOZ_ASSERT(!p.found()); - MOZ_ASSERT(!(p.keyHash & sCollisionBit)); - - // Check for error from ensureHash() here. - if (p.isValid()) - return false; - - // Changing an entry from removed to live does not affect whether we - // are overloaded and can be handled separately. - if (p.entry_->isRemoved()) { - if (!this->checkSimulatedOOM()) - return false; - METER(stats.addOverRemoved++); - removedCount--; - p.keyHash |= sCollisionBit; - } else { - // Preserve the validity of |p.entry_|. - RebuildStatus status = checkOverloaded(); - if (status == RehashFailed) - return false; - if (status == NotOverloaded && !this->checkSimulatedOOM()) - return false; - if (status == Rehashed) - p.entry_ = &findFreeEntry(p.keyHash); - } - - p.entry_->setLive(p.keyHash, mozilla::Forward<Args>(args)...); - entryCount++; -#ifdef JS_DEBUG - mutationCount++; - p.generation = generation(); - p.mutationCount = mutationCount; -#endif - return true; - } - - // Note: |l| may be a reference to a piece of |u|, so this function - // must take care not to use |l| after moving |u|. - template <typename... Args> - void putNewInfallible(const Lookup& l, Args&&... args) - { - MOZ_ASSERT(!lookup(l).found()); - mozilla::ReentrancyGuard g(*this); - putNewInfallibleInternal(l, mozilla::Forward<Args>(args)...); - } - - // Note: |l| may be alias arguments in |args|, so this function must take - // care not to use |l| after moving |args|. - template <typename... Args> - MOZ_MUST_USE bool putNew(const Lookup& l, Args&&... args) - { - if (!this->checkSimulatedOOM()) - return false; - - if (!EnsureHash<HashPolicy>(l)) - return false; - - if (checkOverloaded() == RehashFailed) - return false; - - putNewInfallible(l, mozilla::Forward<Args>(args)...); - return true; - } - - // Note: |l| may be a reference to a piece of |u|, so this function - // must take care not to use |l| after moving |u|. - template <typename... Args> - MOZ_MUST_USE bool relookupOrAdd(AddPtr& p, const Lookup& l, Args&&... args) - { - // Check for error from ensureHash() here. - if (p.isValid()) - return false; - -#ifdef JS_DEBUG - p.generation = generation(); - p.mutationCount = mutationCount; -#endif - { - mozilla::ReentrancyGuard g(*this); - MOZ_ASSERT(prepareHash(l) == p.keyHash); // l has not been destroyed - p.entry_ = &lookup(l, p.keyHash, sCollisionBit); - } - return p.found() || add(p, mozilla::Forward<Args>(args)...); - } - - void remove(Ptr p) - { - MOZ_ASSERT(table); - mozilla::ReentrancyGuard g(*this); - MOZ_ASSERT(p.found()); - remove(*p.entry_); - checkUnderloaded(); - } - - void rekeyWithoutRehash(Ptr p, const Lookup& l, const Key& k) - { - MOZ_ASSERT(table); - mozilla::ReentrancyGuard g(*this); - MOZ_ASSERT(p.found()); - typename HashTableEntry<T>::NonConstT t(mozilla::Move(*p)); - HashPolicy::setKey(t, const_cast<Key&>(k)); - remove(*p.entry_); - putNewInfallibleInternal(l, mozilla::Move(t)); - } - - void rekeyAndMaybeRehash(Ptr p, const Lookup& l, const Key& k) - { - rekeyWithoutRehash(p, l, k); - checkOverRemoved(); - } - -#undef METER -}; - -} // namespace detail -} // namespace js - -#endif /* js_HashTable_h */ diff --git a/android/armeabi/include/spidermonkey/js/HeapAPI.h b/android/armeabi/include/spidermonkey/js/HeapAPI.h deleted file mode 100644 index e37d13e9..00000000 --- a/android/armeabi/include/spidermonkey/js/HeapAPI.h +++ /dev/null @@ -1,406 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_HeapAPI_h -#define js_HeapAPI_h - -#include <limits.h> - -#include "jspubtd.h" - -#include "js/TraceKind.h" -#include "js/Utility.h" - -/* These values are private to the JS engine. */ -namespace js { - -JS_FRIEND_API(bool) -CurrentThreadCanAccessZone(JS::Zone* zone); - -namespace gc { - -struct Cell; - -const size_t ArenaShift = 12; -const size_t ArenaSize = size_t(1) << ArenaShift; -const size_t ArenaMask = ArenaSize - 1; - -#ifdef JS_GC_SMALL_CHUNK_SIZE -const size_t ChunkShift = 18; -#else -const size_t ChunkShift = 20; -#endif -const size_t ChunkSize = size_t(1) << ChunkShift; -const size_t ChunkMask = ChunkSize - 1; - -const size_t CellShift = 3; -const size_t CellSize = size_t(1) << CellShift; -const size_t CellMask = CellSize - 1; - -/* These are magic constants derived from actual offsets in gc/Heap.h. */ -#ifdef JS_GC_SMALL_CHUNK_SIZE -const size_t ChunkMarkBitmapOffset = 258104; -const size_t ChunkMarkBitmapBits = 31744; -#else -const size_t ChunkMarkBitmapOffset = 1032352; -const size_t ChunkMarkBitmapBits = 129024; -#endif -const size_t ChunkRuntimeOffset = ChunkSize - sizeof(void*); -const size_t ChunkTrailerSize = 2 * sizeof(uintptr_t) + sizeof(uint64_t); -const size_t ChunkLocationOffset = ChunkSize - ChunkTrailerSize; -const size_t ArenaZoneOffset = sizeof(size_t); -const size_t ArenaHeaderSize = sizeof(size_t) + 2 * sizeof(uintptr_t) + - sizeof(size_t) + sizeof(uintptr_t); - -/* - * Live objects are marked black. How many other additional colors are available - * depends on the size of the GCThing. Objects marked gray are eligible for - * cycle collection. - */ -static const uint32_t BLACK = 0; -static const uint32_t GRAY = 1; - -/* - * The "location" field in the Chunk trailer is a enum indicating various roles - * of the chunk. - */ -enum class ChunkLocation : uint32_t -{ - Invalid = 0, - Nursery = 1, - TenuredHeap = 2 -}; - -#ifdef JS_DEBUG -/* When downcasting, ensure we are actually the right type. */ -extern JS_FRIEND_API(void) -AssertGCThingHasType(js::gc::Cell* cell, JS::TraceKind kind); -#else -inline void -AssertGCThingHasType(js::gc::Cell* cell, JS::TraceKind kind) {} -#endif - -MOZ_ALWAYS_INLINE bool IsInsideNursery(const js::gc::Cell* cell); - -} /* namespace gc */ -} /* namespace js */ - -namespace JS { -struct Zone; - -/* Default size for the generational nursery in bytes. */ -const uint32_t DefaultNurseryBytes = 16 * js::gc::ChunkSize; - -/* Default maximum heap size in bytes to pass to JS_NewRuntime(). */ -const uint32_t DefaultHeapMaxBytes = 32 * 1024 * 1024; - -namespace shadow { - -struct Zone -{ - protected: - JSRuntime* const runtime_; - JSTracer* const barrierTracer_; // A pointer to the JSRuntime's |gcMarker|. - - public: - // Stack GC roots for Rooted GC pointers. - js::RootedListHeads stackRoots_; - template <typename T> friend class JS::Rooted; - - bool needsIncrementalBarrier_; - - Zone(JSRuntime* runtime, JSTracer* barrierTracerArg) - : runtime_(runtime), - barrierTracer_(barrierTracerArg), - needsIncrementalBarrier_(false) - { - for (auto& stackRootPtr : stackRoots_) - stackRootPtr = nullptr; - } - - bool needsIncrementalBarrier() const { - return needsIncrementalBarrier_; - } - - JSTracer* barrierTracer() { - MOZ_ASSERT(needsIncrementalBarrier_); - MOZ_ASSERT(js::CurrentThreadCanAccessRuntime(runtime_)); - return barrierTracer_; - } - - JSRuntime* runtimeFromMainThread() const { - MOZ_ASSERT(js::CurrentThreadCanAccessRuntime(runtime_)); - return runtime_; - } - - // Note: Unrestricted access to the zone's runtime from an arbitrary - // thread can easily lead to races. Use this method very carefully. - JSRuntime* runtimeFromAnyThread() const { - return runtime_; - } - - static MOZ_ALWAYS_INLINE JS::shadow::Zone* asShadowZone(JS::Zone* zone) { - return reinterpret_cast<JS::shadow::Zone*>(zone); - } -}; - -} /* namespace shadow */ - -/** - * A GC pointer, tagged with the trace kind. - * - * In general, a GC pointer should be stored with an exact type. This class - * is for use when that is not possible because a single pointer must point - * to several kinds of GC thing. - */ -class JS_FRIEND_API(GCCellPtr) -{ - public: - // Construction from a void* and trace kind. - GCCellPtr(void* gcthing, JS::TraceKind traceKind) : ptr(checkedCast(gcthing, traceKind)) {} - - // Automatically construct a null GCCellPtr from nullptr. - MOZ_IMPLICIT GCCellPtr(decltype(nullptr)) : ptr(checkedCast(nullptr, JS::TraceKind::Null)) {} - - // Construction from an explicit type. - template <typename T> - explicit GCCellPtr(T* p) : ptr(checkedCast(p, JS::MapTypeToTraceKind<T>::kind)) { } - explicit GCCellPtr(JSFunction* p) : ptr(checkedCast(p, JS::TraceKind::Object)) { } - explicit GCCellPtr(JSFlatString* str) : ptr(checkedCast(str, JS::TraceKind::String)) { } - explicit GCCellPtr(const Value& v); - - JS::TraceKind kind() const { - JS::TraceKind traceKind = JS::TraceKind(ptr & OutOfLineTraceKindMask); - if (uintptr_t(traceKind) != OutOfLineTraceKindMask) - return traceKind; - return outOfLineKind(); - } - - // Allow GCCellPtr to be used in a boolean context. - explicit operator bool() const { - MOZ_ASSERT(bool(asCell()) == (kind() != JS::TraceKind::Null)); - return asCell(); - } - - // Simplify checks to the kind. - template <typename T> - bool is() const { return kind() == JS::MapTypeToTraceKind<T>::kind; } - - // Conversions to more specific types must match the kind. Access to - // further refined types is not allowed directly from a GCCellPtr. - template <typename T> - T& as() const { - MOZ_ASSERT(kind() == JS::MapTypeToTraceKind<T>::kind); - // We can't use static_cast here, because the fact that JSObject - // inherits from js::gc::Cell is not part of the public API. - return *reinterpret_cast<T*>(asCell()); - } - - // Return a pointer to the cell this |GCCellPtr| refers to, or |nullptr|. - // (It would be more symmetrical with |to| for this to return a |Cell&|, but - // the result can be |nullptr|, and null references are undefined behavior.) - js::gc::Cell* asCell() const { - return reinterpret_cast<js::gc::Cell*>(ptr & ~OutOfLineTraceKindMask); - } - - // The CC's trace logger needs an identity that is XPIDL serializable. - uint64_t unsafeAsInteger() const { - return static_cast<uint64_t>(unsafeAsUIntPtr()); - } - // Inline mark bitmap access requires direct pointer arithmetic. - uintptr_t unsafeAsUIntPtr() const { - MOZ_ASSERT(asCell()); - MOZ_ASSERT(!js::gc::IsInsideNursery(asCell())); - return reinterpret_cast<uintptr_t>(asCell()); - } - - bool mayBeOwnedByOtherRuntime() const; - - private: - static uintptr_t checkedCast(void* p, JS::TraceKind traceKind) { - js::gc::Cell* cell = static_cast<js::gc::Cell*>(p); - MOZ_ASSERT((uintptr_t(p) & OutOfLineTraceKindMask) == 0); - AssertGCThingHasType(cell, traceKind); - // Note: the OutOfLineTraceKindMask bits are set on all out-of-line kinds - // so that we can mask instead of branching. - MOZ_ASSERT_IF(uintptr_t(traceKind) >= OutOfLineTraceKindMask, - (uintptr_t(traceKind) & OutOfLineTraceKindMask) == OutOfLineTraceKindMask); - return uintptr_t(p) | (uintptr_t(traceKind) & OutOfLineTraceKindMask); - } - - JS::TraceKind outOfLineKind() const; - - uintptr_t ptr; -}; - -inline bool -operator==(const GCCellPtr& ptr1, const GCCellPtr& ptr2) -{ - return ptr1.asCell() == ptr2.asCell(); -} - -inline bool -operator!=(const GCCellPtr& ptr1, const GCCellPtr& ptr2) -{ - return !(ptr1 == ptr2); -} - -// Unwraps the given GCCellPtr and calls the given functor with a template -// argument of the actual type of the pointer. -template <typename F, typename... Args> -auto -DispatchTyped(F f, GCCellPtr thing, Args&&... args) - -> decltype(f(static_cast<JSObject*>(nullptr), mozilla::Forward<Args>(args)...)) -{ - switch (thing.kind()) { -#define JS_EXPAND_DEF(name, type, _) \ - case JS::TraceKind::name: \ - return f(&thing.as<type>(), mozilla::Forward<Args>(args)...); - JS_FOR_EACH_TRACEKIND(JS_EXPAND_DEF); -#undef JS_EXPAND_DEF - default: - MOZ_CRASH("Invalid trace kind in DispatchTyped for GCCellPtr."); - } -} - -} /* namespace JS */ - -namespace js { -namespace gc { -namespace detail { - -static MOZ_ALWAYS_INLINE uintptr_t* -GetGCThingMarkBitmap(const uintptr_t addr) -{ - MOZ_ASSERT(addr); - const uintptr_t bmap_addr = (addr & ~ChunkMask) | ChunkMarkBitmapOffset; - return reinterpret_cast<uintptr_t*>(bmap_addr); -} - -static MOZ_ALWAYS_INLINE void -GetGCThingMarkWordAndMask(const uintptr_t addr, uint32_t color, - uintptr_t** wordp, uintptr_t* maskp) -{ - MOZ_ASSERT(addr); - const size_t bit = (addr & js::gc::ChunkMask) / js::gc::CellSize + color; - MOZ_ASSERT(bit < js::gc::ChunkMarkBitmapBits); - uintptr_t* bitmap = GetGCThingMarkBitmap(addr); - const uintptr_t nbits = sizeof(*bitmap) * CHAR_BIT; - *maskp = uintptr_t(1) << (bit % nbits); - *wordp = &bitmap[bit / nbits]; -} - -static MOZ_ALWAYS_INLINE JS::Zone* -GetGCThingZone(const uintptr_t addr) -{ - MOZ_ASSERT(addr); - const uintptr_t zone_addr = (addr & ~ArenaMask) | ArenaZoneOffset; - return *reinterpret_cast<JS::Zone**>(zone_addr); - -} - -static MOZ_ALWAYS_INLINE JS::shadow::Runtime* -GetCellRuntime(const Cell* cell) -{ - MOZ_ASSERT(cell); - const uintptr_t addr = uintptr_t(cell); - const uintptr_t rt_addr = (addr & ~ChunkMask) | ChunkRuntimeOffset; - return *reinterpret_cast<JS::shadow::Runtime**>(rt_addr); -} - -static MOZ_ALWAYS_INLINE bool -CellIsMarkedGray(const Cell* cell) -{ - MOZ_ASSERT(cell); - if (js::gc::IsInsideNursery(cell)) - return false; - - uintptr_t* word, mask; - js::gc::detail::GetGCThingMarkWordAndMask(uintptr_t(cell), js::gc::GRAY, &word, &mask); - return *word & mask; -} - -extern JS_PUBLIC_API(bool) -CellIsMarkedGrayIfKnown(const Cell* cell); - -} /* namespace detail */ - -MOZ_ALWAYS_INLINE bool -IsInsideNursery(const js::gc::Cell* cell) -{ - if (!cell) - return false; - uintptr_t addr = uintptr_t(cell); - addr &= ~js::gc::ChunkMask; - addr |= js::gc::ChunkLocationOffset; - auto location = *reinterpret_cast<ChunkLocation*>(addr); - MOZ_ASSERT(location == ChunkLocation::Nursery || location == ChunkLocation::TenuredHeap); - return location == ChunkLocation::Nursery; -} - -} /* namespace gc */ -} /* namespace js */ - -namespace JS { - -static MOZ_ALWAYS_INLINE Zone* -GetTenuredGCThingZone(GCCellPtr thing) -{ - MOZ_ASSERT(!js::gc::IsInsideNursery(thing.asCell())); - return js::gc::detail::GetGCThingZone(thing.unsafeAsUIntPtr()); -} - -static MOZ_ALWAYS_INLINE Zone* -GetStringZone(JSString* str) -{ - return js::gc::detail::GetGCThingZone(uintptr_t(str)); -} - -extern JS_PUBLIC_API(Zone*) -GetObjectZone(JSObject* obj); - -static MOZ_ALWAYS_INLINE bool -GCThingIsMarkedGray(GCCellPtr thing) -{ - if (thing.mayBeOwnedByOtherRuntime()) - return false; - return js::gc::detail::CellIsMarkedGrayIfKnown(thing.asCell()); -} - -extern JS_PUBLIC_API(JS::TraceKind) -GCThingTraceKind(void* thing); - -} /* namespace JS */ - -namespace js { -namespace gc { - -static MOZ_ALWAYS_INLINE bool -IsIncrementalBarrierNeededOnTenuredGCThing(JS::shadow::Runtime* rt, const JS::GCCellPtr thing) -{ - MOZ_ASSERT(thing); - MOZ_ASSERT(!js::gc::IsInsideNursery(thing.asCell())); - - // TODO: I'd like to assert !isHeapBusy() here but this gets called while we - // are tracing the heap, e.g. during memory reporting (see bug 1313318). - MOZ_ASSERT(!rt->isHeapCollecting()); - - JS::Zone* zone = JS::GetTenuredGCThingZone(thing); - return JS::shadow::Zone::asShadowZone(zone)->needsIncrementalBarrier(); -} - -/** - * Create an object providing access to the garbage collector's internal notion - * of the current state of memory (both GC heap memory and GCthing-controlled - * malloc memory. - */ -extern JS_PUBLIC_API(JSObject*) -NewMemoryInfoObject(JSContext* cx); - -} /* namespace gc */ -} /* namespace js */ - -#endif /* js_HeapAPI_h */ diff --git a/android/armeabi/include/spidermonkey/js/Id.h b/android/armeabi/include/spidermonkey/js/Id.h deleted file mode 100644 index d474e784..00000000 --- a/android/armeabi/include/spidermonkey/js/Id.h +++ /dev/null @@ -1,207 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_Id_h -#define js_Id_h - -// A jsid is an identifier for a property or method of an object which is -// either a 31-bit unsigned integer, interned string or symbol. -// -// Also, there is an additional jsid value, JSID_VOID, which does not occur in -// JS scripts but may be used to indicate the absence of a valid jsid. A void -// jsid is not a valid id and only arises as an exceptional API return value, -// such as in JS_NextProperty. Embeddings must not pass JSID_VOID into JSAPI -// entry points expecting a jsid and do not need to handle JSID_VOID in hooks -// receiving a jsid except when explicitly noted in the API contract. -// -// A jsid is not implicitly convertible to or from a Value; JS_ValueToId or -// JS_IdToValue must be used instead. - -#include "jstypes.h" - -#include "js/HeapAPI.h" -#include "js/RootingAPI.h" -#include "js/TypeDecls.h" -#include "js/Utility.h" - -struct jsid -{ - size_t asBits; - bool operator==(const jsid& rhs) const { return asBits == rhs.asBits; } - bool operator!=(const jsid& rhs) const { return asBits != rhs.asBits; } -} JS_HAZ_GC_POINTER; -#define JSID_BITS(id) (id.asBits) - -#define JSID_TYPE_STRING 0x0 -#define JSID_TYPE_INT 0x1 -#define JSID_TYPE_VOID 0x2 -#define JSID_TYPE_SYMBOL 0x4 -#define JSID_TYPE_MASK 0x7 - -// Avoid using canonical 'id' for jsid parameters since this is a magic word in -// Objective-C++ which, apparently, wants to be able to #include jsapi.h. -#define id iden - -static MOZ_ALWAYS_INLINE bool -JSID_IS_STRING(jsid id) -{ - return (JSID_BITS(id) & JSID_TYPE_MASK) == 0; -} - -static MOZ_ALWAYS_INLINE JSString* -JSID_TO_STRING(jsid id) -{ - MOZ_ASSERT(JSID_IS_STRING(id)); - return (JSString*)JSID_BITS(id); -} - -/** - * Only JSStrings that have been interned via the JSAPI can be turned into - * jsids by API clients. - * - * N.B. if a jsid is backed by a string which has not been interned, that - * string must be appropriately rooted to avoid being collected by the GC. - */ -JS_PUBLIC_API(jsid) -INTERNED_STRING_TO_JSID(JSContext* cx, JSString* str); - -static MOZ_ALWAYS_INLINE bool -JSID_IS_INT(jsid id) -{ - return !!(JSID_BITS(id) & JSID_TYPE_INT); -} - -static MOZ_ALWAYS_INLINE int32_t -JSID_TO_INT(jsid id) -{ - MOZ_ASSERT(JSID_IS_INT(id)); - return ((uint32_t)JSID_BITS(id)) >> 1; -} - -#define JSID_INT_MIN 0 -#define JSID_INT_MAX INT32_MAX - -static MOZ_ALWAYS_INLINE bool -INT_FITS_IN_JSID(int32_t i) -{ - return i >= 0; -} - -static MOZ_ALWAYS_INLINE jsid -INT_TO_JSID(int32_t i) -{ - jsid id; - MOZ_ASSERT(INT_FITS_IN_JSID(i)); - JSID_BITS(id) = ((i << 1) | JSID_TYPE_INT); - return id; -} - -static MOZ_ALWAYS_INLINE bool -JSID_IS_SYMBOL(jsid id) -{ - return (JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_SYMBOL && - JSID_BITS(id) != JSID_TYPE_SYMBOL; -} - -static MOZ_ALWAYS_INLINE JS::Symbol* -JSID_TO_SYMBOL(jsid id) -{ - MOZ_ASSERT(JSID_IS_SYMBOL(id)); - return (JS::Symbol*)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK); -} - -static MOZ_ALWAYS_INLINE jsid -SYMBOL_TO_JSID(JS::Symbol* sym) -{ - jsid id; - MOZ_ASSERT(sym != nullptr); - MOZ_ASSERT((size_t(sym) & JSID_TYPE_MASK) == 0); - MOZ_ASSERT(!js::gc::IsInsideNursery(reinterpret_cast<js::gc::Cell*>(sym))); - JSID_BITS(id) = (size_t(sym) | JSID_TYPE_SYMBOL); - return id; -} - -static MOZ_ALWAYS_INLINE bool -JSID_IS_GCTHING(jsid id) -{ - return JSID_IS_STRING(id) || JSID_IS_SYMBOL(id); -} - -static MOZ_ALWAYS_INLINE JS::GCCellPtr -JSID_TO_GCTHING(jsid id) -{ - void* thing = (void*)(JSID_BITS(id) & ~(size_t)JSID_TYPE_MASK); - if (JSID_IS_STRING(id)) - return JS::GCCellPtr(thing, JS::TraceKind::String); - MOZ_ASSERT(JSID_IS_SYMBOL(id)); - return JS::GCCellPtr(thing, JS::TraceKind::Symbol); -} - -static MOZ_ALWAYS_INLINE bool -JSID_IS_VOID(const jsid id) -{ - MOZ_ASSERT_IF(((size_t)JSID_BITS(id) & JSID_TYPE_MASK) == JSID_TYPE_VOID, - JSID_BITS(id) == JSID_TYPE_VOID); - return (size_t)JSID_BITS(id) == JSID_TYPE_VOID; -} - -static MOZ_ALWAYS_INLINE bool -JSID_IS_EMPTY(const jsid id) -{ - return (size_t)JSID_BITS(id) == JSID_TYPE_SYMBOL; -} - -extern JS_PUBLIC_DATA(const jsid) JSID_VOID; -extern JS_PUBLIC_DATA(const jsid) JSID_EMPTY; - -extern JS_PUBLIC_DATA(const JS::HandleId) JSID_VOIDHANDLE; -extern JS_PUBLIC_DATA(const JS::HandleId) JSID_EMPTYHANDLE; - -namespace JS { - -template <> -struct GCPolicy<jsid> -{ - static jsid initial() { return JSID_VOID; } - static void trace(JSTracer* trc, jsid* idp, const char* name) { - js::UnsafeTraceManuallyBarrieredEdge(trc, idp, name); - } -}; - -} // namespace JS - -namespace js { - -template <> -struct BarrierMethods<jsid> -{ - static void postBarrier(jsid* idp, jsid prev, jsid next) {} - static void exposeToJS(jsid id) { - if (JSID_IS_GCTHING(id)) - js::gc::ExposeGCThingToActiveJS(JSID_TO_GCTHING(id)); - } -}; - -// If the jsid is a GC pointer type, convert to that type and call |f| with -// the pointer. If the jsid is not a GC type, calls F::defaultValue. -template <typename F, typename... Args> -auto -DispatchTyped(F f, const jsid& id, Args&&... args) - -> decltype(f(static_cast<JSString*>(nullptr), mozilla::Forward<Args>(args)...)) -{ - if (JSID_IS_STRING(id)) - return f(JSID_TO_STRING(id), mozilla::Forward<Args>(args)...); - if (JSID_IS_SYMBOL(id)) - return f(JSID_TO_SYMBOL(id), mozilla::Forward<Args>(args)...); - MOZ_ASSERT(!JSID_IS_GCTHING(id)); - return F::defaultValue(id); -} - -#undef id - -} // namespace js - -#endif /* js_Id_h */ diff --git a/android/armeabi/include/spidermonkey/js/Initialization.h b/android/armeabi/include/spidermonkey/js/Initialization.h deleted file mode 100644 index 8a1cf910..00000000 --- a/android/armeabi/include/spidermonkey/js/Initialization.h +++ /dev/null @@ -1,125 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* SpiderMonkey initialization and shutdown APIs. */ - -#ifndef js_Initialization_h -#define js_Initialization_h - -#include "jstypes.h" - -namespace JS { -namespace detail { - -enum class InitState { Uninitialized = 0, Running, ShutDown }; - -/** - * SpiderMonkey's initialization status is tracked here, and it controls things - * that should happen only once across all runtimes. It's an API requirement - * that JS_Init (and JS_ShutDown, if called) be called in a thread-aware - * manner, so this (internal -- embedders, don't use!) variable doesn't need to - * be atomic. - */ -extern JS_PUBLIC_DATA(InitState) -libraryInitState; - -extern JS_PUBLIC_API(const char*) -InitWithFailureDiagnostic(bool isDebugBuild); - -} // namespace detail -} // namespace JS - -// These are equivalent to ICU's |UMemAllocFn|, |UMemReallocFn|, and -// |UMemFreeFn| types. The first argument (called |context| in the ICU docs) -// will always be nullptr and should be ignored. -typedef void* (*JS_ICUAllocFn)(const void*, size_t size); -typedef void* (*JS_ICUReallocFn)(const void*, void* p, size_t size); -typedef void (*JS_ICUFreeFn)(const void*, void* p); - -/** - * This function can be used to track memory used by ICU. If it is called, it - * *must* be called before JS_Init. Don't use it unless you know what you're - * doing! - */ -extern JS_PUBLIC_API(bool) -JS_SetICUMemoryFunctions(JS_ICUAllocFn allocFn, - JS_ICUReallocFn reallocFn, - JS_ICUFreeFn freeFn); - -/** - * Initialize SpiderMonkey, returning true only if initialization succeeded. - * Once this method has succeeded, it is safe to call JS_NewRuntime and other - * JSAPI methods. - * - * This method must be called before any other JSAPI method is used on any - * thread. Once it has been used, it is safe to call any JSAPI method, and it - * remains safe to do so until JS_ShutDown is correctly called. - * - * It is currently not possible to initialize SpiderMonkey multiple times (that - * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so - * again). This restriction may eventually be lifted. - */ -inline bool -JS_Init(void) -{ -#ifdef DEBUG - return !JS::detail::InitWithFailureDiagnostic(true); -#else - return !JS::detail::InitWithFailureDiagnostic(false); -#endif -} - -/** - * A variant of JS_Init. On success it returns nullptr. On failure it returns a - * pointer to a string literal that describes how initialization failed, which - * can be useful for debugging purposes. - */ -inline const char* -JS_InitWithFailureDiagnostic(void) -{ -#ifdef DEBUG - return JS::detail::InitWithFailureDiagnostic(true); -#else - return JS::detail::InitWithFailureDiagnostic(false); -#endif -} - -/* - * Returns true if SpiderMonkey has been initialized successfully, even if it has - * possibly been shut down. - * - * Note that it is the responsibility of the embedder to call JS_Init() and - * JS_ShutDown() at the correct times, and therefore this API should ideally not - * be necessary to use. This is only intended to be used in cases where the - * embedder isn't in full control of deciding whether to initialize SpiderMonkey - * or hand off the task to another consumer. - */ -inline bool -JS_IsInitialized(void) -{ - return JS::detail::libraryInitState != JS::detail::InitState::Uninitialized; -} - -/** - * Destroy free-standing resources allocated by SpiderMonkey, not associated - * with any runtime, context, or other structure. - * - * This method should be called after all other JSAPI data has been properly - * cleaned up: every new runtime must have been destroyed, every new context - * must have been destroyed, and so on. Calling this method before all other - * resources have been destroyed has undefined behavior. - * - * Failure to call this method, at present, has no adverse effects other than - * leaking memory. This may not always be the case; it's recommended that all - * embedders call this method when all other JSAPI operations have completed. - * - * It is currently not possible to initialize SpiderMonkey multiple times (that - * is, calling JS_Init/JSAPI methods/JS_ShutDown in that order, then doing so - * again). This restriction may eventually be lifted. - */ -extern JS_PUBLIC_API(void) -JS_ShutDown(void); - -#endif /* js_Initialization_h */ diff --git a/android/armeabi/include/spidermonkey/js/LegacyIntTypes.h b/android/armeabi/include/spidermonkey/js/LegacyIntTypes.h deleted file mode 100644 index 2c8498c8..00000000 --- a/android/armeabi/include/spidermonkey/js/LegacyIntTypes.h +++ /dev/null @@ -1,59 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * This section typedefs the old 'native' types to the new <stdint.h> types. - * These redefinitions are provided solely to allow JSAPI users to more easily - * transition to <stdint.h> types. They are not to be used in the JSAPI, and - * new JSAPI user code should not use them. This mapping file may eventually - * be removed from SpiderMonkey, so don't depend on it in the long run. - */ - -/* - * BEWARE: Comity with other implementers of these types is not guaranteed. - * Indeed, if you use this header and third-party code defining these - * types, *expect* to encounter either compile errors or link errors, - * depending how these types are used and on the order of inclusion. - * It is safest to use only the <stdint.h> types. - */ -#ifndef js_LegacyIntTypes_h -#define js_LegacyIntTypes_h - -#include <stdint.h> - -#include "js-config.h" - -typedef uint8_t uint8; -typedef uint16_t uint16; -typedef uint32_t uint32; -typedef uint64_t uint64; - -/* - * On AIX 4.3, sys/inttypes.h (which is included by sys/types.h, a very - * common header file) defines the types int8, int16, int32, and int64. - * So we don't define these four types here to avoid conflicts in case - * the code also includes sys/types.h. - */ -#if defined(AIX) && defined(HAVE_SYS_INTTYPES_H) -#include <sys/inttypes.h> -#else -typedef int8_t int8; -typedef int16_t int16; -typedef int32_t int32; -typedef int64_t int64; -#endif /* AIX && HAVE_SYS_INTTYPES_H */ - -typedef uint8_t JSUint8; -typedef uint16_t JSUint16; -typedef uint32_t JSUint32; -typedef uint64_t JSUint64; - -typedef int8_t JSInt8; -typedef int16_t JSInt16; -typedef int32_t JSInt32; -typedef int64_t JSInt64; - -#endif /* js_LegacyIntTypes_h */ diff --git a/android/armeabi/include/spidermonkey/js/MemoryMetrics.h b/android/armeabi/include/spidermonkey/js/MemoryMetrics.h deleted file mode 100644 index 9b5caa24..00000000 --- a/android/armeabi/include/spidermonkey/js/MemoryMetrics.h +++ /dev/null @@ -1,971 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_MemoryMetrics_h -#define js_MemoryMetrics_h - -// These declarations are highly likely to change in the future. Depend on them -// at your own risk. - -#include "mozilla/MemoryReporting.h" -#include "mozilla/PodOperations.h" -#include "mozilla/TypeTraits.h" - -#include <string.h> - -#include "jsalloc.h" -#include "jspubtd.h" - -#include "js/HashTable.h" -#include "js/TracingAPI.h" -#include "js/Utility.h" -#include "js/Vector.h" - -class nsISupports; // Needed for ObjectPrivateVisitor. - -namespace JS { - -struct TabSizes -{ - enum Kind { - Objects, - Strings, - Private, - Other - }; - - TabSizes() { mozilla::PodZero(this); } - - void add(Kind kind, size_t n) { - switch (kind) { - case Objects: objects += n; break; - case Strings: strings += n; break; - case Private: private_ += n; break; - case Other: other += n; break; - default: MOZ_CRASH("bad TabSizes kind"); - } - } - - size_t objects; - size_t strings; - size_t private_; - size_t other; -}; - -/** These are the measurements used by Servo. */ -struct ServoSizes -{ - enum Kind { - GCHeapUsed, - GCHeapUnused, - GCHeapAdmin, - GCHeapDecommitted, - MallocHeap, - NonHeap, - Ignore - }; - - ServoSizes() { mozilla::PodZero(this); } - - void add(Kind kind, size_t n) { - switch (kind) { - case GCHeapUsed: gcHeapUsed += n; break; - case GCHeapUnused: gcHeapUnused += n; break; - case GCHeapAdmin: gcHeapAdmin += n; break; - case GCHeapDecommitted: gcHeapDecommitted += n; break; - case MallocHeap: mallocHeap += n; break; - case NonHeap: nonHeap += n; break; - case Ignore: /* do nothing */ break; - default: MOZ_CRASH("bad ServoSizes kind"); - } - } - - size_t gcHeapUsed; - size_t gcHeapUnused; - size_t gcHeapAdmin; - size_t gcHeapDecommitted; - size_t mallocHeap; - size_t nonHeap; -}; - -} // namespace JS - -namespace js { - -/** - * In memory reporting, we have concept of "sundries", line items which are too - * small to be worth reporting individually. Under some circumstances, a memory - * reporter gets tossed into the sundries bucket if it's smaller than - * MemoryReportingSundriesThreshold() bytes. - * - * We need to define this value here, rather than in the code which actually - * generates the memory reports, because NotableStringInfo uses this value. - */ -JS_FRIEND_API(size_t) MemoryReportingSundriesThreshold(); - -/** - * This hash policy avoids flattening ropes (which perturbs the site being - * measured and requires a JSContext) at the expense of doing a FULL ROPE COPY - * on every hash and match! Beware. - */ -struct InefficientNonFlatteningStringHashPolicy -{ - typedef JSString* Lookup; - static HashNumber hash(const Lookup& l); - static bool match(const JSString* const& k, const Lookup& l); -}; - -struct CStringHashPolicy -{ - typedef const char* Lookup; - static HashNumber hash(const Lookup& l); - static bool match(const char* const& k, const Lookup& l); -}; - -// This file features many classes with numerous size_t fields, and each such -// class has one or more methods that need to operate on all of these fields. -// Writing these individually is error-prone -- it's easy to add a new field -// without updating all the required methods. So we define a single macro list -// in each class to name the fields (and notable characteristics of them), and -// then use the following macros to transform those lists into the required -// methods. -// -// - The |tabKind| value is used when measuring TabSizes. -// -// - The |servoKind| value is used when measuring ServoSizes and also for -// the various sizeOfLiveGCThings() methods. -// -// In some classes, one or more of the macro arguments aren't used. We use '_' -// for those. -// -#define DECL_SIZE(tabKind, servoKind, mSize) size_t mSize; -#define ZERO_SIZE(tabKind, servoKind, mSize) mSize(0), -#define COPY_OTHER_SIZE(tabKind, servoKind, mSize) mSize(other.mSize), -#define ADD_OTHER_SIZE(tabKind, servoKind, mSize) mSize += other.mSize; -#define SUB_OTHER_SIZE(tabKind, servoKind, mSize) \ - MOZ_ASSERT(mSize >= other.mSize); \ - mSize -= other.mSize; -#define ADD_SIZE_TO_N(tabKind, servoKind, mSize) n += mSize; -#define ADD_SIZE_TO_N_IF_LIVE_GC_THING(tabKind, servoKind, mSize) \ - /* Avoid self-comparison warnings by comparing enums indirectly. */ \ - n += (mozilla::IsSame<int[ServoSizes::servoKind], int[ServoSizes::GCHeapUsed]>::value) \ - ? mSize \ - : 0; -#define ADD_TO_TAB_SIZES(tabKind, servoKind, mSize) sizes->add(JS::TabSizes::tabKind, mSize); -#define ADD_TO_SERVO_SIZES(tabKind, servoKind, mSize) sizes->add(JS::ServoSizes::servoKind, mSize); - -} // namespace js - -namespace JS { - -struct ClassInfo -{ -#define FOR_EACH_SIZE(macro) \ - macro(Objects, GCHeapUsed, objectsGCHeap) \ - macro(Objects, MallocHeap, objectsMallocHeapSlots) \ - macro(Objects, MallocHeap, objectsMallocHeapElementsNormal) \ - macro(Objects, MallocHeap, objectsMallocHeapElementsAsmJS) \ - macro(Objects, MallocHeap, objectsMallocHeapMisc) \ - macro(Objects, NonHeap, objectsNonHeapElementsNormal) \ - macro(Objects, NonHeap, objectsNonHeapElementsShared) \ - macro(Objects, NonHeap, objectsNonHeapElementsWasm) \ - macro(Objects, NonHeap, objectsNonHeapCodeWasm) - - ClassInfo() - : FOR_EACH_SIZE(ZERO_SIZE) - wasmGuardPages(0) - {} - - void add(const ClassInfo& other) { - FOR_EACH_SIZE(ADD_OTHER_SIZE) - } - - void subtract(const ClassInfo& other) { - FOR_EACH_SIZE(SUB_OTHER_SIZE) - } - - size_t sizeOfAllThings() const { - size_t n = 0; - FOR_EACH_SIZE(ADD_SIZE_TO_N) - return n; - } - - bool isNotable() const { - static const size_t NotabilityThreshold = 16 * 1024; - return sizeOfAllThings() >= NotabilityThreshold; - } - - size_t sizeOfLiveGCThings() const { - size_t n = 0; - FOR_EACH_SIZE(ADD_SIZE_TO_N_IF_LIVE_GC_THING) - return n; - } - - void addToTabSizes(TabSizes* sizes) const { - FOR_EACH_SIZE(ADD_TO_TAB_SIZES) - } - - void addToServoSizes(ServoSizes *sizes) const { - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES) - } - - FOR_EACH_SIZE(DECL_SIZE) - size_t wasmGuardPages; - -#undef FOR_EACH_SIZE -}; - -struct ShapeInfo -{ -#define FOR_EACH_SIZE(macro) \ - macro(Other, GCHeapUsed, shapesGCHeapTree) \ - macro(Other, GCHeapUsed, shapesGCHeapDict) \ - macro(Other, GCHeapUsed, shapesGCHeapBase) \ - macro(Other, MallocHeap, shapesMallocHeapTreeTables) \ - macro(Other, MallocHeap, shapesMallocHeapDictTables) \ - macro(Other, MallocHeap, shapesMallocHeapTreeKids) - - ShapeInfo() - : FOR_EACH_SIZE(ZERO_SIZE) - dummy() - {} - - void add(const ShapeInfo& other) { - FOR_EACH_SIZE(ADD_OTHER_SIZE) - } - - void subtract(const ShapeInfo& other) { - FOR_EACH_SIZE(SUB_OTHER_SIZE) - } - - size_t sizeOfAllThings() const { - size_t n = 0; - FOR_EACH_SIZE(ADD_SIZE_TO_N) - return n; - } - - size_t sizeOfLiveGCThings() const { - size_t n = 0; - FOR_EACH_SIZE(ADD_SIZE_TO_N_IF_LIVE_GC_THING) - return n; - } - - void addToTabSizes(TabSizes* sizes) const { - FOR_EACH_SIZE(ADD_TO_TAB_SIZES) - } - - void addToServoSizes(ServoSizes *sizes) const { - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES) - } - - FOR_EACH_SIZE(DECL_SIZE) - int dummy; // present just to absorb the trailing comma from FOR_EACH_SIZE(ZERO_SIZE) - -#undef FOR_EACH_SIZE -}; - -/** - * Holds data about a notable class (one whose combined object and shape - * instances use more than a certain amount of memory) so we can report it - * individually. - * - * The only difference between this class and ClassInfo is that this class - * holds a copy of the filename. - */ -struct NotableClassInfo : public ClassInfo -{ - NotableClassInfo(); - NotableClassInfo(const char* className, const ClassInfo& info); - NotableClassInfo(NotableClassInfo&& info); - NotableClassInfo& operator=(NotableClassInfo&& info); - - ~NotableClassInfo() { - js_free(className_); - } - - char* className_; - - private: - NotableClassInfo(const NotableClassInfo& info) = delete; -}; - -/** Data for tracking JIT-code memory usage. */ -struct CodeSizes -{ -#define FOR_EACH_SIZE(macro) \ - macro(_, NonHeap, ion) \ - macro(_, NonHeap, baseline) \ - macro(_, NonHeap, regexp) \ - macro(_, NonHeap, other) \ - macro(_, NonHeap, unused) - - CodeSizes() - : FOR_EACH_SIZE(ZERO_SIZE) - dummy() - {} - - void addToServoSizes(ServoSizes *sizes) const { - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES) - } - - FOR_EACH_SIZE(DECL_SIZE) - int dummy; // present just to absorb the trailing comma from FOR_EACH_SIZE(ZERO_SIZE) - -#undef FOR_EACH_SIZE -}; - -/** Data for tracking GC memory usage. */ -struct GCSizes -{ - // |nurseryDecommitted| is marked as NonHeap rather than GCHeapDecommitted - // because we don't consider the nursery to be part of the GC heap. -#define FOR_EACH_SIZE(macro) \ - macro(_, MallocHeap, marker) \ - macro(_, NonHeap, nurseryCommitted) \ - macro(_, MallocHeap, nurseryMallocedBuffers) \ - macro(_, MallocHeap, storeBufferVals) \ - macro(_, MallocHeap, storeBufferCells) \ - macro(_, MallocHeap, storeBufferSlots) \ - macro(_, MallocHeap, storeBufferWholeCells) \ - macro(_, MallocHeap, storeBufferGenerics) - - GCSizes() - : FOR_EACH_SIZE(ZERO_SIZE) - dummy() - {} - - void addToServoSizes(ServoSizes *sizes) const { - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES) - } - - FOR_EACH_SIZE(DECL_SIZE) - int dummy; // present just to absorb the trailing comma from FOR_EACH_SIZE(ZERO_SIZE) - -#undef FOR_EACH_SIZE -}; - -/** - * This class holds information about the memory taken up by identical copies of - * a particular string. Multiple JSStrings may have their sizes aggregated - * together into one StringInfo object. Note that two strings with identical - * chars will not be aggregated together if one is a short string and the other - * is not. - */ -struct StringInfo -{ -#define FOR_EACH_SIZE(macro) \ - macro(Strings, GCHeapUsed, gcHeapLatin1) \ - macro(Strings, GCHeapUsed, gcHeapTwoByte) \ - macro(Strings, MallocHeap, mallocHeapLatin1) \ - macro(Strings, MallocHeap, mallocHeapTwoByte) - - StringInfo() - : FOR_EACH_SIZE(ZERO_SIZE) - numCopies(0) - {} - - void add(const StringInfo& other) { - FOR_EACH_SIZE(ADD_OTHER_SIZE); - numCopies++; - } - - void subtract(const StringInfo& other) { - FOR_EACH_SIZE(SUB_OTHER_SIZE); - numCopies--; - } - - bool isNotable() const { - static const size_t NotabilityThreshold = 16 * 1024; - size_t n = 0; - FOR_EACH_SIZE(ADD_SIZE_TO_N) - return n >= NotabilityThreshold; - } - - size_t sizeOfLiveGCThings() const { - size_t n = 0; - FOR_EACH_SIZE(ADD_SIZE_TO_N_IF_LIVE_GC_THING) - return n; - } - - void addToTabSizes(TabSizes* sizes) const { - FOR_EACH_SIZE(ADD_TO_TAB_SIZES) - } - - void addToServoSizes(ServoSizes *sizes) const { - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES) - } - - FOR_EACH_SIZE(DECL_SIZE) - uint32_t numCopies; // How many copies of the string have we seen? - -#undef FOR_EACH_SIZE -}; - -/** - * Holds data about a notable string (one which, counting all duplicates, uses - * more than a certain amount of memory) so we can report it individually. - * - * The only difference between this class and StringInfo is that - * NotableStringInfo holds a copy of some or all of the string's chars. - */ -struct NotableStringInfo : public StringInfo -{ - static const size_t MAX_SAVED_CHARS = 1024; - - NotableStringInfo(); - NotableStringInfo(JSString* str, const StringInfo& info); - NotableStringInfo(NotableStringInfo&& info); - NotableStringInfo& operator=(NotableStringInfo&& info); - - ~NotableStringInfo() { - js_free(buffer); - } - - char* buffer; - size_t length; - - private: - NotableStringInfo(const NotableStringInfo& info) = delete; -}; - -/** - * This class holds information about the memory taken up by script sources - * from a particular file. - */ -struct ScriptSourceInfo -{ -#define FOR_EACH_SIZE(macro) \ - macro(_, MallocHeap, misc) - - ScriptSourceInfo() - : FOR_EACH_SIZE(ZERO_SIZE) - numScripts(0) - {} - - void add(const ScriptSourceInfo& other) { - FOR_EACH_SIZE(ADD_OTHER_SIZE) - numScripts++; - } - - void subtract(const ScriptSourceInfo& other) { - FOR_EACH_SIZE(SUB_OTHER_SIZE) - numScripts--; - } - - void addToServoSizes(ServoSizes *sizes) const { - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES) - } - - bool isNotable() const { - static const size_t NotabilityThreshold = 16 * 1024; - size_t n = 0; - FOR_EACH_SIZE(ADD_SIZE_TO_N) - return n >= NotabilityThreshold; - } - - FOR_EACH_SIZE(DECL_SIZE) - uint32_t numScripts; // How many ScriptSources come from this file? (It - // can be more than one in XML files that have - // multiple scripts in CDATA sections.) -#undef FOR_EACH_SIZE -}; - -/** - * Holds data about a notable script source file (one whose combined - * script sources use more than a certain amount of memory) so we can report it - * individually. - * - * The only difference between this class and ScriptSourceInfo is that this - * class holds a copy of the filename. - */ -struct NotableScriptSourceInfo : public ScriptSourceInfo -{ - NotableScriptSourceInfo(); - NotableScriptSourceInfo(const char* filename, const ScriptSourceInfo& info); - NotableScriptSourceInfo(NotableScriptSourceInfo&& info); - NotableScriptSourceInfo& operator=(NotableScriptSourceInfo&& info); - - ~NotableScriptSourceInfo() { - js_free(filename_); - } - - char* filename_; - - private: - NotableScriptSourceInfo(const NotableScriptSourceInfo& info) = delete; -}; - -/** - * These measurements relate directly to the JSRuntime, and not to zones and - * compartments within it. - */ -struct RuntimeSizes -{ -#define FOR_EACH_SIZE(macro) \ - macro(_, MallocHeap, object) \ - macro(_, MallocHeap, atomsTable) \ - macro(_, MallocHeap, contexts) \ - macro(_, MallocHeap, temporary) \ - macro(_, MallocHeap, interpreterStack) \ - macro(_, MallocHeap, mathCache) \ - macro(_, MallocHeap, sharedImmutableStringsCache) \ - macro(_, MallocHeap, sharedIntlData) \ - macro(_, MallocHeap, uncompressedSourceCache) \ - macro(_, MallocHeap, scriptData) - - RuntimeSizes() - : FOR_EACH_SIZE(ZERO_SIZE) - scriptSourceInfo(), - code(), - gc(), - notableScriptSources() - { - allScriptSources = js_new<ScriptSourcesHashMap>(); - if (!allScriptSources || !allScriptSources->init()) - MOZ_CRASH("oom"); - } - - ~RuntimeSizes() { - // |allScriptSources| is usually deleted and set to nullptr before this - // destructor runs. But there are failure cases due to OOMs that may - // prevent that, so it doesn't hurt to try again here. - js_delete(allScriptSources); - } - - void addToServoSizes(ServoSizes *sizes) const { - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES) - scriptSourceInfo.addToServoSizes(sizes); - code.addToServoSizes(sizes); - gc.addToServoSizes(sizes); - } - - // The script source measurements in |scriptSourceInfo| are initially for - // all script sources. At the end, if the measurement granularity is - // FineGrained, we subtract the measurements of the notable script sources - // and move them into |notableScriptSources|. - FOR_EACH_SIZE(DECL_SIZE) - ScriptSourceInfo scriptSourceInfo; - CodeSizes code; - GCSizes gc; - - typedef js::HashMap<const char*, ScriptSourceInfo, - js::CStringHashPolicy, - js::SystemAllocPolicy> ScriptSourcesHashMap; - - // |allScriptSources| is only used transiently. During the reporting phase - // it is filled with info about every script source in the runtime. It's - // then used to fill in |notableScriptSources| (which actually gets - // reported), and immediately discarded afterwards. - ScriptSourcesHashMap* allScriptSources; - js::Vector<NotableScriptSourceInfo, 0, js::SystemAllocPolicy> notableScriptSources; - -#undef FOR_EACH_SIZE -}; - -struct UnusedGCThingSizes -{ -#define FOR_EACH_SIZE(macro) \ - macro(Other, GCHeapUnused, object) \ - macro(Other, GCHeapUnused, script) \ - macro(Other, GCHeapUnused, lazyScript) \ - macro(Other, GCHeapUnused, shape) \ - macro(Other, GCHeapUnused, baseShape) \ - macro(Other, GCHeapUnused, objectGroup) \ - macro(Other, GCHeapUnused, string) \ - macro(Other, GCHeapUnused, symbol) \ - macro(Other, GCHeapUnused, jitcode) \ - macro(Other, GCHeapUnused, scope) - - UnusedGCThingSizes() - : FOR_EACH_SIZE(ZERO_SIZE) - dummy() - {} - - UnusedGCThingSizes(UnusedGCThingSizes&& other) - : FOR_EACH_SIZE(COPY_OTHER_SIZE) - dummy() - {} - - void addToKind(JS::TraceKind kind, intptr_t n) { - switch (kind) { - case JS::TraceKind::Object: object += n; break; - case JS::TraceKind::String: string += n; break; - case JS::TraceKind::Symbol: symbol += n; break; - case JS::TraceKind::Script: script += n; break; - case JS::TraceKind::Shape: shape += n; break; - case JS::TraceKind::BaseShape: baseShape += n; break; - case JS::TraceKind::JitCode: jitcode += n; break; - case JS::TraceKind::LazyScript: lazyScript += n; break; - case JS::TraceKind::ObjectGroup: objectGroup += n; break; - case JS::TraceKind::Scope: scope += n; break; - default: - MOZ_CRASH("Bad trace kind for UnusedGCThingSizes"); - } - } - - void addSizes(const UnusedGCThingSizes& other) { - FOR_EACH_SIZE(ADD_OTHER_SIZE) - } - - size_t totalSize() const { - size_t n = 0; - FOR_EACH_SIZE(ADD_SIZE_TO_N) - return n; - } - - void addToTabSizes(JS::TabSizes *sizes) const { - FOR_EACH_SIZE(ADD_TO_TAB_SIZES) - } - - void addToServoSizes(JS::ServoSizes *sizes) const { - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES) - } - - FOR_EACH_SIZE(DECL_SIZE) - int dummy; // present just to absorb the trailing comma from FOR_EACH_SIZE(ZERO_SIZE) - -#undef FOR_EACH_SIZE -}; - -struct ZoneStats -{ -#define FOR_EACH_SIZE(macro) \ - macro(Other, GCHeapUsed, symbolsGCHeap) \ - macro(Other, GCHeapAdmin, gcHeapArenaAdmin) \ - macro(Other, GCHeapUsed, lazyScriptsGCHeap) \ - macro(Other, MallocHeap, lazyScriptsMallocHeap) \ - macro(Other, GCHeapUsed, jitCodesGCHeap) \ - macro(Other, GCHeapUsed, objectGroupsGCHeap) \ - macro(Other, MallocHeap, objectGroupsMallocHeap) \ - macro(Other, GCHeapUsed, scopesGCHeap) \ - macro(Other, MallocHeap, scopesMallocHeap) \ - macro(Other, MallocHeap, typePool) \ - macro(Other, MallocHeap, baselineStubsOptimized) \ - macro(Other, MallocHeap, uniqueIdMap) \ - macro(Other, MallocHeap, shapeTables) - - ZoneStats() - : FOR_EACH_SIZE(ZERO_SIZE) - unusedGCThings(), - stringInfo(), - shapeInfo(), - extra(), - allStrings(nullptr), - notableStrings(), - isTotals(true) - {} - - ZoneStats(ZoneStats&& other) - : FOR_EACH_SIZE(COPY_OTHER_SIZE) - unusedGCThings(mozilla::Move(other.unusedGCThings)), - stringInfo(mozilla::Move(other.stringInfo)), - shapeInfo(mozilla::Move(other.shapeInfo)), - extra(other.extra), - allStrings(other.allStrings), - notableStrings(mozilla::Move(other.notableStrings)), - isTotals(other.isTotals) - { - other.allStrings = nullptr; - MOZ_ASSERT(!other.isTotals); - } - - ~ZoneStats() { - // |allStrings| is usually deleted and set to nullptr before this - // destructor runs. But there are failure cases due to OOMs that may - // prevent that, so it doesn't hurt to try again here. - js_delete(allStrings); - } - - bool initStrings(JSRuntime* rt); - - void addSizes(const ZoneStats& other) { - MOZ_ASSERT(isTotals); - FOR_EACH_SIZE(ADD_OTHER_SIZE) - unusedGCThings.addSizes(other.unusedGCThings); - stringInfo.add(other.stringInfo); - shapeInfo.add(other.shapeInfo); - } - - size_t sizeOfLiveGCThings() const { - MOZ_ASSERT(isTotals); - size_t n = 0; - FOR_EACH_SIZE(ADD_SIZE_TO_N_IF_LIVE_GC_THING) - n += stringInfo.sizeOfLiveGCThings(); - n += shapeInfo.sizeOfLiveGCThings(); - return n; - } - - void addToTabSizes(JS::TabSizes* sizes) const { - MOZ_ASSERT(isTotals); - FOR_EACH_SIZE(ADD_TO_TAB_SIZES) - unusedGCThings.addToTabSizes(sizes); - stringInfo.addToTabSizes(sizes); - shapeInfo.addToTabSizes(sizes); - } - - void addToServoSizes(JS::ServoSizes *sizes) const { - MOZ_ASSERT(isTotals); - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES) - unusedGCThings.addToServoSizes(sizes); - stringInfo.addToServoSizes(sizes); - shapeInfo.addToServoSizes(sizes); - } - - // These string measurements are initially for all strings. At the end, - // if the measurement granularity is FineGrained, we subtract the - // measurements of the notable script sources and move them into - // |notableStrings|. - FOR_EACH_SIZE(DECL_SIZE) - UnusedGCThingSizes unusedGCThings; - StringInfo stringInfo; - ShapeInfo shapeInfo; - void* extra; // This field can be used by embedders. - - typedef js::HashMap<JSString*, StringInfo, - js::InefficientNonFlatteningStringHashPolicy, - js::SystemAllocPolicy> StringsHashMap; - - // |allStrings| is only used transiently. During the zone traversal it is - // filled with info about every string in the zone. It's then used to fill - // in |notableStrings| (which actually gets reported), and immediately - // discarded afterwards. - StringsHashMap* allStrings; - js::Vector<NotableStringInfo, 0, js::SystemAllocPolicy> notableStrings; - bool isTotals; - -#undef FOR_EACH_SIZE -}; - -struct CompartmentStats -{ - // We assume that |objectsPrivate| is on the malloc heap, but it's not - // actually guaranteed. But for Servo, at least, it's a moot point because - // it doesn't provide an ObjectPrivateVisitor so the value will always be - // zero. -#define FOR_EACH_SIZE(macro) \ - macro(Private, MallocHeap, objectsPrivate) \ - macro(Other, GCHeapUsed, scriptsGCHeap) \ - macro(Other, MallocHeap, scriptsMallocHeapData) \ - macro(Other, MallocHeap, baselineData) \ - macro(Other, MallocHeap, baselineStubsFallback) \ - macro(Other, MallocHeap, ionData) \ - macro(Other, MallocHeap, typeInferenceTypeScripts) \ - macro(Other, MallocHeap, typeInferenceAllocationSiteTables) \ - macro(Other, MallocHeap, typeInferenceArrayTypeTables) \ - macro(Other, MallocHeap, typeInferenceObjectTypeTables) \ - macro(Other, MallocHeap, compartmentObject) \ - macro(Other, MallocHeap, compartmentTables) \ - macro(Other, MallocHeap, innerViewsTable) \ - macro(Other, MallocHeap, lazyArrayBuffersTable) \ - macro(Other, MallocHeap, objectMetadataTable) \ - macro(Other, MallocHeap, crossCompartmentWrappersTable) \ - macro(Other, MallocHeap, regexpCompartment) \ - macro(Other, MallocHeap, savedStacksSet) \ - macro(Other, MallocHeap, varNamesSet) \ - macro(Other, MallocHeap, nonSyntacticLexicalScopesTable) \ - macro(Other, MallocHeap, jitCompartment) \ - macro(Other, MallocHeap, privateData) - - CompartmentStats() - : FOR_EACH_SIZE(ZERO_SIZE) - classInfo(), - extra(), - allClasses(nullptr), - notableClasses(), - isTotals(true) - {} - - CompartmentStats(CompartmentStats&& other) - : FOR_EACH_SIZE(COPY_OTHER_SIZE) - classInfo(mozilla::Move(other.classInfo)), - extra(other.extra), - allClasses(other.allClasses), - notableClasses(mozilla::Move(other.notableClasses)), - isTotals(other.isTotals) - { - other.allClasses = nullptr; - MOZ_ASSERT(!other.isTotals); - } - - CompartmentStats(const CompartmentStats&) = delete; // disallow copying - - ~CompartmentStats() { - // |allClasses| is usually deleted and set to nullptr before this - // destructor runs. But there are failure cases due to OOMs that may - // prevent that, so it doesn't hurt to try again here. - js_delete(allClasses); - } - - bool initClasses(JSRuntime* rt); - - void addSizes(const CompartmentStats& other) { - MOZ_ASSERT(isTotals); - FOR_EACH_SIZE(ADD_OTHER_SIZE) - classInfo.add(other.classInfo); - } - - size_t sizeOfLiveGCThings() const { - MOZ_ASSERT(isTotals); - size_t n = 0; - FOR_EACH_SIZE(ADD_SIZE_TO_N_IF_LIVE_GC_THING) - n += classInfo.sizeOfLiveGCThings(); - return n; - } - - void addToTabSizes(TabSizes* sizes) const { - MOZ_ASSERT(isTotals); - FOR_EACH_SIZE(ADD_TO_TAB_SIZES); - classInfo.addToTabSizes(sizes); - } - - void addToServoSizes(ServoSizes *sizes) const { - MOZ_ASSERT(isTotals); - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES); - classInfo.addToServoSizes(sizes); - } - - // The class measurements in |classInfo| are initially for all classes. At - // the end, if the measurement granularity is FineGrained, we subtract the - // measurements of the notable classes and move them into |notableClasses|. - FOR_EACH_SIZE(DECL_SIZE) - ClassInfo classInfo; - void* extra; // This field can be used by embedders. - - typedef js::HashMap<const char*, ClassInfo, - js::CStringHashPolicy, - js::SystemAllocPolicy> ClassesHashMap; - - // These are similar to |allStrings| and |notableStrings| in ZoneStats. - ClassesHashMap* allClasses; - js::Vector<NotableClassInfo, 0, js::SystemAllocPolicy> notableClasses; - bool isTotals; - -#undef FOR_EACH_SIZE -}; - -typedef js::Vector<CompartmentStats, 0, js::SystemAllocPolicy> CompartmentStatsVector; -typedef js::Vector<ZoneStats, 0, js::SystemAllocPolicy> ZoneStatsVector; - -struct RuntimeStats -{ - // |gcHeapChunkTotal| is ignored because it's the sum of all the other - // values. |gcHeapGCThings| is ignored because it's the sum of some of the - // values from the zones and compartments. Both of those values are not - // reported directly, but are just present for sanity-checking other - // values. -#define FOR_EACH_SIZE(macro) \ - macro(_, Ignore, gcHeapChunkTotal) \ - macro(_, GCHeapDecommitted, gcHeapDecommittedArenas) \ - macro(_, GCHeapUnused, gcHeapUnusedChunks) \ - macro(_, GCHeapUnused, gcHeapUnusedArenas) \ - macro(_, GCHeapAdmin, gcHeapChunkAdmin) \ - macro(_, Ignore, gcHeapGCThings) - - explicit RuntimeStats(mozilla::MallocSizeOf mallocSizeOf) - : FOR_EACH_SIZE(ZERO_SIZE) - runtime(), - cTotals(), - zTotals(), - compartmentStatsVector(), - zoneStatsVector(), - currZoneStats(nullptr), - mallocSizeOf_(mallocSizeOf) - {} - - // Here's a useful breakdown of the GC heap. - // - // - rtStats.gcHeapChunkTotal - // - decommitted bytes - // - rtStats.gcHeapDecommittedArenas (decommitted arenas in non-empty chunks) - // - unused bytes - // - rtStats.gcHeapUnusedChunks (empty chunks) - // - rtStats.gcHeapUnusedArenas (empty arenas within non-empty chunks) - // - rtStats.zTotals.unusedGCThings.totalSize() (empty GC thing slots within non-empty arenas) - // - used bytes - // - rtStats.gcHeapChunkAdmin - // - rtStats.zTotals.gcHeapArenaAdmin - // - rtStats.gcHeapGCThings (in-use GC things) - // == rtStats.zTotals.sizeOfLiveGCThings() + rtStats.cTotals.sizeOfLiveGCThings() - // - // It's possible that some arenas in empty chunks may be decommitted, but - // we don't count those under rtStats.gcHeapDecommittedArenas because (a) - // it's rare, and (b) this means that rtStats.gcHeapUnusedChunks is a - // multiple of the chunk size, which is good. - - void addToServoSizes(ServoSizes *sizes) const { - FOR_EACH_SIZE(ADD_TO_SERVO_SIZES) - runtime.addToServoSizes(sizes); - } - - FOR_EACH_SIZE(DECL_SIZE) - - RuntimeSizes runtime; - - CompartmentStats cTotals; // The sum of this runtime's compartments' measurements. - ZoneStats zTotals; // The sum of this runtime's zones' measurements. - - CompartmentStatsVector compartmentStatsVector; - ZoneStatsVector zoneStatsVector; - - ZoneStats* currZoneStats; - - mozilla::MallocSizeOf mallocSizeOf_; - - virtual void initExtraCompartmentStats(JSCompartment* c, CompartmentStats* cstats) = 0; - virtual void initExtraZoneStats(JS::Zone* zone, ZoneStats* zstats) = 0; - -#undef FOR_EACH_SIZE -}; - -class ObjectPrivateVisitor -{ - public: - // Within CollectRuntimeStats, this method is called for each JS object - // that has an nsISupports pointer. - virtual size_t sizeOfIncludingThis(nsISupports* aSupports) = 0; - - // A callback that gets a JSObject's nsISupports pointer, if it has one. - // Note: this function does *not* addref |iface|. - typedef bool(*GetISupportsFun)(JSObject* obj, nsISupports** iface); - GetISupportsFun getISupports_; - - explicit ObjectPrivateVisitor(GetISupportsFun getISupports) - : getISupports_(getISupports) - {} -}; - -extern JS_PUBLIC_API(bool) -CollectRuntimeStats(JSContext* cx, RuntimeStats* rtStats, ObjectPrivateVisitor* opv, bool anonymize); - -extern JS_PUBLIC_API(size_t) -SystemCompartmentCount(JSContext* cx); - -extern JS_PUBLIC_API(size_t) -UserCompartmentCount(JSContext* cx); - -extern JS_PUBLIC_API(size_t) -PeakSizeOfTemporary(const JSContext* cx); - -extern JS_PUBLIC_API(bool) -AddSizeOfTab(JSContext* cx, JS::HandleObject obj, mozilla::MallocSizeOf mallocSizeOf, - ObjectPrivateVisitor* opv, TabSizes* sizes); - -extern JS_PUBLIC_API(bool) -AddServoSizeOf(JSContext* cx, mozilla::MallocSizeOf mallocSizeOf, - ObjectPrivateVisitor *opv, ServoSizes *sizes); - -} // namespace JS - -#undef DECL_SIZE -#undef ZERO_SIZE -#undef COPY_OTHER_SIZE -#undef ADD_OTHER_SIZE -#undef SUB_OTHER_SIZE -#undef ADD_SIZE_TO_N -#undef ADD_SIZE_TO_N_IF_LIVE_GC_THING -#undef ADD_TO_TAB_SIZES - -#endif /* js_MemoryMetrics_h */ diff --git a/android/armeabi/include/spidermonkey/js/Principals.h b/android/armeabi/include/spidermonkey/js/Principals.h deleted file mode 100644 index cf6c813a..00000000 --- a/android/armeabi/include/spidermonkey/js/Principals.h +++ /dev/null @@ -1,132 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* JSPrincipals and related interfaces. */ - -#ifndef js_Principals_h -#define js_Principals_h - -#include "mozilla/Atomics.h" - -#include <stdint.h> - -#include "jspubtd.h" - -#include "js/StructuredClone.h" - -namespace js { - struct PerformanceGroup; -} // namespace js - -struct JSPrincipals { - /* Don't call "destroy"; use reference counting macros below. */ - mozilla::Atomic<int32_t> refcount; - -#ifdef JS_DEBUG - /* A helper to facilitate principals debugging. */ - uint32_t debugToken; -#endif - - JSPrincipals() : refcount(0) {} - - void setDebugToken(uint32_t token) { -# ifdef JS_DEBUG - debugToken = token; -# endif - } - - /* - * Write the principals with the given |writer|. Return false on failure, - * true on success. - */ - virtual bool write(JSContext* cx, JSStructuredCloneWriter* writer) = 0; - - /* - * This is not defined by the JS engine but should be provided by the - * embedding. - */ - JS_PUBLIC_API(void) dump(); -}; - -extern JS_PUBLIC_API(void) -JS_HoldPrincipals(JSPrincipals* principals); - -extern JS_PUBLIC_API(void) -JS_DropPrincipals(JSContext* cx, JSPrincipals* principals); - -// Return whether the first principal subsumes the second. The exact meaning of -// 'subsumes' is left up to the browser. Subsumption is checked inside the JS -// engine when determining, e.g., which stack frames to display in a backtrace. -typedef bool -(* JSSubsumesOp)(JSPrincipals* first, JSPrincipals* second); - -/* - * Used to check if a CSP instance wants to disable eval() and friends. - * See js_CheckCSPPermitsJSAction() in jsobj. - */ -typedef bool -(* JSCSPEvalChecker)(JSContext* cx); - -struct JSSecurityCallbacks { - JSCSPEvalChecker contentSecurityPolicyAllows; - JSSubsumesOp subsumes; -}; - -extern JS_PUBLIC_API(void) -JS_SetSecurityCallbacks(JSContext* cx, const JSSecurityCallbacks* callbacks); - -extern JS_PUBLIC_API(const JSSecurityCallbacks*) -JS_GetSecurityCallbacks(JSContext* cx); - -/* - * Code running with "trusted" principals will be given a deeper stack - * allocation than ordinary scripts. This allows trusted script to run after - * untrusted script has exhausted the stack. This function sets the - * runtime-wide trusted principal. - * - * This principals is not held (via JS_HoldPrincipals/JS_DropPrincipals). - * Instead, the caller must ensure that the given principals stays valid for as - * long as 'cx' may point to it. If the principals would be destroyed before - * 'cx', JS_SetTrustedPrincipals must be called again, passing nullptr for - * 'prin'. - */ -extern JS_PUBLIC_API(void) -JS_SetTrustedPrincipals(JSContext* cx, JSPrincipals* prin); - -typedef void -(* JSDestroyPrincipalsOp)(JSPrincipals* principals); - -/* - * Initialize the callback that is called to destroy JSPrincipals instance - * when its reference counter drops to zero. The initialization can be done - * only once per JS runtime. - */ -extern JS_PUBLIC_API(void) -JS_InitDestroyPrincipalsCallback(JSContext* cx, JSDestroyPrincipalsOp destroyPrincipals); - -/* - * Read a JSPrincipals instance from the given |reader| and initialize the out - * paratemer |outPrincipals| to the JSPrincipals instance read. - * - * Return false on failure, true on success. The |outPrincipals| parameter - * should not be modified if false is returned. - * - * The caller is not responsible for calling JS_HoldPrincipals on the resulting - * JSPrincipals instance, the JSReadPrincipalsOp must increment the refcount of - * the resulting JSPrincipals on behalf of the caller. - */ -using JSReadPrincipalsOp = bool (*)(JSContext* cx, JSStructuredCloneReader* reader, - JSPrincipals** outPrincipals); - -/* - * Initialize the callback that is called to read JSPrincipals instances from a - * buffer. The initialization can be done only once per JS runtime. - */ -extern JS_PUBLIC_API(void) -JS_InitReadPrincipalsCallback(JSContext* cx, JSReadPrincipalsOp read); - - -#endif /* js_Principals_h */ diff --git a/android/armeabi/include/spidermonkey/js/ProfilingFrameIterator.h b/android/armeabi/include/spidermonkey/js/ProfilingFrameIterator.h deleted file mode 100644 index d082213d..00000000 --- a/android/armeabi/include/spidermonkey/js/ProfilingFrameIterator.h +++ /dev/null @@ -1,203 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_ProfilingFrameIterator_h -#define js_ProfilingFrameIterator_h - -#include "mozilla/Alignment.h" -#include "mozilla/Maybe.h" - -#include "jsbytecode.h" -#include "js/GCAPI.h" -#include "js/TypeDecls.h" -#include "js/Utility.h" - -struct JSContext; -struct JSRuntime; -class JSScript; - -namespace js { - class Activation; - namespace jit { - class JitActivation; - class JitProfilingFrameIterator; - class JitcodeGlobalEntry; - } // namespace jit - namespace wasm { - class ProfilingFrameIterator; - } // namespace wasm -} // namespace js - -namespace JS { - -struct ForEachTrackedOptimizationAttemptOp; -struct ForEachTrackedOptimizationTypeInfoOp; - -// This iterator can be used to walk the stack of a thread suspended at an -// arbitrary pc. To provide acurate results, profiling must have been enabled -// (via EnableRuntimeProfilingStack) before executing the callstack being -// unwound. -// -// Note that the caller must not do anything that could cause GC to happen while -// the iterator is alive, since this could invalidate Ion code and cause its -// contents to become out of date. -class JS_PUBLIC_API(ProfilingFrameIterator) -{ - JSRuntime* rt_; - uint32_t sampleBufferGen_; - js::Activation* activation_; - - // When moving past a JitActivation, we need to save the prevJitTop - // from it to use as the exit-frame pointer when the next caller jit - // activation (if any) comes around. - void* savedPrevJitTop_; - - JS::AutoCheckCannotGC nogc_; - - static const unsigned StorageSpace = 8 * sizeof(void*); - mozilla::AlignedStorage<StorageSpace> storage_; - js::wasm::ProfilingFrameIterator& wasmIter() { - MOZ_ASSERT(!done()); - MOZ_ASSERT(isWasm()); - return *reinterpret_cast<js::wasm::ProfilingFrameIterator*>(storage_.addr()); - } - const js::wasm::ProfilingFrameIterator& wasmIter() const { - MOZ_ASSERT(!done()); - MOZ_ASSERT(isWasm()); - return *reinterpret_cast<const js::wasm::ProfilingFrameIterator*>(storage_.addr()); - } - - js::jit::JitProfilingFrameIterator& jitIter() { - MOZ_ASSERT(!done()); - MOZ_ASSERT(isJit()); - return *reinterpret_cast<js::jit::JitProfilingFrameIterator*>(storage_.addr()); - } - - const js::jit::JitProfilingFrameIterator& jitIter() const { - MOZ_ASSERT(!done()); - MOZ_ASSERT(isJit()); - return *reinterpret_cast<const js::jit::JitProfilingFrameIterator*>(storage_.addr()); - } - - void settle(); - - bool hasSampleBufferGen() const { - return sampleBufferGen_ != UINT32_MAX; - } - - public: - struct RegisterState - { - RegisterState() : pc(nullptr), sp(nullptr), lr(nullptr) {} - void* pc; - void* sp; - void* lr; - }; - - ProfilingFrameIterator(JSContext* cx, const RegisterState& state, - uint32_t sampleBufferGen = UINT32_MAX); - ~ProfilingFrameIterator(); - void operator++(); - bool done() const { return !activation_; } - - // Assuming the stack grows down (we do), the return value: - // - always points into the stack - // - is weakly monotonically increasing (may be equal for successive frames) - // - will compare greater than newer native and psuedo-stack frame addresses - // and less than older native and psuedo-stack frame addresses - void* stackAddress() const; - - enum FrameKind - { - Frame_Baseline, - Frame_Ion, - Frame_Wasm - }; - - struct Frame - { - FrameKind kind; - void* stackAddress; - void* returnAddress; - void* activation; - UniqueChars label; - }; - - bool isWasm() const; - bool isJit() const; - - uint32_t extractStack(Frame* frames, uint32_t offset, uint32_t end) const; - - mozilla::Maybe<Frame> getPhysicalFrameWithoutLabel() const; - - private: - mozilla::Maybe<Frame> getPhysicalFrameAndEntry(js::jit::JitcodeGlobalEntry* entry) const; - - void iteratorConstruct(const RegisterState& state); - void iteratorConstruct(); - void iteratorDestroy(); - bool iteratorDone(); -}; - -JS_FRIEND_API(bool) -IsProfilingEnabledForContext(JSContext* cx); - -/** - * After each sample run, this method should be called with the latest sample - * buffer generation, and the lapCount. It will update corresponding fields on - * JSRuntime. - * - * See fields |profilerSampleBufferGen|, |profilerSampleBufferLapCount| on - * JSRuntime for documentation about what these values are used for. - */ -JS_FRIEND_API(void) -UpdateJSContextProfilerSampleBufferGen(JSContext* cx, uint32_t generation, - uint32_t lapCount); - -struct ForEachProfiledFrameOp -{ - // A handle to the underlying JitcodeGlobalEntry, so as to avoid repeated - // lookups on JitcodeGlobalTable. - class MOZ_STACK_CLASS FrameHandle - { - friend JS_PUBLIC_API(void) ForEachProfiledFrame(JSContext* cx, void* addr, - ForEachProfiledFrameOp& op); - - JSRuntime* rt_; - js::jit::JitcodeGlobalEntry& entry_; - void* addr_; - void* canonicalAddr_; - const char* label_; - uint32_t depth_; - mozilla::Maybe<uint8_t> optsIndex_; - - FrameHandle(JSRuntime* rt, js::jit::JitcodeGlobalEntry& entry, void* addr, - const char* label, uint32_t depth); - - void updateHasTrackedOptimizations(); - - public: - const char* label() const { return label_; } - uint32_t depth() const { return depth_; } - bool hasTrackedOptimizations() const { return optsIndex_.isSome(); } - void* canonicalAddress() const { return canonicalAddr_; } - - ProfilingFrameIterator::FrameKind frameKind() const; - void forEachOptimizationAttempt(ForEachTrackedOptimizationAttemptOp& op, - JSScript** scriptOut, jsbytecode** pcOut) const; - void forEachOptimizationTypeInfo(ForEachTrackedOptimizationTypeInfoOp& op) const; - }; - - // Called once per frame. - virtual void operator()(const FrameHandle& frame) = 0; -}; - -JS_PUBLIC_API(void) -ForEachProfiledFrame(JSContext* cx, void* addr, ForEachProfiledFrameOp& op); - -} // namespace JS - -#endif /* js_ProfilingFrameIterator_h */ diff --git a/android/armeabi/include/spidermonkey/js/ProfilingStack.h b/android/armeabi/include/spidermonkey/js/ProfilingStack.h deleted file mode 100644 index 6b6c9701..00000000 --- a/android/armeabi/include/spidermonkey/js/ProfilingStack.h +++ /dev/null @@ -1,208 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_ProfilingStack_h -#define js_ProfilingStack_h - -#include "jsbytecode.h" -#include "jstypes.h" -#include "js/TypeDecls.h" - -#include "js/Utility.h" - -struct JSRuntime; -class JSTracer; - -namespace js { - -// A call stack can be specified to the JS engine such that all JS entry/exits -// to functions push/pop an entry to/from the specified stack. -// -// For more detailed information, see vm/SPSProfiler.h. -// -class ProfileEntry -{ - // All fields are marked volatile to prevent the compiler from re-ordering - // instructions. Namely this sequence: - // - // entry[size] = ...; - // size++; - // - // If the size modification were somehow reordered before the stores, then - // if a sample were taken it would be examining bogus information. - // - // A ProfileEntry represents both a C++ profile entry and a JS one. - - // Descriptive string of this entry. - const char * volatile string; - - // Stack pointer for non-JS entries, the script pointer otherwise. - void * volatile spOrScript; - - // Line number for non-JS entries, the bytecode offset otherwise. - int32_t volatile lineOrPcOffset; - - // General purpose storage describing this frame. - uint32_t volatile flags_; - - public: - // These traits are bit masks. Make sure they're powers of 2. - enum Flags : uint32_t { - // Indicate whether a profile entry represents a CPP frame. If not set, - // a JS frame is assumed by default. You're not allowed to publicly - // change the frame type. Instead, initialize the ProfileEntry as either - // a JS or CPP frame with `initJsFrame` or `initCppFrame` respectively. - IS_CPP_ENTRY = 0x01, - - // Indicate that copying the frame label is not necessary when taking a - // sample of the pseudostack. - FRAME_LABEL_COPY = 0x02, - - // This ProfileEntry is a dummy entry indicating the start of a run - // of JS pseudostack entries. - BEGIN_PSEUDO_JS = 0x04, - - // This flag is used to indicate that an interpreter JS entry has OSR-ed - // into baseline. - OSR = 0x08, - - // Union of all flags. - ALL = IS_CPP_ENTRY|FRAME_LABEL_COPY|BEGIN_PSEUDO_JS|OSR, - - // Mask for removing all flags except the category information. - CATEGORY_MASK = ~ALL - }; - - // Keep these in sync with devtools/client/performance/modules/categories.js - enum class Category : uint32_t { - OTHER = 0x10, - CSS = 0x20, - JS = 0x40, - GC = 0x80, - CC = 0x100, - NETWORK = 0x200, - GRAPHICS = 0x400, - STORAGE = 0x800, - EVENTS = 0x1000, - - FIRST = OTHER, - LAST = EVENTS - }; - - static_assert((static_cast<int>(Category::FIRST) & Flags::ALL) == 0, - "The category bitflags should not intersect with the other flags!"); - - // All of these methods are marked with the 'volatile' keyword because SPS's - // representation of the stack is stored such that all ProfileEntry - // instances are volatile. These methods would not be available unless they - // were marked as volatile as well. - - bool isCpp() const volatile { return hasFlag(IS_CPP_ENTRY); } - bool isJs() const volatile { return !isCpp(); } - - bool isCopyLabel() const volatile { return hasFlag(FRAME_LABEL_COPY); } - - void setLabel(const char* aString) volatile { string = aString; } - const char* label() const volatile { return string; } - - void initJsFrame(JSScript* aScript, jsbytecode* aPc) volatile { - flags_ = 0; - spOrScript = aScript; - setPC(aPc); - } - void initCppFrame(void* aSp, uint32_t aLine) volatile { - flags_ = IS_CPP_ENTRY; - spOrScript = aSp; - lineOrPcOffset = static_cast<int32_t>(aLine); - } - - void setFlag(uint32_t flag) volatile { - MOZ_ASSERT(flag != IS_CPP_ENTRY); - flags_ |= flag; - } - void unsetFlag(uint32_t flag) volatile { - MOZ_ASSERT(flag != IS_CPP_ENTRY); - flags_ &= ~flag; - } - bool hasFlag(uint32_t flag) const volatile { - return bool(flags_ & flag); - } - - uint32_t flags() const volatile { - return flags_; - } - - uint32_t category() const volatile { - return flags_ & CATEGORY_MASK; - } - void setCategory(Category c) volatile { - MOZ_ASSERT(c >= Category::FIRST); - MOZ_ASSERT(c <= Category::LAST); - flags_ &= ~CATEGORY_MASK; - setFlag(static_cast<uint32_t>(c)); - } - - void setOSR() volatile { - MOZ_ASSERT(isJs()); - setFlag(OSR); - } - void unsetOSR() volatile { - MOZ_ASSERT(isJs()); - unsetFlag(OSR); - } - bool isOSR() const volatile { - return hasFlag(OSR); - } - - void* stackAddress() const volatile { - MOZ_ASSERT(!isJs()); - return spOrScript; - } - JSScript* script() const volatile; - uint32_t line() const volatile { - MOZ_ASSERT(!isJs()); - return static_cast<uint32_t>(lineOrPcOffset); - } - - // Note that the pointer returned might be invalid. - JSScript* rawScript() const volatile { - MOZ_ASSERT(isJs()); - return (JSScript*)spOrScript; - } - - // We can't know the layout of JSScript, so look in vm/SPSProfiler.cpp. - JS_FRIEND_API(jsbytecode*) pc() const volatile; - JS_FRIEND_API(void) setPC(jsbytecode* pc) volatile; - - void trace(JSTracer* trc); - - // The offset of a pc into a script's code can actually be 0, so to - // signify a nullptr pc, use a -1 index. This is checked against in - // pc() and setPC() to set/get the right pc. - static const int32_t NullPCOffset = -1; - - static size_t offsetOfLabel() { return offsetof(ProfileEntry, string); } - static size_t offsetOfSpOrScript() { return offsetof(ProfileEntry, spOrScript); } - static size_t offsetOfLineOrPcOffset() { return offsetof(ProfileEntry, lineOrPcOffset); } - static size_t offsetOfFlags() { return offsetof(ProfileEntry, flags_); } -}; - -JS_FRIEND_API(void) -SetContextProfilingStack(JSContext* cx, ProfileEntry* stack, uint32_t* size, - uint32_t max); - -JS_FRIEND_API(void) -EnableContextProfilingStack(JSContext* cx, bool enabled); - -JS_FRIEND_API(void) -RegisterContextProfilingEventMarker(JSContext* cx, void (*fn)(const char*)); - -JS_FRIEND_API(jsbytecode*) -ProfilingGetPC(JSContext* cx, JSScript* script, void* ip); - -} // namespace js - -#endif /* js_ProfilingStack_h */ diff --git a/android/armeabi/include/spidermonkey/js/Proxy.h b/android/armeabi/include/spidermonkey/js/Proxy.h deleted file mode 100644 index 3e95538d..00000000 --- a/android/armeabi/include/spidermonkey/js/Proxy.h +++ /dev/null @@ -1,632 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_Proxy_h -#define js_Proxy_h - -#include "mozilla/Maybe.h" - -#include "jsfriendapi.h" - -#include "js/CallNonGenericMethod.h" -#include "js/Class.h" - -namespace js { - -using JS::AutoIdVector; -using JS::CallArgs; -using JS::Handle; -using JS::HandleId; -using JS::HandleObject; -using JS::HandleValue; -using JS::IsAcceptableThis; -using JS::MutableHandle; -using JS::MutableHandleObject; -using JS::MutableHandleValue; -using JS::NativeImpl; -using JS::ObjectOpResult; -using JS::PrivateValue; -using JS::PropertyDescriptor; -using JS::Value; - -class RegExpGuard; -class JS_FRIEND_API(Wrapper); - -/* - * A proxy is a JSObject with highly customizable behavior. ES6 specifies a - * single kind of proxy, but the customization mechanisms we use to implement - * ES6 Proxy objects are also useful wherever an object with weird behavior is - * wanted. Proxies are used to implement: - * - * - the scope objects used by the Debugger's frame.eval() method - * (see js::GetDebugScopeForFunction) - * - * - the khuey hack, whereby a whole compartment can be blown away - * even if other compartments hold references to objects in it - * (see js::NukeCrossCompartmentWrappers) - * - * - XPConnect security wrappers, which protect chrome from malicious content - * (js/xpconnect/wrappers) - * - * - DOM objects with special property behavior, like named getters - * (dom/bindings/Codegen.py generates these proxies from WebIDL) - * - * - semi-transparent use of objects that live in other processes - * (CPOWs, implemented in js/ipc) - * - * ### Proxies and internal methods - * - * ES2016 specifies 13 internal methods. The runtime semantics of just - * about everything a script can do to an object is specified in terms - * of these internal methods. For example: - * - * JS code ES6 internal method that gets called - * --------------------------- -------------------------------- - * obj.prop obj.[[Get]](obj, "prop") - * "prop" in obj obj.[[HasProperty]]("prop") - * new obj() obj.[[Construct]](<empty argument List>) - * - * With regard to the implementation of these internal methods, there are three - * very different kinds of object in SpiderMonkey. - * - * 1. Native objects' internal methods are implemented in vm/NativeObject.cpp, - * with duplicate (but functionally identical) implementations scattered - * through the ICs and JITs. - * - * 2. Certain non-native objects have internal methods that are implemented as - * magical js::ObjectOps hooks. We're trying to get rid of these. - * - * 3. All other objects are proxies. A proxy's internal methods are - * implemented in C++, as the virtual methods of a C++ object stored on the - * proxy, known as its handler. - * - * This means that just about anything you do to a proxy will end up going - * through a C++ virtual method call. Possibly several. There's no reason the - * JITs and ICs can't specialize for particular proxies, based on the handler; - * but currently we don't do much of this, so the virtual method overhead - * typically is actually incurred. - * - * ### The proxy handler hierarchy - * - * A major use case for proxies is to forward each internal method call to - * another object, known as its target. The target can be an arbitrary JS - * object. Not every proxy has the notion of a target, however. - * - * To minimize code duplication, a set of abstract proxy handler classes is - * provided, from which other handlers may inherit. These abstract classes are - * organized in the following hierarchy: - * - * BaseProxyHandler - * | - * Wrapper // has a target, can be unwrapped to reveal - * | // target (see js::CheckedUnwrap) - * | - * CrossCompartmentWrapper // target is in another compartment; - * // implements membrane between compartments - * - * Example: Some DOM objects (including all the arraylike DOM objects) are - * implemented as proxies. Since these objects don't need to forward operations - * to any underlying JS object, DOMJSProxyHandler directly subclasses - * BaseProxyHandler. - * - * Gecko's security wrappers are examples of cross-compartment wrappers. - * - * ### Proxy prototype chains - * - * In addition to the normal methods, there are two models for proxy prototype - * chains. - * - * 1. Proxies can use the standard prototype mechanism used throughout the - * engine. To do so, simply pass a prototype to NewProxyObject() at - * creation time. All prototype accesses will then "just work" to treat the - * proxy as a "normal" object. - * - * 2. A proxy can implement more complicated prototype semantics (if, for - * example, it wants to delegate the prototype lookup to a wrapped object) - * by passing Proxy::LazyProto as the prototype at create time. This - * guarantees that the getPrototype() handler method will be called every - * time the object's prototype chain is accessed. - * - * This system is implemented with two methods: {get,set}Prototype. The - * default implementation of setPrototype throws a TypeError. Since it is - * not possible to create an object without a sense of prototype chain, - * handlers must implement getPrototype if opting in to the dynamic - * prototype system. - */ - -/* - * BaseProxyHandler is the most generic kind of proxy handler. It does not make - * any assumptions about the target. Consequently, it does not provide any - * default implementation for most methods. As a convenience, a few high-level - * methods, like get() and set(), are given default implementations that work by - * calling the low-level methods, like getOwnPropertyDescriptor(). - * - * Important: If you add a method here, you should probably also add a - * Proxy::foo entry point with an AutoEnterPolicy. If you don't, you need an - * explicit override for the method in SecurityWrapper. See bug 945826 comment 0. - */ -class JS_FRIEND_API(BaseProxyHandler) -{ - /* - * Sometimes it's desirable to designate groups of proxy handlers as "similar". - * For this, we use the notion of a "family": A consumer-provided opaque pointer - * that designates the larger group to which this proxy belongs. - * - * If it will never be important to differentiate this proxy from others as - * part of a distinct group, nullptr may be used instead. - */ - const void* mFamily; - - /* - * Proxy handlers can use mHasPrototype to request the following special - * treatment from the JS engine: - * - * - When mHasPrototype is true, the engine never calls these methods: - * getPropertyDescriptor, has, set, enumerate, iterate. Instead, for - * these operations, it calls the "own" methods like - * getOwnPropertyDescriptor, hasOwn, defineProperty, - * getOwnEnumerablePropertyKeys, etc., and consults the prototype chain - * if needed. - * - * - When mHasPrototype is true, the engine calls handler->get() only if - * handler->hasOwn() says an own property exists on the proxy. If not, - * it consults the prototype chain. - * - * This is useful because it frees the ProxyHandler from having to implement - * any behavior having to do with the prototype chain. - */ - bool mHasPrototype; - - /* - * All proxies indicate whether they have any sort of interesting security - * policy that might prevent the caller from doing something it wants to - * the object. In the case of wrappers, this distinction is used to - * determine whether the caller may strip off the wrapper if it so desires. - */ - bool mHasSecurityPolicy; - - public: - explicit constexpr BaseProxyHandler(const void* aFamily, bool aHasPrototype = false, - bool aHasSecurityPolicy = false) - : mFamily(aFamily), - mHasPrototype(aHasPrototype), - mHasSecurityPolicy(aHasSecurityPolicy) - { } - - bool hasPrototype() const { - return mHasPrototype; - } - - bool hasSecurityPolicy() const { - return mHasSecurityPolicy; - } - - inline const void* family() const { - return mFamily; - } - static size_t offsetOfFamily() { - return offsetof(BaseProxyHandler, mFamily); - } - - virtual bool finalizeInBackground(const Value& priv) const { - /* - * Called on creation of a proxy to determine whether its finalize - * method can be finalized on the background thread. - */ - return true; - } - - virtual bool canNurseryAllocate() const { - /* - * Nursery allocation is allowed if and only if it is safe to not - * run |finalize| when the ProxyObject dies. - */ - return false; - } - - /* Policy enforcement methods. - * - * enter() allows the policy to specify whether the caller may perform |act| - * on the proxy's |id| property. In the case when |act| is CALL, |id| is - * generally JSID_VOID. - * - * The |act| parameter to enter() specifies the action being performed. - * If |bp| is false, the method suggests that the caller throw (though it - * may still decide to squelch the error). - * - * We make these OR-able so that assertEnteredPolicy can pass a union of them. - * For example, get{,Own}PropertyDescriptor is invoked by calls to ::get() - * ::set(), in addition to being invoked on its own, so there are several - * valid Actions that could have been entered. - */ - typedef uint32_t Action; - enum { - NONE = 0x00, - GET = 0x01, - SET = 0x02, - CALL = 0x04, - ENUMERATE = 0x08, - GET_PROPERTY_DESCRIPTOR = 0x10 - }; - - virtual bool enter(JSContext* cx, HandleObject wrapper, HandleId id, Action act, - bool* bp) const; - - /* Standard internal methods. */ - virtual bool getOwnPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id, - MutableHandle<PropertyDescriptor> desc) const = 0; - virtual bool defineProperty(JSContext* cx, HandleObject proxy, HandleId id, - Handle<PropertyDescriptor> desc, - ObjectOpResult& result) const = 0; - virtual bool ownPropertyKeys(JSContext* cx, HandleObject proxy, - AutoIdVector& props) const = 0; - virtual bool delete_(JSContext* cx, HandleObject proxy, HandleId id, - ObjectOpResult& result) const = 0; - - /* - * These methods are standard, but the engine does not normally call them. - * They're opt-in. See "Proxy prototype chains" above. - * - * getPrototype() crashes if called. setPrototype() throws a TypeError. - */ - virtual bool getPrototype(JSContext* cx, HandleObject proxy, MutableHandleObject protop) const; - virtual bool setPrototype(JSContext* cx, HandleObject proxy, HandleObject proto, - ObjectOpResult& result) const; - - /* Non-standard but conceptual kin to {g,s}etPrototype, so these live here. */ - virtual bool getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy, bool* isOrdinary, - MutableHandleObject protop) const = 0; - virtual bool setImmutablePrototype(JSContext* cx, HandleObject proxy, bool* succeeded) const; - - virtual bool preventExtensions(JSContext* cx, HandleObject proxy, - ObjectOpResult& result) const = 0; - virtual bool isExtensible(JSContext* cx, HandleObject proxy, bool* extensible) const = 0; - - /* - * These standard internal methods are implemented, as a convenience, so - * that ProxyHandler subclasses don't have to provide every single method. - * - * The base-class implementations work by calling getPropertyDescriptor(). - * They do not follow any standard. When in doubt, override them. - */ - virtual bool has(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const; - virtual bool get(JSContext* cx, HandleObject proxy, HandleValue receiver, - HandleId id, MutableHandleValue vp) const; - virtual bool set(JSContext* cx, HandleObject proxy, HandleId id, HandleValue v, - HandleValue receiver, ObjectOpResult& result) const; - - /* - * [[Call]] and [[Construct]] are standard internal methods but according - * to the spec, they are not present on every object. - * - * SpiderMonkey never calls a proxy's call()/construct() internal method - * unless isCallable()/isConstructor() returns true for that proxy. - * - * BaseProxyHandler::isCallable()/isConstructor() always return false, and - * BaseProxyHandler::call()/construct() crash if called. So if you're - * creating a kind of that is never callable, you don't have to override - * anything, but otherwise you probably want to override all four. - */ - virtual bool call(JSContext* cx, HandleObject proxy, const CallArgs& args) const; - virtual bool construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const; - - /* SpiderMonkey extensions. */ - virtual bool enumerate(JSContext* cx, HandleObject proxy, MutableHandleObject objp) const; - virtual bool getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id, - MutableHandle<PropertyDescriptor> desc) const; - virtual bool hasOwn(JSContext* cx, HandleObject proxy, HandleId id, bool* bp) const; - virtual bool getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject proxy, - AutoIdVector& props) const; - virtual bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl, - const CallArgs& args) const; - virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, bool* bp) const; - virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy, - ESClass* cls) const; - virtual bool isArray(JSContext* cx, HandleObject proxy, JS::IsArrayAnswer* answer) const; - virtual const char* className(JSContext* cx, HandleObject proxy) const; - virtual JSString* fun_toString(JSContext* cx, HandleObject proxy, unsigned indent) const; - virtual bool regexp_toShared(JSContext* cx, HandleObject proxy, RegExpGuard* g) const; - virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy, MutableHandleValue vp) const; - virtual void trace(JSTracer* trc, JSObject* proxy) const; - virtual void finalize(JSFreeOp* fop, JSObject* proxy) const; - virtual void objectMoved(JSObject* proxy, const JSObject* old) const; - - // Allow proxies, wrappers in particular, to specify callability at runtime. - // Note: These do not take const JSObject*, but they do in spirit. - // We are not prepared to do this, as there's little const correctness - // in the external APIs that handle proxies. - virtual bool isCallable(JSObject* obj) const; - virtual bool isConstructor(JSObject* obj) const; - - // These two hooks must be overridden, or not overridden, in tandem -- no - // overriding just one! - virtual bool watch(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, - JS::HandleObject callable) const; - virtual bool unwatch(JSContext* cx, JS::HandleObject proxy, JS::HandleId id) const; - - virtual bool getElements(JSContext* cx, HandleObject proxy, uint32_t begin, uint32_t end, - ElementAdder* adder) const; - - /* See comment for weakmapKeyDelegateOp in js/Class.h. */ - virtual JSObject* weakmapKeyDelegate(JSObject* proxy) const; - virtual bool isScripted() const { return false; } -}; - -extern JS_FRIEND_DATA(const js::Class* const) ProxyClassPtr; - -inline bool IsProxy(const JSObject* obj) -{ - return GetObjectClass(obj)->isProxy(); -} - -namespace detail { -const uint32_t PROXY_EXTRA_SLOTS = 2; - -// Layout of the values stored by a proxy. Note that API clients require the -// private slot to be the first slot in the proxy's values, so that the private -// slot can be accessed in the same fashion as the first reserved slot, via -// {Get,Set}ReservedOrProxyPrivateSlot. - -struct ProxyValueArray -{ - Value privateSlot; - Value extraSlots[PROXY_EXTRA_SLOTS]; - - ProxyValueArray() - : privateSlot(JS::UndefinedValue()) - { - for (size_t i = 0; i < PROXY_EXTRA_SLOTS; i++) - extraSlots[i] = JS::UndefinedValue(); - } -}; - -// All proxies share the same data layout. Following the object's shape and -// type, the proxy has a ProxyDataLayout structure with a pointer to an array -// of values and the proxy's handler. This is designed both so that proxies can -// be easily swapped with other objects (via RemapWrapper) and to mimic the -// layout of other objects (proxies and other objects have the same size) so -// that common code can access either type of object. -// -// See GetReservedOrProxyPrivateSlot below. -struct ProxyDataLayout -{ - ProxyValueArray* values; - const BaseProxyHandler* handler; -}; - -const uint32_t ProxyDataOffset = 2 * sizeof(void*); - -inline ProxyDataLayout* -GetProxyDataLayout(JSObject* obj) -{ - MOZ_ASSERT(IsProxy(obj)); - return reinterpret_cast<ProxyDataLayout*>(reinterpret_cast<uint8_t*>(obj) + ProxyDataOffset); -} - -inline const ProxyDataLayout* -GetProxyDataLayout(const JSObject* obj) -{ - MOZ_ASSERT(IsProxy(obj)); - return reinterpret_cast<const ProxyDataLayout*>(reinterpret_cast<const uint8_t*>(obj) + - ProxyDataOffset); -} -} // namespace detail - -inline const BaseProxyHandler* -GetProxyHandler(const JSObject* obj) -{ - return detail::GetProxyDataLayout(obj)->handler; -} - -inline const Value& -GetProxyPrivate(const JSObject* obj) -{ - return detail::GetProxyDataLayout(obj)->values->privateSlot; -} - -inline JSObject* -GetProxyTargetObject(JSObject* obj) -{ - return GetProxyPrivate(obj).toObjectOrNull(); -} - -inline const Value& -GetProxyExtra(const JSObject* obj, size_t n) -{ - MOZ_ASSERT(n < detail::PROXY_EXTRA_SLOTS); - return detail::GetProxyDataLayout(obj)->values->extraSlots[n]; -} - -inline void -SetProxyHandler(JSObject* obj, const BaseProxyHandler* handler) -{ - detail::GetProxyDataLayout(obj)->handler = handler; -} - -JS_FRIEND_API(void) -SetValueInProxy(Value* slot, const Value& value); - -inline void -SetProxyExtra(JSObject* obj, size_t n, const Value& extra) -{ - MOZ_ASSERT(n < detail::PROXY_EXTRA_SLOTS); - Value* vp = &detail::GetProxyDataLayout(obj)->values->extraSlots[n]; - - // Trigger a barrier before writing the slot. - if (vp->isMarkable() || extra.isMarkable()) - SetValueInProxy(vp, extra); - else - *vp = extra; -} - -inline bool -IsScriptedProxy(const JSObject* obj) -{ - return IsProxy(obj) && GetProxyHandler(obj)->isScripted(); -} - -inline const Value& -GetReservedOrProxyPrivateSlot(const JSObject* obj, size_t slot) -{ - MOZ_ASSERT(slot == 0); - MOZ_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj)) || IsProxy(obj)); - return reinterpret_cast<const shadow::Object*>(obj)->slotRef(slot); -} - -inline void -SetReservedOrProxyPrivateSlot(JSObject* obj, size_t slot, const Value& value) -{ - MOZ_ASSERT(slot == 0); - MOZ_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj)) || IsProxy(obj)); - shadow::Object* sobj = reinterpret_cast<shadow::Object*>(obj); - if (sobj->slotRef(slot).isMarkable() || value.isMarkable()) - SetReservedOrProxyPrivateSlotWithBarrier(obj, slot, value); - else - sobj->slotRef(slot) = value; -} - -class MOZ_STACK_CLASS ProxyOptions { - protected: - /* protected constructor for subclass */ - explicit ProxyOptions(bool singletonArg, bool lazyProtoArg = false) - : singleton_(singletonArg), - lazyProto_(lazyProtoArg), - clasp_(ProxyClassPtr) - {} - - public: - ProxyOptions() : singleton_(false), - lazyProto_(false), - clasp_(ProxyClassPtr) - {} - - bool singleton() const { return singleton_; } - ProxyOptions& setSingleton(bool flag) { - singleton_ = flag; - return *this; - } - - bool lazyProto() const { return lazyProto_; } - ProxyOptions& setLazyProto(bool flag) { - lazyProto_ = flag; - return *this; - } - - const Class* clasp() const { - return clasp_; - } - ProxyOptions& setClass(const Class* claspArg) { - clasp_ = claspArg; - return *this; - } - - private: - bool singleton_; - bool lazyProto_; - const Class* clasp_; -}; - -JS_FRIEND_API(JSObject*) -NewProxyObject(JSContext* cx, const BaseProxyHandler* handler, HandleValue priv, - JSObject* proto, const ProxyOptions& options = ProxyOptions()); - -JSObject* -RenewProxyObject(JSContext* cx, JSObject* obj, BaseProxyHandler* handler, const Value& priv); - -class JS_FRIEND_API(AutoEnterPolicy) -{ - public: - typedef BaseProxyHandler::Action Action; - AutoEnterPolicy(JSContext* cx, const BaseProxyHandler* handler, - HandleObject wrapper, HandleId id, Action act, bool mayThrow) -#ifdef JS_DEBUG - : context(nullptr) -#endif - { - allow = handler->hasSecurityPolicy() ? handler->enter(cx, wrapper, id, act, &rv) - : true; - recordEnter(cx, wrapper, id, act); - // We want to throw an exception if all of the following are true: - // * The policy disallowed access. - // * The policy set rv to false, indicating that we should throw. - // * The caller did not instruct us to ignore exceptions. - // * The policy did not throw itself. - if (!allow && !rv && mayThrow) - reportErrorIfExceptionIsNotPending(cx, id); - } - - virtual ~AutoEnterPolicy() { recordLeave(); } - inline bool allowed() { return allow; } - inline bool returnValue() { MOZ_ASSERT(!allowed()); return rv; } - - protected: - // no-op constructor for subclass - AutoEnterPolicy() -#ifdef JS_DEBUG - : context(nullptr) - , enteredAction(BaseProxyHandler::NONE) -#endif - {} - void reportErrorIfExceptionIsNotPending(JSContext* cx, jsid id); - bool allow; - bool rv; - -#ifdef JS_DEBUG - JSContext* context; - mozilla::Maybe<HandleObject> enteredProxy; - mozilla::Maybe<HandleId> enteredId; - Action enteredAction; - - // NB: We explicitly don't track the entered action here, because sometimes - // set() methods do an implicit get() during their implementation, leading - // to spurious assertions. - AutoEnterPolicy* prev; - void recordEnter(JSContext* cx, HandleObject proxy, HandleId id, Action act); - void recordLeave(); - - friend JS_FRIEND_API(void) assertEnteredPolicy(JSContext* cx, JSObject* proxy, jsid id, Action act); -#else - inline void recordEnter(JSContext* cx, JSObject* proxy, jsid id, Action act) {} - inline void recordLeave() {} -#endif - -}; - -#ifdef JS_DEBUG -class JS_FRIEND_API(AutoWaivePolicy) : public AutoEnterPolicy { -public: - AutoWaivePolicy(JSContext* cx, HandleObject proxy, HandleId id, - BaseProxyHandler::Action act) - { - allow = true; - recordEnter(cx, proxy, id, act); - } -}; -#else -class JS_FRIEND_API(AutoWaivePolicy) { - public: - AutoWaivePolicy(JSContext* cx, HandleObject proxy, HandleId id, - BaseProxyHandler::Action act) - {} -}; -#endif - -#ifdef JS_DEBUG -extern JS_FRIEND_API(void) -assertEnteredPolicy(JSContext* cx, JSObject* obj, jsid id, - BaseProxyHandler::Action act); -#else -inline void assertEnteredPolicy(JSContext* cx, JSObject* obj, jsid id, - BaseProxyHandler::Action act) -{} -#endif - -extern JS_FRIEND_API(JSObject*) -InitProxyClass(JSContext* cx, JS::HandleObject obj); - -} /* namespace js */ - -#endif /* js_Proxy_h */ diff --git a/android/armeabi/include/spidermonkey/js/Realm.h b/android/armeabi/include/spidermonkey/js/Realm.h deleted file mode 100644 index 13a22c70..00000000 --- a/android/armeabi/include/spidermonkey/js/Realm.h +++ /dev/null @@ -1,42 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Ways to get various per-Realm objects. All the getters declared in this - * header operate on the Realm corresponding to the current compartment on the - * JSContext. - */ - -#ifndef js_Realm_h -#define js_Realm_h - -#include "jstypes.h" - -struct JSContext; -class JSObject; - -namespace JS { - -extern JS_PUBLIC_API(JSObject*) -GetRealmObjectPrototype(JSContext* cx); - -extern JS_PUBLIC_API(JSObject*) -GetRealmFunctionPrototype(JSContext* cx); - -extern JS_PUBLIC_API(JSObject*) -GetRealmArrayPrototype(JSContext* cx); - -extern JS_PUBLIC_API(JSObject*) -GetRealmErrorPrototype(JSContext* cx); - -extern JS_PUBLIC_API(JSObject*) -GetRealmIteratorPrototype(JSContext* cx); - -} // namespace JS - -#endif // js_Realm_h - - diff --git a/android/armeabi/include/spidermonkey/js/RequiredDefines.h b/android/armeabi/include/spidermonkey/js/RequiredDefines.h deleted file mode 100644 index 308fd7d6..00000000 --- a/android/armeabi/include/spidermonkey/js/RequiredDefines.h +++ /dev/null @@ -1,34 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Various #defines required to build SpiderMonkey. Embedders should add this - * file to the start of the command line via -include or a similar mechanism, - * or SpiderMonkey public headers may not work correctly. - */ - -#ifndef js_RequiredDefines_h -#define js_RequiredDefines_h - -/* - * The c99 defining the limit macros (UINT32_MAX for example), says: - * - * C++ implementations should define these macros only when - * __STDC_LIMIT_MACROS is defined before <stdint.h> is included. - * - * The same also occurs with __STDC_CONSTANT_MACROS for the constant macros - * (INT8_C for example) used to specify a literal constant of the proper type, - * and with __STDC_FORMAT_MACROS for the format macros (PRId32 for example) used - * with the fprintf function family. - */ -#define __STDC_LIMIT_MACROS -#define __STDC_CONSTANT_MACROS -#define __STDC_FORMAT_MACROS - -/* Also define a char16_t type if not provided by the compiler. */ -#include "mozilla/Char16.h" - -#endif /* js_RequiredDefines_h */ diff --git a/android/armeabi/include/spidermonkey/js/RootingAPI.h b/android/armeabi/include/spidermonkey/js/RootingAPI.h deleted file mode 100644 index a99ac4ec..00000000 --- a/android/armeabi/include/spidermonkey/js/RootingAPI.h +++ /dev/null @@ -1,1308 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_RootingAPI_h -#define js_RootingAPI_h - -#include "mozilla/Attributes.h" -#include "mozilla/DebugOnly.h" -#include "mozilla/GuardObjects.h" -#include "mozilla/LinkedList.h" -#include "mozilla/Move.h" -#include "mozilla/TypeTraits.h" - -#include <type_traits> - -#include "jspubtd.h" - -#include "js/GCAnnotations.h" -#include "js/GCAPI.h" -#include "js/GCPolicyAPI.h" -#include "js/HeapAPI.h" -#include "js/TypeDecls.h" -#include "js/UniquePtr.h" -#include "js/Utility.h" - -/* - * Moving GC Stack Rooting - * - * A moving GC may change the physical location of GC allocated things, even - * when they are rooted, updating all pointers to the thing to refer to its new - * location. The GC must therefore know about all live pointers to a thing, - * not just one of them, in order to behave correctly. - * - * The |Rooted| and |Handle| classes below are used to root stack locations - * whose value may be held live across a call that can trigger GC. For a - * code fragment such as: - * - * JSObject* obj = NewObject(cx); - * DoSomething(cx); - * ... = obj->lastProperty(); - * - * If |DoSomething()| can trigger a GC, the stack location of |obj| must be - * rooted to ensure that the GC does not move the JSObject referred to by - * |obj| without updating |obj|'s location itself. This rooting must happen - * regardless of whether there are other roots which ensure that the object - * itself will not be collected. - * - * If |DoSomething()| cannot trigger a GC, and the same holds for all other - * calls made between |obj|'s definitions and its last uses, then no rooting - * is required. - * - * SpiderMonkey can trigger a GC at almost any time and in ways that are not - * always clear. For example, the following innocuous-looking actions can - * cause a GC: allocation of any new GC thing; JSObject::hasProperty; - * JS_ReportError and friends; and ToNumber, among many others. The following - * dangerous-looking actions cannot trigger a GC: js_malloc, cx->malloc_, - * rt->malloc_, and friends and JS_ReportOutOfMemory. - * - * The following family of three classes will exactly root a stack location. - * Incorrect usage of these classes will result in a compile error in almost - * all cases. Therefore, it is very hard to be incorrectly rooted if you use - * these classes exclusively. These classes are all templated on the type T of - * the value being rooted. - * - * - Rooted<T> declares a variable of type T, whose value is always rooted. - * Rooted<T> may be automatically coerced to a Handle<T>, below. Rooted<T> - * should be used whenever a local variable's value may be held live across a - * call which can trigger a GC. - * - * - Handle<T> is a const reference to a Rooted<T>. Functions which take GC - * things or values as arguments and need to root those arguments should - * generally use handles for those arguments and avoid any explicit rooting. - * This has two benefits. First, when several such functions call each other - * then redundant rooting of multiple copies of the GC thing can be avoided. - * Second, if the caller does not pass a rooted value a compile error will be - * generated, which is quicker and easier to fix than when relying on a - * separate rooting analysis. - * - * - MutableHandle<T> is a non-const reference to Rooted<T>. It is used in the - * same way as Handle<T> and includes a |set(const T& v)| method to allow - * updating the value of the referenced Rooted<T>. A MutableHandle<T> can be - * created with an implicit cast from a Rooted<T>*. - * - * In some cases the small performance overhead of exact rooting (measured to - * be a few nanoseconds on desktop) is too much. In these cases, try the - * following: - * - * - Move all Rooted<T> above inner loops: this allows you to re-use the root - * on each iteration of the loop. - * - * - Pass Handle<T> through your hot call stack to avoid re-rooting costs at - * every invocation. - * - * The following diagram explains the list of supported, implicit type - * conversions between classes of this family: - * - * Rooted<T> ----> Handle<T> - * | ^ - * | | - * | | - * +---> MutableHandle<T> - * (via &) - * - * All of these types have an implicit conversion to raw pointers. - */ - -namespace js { - -template <typename T> -struct BarrierMethods { -}; - -template <typename T> -class RootedBase {}; - -template <typename T> -class HandleBase {}; - -template <typename T> -class MutableHandleBase {}; - -template <typename T> -class HeapBase {}; - -// Cannot use FOR_EACH_HEAP_ABLE_GC_POINTER_TYPE, as this would import too many macros into scope -template <typename T> struct IsHeapConstructibleType { static constexpr bool value = false; }; -#define DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE(T) \ - template <> struct IsHeapConstructibleType<T> { static constexpr bool value = true; }; -FOR_EACH_PUBLIC_GC_POINTER_TYPE(DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE) -FOR_EACH_PUBLIC_TAGGED_GC_POINTER_TYPE(DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE) -#undef DECLARE_IS_HEAP_CONSTRUCTIBLE_TYPE - -template <typename T> -class PersistentRootedBase {}; - -static void* const ConstNullValue = nullptr; - -namespace gc { -struct Cell; -template<typename T> -struct PersistentRootedMarker; -} /* namespace gc */ - -#define DECLARE_POINTER_COMPARISON_OPS(T) \ - bool operator==(const T& other) const { return get() == other; } \ - bool operator!=(const T& other) const { return get() != other; } - -// Important: Return a reference so passing a Rooted<T>, etc. to -// something that takes a |const T&| is not a GC hazard. -#define DECLARE_POINTER_CONSTREF_OPS(T) \ - operator const T&() const { return get(); } \ - const T& operator->() const { return get(); } - -// Assignment operators on a base class are hidden by the implicitly defined -// operator= on the derived class. Thus, define the operator= directly on the -// class as we would need to manually pass it through anyway. -#define DECLARE_POINTER_ASSIGN_OPS(Wrapper, T) \ - Wrapper<T>& operator=(const T& p) { \ - set(p); \ - return *this; \ - } \ - Wrapper<T>& operator=(const Wrapper<T>& other) { \ - set(other.get()); \ - return *this; \ - } \ - -#define DELETE_ASSIGNMENT_OPS(Wrapper, T) \ - template <typename S> Wrapper<T>& operator=(S) = delete; \ - Wrapper<T>& operator=(const Wrapper<T>&) = delete; - -#define DECLARE_NONPOINTER_ACCESSOR_METHODS(ptr) \ - const T* address() const { return &(ptr); } \ - const T& get() const { return (ptr); } \ - -#define DECLARE_NONPOINTER_MUTABLE_ACCESSOR_METHODS(ptr) \ - T* address() { return &(ptr); } \ - T& get() { return (ptr); } \ - -} /* namespace js */ - -namespace JS { - -template <typename T> class Rooted; -template <typename T> class PersistentRooted; - -/* This is exposing internal state of the GC for inlining purposes. */ -JS_FRIEND_API(bool) isGCEnabled(); - -JS_FRIEND_API(void) HeapObjectPostBarrier(JSObject** objp, JSObject* prev, JSObject* next); - -#ifdef JS_DEBUG -/** - * For generational GC, assert that an object is in the tenured generation as - * opposed to being in the nursery. - */ -extern JS_FRIEND_API(void) -AssertGCThingMustBeTenured(JSObject* obj); -extern JS_FRIEND_API(void) -AssertGCThingIsNotAnObjectSubclass(js::gc::Cell* cell); -#else -inline void -AssertGCThingMustBeTenured(JSObject* obj) {} -inline void -AssertGCThingIsNotAnObjectSubclass(js::gc::Cell* cell) {} -#endif - -/** - * The Heap<T> class is a heap-stored reference to a JS GC thing. All members of - * heap classes that refer to GC things should use Heap<T> (or possibly - * TenuredHeap<T>, described below). - * - * Heap<T> is an abstraction that hides some of the complexity required to - * maintain GC invariants for the contained reference. It uses operator - * overloading to provide a normal pointer interface, but notifies the GC every - * time the value it contains is updated. This is necessary for generational GC, - * which keeps track of all pointers into the nursery. - * - * Heap<T> instances must be traced when their containing object is traced to - * keep the pointed-to GC thing alive. - * - * Heap<T> objects should only be used on the heap. GC references stored on the - * C/C++ stack must use Rooted/Handle/MutableHandle instead. - * - * Type T must be a public GC pointer type. - */ -template <typename T> -class Heap : public js::HeapBase<T> -{ - // Please note: this can actually also be used by nsXBLMaybeCompiled<T>, for legacy reasons. - static_assert(js::IsHeapConstructibleType<T>::value, - "Type T must be a public GC pointer type"); - public: - Heap() { - static_assert(sizeof(T) == sizeof(Heap<T>), - "Heap<T> must be binary compatible with T."); - init(GCPolicy<T>::initial()); - } - explicit Heap(const T& p) { init(p); } - - /* - * For Heap, move semantics are equivalent to copy semantics. In C++, a - * copy constructor taking const-ref is the way to get a single function - * that will be used for both lvalue and rvalue copies, so we can simply - * omit the rvalue variant. - */ - explicit Heap(const Heap<T>& p) { init(p.ptr); } - - ~Heap() { - post(ptr, GCPolicy<T>::initial()); - } - - DECLARE_POINTER_CONSTREF_OPS(T); - DECLARE_POINTER_ASSIGN_OPS(Heap, T); - - const T* address() const { return &ptr; } - - void exposeToActiveJS() const { - js::BarrierMethods<T>::exposeToJS(ptr); - } - const T& get() const { - exposeToActiveJS(); - return ptr; - } - const T& unbarrieredGet() const { - return ptr; - } - - T* unsafeGet() { return &ptr; } - - explicit operator bool() const { - return bool(js::BarrierMethods<T>::asGCThingOrNull(ptr)); - } - explicit operator bool() { - return bool(js::BarrierMethods<T>::asGCThingOrNull(ptr)); - } - - private: - void init(const T& newPtr) { - ptr = newPtr; - post(GCPolicy<T>::initial(), ptr); - } - - void set(const T& newPtr) { - T tmp = ptr; - ptr = newPtr; - post(tmp, ptr); - } - - void post(const T& prev, const T& next) { - js::BarrierMethods<T>::postBarrier(&ptr, prev, next); - } - - T ptr; -}; - -static MOZ_ALWAYS_INLINE bool -ObjectIsTenured(JSObject* obj) -{ - return !js::gc::IsInsideNursery(reinterpret_cast<js::gc::Cell*>(obj)); -} - -static MOZ_ALWAYS_INLINE bool -ObjectIsTenured(const Heap<JSObject*>& obj) -{ - return ObjectIsTenured(obj.unbarrieredGet()); -} - -static MOZ_ALWAYS_INLINE bool -ObjectIsMarkedGray(JSObject* obj) -{ - auto cell = reinterpret_cast<js::gc::Cell*>(obj); - return js::gc::detail::CellIsMarkedGrayIfKnown(cell); -} - -static MOZ_ALWAYS_INLINE bool -ObjectIsMarkedGray(const JS::Heap<JSObject*>& obj) -{ - return ObjectIsMarkedGray(obj.unbarrieredGet()); -} - -static MOZ_ALWAYS_INLINE bool -ScriptIsMarkedGray(JSScript* script) -{ - auto cell = reinterpret_cast<js::gc::Cell*>(script); - return js::gc::detail::CellIsMarkedGrayIfKnown(cell); -} - -static MOZ_ALWAYS_INLINE bool -ScriptIsMarkedGray(const Heap<JSScript*>& script) -{ - return ScriptIsMarkedGray(script.unbarrieredGet()); -} - -/** - * The TenuredHeap<T> class is similar to the Heap<T> class above in that it - * encapsulates the GC concerns of an on-heap reference to a JS object. However, - * it has two important differences: - * - * 1) Pointers which are statically known to only reference "tenured" objects - * can avoid the extra overhead of SpiderMonkey's write barriers. - * - * 2) Objects in the "tenured" heap have stronger alignment restrictions than - * those in the "nursery", so it is possible to store flags in the lower - * bits of pointers known to be tenured. TenuredHeap wraps a normal tagged - * pointer with a nice API for accessing the flag bits and adds various - * assertions to ensure that it is not mis-used. - * - * GC things are said to be "tenured" when they are located in the long-lived - * heap: e.g. they have gained tenure as an object by surviving past at least - * one GC. For performance, SpiderMonkey allocates some things which are known - * to normally be long lived directly into the tenured generation; for example, - * global objects. Additionally, SpiderMonkey does not visit individual objects - * when deleting non-tenured objects, so object with finalizers are also always - * tenured; for instance, this includes most DOM objects. - * - * The considerations to keep in mind when using a TenuredHeap<T> vs a normal - * Heap<T> are: - * - * - It is invalid for a TenuredHeap<T> to refer to a non-tenured thing. - * - It is however valid for a Heap<T> to refer to a tenured thing. - * - It is not possible to store flag bits in a Heap<T>. - */ -template <typename T> -class TenuredHeap : public js::HeapBase<T> -{ - public: - TenuredHeap() : bits(0) { - static_assert(sizeof(T) == sizeof(TenuredHeap<T>), - "TenuredHeap<T> must be binary compatible with T."); - } - explicit TenuredHeap(T p) : bits(0) { setPtr(p); } - explicit TenuredHeap(const TenuredHeap<T>& p) : bits(0) { setPtr(p.getPtr()); } - - bool operator==(const TenuredHeap<T>& other) { return bits == other.bits; } - bool operator!=(const TenuredHeap<T>& other) { return bits != other.bits; } - - void setPtr(T newPtr) { - MOZ_ASSERT((reinterpret_cast<uintptr_t>(newPtr) & flagsMask) == 0); - if (newPtr) - AssertGCThingMustBeTenured(newPtr); - bits = (bits & flagsMask) | reinterpret_cast<uintptr_t>(newPtr); - } - - void setFlags(uintptr_t flagsToSet) { - MOZ_ASSERT((flagsToSet & ~flagsMask) == 0); - bits |= flagsToSet; - } - - void unsetFlags(uintptr_t flagsToUnset) { - MOZ_ASSERT((flagsToUnset & ~flagsMask) == 0); - bits &= ~flagsToUnset; - } - - bool hasFlag(uintptr_t flag) const { - MOZ_ASSERT((flag & ~flagsMask) == 0); - return (bits & flag) != 0; - } - - T unbarrieredGetPtr() const { return reinterpret_cast<T>(bits & ~flagsMask); } - uintptr_t getFlags() const { return bits & flagsMask; } - - void exposeToActiveJS() const { - js::BarrierMethods<T>::exposeToJS(unbarrieredGetPtr()); - } - T getPtr() const { - exposeToActiveJS(); - return unbarrieredGetPtr(); - } - - operator T() const { return getPtr(); } - T operator->() const { return getPtr(); } - - explicit operator bool() const { - return bool(js::BarrierMethods<T>::asGCThingOrNull(unbarrieredGetPtr())); - } - explicit operator bool() { - return bool(js::BarrierMethods<T>::asGCThingOrNull(unbarrieredGetPtr())); - } - - TenuredHeap<T>& operator=(T p) { - setPtr(p); - return *this; - } - - TenuredHeap<T>& operator=(const TenuredHeap<T>& other) { - bits = other.bits; - return *this; - } - - private: - enum { - maskBits = 3, - flagsMask = (1 << maskBits) - 1, - }; - - uintptr_t bits; -}; - -/** - * Reference to a T that has been rooted elsewhere. This is most useful - * as a parameter type, which guarantees that the T lvalue is properly - * rooted. See "Move GC Stack Rooting" above. - * - * If you want to add additional methods to Handle for a specific - * specialization, define a HandleBase<T> specialization containing them. - */ -template <typename T> -class MOZ_NONHEAP_CLASS Handle : public js::HandleBase<T> -{ - friend class JS::MutableHandle<T>; - - public: - /* Creates a handle from a handle of a type convertible to T. */ - template <typename S> - MOZ_IMPLICIT Handle(Handle<S> handle, - typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0) - { - static_assert(sizeof(Handle<T>) == sizeof(T*), - "Handle must be binary compatible with T*."); - ptr = reinterpret_cast<const T*>(handle.address()); - } - - MOZ_IMPLICIT Handle(decltype(nullptr)) { - static_assert(mozilla::IsPointer<T>::value, - "nullptr_t overload not valid for non-pointer types"); - ptr = reinterpret_cast<const T*>(&js::ConstNullValue); - } - - MOZ_IMPLICIT Handle(MutableHandle<T> handle) { - ptr = handle.address(); - } - - /* - * Take care when calling this method! - * - * This creates a Handle from the raw location of a T. - * - * It should be called only if the following conditions hold: - * - * 1) the location of the T is guaranteed to be marked (for some reason - * other than being a Rooted), e.g., if it is guaranteed to be reachable - * from an implicit root. - * - * 2) the contents of the location are immutable, or at least cannot change - * for the lifetime of the handle, as its users may not expect its value - * to change underneath them. - */ - static constexpr Handle fromMarkedLocation(const T* p) { - return Handle(p, DeliberatelyChoosingThisOverload, - ImUsingThisOnlyInFromFromMarkedLocation); - } - - /* - * Construct a handle from an explicitly rooted location. This is the - * normal way to create a handle, and normally happens implicitly. - */ - template <typename S> - inline - MOZ_IMPLICIT Handle(const Rooted<S>& root, - typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0); - - template <typename S> - inline - MOZ_IMPLICIT Handle(const PersistentRooted<S>& root, - typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0); - - /* Construct a read only handle from a mutable handle. */ - template <typename S> - inline - MOZ_IMPLICIT Handle(MutableHandle<S>& root, - typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy = 0); - - DECLARE_POINTER_COMPARISON_OPS(T); - DECLARE_POINTER_CONSTREF_OPS(T); - DECLARE_NONPOINTER_ACCESSOR_METHODS(*ptr); - - private: - Handle() {} - DELETE_ASSIGNMENT_OPS(Handle, T); - - enum Disambiguator { DeliberatelyChoosingThisOverload = 42 }; - enum CallerIdentity { ImUsingThisOnlyInFromFromMarkedLocation = 17 }; - constexpr Handle(const T* p, Disambiguator, CallerIdentity) : ptr(p) {} - - const T* ptr; -}; - -/** - * Similar to a handle, but the underlying storage can be changed. This is - * useful for outparams. - * - * If you want to add additional methods to MutableHandle for a specific - * specialization, define a MutableHandleBase<T> specialization containing - * them. - */ -template <typename T> -class MOZ_STACK_CLASS MutableHandle : public js::MutableHandleBase<T> -{ - public: - inline MOZ_IMPLICIT MutableHandle(Rooted<T>* root); - inline MOZ_IMPLICIT MutableHandle(PersistentRooted<T>* root); - - private: - // Disallow nullptr for overloading purposes. - MutableHandle(decltype(nullptr)) = delete; - - public: - void set(const T& v) { - *ptr = v; - } - - /* - * This may be called only if the location of the T is guaranteed - * to be marked (for some reason other than being a Rooted), - * e.g., if it is guaranteed to be reachable from an implicit root. - * - * Create a MutableHandle from a raw location of a T. - */ - static MutableHandle fromMarkedLocation(T* p) { - MutableHandle h; - h.ptr = p; - return h; - } - - DECLARE_POINTER_CONSTREF_OPS(T); - DECLARE_NONPOINTER_ACCESSOR_METHODS(*ptr); - DECLARE_NONPOINTER_MUTABLE_ACCESSOR_METHODS(*ptr); - - private: - MutableHandle() {} - DELETE_ASSIGNMENT_OPS(MutableHandle, T); - - T* ptr; -}; - -} /* namespace JS */ - -namespace js { - -template <typename T> -struct BarrierMethods<T*> -{ - static T* initial() { return nullptr; } - static gc::Cell* asGCThingOrNull(T* v) { - if (!v) - return nullptr; - MOZ_ASSERT(uintptr_t(v) > 32); - return reinterpret_cast<gc::Cell*>(v); - } - static void postBarrier(T** vp, T* prev, T* next) { - if (next) - JS::AssertGCThingIsNotAnObjectSubclass(reinterpret_cast<js::gc::Cell*>(next)); - } - static void exposeToJS(T* t) { - if (t) - js::gc::ExposeGCThingToActiveJS(JS::GCCellPtr(t)); - } -}; - -template <> -struct BarrierMethods<JSObject*> -{ - static JSObject* initial() { return nullptr; } - static gc::Cell* asGCThingOrNull(JSObject* v) { - if (!v) - return nullptr; - MOZ_ASSERT(uintptr_t(v) > 32); - return reinterpret_cast<gc::Cell*>(v); - } - static void postBarrier(JSObject** vp, JSObject* prev, JSObject* next) { - JS::HeapObjectPostBarrier(vp, prev, next); - } - static void exposeToJS(JSObject* obj) { - if (obj) - JS::ExposeObjectToActiveJS(obj); - } -}; - -template <> -struct BarrierMethods<JSFunction*> -{ - static JSFunction* initial() { return nullptr; } - static gc::Cell* asGCThingOrNull(JSFunction* v) { - if (!v) - return nullptr; - MOZ_ASSERT(uintptr_t(v) > 32); - return reinterpret_cast<gc::Cell*>(v); - } - static void postBarrier(JSFunction** vp, JSFunction* prev, JSFunction* next) { - JS::HeapObjectPostBarrier(reinterpret_cast<JSObject**>(vp), - reinterpret_cast<JSObject*>(prev), - reinterpret_cast<JSObject*>(next)); - } - static void exposeToJS(JSFunction* fun) { - if (fun) - JS::ExposeObjectToActiveJS(reinterpret_cast<JSObject*>(fun)); - } -}; - -// Provide hash codes for Cell kinds that may be relocated and, thus, not have -// a stable address to use as the base for a hash code. Instead of the address, -// this hasher uses Cell::getUniqueId to provide exact matches and as a base -// for generating hash codes. -// -// Note: this hasher, like PointerHasher can "hash" a nullptr. While a nullptr -// would not likely be a useful key, there are some cases where being able to -// hash a nullptr is useful, either on purpose or because of bugs: -// (1) existence checks where the key may happen to be null and (2) some -// aggregate Lookup kinds embed a JSObject* that is frequently null and do not -// null test before dispatching to the hasher. -template <typename T> -struct JS_PUBLIC_API(MovableCellHasher) -{ - using Key = T; - using Lookup = T; - - static bool hasHash(const Lookup& l); - static bool ensureHash(const Lookup& l); - static HashNumber hash(const Lookup& l); - static bool match(const Key& k, const Lookup& l); - static void rekey(Key& k, const Key& newKey) { k = newKey; } -}; - -template <typename T> -struct JS_PUBLIC_API(MovableCellHasher<JS::Heap<T>>) -{ - using Key = JS::Heap<T>; - using Lookup = T; - - static bool hasHash(const Lookup& l) { return MovableCellHasher<T>::hasHash(l); } - static bool ensureHash(const Lookup& l) { return MovableCellHasher<T>::ensureHash(l); } - static HashNumber hash(const Lookup& l) { return MovableCellHasher<T>::hash(l); } - static bool match(const Key& k, const Lookup& l) { - return MovableCellHasher<T>::match(k.unbarrieredGet(), l); - } - static void rekey(Key& k, const Key& newKey) { k.unsafeSet(newKey); } -}; - -template <typename T> -struct FallibleHashMethods<MovableCellHasher<T>> -{ - template <typename Lookup> static bool hasHash(Lookup&& l) { - return MovableCellHasher<T>::hasHash(mozilla::Forward<Lookup>(l)); - } - template <typename Lookup> static bool ensureHash(Lookup&& l) { - return MovableCellHasher<T>::ensureHash(mozilla::Forward<Lookup>(l)); - } -}; - -} /* namespace js */ - -namespace js { - -// The alignment must be set because the Rooted and PersistentRooted ptr fields -// may be accessed through reinterpret_cast<Rooted<ConcreteTraceable>*>, and -// the compiler may choose a different alignment for the ptr field when it -// knows the actual type stored in DispatchWrapper<T>. -// -// It would make more sense to align only those specific fields of type -// DispatchWrapper, rather than DispatchWrapper itself, but that causes MSVC to -// fail when Rooted is used in an IsConvertible test. -template <typename T> -class alignas(8) DispatchWrapper -{ - static_assert(JS::MapTypeToRootKind<T>::kind == JS::RootKind::Traceable, - "DispatchWrapper is intended only for usage with a Traceable"); - - using TraceFn = void (*)(JSTracer*, T*, const char*); - TraceFn tracer; - alignas(gc::CellSize) T storage; - - public: - template <typename U> - MOZ_IMPLICIT DispatchWrapper(U&& initial) - : tracer(&JS::GCPolicy<T>::trace), - storage(mozilla::Forward<U>(initial)) - { } - - // Mimic a pointer type, so that we can drop into Rooted. - T* operator &() { return &storage; } - const T* operator &() const { return &storage; } - operator T&() { return storage; } - operator const T&() const { return storage; } - - // Trace the contained storage (of unknown type) using the trace function - // we set aside when we did know the type. - static void TraceWrapped(JSTracer* trc, T* thingp, const char* name) { - auto wrapper = reinterpret_cast<DispatchWrapper*>( - uintptr_t(thingp) - offsetof(DispatchWrapper, storage)); - wrapper->tracer(trc, &wrapper->storage, name); - } -}; - -} /* namespace js */ - -namespace JS { - -/** - * Local variable of type T whose value is always rooted. This is typically - * used for local variables, or for non-rooted values being passed to a - * function that requires a handle, e.g. Foo(Root<T>(cx, x)). - * - * If you want to add additional methods to Rooted for a specific - * specialization, define a RootedBase<T> specialization containing them. - */ -template <typename T> -class MOZ_RAII Rooted : public js::RootedBase<T> -{ - inline void registerWithRootLists(js::RootedListHeads& roots) { - this->stack = &roots[JS::MapTypeToRootKind<T>::kind]; - this->prev = *stack; - *stack = reinterpret_cast<Rooted<void*>*>(this); - } - - inline js::RootedListHeads& rootLists(JS::RootingContext* cx) { - return rootLists(static_cast<js::ContextFriendFields*>(cx)); - } - inline js::RootedListHeads& rootLists(js::ContextFriendFields* cx) { - if (JS::Zone* zone = cx->zone_) - return JS::shadow::Zone::asShadowZone(zone)->stackRoots_; - MOZ_ASSERT(cx->isJSContext); - return cx->roots.stackRoots_; - } - inline js::RootedListHeads& rootLists(JSContext* cx) { - return rootLists(js::ContextFriendFields::get(cx)); - } - - public: - template <typename RootingContext> - explicit Rooted(const RootingContext& cx) - : ptr(GCPolicy<T>::initial()) - { - registerWithRootLists(rootLists(cx)); - } - - template <typename RootingContext, typename S> - Rooted(const RootingContext& cx, S&& initial) - : ptr(mozilla::Forward<S>(initial)) - { - registerWithRootLists(rootLists(cx)); - } - - ~Rooted() { - MOZ_ASSERT(*stack == reinterpret_cast<Rooted<void*>*>(this)); - *stack = prev; - } - - Rooted<T>* previous() { return reinterpret_cast<Rooted<T>*>(prev); } - - /* - * This method is public for Rooted so that Codegen.py can use a Rooted - * interchangeably with a MutableHandleValue. - */ - void set(const T& value) { - ptr = value; - } - - DECLARE_POINTER_COMPARISON_OPS(T); - DECLARE_POINTER_CONSTREF_OPS(T); - DECLARE_POINTER_ASSIGN_OPS(Rooted, T); - DECLARE_NONPOINTER_ACCESSOR_METHODS(ptr); - DECLARE_NONPOINTER_MUTABLE_ACCESSOR_METHODS(ptr); - - private: - /* - * These need to be templated on void* to avoid aliasing issues between, for - * example, Rooted<JSObject> and Rooted<JSFunction>, which use the same - * stack head pointer for different classes. - */ - Rooted<void*>** stack; - Rooted<void*>* prev; - - /* - * For pointer types, the TraceKind for tracing is based on the list it is - * in (selected via MapTypeToRootKind), so no additional storage is - * required here. Non-pointer types, however, share the same list, so the - * function to call for tracing is stored adjacent to the struct. Since C++ - * cannot templatize on storage class, this is implemented via the wrapper - * class DispatchWrapper. - */ - using MaybeWrapped = typename mozilla::Conditional< - MapTypeToRootKind<T>::kind == JS::RootKind::Traceable, - js::DispatchWrapper<T>, - T>::Type; - MaybeWrapped ptr; - - Rooted(const Rooted&) = delete; -} JS_HAZ_ROOTED; - -} /* namespace JS */ - -namespace js { - -/** - * Augment the generic Rooted<T> interface when T = JSObject* with - * class-querying and downcasting operations. - * - * Given a Rooted<JSObject*> obj, one can view - * Handle<StringObject*> h = obj.as<StringObject*>(); - * as an optimization of - * Rooted<StringObject*> rooted(cx, &obj->as<StringObject*>()); - * Handle<StringObject*> h = rooted; - */ -template <> -class RootedBase<JSObject*> -{ - public: - template <class U> - JS::Handle<U*> as() const; -}; - -/** - * Augment the generic Handle<T> interface when T = JSObject* with - * downcasting operations. - * - * Given a Handle<JSObject*> obj, one can view - * Handle<StringObject*> h = obj.as<StringObject*>(); - * as an optimization of - * Rooted<StringObject*> rooted(cx, &obj->as<StringObject*>()); - * Handle<StringObject*> h = rooted; - */ -template <> -class HandleBase<JSObject*> -{ - public: - template <class U> - JS::Handle<U*> as() const; -}; - -/** Interface substitute for Rooted<T> which does not root the variable's memory. */ -template <typename T> -class MOZ_RAII FakeRooted : public RootedBase<T> -{ - public: - template <typename CX> - explicit FakeRooted(CX* cx) : ptr(JS::GCPolicy<T>::initial()) {} - - template <typename CX> - FakeRooted(CX* cx, T initial) : ptr(initial) {} - - DECLARE_POINTER_COMPARISON_OPS(T); - DECLARE_POINTER_CONSTREF_OPS(T); - DECLARE_POINTER_ASSIGN_OPS(FakeRooted, T); - DECLARE_NONPOINTER_ACCESSOR_METHODS(ptr); - DECLARE_NONPOINTER_MUTABLE_ACCESSOR_METHODS(ptr); - - private: - T ptr; - - void set(const T& value) { - ptr = value; - } - - FakeRooted(const FakeRooted&) = delete; -}; - -/** Interface substitute for MutableHandle<T> which is not required to point to rooted memory. */ -template <typename T> -class FakeMutableHandle : public js::MutableHandleBase<T> -{ - public: - MOZ_IMPLICIT FakeMutableHandle(T* t) { - ptr = t; - } - - MOZ_IMPLICIT FakeMutableHandle(FakeRooted<T>* root) { - ptr = root->address(); - } - - void set(const T& v) { - *ptr = v; - } - - DECLARE_POINTER_CONSTREF_OPS(T); - DECLARE_NONPOINTER_ACCESSOR_METHODS(*ptr); - DECLARE_NONPOINTER_MUTABLE_ACCESSOR_METHODS(*ptr); - - private: - FakeMutableHandle() {} - DELETE_ASSIGNMENT_OPS(FakeMutableHandle, T); - - T* ptr; -}; - -/** - * Types for a variable that either should or shouldn't be rooted, depending on - * the template parameter allowGC. Used for implementing functions that can - * operate on either rooted or unrooted data. - * - * The toHandle() and toMutableHandle() functions are for calling functions - * which require handle types and are only called in the CanGC case. These - * allow the calling code to type check. - */ -enum AllowGC { - NoGC = 0, - CanGC = 1 -}; -template <typename T, AllowGC allowGC> -class MaybeRooted -{ -}; - -template <typename T> class MaybeRooted<T, CanGC> -{ - public: - typedef JS::Handle<T> HandleType; - typedef JS::Rooted<T> RootType; - typedef JS::MutableHandle<T> MutableHandleType; - - static inline JS::Handle<T> toHandle(HandleType v) { - return v; - } - - static inline JS::MutableHandle<T> toMutableHandle(MutableHandleType v) { - return v; - } - - template <typename T2> - static inline JS::Handle<T2*> downcastHandle(HandleType v) { - return v.template as<T2>(); - } -}; - -template <typename T> class MaybeRooted<T, NoGC> -{ - public: - typedef const T& HandleType; - typedef FakeRooted<T> RootType; - typedef FakeMutableHandle<T> MutableHandleType; - - static JS::Handle<T> toHandle(HandleType v) { - MOZ_CRASH("Bad conversion"); - } - - static JS::MutableHandle<T> toMutableHandle(MutableHandleType v) { - MOZ_CRASH("Bad conversion"); - } - - template <typename T2> - static inline T2* downcastHandle(HandleType v) { - return &v->template as<T2>(); - } -}; - -} /* namespace js */ - -namespace JS { - -template <typename T> template <typename S> -inline -Handle<T>::Handle(const Rooted<S>& root, - typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy) -{ - ptr = reinterpret_cast<const T*>(root.address()); -} - -template <typename T> template <typename S> -inline -Handle<T>::Handle(const PersistentRooted<S>& root, - typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy) -{ - ptr = reinterpret_cast<const T*>(root.address()); -} - -template <typename T> template <typename S> -inline -Handle<T>::Handle(MutableHandle<S>& root, - typename mozilla::EnableIf<mozilla::IsConvertible<S, T>::value, int>::Type dummy) -{ - ptr = reinterpret_cast<const T*>(root.address()); -} - -template <typename T> -inline -MutableHandle<T>::MutableHandle(Rooted<T>* root) -{ - static_assert(sizeof(MutableHandle<T>) == sizeof(T*), - "MutableHandle must be binary compatible with T*."); - ptr = root->address(); -} - -template <typename T> -inline -MutableHandle<T>::MutableHandle(PersistentRooted<T>* root) -{ - static_assert(sizeof(MutableHandle<T>) == sizeof(T*), - "MutableHandle must be binary compatible with T*."); - ptr = root->address(); -} - -/** - * A copyable, assignable global GC root type with arbitrary lifetime, an - * infallible constructor, and automatic unrooting on destruction. - * - * These roots can be used in heap-allocated data structures, so they are not - * associated with any particular JSContext or stack. They are registered with - * the JSRuntime itself, without locking, so they require a full JSContext to be - * initialized, not one of its more restricted superclasses. Initialization may - * take place on construction, or in two phases if the no-argument constructor - * is called followed by init(). - * - * Note that you must not use an PersistentRooted in an object owned by a JS - * object: - * - * Whenever one object whose lifetime is decided by the GC refers to another - * such object, that edge must be traced only if the owning JS object is traced. - * This applies not only to JS objects (which obviously are managed by the GC) - * but also to C++ objects owned by JS objects. - * - * If you put a PersistentRooted in such a C++ object, that is almost certainly - * a leak. When a GC begins, the referent of the PersistentRooted is treated as - * live, unconditionally (because a PersistentRooted is a *root*), even if the - * JS object that owns it is unreachable. If there is any path from that - * referent back to the JS object, then the C++ object containing the - * PersistentRooted will not be destructed, and the whole blob of objects will - * not be freed, even if there are no references to them from the outside. - * - * In the context of Firefox, this is a severe restriction: almost everything in - * Firefox is owned by some JS object or another, so using PersistentRooted in - * such objects would introduce leaks. For these kinds of edges, Heap<T> or - * TenuredHeap<T> would be better types. It's up to the implementor of the type - * containing Heap<T> or TenuredHeap<T> members to make sure their referents get - * marked when the object itself is marked. - */ -template<typename T> -class PersistentRooted : public js::PersistentRootedBase<T>, - private mozilla::LinkedListElement<PersistentRooted<T>> -{ - using ListBase = mozilla::LinkedListElement<PersistentRooted<T>>; - - friend class mozilla::LinkedList<PersistentRooted>; - friend class mozilla::LinkedListElement<PersistentRooted>; - - void registerWithRootLists(js::RootLists& roots) { - MOZ_ASSERT(!initialized()); - JS::RootKind kind = JS::MapTypeToRootKind<T>::kind; - roots.heapRoots_[kind].insertBack(reinterpret_cast<JS::PersistentRooted<void*>*>(this)); - } - - js::RootLists& rootLists(JSContext* cx) { - return rootLists(JS::RootingContext::get(cx)); - } - js::RootLists& rootLists(JS::RootingContext* cx) { - MOZ_ASSERT(cx->isJSContext); - return cx->roots; - } - - // Disallow ExclusiveContext*. - js::RootLists& rootLists(js::ContextFriendFields* cx) = delete; - - public: - PersistentRooted() : ptr(GCPolicy<T>::initial()) {} - - template <typename RootingContext> - explicit PersistentRooted(const RootingContext& cx) - : ptr(GCPolicy<T>::initial()) - { - registerWithRootLists(rootLists(cx)); - } - - template <typename RootingContext, typename U> - PersistentRooted(const RootingContext& cx, U&& initial) - : ptr(mozilla::Forward<U>(initial)) - { - registerWithRootLists(rootLists(cx)); - } - - PersistentRooted(const PersistentRooted& rhs) - : mozilla::LinkedListElement<PersistentRooted<T>>(), - ptr(rhs.ptr) - { - /* - * Copy construction takes advantage of the fact that the original - * is already inserted, and simply adds itself to whatever list the - * original was on - no JSRuntime pointer needed. - * - * This requires mutating rhs's links, but those should be 'mutable' - * anyway. C++ doesn't let us declare mutable base classes. - */ - const_cast<PersistentRooted&>(rhs).setNext(this); - } - - bool initialized() { - return ListBase::isInList(); - } - - template <typename RootingContext> - void init(const RootingContext& cx) { - init(cx, GCPolicy<T>::initial()); - } - - template <typename RootingContext, typename U> - void init(const RootingContext& cx, U&& initial) { - ptr = mozilla::Forward<U>(initial); - registerWithRootLists(rootLists(cx)); - } - - void reset() { - if (initialized()) { - set(GCPolicy<T>::initial()); - ListBase::remove(); - } - } - - DECLARE_POINTER_COMPARISON_OPS(T); - DECLARE_POINTER_CONSTREF_OPS(T); - DECLARE_POINTER_ASSIGN_OPS(PersistentRooted, T); - DECLARE_NONPOINTER_ACCESSOR_METHODS(ptr); - - // These are the same as DECLARE_NONPOINTER_MUTABLE_ACCESSOR_METHODS, except - // they check that |this| is initialized in case the caller later stores - // something in |ptr|. - T* address() { - MOZ_ASSERT(initialized()); - return &ptr; - } - T& get() { - MOZ_ASSERT(initialized()); - return ptr; - } - - private: - template <typename U> - void set(U&& value) { - MOZ_ASSERT(initialized()); - ptr = mozilla::Forward<U>(value); - } - - // See the comment above Rooted::ptr. - using MaybeWrapped = typename mozilla::Conditional< - MapTypeToRootKind<T>::kind == JS::RootKind::Traceable, - js::DispatchWrapper<T>, - T>::Type; - MaybeWrapped ptr; -} JS_HAZ_ROOTED; - -class JS_PUBLIC_API(ObjectPtr) -{ - Heap<JSObject*> value; - - public: - ObjectPtr() : value(nullptr) {} - - explicit ObjectPtr(JSObject* obj) : value(obj) {} - - /* Always call finalize before the destructor. */ - ~ObjectPtr() { MOZ_ASSERT(!value); } - - void finalize(JSRuntime* rt); - void finalize(JSContext* cx); - - void init(JSObject* obj) { value = obj; } - - JSObject* get() const { return value; } - JSObject* unbarrieredGet() const { return value.unbarrieredGet(); } - - void writeBarrierPre(JSContext* cx) { - IncrementalObjectBarrier(value); - } - - void updateWeakPointerAfterGC(); - - ObjectPtr& operator=(JSObject* obj) { - IncrementalObjectBarrier(value); - value = obj; - return *this; - } - - void trace(JSTracer* trc, const char* name); - - JSObject& operator*() const { return *value; } - JSObject* operator->() const { return value; } - operator JSObject*() const { return value; } - - explicit operator bool() const { return value.unbarrieredGet(); } - explicit operator bool() { return value.unbarrieredGet(); } -}; - -} /* namespace JS */ - -namespace js { - -template <typename Outer, typename T, typename D> -class UniquePtrOperations -{ - const UniquePtr<T, D>& uniquePtr() const { return static_cast<const Outer*>(this)->get(); } - - public: - explicit operator bool() const { return !!uniquePtr(); } -}; - -template <typename Outer, typename T, typename D> -class MutableUniquePtrOperations : public UniquePtrOperations<Outer, T, D> -{ - UniquePtr<T, D>& uniquePtr() { return static_cast<Outer*>(this)->get(); } - - public: - MOZ_MUST_USE typename UniquePtr<T, D>::Pointer release() { return uniquePtr().release(); } -}; - -template <typename T, typename D> -class RootedBase<UniquePtr<T, D>> - : public MutableUniquePtrOperations<JS::Rooted<UniquePtr<T, D>>, T, D> -{ }; - -template <typename T, typename D> -class MutableHandleBase<UniquePtr<T, D>> - : public MutableUniquePtrOperations<JS::MutableHandle<UniquePtr<T, D>>, T, D> -{ }; - -template <typename T, typename D> -class HandleBase<UniquePtr<T, D>> - : public UniquePtrOperations<JS::Handle<UniquePtr<T, D>>, T, D> -{ }; - -template <typename T, typename D> -class PersistentRootedBase<UniquePtr<T, D>> - : public MutableUniquePtrOperations<JS::PersistentRooted<UniquePtr<T, D>>, T, D> -{ }; - -namespace gc { - -template <typename T, typename TraceCallbacks> -void -CallTraceCallbackOnNonHeap(T* v, const TraceCallbacks& aCallbacks, const char* aName, void* aClosure) -{ - static_assert(sizeof(T) == sizeof(JS::Heap<T>), "T and Heap<T> must be compatible."); - MOZ_ASSERT(v); - mozilla::DebugOnly<Cell*> cell = BarrierMethods<T>::asGCThingOrNull(*v); - MOZ_ASSERT(cell); - MOZ_ASSERT(!IsInsideNursery(cell)); - JS::Heap<T>* asHeapT = reinterpret_cast<JS::Heap<T>*>(v); - aCallbacks.Trace(asHeapT, aName, aClosure); -} - -} /* namespace gc */ -} /* namespace js */ - -// mozilla::Swap uses a stack temporary, which prevents classes like Heap<T> -// from being declared MOZ_HEAP_CLASS. -namespace mozilla { - -template <typename T> -inline void -Swap(JS::Heap<T>& aX, JS::Heap<T>& aY) -{ - T tmp = aX; - aX = aY; - aY = tmp; -} - -template <typename T> -inline void -Swap(JS::TenuredHeap<T>& aX, JS::TenuredHeap<T>& aY) -{ - T tmp = aX; - aX = aY; - aY = tmp; -} - -} /* namespace mozilla */ - -#undef DELETE_ASSIGNMENT_OPS - -#endif /* js_RootingAPI_h */ diff --git a/android/armeabi/include/spidermonkey/js/SliceBudget.h b/android/armeabi/include/spidermonkey/js/SliceBudget.h deleted file mode 100644 index 78982df0..00000000 --- a/android/armeabi/include/spidermonkey/js/SliceBudget.h +++ /dev/null @@ -1,91 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_SliceBudget_h -#define js_SliceBudget_h - -#include <stdint.h> - -namespace js { - -struct JS_PUBLIC_API(TimeBudget) -{ - int64_t budget; - - explicit TimeBudget(int64_t milliseconds) { budget = milliseconds; } -}; - -struct JS_PUBLIC_API(WorkBudget) -{ - int64_t budget; - - explicit WorkBudget(int64_t work) { budget = work; } -}; - -/* - * This class records how much work has been done in a given collection slice, - * so that we can return before pausing for too long. Some slices are allowed - * to run for unlimited time, and others are bounded. To reduce the number of - * gettimeofday calls, we only check the time every 1000 operations. - */ -class JS_PUBLIC_API(SliceBudget) -{ - static const int64_t unlimitedDeadline = INT64_MAX; - static const intptr_t unlimitedStartCounter = INTPTR_MAX; - - bool checkOverBudget(); - - SliceBudget(); - - public: - // Memory of the originally requested budget. If isUnlimited, neither of - // these are in use. If deadline==0, then workBudget is valid. Otherwise - // timeBudget is valid. - TimeBudget timeBudget; - WorkBudget workBudget; - - int64_t deadline; /* in microseconds */ - intptr_t counter; - - static const intptr_t CounterReset = 1000; - - static const int64_t UnlimitedTimeBudget = -1; - static const int64_t UnlimitedWorkBudget = -1; - - /* Use to create an unlimited budget. */ - static SliceBudget unlimited() { return SliceBudget(); } - - /* Instantiate as SliceBudget(TimeBudget(n)). */ - explicit SliceBudget(TimeBudget time); - - /* Instantiate as SliceBudget(WorkBudget(n)). */ - explicit SliceBudget(WorkBudget work); - - void makeUnlimited() { - deadline = unlimitedDeadline; - counter = unlimitedStartCounter; - } - - void step(intptr_t amt = 1) { - counter -= amt; - } - - bool isOverBudget() { - if (counter > 0) - return false; - return checkOverBudget(); - } - - bool isWorkBudget() const { return deadline == 0; } - bool isTimeBudget() const { return deadline > 0 && !isUnlimited(); } - bool isUnlimited() const { return deadline == unlimitedDeadline; } - - int describe(char* buffer, size_t maxlen) const; -}; - -} // namespace js - -#endif /* js_SliceBudget_h */ diff --git a/android/armeabi/include/spidermonkey/js/StructuredClone.h b/android/armeabi/include/spidermonkey/js/StructuredClone.h deleted file mode 100644 index e10a3073..00000000 --- a/android/armeabi/include/spidermonkey/js/StructuredClone.h +++ /dev/null @@ -1,358 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_StructuredClone_h -#define js_StructuredClone_h - -#include "mozilla/Attributes.h" -#include "mozilla/BufferList.h" - -#include <stdint.h> - -#include "jstypes.h" - -#include "js/RootingAPI.h" -#include "js/TypeDecls.h" -#include "js/Value.h" - -struct JSRuntime; -struct JSStructuredCloneReader; -struct JSStructuredCloneWriter; - -// API for the HTML5 internal structured cloning algorithm. - -namespace JS { - -enum class StructuredCloneScope : uint32_t { - SameProcessSameThread, - SameProcessDifferentThread, - DifferentProcess -}; - -enum TransferableOwnership { - /** Transferable data has not been filled in yet */ - SCTAG_TMO_UNFILLED = 0, - - /** Structured clone buffer does not yet own the data */ - SCTAG_TMO_UNOWNED = 1, - - /** All values at least this large are owned by the clone buffer */ - SCTAG_TMO_FIRST_OWNED = 2, - - /** Data is a pointer that can be freed */ - SCTAG_TMO_ALLOC_DATA = 2, - - /** Data is a memory mapped pointer */ - SCTAG_TMO_MAPPED_DATA = 3, - - /** - * Data is embedding-specific. The engine can free it by calling the - * freeTransfer op. The embedding can also use SCTAG_TMO_USER_MIN and - * greater, up to 32 bits, to distinguish specific ownership variants. - */ - SCTAG_TMO_CUSTOM = 4, - - SCTAG_TMO_USER_MIN -}; - -class CloneDataPolicy -{ - bool sharedArrayBuffer_; - - public: - // The default is to allow all policy-controlled aspects. - - CloneDataPolicy() : - sharedArrayBuffer_(true) - {} - - // In the JS engine, SharedArrayBuffers can only be cloned intra-process - // because the shared memory areas are allocated in process-private memory. - // Clients should therefore deny SharedArrayBuffers when cloning data that - // are to be transmitted inter-process. - // - // Clients should also deny SharedArrayBuffers when cloning data that are to - // be transmitted intra-process if policy needs dictate such denial. - - CloneDataPolicy& denySharedArrayBuffer() { - sharedArrayBuffer_ = false; - return *this; - } - - bool isSharedArrayBufferAllowed() const { - return sharedArrayBuffer_; - } -}; - -} /* namespace JS */ - -/** - * Read structured data from the reader r. This hook is used to read a value - * previously serialized by a call to the WriteStructuredCloneOp hook. - * - * tag and data are the pair of uint32_t values from the header. The callback - * may use the JS_Read* APIs to read any other relevant parts of the object - * from the reader r. closure is any value passed to the JS_ReadStructuredClone - * function. Return the new object on success, nullptr on error/exception. - */ -typedef JSObject* (*ReadStructuredCloneOp)(JSContext* cx, JSStructuredCloneReader* r, - uint32_t tag, uint32_t data, void* closure); - -/** - * Structured data serialization hook. The engine can write primitive values, - * Objects, Arrays, Dates, RegExps, TypedArrays, ArrayBuffers, Sets, Maps, - * and SharedTypedArrays. Any other type of object requires application support. - * This callback must first use the JS_WriteUint32Pair API to write an object - * header, passing a value greater than JS_SCTAG_USER to the tag parameter. - * Then it can use the JS_Write* APIs to write any other relevant parts of - * the value v to the writer w. closure is any value passed to the - * JS_WriteStructuredClone function. - * - * Return true on success, false on error/exception. - */ -typedef bool (*WriteStructuredCloneOp)(JSContext* cx, JSStructuredCloneWriter* w, - JS::HandleObject obj, void* closure); - -/** - * This is called when JS_WriteStructuredClone is given an invalid transferable. - * To follow HTML5, the application must throw a DATA_CLONE_ERR DOMException - * with error set to one of the JS_SCERR_* values. - */ -typedef void (*StructuredCloneErrorOp)(JSContext* cx, uint32_t errorid); - -/** - * This is called when JS_ReadStructuredClone receives a transferable object - * not known to the engine. If this hook does not exist or returns false, the - * JS engine calls the reportError op if set, otherwise it throws a - * DATA_CLONE_ERR DOM Exception. This method is called before any other - * callback and must return a non-null object in returnObject on success. - */ -typedef bool (*ReadTransferStructuredCloneOp)(JSContext* cx, JSStructuredCloneReader* r, - uint32_t tag, void* content, uint64_t extraData, - void* closure, - JS::MutableHandleObject returnObject); - -/** - * Called when JS_WriteStructuredClone receives a transferable object not - * handled by the engine. If this hook does not exist or returns false, the JS - * engine will call the reportError hook or fall back to throwing a - * DATA_CLONE_ERR DOM Exception. This method is called before any other - * callback. - * - * tag: indicates what type of transferable this is. Must be greater than - * 0xFFFF0201 (value of the internal SCTAG_TRANSFER_MAP_PENDING_ENTRY) - * - * ownership: see TransferableOwnership, above. Used to communicate any needed - * ownership info to the FreeTransferStructuredCloneOp. - * - * content, extraData: what the ReadTransferStructuredCloneOp will receive - */ -typedef bool (*TransferStructuredCloneOp)(JSContext* cx, - JS::Handle<JSObject*> obj, - void* closure, - // Output: - uint32_t* tag, - JS::TransferableOwnership* ownership, - void** content, - uint64_t* extraData); - -/** - * Called when freeing an unknown transferable object. Note that it - * should never trigger a garbage collection (and will assert in a - * debug build if it does.) - */ -typedef void (*FreeTransferStructuredCloneOp)(uint32_t tag, JS::TransferableOwnership ownership, - void* content, uint64_t extraData, void* closure); - -// The maximum supported structured-clone serialization format version. -// Increment this when anything at all changes in the serialization format. -// (Note that this does not need to be bumped for Transferable-only changes, -// since they are never saved to persistent storage.) -#define JS_STRUCTURED_CLONE_VERSION 8 - -struct JSStructuredCloneCallbacks { - ReadStructuredCloneOp read; - WriteStructuredCloneOp write; - StructuredCloneErrorOp reportError; - ReadTransferStructuredCloneOp readTransfer; - TransferStructuredCloneOp writeTransfer; - FreeTransferStructuredCloneOp freeTransfer; -}; - -enum OwnTransferablePolicy { - OwnsTransferablesIfAny, - IgnoreTransferablesIfAny, - NoTransferables -}; - -class MOZ_NON_MEMMOVABLE JSStructuredCloneData : public mozilla::BufferList<js::SystemAllocPolicy> -{ - typedef js::SystemAllocPolicy AllocPolicy; - typedef mozilla::BufferList<js::SystemAllocPolicy> BufferList; - - static const size_t kInitialSize = 0; - static const size_t kInitialCapacity = 4096; - static const size_t kStandardCapacity = 4096; - - const JSStructuredCloneCallbacks* callbacks_; - void* closure_; - OwnTransferablePolicy ownTransferables_; - - void setOptionalCallbacks(const JSStructuredCloneCallbacks* callbacks, - void* closure, - OwnTransferablePolicy policy) { - callbacks_ = callbacks; - closure_ = closure; - ownTransferables_ = policy; - } - - friend struct JSStructuredCloneWriter; - friend class JS_PUBLIC_API(JSAutoStructuredCloneBuffer); - -public: - explicit JSStructuredCloneData(AllocPolicy aAP = AllocPolicy()) - : BufferList(kInitialSize, kInitialCapacity, kStandardCapacity, aAP) - , callbacks_(nullptr) - , closure_(nullptr) - , ownTransferables_(OwnTransferablePolicy::NoTransferables) - {} - MOZ_IMPLICIT JSStructuredCloneData(BufferList&& buffers) - : BufferList(Move(buffers)) - , callbacks_(nullptr) - , closure_(nullptr) - , ownTransferables_(OwnTransferablePolicy::NoTransferables) - {} - JSStructuredCloneData(JSStructuredCloneData&& other) = default; - JSStructuredCloneData& operator=(JSStructuredCloneData&& other) = default; - ~JSStructuredCloneData(); - - using BufferList::BufferList; -}; - -/** Note: if the *data contains transferable objects, it can be read only once. */ -JS_PUBLIC_API(bool) -JS_ReadStructuredClone(JSContext* cx, JSStructuredCloneData& data, uint32_t version, - JS::StructuredCloneScope scope, - JS::MutableHandleValue vp, - const JSStructuredCloneCallbacks* optionalCallbacks, void* closure); - -JS_PUBLIC_API(bool) -JS_WriteStructuredClone(JSContext* cx, JS::HandleValue v, JSStructuredCloneData* data, - JS::StructuredCloneScope scope, - JS::CloneDataPolicy cloneDataPolicy, - const JSStructuredCloneCallbacks* optionalCallbacks, - void* closure, JS::HandleValue transferable); - -JS_PUBLIC_API(bool) -JS_StructuredCloneHasTransferables(JSStructuredCloneData& data, bool* hasTransferable); - -JS_PUBLIC_API(bool) -JS_StructuredClone(JSContext* cx, JS::HandleValue v, JS::MutableHandleValue vp, - const JSStructuredCloneCallbacks* optionalCallbacks, void* closure); - -/** RAII sugar for JS_WriteStructuredClone. */ -class JS_PUBLIC_API(JSAutoStructuredCloneBuffer) { - const JS::StructuredCloneScope scope_; - JSStructuredCloneData data_; - uint32_t version_; - - public: - JSAutoStructuredCloneBuffer(JS::StructuredCloneScope scope, - const JSStructuredCloneCallbacks* callbacks, void* closure) - : scope_(scope), version_(JS_STRUCTURED_CLONE_VERSION) - { - data_.setOptionalCallbacks(callbacks, closure, OwnTransferablePolicy::NoTransferables); - } - - JSAutoStructuredCloneBuffer(JSAutoStructuredCloneBuffer&& other); - JSAutoStructuredCloneBuffer& operator=(JSAutoStructuredCloneBuffer&& other); - - ~JSAutoStructuredCloneBuffer() { clear(); } - - JSStructuredCloneData& data() { return data_; } - bool empty() const { return !data_.Size(); } - - void clear(const JSStructuredCloneCallbacks* optionalCallbacks=nullptr, void* closure=nullptr); - - /** Copy some memory. It will be automatically freed by the destructor. */ - bool copy(const JSStructuredCloneData& data, uint32_t version=JS_STRUCTURED_CLONE_VERSION, - const JSStructuredCloneCallbacks* callbacks=nullptr, void* closure=nullptr); - - /** - * Adopt some memory. It will be automatically freed by the destructor. - * data must have been allocated by the JS engine (e.g., extracted via - * JSAutoStructuredCloneBuffer::steal). - */ - void adopt(JSStructuredCloneData&& data, uint32_t version=JS_STRUCTURED_CLONE_VERSION, - const JSStructuredCloneCallbacks* callbacks=nullptr, void* closure=nullptr); - - /** - * Release the buffer and transfer ownership to the caller. - */ - void steal(JSStructuredCloneData* data, uint32_t* versionp=nullptr, - const JSStructuredCloneCallbacks** callbacks=nullptr, void** closure=nullptr); - - /** - * Abandon ownership of any transferable objects stored in the buffer, - * without freeing the buffer itself. Useful when copying the data out into - * an external container, though note that you will need to use adopt() to - * properly release that data eventually. - */ - void abandon() { data_.ownTransferables_ = OwnTransferablePolicy::IgnoreTransferablesIfAny; } - - bool read(JSContext* cx, JS::MutableHandleValue vp, - const JSStructuredCloneCallbacks* optionalCallbacks=nullptr, void* closure=nullptr); - - bool write(JSContext* cx, JS::HandleValue v, - const JSStructuredCloneCallbacks* optionalCallbacks=nullptr, void* closure=nullptr); - - bool write(JSContext* cx, JS::HandleValue v, JS::HandleValue transferable, - JS::CloneDataPolicy cloneDataPolicy, - const JSStructuredCloneCallbacks* optionalCallbacks=nullptr, void* closure=nullptr); - - private: - // Copy and assignment are not supported. - JSAutoStructuredCloneBuffer(const JSAutoStructuredCloneBuffer& other) = delete; - JSAutoStructuredCloneBuffer& operator=(const JSAutoStructuredCloneBuffer& other) = delete; -}; - -// The range of tag values the application may use for its own custom object types. -#define JS_SCTAG_USER_MIN ((uint32_t) 0xFFFF8000) -#define JS_SCTAG_USER_MAX ((uint32_t) 0xFFFFFFFF) - -#define JS_SCERR_RECURSION 0 -#define JS_SCERR_TRANSFERABLE 1 -#define JS_SCERR_DUP_TRANSFERABLE 2 -#define JS_SCERR_UNSUPPORTED_TYPE 3 - -JS_PUBLIC_API(bool) -JS_ReadUint32Pair(JSStructuredCloneReader* r, uint32_t* p1, uint32_t* p2); - -JS_PUBLIC_API(bool) -JS_ReadBytes(JSStructuredCloneReader* r, void* p, size_t len); - -JS_PUBLIC_API(bool) -JS_ReadTypedArray(JSStructuredCloneReader* r, JS::MutableHandleValue vp); - -JS_PUBLIC_API(bool) -JS_WriteUint32Pair(JSStructuredCloneWriter* w, uint32_t tag, uint32_t data); - -JS_PUBLIC_API(bool) -JS_WriteBytes(JSStructuredCloneWriter* w, const void* p, size_t len); - -JS_PUBLIC_API(bool) -JS_WriteString(JSStructuredCloneWriter* w, JS::HandleString str); - -JS_PUBLIC_API(bool) -JS_WriteTypedArray(JSStructuredCloneWriter* w, JS::HandleValue v); - -JS_PUBLIC_API(bool) -JS_ObjectNotWritten(JSStructuredCloneWriter* w, JS::HandleObject obj); - -JS_PUBLIC_API(JS::StructuredCloneScope) -JS_GetStructuredCloneScope(JSStructuredCloneWriter* w); - -#endif /* js_StructuredClone_h */ diff --git a/android/armeabi/include/spidermonkey/js/SweepingAPI.h b/android/armeabi/include/spidermonkey/js/SweepingAPI.h deleted file mode 100644 index 0eb29ae4..00000000 --- a/android/armeabi/include/spidermonkey/js/SweepingAPI.h +++ /dev/null @@ -1,65 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_SweepingAPI_h -#define js_SweepingAPI_h - -#include "js/HeapAPI.h" - -namespace js { -template <typename T> -class WeakCacheBase {}; -} // namespace js - -namespace JS { -template <typename T> class WeakCache; - -namespace shadow { -JS_PUBLIC_API(void) -RegisterWeakCache(JS::Zone* zone, JS::WeakCache<void*>* cachep); -} // namespace shadow - -// A WeakCache stores the given Sweepable container and links itself into a -// list of such caches that are swept during each GC. -template <typename T> -class WeakCache : public js::WeakCacheBase<T>, - private mozilla::LinkedListElement<WeakCache<T>> -{ - friend class mozilla::LinkedListElement<WeakCache<T>>; - friend class mozilla::LinkedList<WeakCache<T>>; - - WeakCache() = delete; - WeakCache(const WeakCache&) = delete; - - using SweepFn = void (*)(T*); - SweepFn sweeper; - T cache; - - public: - using Type = T; - - template <typename U> - WeakCache(Zone* zone, U&& initial) - : cache(mozilla::Forward<U>(initial)) - { - sweeper = GCPolicy<T>::sweep; - shadow::RegisterWeakCache(zone, reinterpret_cast<WeakCache<void*>*>(this)); - } - WeakCache(WeakCache&& other) - : sweeper(other.sweeper), - cache(mozilla::Move(other.cache)) - { - } - - const T& get() const { return cache; } - T& get() { return cache; } - - void sweep() { sweeper(&cache); } -}; - -} // namespace JS - -#endif // js_SweepingAPI_h diff --git a/android/armeabi/include/spidermonkey/js/TraceKind.h b/android/armeabi/include/spidermonkey/js/TraceKind.h deleted file mode 100644 index 2eda9cb2..00000000 --- a/android/armeabi/include/spidermonkey/js/TraceKind.h +++ /dev/null @@ -1,212 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_TraceKind_h -#define js_TraceKind_h - -#include "mozilla/UniquePtr.h" - -#include "js/TypeDecls.h" - -// Forward declarations of all the types a TraceKind can denote. -namespace js { -class BaseShape; -class LazyScript; -class ObjectGroup; -class Shape; -class Scope; -namespace jit { -class JitCode; -} // namespace jit -} // namespace js - -namespace JS { - -// When tracing a thing, the GC needs to know about the layout of the object it -// is looking at. There are a fixed number of different layouts that the GC -// knows about. The "trace kind" is a static map which tells which layout a GC -// thing has. -// -// Although this map is public, the details are completely hidden. Not all of -// the matching C++ types are exposed, and those that are, are opaque. -// -// See Value::gcKind() and JSTraceCallback in Tracer.h for more details. -enum class TraceKind -{ - // These trace kinds have a publicly exposed, although opaque, C++ type. - // Note: The order here is determined by our Value packing. Other users - // should sort alphabetically, for consistency. - Object = 0x00, - String = 0x01, - Symbol = 0x02, - Script = 0x03, - - // Shape details are exposed through JS_TraceShapeCycleCollectorChildren. - Shape = 0x04, - - // ObjectGroup details are exposed through JS_TraceObjectGroupCycleCollectorChildren. - ObjectGroup = 0x05, - - // The kind associated with a nullptr. - Null = 0x06, - - // The following kinds do not have an exposed C++ idiom. - BaseShape = 0x0F, - JitCode = 0x1F, - LazyScript = 0x2F, - Scope = 0x3F -}; -const static uintptr_t OutOfLineTraceKindMask = 0x07; -static_assert(uintptr_t(JS::TraceKind::BaseShape) & OutOfLineTraceKindMask, "mask bits are set"); -static_assert(uintptr_t(JS::TraceKind::JitCode) & OutOfLineTraceKindMask, "mask bits are set"); -static_assert(uintptr_t(JS::TraceKind::LazyScript) & OutOfLineTraceKindMask, "mask bits are set"); -static_assert(uintptr_t(JS::TraceKind::Scope) & OutOfLineTraceKindMask, "mask bits are set"); - -// When this header is imported inside SpiderMonkey, the class definitions are -// available and we can query those definitions to find the correct kind -// directly from the class hierarchy. -template <typename T> -struct MapTypeToTraceKind { - static const JS::TraceKind kind = T::TraceKind; -}; - -// When this header is used outside SpiderMonkey, the class definitions are not -// available, so the following table containing all public GC types is used. -#define JS_FOR_EACH_TRACEKIND(D) \ - /* PrettyName TypeName AddToCCKind */ \ - D(BaseShape, js::BaseShape, true) \ - D(JitCode, js::jit::JitCode, true) \ - D(LazyScript, js::LazyScript, true) \ - D(Scope, js::Scope, true) \ - D(Object, JSObject, true) \ - D(ObjectGroup, js::ObjectGroup, true) \ - D(Script, JSScript, true) \ - D(Shape, js::Shape, true) \ - D(String, JSString, false) \ - D(Symbol, JS::Symbol, false) - -// Map from all public types to their trace kind. -#define JS_EXPAND_DEF(name, type, _) \ - template <> struct MapTypeToTraceKind<type> { \ - static const JS::TraceKind kind = JS::TraceKind::name; \ - }; -JS_FOR_EACH_TRACEKIND(JS_EXPAND_DEF); -#undef JS_EXPAND_DEF - -// RootKind is closely related to TraceKind. Whereas TraceKind's indices are -// laid out for convenient embedding as a pointer tag, the indicies of RootKind -// are designed for use as array keys via EnumeratedArray. -enum class RootKind : int8_t -{ - // These map 1:1 with trace kinds. -#define EXPAND_ROOT_KIND(name, _0, _1) \ - name, -JS_FOR_EACH_TRACEKIND(EXPAND_ROOT_KIND) -#undef EXPAND_ROOT_KIND - - // These tagged pointers are special-cased for performance. - Id, - Value, - - // Everything else. - Traceable, - - Limit -}; - -// Most RootKind correspond directly to a trace kind. -template <TraceKind traceKind> struct MapTraceKindToRootKind {}; -#define JS_EXPAND_DEF(name, _0, _1) \ - template <> struct MapTraceKindToRootKind<JS::TraceKind::name> { \ - static const JS::RootKind kind = JS::RootKind::name; \ - }; -JS_FOR_EACH_TRACEKIND(JS_EXPAND_DEF) -#undef JS_EXPAND_DEF - -// Specify the RootKind for all types. Value and jsid map to special cases; -// pointer types we can derive directly from the TraceKind; everything else -// should go in the Traceable list and use GCPolicy<T>::trace for tracing. -template <typename T> -struct MapTypeToRootKind { - static const JS::RootKind kind = JS::RootKind::Traceable; -}; -template <typename T> -struct MapTypeToRootKind<T*> { - static const JS::RootKind kind = - JS::MapTraceKindToRootKind<JS::MapTypeToTraceKind<T>::kind>::kind; -}; -template <typename T> -struct MapTypeToRootKind<mozilla::UniquePtr<T>> { - static const JS::RootKind kind = JS::MapTypeToRootKind<T>::kind; -}; -template <> struct MapTypeToRootKind<JS::Value> { - static const JS::RootKind kind = JS::RootKind::Value; -}; -template <> struct MapTypeToRootKind<jsid> { - static const JS::RootKind kind = JS::RootKind::Id; -}; -template <> struct MapTypeToRootKind<JSFunction*> : public MapTypeToRootKind<JSObject*> {}; - -// Fortunately, few places in the system need to deal with fully abstract -// cells. In those places that do, we generally want to move to a layout -// templated function as soon as possible. This template wraps the upcast -// for that dispatch. -// -// Given a call: -// -// DispatchTraceKindTyped(f, thing, traceKind, ... args) -// -// Downcast the |void *thing| to the specific type designated by |traceKind|, -// and pass it to the functor |f| along with |... args|, forwarded. Pass the -// type designated by |traceKind| as the functor's template argument. The -// |thing| parameter is optional; without it, we simply pass through |... args|. - -// GCC and Clang require an explicit template declaration in front of the -// specialization of operator() because it is a dependent template. MSVC, on -// the other hand, gets very confused if we have a |template| token there. -// The clang-cl front end defines _MSC_VER, but still requires the explicit -// template declaration, so we must test for __clang__ here as well. -#if defined(_MSC_VER) && !defined(__clang__) -# define JS_DEPENDENT_TEMPLATE_HINT -#else -# define JS_DEPENDENT_TEMPLATE_HINT template -#endif -template <typename F, typename... Args> -auto -DispatchTraceKindTyped(F f, JS::TraceKind traceKind, Args&&... args) - -> decltype(f. JS_DEPENDENT_TEMPLATE_HINT operator()<JSObject>(mozilla::Forward<Args>(args)...)) -{ - switch (traceKind) { -#define JS_EXPAND_DEF(name, type, _) \ - case JS::TraceKind::name: \ - return f. JS_DEPENDENT_TEMPLATE_HINT operator()<type>(mozilla::Forward<Args>(args)...); - JS_FOR_EACH_TRACEKIND(JS_EXPAND_DEF); -#undef JS_EXPAND_DEF - default: - MOZ_CRASH("Invalid trace kind in DispatchTraceKindTyped."); - } -} -#undef JS_DEPENDENT_TEMPLATE_HINT - -template <typename F, typename... Args> -auto -DispatchTraceKindTyped(F f, void* thing, JS::TraceKind traceKind, Args&&... args) - -> decltype(f(static_cast<JSObject*>(nullptr), mozilla::Forward<Args>(args)...)) -{ - switch (traceKind) { -#define JS_EXPAND_DEF(name, type, _) \ - case JS::TraceKind::name: \ - return f(static_cast<type*>(thing), mozilla::Forward<Args>(args)...); - JS_FOR_EACH_TRACEKIND(JS_EXPAND_DEF); -#undef JS_EXPAND_DEF - default: - MOZ_CRASH("Invalid trace kind in DispatchTraceKindTyped."); - } -} - -} // namespace JS - -#endif // js_TraceKind_h diff --git a/android/armeabi/include/spidermonkey/js/TracingAPI.h b/android/armeabi/include/spidermonkey/js/TracingAPI.h deleted file mode 100644 index 37c69aca..00000000 --- a/android/armeabi/include/spidermonkey/js/TracingAPI.h +++ /dev/null @@ -1,403 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_TracingAPI_h -#define js_TracingAPI_h - -#include "jsalloc.h" - -#include "js/HashTable.h" -#include "js/HeapAPI.h" -#include "js/TraceKind.h" - -class JS_PUBLIC_API(JSTracer); - -namespace JS { -class JS_PUBLIC_API(CallbackTracer); -template <typename T> class Heap; -template <typename T> class TenuredHeap; - -/** Returns a static string equivalent of |kind|. */ -JS_FRIEND_API(const char*) -GCTraceKindToAscii(JS::TraceKind kind); - -} // namespace JS - -enum WeakMapTraceKind { - /** - * Do not trace into weak map keys or values during traversal. Users must - * handle weak maps manually. - */ - DoNotTraceWeakMaps, - - /** - * Do true ephemeron marking with a weak key lookup marking phase. This is - * the default for GCMarker. - */ - ExpandWeakMaps, - - /** - * Trace through to all values, irrespective of whether the keys are live - * or not. Used for non-marking tracers. - */ - TraceWeakMapValues, - - /** - * Trace through to all keys and values, irrespective of whether the keys - * are live or not. Used for non-marking tracers. - */ - TraceWeakMapKeysValues -}; - -class JS_PUBLIC_API(JSTracer) -{ - public: - // Return the runtime set on the tracer. - JSRuntime* runtime() const { return runtime_; } - - // Return the weak map tracing behavior currently set on this tracer. - WeakMapTraceKind weakMapAction() const { return weakMapAction_; } - - enum class TracerKindTag { - // Marking path: a tracer used only for marking liveness of cells, not - // for moving them. The kind will transition to WeakMarking after - // everything reachable by regular edges has been marked. - Marking, - - // Same as Marking, except we have now moved on to the "weak marking - // phase", in which every marked obj/script is immediately looked up to - // see if it is a weak map key (and therefore might require marking its - // weak map value). - WeakMarking, - - // A tracer that traverses the graph for the purposes of moving objects - // from the nursery to the tenured area. - Tenuring, - - // General-purpose traversal that invokes a callback on each cell. - // Traversing children is the responsibility of the callback. - Callback - }; - bool isMarkingTracer() const { return tag_ == TracerKindTag::Marking || tag_ == TracerKindTag::WeakMarking; } - bool isWeakMarkingTracer() const { return tag_ == TracerKindTag::WeakMarking; } - bool isTenuringTracer() const { return tag_ == TracerKindTag::Tenuring; } - bool isCallbackTracer() const { return tag_ == TracerKindTag::Callback; } - inline JS::CallbackTracer* asCallbackTracer(); -#ifdef DEBUG - bool checkEdges() { return checkEdges_; } -#endif - - protected: - JSTracer(JSRuntime* rt, TracerKindTag tag, - WeakMapTraceKind weakTraceKind = TraceWeakMapValues) - : runtime_(rt) - , weakMapAction_(weakTraceKind) -#ifdef DEBUG - , checkEdges_(true) -#endif - , tag_(tag) - {} - -#ifdef DEBUG - // Set whether to check edges are valid in debug builds. - void setCheckEdges(bool check) { - checkEdges_ = check; - } -#endif - - private: - JSRuntime* runtime_; - WeakMapTraceKind weakMapAction_; -#ifdef DEBUG - bool checkEdges_; -#endif - - protected: - TracerKindTag tag_; -}; - -namespace JS { - -class AutoTracingName; -class AutoTracingIndex; -class AutoTracingCallback; - -class JS_PUBLIC_API(CallbackTracer) : public JSTracer -{ - public: - CallbackTracer(JSRuntime* rt, WeakMapTraceKind weakTraceKind = TraceWeakMapValues) - : JSTracer(rt, JSTracer::TracerKindTag::Callback, weakTraceKind), - contextName_(nullptr), contextIndex_(InvalidIndex), contextFunctor_(nullptr) - {} - CallbackTracer(JSContext* cx, WeakMapTraceKind weakTraceKind = TraceWeakMapValues); - - // Override these methods to receive notification when an edge is visited - // with the type contained in the callback. The default implementation - // dispatches to the fully-generic onChild implementation, so for cases that - // do not care about boxing overhead and do not need the actual edges, - // just override the generic onChild. - virtual void onObjectEdge(JSObject** objp) { onChild(JS::GCCellPtr(*objp)); } - virtual void onStringEdge(JSString** strp) { onChild(JS::GCCellPtr(*strp)); } - virtual void onSymbolEdge(JS::Symbol** symp) { onChild(JS::GCCellPtr(*symp)); } - virtual void onScriptEdge(JSScript** scriptp) { onChild(JS::GCCellPtr(*scriptp)); } - virtual void onShapeEdge(js::Shape** shapep) { - onChild(JS::GCCellPtr(*shapep, JS::TraceKind::Shape)); - } - virtual void onObjectGroupEdge(js::ObjectGroup** groupp) { - onChild(JS::GCCellPtr(*groupp, JS::TraceKind::ObjectGroup)); - } - virtual void onBaseShapeEdge(js::BaseShape** basep) { - onChild(JS::GCCellPtr(*basep, JS::TraceKind::BaseShape)); - } - virtual void onJitCodeEdge(js::jit::JitCode** codep) { - onChild(JS::GCCellPtr(*codep, JS::TraceKind::JitCode)); - } - virtual void onLazyScriptEdge(js::LazyScript** lazyp) { - onChild(JS::GCCellPtr(*lazyp, JS::TraceKind::LazyScript)); - } - virtual void onScopeEdge(js::Scope** scopep) { - onChild(JS::GCCellPtr(*scopep, JS::TraceKind::Scope)); - } - - // Override this method to receive notification when a node in the GC - // heap graph is visited. - virtual void onChild(const JS::GCCellPtr& thing) = 0; - - // Access to the tracing context: - // When tracing with a JS::CallbackTracer, we invoke the callback with the - // edge location and the type of target. This is useful for operating on - // the edge in the abstract or on the target thing, satisfying most common - // use cases. However, some tracers need additional detail about the - // specific edge that is being traced in order to be useful. Unfortunately, - // the raw pointer to the edge that we provide is not enough information to - // infer much of anything useful about that edge. - // - // In order to better support use cases that care in particular about edges - // -- as opposed to the target thing -- tracing implementations are - // responsible for providing extra context information about each edge they - // trace, as it is traced. This contains, at a minimum, an edge name and, - // when tracing an array, the index. Further specialization can be achived - // (with some complexity), by associating a functor with the tracer so - // that, when requested, the user can generate totally custom edge - // descriptions. - - // Returns the current edge's name. It is only valid to call this when - // inside the trace callback, however, the edge name will always be set. - const char* contextName() const { MOZ_ASSERT(contextName_); return contextName_; } - - // Returns the current edge's index, if marked as part of an array of edges. - // This must be called only inside the trace callback. When not tracing an - // array, the value will be InvalidIndex. - const static size_t InvalidIndex = size_t(-1); - size_t contextIndex() const { return contextIndex_; } - - // Build a description of this edge in the heap graph. This call may invoke - // the context functor, if set, which may inspect arbitrary areas of the - // heap. On the other hand, the description provided by this method may be - // substantially more accurate and useful than those provided by only the - // contextName and contextIndex. - void getTracingEdgeName(char* buffer, size_t bufferSize); - - // The trace implementation may associate a callback with one or more edges - // using AutoTracingDetails. This functor is called by getTracingEdgeName - // and is responsible for providing a textual representation of the - // currently being traced edge. The callback has access to the full heap, - // including the currently set tracing context. - class ContextFunctor { - public: - virtual void operator()(CallbackTracer* trc, char* buf, size_t bufsize) = 0; - }; - -#ifdef DEBUG - enum class TracerKind { DoNotCare, Moving, GrayBuffering, VerifyTraceProtoAndIface }; - virtual TracerKind getTracerKind() const { return TracerKind::DoNotCare; } -#endif - - // In C++, overriding a method hides all methods in the base class with - // that name, not just methods with that signature. Thus, the typed edge - // methods have to have distinct names to allow us to override them - // individually, which is freqently useful if, for example, we only want to - // process only one type of edge. - void dispatchToOnEdge(JSObject** objp) { onObjectEdge(objp); } - void dispatchToOnEdge(JSString** strp) { onStringEdge(strp); } - void dispatchToOnEdge(JS::Symbol** symp) { onSymbolEdge(symp); } - void dispatchToOnEdge(JSScript** scriptp) { onScriptEdge(scriptp); } - void dispatchToOnEdge(js::Shape** shapep) { onShapeEdge(shapep); } - void dispatchToOnEdge(js::ObjectGroup** groupp) { onObjectGroupEdge(groupp); } - void dispatchToOnEdge(js::BaseShape** basep) { onBaseShapeEdge(basep); } - void dispatchToOnEdge(js::jit::JitCode** codep) { onJitCodeEdge(codep); } - void dispatchToOnEdge(js::LazyScript** lazyp) { onLazyScriptEdge(lazyp); } - void dispatchToOnEdge(js::Scope** scopep) { onScopeEdge(scopep); } - - private: - friend class AutoTracingName; - const char* contextName_; - - friend class AutoTracingIndex; - size_t contextIndex_; - - friend class AutoTracingDetails; - ContextFunctor* contextFunctor_; -}; - -// Set the name portion of the tracer's context for the current edge. -class MOZ_RAII AutoTracingName -{ - CallbackTracer* trc_; - const char* prior_; - - public: - AutoTracingName(CallbackTracer* trc, const char* name) : trc_(trc), prior_(trc->contextName_) { - MOZ_ASSERT(name); - trc->contextName_ = name; - } - ~AutoTracingName() { - MOZ_ASSERT(trc_->contextName_); - trc_->contextName_ = prior_; - } -}; - -// Set the index portion of the tracer's context for the current range. -class MOZ_RAII AutoTracingIndex -{ - CallbackTracer* trc_; - - public: - explicit AutoTracingIndex(JSTracer* trc, size_t initial = 0) : trc_(nullptr) { - if (trc->isCallbackTracer()) { - trc_ = trc->asCallbackTracer(); - MOZ_ASSERT(trc_->contextIndex_ == CallbackTracer::InvalidIndex); - trc_->contextIndex_ = initial; - } - } - ~AutoTracingIndex() { - if (trc_) { - MOZ_ASSERT(trc_->contextIndex_ != CallbackTracer::InvalidIndex); - trc_->contextIndex_ = CallbackTracer::InvalidIndex; - } - } - - void operator++() { - if (trc_) { - MOZ_ASSERT(trc_->contextIndex_ != CallbackTracer::InvalidIndex); - ++trc_->contextIndex_; - } - } -}; - -// Set a context callback for the trace callback to use, if it needs a detailed -// edge description. -class MOZ_RAII AutoTracingDetails -{ - CallbackTracer* trc_; - - public: - AutoTracingDetails(JSTracer* trc, CallbackTracer::ContextFunctor& func) : trc_(nullptr) { - if (trc->isCallbackTracer()) { - trc_ = trc->asCallbackTracer(); - MOZ_ASSERT(trc_->contextFunctor_ == nullptr); - trc_->contextFunctor_ = &func; - } - } - ~AutoTracingDetails() { - if (trc_) { - MOZ_ASSERT(trc_->contextFunctor_); - trc_->contextFunctor_ = nullptr; - } - } -}; - -} // namespace JS - -JS::CallbackTracer* -JSTracer::asCallbackTracer() -{ - MOZ_ASSERT(isCallbackTracer()); - return static_cast<JS::CallbackTracer*>(this); -} - -namespace JS { - -// The JS::TraceEdge family of functions traces the given GC thing reference. -// This performs the tracing action configured on the given JSTracer: typically -// calling the JSTracer::callback or marking the thing as live. -// -// The argument to JS::TraceEdge is an in-out param: when the function returns, -// the garbage collector might have moved the GC thing. In this case, the -// reference passed to JS::TraceEdge will be updated to the thing's new -// location. Callers of this method are responsible for updating any state that -// is dependent on the object's address. For example, if the object's address -// is used as a key in a hashtable, then the object must be removed and -// re-inserted with the correct hash. -// -// Note that while |edgep| must never be null, it is fine for |*edgep| to be -// nullptr. -template <typename T> -extern JS_PUBLIC_API(void) -TraceEdge(JSTracer* trc, JS::Heap<T>* edgep, const char* name); - -extern JS_PUBLIC_API(void) -TraceEdge(JSTracer* trc, JS::TenuredHeap<JSObject*>* edgep, const char* name); - -// Edges that are always traced as part of root marking do not require -// incremental barriers. This function allows for marking non-barriered -// pointers, but asserts that this happens during root marking. -// -// Note that while |edgep| must never be null, it is fine for |*edgep| to be -// nullptr. -template <typename T> -extern JS_PUBLIC_API(void) -UnsafeTraceRoot(JSTracer* trc, T* edgep, const char* name); - -extern JS_PUBLIC_API(void) -TraceChildren(JSTracer* trc, GCCellPtr thing); - -using ZoneSet = js::HashSet<Zone*, js::DefaultHasher<Zone*>, js::SystemAllocPolicy>; -using CompartmentSet = js::HashSet<JSCompartment*, js::DefaultHasher<JSCompartment*>, - js::SystemAllocPolicy>; - -/** - * Trace every value within |compartments| that is wrapped by a - * cross-compartment wrapper from a compartment that is not an element of - * |compartments|. - */ -extern JS_PUBLIC_API(void) -TraceIncomingCCWs(JSTracer* trc, const JS::CompartmentSet& compartments); - -} // namespace JS - -extern JS_PUBLIC_API(void) -JS_GetTraceThingInfo(char* buf, size_t bufsize, JSTracer* trc, - void* thing, JS::TraceKind kind, bool includeDetails); - -namespace js { - -// Trace an edge that is not a GC root and is not wrapped in a barriered -// wrapper for some reason. -// -// This method does not check if |*edgep| is non-null before tracing through -// it, so callers must check any nullable pointer before calling this method. -template <typename T> -extern JS_PUBLIC_API(void) -UnsafeTraceManuallyBarrieredEdge(JSTracer* trc, T* edgep, const char* name); - -namespace gc { - -// Return true if the given edge is not live and is about to be swept. -template <typename T> -extern JS_PUBLIC_API(bool) -EdgeNeedsSweep(JS::Heap<T>* edgep); - -// Not part of the public API, but declared here so we can use it in GCPolicy -// which is. -template <typename T> -bool -IsAboutToBeFinalizedUnbarriered(T* thingp); - -} // namespace gc -} // namespace js - -#endif /* js_TracingAPI_h */ diff --git a/android/armeabi/include/spidermonkey/js/TrackedOptimizationInfo.h b/android/armeabi/include/spidermonkey/js/TrackedOptimizationInfo.h deleted file mode 100644 index b697765c..00000000 --- a/android/armeabi/include/spidermonkey/js/TrackedOptimizationInfo.h +++ /dev/null @@ -1,285 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_TrackedOptimizationInfo_h -#define js_TrackedOptimizationInfo_h - -#include "mozilla/Maybe.h" - -namespace JS { - -#define TRACKED_STRATEGY_LIST(_) \ - _(GetProp_ArgumentsLength) \ - _(GetProp_ArgumentsCallee) \ - _(GetProp_InferredConstant) \ - _(GetProp_Constant) \ - _(GetProp_NotDefined) \ - _(GetProp_StaticName) \ - _(GetProp_SimdGetter) \ - _(GetProp_TypedObject) \ - _(GetProp_DefiniteSlot) \ - _(GetProp_Unboxed) \ - _(GetProp_CommonGetter) \ - _(GetProp_InlineAccess) \ - _(GetProp_Innerize) \ - _(GetProp_InlineCache) \ - _(GetProp_SharedCache) \ - _(GetProp_ModuleNamespace) \ - \ - _(SetProp_CommonSetter) \ - _(SetProp_TypedObject) \ - _(SetProp_DefiniteSlot) \ - _(SetProp_Unboxed) \ - _(SetProp_InlineAccess) \ - _(SetProp_InlineCache) \ - \ - _(GetElem_TypedObject) \ - _(GetElem_Dense) \ - _(GetElem_TypedStatic) \ - _(GetElem_TypedArray) \ - _(GetElem_String) \ - _(GetElem_Arguments) \ - _(GetElem_ArgumentsInlined) \ - _(GetElem_InlineCache) \ - \ - _(SetElem_TypedObject) \ - _(SetElem_TypedStatic) \ - _(SetElem_TypedArray) \ - _(SetElem_Dense) \ - _(SetElem_Arguments) \ - _(SetElem_InlineCache) \ - \ - _(BinaryArith_Concat) \ - _(BinaryArith_SpecializedTypes) \ - _(BinaryArith_SpecializedOnBaselineTypes) \ - _(BinaryArith_SharedCache) \ - _(BinaryArith_Call) \ - \ - _(InlineCache_OptimizedStub) \ - \ - _(Call_Inline) - - -// Ordering is important below. All outcomes before GenericSuccess will be -// considered failures, and all outcomes after GenericSuccess will be -// considered successes. -#define TRACKED_OUTCOME_LIST(_) \ - _(GenericFailure) \ - _(Disabled) \ - _(NoTypeInfo) \ - _(NoAnalysisInfo) \ - _(NoShapeInfo) \ - _(UnknownObject) \ - _(UnknownProperties) \ - _(Singleton) \ - _(NotSingleton) \ - _(NotFixedSlot) \ - _(InconsistentFixedSlot) \ - _(NotObject) \ - _(NotStruct) \ - _(NotUnboxed) \ - _(NotUndefined) \ - _(UnboxedConvertedToNative) \ - _(StructNoField) \ - _(InconsistentFieldType) \ - _(InconsistentFieldOffset) \ - _(NeedsTypeBarrier) \ - _(InDictionaryMode) \ - _(NoProtoFound) \ - _(MultiProtoPaths) \ - _(NonWritableProperty) \ - _(ProtoIndexedProps) \ - _(ArrayBadFlags) \ - _(ArrayDoubleConversion) \ - _(ArrayRange) \ - _(ArraySeenNegativeIndex) \ - _(TypedObjectHasDetachedBuffer) \ - _(TypedObjectArrayRange) \ - _(AccessNotDense) \ - _(AccessNotSimdObject) \ - _(AccessNotTypedObject) \ - _(AccessNotTypedArray) \ - _(AccessNotString) \ - _(OperandNotString) \ - _(OperandNotNumber) \ - _(OperandNotStringOrNumber) \ - _(OperandNotSimpleArith) \ - _(StaticTypedArrayUint32) \ - _(StaticTypedArrayCantComputeMask) \ - _(OutOfBounds) \ - _(GetElemStringNotCached) \ - _(NonNativeReceiver) \ - _(IndexType) \ - _(SetElemNonDenseNonTANotCached) \ - _(NoSimdJitSupport) \ - _(SimdTypeNotOptimized) \ - _(UnknownSimdProperty) \ - _(NotModuleNamespace) \ - _(UnknownProperty) \ - \ - _(ICOptStub_GenericSuccess) \ - \ - _(ICGetPropStub_ReadSlot) \ - _(ICGetPropStub_CallGetter) \ - _(ICGetPropStub_ArrayLength) \ - _(ICGetPropStub_UnboxedRead) \ - _(ICGetPropStub_UnboxedReadExpando) \ - _(ICGetPropStub_UnboxedArrayLength) \ - _(ICGetPropStub_TypedArrayLength) \ - _(ICGetPropStub_DOMProxyShadowed) \ - _(ICGetPropStub_DOMProxyUnshadowed) \ - _(ICGetPropStub_GenericProxy) \ - _(ICGetPropStub_ArgumentsLength) \ - \ - _(ICSetPropStub_Slot) \ - _(ICSetPropStub_GenericProxy) \ - _(ICSetPropStub_DOMProxyShadowed) \ - _(ICSetPropStub_DOMProxyUnshadowed) \ - _(ICSetPropStub_CallSetter) \ - _(ICSetPropStub_AddSlot) \ - _(ICSetPropStub_SetUnboxed) \ - \ - _(ICGetElemStub_ReadSlot) \ - _(ICGetElemStub_CallGetter) \ - _(ICGetElemStub_ReadUnboxed) \ - _(ICGetElemStub_Dense) \ - _(ICGetElemStub_DenseHole) \ - _(ICGetElemStub_TypedArray) \ - _(ICGetElemStub_ArgsElementMapped) \ - _(ICGetElemStub_ArgsElementUnmapped) \ - \ - _(ICSetElemStub_Dense) \ - _(ICSetElemStub_TypedArray) \ - \ - _(ICNameStub_ReadSlot) \ - _(ICNameStub_CallGetter) \ - _(ICNameStub_TypeOfNoProperty) \ - \ - _(CantInlineGeneric) \ - _(CantInlineNoTarget) \ - _(CantInlineNotInterpreted) \ - _(CantInlineNoBaseline) \ - _(CantInlineLazy) \ - _(CantInlineNotConstructor) \ - _(CantInlineClassConstructor) \ - _(CantInlineDisabledIon) \ - _(CantInlineTooManyArgs) \ - _(CantInlineNeedsArgsObj) \ - _(CantInlineDebuggee) \ - _(CantInlineUnknownProps) \ - _(CantInlineExceededDepth) \ - _(CantInlineExceededTotalBytecodeLength) \ - _(CantInlineBigCaller) \ - _(CantInlineBigCallee) \ - _(CantInlineBigCalleeInlinedBytecodeLength) \ - _(CantInlineNotHot) \ - _(CantInlineNotInDispatch) \ - _(CantInlineUnreachable) \ - _(CantInlineNativeBadForm) \ - _(CantInlineNativeBadType) \ - _(CantInlineNativeNoTemplateObj) \ - _(CantInlineBound) \ - _(CantInlineNativeNoSpecialization) \ - _(HasCommonInliningPath) \ - \ - _(GenericSuccess) \ - _(Inlined) \ - _(DOM) \ - _(Monomorphic) \ - _(Polymorphic) - -#define TRACKED_TYPESITE_LIST(_) \ - _(Receiver) \ - _(Operand) \ - _(Index) \ - _(Value) \ - _(Call_Target) \ - _(Call_This) \ - _(Call_Arg) \ - _(Call_Return) - -enum class TrackedStrategy : uint32_t { -#define STRATEGY_OP(name) name, - TRACKED_STRATEGY_LIST(STRATEGY_OP) -#undef STRATEGY_OPT - - Count -}; - -enum class TrackedOutcome : uint32_t { -#define OUTCOME_OP(name) name, - TRACKED_OUTCOME_LIST(OUTCOME_OP) -#undef OUTCOME_OP - - Count -}; - -enum class TrackedTypeSite : uint32_t { -#define TYPESITE_OP(name) name, - TRACKED_TYPESITE_LIST(TYPESITE_OP) -#undef TYPESITE_OP - - Count -}; - -JS_PUBLIC_API(const char*) -TrackedStrategyString(TrackedStrategy strategy); - -JS_PUBLIC_API(const char*) -TrackedOutcomeString(TrackedOutcome outcome); - -JS_PUBLIC_API(const char*) -TrackedTypeSiteString(TrackedTypeSite site); - -struct ForEachTrackedOptimizationAttemptOp -{ - virtual void operator()(TrackedStrategy strategy, TrackedOutcome outcome) = 0; -}; - -struct ForEachTrackedOptimizationTypeInfoOp -{ - // Called 0+ times per entry, once for each type in the type set that Ion - // saw during MIR construction. readType is always called _before_ - // operator() on the same entry. - // - // The keyedBy parameter describes how the type is keyed: - // - "primitive" for primitive types - // - "constructor" for object types tied to a scripted constructor - // function. - // - "alloc site" for object types tied to an allocation site. - // - "prototype" for object types tied neither to a constructor nor - // to an allocation site, but to a prototype. - // - "singleton" for object types which only has a single value. - // - "function" for object types referring to scripted functions. - // - "native" for object types referring to native functions. - // - // The name parameter is the string representation of the type. If the - // type is keyed by "constructor", or if the type itself refers to a - // scripted function, the name is the function's displayAtom. If the type - // is keyed by "native", this is nullptr. - // - // The location parameter is the filename if the type is keyed by - // "constructor", "alloc site", or if the type itself refers to a scripted - // function. If the type is keyed by "native", it is the offset of the - // native function, suitable for use with addr2line on Linux or atos on OS - // X. Otherwise it is nullptr. - // - // The lineno parameter is the line number if the type is keyed by - // "constructor", "alloc site", or if the type itself refers to a scripted - // function. Otherwise it is Nothing(). - // - // The location parameter is the only one that may need escaping if being - // quoted. - virtual void readType(const char* keyedBy, const char* name, - const char* location, mozilla::Maybe<unsigned> lineno) = 0; - - // Called once per entry. - virtual void operator()(TrackedTypeSite site, const char* mirType) = 0; -}; - -} // namespace JS - -#endif // js_TrackedOptimizationInfo_h diff --git a/android/armeabi/include/spidermonkey/js/TypeDecls.h b/android/armeabi/include/spidermonkey/js/TypeDecls.h deleted file mode 100644 index acb93f97..00000000 --- a/android/armeabi/include/spidermonkey/js/TypeDecls.h +++ /dev/null @@ -1,79 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// This file contains public type declarations that are used *frequently*. If -// it doesn't occur at least 10 times in Gecko, it probably shouldn't be in -// here. -// -// It includes only: -// - forward declarations of structs and classes; -// - typedefs; -// - enums (maybe). -// It does *not* contain any struct or class definitions. - -#ifndef js_TypeDecls_h -#define js_TypeDecls_h - -#include <stddef.h> -#include <stdint.h> - -#include "js-config.h" - -struct JSContext; -class JSFunction; -class JSObject; -class JSScript; -class JSString; -class JSAddonId; - -struct jsid; - -namespace JS { - -typedef unsigned char Latin1Char; - -class Symbol; -class Value; -template <typename T> class Handle; -template <typename T> class MutableHandle; -template <typename T> class Rooted; -template <typename T> class PersistentRooted; - -typedef Handle<JSFunction*> HandleFunction; -typedef Handle<jsid> HandleId; -typedef Handle<JSObject*> HandleObject; -typedef Handle<JSScript*> HandleScript; -typedef Handle<JSString*> HandleString; -typedef Handle<JS::Symbol*> HandleSymbol; -typedef Handle<Value> HandleValue; - -typedef MutableHandle<JSFunction*> MutableHandleFunction; -typedef MutableHandle<jsid> MutableHandleId; -typedef MutableHandle<JSObject*> MutableHandleObject; -typedef MutableHandle<JSScript*> MutableHandleScript; -typedef MutableHandle<JSString*> MutableHandleString; -typedef MutableHandle<JS::Symbol*> MutableHandleSymbol; -typedef MutableHandle<Value> MutableHandleValue; - -typedef Rooted<JSObject*> RootedObject; -typedef Rooted<JSFunction*> RootedFunction; -typedef Rooted<JSScript*> RootedScript; -typedef Rooted<JSString*> RootedString; -typedef Rooted<JS::Symbol*> RootedSymbol; -typedef Rooted<jsid> RootedId; -typedef Rooted<JS::Value> RootedValue; - -typedef PersistentRooted<JSFunction*> PersistentRootedFunction; -typedef PersistentRooted<jsid> PersistentRootedId; -typedef PersistentRooted<JSObject*> PersistentRootedObject; -typedef PersistentRooted<JSScript*> PersistentRootedScript; -typedef PersistentRooted<JSString*> PersistentRootedString; -typedef PersistentRooted<JS::Symbol*> PersistentRootedSymbol; -typedef PersistentRooted<Value> PersistentRootedValue; - -} // namespace JS - -#endif /* js_TypeDecls_h */ diff --git a/android/armeabi/include/spidermonkey/js/UbiNode.h b/android/armeabi/include/spidermonkey/js/UbiNode.h deleted file mode 100644 index c8742f33..00000000 --- a/android/armeabi/include/spidermonkey/js/UbiNode.h +++ /dev/null @@ -1,1144 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_UbiNode_h -#define js_UbiNode_h - -#include "mozilla/Alignment.h" -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Maybe.h" -#include "mozilla/MemoryReporting.h" -#include "mozilla/Move.h" -#include "mozilla/RangedPtr.h" -#include "mozilla/TypeTraits.h" -#include "mozilla/Variant.h" - -#include "jspubtd.h" - -#include "js/GCAPI.h" -#include "js/HashTable.h" -#include "js/RootingAPI.h" -#include "js/TracingAPI.h" -#include "js/TypeDecls.h" -#include "js/UniquePtr.h" -#include "js/Value.h" -#include "js/Vector.h" - -// JS::ubi::Node -// -// JS::ubi::Node is a pointer-like type designed for internal use by heap -// analysis tools. A ubi::Node can refer to: -// -// - a JS value, like a string, object, or symbol; -// - an internal SpiderMonkey structure, like a shape or a scope chain object -// - an instance of some embedding-provided type: in Firefox, an XPCOM -// object, or an internal DOM node class instance -// -// A ubi::Node instance provides metadata about its referent, and can -// enumerate its referent's outgoing edges, so you can implement heap analysis -// algorithms that walk the graph - finding paths between objects, or -// computing heap dominator trees, say - using ubi::Node, while remaining -// ignorant of the details of the types you're operating on. -// -// Of course, when it comes to presenting the results in a developer-facing -// tool, you'll need to stop being ignorant of those details, because you have -// to discuss the ubi::Nodes' referents with the developer. Here, ubi::Node -// can hand you dynamically checked, properly typed pointers to the original -// objects via the as<T> method, or generate descriptions of the referent -// itself. -// -// ubi::Node instances are lightweight (two-word) value types. Instances: -// - compare equal if and only if they refer to the same object; -// - have hash values that respect their equality relation; and -// - have serializations that are only equal if the ubi::Nodes are equal. -// -// A ubi::Node is only valid for as long as its referent is alive; if its -// referent goes away, the ubi::Node becomes a dangling pointer. A ubi::Node -// that refers to a GC-managed object is not automatically a GC root; if the -// GC frees or relocates its referent, the ubi::Node becomes invalid. A -// ubi::Node that refers to a reference-counted object does not bump the -// reference count. -// -// ubi::Node values require no supporting data structures, making them -// feasible for use in memory-constrained devices --- ideally, the memory -// requirements of the algorithm which uses them will be the limiting factor, -// not the demands of ubi::Node itself. -// -// One can construct a ubi::Node value given a pointer to a type that ubi::Node -// supports. In the other direction, one can convert a ubi::Node back to a -// pointer; these downcasts are checked dynamically. In particular, one can -// convert a 'JSContext*' to a ubi::Node, yielding a node with an outgoing edge -// for every root registered with the runtime; starting from this, one can walk -// the entire heap. (Of course, one could also start traversal at any other kind -// of type to which one has a pointer.) -// -// -// Extending ubi::Node To Handle Your Embedding's Types -// -// To add support for a new ubi::Node referent type R, you must define a -// specialization of the ubi::Concrete template, ubi::Concrete<R>, which -// inherits from ubi::Base. ubi::Node itself uses the specialization for -// compile-time information (i.e. the checked conversions between R * and -// ubi::Node), and the inheritance for run-time dispatching. -// -// -// ubi::Node Exposes Implementation Details -// -// In many cases, a JavaScript developer's view of their data differs -// substantially from its actual implementation. For example, while the -// ECMAScript specification describes objects as maps from property names to -// sets of attributes (like ECMAScript's [[Value]]), in practice many objects -// have only a pointer to a shape, shared with other similar objects, and -// indexed slots that contain the [[Value]] attributes. As another example, a -// string produced by concatenating two other strings may sometimes be -// represented by a "rope", a structure that points to the two original -// strings. -// -// We intend to use ubi::Node to write tools that report memory usage, so it's -// important that ubi::Node accurately portray how much memory nodes consume. -// Thus, for example, when data that apparently belongs to multiple nodes is -// in fact shared in a common structure, ubi::Node's graph uses a separate -// node for that shared structure, and presents edges to it from the data's -// apparent owners. For example, ubi::Node exposes SpiderMonkey objects' -// shapes and base shapes, and exposes rope string and substring structure, -// because these optimizations become visible when a tool reports how much -// memory a structure consumes. -// -// However, fine granularity is not a goal. When a particular object is the -// exclusive owner of a separate block of memory, ubi::Node may present the -// object and its block as a single node, and add their sizes together when -// reporting the node's size, as there is no meaningful loss of data in this -// case. Thus, for example, a ubi::Node referring to a JavaScript object, when -// asked for the object's size in bytes, includes the object's slot and -// element arrays' sizes in the total. There is no separate ubi::Node value -// representing the slot and element arrays, since they are owned exclusively -// by the object. -// -// -// Presenting Analysis Results To JavaScript Developers -// -// If an analysis provides its results in terms of ubi::Node values, a user -// interface presenting those results will generally need to clean them up -// before they can be understood by JavaScript developers. For example, -// JavaScript developers should not need to understand shapes, only JavaScript -// objects. Similarly, they should not need to understand the distinction -// between DOM nodes and the JavaScript shadow objects that represent them. -// -// -// Rooting Restrictions -// -// At present there is no way to root ubi::Node instances, so instances can't be -// live across any operation that might GC. Analyses using ubi::Node must either -// run to completion and convert their results to some other rootable type, or -// save their intermediate state in some rooted structure if they must GC before -// they complete. (For algorithms like path-finding and dominator tree -// computation, we implement the algorithm avoiding any operation that could -// cause a GC --- and use AutoCheckCannotGC to verify this.) -// -// If this restriction prevents us from implementing interesting tools, we may -// teach the GC how to root ubi::Nodes, fix up hash tables that use them as -// keys, etc. -// -// -// Hostile Graph Structure -// -// Analyses consuming ubi::Node graphs must be robust when presented with graphs -// that are deliberately constructed to exploit their weaknesses. When operating -// on live graphs, web content has control over the object graph, and less -// direct control over shape and string structure, and analyses should be -// prepared to handle extreme cases gracefully. For example, if an analysis were -// to use the C++ stack in a depth-first traversal, carefully constructed -// content could cause the analysis to overflow the stack. -// -// When ubi::Nodes refer to nodes deserialized from a heap snapshot, analyses -// must be even more careful: since snapshots often come from potentially -// compromised e10s content processes, even properties normally guaranteed by -// the platform (the proper linking of DOM nodes, for example) might be -// corrupted. While it is the deserializer's responsibility to check the basic -// structure of the snapshot file, the analyses should be prepared for ubi::Node -// graphs constructed from snapshots to be even more bizarre. - -class JSAtom; - -namespace JS { -namespace ubi { - -class Edge; -class EdgeRange; -class StackFrame; - -} // namespace ubi -} // namespace JS - -namespace JS { -namespace ubi { - -using mozilla::Forward; -using mozilla::Maybe; -using mozilla::Move; -using mozilla::RangedPtr; -using mozilla::Variant; - -template <typename T> -using Vector = mozilla::Vector<T, 0, js::SystemAllocPolicy>; - -/*** ubi::StackFrame ******************************************************************************/ - -// Concrete JS::ubi::StackFrame instances backed by a live SavedFrame object -// store their strings as JSAtom*, while deserialized stack frames from offline -// heap snapshots store their strings as const char16_t*. In order to provide -// zero-cost accessors to these strings in a single interface that works with -// both cases, we use this variant type. -class AtomOrTwoByteChars : public Variant<JSAtom*, const char16_t*> { - using Base = Variant<JSAtom*, const char16_t*>; - - public: - template<typename T> - MOZ_IMPLICIT AtomOrTwoByteChars(T&& rhs) : Base(Forward<T>(rhs)) { } - - template<typename T> - AtomOrTwoByteChars& operator=(T&& rhs) { - MOZ_ASSERT(this != &rhs, "self-move disallowed"); - this->~AtomOrTwoByteChars(); - new (this) AtomOrTwoByteChars(Forward<T>(rhs)); - return *this; - } - - // Return the length of the given AtomOrTwoByteChars string. - size_t length(); - - // Copy the given AtomOrTwoByteChars string into the destination buffer, - // inflating if necessary. Does NOT null terminate. Returns the number of - // characters written to destination. - size_t copyToBuffer(RangedPtr<char16_t> destination, size_t length); -}; - -// The base class implemented by each ConcreteStackFrame<T> type. Subclasses -// must not add data members to this class. -class BaseStackFrame { - friend class StackFrame; - - BaseStackFrame(const StackFrame&) = delete; - BaseStackFrame& operator=(const StackFrame&) = delete; - - protected: - void* ptr; - explicit BaseStackFrame(void* ptr) : ptr(ptr) { } - - public: - // This is a value type that should not have a virtual destructor. Don't add - // destructors in subclasses! - - // Get a unique identifier for this StackFrame. The identifier is not valid - // across garbage collections. - virtual uint64_t identifier() const { return uint64_t(uintptr_t(ptr)); } - - // Get this frame's parent frame. - virtual StackFrame parent() const = 0; - - // Get this frame's line number. - virtual uint32_t line() const = 0; - - // Get this frame's column number. - virtual uint32_t column() const = 0; - - // Get this frame's source name. Never null. - virtual AtomOrTwoByteChars source() const = 0; - - // Return this frame's function name if named, otherwise the inferred - // display name. Can be null. - virtual AtomOrTwoByteChars functionDisplayName() const = 0; - - // Returns true if this frame's function is system JavaScript running with - // trusted principals, false otherwise. - virtual bool isSystem() const = 0; - - // Return true if this frame's function is a self-hosted JavaScript builtin, - // false otherwise. - virtual bool isSelfHosted(JSContext* cx) const = 0; - - // Construct a SavedFrame stack for the stack starting with this frame and - // containing all of its parents. The SavedFrame objects will be placed into - // cx's current compartment. - // - // Note that the process of - // - // SavedFrame - // | - // V - // JS::ubi::StackFrame - // | - // V - // offline heap snapshot - // | - // V - // JS::ubi::StackFrame - // | - // V - // SavedFrame - // - // is lossy because we cannot serialize and deserialize the SavedFrame's - // principals in the offline heap snapshot, so JS::ubi::StackFrame - // simplifies the principals check into the boolean isSystem() state. This - // is fine because we only expose JS::ubi::Stack to devtools and chrome - // code, and not to the web platform. - virtual MOZ_MUST_USE bool constructSavedFrameStack(JSContext* cx, - MutableHandleObject outSavedFrameStack) - const = 0; - - // Trace the concrete implementation of JS::ubi::StackFrame. - virtual void trace(JSTracer* trc) = 0; -}; - -// A traits template with a specialization for each backing type that implements -// the ubi::BaseStackFrame interface. Each specialization must be the a subclass -// of ubi::BaseStackFrame. -template<typename T> class ConcreteStackFrame; - -// A JS::ubi::StackFrame represents a frame in a recorded stack. It can be -// backed either by a live SavedFrame object or by a structure deserialized from -// an offline heap snapshot. -// -// It is a value type that may be memcpy'd hither and thither without worrying -// about constructors or destructors, similar to POD types. -// -// Its lifetime is the same as the lifetime of the graph that is being analyzed -// by the JS::ubi::Node that the JS::ubi::StackFrame came from. That is, if the -// graph being analyzed is the live heap graph, the JS::ubi::StackFrame is only -// valid within the scope of an AutoCheckCannotGC; if the graph being analyzed -// is an offline heap snapshot, the JS::ubi::StackFrame is valid as long as the -// offline heap snapshot is alive. -class StackFrame { - // Storage in which we allocate BaseStackFrame subclasses. - mozilla::AlignedStorage2<BaseStackFrame> storage; - - BaseStackFrame* base() { return storage.addr(); } - const BaseStackFrame* base() const { return storage.addr(); } - - template<typename T> - void construct(T* ptr) { - static_assert(mozilla::IsBaseOf<BaseStackFrame, ConcreteStackFrame<T>>::value, - "ConcreteStackFrame<T> must inherit from BaseStackFrame"); - static_assert(sizeof(ConcreteStackFrame<T>) == sizeof(*base()), - "ubi::ConcreteStackFrame<T> specializations must be the same size as " - "ubi::BaseStackFrame"); - ConcreteStackFrame<T>::construct(base(), ptr); - } - struct ConstructFunctor; - - public: - StackFrame() { construct<void>(nullptr); } - - template<typename T> - MOZ_IMPLICIT StackFrame(T* ptr) { - construct(ptr); - } - - template<typename T> - StackFrame& operator=(T* ptr) { - construct(ptr); - return *this; - } - - // Constructors accepting SpiderMonkey's generic-pointer-ish types. - - template<typename T> - explicit StackFrame(const JS::Handle<T*>& handle) { - construct(handle.get()); - } - - template<typename T> - StackFrame& operator=(const JS::Handle<T*>& handle) { - construct(handle.get()); - return *this; - } - - template<typename T> - explicit StackFrame(const JS::Rooted<T*>& root) { - construct(root.get()); - } - - template<typename T> - StackFrame& operator=(const JS::Rooted<T*>& root) { - construct(root.get()); - return *this; - } - - // Because StackFrame is just a vtable pointer and an instance pointer, we - // can memcpy everything around instead of making concrete classes define - // virtual constructors. See the comment above Node's copy constructor for - // more details; that comment applies here as well. - StackFrame(const StackFrame& rhs) { - memcpy(storage.u.mBytes, rhs.storage.u.mBytes, sizeof(storage.u)); - } - - StackFrame& operator=(const StackFrame& rhs) { - memcpy(storage.u.mBytes, rhs.storage.u.mBytes, sizeof(storage.u)); - return *this; - } - - bool operator==(const StackFrame& rhs) const { return base()->ptr == rhs.base()->ptr; } - bool operator!=(const StackFrame& rhs) const { return !(*this == rhs); } - - explicit operator bool() const { - return base()->ptr != nullptr; - } - - // Copy this StackFrame's source name into the given |destination| - // buffer. Copy no more than |length| characters. The result is *not* null - // terminated. Returns how many characters were written into the buffer. - size_t source(RangedPtr<char16_t> destination, size_t length) const; - - // Copy this StackFrame's function display name into the given |destination| - // buffer. Copy no more than |length| characters. The result is *not* null - // terminated. Returns how many characters were written into the buffer. - size_t functionDisplayName(RangedPtr<char16_t> destination, size_t length) const; - - // Get the size of the respective strings. 0 is returned for null strings. - size_t sourceLength(); - size_t functionDisplayNameLength(); - - // Methods that forward to virtual calls through BaseStackFrame. - - void trace(JSTracer* trc) { base()->trace(trc); } - uint64_t identifier() const { - auto id = base()->identifier(); - MOZ_ASSERT(JS::Value::isNumberRepresentable(id)); - return id; - } - uint32_t line() const { return base()->line(); } - uint32_t column() const { return base()->column(); } - AtomOrTwoByteChars source() const { return base()->source(); } - AtomOrTwoByteChars functionDisplayName() const { return base()->functionDisplayName(); } - StackFrame parent() const { return base()->parent(); } - bool isSystem() const { return base()->isSystem(); } - bool isSelfHosted(JSContext* cx) const { return base()->isSelfHosted(cx); } - MOZ_MUST_USE bool constructSavedFrameStack(JSContext* cx, - MutableHandleObject outSavedFrameStack) const { - return base()->constructSavedFrameStack(cx, outSavedFrameStack); - } - - struct HashPolicy { - using Lookup = JS::ubi::StackFrame; - - static js::HashNumber hash(const Lookup& lookup) { - return lookup.identifier(); - } - - static bool match(const StackFrame& key, const Lookup& lookup) { - return key == lookup; - } - - static void rekey(StackFrame& k, const StackFrame& newKey) { - k = newKey; - } - }; -}; - -// The ubi::StackFrame null pointer. Any attempt to operate on a null -// ubi::StackFrame crashes. -template<> -class ConcreteStackFrame<void> : public BaseStackFrame { - explicit ConcreteStackFrame(void* ptr) : BaseStackFrame(ptr) { } - - public: - static void construct(void* storage, void*) { new (storage) ConcreteStackFrame(nullptr); } - - uint64_t identifier() const override { return 0; } - void trace(JSTracer* trc) override { } - MOZ_MUST_USE bool constructSavedFrameStack(JSContext* cx, MutableHandleObject out) - const override - { - out.set(nullptr); - return true; - } - - uint32_t line() const override { MOZ_CRASH("null JS::ubi::StackFrame"); } - uint32_t column() const override { MOZ_CRASH("null JS::ubi::StackFrame"); } - AtomOrTwoByteChars source() const override { MOZ_CRASH("null JS::ubi::StackFrame"); } - AtomOrTwoByteChars functionDisplayName() const override { MOZ_CRASH("null JS::ubi::StackFrame"); } - StackFrame parent() const override { MOZ_CRASH("null JS::ubi::StackFrame"); } - bool isSystem() const override { MOZ_CRASH("null JS::ubi::StackFrame"); } - bool isSelfHosted(JSContext* cx) const override { MOZ_CRASH("null JS::ubi::StackFrame"); } -}; - -MOZ_MUST_USE bool ConstructSavedFrameStackSlow(JSContext* cx, JS::ubi::StackFrame& frame, - MutableHandleObject outSavedFrameStack); - - -/*** ubi::Node ************************************************************************************/ - -// A concrete node specialization can claim its referent is a member of a -// particular "coarse type" which is less specific than the actual -// implementation type but generally more palatable for web developers. For -// example, JitCode can be considered to have a coarse type of "Script". This is -// used by some analyses for putting nodes into different buckets. The default, -// if a concrete specialization does not provide its own mapping to a CoarseType -// variant, is "Other". -// -// NB: the values associated with a particular enum variant must not change or -// be reused for new variants. Doing so will cause inspecting ubi::Nodes backed -// by an offline heap snapshot from an older SpiderMonkey/Firefox version to -// break. Consider this enum append only. -enum class CoarseType: uint32_t { - Other = 0, - Object = 1, - Script = 2, - String = 3, - - FIRST = Other, - LAST = String -}; - -inline uint32_t -CoarseTypeToUint32(CoarseType type) -{ - return static_cast<uint32_t>(type); -} - -inline bool -Uint32IsValidCoarseType(uint32_t n) -{ - auto first = static_cast<uint32_t>(CoarseType::FIRST); - auto last = static_cast<uint32_t>(CoarseType::LAST); - MOZ_ASSERT(first < last); - return first <= n && n <= last; -} - -inline CoarseType -Uint32ToCoarseType(uint32_t n) -{ - MOZ_ASSERT(Uint32IsValidCoarseType(n)); - return static_cast<CoarseType>(n); -} - -// The base class implemented by each ubi::Node referent type. Subclasses must -// not add data members to this class. -class Base { - friend class Node; - - // For performance's sake, we'd prefer to avoid a virtual destructor; and - // an empty constructor seems consistent with the 'lightweight value type' - // visible behavior we're trying to achieve. But if the destructor isn't - // virtual, and a subclass overrides it, the subclass's destructor will be - // ignored. Is there a way to make the compiler catch that error? - - protected: - // Space for the actual pointer. Concrete subclasses should define a - // properly typed 'get' member function to access this. - void* ptr; - - explicit Base(void* ptr) : ptr(ptr) { } - - public: - bool operator==(const Base& rhs) const { - // Some compilers will indeed place objects of different types at - // the same address, so technically, we should include the vtable - // in this comparison. But it seems unlikely to cause problems in - // practice. - return ptr == rhs.ptr; - } - bool operator!=(const Base& rhs) const { return !(*this == rhs); } - - // An identifier for this node, guaranteed to be stable and unique for as - // long as this ubi::Node's referent is alive and at the same address. - // - // This is probably suitable for use in serializations, as it is an integral - // type. It may also help save memory when constructing HashSets of - // ubi::Nodes: since a uint64_t will always be smaller-or-equal-to the size - // of a ubi::Node, a HashSet<ubi::Node::Id> may use less space per element - // than a HashSet<ubi::Node>. - // - // (Note that 'unique' only means 'up to equality on ubi::Node'; see the - // caveats about multiple objects allocated at the same address for - // 'ubi::Node::operator=='.) - using Id = uint64_t; - virtual Id identifier() const { return Id(uintptr_t(ptr)); } - - // Returns true if this node is pointing to something on the live heap, as - // opposed to something from a deserialized core dump. Returns false, - // otherwise. - virtual bool isLive() const { return true; }; - - // Return the coarse-grained type-of-thing that this node represents. - virtual CoarseType coarseType() const { return CoarseType::Other; } - - // Return a human-readable name for the referent's type. The result should - // be statically allocated. (You can use u"strings" for this.) - // - // This must always return Concrete<T>::concreteTypeName; we use that - // pointer as a tag for this particular referent type. - virtual const char16_t* typeName() const = 0; - - // Return the size of this node, in bytes. Include any structures that this - // node owns exclusively that are not exposed as their own ubi::Nodes. - // |mallocSizeOf| should be a malloc block sizing function; see - // |mfbt/MemoryReporting.h|. - // - // Because we can use |JS::ubi::Node|s backed by a snapshot that was taken - // on a 64-bit platform when we are currently on a 32-bit platform, we - // cannot rely on |size_t| for node sizes. Instead, |Size| is uint64_t on - // all platforms. - using Size = uint64_t; - virtual Size size(mozilla::MallocSizeOf mallocSizeof) const { return 1; } - - // Return an EdgeRange that initially contains all the referent's outgoing - // edges. The caller takes ownership of the EdgeRange. - // - // If wantNames is true, compute names for edges. Doing so can be expensive - // in time and memory. - virtual js::UniquePtr<EdgeRange> edges(JSContext* cx, bool wantNames) const = 0; - - // Return the Zone to which this node's referent belongs, or nullptr if the - // referent is not of a type allocated in SpiderMonkey Zones. - virtual JS::Zone* zone() const { return nullptr; } - - // Return the compartment for this node. Some ubi::Node referents are not - // associated with JSCompartments, such as JSStrings (which are associated - // with Zones). When the referent is not associated with a compartment, - // nullptr is returned. - virtual JSCompartment* compartment() const { return nullptr; } - - // Return whether this node's referent's allocation stack was captured. - virtual bool hasAllocationStack() const { return false; } - - // Get the stack recorded at the time this node's referent was - // allocated. This must only be called when hasAllocationStack() is true. - virtual StackFrame allocationStack() const { - MOZ_CRASH("Concrete classes that have an allocation stack must override both " - "hasAllocationStack and allocationStack."); - } - - // Methods for JSObject Referents - // - // These methods are only semantically valid if the referent is either a - // JSObject in the live heap, or represents a previously existing JSObject - // from some deserialized heap snapshot. - - // Return the object's [[Class]]'s name. - virtual const char* jsObjectClassName() const { return nullptr; } - - // If this object was constructed with `new` and we have the data available, - // place the contructor function's display name in the out parameter. - // Otherwise, place nullptr in the out parameter. Caller maintains ownership - // of the out parameter. True is returned on success, false is returned on - // OOM. - virtual MOZ_MUST_USE bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName) - const - { - outName.reset(nullptr); - return true; - } - - // Methods for CoarseType::Script referents - - // Return the script's source's filename if available. If unavailable, - // return nullptr. - virtual const char* scriptFilename() const { return nullptr; } - - private: - Base(const Base& rhs) = delete; - Base& operator=(const Base& rhs) = delete; -}; - -// A traits template with a specialization for each referent type that -// ubi::Node supports. The specialization must be the concrete subclass of Base -// that represents a pointer to the referent type. It must include these -// members: -// -// // The specific char16_t array returned by Concrete<T>::typeName(). -// static const char16_t concreteTypeName[]; -// -// // Construct an instance of this concrete class in |storage| referring -// // to |referent|. Implementations typically use a placement 'new'. -// // -// // In some cases, |referent| will contain dynamic type information that -// // identifies it a some more specific subclass of |Referent|. For -// // example, when |Referent| is |JSObject|, then |referent->getClass()| -// // could tell us that it's actually a JSFunction. Similarly, if -// // |Referent| is |nsISupports|, we would like a ubi::Node that knows its -// // final implementation type. -// // -// // So we delegate the actual construction to this specialization, which -// // knows Referent's details. -// static void construct(void* storage, Referent* referent); -template<typename Referent> -class Concrete; - -// A container for a Base instance; all members simply forward to the contained -// instance. This container allows us to pass ubi::Node instances by value. -class Node { - // Storage in which we allocate Base subclasses. - mozilla::AlignedStorage2<Base> storage; - Base* base() { return storage.addr(); } - const Base* base() const { return storage.addr(); } - - template<typename T> - void construct(T* ptr) { - static_assert(sizeof(Concrete<T>) == sizeof(*base()), - "ubi::Base specializations must be the same size as ubi::Base"); - static_assert(mozilla::IsBaseOf<Base, Concrete<T>>::value, - "ubi::Concrete<T> must inherit from ubi::Base"); - Concrete<T>::construct(base(), ptr); - } - struct ConstructFunctor; - - public: - Node() { construct<void>(nullptr); } - - template<typename T> - MOZ_IMPLICIT Node(T* ptr) { - construct(ptr); - } - template<typename T> - Node& operator=(T* ptr) { - construct(ptr); - return *this; - } - - // We can construct and assign from rooted forms of pointers. - template<typename T> - MOZ_IMPLICIT Node(const Rooted<T*>& root) { - construct(root.get()); - } - template<typename T> - Node& operator=(const Rooted<T*>& root) { - construct(root.get()); - return *this; - } - - // Constructors accepting SpiderMonkey's other generic-pointer-ish types. - // Note that we *do* want an implicit constructor here: JS::Value and - // JS::ubi::Node are both essentially tagged references to other sorts of - // objects, so letting conversions happen automatically is appropriate. - MOZ_IMPLICIT Node(JS::HandleValue value); - explicit Node(const JS::GCCellPtr& thing); - - // copy construction and copy assignment just use memcpy, since we know - // instances contain nothing but a vtable pointer and a data pointer. - // - // To be completely correct, concrete classes could provide a virtual - // 'construct' member function, which we could invoke on rhs to construct an - // instance in our storage. But this is good enough; there's no need to jump - // through vtables for copying and assignment that are just going to move - // two words around. The compiler knows how to optimize memcpy. - Node(const Node& rhs) { - memcpy(storage.u.mBytes, rhs.storage.u.mBytes, sizeof(storage.u)); - } - - Node& operator=(const Node& rhs) { - memcpy(storage.u.mBytes, rhs.storage.u.mBytes, sizeof(storage.u)); - return *this; - } - - bool operator==(const Node& rhs) const { return *base() == *rhs.base(); } - bool operator!=(const Node& rhs) const { return *base() != *rhs.base(); } - - explicit operator bool() const { - return base()->ptr != nullptr; - } - - bool isLive() const { return base()->isLive(); } - - // Get the canonical type name for the given type T. - template<typename T> - static const char16_t* canonicalTypeName() { return Concrete<T>::concreteTypeName; } - - template<typename T> - bool is() const { - return base()->typeName() == canonicalTypeName<T>(); - } - - template<typename T> - T* as() const { - MOZ_ASSERT(isLive()); - MOZ_ASSERT(is<T>()); - return static_cast<T*>(base()->ptr); - } - - template<typename T> - T* asOrNull() const { - MOZ_ASSERT(isLive()); - return is<T>() ? static_cast<T*>(base()->ptr) : nullptr; - } - - // If this node refers to something that can be represented as a JavaScript - // value that is safe to expose to JavaScript code, return that value. - // Otherwise return UndefinedValue(). JSStrings, JS::Symbols, and some (but - // not all!) JSObjects can be exposed. - JS::Value exposeToJS() const; - - CoarseType coarseType() const { return base()->coarseType(); } - const char16_t* typeName() const { return base()->typeName(); } - JS::Zone* zone() const { return base()->zone(); } - JSCompartment* compartment() const { return base()->compartment(); } - const char* jsObjectClassName() const { return base()->jsObjectClassName(); } - MOZ_MUST_USE bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName) const { - return base()->jsObjectConstructorName(cx, outName); - } - - const char* scriptFilename() const { return base()->scriptFilename(); } - - using Size = Base::Size; - Size size(mozilla::MallocSizeOf mallocSizeof) const { - auto size = base()->size(mallocSizeof); - MOZ_ASSERT(size > 0, - "C++ does not have zero-sized types! Choose 1 if you just need a " - "conservative default."); - return size; - } - - js::UniquePtr<EdgeRange> edges(JSContext* cx, bool wantNames = true) const { - return base()->edges(cx, wantNames); - } - - bool hasAllocationStack() const { return base()->hasAllocationStack(); } - StackFrame allocationStack() const { - return base()->allocationStack(); - } - - using Id = Base::Id; - Id identifier() const { - auto id = base()->identifier(); - MOZ_ASSERT(JS::Value::isNumberRepresentable(id)); - return id; - } - - // A hash policy for ubi::Nodes. - // This simply uses the stock PointerHasher on the ubi::Node's pointer. - // We specialize DefaultHasher below to make this the default. - class HashPolicy { - typedef js::PointerHasher<void*, mozilla::tl::FloorLog2<sizeof(void*)>::value> PtrHash; - - public: - typedef Node Lookup; - - static js::HashNumber hash(const Lookup& l) { return PtrHash::hash(l.base()->ptr); } - static bool match(const Node& k, const Lookup& l) { return k == l; } - static void rekey(Node& k, const Node& newKey) { k = newKey; } - }; -}; - -using NodeSet = js::HashSet<Node, js::DefaultHasher<Node>, js::SystemAllocPolicy>; -using NodeSetPtr = mozilla::UniquePtr<NodeSet, JS::DeletePolicy<NodeSet>>; - -/*** Edge and EdgeRange ***************************************************************************/ - -using EdgeName = UniqueTwoByteChars; - -// An outgoing edge to a referent node. -class Edge { - public: - Edge() : name(nullptr), referent() { } - - // Construct an initialized Edge, taking ownership of |name|. - Edge(char16_t* name, const Node& referent) - : name(name) - , referent(referent) - { } - - // Move construction and assignment. - Edge(Edge&& rhs) - : name(mozilla::Move(rhs.name)) - , referent(rhs.referent) - { } - - Edge& operator=(Edge&& rhs) { - MOZ_ASSERT(&rhs != this); - this->~Edge(); - new (this) Edge(mozilla::Move(rhs)); - return *this; - } - - Edge(const Edge&) = delete; - Edge& operator=(const Edge&) = delete; - - // This edge's name. This may be nullptr, if Node::edges was called with - // false as the wantNames parameter. - // - // The storage is owned by this Edge, and will be freed when this Edge is - // destructed. You may take ownership of the name by `mozilla::Move`ing it - // out of the edge; it is just a UniquePtr. - // - // (In real life we'll want a better representation for names, to avoid - // creating tons of strings when the names follow a pattern; and we'll need - // to think about lifetimes carefully to ensure traversal stays cheap.) - EdgeName name; - - // This edge's referent. - Node referent; -}; - -// EdgeRange is an abstract base class for iterating over a node's outgoing -// edges. (This is modeled after js::HashTable<K,V>::Range.) -// -// Concrete instances of this class need not be as lightweight as Node itself, -// since they're usually only instantiated while iterating over a particular -// object's edges. For example, a dumb implementation for JS Cells might use -// JS::TraceChildren to to get the outgoing edges, and then store them in an -// array internal to the EdgeRange. -class EdgeRange { - protected: - // The current front edge of this range, or nullptr if this range is empty. - Edge* front_; - - EdgeRange() : front_(nullptr) { } - - public: - virtual ~EdgeRange() { } - - // True if there are no more edges in this range. - bool empty() const { return !front_; } - - // The front edge of this range. This is owned by the EdgeRange, and is - // only guaranteed to live until the next call to popFront, or until - // the EdgeRange is destructed. - const Edge& front() const { return *front_; } - Edge& front() { return *front_; } - - // Remove the front edge from this range. This should only be called if - // !empty(). - virtual void popFront() = 0; - - private: - EdgeRange(const EdgeRange&) = delete; - EdgeRange& operator=(const EdgeRange&) = delete; -}; - - -typedef mozilla::Vector<Edge, 8, js::SystemAllocPolicy> EdgeVector; - -// An EdgeRange concrete class that holds a pre-existing vector of -// Edges. A PreComputedEdgeRange does not take ownership of its -// EdgeVector; it is up to the PreComputedEdgeRange's consumer to manage -// that lifetime. -class PreComputedEdgeRange : public EdgeRange { - EdgeVector& edges; - size_t i; - - void settle() { - front_ = i < edges.length() ? &edges[i] : nullptr; - } - - public: - explicit PreComputedEdgeRange(EdgeVector& edges) - : edges(edges), - i(0) - { - settle(); - } - - void popFront() override { - MOZ_ASSERT(!empty()); - i++; - settle(); - } -}; - -/*** RootList *************************************************************************************/ - -// RootList is a class that can be pointed to by a |ubi::Node|, creating a -// fictional root-of-roots which has edges to every GC root in the JS -// runtime. Having a single root |ubi::Node| is useful for algorithms written -// with the assumption that there aren't multiple roots (such as computing -// dominator trees) and you want a single point of entry. It also ensures that -// the roots themselves get visited by |ubi::BreadthFirst| (they would otherwise -// only be used as starting points). -// -// RootList::init itself causes a minor collection, but once the list of roots -// has been created, GC must not occur, as the referent ubi::Nodes are not -// stable across GC. The init calls emplace on |noGC|'s AutoCheckCannotGC, whose -// lifetime must extend at least as long as the RootList itself. -// -// Example usage: -// -// { -// mozilla::Maybe<JS::AutoCheckCannotGC> maybeNoGC; -// JS::ubi::RootList rootList(cx, maybeNoGC); -// if (!rootList.init()) -// return false; -// -// // The AutoCheckCannotGC is guaranteed to exist if init returned true. -// MOZ_ASSERT(maybeNoGC.isSome()); -// -// JS::ubi::Node root(&rootList); -// -// ... -// } -class MOZ_STACK_CLASS RootList { - Maybe<AutoCheckCannotGC>& noGC; - - public: - JSContext* cx; - EdgeVector edges; - bool wantNames; - - RootList(JSContext* cx, Maybe<AutoCheckCannotGC>& noGC, bool wantNames = false); - - // Find all GC roots. - MOZ_MUST_USE bool init(); - // Find only GC roots in the provided set of |JSCompartment|s. - MOZ_MUST_USE bool init(CompartmentSet& debuggees); - // Find only GC roots in the given Debugger object's set of debuggee - // compartments. - MOZ_MUST_USE bool init(HandleObject debuggees); - - // Returns true if the RootList has been initialized successfully, false - // otherwise. - bool initialized() { return noGC.isSome(); } - - // Explicitly add the given Node as a root in this RootList. If wantNames is - // true, you must pass an edgeName. The RootList does not take ownership of - // edgeName. - MOZ_MUST_USE bool addRoot(Node node, const char16_t* edgeName = nullptr); -}; - - -/*** Concrete classes for ubi::Node referent types ************************************************/ - -template<> -class Concrete<RootList> : public Base { - protected: - explicit Concrete(RootList* ptr) : Base(ptr) { } - RootList& get() const { return *static_cast<RootList*>(ptr); } - - public: - static void construct(void* storage, RootList* ptr) { new (storage) Concrete(ptr); } - - js::UniquePtr<EdgeRange> edges(JSContext* cx, bool wantNames) const override; - - const char16_t* typeName() const override { return concreteTypeName; } - static const char16_t concreteTypeName[]; -}; - -// A reusable ubi::Concrete specialization base class for types supported by -// JS::TraceChildren. -template<typename Referent> -class TracerConcrete : public Base { - js::UniquePtr<EdgeRange> edges(JSContext* cx, bool wantNames) const override; - JS::Zone* zone() const override; - - protected: - explicit TracerConcrete(Referent* ptr) : Base(ptr) { } - Referent& get() const { return *static_cast<Referent*>(ptr); } -}; - -// For JS::TraceChildren-based types that have a 'compartment' method. -template<typename Referent> -class TracerConcreteWithCompartment : public TracerConcrete<Referent> { - typedef TracerConcrete<Referent> TracerBase; - JSCompartment* compartment() const override; - - protected: - explicit TracerConcreteWithCompartment(Referent* ptr) : TracerBase(ptr) { } -}; - -// Define specializations for some commonly-used public JSAPI types. -// These can use the generic templates above. -template<> -class Concrete<JS::Symbol> : TracerConcrete<JS::Symbol> { - protected: - explicit Concrete(JS::Symbol* ptr) : TracerConcrete(ptr) { } - - public: - static void construct(void* storage, JS::Symbol* ptr) { - new (storage) Concrete(ptr); - } - - Size size(mozilla::MallocSizeOf mallocSizeOf) const override; - - const char16_t* typeName() const override { return concreteTypeName; } - static const char16_t concreteTypeName[]; -}; - -template<> -class Concrete<JSScript> : TracerConcreteWithCompartment<JSScript> { - protected: - explicit Concrete(JSScript *ptr) : TracerConcreteWithCompartment<JSScript>(ptr) { } - - public: - static void construct(void *storage, JSScript *ptr) { new (storage) Concrete(ptr); } - - CoarseType coarseType() const final { return CoarseType::Script; } - Size size(mozilla::MallocSizeOf mallocSizeOf) const override; - const char* scriptFilename() const final; - - const char16_t* typeName() const override { return concreteTypeName; } - static const char16_t concreteTypeName[]; -}; - -// The JSObject specialization. -template<> -class Concrete<JSObject> : public TracerConcreteWithCompartment<JSObject> { - protected: - explicit Concrete(JSObject* ptr) : TracerConcreteWithCompartment(ptr) { } - - public: - static void construct(void* storage, JSObject* ptr) { - new (storage) Concrete(ptr); - } - - const char* jsObjectClassName() const override; - MOZ_MUST_USE bool jsObjectConstructorName(JSContext* cx, UniqueTwoByteChars& outName) - const override; - Size size(mozilla::MallocSizeOf mallocSizeOf) const override; - - bool hasAllocationStack() const override; - StackFrame allocationStack() const override; - - CoarseType coarseType() const final { return CoarseType::Object; } - - const char16_t* typeName() const override { return concreteTypeName; } - static const char16_t concreteTypeName[]; -}; - -// For JSString, we extend the generic template with a 'size' implementation. -template<> -class Concrete<JSString> : TracerConcrete<JSString> { - protected: - explicit Concrete(JSString *ptr) : TracerConcrete<JSString>(ptr) { } - - public: - static void construct(void *storage, JSString *ptr) { new (storage) Concrete(ptr); } - - Size size(mozilla::MallocSizeOf mallocSizeOf) const override; - - CoarseType coarseType() const final { return CoarseType::String; } - - const char16_t* typeName() const override { return concreteTypeName; } - static const char16_t concreteTypeName[]; -}; - -// The ubi::Node null pointer. Any attempt to operate on a null ubi::Node asserts. -template<> -class Concrete<void> : public Base { - const char16_t* typeName() const override; - Size size(mozilla::MallocSizeOf mallocSizeOf) const override; - js::UniquePtr<EdgeRange> edges(JSContext* cx, bool wantNames) const override; - JS::Zone* zone() const override; - JSCompartment* compartment() const override; - CoarseType coarseType() const final; - - explicit Concrete(void* ptr) : Base(ptr) { } - - public: - static void construct(void* storage, void* ptr) { new (storage) Concrete(ptr); } -}; - - -} // namespace ubi -} // namespace JS - -namespace js { - -// Make ubi::Node::HashPolicy the default hash policy for ubi::Node. -template<> struct DefaultHasher<JS::ubi::Node> : JS::ubi::Node::HashPolicy { }; -template<> struct DefaultHasher<JS::ubi::StackFrame> : JS::ubi::StackFrame::HashPolicy { }; - -} // namespace js - -#endif // js_UbiNode_h diff --git a/android/armeabi/include/spidermonkey/js/UbiNodeBreadthFirst.h b/android/armeabi/include/spidermonkey/js/UbiNodeBreadthFirst.h deleted file mode 100644 index 8446dbc6..00000000 --- a/android/armeabi/include/spidermonkey/js/UbiNodeBreadthFirst.h +++ /dev/null @@ -1,244 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_UbiNodeBreadthFirst_h -#define js_UbiNodeBreadthFirst_h - -#include "js/UbiNode.h" -#include "js/Utility.h" -#include "js/Vector.h" - -namespace JS { -namespace ubi { - -// A breadth-first traversal template for graphs of ubi::Nodes. -// -// No GC may occur while an instance of this template is live. -// -// The provided Handler type should have two members: -// -// typename NodeData; -// -// The value type of |BreadthFirst<Handler>::visited|, the HashMap of -// ubi::Nodes that have been visited so far. Since the algorithm needs a -// hash table like this for its own use anyway, it is simple to let -// Handler store its own metadata about each node in the same table. -// -// For example, if you want to find a shortest path to each node from any -// traversal starting point, your |NodeData| type could record the first -// edge to reach each node, and the node from which it originates. Then, -// when the traversal is complete, you can walk backwards from any node -// to some starting point, and the path recorded will be a shortest path. -// -// This type must have a default constructor. If this type owns any other -// resources, move constructors and assignment operators are probably a -// good idea, too. -// -// bool operator() (BreadthFirst& traversal, -// Node origin, const Edge& edge, -// Handler::NodeData* referentData, bool first); -// -// The visitor function, called to report that we have traversed -// |edge| from |origin|. This is called once for each edge we traverse. -// As this is a breadth-first search, any prior calls to the visitor function -// were for origin nodes not further from the start nodes than |origin|. -// -// |traversal| is this traversal object, passed along for convenience. -// -// |referentData| is a pointer to the value of the entry in -// |traversal.visited| for |edge.referent|; the visitor function can -// store whatever metadata it likes about |edge.referent| there. -// -// |first| is true if this is the first time we have visited an edge -// leading to |edge.referent|. This could be stored in NodeData, but -// the algorithm knows whether it has just created the entry in -// |traversal.visited|, so it passes it along for convenience. -// -// The visitor function may call |traversal.abandonReferent()| if it -// doesn't want to traverse the outgoing edges of |edge.referent|. You can -// use this to limit the traversal to a given portion of the graph: it will -// never visit nodes reachable only through nodes that you have abandoned. -// Note that |abandonReferent| must be called the first time the given node -// is reached; that is, |first| must be true. -// -// The visitor function may call |traversal.stop()| if it doesn't want -// to visit any more nodes at all. -// -// The visitor function may consult |traversal.visited| for information -// about other nodes, but it should not add or remove entries. -// -// The visitor function should return true on success, or false if an -// error occurs. A false return value terminates the traversal -// immediately, and causes BreadthFirst<Handler>::traverse to return -// false. -template<typename Handler> -struct BreadthFirst { - - // Construct a breadth-first traversal object that reports the nodes it - // reaches to |handler|. The traversal asserts that no GC happens in its - // runtime during its lifetime. - // - // We do nothing with noGC, other than require it to exist, with a lifetime - // that encloses our own. - BreadthFirst(JSContext* cx, Handler& handler, const JS::AutoCheckCannotGC& noGC) - : wantNames(true), cx(cx), visited(), handler(handler), pending(), - traversalBegun(false), stopRequested(false), abandonRequested(false) - { } - - // Initialize this traversal object. Return false on OOM. - bool init() { return visited.init(); } - - // Add |node| as a starting point for the traversal. You may add - // as many starting points as you like. Return false on OOM. - bool addStart(Node node) { return pending.append(node); } - - // Add |node| as a starting point for the traversal (see addStart) and also - // add it to the |visited| set. Return false on OOM. - bool addStartVisited(Node node) { - typename NodeMap::AddPtr ptr = visited.lookupForAdd(node); - if (!ptr && !visited.add(ptr, node, typename Handler::NodeData())) - return false; - return addStart(node); - } - - // True if the handler wants us to compute edge names; doing so can be - // expensive in time and memory. True by default. - bool wantNames; - - // Traverse the graph in breadth-first order, starting at the given - // start nodes, applying |handler::operator()| for each edge traversed - // as described above. - // - // This should be called only once per instance of this class. - // - // Return false on OOM or error return from |handler::operator()|. - bool traverse() - { - MOZ_ASSERT(!traversalBegun); - traversalBegun = true; - - // While there are pending nodes, visit them. - while (!pending.empty()) { - Node origin = pending.front(); - pending.popFront(); - - // Get a range containing all origin's outgoing edges. - auto range = origin.edges(cx, wantNames); - if (!range) - return false; - - // Traverse each edge. - for (; !range->empty(); range->popFront()) { - MOZ_ASSERT(!stopRequested); - - Edge& edge = range->front(); - typename NodeMap::AddPtr a = visited.lookupForAdd(edge.referent); - bool first = !a; - - if (first) { - // This is the first time we've reached |edge.referent|. - // Mark it as visited. - if (!visited.add(a, edge.referent, typename Handler::NodeData())) - return false; - } - - MOZ_ASSERT(a); - - // Report this edge to the visitor function. - if (!handler(*this, origin, edge, &a->value(), first)) - return false; - - if (stopRequested) - return true; - - // Arrange to traverse this edge's referent's outgoing edges - // later --- unless |handler| asked us not to. - if (abandonRequested) { - // Skip the enqueue; reset flag for future iterations. - abandonRequested = false; - } else if (first) { - if (!pending.append(edge.referent)) - return false; - } - } - } - - return true; - } - - // Stop traversal, and return true from |traverse| without visiting any - // more nodes. Only |handler::operator()| should call this function; it - // may do so to stop the traversal early, without returning false and - // then making |traverse|'s caller disambiguate that result from a real - // error. - void stop() { stopRequested = true; } - - // Request that the current edge's referent's outgoing edges not be - // traversed. This must be called the first time that referent is reached. - // Other edges *to* that referent will still be traversed. - void abandonReferent() { abandonRequested = true; } - - // The context with which we were constructed. - JSContext* cx; - - // A map associating each node N that we have reached with a - // Handler::NodeData, for |handler|'s use. This is public, so that - // |handler| can access it to see the traversal thus far. - using NodeMap = js::HashMap<Node, typename Handler::NodeData, js::DefaultHasher<Node>, - js::SystemAllocPolicy>; - NodeMap visited; - - private: - // Our handler object. - Handler& handler; - - // A queue template. Appending and popping the front are constant time. - // Wasted space is never more than some recent actual population plus the - // current population. - template <typename T> - class Queue { - js::Vector<T, 0, js::SystemAllocPolicy> head, tail; - size_t frontIndex; - public: - Queue() : head(), tail(), frontIndex(0) { } - bool empty() { return frontIndex >= head.length(); } - T& front() { - MOZ_ASSERT(!empty()); - return head[frontIndex]; - } - void popFront() { - MOZ_ASSERT(!empty()); - frontIndex++; - if (frontIndex >= head.length()) { - head.clearAndFree(); - head.swap(tail); - frontIndex = 0; - } - } - bool append(const T& elt) { - return frontIndex == 0 ? head.append(elt) : tail.append(elt); - } - }; - - // A queue of nodes that we have reached, but whose outgoing edges we - // have not yet traversed. Nodes reachable in fewer edges are enqueued - // earlier. - Queue<Node> pending; - - // True if our traverse function has been called. - bool traversalBegun; - - // True if we've been asked to stop the traversal. - bool stopRequested; - - // True if we've been asked to abandon the current edge's referent. - bool abandonRequested; -}; - -} // namespace ubi -} // namespace JS - -#endif // js_UbiNodeBreadthFirst_h diff --git a/android/armeabi/include/spidermonkey/js/UbiNodeCensus.h b/android/armeabi/include/spidermonkey/js/UbiNodeCensus.h deleted file mode 100644 index c0859ec5..00000000 --- a/android/armeabi/include/spidermonkey/js/UbiNodeCensus.h +++ /dev/null @@ -1,251 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_UbiNodeCensus_h -#define js_UbiNodeCensus_h - -#include "mozilla/Attributes.h" -#include "mozilla/Move.h" - -#include <algorithm> - -#include "jsapi.h" - -#include "js/UbiNode.h" -#include "js/UbiNodeBreadthFirst.h" - -// A census is a ubi::Node traversal that assigns each node to one or more -// buckets, and returns a report with the size of each bucket. -// -// We summarize the results of a census with counts broken down according to -// criteria selected by the API consumer code that is requesting the census. For -// example, the following breakdown might give an interesting overview of the -// heap: -// -// - all nodes -// - objects -// - objects with a specific [[Class]] * -// - strings -// - scripts -// - all other Node types -// - nodes with a specific ubi::Node::typeName * -// -// Obviously, the parts of this tree marked with * represent many separate -// counts, depending on how many distinct [[Class]] values and ubi::Node type -// names we encounter. -// -// The supported types of breakdowns are documented in -// js/src/doc/Debugger/Debugger.Memory.md. -// -// When we parse the 'breakdown' argument to takeCensus, we build a tree of -// CountType nodes. For example, for the breakdown shown in the -// Debugger.Memory.prototype.takeCensus, documentation: -// -// { -// by: "coarseType", -// objects: { by: "objectClass" }, -// other: { by: "internalType" } -// } -// -// we would build the following tree of CountType subclasses: -// -// ByCoarseType -// objects: ByObjectClass -// each class: SimpleCount -// scripts: SimpleCount -// strings: SimpleCount -// other: ByUbinodeType -// each type: SimpleCount -// -// The interior nodes are all breakdown types that categorize nodes according to -// one characteristic or another; and the leaf nodes are all SimpleType. -// -// Each CountType has its own concrete C++ type that holds the counts it -// produces. SimpleCount::Count just holds totals. ByObjectClass::Count has a -// hash table whose keys are object class names and whose values are counts of -// some other type (in the example above, SimpleCount). -// -// To keep actual count nodes small, they have no vtable. Instead, each count -// points to its CountType, which knows how to carry out all the operations we -// need on a Count. A CountType can produce new count nodes; process nodes as we -// visit them; build a JS object reporting the results; and destruct count -// nodes. - - -namespace JS { -namespace ubi { - -struct Census; - -class CountBase; - -struct CountDeleter { - void operator()(CountBase*); -}; - -using CountBasePtr = js::UniquePtr<CountBase, CountDeleter>; - -// Abstract base class for CountType nodes. -struct CountType { - explicit CountType() { } - virtual ~CountType() { } - - // Destruct a count tree node that this type instance constructed. - virtual void destructCount(CountBase& count) = 0; - - // Return a fresh node for the count tree that categorizes nodes according - // to this type. Return a nullptr on OOM. - virtual CountBasePtr makeCount() = 0; - - // Trace |count| and all its children, for garbage collection. - virtual void traceCount(CountBase& count, JSTracer* trc) = 0; - - // Implement the 'count' method for counts returned by this CountType - // instance's 'newCount' method. - virtual MOZ_MUST_USE bool count(CountBase& count, - mozilla::MallocSizeOf mallocSizeOf, - const Node& node) = 0; - - // Implement the 'report' method for counts returned by this CountType - // instance's 'newCount' method. - virtual MOZ_MUST_USE bool report(JSContext* cx, CountBase& count, - MutableHandleValue report) = 0; -}; - -using CountTypePtr = js::UniquePtr<CountType>; - -// An abstract base class for count tree nodes. -class CountBase { - // In lieu of a vtable, each CountBase points to its type, which - // carries not only the implementations of the CountBase methods, but also - // additional parameters for the type's behavior, as specified in the - // breakdown argument passed to takeCensus. - CountType& type; - - protected: - ~CountBase() { } - - public: - explicit CountBase(CountType& type) - : type(type) - , total_(0) - , smallestNodeIdCounted_(SIZE_MAX) - { } - - // Categorize and count |node| as appropriate for this count's type. - MOZ_MUST_USE bool count(mozilla::MallocSizeOf mallocSizeOf, const Node& node) { - total_++; - - auto id = node.identifier(); - if (id < smallestNodeIdCounted_) { - smallestNodeIdCounted_ = id; - } - -#ifdef DEBUG - size_t oldTotal = total_; -#endif - - bool ret = type.count(*this, mallocSizeOf, node); - - MOZ_ASSERT(total_ == oldTotal, - "CountType::count should not increment total_, CountBase::count handles that"); - - return ret; - } - - // Construct a JavaScript object reporting the counts recorded in this - // count, and store it in |report|. Return true on success, or false on - // failure. - MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) { - return type.report(cx, *this, report); - } - - // Down-cast this CountBase to its true type, based on its 'type' member, - // and run its destructor. - void destruct() { return type.destructCount(*this); } - - // Trace this count for garbage collection. - void trace(JSTracer* trc) { type.traceCount(*this, trc); } - - size_t total_; - - // The smallest JS::ubi::Node::identifier() passed to this instance's - // count() method. This provides a stable way to sort sets. - Node::Id smallestNodeIdCounted_; -}; - -class RootedCount : JS::CustomAutoRooter { - CountBasePtr count; - - void trace(JSTracer* trc) override { count->trace(trc); } - - public: - RootedCount(JSContext* cx, CountBasePtr&& count) - : CustomAutoRooter(cx), - count(Move(count)) - { } - CountBase* operator->() const { return count.get(); } - explicit operator bool() const { return count.get(); } - operator CountBasePtr&() { return count; } -}; - -// Common data for a census traversal, shared across all CountType nodes. -struct Census { - JSContext* const cx; - // If the targetZones set is non-empty, then only consider nodes whose zone - // is an element of the set. If the targetZones set is empty, then nodes in - // all zones are considered. - JS::ZoneSet targetZones; - Zone* atomsZone; - - explicit Census(JSContext* cx) : cx(cx), atomsZone(nullptr) { } - - MOZ_MUST_USE bool init(); -}; - -// A BreadthFirst handler type that conducts a census, using a CountBase to -// categorize and count each node. -class CensusHandler { - Census& census; - CountBasePtr& rootCount; - mozilla::MallocSizeOf mallocSizeOf; - - public: - CensusHandler(Census& census, CountBasePtr& rootCount, mozilla::MallocSizeOf mallocSizeOf) - : census(census), - rootCount(rootCount), - mallocSizeOf(mallocSizeOf) - { } - - MOZ_MUST_USE bool report(JSContext* cx, MutableHandleValue report) { - return rootCount->report(cx, report); - } - - // This class needs to retain no per-node data. - class NodeData { }; - - MOZ_MUST_USE bool operator() (BreadthFirst<CensusHandler>& traversal, - Node origin, const Edge& edge, - NodeData* referentData, bool first); -}; - -using CensusTraversal = BreadthFirst<CensusHandler>; - -// Examine the census options supplied by the API consumer, and (among other -// things) use that to build a CountType tree. -MOZ_MUST_USE bool ParseCensusOptions(JSContext* cx, Census& census, HandleObject options, - CountTypePtr& outResult); - -// Parse the breakdown language (as described in -// js/src/doc/Debugger/Debugger.Memory.md) into a CountTypePtr. A null pointer -// is returned on error and is reported to the cx. -CountTypePtr ParseBreakdown(JSContext* cx, HandleValue breakdownValue); - - -} // namespace ubi -} // namespace JS - -#endif // js_UbiNodeCensus_h diff --git a/android/armeabi/include/spidermonkey/js/UbiNodeDominatorTree.h b/android/armeabi/include/spidermonkey/js/UbiNodeDominatorTree.h deleted file mode 100644 index 3422b76b..00000000 --- a/android/armeabi/include/spidermonkey/js/UbiNodeDominatorTree.h +++ /dev/null @@ -1,677 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_UbiNodeDominatorTree_h -#define js_UbiNodeDominatorTree_h - -#include "mozilla/Attributes.h" -#include "mozilla/DebugOnly.h" -#include "mozilla/Maybe.h" -#include "mozilla/Move.h" -#include "mozilla/UniquePtr.h" - -#include "jsalloc.h" - -#include "js/UbiNode.h" -#include "js/UbiNodePostOrder.h" -#include "js/Utility.h" -#include "js/Vector.h" - -namespace JS { -namespace ubi { - -/** - * In a directed graph with a root node `R`, a node `A` is said to "dominate" a - * node `B` iff every path from `R` to `B` contains `A`. A node `A` is said to - * be the "immediate dominator" of a node `B` iff it dominates `B`, is not `B` - * itself, and does not dominate any other nodes which also dominate `B` in - * turn. - * - * If we take every node from a graph `G` and create a new graph `T` with edges - * to each node from its immediate dominator, then `T` is a tree (each node has - * only one immediate dominator, or none if it is the root). This tree is called - * a "dominator tree". - * - * This class represents a dominator tree constructed from a `JS::ubi::Node` - * heap graph. The domination relationship and dominator trees are useful tools - * for analyzing heap graphs because they tell you: - * - * - Exactly what could be reclaimed by the GC if some node `A` became - * unreachable: those nodes which are dominated by `A`, - * - * - The "retained size" of a node in the heap graph, in contrast to its - * "shallow size". The "shallow size" is the space taken by a node itself, - * not counting anything it references. The "retained size" of a node is its - * shallow size plus the size of all the things that would be collected if - * the original node wasn't (directly or indirectly) referencing them. In - * other words, the retained size is the shallow size of a node plus the - * shallow sizes of every other node it dominates. For example, the root - * node in a binary tree might have a small shallow size that does not take - * up much space itself, but it dominates the rest of the binary tree and - * its retained size is therefore significant (assuming no external - * references into the tree). - * - * The simple, engineered algorithm presented in "A Simple, Fast Dominance - * Algorithm" by Cooper el al[0] is used to find dominators and construct the - * dominator tree. This algorithm runs in O(n^2) time, but is faster in practice - * than alternative algorithms with better theoretical running times, such as - * Lengauer-Tarjan which runs in O(e * log(n)). The big caveat to that statement - * is that Cooper et al found it is faster in practice *on control flow graphs* - * and I'm not convinced that this property also holds on *heap* graphs. That - * said, the implementation of this algorithm is *much* simpler than - * Lengauer-Tarjan and has been found to be fast enough at least for the time - * being. - * - * [0]: http://www.cs.rice.edu/~keith/EMBED/dom.pdf - */ -class JS_PUBLIC_API(DominatorTree) -{ - private: - // Types. - - using PredecessorSets = js::HashMap<Node, NodeSetPtr, js::DefaultHasher<Node>, - js::SystemAllocPolicy>; - using NodeToIndexMap = js::HashMap<Node, uint32_t, js::DefaultHasher<Node>, - js::SystemAllocPolicy>; - class DominatedSets; - - public: - class DominatedSetRange; - - /** - * A pointer to an immediately dominated node. - * - * Don't use this type directly; it is no safer than regular pointers. This - * is only for use indirectly with range-based for loops and - * `DominatedSetRange`. - * - * @see JS::ubi::DominatorTree::getDominatedSet - */ - class DominatedNodePtr - { - friend class DominatedSetRange; - - const JS::ubi::Vector<Node>& postOrder; - const uint32_t* ptr; - - DominatedNodePtr(const JS::ubi::Vector<Node>& postOrder, const uint32_t* ptr) - : postOrder(postOrder) - , ptr(ptr) - { } - - public: - bool operator!=(const DominatedNodePtr& rhs) const { return ptr != rhs.ptr; } - void operator++() { ptr++; } - const Node& operator*() const { return postOrder[*ptr]; } - }; - - /** - * A range of immediately dominated `JS::ubi::Node`s for use with - * range-based for loops. - * - * @see JS::ubi::DominatorTree::getDominatedSet - */ - class DominatedSetRange - { - friend class DominatedSets; - - const JS::ubi::Vector<Node>& postOrder; - const uint32_t* beginPtr; - const uint32_t* endPtr; - - DominatedSetRange(JS::ubi::Vector<Node>& postOrder, const uint32_t* begin, const uint32_t* end) - : postOrder(postOrder) - , beginPtr(begin) - , endPtr(end) - { - MOZ_ASSERT(begin <= end); - } - - public: - DominatedNodePtr begin() const { - MOZ_ASSERT(beginPtr <= endPtr); - return DominatedNodePtr(postOrder, beginPtr); - } - - DominatedNodePtr end() const { - return DominatedNodePtr(postOrder, endPtr); - } - - size_t length() const { - MOZ_ASSERT(beginPtr <= endPtr); - return endPtr - beginPtr; - } - - /** - * Safely skip ahead `n` dominators in the range, in O(1) time. - * - * Example usage: - * - * mozilla::Maybe<DominatedSetRange> range = myDominatorTree.getDominatedSet(myNode); - * if (range.isNothing()) { - * // Handle unknown nodes however you see fit... - * return false; - * } - * - * // Don't care about the first ten, for whatever reason. - * range->skip(10); - * for (const JS::ubi::Node& dominatedNode : *range) { - * // ... - * } - */ - void skip(size_t n) { - beginPtr += n; - if (beginPtr > endPtr) - beginPtr = endPtr; - } - }; - - private: - /** - * The set of all dominated sets in a dominator tree. - * - * Internally stores the sets in a contiguous array, with a side table of - * indices into that contiguous array to denote the start index of each - * individual set. - */ - class DominatedSets - { - JS::ubi::Vector<uint32_t> dominated; - JS::ubi::Vector<uint32_t> indices; - - DominatedSets(JS::ubi::Vector<uint32_t>&& dominated, JS::ubi::Vector<uint32_t>&& indices) - : dominated(mozilla::Move(dominated)) - , indices(mozilla::Move(indices)) - { } - - public: - // DominatedSets is not copy-able. - DominatedSets(const DominatedSets& rhs) = delete; - DominatedSets& operator=(const DominatedSets& rhs) = delete; - - // DominatedSets is move-able. - DominatedSets(DominatedSets&& rhs) - : dominated(mozilla::Move(rhs.dominated)) - , indices(mozilla::Move(rhs.indices)) - { - MOZ_ASSERT(this != &rhs, "self-move not allowed"); - } - DominatedSets& operator=(DominatedSets&& rhs) { - this->~DominatedSets(); - new (this) DominatedSets(mozilla::Move(rhs)); - return *this; - } - - /** - * Create the DominatedSets given the mapping of a node index to its - * immediate dominator. Returns `Some` on success, `Nothing` on OOM - * failure. - */ - static mozilla::Maybe<DominatedSets> Create(const JS::ubi::Vector<uint32_t>& doms) { - auto length = doms.length(); - MOZ_ASSERT(length < UINT32_MAX); - - // Create a vector `dominated` holding a flattened set of buckets of - // immediately dominated children nodes, with a lookup table - // `indices` mapping from each node to the beginning of its bucket. - // - // This has three phases: - // - // 1. Iterate over the full set of nodes and count up the size of - // each bucket. These bucket sizes are temporarily stored in the - // `indices` vector. - // - // 2. Convert the `indices` vector to store the cumulative sum of - // the sizes of all buckets before each index, resulting in a - // mapping from node index to one past the end of that node's - // bucket. - // - // 3. Iterate over the full set of nodes again, filling in bucket - // entries from the end of the bucket's range to its - // beginning. This decrements each index as a bucket entry is - // filled in. After having filled in all of a bucket's entries, - // the index points to the start of the bucket. - - JS::ubi::Vector<uint32_t> dominated; - JS::ubi::Vector<uint32_t> indices; - if (!dominated.growBy(length) || !indices.growBy(length)) - return mozilla::Nothing(); - - // 1 - memset(indices.begin(), 0, length * sizeof(uint32_t)); - for (uint32_t i = 0; i < length; i++) - indices[doms[i]]++; - - // 2 - uint32_t sumOfSizes = 0; - for (uint32_t i = 0; i < length; i++) { - sumOfSizes += indices[i]; - MOZ_ASSERT(sumOfSizes <= length); - indices[i] = sumOfSizes; - } - - // 3 - for (uint32_t i = 0; i < length; i++) { - auto idxOfDom = doms[i]; - indices[idxOfDom]--; - dominated[indices[idxOfDom]] = i; - } - -#ifdef DEBUG - // Assert that our buckets are non-overlapping and don't run off the - // end of the vector. - uint32_t lastIndex = 0; - for (uint32_t i = 0; i < length; i++) { - MOZ_ASSERT(indices[i] >= lastIndex); - MOZ_ASSERT(indices[i] < length); - lastIndex = indices[i]; - } -#endif - - return mozilla::Some(DominatedSets(mozilla::Move(dominated), mozilla::Move(indices))); - } - - /** - * Get the set of nodes immediately dominated by the node at - * `postOrder[nodeIndex]`. - */ - DominatedSetRange dominatedSet(JS::ubi::Vector<Node>& postOrder, uint32_t nodeIndex) const { - MOZ_ASSERT(postOrder.length() == indices.length()); - MOZ_ASSERT(nodeIndex < indices.length()); - auto end = nodeIndex == indices.length() - 1 - ? dominated.end() - : &dominated[indices[nodeIndex + 1]]; - return DominatedSetRange(postOrder, &dominated[indices[nodeIndex]], end); - } - }; - - private: - // Data members. - JS::ubi::Vector<Node> postOrder; - NodeToIndexMap nodeToPostOrderIndex; - JS::ubi::Vector<uint32_t> doms; - DominatedSets dominatedSets; - mozilla::Maybe<JS::ubi::Vector<JS::ubi::Node::Size>> retainedSizes; - - private: - // We use `UNDEFINED` as a sentinel value in the `doms` vector to signal - // that we haven't found any dominators for the node at the corresponding - // index in `postOrder` yet. - static const uint32_t UNDEFINED = UINT32_MAX; - - DominatorTree(JS::ubi::Vector<Node>&& postOrder, NodeToIndexMap&& nodeToPostOrderIndex, - JS::ubi::Vector<uint32_t>&& doms, DominatedSets&& dominatedSets) - : postOrder(mozilla::Move(postOrder)) - , nodeToPostOrderIndex(mozilla::Move(nodeToPostOrderIndex)) - , doms(mozilla::Move(doms)) - , dominatedSets(mozilla::Move(dominatedSets)) - , retainedSizes(mozilla::Nothing()) - { } - - static uint32_t intersect(JS::ubi::Vector<uint32_t>& doms, uint32_t finger1, uint32_t finger2) { - while (finger1 != finger2) { - if (finger1 < finger2) - finger1 = doms[finger1]; - else if (finger2 < finger1) - finger2 = doms[finger2]; - } - return finger1; - } - - // Do the post order traversal of the heap graph and populate our - // predecessor sets. - static MOZ_MUST_USE bool doTraversal(JSContext* cx, AutoCheckCannotGC& noGC, const Node& root, - JS::ubi::Vector<Node>& postOrder, - PredecessorSets& predecessorSets) { - uint32_t nodeCount = 0; - auto onNode = [&](const Node& node) { - nodeCount++; - if (MOZ_UNLIKELY(nodeCount == UINT32_MAX)) - return false; - return postOrder.append(node); - }; - - auto onEdge = [&](const Node& origin, const Edge& edge) { - auto p = predecessorSets.lookupForAdd(edge.referent); - if (!p) { - mozilla::UniquePtr<NodeSet, DeletePolicy<NodeSet>> set(js_new<NodeSet>()); - if (!set || - !set->init() || - !predecessorSets.add(p, edge.referent, mozilla::Move(set))) - { - return false; - } - } - MOZ_ASSERT(p && p->value()); - return p->value()->put(origin); - }; - - PostOrder traversal(cx, noGC); - return traversal.init() && - traversal.addStart(root) && - traversal.traverse(onNode, onEdge); - } - - // Populates the given `map` with an entry for each node to its index in - // `postOrder`. - static MOZ_MUST_USE bool mapNodesToTheirIndices(JS::ubi::Vector<Node>& postOrder, - NodeToIndexMap& map) { - MOZ_ASSERT(!map.initialized()); - MOZ_ASSERT(postOrder.length() < UINT32_MAX); - uint32_t length = postOrder.length(); - if (!map.init(length)) - return false; - for (uint32_t i = 0; i < length; i++) - map.putNewInfallible(postOrder[i], i); - return true; - } - - // Convert the Node -> NodeSet predecessorSets to a index -> Vector<index> - // form. - static MOZ_MUST_USE bool convertPredecessorSetsToVectors( - const Node& root, - JS::ubi::Vector<Node>& postOrder, - PredecessorSets& predecessorSets, - NodeToIndexMap& nodeToPostOrderIndex, - JS::ubi::Vector<JS::ubi::Vector<uint32_t>>& predecessorVectors) - { - MOZ_ASSERT(postOrder.length() < UINT32_MAX); - uint32_t length = postOrder.length(); - - MOZ_ASSERT(predecessorVectors.length() == 0); - if (!predecessorVectors.growBy(length)) - return false; - - for (uint32_t i = 0; i < length - 1; i++) { - auto& node = postOrder[i]; - MOZ_ASSERT(node != root, - "Only the last node should be root, since this was a post order traversal."); - - auto ptr = predecessorSets.lookup(node); - MOZ_ASSERT(ptr, - "Because this isn't the root, it had better have predecessors, or else how " - "did we even find it."); - - auto& predecessors = ptr->value(); - if (!predecessorVectors[i].reserve(predecessors->count())) - return false; - for (auto range = predecessors->all(); !range.empty(); range.popFront()) { - auto ptr = nodeToPostOrderIndex.lookup(range.front()); - MOZ_ASSERT(ptr); - predecessorVectors[i].infallibleAppend(ptr->value()); - } - } - predecessorSets.finish(); - return true; - } - - // Initialize `doms` such that the immediate dominator of the `root` is the - // `root` itself and all others are `UNDEFINED`. - static MOZ_MUST_USE bool initializeDominators(JS::ubi::Vector<uint32_t>& doms, - uint32_t length) { - MOZ_ASSERT(doms.length() == 0); - if (!doms.growByUninitialized(length)) - return false; - doms[length - 1] = length - 1; - for (uint32_t i = 0; i < length - 1; i++) - doms[i] = UNDEFINED; - return true; - } - - void assertSanity() const { - MOZ_ASSERT(postOrder.length() == doms.length()); - MOZ_ASSERT(postOrder.length() == nodeToPostOrderIndex.count()); - MOZ_ASSERT_IF(retainedSizes.isSome(), postOrder.length() == retainedSizes->length()); - } - - MOZ_MUST_USE bool computeRetainedSizes(mozilla::MallocSizeOf mallocSizeOf) { - MOZ_ASSERT(retainedSizes.isNothing()); - auto length = postOrder.length(); - - retainedSizes.emplace(); - if (!retainedSizes->growBy(length)) { - retainedSizes = mozilla::Nothing(); - return false; - } - - // Iterate in forward order so that we know all of a node's children in - // the dominator tree have already had their retained size - // computed. Then we can simply say that the retained size of a node is - // its shallow size (JS::ubi::Node::size) plus the retained sizes of its - // immediate children in the tree. - - for (uint32_t i = 0; i < length; i++) { - auto size = postOrder[i].size(mallocSizeOf); - - for (const auto& dominated : dominatedSets.dominatedSet(postOrder, i)) { - // The root node dominates itself, but shouldn't contribute to - // its own retained size. - if (dominated == postOrder[length - 1]) { - MOZ_ASSERT(i == length - 1); - continue; - } - - auto ptr = nodeToPostOrderIndex.lookup(dominated); - MOZ_ASSERT(ptr); - auto idxOfDominated = ptr->value(); - MOZ_ASSERT(idxOfDominated < i); - size += retainedSizes.ref()[idxOfDominated]; - } - - retainedSizes.ref()[i] = size; - } - - return true; - } - - public: - // DominatorTree is not copy-able. - DominatorTree(const DominatorTree&) = delete; - DominatorTree& operator=(const DominatorTree&) = delete; - - // DominatorTree is move-able. - DominatorTree(DominatorTree&& rhs) - : postOrder(mozilla::Move(rhs.postOrder)) - , nodeToPostOrderIndex(mozilla::Move(rhs.nodeToPostOrderIndex)) - , doms(mozilla::Move(rhs.doms)) - , dominatedSets(mozilla::Move(rhs.dominatedSets)) - , retainedSizes(mozilla::Move(rhs.retainedSizes)) - { - MOZ_ASSERT(this != &rhs, "self-move is not allowed"); - } - DominatorTree& operator=(DominatorTree&& rhs) { - this->~DominatorTree(); - new (this) DominatorTree(mozilla::Move(rhs)); - return *this; - } - - /** - * Construct a `DominatorTree` of the heap graph visible from `root`. The - * `root` is also used as the root of the resulting dominator tree. - * - * The resulting `DominatorTree` instance must not outlive the - * `JS::ubi::Node` graph it was constructed from. - * - * - For `JS::ubi::Node` graphs backed by the live heap graph, this means - * that the `DominatorTree`'s lifetime _must_ be contained within the - * scope of the provided `AutoCheckCannotGC` reference because a GC will - * invalidate the nodes. - * - * - For `JS::ubi::Node` graphs backed by some other offline structure - * provided by the embedder, the resulting `DominatorTree`'s lifetime is - * bounded by that offline structure's lifetime. - * - * In practice, this means that within SpiderMonkey we must treat - * `DominatorTree` as if it were backed by the live heap graph and trust - * that embedders with knowledge of the graph's implementation will do the - * Right Thing. - * - * Returns `mozilla::Nothing()` on OOM failure. It is the caller's - * responsibility to handle and report the OOM. - */ - static mozilla::Maybe<DominatorTree> - Create(JSContext* cx, AutoCheckCannotGC& noGC, const Node& root) { - JS::ubi::Vector<Node> postOrder; - PredecessorSets predecessorSets; - if (!predecessorSets.init() || !doTraversal(cx, noGC, root, postOrder, predecessorSets)) - return mozilla::Nothing(); - - MOZ_ASSERT(postOrder.length() < UINT32_MAX); - uint32_t length = postOrder.length(); - MOZ_ASSERT(postOrder[length - 1] == root); - - // From here on out we wish to avoid hash table lookups, and we use - // indices into `postOrder` instead of actual nodes wherever - // possible. This greatly improves the performance of this - // implementation, but we have to pay a little bit of upfront cost to - // convert our data structures to play along first. - - NodeToIndexMap nodeToPostOrderIndex; - if (!mapNodesToTheirIndices(postOrder, nodeToPostOrderIndex)) - return mozilla::Nothing(); - - JS::ubi::Vector<JS::ubi::Vector<uint32_t>> predecessorVectors; - if (!convertPredecessorSetsToVectors(root, postOrder, predecessorSets, nodeToPostOrderIndex, - predecessorVectors)) - return mozilla::Nothing(); - - JS::ubi::Vector<uint32_t> doms; - if (!initializeDominators(doms, length)) - return mozilla::Nothing(); - - bool changed = true; - while (changed) { - changed = false; - - // Iterate over the non-root nodes in reverse post order. - for (uint32_t indexPlusOne = length - 1; indexPlusOne > 0; indexPlusOne--) { - MOZ_ASSERT(postOrder[indexPlusOne - 1] != root); - - // Take the intersection of every predecessor's dominator set; - // that is the current best guess at the immediate dominator for - // this node. - - uint32_t newIDomIdx = UNDEFINED; - - auto& predecessors = predecessorVectors[indexPlusOne - 1]; - auto range = predecessors.all(); - for ( ; !range.empty(); range.popFront()) { - auto idx = range.front(); - if (doms[idx] != UNDEFINED) { - newIDomIdx = idx; - break; - } - } - - MOZ_ASSERT(newIDomIdx != UNDEFINED, - "Because the root is initialized to dominate itself and is the first " - "node in every path, there must exist a predecessor to this node that " - "also has a dominator."); - - for ( ; !range.empty(); range.popFront()) { - auto idx = range.front(); - if (doms[idx] != UNDEFINED) - newIDomIdx = intersect(doms, newIDomIdx, idx); - } - - // If the immediate dominator changed, we will have to do - // another pass of the outer while loop to continue the forward - // dataflow. - if (newIDomIdx != doms[indexPlusOne - 1]) { - doms[indexPlusOne - 1] = newIDomIdx; - changed = true; - } - } - } - - auto maybeDominatedSets = DominatedSets::Create(doms); - if (maybeDominatedSets.isNothing()) - return mozilla::Nothing(); - - return mozilla::Some(DominatorTree(mozilla::Move(postOrder), - mozilla::Move(nodeToPostOrderIndex), - mozilla::Move(doms), - mozilla::Move(*maybeDominatedSets))); - } - - /** - * Get the root node for this dominator tree. - */ - const Node& root() const { - return postOrder[postOrder.length() - 1]; - } - - /** - * Return the immediate dominator of the given `node`. If `node` was not - * reachable from the `root` that this dominator tree was constructed from, - * then return the null `JS::ubi::Node`. - */ - Node getImmediateDominator(const Node& node) const { - assertSanity(); - auto ptr = nodeToPostOrderIndex.lookup(node); - if (!ptr) - return Node(); - - auto idx = ptr->value(); - MOZ_ASSERT(idx < postOrder.length()); - return postOrder[doms[idx]]; - } - - /** - * Get the set of nodes immediately dominated by the given `node`. If `node` - * is not a member of this dominator tree, return `Nothing`. - * - * Example usage: - * - * mozilla::Maybe<DominatedSetRange> range = myDominatorTree.getDominatedSet(myNode); - * if (range.isNothing()) { - * // Handle unknown node however you see fit... - * return false; - * } - * - * for (const JS::ubi::Node& dominatedNode : *range) { - * // Do something with each immediately dominated node... - * } - */ - mozilla::Maybe<DominatedSetRange> getDominatedSet(const Node& node) { - assertSanity(); - auto ptr = nodeToPostOrderIndex.lookup(node); - if (!ptr) - return mozilla::Nothing(); - - auto idx = ptr->value(); - MOZ_ASSERT(idx < postOrder.length()); - return mozilla::Some(dominatedSets.dominatedSet(postOrder, idx)); - } - - /** - * Get the retained size of the given `node`. The size is placed in - * `outSize`, or 0 if `node` is not a member of the dominator tree. Returns - * false on OOM failure, leaving `outSize` unchanged. - */ - MOZ_MUST_USE bool getRetainedSize(const Node& node, mozilla::MallocSizeOf mallocSizeOf, - Node::Size& outSize) { - assertSanity(); - auto ptr = nodeToPostOrderIndex.lookup(node); - if (!ptr) { - outSize = 0; - return true; - } - - if (retainedSizes.isNothing() && !computeRetainedSizes(mallocSizeOf)) - return false; - - auto idx = ptr->value(); - MOZ_ASSERT(idx < postOrder.length()); - outSize = retainedSizes.ref()[idx]; - return true; - } -}; - -} // namespace ubi -} // namespace JS - -#endif // js_UbiNodeDominatorTree_h diff --git a/android/armeabi/include/spidermonkey/js/UbiNodePostOrder.h b/android/armeabi/include/spidermonkey/js/UbiNodePostOrder.h deleted file mode 100644 index a5042677..00000000 --- a/android/armeabi/include/spidermonkey/js/UbiNodePostOrder.h +++ /dev/null @@ -1,191 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_UbiNodePostOrder_h -#define js_UbiNodePostOrder_h - -#include "mozilla/Attributes.h" -#include "mozilla/Maybe.h" -#include "mozilla/Move.h" - -#include "jsalloc.h" - -#include "js/UbiNode.h" -#include "js/Utility.h" -#include "js/Vector.h" - -namespace JS { -namespace ubi { - -/** - * A post-order depth-first traversal of `ubi::Node` graphs. - * - * No GC may occur while an instance of `PostOrder` is live. - * - * The `NodeVisitor` type provided to `PostOrder::traverse` must have the - * following member: - * - * bool operator()(Node& node) - * - * The node visitor method. This method is called once for each `node` - * reachable from the start set in post-order. - * - * This visitor function should return true on success, or false if an error - * occurs. A false return value terminates the traversal immediately, and - * causes `PostOrder::traverse` to return false. - * - * The `EdgeVisitor` type provided to `PostOrder::traverse` must have the - * following member: - * - * bool operator()(Node& origin, Edge& edge) - * - * The edge visitor method. This method is called once for each outgoing - * `edge` from `origin` that is reachable from the start set. - * - * NB: UNLIKE NODES, THERE IS NO GUARANTEED ORDER IN WHICH EDGES AND THEIR - * ORIGINS ARE VISITED! - * - * This visitor function should return true on success, or false if an error - * occurs. A false return value terminates the traversal immediately, and - * causes `PostOrder::traverse` to return false. - */ -struct PostOrder { - private: - struct OriginAndEdges { - Node origin; - EdgeVector edges; - - OriginAndEdges(const Node& node, EdgeVector&& edges) - : origin(node) - , edges(mozilla::Move(edges)) - { } - - OriginAndEdges(const OriginAndEdges& rhs) = delete; - OriginAndEdges& operator=(const OriginAndEdges& rhs) = delete; - - OriginAndEdges(OriginAndEdges&& rhs) - : origin(rhs.origin) - , edges(mozilla::Move(rhs.edges)) - { - MOZ_ASSERT(&rhs != this, "self-move disallowed"); - } - - OriginAndEdges& operator=(OriginAndEdges&& rhs) { - this->~OriginAndEdges(); - new (this) OriginAndEdges(mozilla::Move(rhs)); - return *this; - } - }; - - using Stack = js::Vector<OriginAndEdges, 256, js::SystemAllocPolicy>; - using Set = js::HashSet<Node, js::DefaultHasher<Node>, js::SystemAllocPolicy>; - - JSContext* cx; - Set seen; - Stack stack; -#ifdef DEBUG - bool traversed; -#endif - - private: - MOZ_MUST_USE bool fillEdgesFromRange(EdgeVector& edges, js::UniquePtr<EdgeRange>& range) { - MOZ_ASSERT(range); - for ( ; !range->empty(); range->popFront()) { - if (!edges.append(mozilla::Move(range->front()))) - return false; - } - return true; - } - - MOZ_MUST_USE bool pushForTraversing(const Node& node) { - EdgeVector edges; - auto range = node.edges(cx, /* wantNames */ false); - return range && - fillEdgesFromRange(edges, range) && - stack.append(OriginAndEdges(node, mozilla::Move(edges))); - } - - - public: - // Construct a post-order traversal object. - // - // The traversal asserts that no GC happens in its runtime during its - // lifetime via the `AutoCheckCannotGC&` parameter. We do nothing with it, - // other than require it to exist with a lifetime that encloses our own. - PostOrder(JSContext* cx, AutoCheckCannotGC&) - : cx(cx) - , seen() - , stack() -#ifdef DEBUG - , traversed(false) -#endif - { } - - // Initialize this traversal object. Return false on OOM. - MOZ_MUST_USE bool init() { return seen.init(); } - - // Add `node` as a starting point for the traversal. You may add - // as many starting points as you like. Returns false on OOM. - MOZ_MUST_USE bool addStart(const Node& node) { - if (!seen.put(node)) - return false; - return pushForTraversing(node); - } - - // Traverse the graph in post-order, starting with the set of nodes passed - // to `addStart` and applying `onNode::operator()` for each node in the - // graph and `onEdge::operator()` for each edge in the graph, as described - // above. - // - // This should be called only once per instance of this class. - // - // Return false on OOM or error return from `onNode::operator()` or - // `onEdge::operator()`. - template<typename NodeVisitor, typename EdgeVisitor> - MOZ_MUST_USE bool traverse(NodeVisitor onNode, EdgeVisitor onEdge) { -#ifdef DEBUG - MOZ_ASSERT(!traversed, "Can only traverse() once!"); - traversed = true; -#endif - - while (!stack.empty()) { - auto& origin = stack.back().origin; - auto& edges = stack.back().edges; - - if (edges.empty()) { - if (!onNode(origin)) - return false; - stack.popBack(); - continue; - } - - Edge edge = mozilla::Move(edges.back()); - edges.popBack(); - - if (!onEdge(origin, edge)) - return false; - - auto ptr = seen.lookupForAdd(edge.referent); - // We've already seen this node, don't follow its edges. - if (ptr) - continue; - - // Mark the referent as seen and follow its edges. - if (!seen.add(ptr, edge.referent) || - !pushForTraversing(edge.referent)) - { - return false; - } - } - - return true; - } -}; - -} // namespace ubi -} // namespace JS - -#endif // js_UbiNodePostOrder_h diff --git a/android/armeabi/include/spidermonkey/js/UbiNodeShortestPaths.h b/android/armeabi/include/spidermonkey/js/UbiNodeShortestPaths.h deleted file mode 100644 index edd5aebb..00000000 --- a/android/armeabi/include/spidermonkey/js/UbiNodeShortestPaths.h +++ /dev/null @@ -1,350 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_UbiNodeShortestPaths_h -#define js_UbiNodeShortestPaths_h - -#include "mozilla/Attributes.h" -#include "mozilla/Maybe.h" -#include "mozilla/Move.h" - -#include "jsalloc.h" - -#include "js/UbiNodeBreadthFirst.h" -#include "js/Vector.h" - -namespace JS { -namespace ubi { - -/** - * A back edge along a path in the heap graph. - */ -struct JS_PUBLIC_API(BackEdge) -{ - private: - Node predecessor_; - EdgeName name_; - - public: - using Ptr = mozilla::UniquePtr<BackEdge, JS::DeletePolicy<BackEdge>>; - - BackEdge() : predecessor_(), name_(nullptr) { } - - MOZ_MUST_USE bool init(const Node& predecessor, Edge& edge) { - MOZ_ASSERT(!predecessor_); - MOZ_ASSERT(!name_); - - predecessor_ = predecessor; - name_ = mozilla::Move(edge.name); - return true; - } - - BackEdge(const BackEdge&) = delete; - BackEdge& operator=(const BackEdge&) = delete; - - BackEdge(BackEdge&& rhs) - : predecessor_(rhs.predecessor_) - , name_(mozilla::Move(rhs.name_)) - { - MOZ_ASSERT(&rhs != this); - } - - BackEdge& operator=(BackEdge&& rhs) { - this->~BackEdge(); - new(this) BackEdge(Move(rhs)); - return *this; - } - - Ptr clone() const; - - const EdgeName& name() const { return name_; } - EdgeName& name() { return name_; } - - const JS::ubi::Node& predecessor() const { return predecessor_; } -}; - -/** - * A path is a series of back edges from which we discovered a target node. - */ -using Path = JS::ubi::Vector<BackEdge*>; - -/** - * The `JS::ubi::ShortestPaths` type represents a collection of up to N shortest - * retaining paths for each of a target set of nodes, starting from the same - * root node. - */ -struct JS_PUBLIC_API(ShortestPaths) -{ - private: - // Types, type aliases, and data members. - - using BackEdgeVector = JS::ubi::Vector<BackEdge::Ptr>; - using NodeToBackEdgeVectorMap = js::HashMap<Node, BackEdgeVector, js::DefaultHasher<Node>, - js::SystemAllocPolicy>; - - struct Handler; - using Traversal = BreadthFirst<Handler>; - - /** - * A `JS::ubi::BreadthFirst` traversal handler that records back edges for - * how we reached each node, allowing us to reconstruct the shortest - * retaining paths after the traversal. - */ - struct Handler - { - using NodeData = BackEdge; - - ShortestPaths& shortestPaths; - size_t totalMaxPathsToRecord; - size_t totalPathsRecorded; - - explicit Handler(ShortestPaths& shortestPaths) - : shortestPaths(shortestPaths) - , totalMaxPathsToRecord(shortestPaths.targets_.count() * shortestPaths.maxNumPaths_) - , totalPathsRecorded(0) - { - } - - bool - operator()(Traversal& traversal, JS::ubi::Node origin, JS::ubi::Edge& edge, - BackEdge* back, bool first) - { - MOZ_ASSERT(back); - MOZ_ASSERT(origin == shortestPaths.root_ || traversal.visited.has(origin)); - MOZ_ASSERT(totalPathsRecorded < totalMaxPathsToRecord); - - if (first && !back->init(origin, edge)) - return false; - - if (!shortestPaths.targets_.has(edge.referent)) - return true; - - // If `first` is true, then we moved the edge's name into `back` in - // the above call to `init`. So clone that back edge to get the - // correct edge name. If `first` is not true, then our edge name is - // still in `edge`. This accounts for the asymmetry between - // `back->clone()` in the first branch, and the `init` call in the - // second branch. - - if (first) { - BackEdgeVector paths; - if (!paths.reserve(shortestPaths.maxNumPaths_)) - return false; - auto cloned = back->clone(); - if (!cloned) - return false; - paths.infallibleAppend(mozilla::Move(cloned)); - if (!shortestPaths.paths_.putNew(edge.referent, mozilla::Move(paths))) - return false; - totalPathsRecorded++; - } else { - auto ptr = shortestPaths.paths_.lookup(edge.referent); - MOZ_ASSERT(ptr, - "This isn't the first time we have seen the target node `edge.referent`. " - "We should have inserted it into shortestPaths.paths_ the first time we " - "saw it."); - - if (ptr->value().length() < shortestPaths.maxNumPaths_) { - BackEdge::Ptr thisBackEdge(js_new<BackEdge>()); - if (!thisBackEdge || !thisBackEdge->init(origin, edge)) - return false; - ptr->value().infallibleAppend(mozilla::Move(thisBackEdge)); - totalPathsRecorded++; - } - } - - MOZ_ASSERT(totalPathsRecorded <= totalMaxPathsToRecord); - if (totalPathsRecorded == totalMaxPathsToRecord) - traversal.stop(); - - return true; - } - - }; - - // The maximum number of paths to record for each node. - uint32_t maxNumPaths_; - - // The root node we are starting the search from. - Node root_; - - // The set of nodes we are searching for paths to. - NodeSet targets_; - - // The resulting paths. - NodeToBackEdgeVectorMap paths_; - - // Need to keep alive the traversal's back edges so we can walk them later - // when the traversal is over when recreating the shortest paths. - Traversal::NodeMap backEdges_; - - private: - // Private methods. - - ShortestPaths(uint32_t maxNumPaths, const Node& root, NodeSet&& targets) - : maxNumPaths_(maxNumPaths) - , root_(root) - , targets_(mozilla::Move(targets)) - , paths_() - , backEdges_() - { - MOZ_ASSERT(maxNumPaths_ > 0); - MOZ_ASSERT(root_); - MOZ_ASSERT(targets_.initialized()); - } - - bool initialized() const { - return targets_.initialized() && - paths_.initialized() && - backEdges_.initialized(); - } - - public: - // Public methods. - - ShortestPaths(ShortestPaths&& rhs) - : maxNumPaths_(rhs.maxNumPaths_) - , root_(rhs.root_) - , targets_(mozilla::Move(rhs.targets_)) - , paths_(mozilla::Move(rhs.paths_)) - , backEdges_(mozilla::Move(rhs.backEdges_)) - { - MOZ_ASSERT(this != &rhs, "self-move is not allowed"); - } - - ShortestPaths& operator=(ShortestPaths&& rhs) { - this->~ShortestPaths(); - new (this) ShortestPaths(mozilla::Move(rhs)); - return *this; - } - - ShortestPaths(const ShortestPaths&) = delete; - ShortestPaths& operator=(const ShortestPaths&) = delete; - - /** - * Construct a new `JS::ubi::ShortestPaths`, finding up to `maxNumPaths` - * shortest retaining paths for each target node in `targets` starting from - * `root`. - * - * The resulting `ShortestPaths` instance must not outlive the - * `JS::ubi::Node` graph it was constructed from. - * - * - For `JS::ubi::Node` graphs backed by the live heap graph, this means - * that the `ShortestPaths`'s lifetime _must_ be contained within the - * scope of the provided `AutoCheckCannotGC` reference because a GC will - * invalidate the nodes. - * - * - For `JS::ubi::Node` graphs backed by some other offline structure - * provided by the embedder, the resulting `ShortestPaths`'s lifetime is - * bounded by that offline structure's lifetime. - * - * Returns `mozilla::Nothing()` on OOM failure. It is the caller's - * responsibility to handle and report the OOM. - */ - static mozilla::Maybe<ShortestPaths> - Create(JSContext* cx, AutoCheckCannotGC& noGC, uint32_t maxNumPaths, const Node& root, NodeSet&& targets) { - MOZ_ASSERT(targets.count() > 0); - MOZ_ASSERT(maxNumPaths > 0); - - size_t count = targets.count(); - ShortestPaths paths(maxNumPaths, root, mozilla::Move(targets)); - if (!paths.paths_.init(count)) - return mozilla::Nothing(); - - Handler handler(paths); - Traversal traversal(cx, handler, noGC); - traversal.wantNames = true; - if (!traversal.init() || !traversal.addStart(root) || !traversal.traverse()) - return mozilla::Nothing(); - - // Take ownership of the back edges we created while traversing the - // graph so that we can follow them from `paths_` and don't - // use-after-free. - paths.backEdges_ = mozilla::Move(traversal.visited); - - MOZ_ASSERT(paths.initialized()); - return mozilla::Some(mozilla::Move(paths)); - } - - /** - * Get a range that iterates over each target node we searched for retaining - * paths for. The returned range must not outlive the `ShortestPaths` - * instance. - */ - NodeSet::Range eachTarget() const { - MOZ_ASSERT(initialized()); - return targets_.all(); - } - - /** - * Invoke the provided functor/lambda/callable once for each retaining path - * discovered for `target`. The `func` is passed a single `JS::ubi::Path&` - * argument, which contains each edge along the path ordered starting from - * the root and ending at the target, and must not outlive the scope of the - * call. - * - * Note that it is possible that we did not find any paths from the root to - * the given target, in which case `func` will not be invoked. - */ - template <class Func> - MOZ_MUST_USE bool forEachPath(const Node& target, Func func) { - MOZ_ASSERT(initialized()); - MOZ_ASSERT(targets_.has(target)); - - auto ptr = paths_.lookup(target); - - // We didn't find any paths to this target, so nothing to do here. - if (!ptr) - return true; - - MOZ_ASSERT(ptr->value().length() <= maxNumPaths_); - - Path path; - for (const auto& backEdge : ptr->value()) { - path.clear(); - - if (!path.append(backEdge.get())) - return false; - - Node here = backEdge->predecessor(); - MOZ_ASSERT(here); - - while (here != root_) { - auto p = backEdges_.lookup(here); - MOZ_ASSERT(p); - if (!path.append(&p->value())) - return false; - here = p->value().predecessor(); - MOZ_ASSERT(here); - } - - path.reverse(); - - if (!func(path)) - return false; - } - - return true; - } -}; - -#ifdef DEBUG -// A helper function to dump the first `maxNumPaths` shortest retaining paths to -// `node` from the GC roots. Useful when GC things you expect to have been -// reclaimed by the collector haven't been! -// -// Usage: -// -// JSObject* foo = ...; -// JS::ubi::dumpPaths(rt, JS::ubi::Node(foo)); -JS_PUBLIC_API(void) -dumpPaths(JSRuntime* rt, Node node, uint32_t maxNumPaths = 10); -#endif - -} // namespace ubi -} // namespace JS - -#endif // js_UbiNodeShortestPaths_h diff --git a/android/armeabi/include/spidermonkey/js/UniquePtr.h b/android/armeabi/include/spidermonkey/js/UniquePtr.h deleted file mode 100644 index 0236bab4..00000000 --- a/android/armeabi/include/spidermonkey/js/UniquePtr.h +++ /dev/null @@ -1,61 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_UniquePtr_h -#define js_UniquePtr_h - -#include "mozilla/UniquePtr.h" - -#include "js/Utility.h" - -namespace js { - -// Replacement for mozilla::UniquePtr that defaults to js::DefaultDelete. -template <typename T, typename D = JS::DeletePolicy<T>> -using UniquePtr = mozilla::UniquePtr<T, D>; - -namespace detail { - -template<typename T> -struct UniqueSelector -{ - typedef UniquePtr<T> SingleObject; -}; - -template<typename T> -struct UniqueSelector<T[]> -{ - typedef UniquePtr<T[]> UnknownBound; -}; - -template<typename T, decltype(sizeof(int)) N> -struct UniqueSelector<T[N]> -{ - typedef UniquePtr<T[N]> KnownBound; -}; - -} // namespace detail - -// Replacement for mozilla::MakeUnique that correctly calls js_new and produces -// a js::UniquePtr. -template<typename T, typename... Args> -typename detail::UniqueSelector<T>::SingleObject -MakeUnique(Args&&... aArgs) -{ - return UniquePtr<T>(js_new<T>(mozilla::Forward<Args>(aArgs)...)); -} - -template<typename T> -typename detail::UniqueSelector<T>::UnknownBound -MakeUnique(decltype(sizeof(int)) aN) = delete; - -template<typename T, typename... Args> -typename detail::UniqueSelector<T>::KnownBound -MakeUnique(Args&&... aArgs) = delete; - -} // namespace js - -#endif /* js_UniquePtr_h */ diff --git a/android/armeabi/include/spidermonkey/js/Utility.h b/android/armeabi/include/spidermonkey/js/Utility.h deleted file mode 100644 index 75214c32..00000000 --- a/android/armeabi/include/spidermonkey/js/Utility.h +++ /dev/null @@ -1,577 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_Utility_h -#define js_Utility_h - -#include "mozilla/Assertions.h" -#include "mozilla/Atomics.h" -#include "mozilla/Attributes.h" -#include "mozilla/Compiler.h" -#include "mozilla/Move.h" -#include "mozilla/Scoped.h" -#include "mozilla/TemplateLib.h" -#include "mozilla/UniquePtr.h" - -#include <stdlib.h> -#include <string.h> - -#ifdef JS_OOM_DO_BACKTRACES -#include <execinfo.h> -#include <stdio.h> -#endif - -#include "jstypes.h" - -/* The public JS engine namespace. */ -namespace JS {} - -/* The mozilla-shared reusable template/utility namespace. */ -namespace mozilla {} - -/* The private JS engine namespace. */ -namespace js {} - -#define JS_STATIC_ASSERT(cond) static_assert(cond, "JS_STATIC_ASSERT") -#define JS_STATIC_ASSERT_IF(cond, expr) MOZ_STATIC_ASSERT_IF(cond, expr, "JS_STATIC_ASSERT_IF") - -extern MOZ_NORETURN MOZ_COLD JS_PUBLIC_API(void) -JS_Assert(const char* s, const char* file, int ln); - -/* - * Custom allocator support for SpiderMonkey - */ -#if defined JS_USE_CUSTOM_ALLOCATOR -# include "jscustomallocator.h" -#else - -namespace js { -namespace oom { - -/* - * To make testing OOM in certain helper threads more effective, - * allow restricting the OOM testing to a certain helper thread - * type. This allows us to fail e.g. in off-thread script parsing - * without causing an OOM in the main thread first. - */ -enum ThreadType { - THREAD_TYPE_NONE = 0, // 0 - THREAD_TYPE_MAIN, // 1 - THREAD_TYPE_ASMJS, // 2 - THREAD_TYPE_ION, // 3 - THREAD_TYPE_PARSE, // 4 - THREAD_TYPE_COMPRESS, // 5 - THREAD_TYPE_GCHELPER, // 6 - THREAD_TYPE_GCPARALLEL, // 7 - THREAD_TYPE_PROMISE_TASK, // 8 - THREAD_TYPE_MAX // Used to check shell function arguments -}; - -/* - * Getter/Setter functions to encapsulate mozilla::ThreadLocal, - * implementation is in jsutil.cpp. - */ -# if defined(DEBUG) || defined(JS_OOM_BREAKPOINT) -extern bool InitThreadType(void); -extern void SetThreadType(ThreadType); -extern uint32_t GetThreadType(void); -# else -inline bool InitThreadType(void) { return true; } -inline void SetThreadType(ThreadType t) {}; -inline uint32_t GetThreadType(void) { return 0; } -# endif - -} /* namespace oom */ -} /* namespace js */ - -# if defined(DEBUG) || defined(JS_OOM_BREAKPOINT) - -#ifdef JS_OOM_BREAKPOINT -static MOZ_NEVER_INLINE void js_failedAllocBreakpoint() { asm(""); } -#define JS_OOM_CALL_BP_FUNC() js_failedAllocBreakpoint() -#else -#define JS_OOM_CALL_BP_FUNC() do {} while(0) -#endif - -namespace js { -namespace oom { - -/* - * Out of memory testing support. We provide various testing functions to - * simulate OOM conditions and so we can test that they are handled correctly. - */ - -extern JS_PUBLIC_DATA(uint32_t) targetThread; -extern JS_PUBLIC_DATA(uint64_t) maxAllocations; -extern JS_PUBLIC_DATA(uint64_t) counter; -extern JS_PUBLIC_DATA(bool) failAlways; - -extern void -SimulateOOMAfter(uint64_t allocations, uint32_t thread, bool always); - -extern void -ResetSimulatedOOM(); - -inline bool -IsThreadSimulatingOOM() -{ - return js::oom::targetThread && js::oom::targetThread == js::oom::GetThreadType(); -} - -inline bool -IsSimulatedOOMAllocation() -{ - return IsThreadSimulatingOOM() && - (counter == maxAllocations || (counter > maxAllocations && failAlways)); -} - -inline bool -ShouldFailWithOOM() -{ - if (!IsThreadSimulatingOOM()) - return false; - - counter++; - if (IsSimulatedOOMAllocation()) { - JS_OOM_CALL_BP_FUNC(); - return true; - } - return false; -} - -inline bool -HadSimulatedOOM() { - return counter >= maxAllocations; -} - -} /* namespace oom */ -} /* namespace js */ - -# define JS_OOM_POSSIBLY_FAIL() \ - do { \ - if (js::oom::ShouldFailWithOOM()) \ - return nullptr; \ - } while (0) - -# define JS_OOM_POSSIBLY_FAIL_BOOL() \ - do { \ - if (js::oom::ShouldFailWithOOM()) \ - return false; \ - } while (0) - -# else - -# define JS_OOM_POSSIBLY_FAIL() do {} while(0) -# define JS_OOM_POSSIBLY_FAIL_BOOL() do {} while(0) -namespace js { -namespace oom { -static inline bool IsSimulatedOOMAllocation() { return false; } -static inline bool ShouldFailWithOOM() { return false; } -} /* namespace oom */ -} /* namespace js */ - -# endif /* DEBUG || JS_OOM_BREAKPOINT */ - -namespace js { - -/* Disable OOM testing in sections which are not OOM safe. */ -struct MOZ_RAII AutoEnterOOMUnsafeRegion -{ - MOZ_NORETURN MOZ_COLD void crash(const char* reason); - MOZ_NORETURN MOZ_COLD void crash(size_t size, const char* reason); - - using AnnotateOOMAllocationSizeCallback = void(*)(size_t); - static AnnotateOOMAllocationSizeCallback annotateOOMSizeCallback; - static void setAnnotateOOMAllocationSizeCallback(AnnotateOOMAllocationSizeCallback callback) { - annotateOOMSizeCallback = callback; - } - -#if defined(DEBUG) || defined(JS_OOM_BREAKPOINT) - AutoEnterOOMUnsafeRegion() - : oomEnabled_(oom::IsThreadSimulatingOOM() && oom::maxAllocations != UINT64_MAX), - oomAfter_(0) - { - if (oomEnabled_) { - MOZ_ALWAYS_TRUE(owner_.compareExchange(nullptr, this)); - oomAfter_ = int64_t(oom::maxAllocations) - int64_t(oom::counter); - oom::maxAllocations = UINT64_MAX; - } - } - - ~AutoEnterOOMUnsafeRegion() { - if (oomEnabled_) { - MOZ_ASSERT(oom::maxAllocations == UINT64_MAX); - int64_t maxAllocations = int64_t(oom::counter) + oomAfter_; - MOZ_ASSERT(maxAllocations >= 0, - "alloc count + oom limit exceeds range, your oom limit is probably too large"); - oom::maxAllocations = uint64_t(maxAllocations); - MOZ_ALWAYS_TRUE(owner_.compareExchange(this, nullptr)); - } - } - - private: - // Used to catch concurrent use from other threads. - static mozilla::Atomic<AutoEnterOOMUnsafeRegion*> owner_; - - bool oomEnabled_; - int64_t oomAfter_; -#endif -}; - -} /* namespace js */ - -static inline void* js_malloc(size_t bytes) -{ - JS_OOM_POSSIBLY_FAIL(); - return malloc(bytes); -} - -static inline void* js_calloc(size_t bytes) -{ - JS_OOM_POSSIBLY_FAIL(); - return calloc(bytes, 1); -} - -static inline void* js_calloc(size_t nmemb, size_t size) -{ - JS_OOM_POSSIBLY_FAIL(); - return calloc(nmemb, size); -} - -static inline void* js_realloc(void* p, size_t bytes) -{ - // realloc() with zero size is not portable, as some implementations may - // return nullptr on success and free |p| for this. We assume nullptr - // indicates failure and that |p| is still valid. - MOZ_ASSERT(bytes != 0); - - JS_OOM_POSSIBLY_FAIL(); - return realloc(p, bytes); -} - -static inline void js_free(void* p) -{ - free(p); -} - -static inline char* js_strdup(const char* s) -{ - JS_OOM_POSSIBLY_FAIL(); - return strdup(s); -} -#endif/* JS_USE_CUSTOM_ALLOCATOR */ - -#include <new> - -/* - * Low-level memory management in SpiderMonkey: - * - * ** Do not use the standard malloc/free/realloc: SpiderMonkey allows these - * to be redefined (via JS_USE_CUSTOM_ALLOCATOR) and Gecko even #define's - * these symbols. - * - * ** Do not use the builtin C++ operator new and delete: these throw on - * error and we cannot override them not to. - * - * Allocation: - * - * - If the lifetime of the allocation is tied to the lifetime of a GC-thing - * (that is, finalizing the GC-thing will free the allocation), call one of - * the following functions: - * - * JSContext::{malloc_,realloc_,calloc_,new_} - * JSRuntime::{malloc_,realloc_,calloc_,new_} - * - * These functions accumulate the number of bytes allocated which is used as - * part of the GC-triggering heuristic. - * - * The difference between the JSContext and JSRuntime versions is that the - * cx version reports an out-of-memory error on OOM. (This follows from the - * general SpiderMonkey idiom that a JSContext-taking function reports its - * own errors.) - * - * - Otherwise, use js_malloc/js_realloc/js_calloc/js_new - * - * Deallocation: - * - * - Ordinarily, use js_free/js_delete. - * - * - For deallocations during GC finalization, use one of the following - * operations on the FreeOp provided to the finalizer: - * - * FreeOp::{free_,delete_} - * - * The advantage of these operations is that the memory is batched and freed - * on another thread. - */ - -/* - * Given a class which should provide a 'new' method, add - * JS_DECLARE_NEW_METHODS (see js::MallocProvider for an example). - * - * Note: Do not add a ; at the end of a use of JS_DECLARE_NEW_METHODS, - * or the build will break. - */ -#define JS_DECLARE_NEW_METHODS(NEWNAME, ALLOCATOR, QUALIFIERS) \ - template <class T, typename... Args> \ - QUALIFIERS T * \ - NEWNAME(Args&&... args) MOZ_HEAP_ALLOCATOR { \ - void* memory = ALLOCATOR(sizeof(T)); \ - return MOZ_LIKELY(memory) \ - ? new(memory) T(mozilla::Forward<Args>(args)...) \ - : nullptr; \ - } - -/* - * Given a class which should provide 'make' methods, add - * JS_DECLARE_MAKE_METHODS (see js::MallocProvider for an example). This - * method is functionally the same as JS_DECLARE_NEW_METHODS: it just declares - * methods that return mozilla::UniquePtr instances that will singly-manage - * ownership of the created object. - * - * Note: Do not add a ; at the end of a use of JS_DECLARE_MAKE_METHODS, - * or the build will break. - */ -#define JS_DECLARE_MAKE_METHODS(MAKENAME, NEWNAME, QUALIFIERS)\ - template <class T, typename... Args> \ - QUALIFIERS mozilla::UniquePtr<T, JS::DeletePolicy<T>> \ - MAKENAME(Args&&... args) MOZ_HEAP_ALLOCATOR { \ - T* ptr = NEWNAME<T>(mozilla::Forward<Args>(args)...); \ - return mozilla::UniquePtr<T, JS::DeletePolicy<T>>(ptr); \ - } - -JS_DECLARE_NEW_METHODS(js_new, js_malloc, static MOZ_ALWAYS_INLINE) - -namespace js { - -/* - * Calculate the number of bytes needed to allocate |numElems| contiguous - * instances of type |T|. Return false if the calculation overflowed. - */ -template <typename T> -MOZ_MUST_USE inline bool -CalculateAllocSize(size_t numElems, size_t* bytesOut) -{ - *bytesOut = numElems * sizeof(T); - return (numElems & mozilla::tl::MulOverflowMask<sizeof(T)>::value) == 0; -} - -/* - * Calculate the number of bytes needed to allocate a single instance of type - * |T| followed by |numExtra| contiguous instances of type |Extra|. Return - * false if the calculation overflowed. - */ -template <typename T, typename Extra> -MOZ_MUST_USE inline bool -CalculateAllocSizeWithExtra(size_t numExtra, size_t* bytesOut) -{ - *bytesOut = sizeof(T) + numExtra * sizeof(Extra); - return (numExtra & mozilla::tl::MulOverflowMask<sizeof(Extra)>::value) == 0 && - *bytesOut >= sizeof(T); -} - -} /* namespace js */ - -template <class T> -static MOZ_ALWAYS_INLINE void -js_delete(const T* p) -{ - if (p) { - p->~T(); - js_free(const_cast<T*>(p)); - } -} - -template<class T> -static MOZ_ALWAYS_INLINE void -js_delete_poison(const T* p) -{ - if (p) { - p->~T(); - memset(const_cast<T*>(p), 0x3B, sizeof(T)); - js_free(const_cast<T*>(p)); - } -} - -template <class T> -static MOZ_ALWAYS_INLINE T* -js_pod_malloc() -{ - return static_cast<T*>(js_malloc(sizeof(T))); -} - -template <class T> -static MOZ_ALWAYS_INLINE T* -js_pod_calloc() -{ - return static_cast<T*>(js_calloc(sizeof(T))); -} - -template <class T> -static MOZ_ALWAYS_INLINE T* -js_pod_malloc(size_t numElems) -{ - size_t bytes; - if (MOZ_UNLIKELY(!js::CalculateAllocSize<T>(numElems, &bytes))) - return nullptr; - return static_cast<T*>(js_malloc(bytes)); -} - -template <class T> -static MOZ_ALWAYS_INLINE T* -js_pod_calloc(size_t numElems) -{ - size_t bytes; - if (MOZ_UNLIKELY(!js::CalculateAllocSize<T>(numElems, &bytes))) - return nullptr; - return static_cast<T*>(js_calloc(bytes)); -} - -template <class T> -static MOZ_ALWAYS_INLINE T* -js_pod_realloc(T* prior, size_t oldSize, size_t newSize) -{ - MOZ_ASSERT(!(oldSize & mozilla::tl::MulOverflowMask<sizeof(T)>::value)); - size_t bytes; - if (MOZ_UNLIKELY(!js::CalculateAllocSize<T>(newSize, &bytes))) - return nullptr; - return static_cast<T*>(js_realloc(prior, bytes)); -} - -namespace js { - -template<typename T> -struct ScopedFreePtrTraits -{ - typedef T* type; - static T* empty() { return nullptr; } - static void release(T* ptr) { js_free(ptr); } -}; -SCOPED_TEMPLATE(ScopedJSFreePtr, ScopedFreePtrTraits) - -template <typename T> -struct ScopedDeletePtrTraits : public ScopedFreePtrTraits<T> -{ - static void release(T* ptr) { js_delete(ptr); } -}; -SCOPED_TEMPLATE(ScopedJSDeletePtr, ScopedDeletePtrTraits) - -template <typename T> -struct ScopedReleasePtrTraits : public ScopedFreePtrTraits<T> -{ - static void release(T* ptr) { if (ptr) ptr->release(); } -}; -SCOPED_TEMPLATE(ScopedReleasePtr, ScopedReleasePtrTraits) - -} /* namespace js */ - -namespace JS { - -template<typename T> -struct DeletePolicy -{ - constexpr DeletePolicy() {} - - template<typename U> - MOZ_IMPLICIT DeletePolicy(DeletePolicy<U> other, - typename mozilla::EnableIf<mozilla::IsConvertible<U*, T*>::value, - int>::Type dummy = 0) - {} - - void operator()(const T* ptr) { - js_delete(const_cast<T*>(ptr)); - } -}; - -struct FreePolicy -{ - void operator()(const void* ptr) { - js_free(const_cast<void*>(ptr)); - } -}; - -typedef mozilla::UniquePtr<char[], JS::FreePolicy> UniqueChars; -typedef mozilla::UniquePtr<char16_t[], JS::FreePolicy> UniqueTwoByteChars; - -} // namespace JS - -namespace js { - -/* Integral types for all hash functions. */ -typedef uint32_t HashNumber; -const unsigned HashNumberSizeBits = 32; - -namespace detail { - -/* - * Given a raw hash code, h, return a number that can be used to select a hash - * bucket. - * - * This function aims to produce as uniform an output distribution as possible, - * especially in the most significant (leftmost) bits, even though the input - * distribution may be highly nonrandom, given the constraints that this must - * be deterministic and quick to compute. - * - * Since the leftmost bits of the result are best, the hash bucket index is - * computed by doing ScrambleHashCode(h) / (2^32/N) or the equivalent - * right-shift, not ScrambleHashCode(h) % N or the equivalent bit-mask. - * - * FIXME: OrderedHashTable uses a bit-mask; see bug 775896. - */ -inline HashNumber -ScrambleHashCode(HashNumber h) -{ - /* - * Simply returning h would not cause any hash tables to produce wrong - * answers. But it can produce pathologically bad performance: The caller - * right-shifts the result, keeping only the highest bits. The high bits of - * hash codes are very often completely entropy-free. (So are the lowest - * bits.) - * - * So we use Fibonacci hashing, as described in Knuth, The Art of Computer - * Programming, 6.4. This mixes all the bits of the input hash code h. - * - * The value of goldenRatio is taken from the hex - * expansion of the golden ratio, which starts 1.9E3779B9.... - * This value is especially good if values with consecutive hash codes - * are stored in a hash table; see Knuth for details. - */ - static const HashNumber goldenRatio = 0x9E3779B9U; - return h * goldenRatio; -} - -} /* namespace detail */ - -} /* namespace js */ - -/* sixgill annotation defines */ -#ifndef HAVE_STATIC_ANNOTATIONS -# define HAVE_STATIC_ANNOTATIONS -# ifdef XGILL_PLUGIN -# define STATIC_PRECONDITION(COND) __attribute__((precondition(#COND))) -# define STATIC_PRECONDITION_ASSUME(COND) __attribute__((precondition_assume(#COND))) -# define STATIC_POSTCONDITION(COND) __attribute__((postcondition(#COND))) -# define STATIC_POSTCONDITION_ASSUME(COND) __attribute__((postcondition_assume(#COND))) -# define STATIC_INVARIANT(COND) __attribute__((invariant(#COND))) -# define STATIC_INVARIANT_ASSUME(COND) __attribute__((invariant_assume(#COND))) -# define STATIC_ASSUME(COND) \ - JS_BEGIN_MACRO \ - __attribute__((assume_static(#COND), unused)) \ - int STATIC_PASTE1(assume_static_, __COUNTER__); \ - JS_END_MACRO -# else /* XGILL_PLUGIN */ -# define STATIC_PRECONDITION(COND) /* nothing */ -# define STATIC_PRECONDITION_ASSUME(COND) /* nothing */ -# define STATIC_POSTCONDITION(COND) /* nothing */ -# define STATIC_POSTCONDITION_ASSUME(COND) /* nothing */ -# define STATIC_INVARIANT(COND) /* nothing */ -# define STATIC_INVARIANT_ASSUME(COND) /* nothing */ -# define STATIC_ASSUME(COND) JS_BEGIN_MACRO /* nothing */ JS_END_MACRO -# endif /* XGILL_PLUGIN */ -# define STATIC_SKIP_INFERENCE STATIC_INVARIANT(skip_inference()) -#endif /* HAVE_STATIC_ANNOTATIONS */ - -#endif /* js_Utility_h */ diff --git a/android/armeabi/include/spidermonkey/js/Value.h b/android/armeabi/include/spidermonkey/js/Value.h deleted file mode 100644 index 00fdad58..00000000 --- a/android/armeabi/include/spidermonkey/js/Value.h +++ /dev/null @@ -1,1509 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* JS::Value implementation. */ - -#ifndef js_Value_h -#define js_Value_h - -#include "mozilla/Attributes.h" -#include "mozilla/Casting.h" -#include "mozilla/FloatingPoint.h" -#include "mozilla/Likely.h" - -#include <limits> /* for std::numeric_limits */ - -#include "js-config.h" -#include "jstypes.h" - -#include "js/GCAPI.h" -#include "js/RootingAPI.h" -#include "js/Utility.h" - -namespace JS { class Value; } - -/* JS::Value can store a full int32_t. */ -#define JSVAL_INT_BITS 32 -#define JSVAL_INT_MIN ((int32_t)0x80000000) -#define JSVAL_INT_MAX ((int32_t)0x7fffffff) - -#if defined(JS_PUNBOX64) -# define JSVAL_TAG_SHIFT 47 -#endif - -// Use enums so that printing a JS::Value in the debugger shows nice -// symbolic type tags. - -#if defined(_MSC_VER) -# define JS_ENUM_HEADER(id, type) enum id : type -# define JS_ENUM_FOOTER(id) -#else -# define JS_ENUM_HEADER(id, type) enum id -# define JS_ENUM_FOOTER(id) __attribute__((packed)) -#endif - -/* Remember to propagate changes to the C defines below. */ -JS_ENUM_HEADER(JSValueType, uint8_t) -{ - JSVAL_TYPE_DOUBLE = 0x00, - JSVAL_TYPE_INT32 = 0x01, - JSVAL_TYPE_UNDEFINED = 0x02, - JSVAL_TYPE_BOOLEAN = 0x03, - JSVAL_TYPE_MAGIC = 0x04, - JSVAL_TYPE_STRING = 0x05, - JSVAL_TYPE_SYMBOL = 0x06, - JSVAL_TYPE_PRIVATE_GCTHING = 0x07, - JSVAL_TYPE_NULL = 0x08, - JSVAL_TYPE_OBJECT = 0x0c, - - /* These never appear in a jsval; they are only provided as an out-of-band value. */ - JSVAL_TYPE_UNKNOWN = 0x20, - JSVAL_TYPE_MISSING = 0x21 -} JS_ENUM_FOOTER(JSValueType); - -static_assert(sizeof(JSValueType) == 1, - "compiler typed enum support is apparently buggy"); - -#if defined(JS_NUNBOX32) - -/* Remember to propagate changes to the C defines below. */ -JS_ENUM_HEADER(JSValueTag, uint32_t) -{ - JSVAL_TAG_CLEAR = 0xFFFFFF80, - JSVAL_TAG_INT32 = JSVAL_TAG_CLEAR | JSVAL_TYPE_INT32, - JSVAL_TAG_UNDEFINED = JSVAL_TAG_CLEAR | JSVAL_TYPE_UNDEFINED, - JSVAL_TAG_STRING = JSVAL_TAG_CLEAR | JSVAL_TYPE_STRING, - JSVAL_TAG_SYMBOL = JSVAL_TAG_CLEAR | JSVAL_TYPE_SYMBOL, - JSVAL_TAG_BOOLEAN = JSVAL_TAG_CLEAR | JSVAL_TYPE_BOOLEAN, - JSVAL_TAG_MAGIC = JSVAL_TAG_CLEAR | JSVAL_TYPE_MAGIC, - JSVAL_TAG_NULL = JSVAL_TAG_CLEAR | JSVAL_TYPE_NULL, - JSVAL_TAG_OBJECT = JSVAL_TAG_CLEAR | JSVAL_TYPE_OBJECT, - JSVAL_TAG_PRIVATE_GCTHING = JSVAL_TAG_CLEAR | JSVAL_TYPE_PRIVATE_GCTHING -} JS_ENUM_FOOTER(JSValueTag); - -static_assert(sizeof(JSValueTag) == sizeof(uint32_t), - "compiler typed enum support is apparently buggy"); - -#elif defined(JS_PUNBOX64) - -/* Remember to propagate changes to the C defines below. */ -JS_ENUM_HEADER(JSValueTag, uint32_t) -{ - JSVAL_TAG_MAX_DOUBLE = 0x1FFF0, - JSVAL_TAG_INT32 = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_INT32, - JSVAL_TAG_UNDEFINED = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_UNDEFINED, - JSVAL_TAG_STRING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_STRING, - JSVAL_TAG_SYMBOL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_SYMBOL, - JSVAL_TAG_BOOLEAN = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_BOOLEAN, - JSVAL_TAG_MAGIC = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_MAGIC, - JSVAL_TAG_NULL = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_NULL, - JSVAL_TAG_OBJECT = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_OBJECT, - JSVAL_TAG_PRIVATE_GCTHING = JSVAL_TAG_MAX_DOUBLE | JSVAL_TYPE_PRIVATE_GCTHING -} JS_ENUM_FOOTER(JSValueTag); - -static_assert(sizeof(JSValueTag) == sizeof(uint32_t), - "compiler typed enum support is apparently buggy"); - -JS_ENUM_HEADER(JSValueShiftedTag, uint64_t) -{ - JSVAL_SHIFTED_TAG_MAX_DOUBLE = ((((uint64_t)JSVAL_TAG_MAX_DOUBLE) << JSVAL_TAG_SHIFT) | 0xFFFFFFFF), - JSVAL_SHIFTED_TAG_INT32 = (((uint64_t)JSVAL_TAG_INT32) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_UNDEFINED = (((uint64_t)JSVAL_TAG_UNDEFINED) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_STRING = (((uint64_t)JSVAL_TAG_STRING) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_SYMBOL = (((uint64_t)JSVAL_TAG_SYMBOL) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_BOOLEAN = (((uint64_t)JSVAL_TAG_BOOLEAN) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_MAGIC = (((uint64_t)JSVAL_TAG_MAGIC) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_NULL = (((uint64_t)JSVAL_TAG_NULL) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_OBJECT = (((uint64_t)JSVAL_TAG_OBJECT) << JSVAL_TAG_SHIFT), - JSVAL_SHIFTED_TAG_PRIVATE_GCTHING = (((uint64_t)JSVAL_TAG_PRIVATE_GCTHING) << JSVAL_TAG_SHIFT) -} JS_ENUM_FOOTER(JSValueShiftedTag); - -static_assert(sizeof(JSValueShiftedTag) == sizeof(uint64_t), - "compiler typed enum support is apparently buggy"); - -#endif - -/* - * All our supported compilers implement C++11 |enum Foo : T| syntax, so don't - * expose these macros. (This macro exists *only* because gcc bug 51242 - * <https://gcc.gnu.org/bugzilla/show_bug.cgi?id=51242> makes bit-fields of - * typed enums trigger a warning that can't be turned off. Don't expose it - * beyond this file!) - */ -#undef JS_ENUM_HEADER -#undef JS_ENUM_FOOTER - -#if defined(JS_NUNBOX32) - -#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_CLEAR | (type))) - -#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL -#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT -#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32 -#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING - -#elif defined(JS_PUNBOX64) - -#define JSVAL_PAYLOAD_MASK 0x00007FFFFFFFFFFFLL -#define JSVAL_TAG_MASK 0xFFFF800000000000LL -#define JSVAL_TYPE_TO_TAG(type) ((JSValueTag)(JSVAL_TAG_MAX_DOUBLE | (type))) -#define JSVAL_TYPE_TO_SHIFTED_TAG(type) (((uint64_t)JSVAL_TYPE_TO_TAG(type)) << JSVAL_TAG_SHIFT) - -#define JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET JSVAL_TAG_NULL -#define JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET JSVAL_TAG_OBJECT -#define JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET JSVAL_TAG_INT32 -#define JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET JSVAL_TAG_STRING - -#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET JSVAL_SHIFTED_TAG_NULL -#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET JSVAL_SHIFTED_TAG_OBJECT -#define JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET JSVAL_SHIFTED_TAG_UNDEFINED -#define JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET JSVAL_SHIFTED_TAG_STRING - -#endif /* JS_PUNBOX64 */ - -typedef enum JSWhyMagic -{ - /** a hole in a native object's elements */ - JS_ELEMENTS_HOLE, - - /** there is not a pending iterator value */ - JS_NO_ITER_VALUE, - - /** exception value thrown when closing a generator */ - JS_GENERATOR_CLOSING, - - /** compiler sentinel value */ - JS_NO_CONSTANT, - - /** used in debug builds to catch tracing errors */ - JS_THIS_POISON, - - /** used in debug builds to catch tracing errors */ - JS_ARG_POISON, - - /** an empty subnode in the AST serializer */ - JS_SERIALIZE_NO_NODE, - - /** lazy arguments value on the stack */ - JS_LAZY_ARGUMENTS, - - /** optimized-away 'arguments' value */ - JS_OPTIMIZED_ARGUMENTS, - - /** magic value passed to natives to indicate construction */ - JS_IS_CONSTRUCTING, - - /** value of static block object slot */ - JS_BLOCK_NEEDS_CLONE, - - /** see class js::HashableValue */ - JS_HASH_KEY_EMPTY, - - /** error while running Ion code */ - JS_ION_ERROR, - - /** missing recover instruction result */ - JS_ION_BAILOUT, - - /** optimized out slot */ - JS_OPTIMIZED_OUT, - - /** uninitialized lexical bindings that produce ReferenceError on touch. */ - JS_UNINITIALIZED_LEXICAL, - - /** for local use */ - JS_GENERIC_MAGIC, - - JS_WHY_MAGIC_COUNT -} JSWhyMagic; - -namespace JS { - -static inline constexpr JS::Value UndefinedValue(); -static inline JS::Value PoisonedObjectValue(JSObject* obj); - -namespace detail { - -constexpr int CanonicalizedNaNSignBit = 0; -constexpr uint64_t CanonicalizedNaNSignificand = 0x8000000000000ULL; - -constexpr uint64_t CanonicalizedNaNBits = - mozilla::SpecificNaNBits<double, - detail::CanonicalizedNaNSignBit, - detail::CanonicalizedNaNSignificand>::value; - -} // namespace detail - -/** - * Returns a generic quiet NaN value, with all payload bits set to zero. - * - * Among other properties, this NaN's bit pattern conforms to JS::Value's - * bit pattern restrictions. - */ -static MOZ_ALWAYS_INLINE double -GenericNaN() -{ - return mozilla::SpecificNaN<double>(detail::CanonicalizedNaNSignBit, - detail::CanonicalizedNaNSignificand); -} - -/* MSVC with PGO miscompiles this function. */ -#if defined(_MSC_VER) -# pragma optimize("g", off) -#endif -static inline double -CanonicalizeNaN(double d) -{ - if (MOZ_UNLIKELY(mozilla::IsNaN(d))) - return GenericNaN(); - return d; -} -#if defined(_MSC_VER) -# pragma optimize("", on) -#endif - -/** - * JS::Value is the interface for a single JavaScript Engine value. A few - * general notes on JS::Value: - * - * - JS::Value has setX() and isX() members for X in - * - * { Int32, Double, String, Symbol, Boolean, Undefined, Null, Object, Magic } - * - * JS::Value also contains toX() for each of the non-singleton types. - * - * - Magic is a singleton type whose payload contains either a JSWhyMagic "reason" for - * the magic value or a uint32_t value. By providing JSWhyMagic values when - * creating and checking for magic values, it is possible to assert, at - * runtime, that only magic values with the expected reason flow through a - * particular value. For example, if cx->exception has a magic value, the - * reason must be JS_GENERATOR_CLOSING. - * - * - The JS::Value operations are preferred. The JSVAL_* operations remain for - * compatibility; they may be removed at some point. These operations mostly - * provide similar functionality. But there are a few key differences. One - * is that JS::Value gives null a separate type. - * Also, to help prevent mistakenly boxing a nullable JSObject* as an object, - * Value::setObject takes a JSObject&. (Conversely, Value::toObject returns a - * JSObject&.) A convenience member Value::setObjectOrNull is provided. - * - * - JSVAL_VOID is the same as the singleton value of the Undefined type. - * - * - Note that JS::Value is 8 bytes on 32 and 64-bit architectures. Thus, on - * 32-bit user code should avoid copying jsval/JS::Value as much as possible, - * preferring to pass by const Value&. - */ -class MOZ_NON_PARAM alignas(8) Value -{ - public: -#if defined(JS_NUNBOX32) - using PayloadType = uint32_t; -#elif defined(JS_PUNBOX64) - using PayloadType = uint64_t; -#endif - - /* - * N.B. the default constructor leaves Value unitialized. Adding a default - * constructor prevents Value from being stored in a union. - */ - Value() = default; - Value(const Value& v) = default; - - /** - * Returns false if creating a NumberValue containing the given type would - * be lossy, true otherwise. - */ - template <typename T> - static bool isNumberRepresentable(const T t) { - return T(double(t)) == t; - } - - /*** Mutators ***/ - - void setNull() { - data.asBits = bitsFromTagAndPayload(JSVAL_TAG_NULL, 0); - } - - void setUndefined() { - data.asBits = bitsFromTagAndPayload(JSVAL_TAG_UNDEFINED, 0); - } - - void setInt32(int32_t i) { - data.asBits = bitsFromTagAndPayload(JSVAL_TAG_INT32, uint32_t(i)); - } - - int32_t& getInt32Ref() { - MOZ_ASSERT(isInt32()); - return data.s.payload.i32; - } - - void setDouble(double d) { - // Don't assign to data.asDouble to fix a miscompilation with - // GCC 5.2.1 and 5.3.1. See bug 1312488. - data = layout(d); - MOZ_ASSERT(isDouble()); - } - - void setNaN() { - setDouble(GenericNaN()); - } - - double& getDoubleRef() { - MOZ_ASSERT(isDouble()); - return data.asDouble; - } - - void setString(JSString* str) { - MOZ_ASSERT(uintptr_t(str) > 0x1000); - data.asBits = bitsFromTagAndPayload(JSVAL_TAG_STRING, PayloadType(str)); - } - - void setSymbol(JS::Symbol* sym) { - MOZ_ASSERT(uintptr_t(sym) > 0x1000); - data.asBits = bitsFromTagAndPayload(JSVAL_TAG_SYMBOL, PayloadType(sym)); - } - - void setObject(JSObject& obj) { - MOZ_ASSERT(uintptr_t(&obj) > 0x1000 || uintptr_t(&obj) == 0x48); -#if defined(JS_PUNBOX64) - // VisualStudio cannot contain parenthesized C++ style cast and shift - // inside decltype in template parameter: - // AssertionConditionType<decltype((uintptr_t(x) >> 1))> - // It throws syntax error. - MOZ_ASSERT((((uintptr_t)&obj) >> JSVAL_TAG_SHIFT) == 0); -#endif - setObjectNoCheck(&obj); - } - - private: - void setObjectNoCheck(JSObject* obj) { - data.asBits = bitsFromTagAndPayload(JSVAL_TAG_OBJECT, PayloadType(obj)); - } - - friend inline Value PoisonedObjectValue(JSObject* obj); - - public: - void setBoolean(bool b) { - data.asBits = bitsFromTagAndPayload(JSVAL_TAG_BOOLEAN, uint32_t(b)); - } - - void setMagic(JSWhyMagic why) { - data.asBits = bitsFromTagAndPayload(JSVAL_TAG_MAGIC, uint32_t(why)); - } - - void setMagicUint32(uint32_t payload) { - data.asBits = bitsFromTagAndPayload(JSVAL_TAG_MAGIC, payload); - } - - bool setNumber(uint32_t ui) { - if (ui > JSVAL_INT_MAX) { - setDouble((double)ui); - return false; - } else { - setInt32((int32_t)ui); - return true; - } - } - - bool setNumber(double d) { - int32_t i; - if (mozilla::NumberIsInt32(d, &i)) { - setInt32(i); - return true; - } - - setDouble(d); - return false; - } - - void setObjectOrNull(JSObject* arg) { - if (arg) - setObject(*arg); - else - setNull(); - } - - void swap(Value& rhs) { - uint64_t tmp = rhs.data.asBits; - rhs.data.asBits = data.asBits; - data.asBits = tmp; - } - - private: - JSValueTag toTag() const { -#if defined(JS_NUNBOX32) - return data.s.tag; -#elif defined(JS_PUNBOX64) - return JSValueTag(data.asBits >> JSVAL_TAG_SHIFT); -#endif - } - - public: - /*** JIT-only interfaces to interact with and create raw Values ***/ -#if defined(JS_NUNBOX32) - PayloadType toNunboxPayload() const { - return data.s.payload.i32; - } - - JSValueTag toNunboxTag() const { - return data.s.tag; - } -#elif defined(JS_PUNBOX64) - const void* bitsAsPunboxPointer() const { - return reinterpret_cast<void*>(data.asBits); - } -#endif - - /*** Value type queries ***/ - - /* - * N.B. GCC, in some but not all cases, chooses to emit signed comparison - * of JSValueTag even though its underlying type has been forced to be - * uint32_t. Thus, all comparisons should explicitly cast operands to - * uint32_t. - */ - - bool isUndefined() const { -#if defined(JS_NUNBOX32) - return toTag() == JSVAL_TAG_UNDEFINED; -#elif defined(JS_PUNBOX64) - return data.asBits == JSVAL_SHIFTED_TAG_UNDEFINED; -#endif - } - - bool isNull() const { -#if defined(JS_NUNBOX32) - return toTag() == JSVAL_TAG_NULL; -#elif defined(JS_PUNBOX64) - return data.asBits == JSVAL_SHIFTED_TAG_NULL; -#endif - } - - bool isNullOrUndefined() const { - return isNull() || isUndefined(); - } - - bool isInt32() const { - return toTag() == JSVAL_TAG_INT32; - } - - bool isInt32(int32_t i32) const { - return data.asBits == bitsFromTagAndPayload(JSVAL_TAG_INT32, uint32_t(i32)); - } - - bool isDouble() const { -#if defined(JS_NUNBOX32) - return uint32_t(toTag()) <= uint32_t(JSVAL_TAG_CLEAR); -#elif defined(JS_PUNBOX64) - return (data.asBits | mozilla::DoubleTypeTraits::kSignBit) <= JSVAL_SHIFTED_TAG_MAX_DOUBLE; -#endif - } - - bool isNumber() const { -#if defined(JS_NUNBOX32) - MOZ_ASSERT(toTag() != JSVAL_TAG_CLEAR); - return uint32_t(toTag()) <= uint32_t(JSVAL_UPPER_INCL_TAG_OF_NUMBER_SET); -#elif defined(JS_PUNBOX64) - return data.asBits < JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_NUMBER_SET; -#endif - } - - bool isString() const { - return toTag() == JSVAL_TAG_STRING; - } - - bool isSymbol() const { - return toTag() == JSVAL_TAG_SYMBOL; - } - - bool isObject() const { -#if defined(JS_NUNBOX32) - return toTag() == JSVAL_TAG_OBJECT; -#elif defined(JS_PUNBOX64) - MOZ_ASSERT((data.asBits >> JSVAL_TAG_SHIFT) <= JSVAL_TAG_OBJECT); - return data.asBits >= JSVAL_SHIFTED_TAG_OBJECT; -#endif - } - - bool isPrimitive() const { -#if defined(JS_NUNBOX32) - return uint32_t(toTag()) < uint32_t(JSVAL_UPPER_EXCL_TAG_OF_PRIMITIVE_SET); -#elif defined(JS_PUNBOX64) - return data.asBits < JSVAL_UPPER_EXCL_SHIFTED_TAG_OF_PRIMITIVE_SET; -#endif - } - - bool isObjectOrNull() const { - MOZ_ASSERT(uint32_t(toTag()) <= uint32_t(JSVAL_TAG_OBJECT)); -#if defined(JS_NUNBOX32) - return uint32_t(toTag()) >= uint32_t(JSVAL_LOWER_INCL_TAG_OF_OBJ_OR_NULL_SET); -#elif defined(JS_PUNBOX64) - return data.asBits >= JSVAL_LOWER_INCL_SHIFTED_TAG_OF_OBJ_OR_NULL_SET; -#endif - } - - bool isGCThing() const { -#if defined(JS_NUNBOX32) - /* gcc sometimes generates signed < without explicit casts. */ - return uint32_t(toTag()) >= uint32_t(JSVAL_LOWER_INCL_TAG_OF_GCTHING_SET); -#elif defined(JS_PUNBOX64) - return data.asBits >= JSVAL_LOWER_INCL_SHIFTED_TAG_OF_GCTHING_SET; -#endif - } - - bool isBoolean() const { - return toTag() == JSVAL_TAG_BOOLEAN; - } - - bool isTrue() const { - return data.asBits == bitsFromTagAndPayload(JSVAL_TAG_BOOLEAN, uint32_t(true)); - } - - bool isFalse() const { - return data.asBits == bitsFromTagAndPayload(JSVAL_TAG_BOOLEAN, uint32_t(false)); - } - - bool isMagic() const { - return toTag() == JSVAL_TAG_MAGIC; - } - - bool isMagic(JSWhyMagic why) const { - MOZ_ASSERT_IF(isMagic(), data.s.payload.why == why); - return isMagic(); - } - - bool isMarkable() const { - return isGCThing() && !isNull(); - } - - JS::TraceKind traceKind() const { - MOZ_ASSERT(isMarkable()); - static_assert((JSVAL_TAG_STRING & 0x03) == size_t(JS::TraceKind::String), - "Value type tags must correspond with JS::TraceKinds."); - static_assert((JSVAL_TAG_SYMBOL & 0x03) == size_t(JS::TraceKind::Symbol), - "Value type tags must correspond with JS::TraceKinds."); - static_assert((JSVAL_TAG_OBJECT & 0x03) == size_t(JS::TraceKind::Object), - "Value type tags must correspond with JS::TraceKinds."); - if (MOZ_UNLIKELY(isPrivateGCThing())) - return JS::GCThingTraceKind(toGCThing()); - return JS::TraceKind(toTag() & 0x03); - } - - JSWhyMagic whyMagic() const { - MOZ_ASSERT(isMagic()); - return data.s.payload.why; - } - - uint32_t magicUint32() const { - MOZ_ASSERT(isMagic()); - return data.s.payload.u32; - } - - /*** Comparison ***/ - - bool operator==(const Value& rhs) const { - return data.asBits == rhs.data.asBits; - } - - bool operator!=(const Value& rhs) const { - return data.asBits != rhs.data.asBits; - } - - friend inline bool SameType(const Value& lhs, const Value& rhs); - - /*** Extract the value's typed payload ***/ - - int32_t toInt32() const { - MOZ_ASSERT(isInt32()); -#if defined(JS_NUNBOX32) - return data.s.payload.i32; -#elif defined(JS_PUNBOX64) - return int32_t(data.asBits); -#endif - } - - double toDouble() const { - MOZ_ASSERT(isDouble()); - return data.asDouble; - } - - double toNumber() const { - MOZ_ASSERT(isNumber()); - return isDouble() ? toDouble() : double(toInt32()); - } - - JSString* toString() const { - MOZ_ASSERT(isString()); -#if defined(JS_NUNBOX32) - return data.s.payload.str; -#elif defined(JS_PUNBOX64) - return reinterpret_cast<JSString*>(data.asBits & JSVAL_PAYLOAD_MASK); -#endif - } - - JS::Symbol* toSymbol() const { - MOZ_ASSERT(isSymbol()); -#if defined(JS_NUNBOX32) - return data.s.payload.sym; -#elif defined(JS_PUNBOX64) - return reinterpret_cast<JS::Symbol*>(data.asBits & JSVAL_PAYLOAD_MASK); -#endif - } - - JSObject& toObject() const { - MOZ_ASSERT(isObject()); -#if defined(JS_NUNBOX32) - return *data.s.payload.obj; -#elif defined(JS_PUNBOX64) - return *toObjectOrNull(); -#endif - } - - JSObject* toObjectOrNull() const { - MOZ_ASSERT(isObjectOrNull()); -#if defined(JS_NUNBOX32) - return data.s.payload.obj; -#elif defined(JS_PUNBOX64) - uint64_t ptrBits = data.asBits & JSVAL_PAYLOAD_MASK; - MOZ_ASSERT((ptrBits & 0x7) == 0); - return reinterpret_cast<JSObject*>(ptrBits); -#endif - } - - js::gc::Cell* toGCThing() const { - MOZ_ASSERT(isGCThing()); -#if defined(JS_NUNBOX32) - return data.s.payload.cell; -#elif defined(JS_PUNBOX64) - uint64_t ptrBits = data.asBits & JSVAL_PAYLOAD_MASK; - MOZ_ASSERT((ptrBits & 0x7) == 0); - return reinterpret_cast<js::gc::Cell*>(ptrBits); -#endif - } - - js::gc::Cell* toMarkablePointer() const { - MOZ_ASSERT(isMarkable()); - return toGCThing(); - } - - GCCellPtr toGCCellPtr() const { - return GCCellPtr(toGCThing(), traceKind()); - } - - bool toBoolean() const { - MOZ_ASSERT(isBoolean()); -#if defined(JS_NUNBOX32) - return bool(data.s.payload.boo); -#elif defined(JS_PUNBOX64) - return bool(data.asBits & JSVAL_PAYLOAD_MASK); -#endif - } - - uint32_t payloadAsRawUint32() const { - MOZ_ASSERT(!isDouble()); - return data.s.payload.u32; - } - - uint64_t asRawBits() const { - return data.asBits; - } - - JSValueType extractNonDoubleType() const { - uint32_t type = toTag() & 0xF; - MOZ_ASSERT(type > JSVAL_TYPE_DOUBLE); - return JSValueType(type); - } - - /* - * Private API - * - * Private setters/getters allow the caller to read/write arbitrary types - * that fit in the 64-bit payload. It is the caller's responsibility, after - * storing to a value with setPrivateX to read only using getPrivateX. - * Privates values are given a type which ensures they are not marked. - */ - - void setPrivate(void* ptr) { - MOZ_ASSERT((uintptr_t(ptr) & 1) == 0); -#if defined(JS_NUNBOX32) - data.s.tag = JSValueTag(0); - data.s.payload.ptr = ptr; -#elif defined(JS_PUNBOX64) - data.asBits = uintptr_t(ptr) >> 1; -#endif - MOZ_ASSERT(isDouble()); - } - - void* toPrivate() const { - MOZ_ASSERT(isDouble()); -#if defined(JS_NUNBOX32) - return data.s.payload.ptr; -#elif defined(JS_PUNBOX64) - MOZ_ASSERT((data.asBits & 0x8000000000000000ULL) == 0); - return reinterpret_cast<void*>(data.asBits << 1); -#endif - } - - void setPrivateUint32(uint32_t ui) { - MOZ_ASSERT(uint32_t(int32_t(ui)) == ui); - setInt32(int32_t(ui)); - } - - uint32_t toPrivateUint32() const { - return uint32_t(toInt32()); - } - - /* - * Private GC Thing API - * - * Non-JSObject, JSString, and JS::Symbol cells may be put into the 64-bit - * payload as private GC things. Such Values are considered isMarkable() - * and isGCThing(), and as such, automatically marked. Their traceKind() - * is gotten via their cells. - */ - - void setPrivateGCThing(js::gc::Cell* cell) { - MOZ_ASSERT(JS::GCThingTraceKind(cell) != JS::TraceKind::String, - "Private GC thing Values must not be strings. Make a StringValue instead."); - MOZ_ASSERT(JS::GCThingTraceKind(cell) != JS::TraceKind::Symbol, - "Private GC thing Values must not be symbols. Make a SymbolValue instead."); - MOZ_ASSERT(JS::GCThingTraceKind(cell) != JS::TraceKind::Object, - "Private GC thing Values must not be objects. Make an ObjectValue instead."); - - MOZ_ASSERT(uintptr_t(cell) > 0x1000); -#if defined(JS_PUNBOX64) - // VisualStudio cannot contain parenthesized C++ style cast and shift - // inside decltype in template parameter: - // AssertionConditionType<decltype((uintptr_t(x) >> 1))> - // It throws syntax error. - MOZ_ASSERT((((uintptr_t)cell) >> JSVAL_TAG_SHIFT) == 0); -#endif - data.asBits = bitsFromTagAndPayload(JSVAL_TAG_PRIVATE_GCTHING, PayloadType(cell)); - } - - bool isPrivateGCThing() const { - return toTag() == JSVAL_TAG_PRIVATE_GCTHING; - } - - const size_t* payloadWord() const { -#if defined(JS_NUNBOX32) - return &data.s.payload.word; -#elif defined(JS_PUNBOX64) - return &data.asWord; -#endif - } - - const uintptr_t* payloadUIntPtr() const { -#if defined(JS_NUNBOX32) - return &data.s.payload.uintptr; -#elif defined(JS_PUNBOX64) - return &data.asUIntPtr; -#endif - } - -#if !defined(_MSC_VER) && !defined(__sparc) - // Value must be POD so that MSVC will pass it by value and not in memory - // (bug 689101); the same is true for SPARC as well (bug 737344). More - // precisely, we don't want Value return values compiled as out params. - private: -#endif - -#if MOZ_LITTLE_ENDIAN -# if defined(JS_NUNBOX32) - union layout { - uint64_t asBits; - struct { - union { - int32_t i32; - uint32_t u32; - uint32_t boo; // Don't use |bool| -- it must be four bytes. - JSString* str; - JS::Symbol* sym; - JSObject* obj; - js::gc::Cell* cell; - void* ptr; - JSWhyMagic why; - size_t word; - uintptr_t uintptr; - } payload; - JSValueTag tag; - } s; - double asDouble; - void* asPtr; - - layout() = default; - explicit constexpr layout(uint64_t bits) : asBits(bits) {} - explicit constexpr layout(double d) : asDouble(d) {} - } data; -# elif defined(JS_PUNBOX64) - union layout { - uint64_t asBits; -#if !defined(_WIN64) - /* MSVC does not pack these correctly :-( */ - struct { - uint64_t payload47 : 47; - JSValueTag tag : 17; - } debugView; -#endif - struct { - union { - int32_t i32; - uint32_t u32; - JSWhyMagic why; - } payload; - } s; - double asDouble; - void* asPtr; - size_t asWord; - uintptr_t asUIntPtr; - - layout() = default; - explicit constexpr layout(uint64_t bits) : asBits(bits) {} - explicit constexpr layout(double d) : asDouble(d) {} - } data; -# endif /* JS_PUNBOX64 */ -#else /* MOZ_LITTLE_ENDIAN */ -# if defined(JS_NUNBOX32) - union layout { - uint64_t asBits; - struct { - JSValueTag tag; - union { - int32_t i32; - uint32_t u32; - uint32_t boo; // Don't use |bool| -- it must be four bytes. - JSString* str; - JS::Symbol* sym; - JSObject* obj; - js::gc::Cell* cell; - void* ptr; - JSWhyMagic why; - size_t word; - uintptr_t uintptr; - } payload; - } s; - double asDouble; - void* asPtr; - - layout() = default; - explicit constexpr layout(uint64_t bits) : asBits(bits) {} - explicit constexpr layout(double d) : asDouble(d) {} - } data; -# elif defined(JS_PUNBOX64) - union layout { - uint64_t asBits; - struct { - JSValueTag tag : 17; - uint64_t payload47 : 47; - } debugView; - struct { - uint32_t padding; - union { - int32_t i32; - uint32_t u32; - JSWhyMagic why; - } payload; - } s; - double asDouble; - void* asPtr; - size_t asWord; - uintptr_t asUIntPtr; - - layout() = default; - explicit constexpr layout(uint64_t bits) : asBits(bits) {} - explicit constexpr layout(double d) : asDouble(d) {} - } data; -# endif /* JS_PUNBOX64 */ -#endif /* MOZ_LITTLE_ENDIAN */ - - private: - explicit constexpr Value(uint64_t asBits) : data(asBits) {} - explicit constexpr Value(double d) : data(d) {} - - void staticAssertions() { - JS_STATIC_ASSERT(sizeof(JSValueType) == 1); - JS_STATIC_ASSERT(sizeof(JSValueTag) == 4); - JS_STATIC_ASSERT(sizeof(JSWhyMagic) <= 4); - JS_STATIC_ASSERT(sizeof(Value) == 8); - } - - friend constexpr Value JS::UndefinedValue(); - - public: - static constexpr uint64_t - bitsFromTagAndPayload(JSValueTag tag, PayloadType payload) - { -#if defined(JS_NUNBOX32) - return (uint64_t(uint32_t(tag)) << 32) | payload; -#elif defined(JS_PUNBOX64) - return (uint64_t(uint32_t(tag)) << JSVAL_TAG_SHIFT) | payload; -#endif - } - - static constexpr Value - fromTagAndPayload(JSValueTag tag, PayloadType payload) - { - return fromRawBits(bitsFromTagAndPayload(tag, payload)); - } - - static constexpr Value - fromRawBits(uint64_t asBits) { - return Value(asBits); - } - - static constexpr Value - fromInt32(int32_t i) { - return fromTagAndPayload(JSVAL_TAG_INT32, uint32_t(i)); - } - - static constexpr Value - fromDouble(double d) { - return Value(d); - } -} JS_HAZ_GC_POINTER; - -static_assert(sizeof(Value) == 8, "Value size must leave three tag bits, be a binary power, and is ubiquitously depended upon everywhere"); - -inline bool -IsOptimizedPlaceholderMagicValue(const Value& v) -{ - if (v.isMagic()) { - MOZ_ASSERT(v.whyMagic() == JS_OPTIMIZED_ARGUMENTS || v.whyMagic() == JS_OPTIMIZED_OUT); - return true; - } - return false; -} - -static MOZ_ALWAYS_INLINE void -ExposeValueToActiveJS(const Value& v) -{ - if (v.isMarkable()) - js::gc::ExposeGCThingToActiveJS(GCCellPtr(v)); -} - -/************************************************************************/ - -static inline Value -NullValue() -{ - Value v; - v.setNull(); - return v; -} - -static inline constexpr Value -UndefinedValue() -{ - return Value::fromTagAndPayload(JSVAL_TAG_UNDEFINED, 0); -} - -static inline constexpr Value -Int32Value(int32_t i32) -{ - return Value::fromInt32(i32); -} - -static inline Value -DoubleValue(double dbl) -{ - Value v; - v.setDouble(dbl); - return v; -} - -static inline Value -CanonicalizedDoubleValue(double d) -{ - return MOZ_UNLIKELY(mozilla::IsNaN(d)) - ? Value::fromRawBits(detail::CanonicalizedNaNBits) - : Value::fromDouble(d); -} - -static inline bool -IsCanonicalized(double d) -{ - if (mozilla::IsInfinite(d) || mozilla::IsFinite(d)) - return true; - - uint64_t bits; - mozilla::BitwiseCast<uint64_t>(d, &bits); - return (bits & ~mozilla::DoubleTypeTraits::kSignBit) == detail::CanonicalizedNaNBits; -} - -static inline Value -DoubleNaNValue() -{ - Value v; - v.setNaN(); - return v; -} - -static inline Value -Float32Value(float f) -{ - Value v; - v.setDouble(f); - return v; -} - -static inline Value -StringValue(JSString* str) -{ - Value v; - v.setString(str); - return v; -} - -static inline Value -SymbolValue(JS::Symbol* sym) -{ - Value v; - v.setSymbol(sym); - return v; -} - -static inline Value -BooleanValue(bool boo) -{ - Value v; - v.setBoolean(boo); - return v; -} - -static inline Value -TrueValue() -{ - Value v; - v.setBoolean(true); - return v; -} - -static inline Value -FalseValue() -{ - Value v; - v.setBoolean(false); - return v; -} - -static inline Value -ObjectValue(JSObject& obj) -{ - Value v; - v.setObject(obj); - return v; -} - -static inline Value -ObjectValueCrashOnTouch() -{ - Value v; - v.setObject(*reinterpret_cast<JSObject*>(0x48)); - return v; -} - -static inline Value -MagicValue(JSWhyMagic why) -{ - Value v; - v.setMagic(why); - return v; -} - -static inline Value -MagicValueUint32(uint32_t payload) -{ - Value v; - v.setMagicUint32(payload); - return v; -} - -static inline Value -NumberValue(float f) -{ - Value v; - v.setNumber(f); - return v; -} - -static inline Value -NumberValue(double dbl) -{ - Value v; - v.setNumber(dbl); - return v; -} - -static inline Value -NumberValue(int8_t i) -{ - return Int32Value(i); -} - -static inline Value -NumberValue(uint8_t i) -{ - return Int32Value(i); -} - -static inline Value -NumberValue(int16_t i) -{ - return Int32Value(i); -} - -static inline Value -NumberValue(uint16_t i) -{ - return Int32Value(i); -} - -static inline Value -NumberValue(int32_t i) -{ - return Int32Value(i); -} - -static inline constexpr Value -NumberValue(uint32_t i) -{ - return i <= JSVAL_INT_MAX - ? Int32Value(int32_t(i)) - : Value::fromDouble(double(i)); -} - -namespace detail { - -template <bool Signed> -class MakeNumberValue -{ - public: - template<typename T> - static inline Value create(const T t) - { - Value v; - if (JSVAL_INT_MIN <= t && t <= JSVAL_INT_MAX) - v.setInt32(int32_t(t)); - else - v.setDouble(double(t)); - return v; - } -}; - -template <> -class MakeNumberValue<false> -{ - public: - template<typename T> - static inline Value create(const T t) - { - Value v; - if (t <= JSVAL_INT_MAX) - v.setInt32(int32_t(t)); - else - v.setDouble(double(t)); - return v; - } -}; - -} // namespace detail - -template <typename T> -static inline Value -NumberValue(const T t) -{ - MOZ_ASSERT(Value::isNumberRepresentable(t), "value creation would be lossy"); - return detail::MakeNumberValue<std::numeric_limits<T>::is_signed>::create(t); -} - -static inline Value -ObjectOrNullValue(JSObject* obj) -{ - Value v; - v.setObjectOrNull(obj); - return v; -} - -static inline Value -PrivateValue(void* ptr) -{ - Value v; - v.setPrivate(ptr); - return v; -} - -static inline Value -PrivateUint32Value(uint32_t ui) -{ - Value v; - v.setPrivateUint32(ui); - return v; -} - -static inline Value -PrivateGCThingValue(js::gc::Cell* cell) -{ - Value v; - v.setPrivateGCThing(cell); - return v; -} - -static inline Value -PoisonedObjectValue(JSObject* obj) -{ - Value v; - v.setObjectNoCheck(obj); - return v; -} - -inline bool -SameType(const Value& lhs, const Value& rhs) -{ -#if defined(JS_NUNBOX32) - JSValueTag ltag = lhs.toTag(), rtag = rhs.toTag(); - return ltag == rtag || (ltag < JSVAL_TAG_CLEAR && rtag < JSVAL_TAG_CLEAR); -#elif defined(JS_PUNBOX64) - return (lhs.isDouble() && rhs.isDouble()) || - (((lhs.data.asBits ^ rhs.data.asBits) & 0xFFFF800000000000ULL) == 0); -#endif -} - -} // namespace JS - -/************************************************************************/ - -namespace JS { -JS_PUBLIC_API(void) HeapValuePostBarrier(Value* valuep, const Value& prev, const Value& next); - -template <> -struct GCPolicy<JS::Value> -{ - static Value initial() { return UndefinedValue(); } - static void trace(JSTracer* trc, Value* v, const char* name) { - js::UnsafeTraceManuallyBarrieredEdge(trc, v, name); - } - static bool isTenured(const Value& thing) { - return !thing.isGCThing() || !IsInsideNursery(thing.toGCThing()); - } -}; - -} // namespace JS - -namespace js { - -template <> -struct BarrierMethods<JS::Value> -{ - static gc::Cell* asGCThingOrNull(const JS::Value& v) { - return v.isMarkable() ? v.toGCThing() : nullptr; - } - static void postBarrier(JS::Value* v, const JS::Value& prev, const JS::Value& next) { - JS::HeapValuePostBarrier(v, prev, next); - } - static void exposeToJS(const JS::Value& v) { - JS::ExposeValueToActiveJS(v); - } -}; - -template <class Outer> class MutableValueOperations; - -/** - * A class designed for CRTP use in implementing the non-mutating parts of the - * Value interface in Value-like classes. Outer must be a class inheriting - * ValueOperations<Outer> with a visible get() method returning a const - * reference to the Value abstracted by Outer. - */ -template <class Outer> -class ValueOperations -{ - friend class MutableValueOperations<Outer>; - - const JS::Value& value() const { return static_cast<const Outer*>(this)->get(); } - - public: - bool isUndefined() const { return value().isUndefined(); } - bool isNull() const { return value().isNull(); } - bool isBoolean() const { return value().isBoolean(); } - bool isTrue() const { return value().isTrue(); } - bool isFalse() const { return value().isFalse(); } - bool isNumber() const { return value().isNumber(); } - bool isInt32() const { return value().isInt32(); } - bool isInt32(int32_t i32) const { return value().isInt32(i32); } - bool isDouble() const { return value().isDouble(); } - bool isString() const { return value().isString(); } - bool isSymbol() const { return value().isSymbol(); } - bool isObject() const { return value().isObject(); } - bool isMagic() const { return value().isMagic(); } - bool isMagic(JSWhyMagic why) const { return value().isMagic(why); } - bool isMarkable() const { return value().isMarkable(); } - bool isPrimitive() const { return value().isPrimitive(); } - bool isGCThing() const { return value().isGCThing(); } - - bool isNullOrUndefined() const { return value().isNullOrUndefined(); } - bool isObjectOrNull() const { return value().isObjectOrNull(); } - - bool toBoolean() const { return value().toBoolean(); } - double toNumber() const { return value().toNumber(); } - int32_t toInt32() const { return value().toInt32(); } - double toDouble() const { return value().toDouble(); } - JSString* toString() const { return value().toString(); } - JS::Symbol* toSymbol() const { return value().toSymbol(); } - JSObject& toObject() const { return value().toObject(); } - JSObject* toObjectOrNull() const { return value().toObjectOrNull(); } - gc::Cell* toGCThing() const { return value().toGCThing(); } - JS::TraceKind traceKind() const { return value().traceKind(); } - void* toPrivate() const { return value().toPrivate(); } - uint32_t toPrivateUint32() const { return value().toPrivateUint32(); } - - uint64_t asRawBits() const { return value().asRawBits(); } - JSValueType extractNonDoubleType() const { return value().extractNonDoubleType(); } - - JSWhyMagic whyMagic() const { return value().whyMagic(); } - uint32_t magicUint32() const { return value().magicUint32(); } -}; - -/** - * A class designed for CRTP use in implementing all the mutating parts of the - * Value interface in Value-like classes. Outer must be a class inheriting - * MutableValueOperations<Outer> with visible get() methods returning const and - * non-const references to the Value abstracted by Outer. - */ -template <class Outer> -class MutableValueOperations : public ValueOperations<Outer> -{ - JS::Value& value() { return static_cast<Outer*>(this)->get(); } - - public: - void setNull() { value().setNull(); } - void setUndefined() { value().setUndefined(); } - void setInt32(int32_t i) { value().setInt32(i); } - void setDouble(double d) { value().setDouble(d); } - void setNaN() { setDouble(JS::GenericNaN()); } - void setBoolean(bool b) { value().setBoolean(b); } - void setMagic(JSWhyMagic why) { value().setMagic(why); } - bool setNumber(uint32_t ui) { return value().setNumber(ui); } - bool setNumber(double d) { return value().setNumber(d); } - void setString(JSString* str) { this->value().setString(str); } - void setSymbol(JS::Symbol* sym) { this->value().setSymbol(sym); } - void setObject(JSObject& obj) { this->value().setObject(obj); } - void setObjectOrNull(JSObject* arg) { this->value().setObjectOrNull(arg); } - void setPrivate(void* ptr) { this->value().setPrivate(ptr); } - void setPrivateUint32(uint32_t ui) { this->value().setPrivateUint32(ui); } - void setPrivateGCThing(js::gc::Cell* cell) { this->value().setPrivateGCThing(cell); } -}; - -/* - * Augment the generic Heap<T> interface when T = Value with - * type-querying, value-extracting, and mutating operations. - */ -template <> -class HeapBase<JS::Value> : public ValueOperations<JS::Heap<JS::Value> > -{ - typedef JS::Heap<JS::Value> Outer; - - friend class ValueOperations<Outer>; - - void setBarriered(const JS::Value& v) { - *static_cast<JS::Heap<JS::Value>*>(this) = v; - } - - public: - void setNull() { setBarriered(JS::NullValue()); } - void setUndefined() { setBarriered(JS::UndefinedValue()); } - void setInt32(int32_t i) { setBarriered(JS::Int32Value(i)); } - void setDouble(double d) { setBarriered(JS::DoubleValue(d)); } - void setNaN() { setDouble(JS::GenericNaN()); } - void setBoolean(bool b) { setBarriered(JS::BooleanValue(b)); } - void setMagic(JSWhyMagic why) { setBarriered(JS::MagicValue(why)); } - void setString(JSString* str) { setBarriered(JS::StringValue(str)); } - void setSymbol(JS::Symbol* sym) { setBarriered(JS::SymbolValue(sym)); } - void setObject(JSObject& obj) { setBarriered(JS::ObjectValue(obj)); } - void setPrivateGCThing(js::gc::Cell* cell) { setBarriered(JS::PrivateGCThingValue(cell)); } - - bool setNumber(uint32_t ui) { - if (ui > JSVAL_INT_MAX) { - setDouble((double)ui); - return false; - } else { - setInt32((int32_t)ui); - return true; - } - } - - bool setNumber(double d) { - int32_t i; - if (mozilla::NumberIsInt32(d, &i)) { - setInt32(i); - return true; - } - - setDouble(d); - return false; - } - - void setObjectOrNull(JSObject* arg) { - if (arg) - setObject(*arg); - else - setNull(); - } -}; - -template <> -class HandleBase<JS::Value> : public ValueOperations<JS::Handle<JS::Value> > -{}; - -template <> -class MutableHandleBase<JS::Value> : public MutableValueOperations<JS::MutableHandle<JS::Value> > -{}; - -template <> -class RootedBase<JS::Value> : public MutableValueOperations<JS::Rooted<JS::Value> > -{}; - -template <> -class PersistentRootedBase<JS::Value> : public MutableValueOperations<JS::PersistentRooted<JS::Value>> -{}; - -/* - * If the Value is a GC pointer type, convert to that type and call |f| with - * the pointer. If the Value is not a GC type, calls F::defaultValue. - */ -template <typename F, typename... Args> -auto -DispatchTyped(F f, const JS::Value& val, Args&&... args) - -> decltype(f(static_cast<JSObject*>(nullptr), mozilla::Forward<Args>(args)...)) -{ - if (val.isString()) - return f(val.toString(), mozilla::Forward<Args>(args)...); - if (val.isObject()) - return f(&val.toObject(), mozilla::Forward<Args>(args)...); - if (val.isSymbol()) - return f(val.toSymbol(), mozilla::Forward<Args>(args)...); - if (MOZ_UNLIKELY(val.isPrivateGCThing())) - return DispatchTyped(f, val.toGCCellPtr(), mozilla::Forward<Args>(args)...); - MOZ_ASSERT(!val.isMarkable()); - return F::defaultValue(val); -} - -template <class S> struct VoidDefaultAdaptor { static void defaultValue(const S&) {} }; -template <class S> struct IdentityDefaultAdaptor { static S defaultValue(const S& v) {return v;} }; -template <class S, bool v> struct BoolDefaultAdaptor { static bool defaultValue(const S&) { return v; } }; - -} // namespace js - -/************************************************************************/ - -namespace JS { - -extern JS_PUBLIC_DATA(const HandleValue) NullHandleValue; -extern JS_PUBLIC_DATA(const HandleValue) UndefinedHandleValue; -extern JS_PUBLIC_DATA(const HandleValue) TrueHandleValue; -extern JS_PUBLIC_DATA(const HandleValue) FalseHandleValue; - -} // namespace JS - -#endif /* js_Value_h */ diff --git a/android/armeabi/include/spidermonkey/js/Vector.h b/android/armeabi/include/spidermonkey/js/Vector.h deleted file mode 100644 index 6fa63e93..00000000 --- a/android/armeabi/include/spidermonkey/js/Vector.h +++ /dev/null @@ -1,45 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_Vector_h -#define js_Vector_h - -#include "mozilla/Vector.h" - -/* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */ -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4345) -#endif - -namespace js { - -class TempAllocPolicy; - -namespace detail { - -template <typename T> -struct TypeIsGCThing : mozilla::FalseType -{}; - -// Uncomment this once we actually can assert it: -//template <> -//struct TypeIsGCThing<JS::Value> : mozilla::TrueType -//{}; - -} // namespace detail - -template <typename T, - size_t MinInlineCapacity = 0, - class AllocPolicy = TempAllocPolicy, - // Don't use this with JS::Value! Use JS::AutoValueVector instead. - typename = typename mozilla::EnableIf<!detail::TypeIsGCThing<T>::value>::Type - > -using Vector = mozilla::Vector<T, MinInlineCapacity, AllocPolicy>; - -} // namespace js - -#endif /* js_Vector_h */ diff --git a/android/armeabi/include/spidermonkey/js/WeakMapPtr.h b/android/armeabi/include/spidermonkey/js/WeakMapPtr.h deleted file mode 100644 index 41860551..00000000 --- a/android/armeabi/include/spidermonkey/js/WeakMapPtr.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef js_WeakMapPtr_h -#define js_WeakMapPtr_h - -#include "jspubtd.h" - -#include "js/TypeDecls.h" - -namespace JS { - -// A wrapper around the internal C++ representation of SpiderMonkey WeakMaps, -// usable outside the engine. -// -// The supported template specializations are enumerated in WeakMapPtr.cpp. If -// you want to use this class for a different key/value combination, add it to -// the list and the compiler will generate the relevant machinery. -template <typename K, typename V> -class JS_PUBLIC_API(WeakMapPtr) -{ - public: - WeakMapPtr() : ptr(nullptr) {} - bool init(JSContext* cx); - bool initialized() { return ptr != nullptr; } - void destroy(); - virtual ~WeakMapPtr() { MOZ_ASSERT(!initialized()); } - void trace(JSTracer* tracer); - - V lookup(const K& key); - bool put(JSContext* cx, const K& key, const V& value); - - private: - void* ptr; - - // WeakMapPtr is neither copyable nor assignable. - WeakMapPtr(const WeakMapPtr& wmp) = delete; - WeakMapPtr& operator=(const WeakMapPtr& wmp) = delete; -}; - -} /* namespace JS */ - -#endif /* js_WeakMapPtr_h */ diff --git a/android/armeabi/include/spidermonkey/jsalloc.h b/android/armeabi/include/spidermonkey/jsalloc.h deleted file mode 100644 index b9ae5190..00000000 --- a/android/armeabi/include/spidermonkey/jsalloc.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * JS allocation policies. - * - * The allocators here are for system memory with lifetimes which are not - * managed by the GC. See the comment at the top of vm/MallocProvider.h. - */ - -#ifndef jsalloc_h -#define jsalloc_h - -#include "js/TypeDecls.h" -#include "js/Utility.h" - -namespace js { - -enum class AllocFunction { - Malloc, - Calloc, - Realloc -}; - -struct ContextFriendFields; - -/* Policy for using system memory functions and doing no error reporting. */ -class SystemAllocPolicy -{ - public: - template <typename T> T* maybe_pod_malloc(size_t numElems) { return js_pod_malloc<T>(numElems); } - template <typename T> T* maybe_pod_calloc(size_t numElems) { return js_pod_calloc<T>(numElems); } - template <typename T> T* maybe_pod_realloc(T* p, size_t oldSize, size_t newSize) { - return js_pod_realloc<T>(p, oldSize, newSize); - } - template <typename T> T* pod_malloc(size_t numElems) { return maybe_pod_malloc<T>(numElems); } - template <typename T> T* pod_calloc(size_t numElems) { return maybe_pod_calloc<T>(numElems); } - template <typename T> T* pod_realloc(T* p, size_t oldSize, size_t newSize) { - return maybe_pod_realloc<T>(p, oldSize, newSize); - } - void free_(void* p) { js_free(p); } - void reportAllocOverflow() const {} - bool checkSimulatedOOM() const { - return !js::oom::ShouldFailWithOOM(); - } -}; - -class ExclusiveContext; -void ReportOutOfMemory(ExclusiveContext* cxArg); - -/* - * Allocation policy that calls the system memory functions and reports errors - * to the context. Since the JSContext given on construction is stored for - * the lifetime of the container, this policy may only be used for containers - * whose lifetime is a shorter than the given JSContext. - * - * FIXME bug 647103 - rewrite this in terms of temporary allocation functions, - * not the system ones. - */ -class TempAllocPolicy -{ - ContextFriendFields* const cx_; - - /* - * Non-inline helper to call JSRuntime::onOutOfMemory with minimal - * code bloat. - */ - JS_FRIEND_API(void*) onOutOfMemory(AllocFunction allocFunc, size_t nbytes, - void* reallocPtr = nullptr); - - template <typename T> - T* onOutOfMemoryTyped(AllocFunction allocFunc, size_t numElems, void* reallocPtr = nullptr) { - size_t bytes; - if (MOZ_UNLIKELY(!CalculateAllocSize<T>(numElems, &bytes))) - return nullptr; - return static_cast<T*>(onOutOfMemory(allocFunc, bytes, reallocPtr)); - } - - public: - MOZ_IMPLICIT TempAllocPolicy(JSContext* cx) : cx_((ContextFriendFields*) cx) {} // :( - MOZ_IMPLICIT TempAllocPolicy(ContextFriendFields* cx) : cx_(cx) {} - - template <typename T> - T* maybe_pod_malloc(size_t numElems) { - return js_pod_malloc<T>(numElems); - } - - template <typename T> - T* maybe_pod_calloc(size_t numElems) { - return js_pod_calloc<T>(numElems); - } - - template <typename T> - T* maybe_pod_realloc(T* prior, size_t oldSize, size_t newSize) { - return js_pod_realloc<T>(prior, oldSize, newSize); - } - - template <typename T> - T* pod_malloc(size_t numElems) { - T* p = maybe_pod_malloc<T>(numElems); - if (MOZ_UNLIKELY(!p)) - p = onOutOfMemoryTyped<T>(AllocFunction::Malloc, numElems); - return p; - } - - template <typename T> - T* pod_calloc(size_t numElems) { - T* p = maybe_pod_calloc<T>(numElems); - if (MOZ_UNLIKELY(!p)) - p = onOutOfMemoryTyped<T>(AllocFunction::Calloc, numElems); - return p; - } - - template <typename T> - T* pod_realloc(T* prior, size_t oldSize, size_t newSize) { - T* p2 = maybe_pod_realloc<T>(prior, oldSize, newSize); - if (MOZ_UNLIKELY(!p2)) - p2 = onOutOfMemoryTyped<T>(AllocFunction::Realloc, newSize, prior); - return p2; - } - - void free_(void* p) { - js_free(p); - } - - JS_FRIEND_API(void) reportAllocOverflow() const; - - bool checkSimulatedOOM() const { - if (js::oom::ShouldFailWithOOM()) { - js::ReportOutOfMemory(reinterpret_cast<ExclusiveContext*>(cx_)); - return false; - } - - return true; - } -}; - -} /* namespace js */ - -#endif /* jsalloc_h */ diff --git a/android/armeabi/include/spidermonkey/jsapi.h b/android/armeabi/include/spidermonkey/jsapi.h deleted file mode 100644 index 84d639a0..00000000 --- a/android/armeabi/include/spidermonkey/jsapi.h +++ /dev/null @@ -1,6630 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* JavaScript API. */ - -#ifndef jsapi_h -#define jsapi_h - -#include "mozilla/AlreadyAddRefed.h" -#include "mozilla/FloatingPoint.h" -#include "mozilla/MemoryReporting.h" -#include "mozilla/Range.h" -#include "mozilla/RangedPtr.h" -#include "mozilla/RefCounted.h" -#include "mozilla/RefPtr.h" -#include "mozilla/Variant.h" - -#include <stdarg.h> -#include <stddef.h> -#include <stdint.h> -#include <stdio.h> - -#include "jsalloc.h" -#include "jspubtd.h" - -#include "js/CallArgs.h" -#include "js/CharacterEncoding.h" -#include "js/Class.h" -#include "js/GCVector.h" -#include "js/HashTable.h" -#include "js/Id.h" -#include "js/Principals.h" -#include "js/Realm.h" -#include "js/RootingAPI.h" -#include "js/TracingAPI.h" -#include "js/Utility.h" -#include "js/Value.h" -#include "js/Vector.h" - -/************************************************************************/ - -namespace JS { - -class TwoByteChars; - -#ifdef JS_DEBUG - -class JS_PUBLIC_API(AutoCheckRequestDepth) -{ - JSContext* cx; - public: - explicit AutoCheckRequestDepth(JSContext* cx); - explicit AutoCheckRequestDepth(js::ContextFriendFields* cx); - ~AutoCheckRequestDepth(); -}; - -# define CHECK_REQUEST(cx) \ - JS::AutoCheckRequestDepth _autoCheckRequestDepth(cx) - -#else - -# define CHECK_REQUEST(cx) \ - ((void) 0) - -#endif /* JS_DEBUG */ - -/** AutoValueArray roots an internal fixed-size array of Values. */ -template <size_t N> -class MOZ_RAII AutoValueArray : public AutoGCRooter -{ - const size_t length_; - Value elements_[N]; - - public: - explicit AutoValueArray(JSContext* cx - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : AutoGCRooter(cx, VALARRAY), length_(N) - { - /* Always initialize in case we GC before assignment. */ - mozilla::PodArrayZero(elements_); - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - unsigned length() const { return length_; } - const Value* begin() const { return elements_; } - Value* begin() { return elements_; } - - HandleValue operator[](unsigned i) const { - MOZ_ASSERT(i < N); - return HandleValue::fromMarkedLocation(&elements_[i]); - } - MutableHandleValue operator[](unsigned i) { - MOZ_ASSERT(i < N); - return MutableHandleValue::fromMarkedLocation(&elements_[i]); - } - - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -template<class T> -class MOZ_RAII AutoVectorRooterBase : protected AutoGCRooter -{ - typedef js::Vector<T, 8> VectorImpl; - VectorImpl vector; - - public: - explicit AutoVectorRooterBase(JSContext* cx, ptrdiff_t tag - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : AutoGCRooter(cx, tag), vector(cx) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - explicit AutoVectorRooterBase(js::ContextFriendFields* cx, ptrdiff_t tag - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : AutoGCRooter(cx, tag), vector(cx) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - typedef T ElementType; - typedef typename VectorImpl::Range Range; - - size_t length() const { return vector.length(); } - bool empty() const { return vector.empty(); } - - MOZ_MUST_USE bool append(const T& v) { return vector.append(v); } - MOZ_MUST_USE bool appendN(const T& v, size_t len) { return vector.appendN(v, len); } - MOZ_MUST_USE bool append(const T* ptr, size_t len) { return vector.append(ptr, len); } - MOZ_MUST_USE bool appendAll(const AutoVectorRooterBase<T>& other) { - return vector.appendAll(other.vector); - } - - MOZ_MUST_USE bool insert(T* p, const T& val) { return vector.insert(p, val); } - - /* For use when space has already been reserved. */ - void infallibleAppend(const T& v) { vector.infallibleAppend(v); } - - void popBack() { vector.popBack(); } - T popCopy() { return vector.popCopy(); } - - MOZ_MUST_USE bool growBy(size_t inc) { - size_t oldLength = vector.length(); - if (!vector.growByUninitialized(inc)) - return false; - makeRangeGCSafe(oldLength); - return true; - } - - MOZ_MUST_USE bool resize(size_t newLength) { - size_t oldLength = vector.length(); - if (newLength <= oldLength) { - vector.shrinkBy(oldLength - newLength); - return true; - } - if (!vector.growByUninitialized(newLength - oldLength)) - return false; - makeRangeGCSafe(oldLength); - return true; - } - - void clear() { vector.clear(); } - - MOZ_MUST_USE bool reserve(size_t newLength) { - return vector.reserve(newLength); - } - - JS::MutableHandle<T> operator[](size_t i) { - return JS::MutableHandle<T>::fromMarkedLocation(&vector[i]); - } - JS::Handle<T> operator[](size_t i) const { - return JS::Handle<T>::fromMarkedLocation(&vector[i]); - } - - const T* begin() const { return vector.begin(); } - T* begin() { return vector.begin(); } - - const T* end() const { return vector.end(); } - T* end() { return vector.end(); } - - Range all() { return vector.all(); } - - const T& back() const { return vector.back(); } - - friend void AutoGCRooter::trace(JSTracer* trc); - - private: - void makeRangeGCSafe(size_t oldLength) { - T* t = vector.begin() + oldLength; - for (size_t i = oldLength; i < vector.length(); ++i, ++t) - memset(t, 0, sizeof(T)); - } - - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -template <typename T> -class MOZ_RAII AutoVectorRooter : public AutoVectorRooterBase<T> -{ - public: - explicit AutoVectorRooter(JSContext* cx - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : AutoVectorRooterBase<T>(cx, this->GetTag(T())) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - explicit AutoVectorRooter(js::ContextFriendFields* cx - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : AutoVectorRooterBase<T>(cx, this->GetTag(T())) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -class AutoValueVector : public Rooted<GCVector<Value, 8>> { - using Vec = GCVector<Value, 8>; - using Base = Rooted<Vec>; - public: - explicit AutoValueVector(JSContext* cx) : Base(cx, Vec(cx)) {} - explicit AutoValueVector(js::ContextFriendFields* cx) : Base(cx, Vec(cx)) {} -}; - -class AutoIdVector : public Rooted<GCVector<jsid, 8>> { - using Vec = GCVector<jsid, 8>; - using Base = Rooted<Vec>; - public: - explicit AutoIdVector(JSContext* cx) : Base(cx, Vec(cx)) {} - explicit AutoIdVector(js::ContextFriendFields* cx) : Base(cx, Vec(cx)) {} - - bool appendAll(const AutoIdVector& other) { return this->Base::appendAll(other.get()); } -}; - -class AutoObjectVector : public Rooted<GCVector<JSObject*, 8>> { - using Vec = GCVector<JSObject*, 8>; - using Base = Rooted<Vec>; - public: - explicit AutoObjectVector(JSContext* cx) : Base(cx, Vec(cx)) {} - explicit AutoObjectVector(js::ContextFriendFields* cx) : Base(cx, Vec(cx)) {} -}; - -using ValueVector = JS::GCVector<JS::Value>; -using IdVector = JS::GCVector<jsid>; -using ScriptVector = JS::GCVector<JSScript*>; -using StringVector = JS::GCVector<JSString*>; - -template<class Key, class Value> -class MOZ_RAII AutoHashMapRooter : protected AutoGCRooter -{ - private: - typedef js::HashMap<Key, Value> HashMapImpl; - - public: - explicit AutoHashMapRooter(JSContext* cx, ptrdiff_t tag - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : AutoGCRooter(cx, tag), map(cx) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - typedef Key KeyType; - typedef Value ValueType; - typedef typename HashMapImpl::Entry Entry; - typedef typename HashMapImpl::Lookup Lookup; - typedef typename HashMapImpl::Ptr Ptr; - typedef typename HashMapImpl::AddPtr AddPtr; - - bool init(uint32_t len = 16) { - return map.init(len); - } - bool initialized() const { - return map.initialized(); - } - Ptr lookup(const Lookup& l) const { - return map.lookup(l); - } - void remove(Ptr p) { - map.remove(p); - } - AddPtr lookupForAdd(const Lookup& l) const { - return map.lookupForAdd(l); - } - - template<typename KeyInput, typename ValueInput> - bool add(AddPtr& p, const KeyInput& k, const ValueInput& v) { - return map.add(p, k, v); - } - - bool add(AddPtr& p, const Key& k) { - return map.add(p, k); - } - - template<typename KeyInput, typename ValueInput> - bool relookupOrAdd(AddPtr& p, const KeyInput& k, const ValueInput& v) { - return map.relookupOrAdd(p, k, v); - } - - typedef typename HashMapImpl::Range Range; - Range all() const { - return map.all(); - } - - typedef typename HashMapImpl::Enum Enum; - - void clear() { - map.clear(); - } - - void finish() { - map.finish(); - } - - bool empty() const { - return map.empty(); - } - - uint32_t count() const { - return map.count(); - } - - size_t capacity() const { - return map.capacity(); - } - - size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return map.sizeOfExcludingThis(mallocSizeOf); - } - size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return map.sizeOfIncludingThis(mallocSizeOf); - } - - /************************************************** Shorthand operations */ - - bool has(const Lookup& l) const { - return map.has(l); - } - - template<typename KeyInput, typename ValueInput> - bool put(const KeyInput& k, const ValueInput& v) { - return map.put(k, v); - } - - template<typename KeyInput, typename ValueInput> - bool putNew(const KeyInput& k, const ValueInput& v) { - return map.putNew(k, v); - } - - Ptr lookupWithDefault(const Key& k, const Value& defaultValue) { - return map.lookupWithDefault(k, defaultValue); - } - - void remove(const Lookup& l) { - map.remove(l); - } - - friend void AutoGCRooter::trace(JSTracer* trc); - - private: - AutoHashMapRooter(const AutoHashMapRooter& hmr) = delete; - AutoHashMapRooter& operator=(const AutoHashMapRooter& hmr) = delete; - - HashMapImpl map; - - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -template<class T> -class MOZ_RAII AutoHashSetRooter : protected AutoGCRooter -{ - private: - typedef js::HashSet<T> HashSetImpl; - - public: - explicit AutoHashSetRooter(JSContext* cx, ptrdiff_t tag - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : AutoGCRooter(cx, tag), set(cx) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - typedef typename HashSetImpl::Lookup Lookup; - typedef typename HashSetImpl::Ptr Ptr; - typedef typename HashSetImpl::AddPtr AddPtr; - - bool init(uint32_t len = 16) { - return set.init(len); - } - bool initialized() const { - return set.initialized(); - } - Ptr lookup(const Lookup& l) const { - return set.lookup(l); - } - void remove(Ptr p) { - set.remove(p); - } - AddPtr lookupForAdd(const Lookup& l) const { - return set.lookupForAdd(l); - } - - bool add(AddPtr& p, const T& t) { - return set.add(p, t); - } - - bool relookupOrAdd(AddPtr& p, const Lookup& l, const T& t) { - return set.relookupOrAdd(p, l, t); - } - - typedef typename HashSetImpl::Range Range; - Range all() const { - return set.all(); - } - - typedef typename HashSetImpl::Enum Enum; - - void clear() { - set.clear(); - } - - void finish() { - set.finish(); - } - - bool empty() const { - return set.empty(); - } - - uint32_t count() const { - return set.count(); - } - - size_t capacity() const { - return set.capacity(); - } - - size_t sizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return set.sizeOfExcludingThis(mallocSizeOf); - } - size_t sizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) const { - return set.sizeOfIncludingThis(mallocSizeOf); - } - - /************************************************** Shorthand operations */ - - bool has(const Lookup& l) const { - return set.has(l); - } - - bool put(const T& t) { - return set.put(t); - } - - bool putNew(const T& t) { - return set.putNew(t); - } - - void remove(const Lookup& l) { - set.remove(l); - } - - friend void AutoGCRooter::trace(JSTracer* trc); - - private: - AutoHashSetRooter(const AutoHashSetRooter& hmr) = delete; - AutoHashSetRooter& operator=(const AutoHashSetRooter& hmr) = delete; - - HashSetImpl set; - - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -/** - * Custom rooting behavior for internal and external clients. - */ -class MOZ_RAII JS_PUBLIC_API(CustomAutoRooter) : private AutoGCRooter -{ - public: - template <typename CX> - explicit CustomAutoRooter(const CX& cx MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : AutoGCRooter(cx, CUSTOM) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - friend void AutoGCRooter::trace(JSTracer* trc); - - protected: - virtual ~CustomAutoRooter() {} - - /** Supplied by derived class to trace roots. */ - virtual void trace(JSTracer* trc) = 0; - - private: - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -/** A handle to an array of rooted values. */ -class HandleValueArray -{ - const size_t length_; - const Value * const elements_; - - HandleValueArray(size_t len, const Value* elements) : length_(len), elements_(elements) {} - - public: - explicit HandleValueArray(const RootedValue& value) : length_(1), elements_(value.address()) {} - - MOZ_IMPLICIT HandleValueArray(const AutoValueVector& values) - : length_(values.length()), elements_(values.begin()) {} - - template <size_t N> - MOZ_IMPLICIT HandleValueArray(const AutoValueArray<N>& values) : length_(N), elements_(values.begin()) {} - - /** CallArgs must already be rooted somewhere up the stack. */ - MOZ_IMPLICIT HandleValueArray(const JS::CallArgs& args) : length_(args.length()), elements_(args.array()) {} - - /** Use with care! Only call this if the data is guaranteed to be marked. */ - static HandleValueArray fromMarkedLocation(size_t len, const Value* elements) { - return HandleValueArray(len, elements); - } - - static HandleValueArray subarray(const HandleValueArray& values, size_t startIndex, size_t len) { - MOZ_ASSERT(startIndex + len <= values.length()); - return HandleValueArray(len, values.begin() + startIndex); - } - - static HandleValueArray empty() { - return HandleValueArray(0, nullptr); - } - - size_t length() const { return length_; } - const Value* begin() const { return elements_; } - - HandleValue operator[](size_t i) const { - MOZ_ASSERT(i < length_); - return HandleValue::fromMarkedLocation(&elements_[i]); - } -}; - -} /* namespace JS */ - -/************************************************************************/ - -struct JSFreeOp { - protected: - JSRuntime* runtime_; - - explicit JSFreeOp(JSRuntime* rt) - : runtime_(rt) { } - - public: - JSRuntime* runtime() const { - MOZ_ASSERT(runtime_); - return runtime_; - } -}; - -/* Callbacks and their arguments. */ - -/************************************************************************/ - -typedef enum JSGCStatus { - JSGC_BEGIN, - JSGC_END -} JSGCStatus; - -typedef void -(* JSGCCallback)(JSContext* cx, JSGCStatus status, void* data); - -typedef void -(* JSObjectsTenuredCallback)(JSContext* cx, void* data); - -typedef enum JSFinalizeStatus { - /** - * Called when preparing to sweep a group of zones, before anything has been - * swept. The collector will not yield to the mutator before calling the - * callback with JSFINALIZE_GROUP_END status. - */ - JSFINALIZE_GROUP_START, - - /** - * Called when preparing to sweep a group of zones. Weak references to - * unmarked things have been removed and things that are not swept - * incrementally have been finalized at this point. The collector may yield - * to the mutator after this point. - */ - JSFINALIZE_GROUP_END, - - /** - * Called at the end of collection when everything has been swept. - */ - JSFINALIZE_COLLECTION_END -} JSFinalizeStatus; - -typedef void -(* JSFinalizeCallback)(JSFreeOp* fop, JSFinalizeStatus status, bool isZoneGC, void* data); - -typedef void -(* JSWeakPointerZoneGroupCallback)(JSContext* cx, void* data); - -typedef void -(* JSWeakPointerCompartmentCallback)(JSContext* cx, JSCompartment* comp, void* data); - -typedef bool -(* JSInterruptCallback)(JSContext* cx); - -typedef JSObject* -(* JSGetIncumbentGlobalCallback)(JSContext* cx); - -typedef bool -(* JSEnqueuePromiseJobCallback)(JSContext* cx, JS::HandleObject job, - JS::HandleObject allocationSite, JS::HandleObject incumbentGlobal, - void* data); - -enum class PromiseRejectionHandlingState { - Unhandled, - Handled -}; - -typedef void -(* JSPromiseRejectionTrackerCallback)(JSContext* cx, JS::HandleObject promise, - PromiseRejectionHandlingState state, void* data); - -typedef void -(* JSProcessPromiseCallback)(JSContext* cx, JS::HandleObject promise); - -/** - * Possible exception types. These types are part of a JSErrorFormatString - * structure. They define which error to throw in case of a runtime error. - * - * JSEXN_WARN is used for warnings in js.msg files (for instance because we - * don't want to prepend 'Error:' to warning messages). This value can go away - * if we ever decide to use an entirely separate mechanism for warnings. - */ -typedef enum JSExnType { - JSEXN_ERR, - JSEXN_FIRST = JSEXN_ERR, - JSEXN_INTERNALERR, - JSEXN_EVALERR, - JSEXN_RANGEERR, - JSEXN_REFERENCEERR, - JSEXN_SYNTAXERR, - JSEXN_TYPEERR, - JSEXN_URIERR, - JSEXN_DEBUGGEEWOULDRUN, - JSEXN_WASMCOMPILEERROR, - JSEXN_WASMRUNTIMEERROR, - JSEXN_WARN, - JSEXN_LIMIT -} JSExnType; - -typedef struct JSErrorFormatString { - /** The error message name in ASCII. */ - const char* name; - - /** The error format string in ASCII. */ - const char* format; - - /** The number of arguments to expand in the formatted error message. */ - uint16_t argCount; - - /** One of the JSExnType constants above. */ - int16_t exnType; -} JSErrorFormatString; - -typedef const JSErrorFormatString* -(* JSErrorCallback)(void* userRef, const unsigned errorNumber); - -typedef bool -(* JSLocaleToUpperCase)(JSContext* cx, JS::HandleString src, JS::MutableHandleValue rval); - -typedef bool -(* JSLocaleToLowerCase)(JSContext* cx, JS::HandleString src, JS::MutableHandleValue rval); - -typedef bool -(* JSLocaleCompare)(JSContext* cx, JS::HandleString src1, JS::HandleString src2, - JS::MutableHandleValue rval); - -typedef bool -(* JSLocaleToUnicode)(JSContext* cx, const char* src, JS::MutableHandleValue rval); - -/** - * Callback used to ask the embedding for the cross compartment wrapper handler - * that implements the desired prolicy for this kind of object in the - * destination compartment. |obj| is the object to be wrapped. If |existing| is - * non-nullptr, it will point to an existing wrapper object that should be - * re-used if possible. |existing| is guaranteed to be a cross-compartment - * wrapper with a lazily-defined prototype and the correct global. It is - * guaranteed not to wrap a function. - */ -typedef JSObject* -(* JSWrapObjectCallback)(JSContext* cx, JS::HandleObject existing, JS::HandleObject obj); - -/** - * Callback used by the wrap hook to ask the embedding to prepare an object - * for wrapping in a context. This might include unwrapping other wrappers - * or even finding a more suitable object for the new compartment. - */ -typedef void -(* JSPreWrapCallback)(JSContext* cx, JS::HandleObject scope, JS::HandleObject obj, - JS::HandleObject objectPassedToWrap, - JS::MutableHandleObject retObj); - -struct JSWrapObjectCallbacks -{ - JSWrapObjectCallback wrap; - JSPreWrapCallback preWrap; -}; - -typedef void -(* JSDestroyCompartmentCallback)(JSFreeOp* fop, JSCompartment* compartment); - -typedef size_t -(* JSSizeOfIncludingThisCompartmentCallback)(mozilla::MallocSizeOf mallocSizeOf, - JSCompartment* compartment); - -typedef void -(* JSZoneCallback)(JS::Zone* zone); - -typedef void -(* JSCompartmentNameCallback)(JSContext* cx, JSCompartment* compartment, - char* buf, size_t bufsize); - -/************************************************************************/ - -static MOZ_ALWAYS_INLINE JS::Value -JS_NumberValue(double d) -{ - int32_t i; - d = JS::CanonicalizeNaN(d); - if (mozilla::NumberIsInt32(d, &i)) - return JS::Int32Value(i); - return JS::DoubleValue(d); -} - -/************************************************************************/ - -JS_PUBLIC_API(bool) -JS_StringHasBeenPinned(JSContext* cx, JSString* str); - -namespace JS { - -/** - * Container class for passing in script source buffers to the JS engine. This - * not only groups the buffer and length values, it also provides a way to - * optionally pass ownership of the buffer to the JS engine without copying. - * Rules for use: - * - * 1) The data array must be allocated with js_malloc() or js_realloc() if - * ownership is being granted to the SourceBufferHolder. - * 2) If ownership is not given to the SourceBufferHolder, then the memory - * must be kept alive until the JS compilation is complete. - * 3) Any code calling SourceBufferHolder::take() must guarantee to keep the - * memory alive until JS compilation completes. Normally only the JS - * engine should be calling take(). - * - * Example use: - * - * size_t length = 512; - * char16_t* chars = static_cast<char16_t*>(js_malloc(sizeof(char16_t) * length)); - * JS::SourceBufferHolder srcBuf(chars, length, JS::SourceBufferHolder::GiveOwnership); - * JS::Compile(cx, options, srcBuf); - */ -class MOZ_STACK_CLASS SourceBufferHolder final -{ - public: - enum Ownership { - NoOwnership, - GiveOwnership - }; - - SourceBufferHolder(const char16_t* data, size_t dataLength, Ownership ownership) - : data_(data), - length_(dataLength), - ownsChars_(ownership == GiveOwnership) - { - // Ensure that null buffers properly return an unowned, empty, - // null-terminated string. - static const char16_t NullChar_ = 0; - if (!get()) { - data_ = &NullChar_; - length_ = 0; - ownsChars_ = false; - } - } - - SourceBufferHolder(SourceBufferHolder&& other) - : data_(other.data_), - length_(other.length_), - ownsChars_(other.ownsChars_) - { - other.data_ = nullptr; - other.length_ = 0; - other.ownsChars_ = false; - } - - ~SourceBufferHolder() { - if (ownsChars_) - js_free(const_cast<char16_t*>(data_)); - } - - // Access the underlying source buffer without affecting ownership. - const char16_t* get() const { return data_; } - - // Length of the source buffer in char16_t code units (not bytes) - size_t length() const { return length_; } - - // Returns true if the SourceBufferHolder owns the buffer and will free - // it upon destruction. If true, it is legal to call take(). - bool ownsChars() const { return ownsChars_; } - - // Retrieve and take ownership of the underlying data buffer. The caller - // is now responsible for calling js_free() on the returned value, *but only - // after JS script compilation has completed*. - // - // After the buffer has been taken the SourceBufferHolder functions as if - // it had been constructed on an unowned buffer; get() and length() still - // work. In order for this to be safe the taken buffer must be kept alive - // until after JS script compilation completes as noted above. - // - // Note, it's the caller's responsibility to check ownsChars() before taking - // the buffer. Taking and then free'ing an unowned buffer will have dire - // consequences. - char16_t* take() { - MOZ_ASSERT(ownsChars_); - ownsChars_ = false; - return const_cast<char16_t*>(data_); - } - - private: - SourceBufferHolder(SourceBufferHolder&) = delete; - SourceBufferHolder& operator=(SourceBufferHolder&) = delete; - - const char16_t* data_; - size_t length_; - bool ownsChars_; -}; - -} /* namespace JS */ - -/************************************************************************/ - -/* Property attributes, set in JSPropertySpec and passed to API functions. - * - * NB: The data structure in which some of these values are stored only uses - * a uint8_t to store the relevant information. Proceed with caution if - * trying to reorder or change the the first byte worth of flags. - */ -#define JSPROP_ENUMERATE 0x01 /* property is visible to for/in loop */ -#define JSPROP_READONLY 0x02 /* not settable: assignment is no-op. - This flag is only valid when neither - JSPROP_GETTER nor JSPROP_SETTER is - set. */ -#define JSPROP_PERMANENT 0x04 /* property cannot be deleted */ -#define JSPROP_PROPOP_ACCESSORS 0x08 /* Passed to JS_Define(UC)Property* and - JS_DefineElement if getters/setters - are JSGetterOp/JSSetterOp */ -#define JSPROP_GETTER 0x10 /* property holds getter function */ -#define JSPROP_SETTER 0x20 /* property holds setter function */ -#define JSPROP_SHARED 0x40 /* don't allocate a value slot for this - property; don't copy the property on - set of the same-named property in an - object that delegates to a prototype - containing this property */ -#define JSPROP_INTERNAL_USE_BIT 0x80 /* internal JS engine use only */ -#define JSFUN_STUB_GSOPS 0x200 /* use JS_PropertyStub getter/setter - instead of defaulting to class gsops - for property holding function */ - -#define JSFUN_CONSTRUCTOR 0x400 /* native that can be called as a ctor */ - -// 0x800 /* Unused */ - -#define JSFUN_HAS_REST 0x1000 /* function has ...rest parameter. */ - -#define JSFUN_FLAGS_MASK 0x1e00 /* | of all the JSFUN_* flags */ - -/* - * If set, will allow redefining a non-configurable property, but only on a - * non-DOM global. This is a temporary hack that will need to go away in bug - * 1105518. - */ -#define JSPROP_REDEFINE_NONCONFIGURABLE 0x1000 - -/* - * Resolve hooks and enumerate hooks must pass this flag when calling - * JS_Define* APIs to reify lazily-defined properties. - * - * JSPROP_RESOLVING is used only with property-defining APIs. It tells the - * engine to skip the resolve hook when performing the lookup at the beginning - * of property definition. This keeps the resolve hook from accidentally - * triggering itself: unchecked recursion. - * - * For enumerate hooks, triggering the resolve hook would be merely silly, not - * fatal, except in some cases involving non-configurable properties. - */ -#define JSPROP_RESOLVING 0x2000 - -#define JSPROP_IGNORE_ENUMERATE 0x4000 /* ignore the value in JSPROP_ENUMERATE. - This flag only valid when defining over - an existing property. */ -#define JSPROP_IGNORE_READONLY 0x8000 /* ignore the value in JSPROP_READONLY. - This flag only valid when defining over - an existing property. */ -#define JSPROP_IGNORE_PERMANENT 0x10000 /* ignore the value in JSPROP_PERMANENT. - This flag only valid when defining over - an existing property. */ -#define JSPROP_IGNORE_VALUE 0x20000 /* ignore the Value in the descriptor. Nothing was - specified when passed to Object.defineProperty - from script. */ - -/** Microseconds since the epoch, midnight, January 1, 1970 UTC. */ -extern JS_PUBLIC_API(int64_t) -JS_Now(void); - -/** Don't want to export data, so provide accessors for non-inline Values. */ -extern JS_PUBLIC_API(JS::Value) -JS_GetNaNValue(JSContext* cx); - -extern JS_PUBLIC_API(JS::Value) -JS_GetNegativeInfinityValue(JSContext* cx); - -extern JS_PUBLIC_API(JS::Value) -JS_GetPositiveInfinityValue(JSContext* cx); - -extern JS_PUBLIC_API(JS::Value) -JS_GetEmptyStringValue(JSContext* cx); - -extern JS_PUBLIC_API(JSString*) -JS_GetEmptyString(JSContext* cx); - -extern JS_PUBLIC_API(bool) -JS_ValueToObject(JSContext* cx, JS::HandleValue v, JS::MutableHandleObject objp); - -extern JS_PUBLIC_API(JSFunction*) -JS_ValueToFunction(JSContext* cx, JS::HandleValue v); - -extern JS_PUBLIC_API(JSFunction*) -JS_ValueToConstructor(JSContext* cx, JS::HandleValue v); - -extern JS_PUBLIC_API(JSString*) -JS_ValueToSource(JSContext* cx, JS::Handle<JS::Value> v); - -extern JS_PUBLIC_API(bool) -JS_DoubleIsInt32(double d, int32_t* ip); - -extern JS_PUBLIC_API(JSType) -JS_TypeOfValue(JSContext* cx, JS::Handle<JS::Value> v); - -namespace JS { - -extern JS_PUBLIC_API(const char*) -InformalValueTypeName(const JS::Value& v); - -} /* namespace JS */ - -extern JS_PUBLIC_API(bool) -JS_StrictlyEqual(JSContext* cx, JS::Handle<JS::Value> v1, JS::Handle<JS::Value> v2, bool* equal); - -extern JS_PUBLIC_API(bool) -JS_LooselyEqual(JSContext* cx, JS::Handle<JS::Value> v1, JS::Handle<JS::Value> v2, bool* equal); - -extern JS_PUBLIC_API(bool) -JS_SameValue(JSContext* cx, JS::Handle<JS::Value> v1, JS::Handle<JS::Value> v2, bool* same); - -/** True iff fun is the global eval function. */ -extern JS_PUBLIC_API(bool) -JS_IsBuiltinEvalFunction(JSFunction* fun); - -/** True iff fun is the Function constructor. */ -extern JS_PUBLIC_API(bool) -JS_IsBuiltinFunctionConstructor(JSFunction* fun); - -/************************************************************************/ - -/* - * Locking, contexts, and memory allocation. - * - * It is important that SpiderMonkey be initialized, and the first context - * be created, in a single-threaded fashion. Otherwise the behavior of the - * library is undefined. - * See: http://developer.mozilla.org/en/docs/Category:JSAPI_Reference - */ - -extern JS_PUBLIC_API(JSContext*) -JS_NewContext(uint32_t maxbytes, - uint32_t maxNurseryBytes = JS::DefaultNurseryBytes, - JSContext* parentContext = nullptr); - -extern JS_PUBLIC_API(void) -JS_DestroyContext(JSContext* cx); - -typedef double (*JS_CurrentEmbedderTimeFunction)(); - -/** - * The embedding can specify a time function that will be used in some - * situations. The function can return the time however it likes; but - * the norm is to return times in units of milliseconds since an - * arbitrary, but consistent, epoch. If the time function is not set, - * a built-in default will be used. - */ -JS_PUBLIC_API(void) -JS_SetCurrentEmbedderTimeFunction(JS_CurrentEmbedderTimeFunction timeFn); - -/** - * Return the time as computed using the current time function, or a - * suitable default if one has not been set. - */ -JS_PUBLIC_API(double) -JS_GetCurrentEmbedderTime(); - -JS_PUBLIC_API(void*) -JS_GetContextPrivate(JSContext* cx); - -JS_PUBLIC_API(void) -JS_SetContextPrivate(JSContext* cx, void* data); - -extern JS_PUBLIC_API(JSContext*) -JS_GetParentContext(JSContext* cx); - -extern JS_PUBLIC_API(void) -JS_BeginRequest(JSContext* cx); - -extern JS_PUBLIC_API(void) -JS_EndRequest(JSContext* cx); - -extern JS_PUBLIC_API(void) -JS_SetFutexCanWait(JSContext* cx); - -namespace js { - -void -AssertHeapIsIdle(JSRuntime* rt); - -} /* namespace js */ - -class MOZ_RAII JSAutoRequest -{ - public: - explicit JSAutoRequest(JSContext* cx - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : mContext(cx) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - JS_BeginRequest(mContext); - } - ~JSAutoRequest() { - JS_EndRequest(mContext); - } - - protected: - JSContext* mContext; - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER - -#if 0 - private: - static void* operator new(size_t) CPP_THROW_NEW { return 0; } - static void operator delete(void*, size_t) { } -#endif -}; - -extern JS_PUBLIC_API(JSVersion) -JS_GetVersion(JSContext* cx); - -/** - * Mutate the version on the compartment. This is generally discouraged, but - * necessary to support the version mutation in the js and xpc shell command - * set. - * - * It would be nice to put this in jsfriendapi, but the linkage requirements - * of the shells make that impossible. - */ -JS_PUBLIC_API(void) -JS_SetVersionForCompartment(JSCompartment* compartment, JSVersion version); - -extern JS_PUBLIC_API(const char*) -JS_VersionToString(JSVersion version); - -extern JS_PUBLIC_API(JSVersion) -JS_StringToVersion(const char* string); - -namespace JS { - -class JS_PUBLIC_API(ContextOptions) { - public: - ContextOptions() - : baseline_(true), - ion_(true), - asmJS_(true), - wasm_(false), - wasmAlwaysBaseline_(false), - throwOnAsmJSValidationFailure_(false), - nativeRegExp_(true), - unboxedArrays_(false), - asyncStack_(true), - throwOnDebuggeeWouldRun_(true), - dumpStackOnDebuggeeWouldRun_(false), - werror_(false), - strictMode_(false), - extraWarnings_(false) - { - } - - bool baseline() const { return baseline_; } - ContextOptions& setBaseline(bool flag) { - baseline_ = flag; - return *this; - } - ContextOptions& toggleBaseline() { - baseline_ = !baseline_; - return *this; - } - - bool ion() const { return ion_; } - ContextOptions& setIon(bool flag) { - ion_ = flag; - return *this; - } - ContextOptions& toggleIon() { - ion_ = !ion_; - return *this; - } - - bool asmJS() const { return asmJS_; } - ContextOptions& setAsmJS(bool flag) { - asmJS_ = flag; - return *this; - } - ContextOptions& toggleAsmJS() { - asmJS_ = !asmJS_; - return *this; - } - - bool wasm() const { return wasm_; } - ContextOptions& setWasm(bool flag) { - wasm_ = flag; - return *this; - } - ContextOptions& toggleWasm() { - wasm_ = !wasm_; - return *this; - } - - bool wasmAlwaysBaseline() const { return wasmAlwaysBaseline_; } - ContextOptions& setWasmAlwaysBaseline(bool flag) { - wasmAlwaysBaseline_ = flag; - return *this; - } - ContextOptions& toggleWasmAlwaysBaseline() { - wasmAlwaysBaseline_ = !wasmAlwaysBaseline_; - return *this; - } - - bool throwOnAsmJSValidationFailure() const { return throwOnAsmJSValidationFailure_; } - ContextOptions& setThrowOnAsmJSValidationFailure(bool flag) { - throwOnAsmJSValidationFailure_ = flag; - return *this; - } - ContextOptions& toggleThrowOnAsmJSValidationFailure() { - throwOnAsmJSValidationFailure_ = !throwOnAsmJSValidationFailure_; - return *this; - } - - bool nativeRegExp() const { return nativeRegExp_; } - ContextOptions& setNativeRegExp(bool flag) { - nativeRegExp_ = flag; - return *this; - } - - bool unboxedArrays() const { return unboxedArrays_; } - ContextOptions& setUnboxedArrays(bool flag) { - unboxedArrays_ = flag; - return *this; - } - - bool asyncStack() const { return asyncStack_; } - ContextOptions& setAsyncStack(bool flag) { - asyncStack_ = flag; - return *this; - } - - bool throwOnDebuggeeWouldRun() const { return throwOnDebuggeeWouldRun_; } - ContextOptions& setThrowOnDebuggeeWouldRun(bool flag) { - throwOnDebuggeeWouldRun_ = flag; - return *this; - } - - bool dumpStackOnDebuggeeWouldRun() const { return dumpStackOnDebuggeeWouldRun_; } - ContextOptions& setDumpStackOnDebuggeeWouldRun(bool flag) { - dumpStackOnDebuggeeWouldRun_ = flag; - return *this; - } - - bool werror() const { return werror_; } - ContextOptions& setWerror(bool flag) { - werror_ = flag; - return *this; - } - ContextOptions& toggleWerror() { - werror_ = !werror_; - return *this; - } - - bool strictMode() const { return strictMode_; } - ContextOptions& setStrictMode(bool flag) { - strictMode_ = flag; - return *this; - } - ContextOptions& toggleStrictMode() { - strictMode_ = !strictMode_; - return *this; - } - - bool extraWarnings() const { return extraWarnings_; } - ContextOptions& setExtraWarnings(bool flag) { - extraWarnings_ = flag; - return *this; - } - ContextOptions& toggleExtraWarnings() { - extraWarnings_ = !extraWarnings_; - return *this; - } - - private: - bool baseline_ : 1; - bool ion_ : 1; - bool asmJS_ : 1; - bool wasm_ : 1; - bool wasmAlwaysBaseline_ : 1; - bool throwOnAsmJSValidationFailure_ : 1; - bool nativeRegExp_ : 1; - bool unboxedArrays_ : 1; - bool asyncStack_ : 1; - bool throwOnDebuggeeWouldRun_ : 1; - bool dumpStackOnDebuggeeWouldRun_ : 1; - bool werror_ : 1; - bool strictMode_ : 1; - bool extraWarnings_ : 1; -}; - -JS_PUBLIC_API(ContextOptions&) -ContextOptionsRef(JSContext* cx); - -/** - * Initialize the runtime's self-hosted code. Embeddings should call this - * exactly once per runtime/context, before the first JS_NewGlobalObject - * call. - */ -JS_PUBLIC_API(bool) -InitSelfHostedCode(JSContext* cx); - -/** - * Asserts (in debug and release builds) that `obj` belongs to the current - * thread's context. - */ -JS_PUBLIC_API(void) -AssertObjectBelongsToCurrentThread(JSObject* obj); - -} /* namespace JS */ - -extern JS_PUBLIC_API(const char*) -JS_GetImplementationVersion(void); - -extern JS_PUBLIC_API(void) -JS_SetDestroyCompartmentCallback(JSContext* cx, JSDestroyCompartmentCallback callback); - -extern JS_PUBLIC_API(void) -JS_SetSizeOfIncludingThisCompartmentCallback(JSContext* cx, - JSSizeOfIncludingThisCompartmentCallback callback); - -extern JS_PUBLIC_API(void) -JS_SetDestroyZoneCallback(JSContext* cx, JSZoneCallback callback); - -extern JS_PUBLIC_API(void) -JS_SetSweepZoneCallback(JSContext* cx, JSZoneCallback callback); - -extern JS_PUBLIC_API(void) -JS_SetCompartmentNameCallback(JSContext* cx, JSCompartmentNameCallback callback); - -extern JS_PUBLIC_API(void) -JS_SetWrapObjectCallbacks(JSContext* cx, const JSWrapObjectCallbacks* callbacks); - -extern JS_PUBLIC_API(void) -JS_SetCompartmentPrivate(JSCompartment* compartment, void* data); - -extern JS_PUBLIC_API(void*) -JS_GetCompartmentPrivate(JSCompartment* compartment); - -extern JS_PUBLIC_API(void) -JS_SetZoneUserData(JS::Zone* zone, void* data); - -extern JS_PUBLIC_API(void*) -JS_GetZoneUserData(JS::Zone* zone); - -extern JS_PUBLIC_API(bool) -JS_WrapObject(JSContext* cx, JS::MutableHandleObject objp); - -extern JS_PUBLIC_API(bool) -JS_WrapValue(JSContext* cx, JS::MutableHandleValue vp); - -extern JS_PUBLIC_API(JSObject*) -JS_TransplantObject(JSContext* cx, JS::HandleObject origobj, JS::HandleObject target); - -extern JS_PUBLIC_API(bool) -JS_RefreshCrossCompartmentWrappers(JSContext* cx, JS::Handle<JSObject*> obj); - -/* - * At any time, a JSContext has a current (possibly-nullptr) compartment. - * Compartments are described in: - * - * developer.mozilla.org/en-US/docs/SpiderMonkey/SpiderMonkey_compartments - * - * The current compartment of a context may be changed. The preferred way to do - * this is with JSAutoCompartment: - * - * void foo(JSContext* cx, JSObject* obj) { - * // in some compartment 'c' - * { - * JSAutoCompartment ac(cx, obj); // constructor enters - * // in the compartment of 'obj' - * } // destructor leaves - * // back in compartment 'c' - * } - * - * For more complicated uses that don't neatly fit in a C++ stack frame, the - * compartment can entered and left using separate function calls: - * - * void foo(JSContext* cx, JSObject* obj) { - * // in 'oldCompartment' - * JSCompartment* oldCompartment = JS_EnterCompartment(cx, obj); - * // in the compartment of 'obj' - * JS_LeaveCompartment(cx, oldCompartment); - * // back in 'oldCompartment' - * } - * - * Note: these calls must still execute in a LIFO manner w.r.t all other - * enter/leave calls on the context. Furthermore, only the return value of a - * JS_EnterCompartment call may be passed as the 'oldCompartment' argument of - * the corresponding JS_LeaveCompartment call. - */ - -class MOZ_RAII JS_PUBLIC_API(JSAutoCompartment) -{ - JSContext* cx_; - JSCompartment* oldCompartment_; - public: - JSAutoCompartment(JSContext* cx, JSObject* target - MOZ_GUARD_OBJECT_NOTIFIER_PARAM); - JSAutoCompartment(JSContext* cx, JSScript* target - MOZ_GUARD_OBJECT_NOTIFIER_PARAM); - ~JSAutoCompartment(); - - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -class MOZ_RAII JS_PUBLIC_API(JSAutoNullableCompartment) -{ - JSContext* cx_; - JSCompartment* oldCompartment_; - public: - explicit JSAutoNullableCompartment(JSContext* cx, JSObject* targetOrNull - MOZ_GUARD_OBJECT_NOTIFIER_PARAM); - ~JSAutoNullableCompartment(); - - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -/** NB: This API is infallible; a nullptr return value does not indicate error. */ -extern JS_PUBLIC_API(JSCompartment*) -JS_EnterCompartment(JSContext* cx, JSObject* target); - -extern JS_PUBLIC_API(void) -JS_LeaveCompartment(JSContext* cx, JSCompartment* oldCompartment); - -typedef void (*JSIterateCompartmentCallback)(JSContext* cx, void* data, JSCompartment* compartment); - -/** - * This function calls |compartmentCallback| on every compartment. Beware that - * there is no guarantee that the compartment will survive after the callback - * returns. Also, barriers are disabled via the TraceSession. - */ -extern JS_PUBLIC_API(void) -JS_IterateCompartments(JSContext* cx, void* data, - JSIterateCompartmentCallback compartmentCallback); - -/** - * Initialize standard JS class constructors, prototypes, and any top-level - * functions and constants associated with the standard classes (e.g. isNaN - * for Number). - * - * NB: This sets cx's global object to obj if it was null. - */ -extern JS_PUBLIC_API(bool) -JS_InitStandardClasses(JSContext* cx, JS::Handle<JSObject*> obj); - -/** - * Resolve id, which must contain either a string or an int, to a standard - * class name in obj if possible, defining the class's constructor and/or - * prototype and storing true in *resolved. If id does not name a standard - * class or a top-level property induced by initializing a standard class, - * store false in *resolved and just return true. Return false on error, - * as usual for bool result-typed API entry points. - * - * This API can be called directly from a global object class's resolve op, - * to define standard classes lazily. The class's enumerate op should call - * JS_EnumerateStandardClasses(cx, obj), to define eagerly during for..in - * loops any classes not yet resolved lazily. - */ -extern JS_PUBLIC_API(bool) -JS_ResolveStandardClass(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* resolved); - -extern JS_PUBLIC_API(bool) -JS_MayResolveStandardClass(const JSAtomState& names, jsid id, JSObject* maybeObj); - -extern JS_PUBLIC_API(bool) -JS_EnumerateStandardClasses(JSContext* cx, JS::HandleObject obj); - -extern JS_PUBLIC_API(bool) -JS_GetClassObject(JSContext* cx, JSProtoKey key, JS::MutableHandle<JSObject*> objp); - -extern JS_PUBLIC_API(bool) -JS_GetClassPrototype(JSContext* cx, JSProtoKey key, JS::MutableHandle<JSObject*> objp); - -namespace JS { - -/* - * Determine if the given object is an instance/prototype/constructor for a standard - * class. If so, return the associated JSProtoKey. If not, return JSProto_Null. - */ - -extern JS_PUBLIC_API(JSProtoKey) -IdentifyStandardInstance(JSObject* obj); - -extern JS_PUBLIC_API(JSProtoKey) -IdentifyStandardPrototype(JSObject* obj); - -extern JS_PUBLIC_API(JSProtoKey) -IdentifyStandardInstanceOrPrototype(JSObject* obj); - -extern JS_PUBLIC_API(JSProtoKey) -IdentifyStandardConstructor(JSObject* obj); - -extern JS_PUBLIC_API(void) -ProtoKeyToId(JSContext* cx, JSProtoKey key, JS::MutableHandleId idp); - -} /* namespace JS */ - -extern JS_PUBLIC_API(JSProtoKey) -JS_IdToProtoKey(JSContext* cx, JS::HandleId id); - -/** - * Returns the original value of |Function.prototype| from the global object in - * which |forObj| was created. - */ -extern JS_PUBLIC_API(JSObject*) -JS_GetFunctionPrototype(JSContext* cx, JS::HandleObject forObj); - -/** - * Returns the original value of |Object.prototype| from the global object in - * which |forObj| was created. - */ -extern JS_PUBLIC_API(JSObject*) -JS_GetObjectPrototype(JSContext* cx, JS::HandleObject forObj); - -/** - * Returns the original value of |Array.prototype| from the global object in - * which |forObj| was created. - */ -extern JS_PUBLIC_API(JSObject*) -JS_GetArrayPrototype(JSContext* cx, JS::HandleObject forObj); - -/** - * Returns the original value of |Error.prototype| from the global - * object of the current compartment of cx. - */ -extern JS_PUBLIC_API(JSObject*) -JS_GetErrorPrototype(JSContext* cx); - -/** - * Returns the %IteratorPrototype% object that all built-in iterator prototype - * chains go through for the global object of the current compartment of cx. - */ -extern JS_PUBLIC_API(JSObject*) -JS_GetIteratorPrototype(JSContext* cx); - -extern JS_PUBLIC_API(JSObject*) -JS_GetGlobalForObject(JSContext* cx, JSObject* obj); - -extern JS_PUBLIC_API(bool) -JS_IsGlobalObject(JSObject* obj); - -extern JS_PUBLIC_API(JSObject*) -JS_GlobalLexicalEnvironment(JSObject* obj); - -extern JS_PUBLIC_API(bool) -JS_HasExtensibleLexicalEnvironment(JSObject* obj); - -extern JS_PUBLIC_API(JSObject*) -JS_ExtensibleLexicalEnvironment(JSObject* obj); - -/** - * May return nullptr, if |c| never had a global (e.g. the atoms compartment), - * or if |c|'s global has been collected. - */ -extern JS_PUBLIC_API(JSObject*) -JS_GetGlobalForCompartmentOrNull(JSContext* cx, JSCompartment* c); - -namespace JS { - -extern JS_PUBLIC_API(JSObject*) -CurrentGlobalOrNull(JSContext* cx); - -} // namespace JS - -/** - * Add 'Reflect.parse', a SpiderMonkey extension, to the Reflect object on the - * given global. - */ -extern JS_PUBLIC_API(bool) -JS_InitReflectParse(JSContext* cx, JS::HandleObject global); - -/** - * Add various profiling-related functions as properties of the given object. - * Defined in builtin/Profilers.cpp. - */ -extern JS_PUBLIC_API(bool) -JS_DefineProfilingFunctions(JSContext* cx, JS::HandleObject obj); - -/* Defined in vm/Debugger.cpp. */ -extern JS_PUBLIC_API(bool) -JS_DefineDebuggerObject(JSContext* cx, JS::HandleObject obj); - -#ifdef JS_HAS_CTYPES -/** - * Initialize the 'ctypes' object on a global variable 'obj'. The 'ctypes' - * object will be sealed. - */ -extern JS_PUBLIC_API(bool) -JS_InitCTypesClass(JSContext* cx, JS::HandleObject global); - -/** - * Convert a unicode string 'source' of length 'slen' to the platform native - * charset, returning a null-terminated string allocated with JS_malloc. On - * failure, this function should report an error. - */ -typedef char* -(* JSCTypesUnicodeToNativeFun)(JSContext* cx, const char16_t* source, size_t slen); - -/** - * Set of function pointers that ctypes can use for various internal functions. - * See JS_SetCTypesCallbacks below. Providing nullptr for a function is safe, - * and will result in the applicable ctypes functionality not being available. - */ -struct JSCTypesCallbacks { - JSCTypesUnicodeToNativeFun unicodeToNative; -}; - -typedef struct JSCTypesCallbacks JSCTypesCallbacks; - -/** - * Set the callbacks on the provided 'ctypesObj' object. 'callbacks' should be a - * pointer to static data that exists for the lifetime of 'ctypesObj', but it - * may safely be altered after calling this function and without having - * to call this function again. - */ -extern JS_PUBLIC_API(void) -JS_SetCTypesCallbacks(JSObject* ctypesObj, const JSCTypesCallbacks* callbacks); -#endif - -extern JS_PUBLIC_API(void*) -JS_malloc(JSContext* cx, size_t nbytes); - -extern JS_PUBLIC_API(void*) -JS_realloc(JSContext* cx, void* p, size_t oldBytes, size_t newBytes); - -/** - * A wrapper for js_free(p) that may delay js_free(p) invocation as a - * performance optimization. - * cx may be nullptr. - */ -extern JS_PUBLIC_API(void) -JS_free(JSContext* cx, void* p); - -/** - * A wrapper for js_free(p) that may delay js_free(p) invocation as a - * performance optimization as specified by the given JSFreeOp instance. - */ -extern JS_PUBLIC_API(void) -JS_freeop(JSFreeOp* fop, void* p); - -extern JS_PUBLIC_API(void) -JS_updateMallocCounter(JSContext* cx, size_t nbytes); - -extern JS_PUBLIC_API(char*) -JS_strdup(JSContext* cx, const char* s); - -/** - * Register externally maintained GC roots. - * - * traceOp: the trace operation. For each root the implementation should call - * JS::TraceEdge whenever the root contains a traceable thing. - * data: the data argument to pass to each invocation of traceOp. - */ -extern JS_PUBLIC_API(bool) -JS_AddExtraGCRootsTracer(JSContext* cx, JSTraceDataOp traceOp, void* data); - -/** Undo a call to JS_AddExtraGCRootsTracer. */ -extern JS_PUBLIC_API(void) -JS_RemoveExtraGCRootsTracer(JSContext* cx, JSTraceDataOp traceOp, void* data); - -/* - * Garbage collector API. - */ -extern JS_PUBLIC_API(void) -JS_GC(JSContext* cx); - -extern JS_PUBLIC_API(void) -JS_MaybeGC(JSContext* cx); - -extern JS_PUBLIC_API(void) -JS_SetGCCallback(JSContext* cx, JSGCCallback cb, void* data); - -extern JS_PUBLIC_API(void) -JS_SetObjectsTenuredCallback(JSContext* cx, JSObjectsTenuredCallback cb, - void* data); - -extern JS_PUBLIC_API(bool) -JS_AddFinalizeCallback(JSContext* cx, JSFinalizeCallback cb, void* data); - -extern JS_PUBLIC_API(void) -JS_RemoveFinalizeCallback(JSContext* cx, JSFinalizeCallback cb); - -/* - * Weak pointers and garbage collection - * - * Weak pointers are by their nature not marked as part of garbage collection, - * but they may need to be updated in two cases after a GC: - * - * 1) Their referent was found not to be live and is about to be finalized - * 2) Their referent has been moved by a compacting GC - * - * To handle this, any part of the system that maintain weak pointers to - * JavaScript GC things must register a callback with - * JS_(Add,Remove)WeakPointer{ZoneGroup,Compartment}Callback(). This callback - * must then call JS_UpdateWeakPointerAfterGC() on all weak pointers it knows - * about. - * - * Since sweeping is incremental, we have several callbacks to avoid repeatedly - * having to visit all embedder structures. The WeakPointerZoneGroupCallback is - * called once for each strongly connected group of zones, whereas the - * WeakPointerCompartmentCallback is called once for each compartment that is - * visited while sweeping. Structures that cannot contain references in more - * than one compartment should sweep the relevant per-compartment structures - * using the latter callback to minimizer per-slice overhead. - * - * The argument to JS_UpdateWeakPointerAfterGC() is an in-out param. If the - * referent is about to be finalized the pointer will be set to null. If the - * referent has been moved then the pointer will be updated to point to the new - * location. - * - * Callers of this method are responsible for updating any state that is - * dependent on the object's address. For example, if the object's address is - * used as a key in a hashtable, then the object must be removed and - * re-inserted with the correct hash. - */ - -extern JS_PUBLIC_API(bool) -JS_AddWeakPointerZoneGroupCallback(JSContext* cx, JSWeakPointerZoneGroupCallback cb, void* data); - -extern JS_PUBLIC_API(void) -JS_RemoveWeakPointerZoneGroupCallback(JSContext* cx, JSWeakPointerZoneGroupCallback cb); - -extern JS_PUBLIC_API(bool) -JS_AddWeakPointerCompartmentCallback(JSContext* cx, JSWeakPointerCompartmentCallback cb, - void* data); - -extern JS_PUBLIC_API(void) -JS_RemoveWeakPointerCompartmentCallback(JSContext* cx, JSWeakPointerCompartmentCallback cb); - -extern JS_PUBLIC_API(void) -JS_UpdateWeakPointerAfterGC(JS::Heap<JSObject*>* objp); - -extern JS_PUBLIC_API(void) -JS_UpdateWeakPointerAfterGCUnbarriered(JSObject** objp); - -typedef enum JSGCParamKey { - /** Maximum nominal heap before last ditch GC. */ - JSGC_MAX_BYTES = 0, - - /** Number of JS_malloc bytes before last ditch GC. */ - JSGC_MAX_MALLOC_BYTES = 1, - - /** Amount of bytes allocated by the GC. */ - JSGC_BYTES = 3, - - /** Number of times GC has been invoked. Includes both major and minor GC. */ - JSGC_NUMBER = 4, - - /** Select GC mode. */ - JSGC_MODE = 6, - - /** Number of cached empty GC chunks. */ - JSGC_UNUSED_CHUNKS = 7, - - /** Total number of allocated GC chunks. */ - JSGC_TOTAL_CHUNKS = 8, - - /** Max milliseconds to spend in an incremental GC slice. */ - JSGC_SLICE_TIME_BUDGET = 9, - - /** Maximum size the GC mark stack can grow to. */ - JSGC_MARK_STACK_LIMIT = 10, - - /** - * GCs less than this far apart in time will be considered 'high-frequency GCs'. - * See setGCLastBytes in jsgc.cpp. - */ - JSGC_HIGH_FREQUENCY_TIME_LIMIT = 11, - - /** Start of dynamic heap growth. */ - JSGC_HIGH_FREQUENCY_LOW_LIMIT = 12, - - /** End of dynamic heap growth. */ - JSGC_HIGH_FREQUENCY_HIGH_LIMIT = 13, - - /** Upper bound of heap growth. */ - JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MAX = 14, - - /** Lower bound of heap growth. */ - JSGC_HIGH_FREQUENCY_HEAP_GROWTH_MIN = 15, - - /** Heap growth for low frequency GCs. */ - JSGC_LOW_FREQUENCY_HEAP_GROWTH = 16, - - /** - * If false, the heap growth factor is fixed at 3. If true, it is determined - * based on whether GCs are high- or low- frequency. - */ - JSGC_DYNAMIC_HEAP_GROWTH = 17, - - /** If true, high-frequency GCs will use a longer mark slice. */ - JSGC_DYNAMIC_MARK_SLICE = 18, - - /** Lower limit after which we limit the heap growth. */ - JSGC_ALLOCATION_THRESHOLD = 19, - - /** - * We try to keep at least this many unused chunks in the free chunk pool at - * all times, even after a shrinking GC. - */ - JSGC_MIN_EMPTY_CHUNK_COUNT = 21, - - /** We never keep more than this many unused chunks in the free chunk pool. */ - JSGC_MAX_EMPTY_CHUNK_COUNT = 22, - - /** Whether compacting GC is enabled. */ - JSGC_COMPACTING_ENABLED = 23, - - /** If true, painting can trigger IGC slices. */ - JSGC_REFRESH_FRAME_SLICES_ENABLED = 24, -} JSGCParamKey; - -extern JS_PUBLIC_API(void) -JS_SetGCParameter(JSContext* cx, JSGCParamKey key, uint32_t value); - -extern JS_PUBLIC_API(uint32_t) -JS_GetGCParameter(JSContext* cx, JSGCParamKey key); - -extern JS_PUBLIC_API(void) -JS_SetGCParametersBasedOnAvailableMemory(JSContext* cx, uint32_t availMem); - -/** - * Create a new JSString whose chars member refers to external memory, i.e., - * memory requiring application-specific finalization. - */ -extern JS_PUBLIC_API(JSString*) -JS_NewExternalString(JSContext* cx, const char16_t* chars, size_t length, - const JSStringFinalizer* fin); - -/** - * Return whether 'str' was created with JS_NewExternalString or - * JS_NewExternalStringWithClosure. - */ -extern JS_PUBLIC_API(bool) -JS_IsExternalString(JSString* str); - -/** - * Return the 'fin' arg passed to JS_NewExternalString. - */ -extern JS_PUBLIC_API(const JSStringFinalizer*) -JS_GetExternalStringFinalizer(JSString* str); - -/** - * Set the size of the native stack that should not be exceed. To disable - * stack size checking pass 0. - * - * SpiderMonkey allows for a distinction between system code (such as GCs, which - * may incidentally be triggered by script but are not strictly performed on - * behalf of such script), trusted script (as determined by JS_SetTrustedPrincipals), - * and untrusted script. Each kind of code may have a different stack quota, - * allowing embedders to keep higher-priority machinery running in the face of - * scripted stack exhaustion by something else. - * - * The stack quotas for each kind of code should be monotonically descending, - * and may be specified with this function. If 0 is passed for a given kind - * of code, it defaults to the value of the next-highest-priority kind. - * - * This function may only be called immediately after the runtime is initialized - * and before any code is executed and/or interrupts requested. - */ -extern JS_PUBLIC_API(void) -JS_SetNativeStackQuota(JSContext* cx, size_t systemCodeStackSize, - size_t trustedScriptStackSize = 0, - size_t untrustedScriptStackSize = 0); - -/************************************************************************/ - -extern JS_PUBLIC_API(bool) -JS_ValueToId(JSContext* cx, JS::HandleValue v, JS::MutableHandleId idp); - -extern JS_PUBLIC_API(bool) -JS_StringToId(JSContext* cx, JS::HandleString s, JS::MutableHandleId idp); - -extern JS_PUBLIC_API(bool) -JS_IdToValue(JSContext* cx, jsid id, JS::MutableHandle<JS::Value> vp); - -namespace JS { - -/** - * Convert obj to a primitive value. On success, store the result in vp and - * return true. - * - * The hint argument must be JSTYPE_STRING, JSTYPE_NUMBER, or JSTYPE_VOID (no - * hint). - * - * Implements: ES6 7.1.1 ToPrimitive(input, [PreferredType]). - */ -extern JS_PUBLIC_API(bool) -ToPrimitive(JSContext* cx, JS::HandleObject obj, JSType hint, JS::MutableHandleValue vp); - -/** - * If args.get(0) is one of the strings "string", "number", or "default", set - * *result to JSTYPE_STRING, JSTYPE_NUMBER, or JSTYPE_VOID accordingly and - * return true. Otherwise, return false with a TypeError pending. - * - * This can be useful in implementing a @@toPrimitive method. - */ -extern JS_PUBLIC_API(bool) -GetFirstArgumentAsTypeHint(JSContext* cx, CallArgs args, JSType *result); - -} /* namespace JS */ - -extern JS_PUBLIC_API(bool) -JS_PropertyStub(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandleValue vp); - -extern JS_PUBLIC_API(bool) -JS_StrictPropertyStub(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandleValue vp, JS::ObjectOpResult& result); - -template<typename T> -struct JSConstScalarSpec { - const char* name; - T val; -}; - -typedef JSConstScalarSpec<double> JSConstDoubleSpec; -typedef JSConstScalarSpec<int32_t> JSConstIntegerSpec; - -struct JSJitInfo; - -/** - * Wrapper to relace JSNative for JSPropertySpecs and JSFunctionSpecs. This will - * allow us to pass one JSJitInfo per function with the property/function spec, - * without additional field overhead. - */ -typedef struct JSNativeWrapper { - JSNative op; - const JSJitInfo* info; -} JSNativeWrapper; - -/* - * Macro static initializers which make it easy to pass no JSJitInfo as part of a - * JSPropertySpec or JSFunctionSpec. - */ -#define JSNATIVE_WRAPPER(native) { {native, nullptr} } - -/** - * Description of a property. JS_DefineProperties and JS_InitClass take arrays - * of these and define many properties at once. JS_PSG, JS_PSGS and JS_PS_END - * are helper macros for defining such arrays. - */ -struct JSPropertySpec { - struct SelfHostedWrapper { - void* unused; - const char* funname; - }; - - struct ValueWrapper { - uintptr_t type; - union { - const char* string; - int32_t int32; - }; - }; - - const char* name; - uint8_t flags; - union { - struct { - union { - JSNativeWrapper native; - SelfHostedWrapper selfHosted; - } getter; - union { - JSNativeWrapper native; - SelfHostedWrapper selfHosted; - } setter; - } accessors; - ValueWrapper value; - }; - - bool isAccessor() const { - return !(flags & JSPROP_INTERNAL_USE_BIT); - } - bool getValue(JSContext* cx, JS::MutableHandleValue value) const; - - bool isSelfHosted() const { - MOZ_ASSERT(isAccessor()); - -#ifdef DEBUG - // Verify that our accessors match our JSPROP_GETTER flag. - if (flags & JSPROP_GETTER) - checkAccessorsAreSelfHosted(); - else - checkAccessorsAreNative(); -#endif - return (flags & JSPROP_GETTER); - } - - static_assert(sizeof(SelfHostedWrapper) == sizeof(JSNativeWrapper), - "JSPropertySpec::getter/setter must be compact"); - static_assert(offsetof(SelfHostedWrapper, funname) == offsetof(JSNativeWrapper, info), - "JS_SELF_HOSTED* macros below require that " - "SelfHostedWrapper::funname overlay " - "JSNativeWrapper::info"); -private: - void checkAccessorsAreNative() const { - MOZ_ASSERT(accessors.getter.native.op); - // We may not have a setter at all. So all we can assert here, for the - // native case is that if we have a jitinfo for the setter then we have - // a setter op too. This is good enough to make sure we don't have a - // SelfHostedWrapper for the setter. - MOZ_ASSERT_IF(accessors.setter.native.info, accessors.setter.native.op); - } - - void checkAccessorsAreSelfHosted() const { - MOZ_ASSERT(!accessors.getter.selfHosted.unused); - MOZ_ASSERT(!accessors.setter.selfHosted.unused); - } -}; - -namespace JS { -namespace detail { - -/* NEVER DEFINED, DON'T USE. For use by JS_CAST_NATIVE_TO only. */ -inline int CheckIsNative(JSNative native); - -/* NEVER DEFINED, DON'T USE. For use by JS_CAST_STRING_TO only. */ -template<size_t N> -inline int -CheckIsCharacterLiteral(const char (&arr)[N]); - -/* NEVER DEFINED, DON'T USE. For use by JS_CAST_INT32_TO only. */ -inline int CheckIsInt32(int32_t value); - -/* NEVER DEFINED, DON'T USE. For use by JS_PROPERTYOP_GETTER only. */ -inline int CheckIsGetterOp(JSGetterOp op); - -/* NEVER DEFINED, DON'T USE. For use by JS_PROPERTYOP_SETTER only. */ -inline int CheckIsSetterOp(JSSetterOp op); - -} // namespace detail -} // namespace JS - -#define JS_CAST_NATIVE_TO(v, To) \ - (static_cast<void>(sizeof(JS::detail::CheckIsNative(v))), \ - reinterpret_cast<To>(v)) - -#define JS_CAST_STRING_TO(s, To) \ - (static_cast<void>(sizeof(JS::detail::CheckIsCharacterLiteral(s))), \ - reinterpret_cast<To>(s)) - -#define JS_CAST_INT32_TO(s, To) \ - (static_cast<void>(sizeof(JS::detail::CheckIsInt32(s))), \ - reinterpret_cast<To>(s)) - -#define JS_CHECK_ACCESSOR_FLAGS(flags) \ - (static_cast<mozilla::EnableIf<((flags) & ~(JSPROP_ENUMERATE | JSPROP_PERMANENT)) == 0>::Type>(0), \ - (flags)) - -#define JS_PROPERTYOP_GETTER(v) \ - (static_cast<void>(sizeof(JS::detail::CheckIsGetterOp(v))), \ - reinterpret_cast<JSNative>(v)) - -#define JS_PROPERTYOP_SETTER(v) \ - (static_cast<void>(sizeof(JS::detail::CheckIsSetterOp(v))), \ - reinterpret_cast<JSNative>(v)) - -#define JS_STUBGETTER JS_PROPERTYOP_GETTER(JS_PropertyStub) - -#define JS_STUBSETTER JS_PROPERTYOP_SETTER(JS_StrictPropertyStub) - -#define JS_PS_ACCESSOR_SPEC(name, getter, setter, flags, extraFlags) \ - { name, uint8_t(JS_CHECK_ACCESSOR_FLAGS(flags) | extraFlags), \ - { { getter, setter } } } -#define JS_PS_VALUE_SPEC(name, value, flags) \ - { name, uint8_t(flags | JSPROP_INTERNAL_USE_BIT), \ - { { value, JSNATIVE_WRAPPER(nullptr) } } } - -#define SELFHOSTED_WRAPPER(name) \ - { { nullptr, JS_CAST_STRING_TO(name, const JSJitInfo*) } } -#define STRINGVALUE_WRAPPER(value) \ - { { reinterpret_cast<JSNative>(JSVAL_TYPE_STRING), JS_CAST_STRING_TO(value, const JSJitInfo*) } } -#define INT32VALUE_WRAPPER(value) \ - { { reinterpret_cast<JSNative>(JSVAL_TYPE_INT32), JS_CAST_INT32_TO(value, const JSJitInfo*) } } - -/* - * JSPropertySpec uses JSNativeWrapper. These macros encapsulate the definition - * of JSNative-backed JSPropertySpecs, by defining the JSNativeWrappers for - * them. - */ -#define JS_PSG(name, getter, flags) \ - JS_PS_ACCESSOR_SPEC(name, JSNATIVE_WRAPPER(getter), JSNATIVE_WRAPPER(nullptr), flags, \ - JSPROP_SHARED) -#define JS_PSGS(name, getter, setter, flags) \ - JS_PS_ACCESSOR_SPEC(name, JSNATIVE_WRAPPER(getter), JSNATIVE_WRAPPER(setter), flags, \ - JSPROP_SHARED) -#define JS_SELF_HOSTED_GET(name, getterName, flags) \ - JS_PS_ACCESSOR_SPEC(name, SELFHOSTED_WRAPPER(getterName), JSNATIVE_WRAPPER(nullptr), flags, \ - JSPROP_SHARED | JSPROP_GETTER) -#define JS_SELF_HOSTED_GETSET(name, getterName, setterName, flags) \ - JS_PS_ACCESSOR_SPEC(name, SELFHOSTED_WRAPPER(getterName), SELFHOSTED_WRAPPER(setterName), \ - flags, JSPROP_SHARED | JSPROP_GETTER | JSPROP_SETTER) -#define JS_SELF_HOSTED_SYM_GET(symbol, getterName, flags) \ - JS_PS_ACCESSOR_SPEC(reinterpret_cast<const char*>(uint32_t(::JS::SymbolCode::symbol) + 1), \ - SELFHOSTED_WRAPPER(getterName), JSNATIVE_WRAPPER(nullptr), flags, \ - JSPROP_SHARED | JSPROP_GETTER) -#define JS_STRING_PS(name, string, flags) \ - JS_PS_VALUE_SPEC(name, STRINGVALUE_WRAPPER(string), flags) -#define JS_STRING_SYM_PS(symbol, string, flags) \ - JS_PS_VALUE_SPEC(reinterpret_cast<const char*>(uint32_t(::JS::SymbolCode::symbol) + 1), \ - STRINGVALUE_WRAPPER(string), flags) -#define JS_INT32_PS(name, value, flags) \ - JS_PS_VALUE_SPEC(name, INT32VALUE_WRAPPER(value), flags) -#define JS_PS_END \ - JS_PS_ACCESSOR_SPEC(nullptr, JSNATIVE_WRAPPER(nullptr), JSNATIVE_WRAPPER(nullptr), 0, 0) - -/** - * To define a native function, set call to a JSNativeWrapper. To define a - * self-hosted function, set selfHostedName to the name of a function - * compiled during JSRuntime::initSelfHosting. - */ -struct JSFunctionSpec { - const char* name; - JSNativeWrapper call; - uint16_t nargs; - uint16_t flags; - const char* selfHostedName; -}; - -/* - * Terminating sentinel initializer to put at the end of a JSFunctionSpec array - * that's passed to JS_DefineFunctions or JS_InitClass. - */ -#define JS_FS_END JS_FS(nullptr,nullptr,0,0) - -/* - * Initializer macros for a JSFunctionSpec array element. JS_FN (whose name pays - * homage to the old JSNative/JSFastNative split) simply adds the flag - * JSFUN_STUB_GSOPS. JS_FNINFO allows the simple adding of - * JSJitInfos. JS_SELF_HOSTED_FN declares a self-hosted function. - * JS_INLINABLE_FN allows specifying an InlinableNative enum value for natives - * inlined or specialized by the JIT. Finally JS_FNSPEC has slots for all the - * fields. - * - * The _SYM variants allow defining a function with a symbol key rather than a - * string key. For example, use JS_SYM_FN(iterator, ...) to define an - * @@iterator method. - */ -#define JS_FS(name,call,nargs,flags) \ - JS_FNSPEC(name, call, nullptr, nargs, flags, nullptr) -#define JS_FN(name,call,nargs,flags) \ - JS_FNSPEC(name, call, nullptr, nargs, (flags) | JSFUN_STUB_GSOPS, nullptr) -#define JS_INLINABLE_FN(name,call,nargs,flags,native) \ - JS_FNSPEC(name, call, &js::jit::JitInfo_##native, nargs, (flags) | JSFUN_STUB_GSOPS, nullptr) -#define JS_SYM_FN(symbol,call,nargs,flags) \ - JS_SYM_FNSPEC(symbol, call, nullptr, nargs, (flags) | JSFUN_STUB_GSOPS, nullptr) -#define JS_FNINFO(name,call,info,nargs,flags) \ - JS_FNSPEC(name, call, info, nargs, flags, nullptr) -#define JS_SELF_HOSTED_FN(name,selfHostedName,nargs,flags) \ - JS_FNSPEC(name, nullptr, nullptr, nargs, flags, selfHostedName) -#define JS_SELF_HOSTED_SYM_FN(symbol, selfHostedName, nargs, flags) \ - JS_SYM_FNSPEC(symbol, nullptr, nullptr, nargs, flags, selfHostedName) -#define JS_SYM_FNSPEC(symbol, call, info, nargs, flags, selfHostedName) \ - JS_FNSPEC(reinterpret_cast<const char*>( \ - uint32_t(::JS::SymbolCode::symbol) + 1), \ - call, info, nargs, flags, selfHostedName) -#define JS_FNSPEC(name,call,info,nargs,flags,selfHostedName) \ - {name, {call, info}, nargs, flags, selfHostedName} - -extern JS_PUBLIC_API(JSObject*) -JS_InitClass(JSContext* cx, JS::HandleObject obj, JS::HandleObject parent_proto, - const JSClass* clasp, JSNative constructor, unsigned nargs, - const JSPropertySpec* ps, const JSFunctionSpec* fs, - const JSPropertySpec* static_ps, const JSFunctionSpec* static_fs); - -/** - * Set up ctor.prototype = proto and proto.constructor = ctor with the - * right property flags. - */ -extern JS_PUBLIC_API(bool) -JS_LinkConstructorAndPrototype(JSContext* cx, JS::Handle<JSObject*> ctor, - JS::Handle<JSObject*> proto); - -extern JS_PUBLIC_API(const JSClass*) -JS_GetClass(JSObject* obj); - -extern JS_PUBLIC_API(bool) -JS_InstanceOf(JSContext* cx, JS::Handle<JSObject*> obj, const JSClass* clasp, JS::CallArgs* args); - -extern JS_PUBLIC_API(bool) -JS_HasInstance(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<JS::Value> v, bool* bp); - -namespace JS { - -// Implementation of -// http://www.ecma-international.org/ecma-262/6.0/#sec-ordinaryhasinstance. If -// you're looking for the equivalent of "instanceof", you want JS_HasInstance, -// not this function. -extern JS_PUBLIC_API(bool) -OrdinaryHasInstance(JSContext* cx, HandleObject objArg, HandleValue v, bool* bp); - -} // namespace JS - -extern JS_PUBLIC_API(void*) -JS_GetPrivate(JSObject* obj); - -extern JS_PUBLIC_API(void) -JS_SetPrivate(JSObject* obj, void* data); - -extern JS_PUBLIC_API(void*) -JS_GetInstancePrivate(JSContext* cx, JS::Handle<JSObject*> obj, const JSClass* clasp, - JS::CallArgs* args); - -extern JS_PUBLIC_API(JSObject*) -JS_GetConstructor(JSContext* cx, JS::Handle<JSObject*> proto); - -namespace JS { - -enum ZoneSpecifier { - FreshZone = 0, - SystemZone = 1 -}; - -/** - * CompartmentCreationOptions specifies options relevant to creating a new - * compartment, that are either immutable characteristics of that compartment - * or that are discarded after the compartment has been created. - * - * Access to these options on an existing compartment is read-only: if you - * need particular selections, make them before you create the compartment. - */ -class JS_PUBLIC_API(CompartmentCreationOptions) -{ - public: - CompartmentCreationOptions() - : addonId_(nullptr), - traceGlobal_(nullptr), - invisibleToDebugger_(false), - mergeable_(false), - preserveJitCode_(false), - cloneSingletons_(false), - sharedMemoryAndAtomics_(false), - secureContext_(false) - { - zone_.spec = JS::FreshZone; - } - - // A null add-on ID means that the compartment is not associated with an - // add-on. - JSAddonId* addonIdOrNull() const { return addonId_; } - CompartmentCreationOptions& setAddonId(JSAddonId* id) { - addonId_ = id; - return *this; - } - - JSTraceOp getTrace() const { - return traceGlobal_; - } - CompartmentCreationOptions& setTrace(JSTraceOp op) { - traceGlobal_ = op; - return *this; - } - - void* zonePointer() const { - MOZ_ASSERT(uintptr_t(zone_.pointer) > uintptr_t(JS::SystemZone)); - return zone_.pointer; - } - ZoneSpecifier zoneSpecifier() const { return zone_.spec; } - CompartmentCreationOptions& setZone(ZoneSpecifier spec); - CompartmentCreationOptions& setSameZoneAs(JSObject* obj); - - // Certain scopes (i.e. XBL compilation scopes) are implementation details - // of the embedding, and references to them should never leak out to script. - // This flag causes the this compartment to skip firing onNewGlobalObject - // and makes addDebuggee a no-op for this global. - bool invisibleToDebugger() const { return invisibleToDebugger_; } - CompartmentCreationOptions& setInvisibleToDebugger(bool flag) { - invisibleToDebugger_ = flag; - return *this; - } - - // Compartments used for off-thread compilation have their contents merged - // into a target compartment when the compilation is finished. This is only - // allowed if this flag is set. The invisibleToDebugger flag must also be - // set for such compartments. - bool mergeable() const { return mergeable_; } - CompartmentCreationOptions& setMergeable(bool flag) { - mergeable_ = flag; - return *this; - } - - // Determines whether this compartment should preserve JIT code on - // non-shrinking GCs. - bool preserveJitCode() const { return preserveJitCode_; } - CompartmentCreationOptions& setPreserveJitCode(bool flag) { - preserveJitCode_ = flag; - return *this; - } - - bool cloneSingletons() const { return cloneSingletons_; } - CompartmentCreationOptions& setCloneSingletons(bool flag) { - cloneSingletons_ = flag; - return *this; - } - - bool getSharedMemoryAndAtomicsEnabled() const; - CompartmentCreationOptions& setSharedMemoryAndAtomicsEnabled(bool flag); - - // This flag doesn't affect JS engine behavior. It is used by Gecko to - // mark whether content windows and workers are "Secure Context"s. See - // https://w3c.github.io/webappsec-secure-contexts/ - // https://bugzilla.mozilla.org/show_bug.cgi?id=1162772#c34 - bool secureContext() const { return secureContext_; } - CompartmentCreationOptions& setSecureContext(bool flag) { - secureContext_ = flag; - return *this; - } - - private: - JSAddonId* addonId_; - JSTraceOp traceGlobal_; - union { - ZoneSpecifier spec; - void* pointer; // js::Zone* is not exposed in the API. - } zone_; - bool invisibleToDebugger_; - bool mergeable_; - bool preserveJitCode_; - bool cloneSingletons_; - bool sharedMemoryAndAtomics_; - bool secureContext_; -}; - -/** - * CompartmentBehaviors specifies behaviors of a compartment that can be - * changed after the compartment's been created. - */ -class JS_PUBLIC_API(CompartmentBehaviors) -{ - public: - class Override { - public: - Override() : mode_(Default) {} - - bool get(bool defaultValue) const { - if (mode_ == Default) - return defaultValue; - return mode_ == ForceTrue; - } - - void set(bool overrideValue) { - mode_ = overrideValue ? ForceTrue : ForceFalse; - } - - void reset() { - mode_ = Default; - } - - private: - enum Mode { - Default, - ForceTrue, - ForceFalse - }; - - Mode mode_; - }; - - CompartmentBehaviors() - : version_(JSVERSION_UNKNOWN) - , discardSource_(false) - , disableLazyParsing_(false) - , singletonsAsTemplates_(true) - { - } - - JSVersion version() const { return version_; } - CompartmentBehaviors& setVersion(JSVersion aVersion) { - MOZ_ASSERT(aVersion != JSVERSION_UNKNOWN); - version_ = aVersion; - return *this; - } - - // For certain globals, we know enough about the code that will run in them - // that we can discard script source entirely. - bool discardSource() const { return discardSource_; } - CompartmentBehaviors& setDiscardSource(bool flag) { - discardSource_ = flag; - return *this; - } - - bool disableLazyParsing() const { return disableLazyParsing_; } - CompartmentBehaviors& setDisableLazyParsing(bool flag) { - disableLazyParsing_ = flag; - return *this; - } - - bool extraWarnings(JSContext* cx) const; - Override& extraWarningsOverride() { return extraWarningsOverride_; } - - bool getSingletonsAsTemplates() const { - return singletonsAsTemplates_; - } - CompartmentBehaviors& setSingletonsAsValues() { - singletonsAsTemplates_ = false; - return *this; - } - - private: - JSVersion version_; - bool discardSource_; - bool disableLazyParsing_; - Override extraWarningsOverride_; - - // To XDR singletons, we need to ensure that all singletons are all used as - // templates, by making JSOP_OBJECT return a clone of the JSScript - // singleton, instead of returning the value which is baked in the JSScript. - bool singletonsAsTemplates_; -}; - -/** - * CompartmentOptions specifies compartment characteristics: both those that - * can't be changed on a compartment once it's been created - * (CompartmentCreationOptions), and those that can be changed on an existing - * compartment (CompartmentBehaviors). - */ -class JS_PUBLIC_API(CompartmentOptions) -{ - public: - explicit CompartmentOptions() - : creationOptions_(), - behaviors_() - {} - - CompartmentOptions(const CompartmentCreationOptions& compartmentCreation, - const CompartmentBehaviors& compartmentBehaviors) - : creationOptions_(compartmentCreation), - behaviors_(compartmentBehaviors) - {} - - // CompartmentCreationOptions specify fundamental compartment - // characteristics that must be specified when the compartment is created, - // that can't be changed after the compartment is created. - CompartmentCreationOptions& creationOptions() { - return creationOptions_; - } - const CompartmentCreationOptions& creationOptions() const { - return creationOptions_; - } - - // CompartmentBehaviors specify compartment characteristics that can be - // changed after the compartment is created. - CompartmentBehaviors& behaviors() { - return behaviors_; - } - const CompartmentBehaviors& behaviors() const { - return behaviors_; - } - - private: - CompartmentCreationOptions creationOptions_; - CompartmentBehaviors behaviors_; -}; - -JS_PUBLIC_API(const CompartmentCreationOptions&) -CompartmentCreationOptionsRef(JSCompartment* compartment); - -JS_PUBLIC_API(const CompartmentCreationOptions&) -CompartmentCreationOptionsRef(JSObject* obj); - -JS_PUBLIC_API(const CompartmentCreationOptions&) -CompartmentCreationOptionsRef(JSContext* cx); - -JS_PUBLIC_API(CompartmentBehaviors&) -CompartmentBehaviorsRef(JSCompartment* compartment); - -JS_PUBLIC_API(CompartmentBehaviors&) -CompartmentBehaviorsRef(JSObject* obj); - -JS_PUBLIC_API(CompartmentBehaviors&) -CompartmentBehaviorsRef(JSContext* cx); - -/** - * During global creation, we fire notifications to callbacks registered - * via the Debugger API. These callbacks are arbitrary script, and can touch - * the global in arbitrary ways. When that happens, the global should not be - * in a half-baked state. But this creates a problem for consumers that need - * to set slots on the global to put it in a consistent state. - * - * This API provides a way for consumers to set slots atomically (immediately - * after the global is created), before any debugger hooks are fired. It's - * unfortunately on the clunky side, but that's the way the cookie crumbles. - * - * If callers have no additional state on the global to set up, they may pass - * |FireOnNewGlobalHook| to JS_NewGlobalObject, which causes that function to - * fire the hook as its final act before returning. Otherwise, callers should - * pass |DontFireOnNewGlobalHook|, which means that they are responsible for - * invoking JS_FireOnNewGlobalObject upon successfully creating the global. If - * an error occurs and the operation aborts, callers should skip firing the - * hook. But otherwise, callers must take care to fire the hook exactly once - * before compiling any script in the global's scope (we have assertions in - * place to enforce this). This lets us be sure that debugger clients never miss - * breakpoints. - */ -enum OnNewGlobalHookOption { - FireOnNewGlobalHook, - DontFireOnNewGlobalHook -}; - -} /* namespace JS */ - -extern JS_PUBLIC_API(JSObject*) -JS_NewGlobalObject(JSContext* cx, const JSClass* clasp, JSPrincipals* principals, - JS::OnNewGlobalHookOption hookOption, - const JS::CompartmentOptions& options); -/** - * Spidermonkey does not have a good way of keeping track of what compartments should be marked on - * their own. We can mark the roots unconditionally, but marking GC things only relevant in live - * compartments is hard. To mitigate this, we create a static trace hook, installed on each global - * object, from which we can be sure the compartment is relevant, and mark it. - * - * It is still possible to specify custom trace hooks for global object classes. They can be - * provided via the CompartmentOptions passed to JS_NewGlobalObject. - */ -extern JS_PUBLIC_API(void) -JS_GlobalObjectTraceHook(JSTracer* trc, JSObject* global); - -extern JS_PUBLIC_API(void) -JS_FireOnNewGlobalObject(JSContext* cx, JS::HandleObject global); - -extern JS_PUBLIC_API(JSObject*) -JS_NewObject(JSContext* cx, const JSClass* clasp); - -extern JS_PUBLIC_API(bool) -JS_IsNative(JSObject* obj); - -/** - * Unlike JS_NewObject, JS_NewObjectWithGivenProto does not compute a default - * proto. If proto is nullptr, the JS object will have `null` as [[Prototype]]. - */ -extern JS_PUBLIC_API(JSObject*) -JS_NewObjectWithGivenProto(JSContext* cx, const JSClass* clasp, JS::Handle<JSObject*> proto); - -/** Creates a new plain object, like `new Object()`, with Object.prototype as [[Prototype]]. */ -extern JS_PUBLIC_API(JSObject*) -JS_NewPlainObject(JSContext* cx); - -/** - * Freeze obj, and all objects it refers to, recursively. This will not recurse - * through non-extensible objects, on the assumption that those are already - * deep-frozen. - */ -extern JS_PUBLIC_API(bool) -JS_DeepFreezeObject(JSContext* cx, JS::Handle<JSObject*> obj); - -/** - * Freezes an object; see ES5's Object.freeze(obj) method. - */ -extern JS_PUBLIC_API(bool) -JS_FreezeObject(JSContext* cx, JS::Handle<JSObject*> obj); - - -/*** Property descriptors ************************************************************************/ - -namespace JS { - -struct JS_PUBLIC_API(PropertyDescriptor) { - JSObject* obj; - unsigned attrs; - JSGetterOp getter; - JSSetterOp setter; - JS::Value value; - - PropertyDescriptor() - : obj(nullptr), attrs(0), getter(nullptr), setter(nullptr), value(JS::UndefinedValue()) - {} - - static void trace(PropertyDescriptor* self, JSTracer* trc) { self->trace(trc); } - void trace(JSTracer* trc); -}; - -template <typename Outer> -class PropertyDescriptorOperations -{ - const PropertyDescriptor& desc() const { return static_cast<const Outer*>(this)->get(); } - - bool has(unsigned bit) const { - MOZ_ASSERT(bit != 0); - MOZ_ASSERT((bit & (bit - 1)) == 0); // only a single bit - return (desc().attrs & bit) != 0; - } - - bool hasAny(unsigned bits) const { - return (desc().attrs & bits) != 0; - } - - bool hasAll(unsigned bits) const { - return (desc().attrs & bits) == bits; - } - - // Non-API attributes bit used internally for arguments objects. - enum { SHADOWABLE = JSPROP_INTERNAL_USE_BIT }; - - public: - // Descriptors with JSGetterOp/JSSetterOp are considered data - // descriptors. It's complicated. - bool isAccessorDescriptor() const { return hasAny(JSPROP_GETTER | JSPROP_SETTER); } - bool isGenericDescriptor() const { - return (desc().attrs& - (JSPROP_GETTER | JSPROP_SETTER | JSPROP_IGNORE_READONLY | JSPROP_IGNORE_VALUE)) == - (JSPROP_IGNORE_READONLY | JSPROP_IGNORE_VALUE); - } - bool isDataDescriptor() const { return !isAccessorDescriptor() && !isGenericDescriptor(); } - - bool hasConfigurable() const { return !has(JSPROP_IGNORE_PERMANENT); } - bool configurable() const { MOZ_ASSERT(hasConfigurable()); return !has(JSPROP_PERMANENT); } - - bool hasEnumerable() const { return !has(JSPROP_IGNORE_ENUMERATE); } - bool enumerable() const { MOZ_ASSERT(hasEnumerable()); return has(JSPROP_ENUMERATE); } - - bool hasValue() const { return !isAccessorDescriptor() && !has(JSPROP_IGNORE_VALUE); } - JS::HandleValue value() const { - return JS::HandleValue::fromMarkedLocation(&desc().value); - } - - bool hasWritable() const { return !isAccessorDescriptor() && !has(JSPROP_IGNORE_READONLY); } - bool writable() const { MOZ_ASSERT(hasWritable()); return !has(JSPROP_READONLY); } - - bool hasGetterObject() const { return has(JSPROP_GETTER); } - JS::HandleObject getterObject() const { - MOZ_ASSERT(hasGetterObject()); - return JS::HandleObject::fromMarkedLocation( - reinterpret_cast<JSObject* const*>(&desc().getter)); - } - bool hasSetterObject() const { return has(JSPROP_SETTER); } - JS::HandleObject setterObject() const { - MOZ_ASSERT(hasSetterObject()); - return JS::HandleObject::fromMarkedLocation( - reinterpret_cast<JSObject* const*>(&desc().setter)); - } - - bool hasGetterOrSetter() const { return desc().getter || desc().setter; } - bool isShared() const { return has(JSPROP_SHARED); } - - JS::HandleObject object() const { - return JS::HandleObject::fromMarkedLocation(&desc().obj); - } - unsigned attributes() const { return desc().attrs; } - JSGetterOp getter() const { return desc().getter; } - JSSetterOp setter() const { return desc().setter; } - - void assertValid() const { -#ifdef DEBUG - MOZ_ASSERT((attributes() & ~(JSPROP_ENUMERATE | JSPROP_IGNORE_ENUMERATE | - JSPROP_PERMANENT | JSPROP_IGNORE_PERMANENT | - JSPROP_READONLY | JSPROP_IGNORE_READONLY | - JSPROP_IGNORE_VALUE | - JSPROP_GETTER | - JSPROP_SETTER | - JSPROP_SHARED | - JSPROP_REDEFINE_NONCONFIGURABLE | - JSPROP_RESOLVING | - SHADOWABLE)) == 0); - MOZ_ASSERT(!hasAll(JSPROP_IGNORE_ENUMERATE | JSPROP_ENUMERATE)); - MOZ_ASSERT(!hasAll(JSPROP_IGNORE_PERMANENT | JSPROP_PERMANENT)); - if (isAccessorDescriptor()) { - MOZ_ASSERT(has(JSPROP_SHARED)); - MOZ_ASSERT(!has(JSPROP_READONLY)); - MOZ_ASSERT(!has(JSPROP_IGNORE_READONLY)); - MOZ_ASSERT(!has(JSPROP_IGNORE_VALUE)); - MOZ_ASSERT(!has(SHADOWABLE)); - MOZ_ASSERT(value().isUndefined()); - MOZ_ASSERT_IF(!has(JSPROP_GETTER), !getter()); - MOZ_ASSERT_IF(!has(JSPROP_SETTER), !setter()); - } else { - MOZ_ASSERT(!hasAll(JSPROP_IGNORE_READONLY | JSPROP_READONLY)); - MOZ_ASSERT_IF(has(JSPROP_IGNORE_VALUE), value().isUndefined()); - } - MOZ_ASSERT(getter() != JS_PropertyStub); - MOZ_ASSERT(setter() != JS_StrictPropertyStub); - - MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_IGNORE_ENUMERATE)); - MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_IGNORE_PERMANENT)); - MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_IGNORE_READONLY)); - MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_IGNORE_VALUE)); - MOZ_ASSERT_IF(has(JSPROP_RESOLVING), !has(JSPROP_REDEFINE_NONCONFIGURABLE)); -#endif - } - - void assertComplete() const { -#ifdef DEBUG - assertValid(); - MOZ_ASSERT((attributes() & ~(JSPROP_ENUMERATE | - JSPROP_PERMANENT | - JSPROP_READONLY | - JSPROP_GETTER | - JSPROP_SETTER | - JSPROP_SHARED | - JSPROP_REDEFINE_NONCONFIGURABLE | - JSPROP_RESOLVING | - SHADOWABLE)) == 0); - MOZ_ASSERT_IF(isAccessorDescriptor(), has(JSPROP_GETTER) && has(JSPROP_SETTER)); -#endif - } - - void assertCompleteIfFound() const { -#ifdef DEBUG - if (object()) - assertComplete(); -#endif - } -}; - -template <typename Outer> -class MutablePropertyDescriptorOperations : public PropertyDescriptorOperations<Outer> -{ - PropertyDescriptor& desc() { return static_cast<Outer*>(this)->get(); } - - public: - void clear() { - object().set(nullptr); - setAttributes(0); - setGetter(nullptr); - setSetter(nullptr); - value().setUndefined(); - } - - void initFields(HandleObject obj, HandleValue v, unsigned attrs, - JSGetterOp getterOp, JSSetterOp setterOp) { - MOZ_ASSERT(getterOp != JS_PropertyStub); - MOZ_ASSERT(setterOp != JS_StrictPropertyStub); - - object().set(obj); - value().set(v); - setAttributes(attrs); - setGetter(getterOp); - setSetter(setterOp); - } - - void assign(PropertyDescriptor& other) { - object().set(other.obj); - setAttributes(other.attrs); - setGetter(other.getter); - setSetter(other.setter); - value().set(other.value); - } - - void setDataDescriptor(HandleValue v, unsigned attrs) { - MOZ_ASSERT((attrs & ~(JSPROP_ENUMERATE | - JSPROP_PERMANENT | - JSPROP_READONLY | - JSPROP_IGNORE_ENUMERATE | - JSPROP_IGNORE_PERMANENT | - JSPROP_IGNORE_READONLY)) == 0); - object().set(nullptr); - setAttributes(attrs); - setGetter(nullptr); - setSetter(nullptr); - value().set(v); - } - - JS::MutableHandleObject object() { - return JS::MutableHandleObject::fromMarkedLocation(&desc().obj); - } - unsigned& attributesRef() { return desc().attrs; } - JSGetterOp& getter() { return desc().getter; } - JSSetterOp& setter() { return desc().setter; } - JS::MutableHandleValue value() { - return JS::MutableHandleValue::fromMarkedLocation(&desc().value); - } - void setValue(JS::HandleValue v) { - MOZ_ASSERT(!(desc().attrs & (JSPROP_GETTER | JSPROP_SETTER))); - attributesRef() &= ~JSPROP_IGNORE_VALUE; - value().set(v); - } - - void setConfigurable(bool configurable) { - setAttributes((desc().attrs & ~(JSPROP_IGNORE_PERMANENT | JSPROP_PERMANENT)) | - (configurable ? 0 : JSPROP_PERMANENT)); - } - void setEnumerable(bool enumerable) { - setAttributes((desc().attrs & ~(JSPROP_IGNORE_ENUMERATE | JSPROP_ENUMERATE)) | - (enumerable ? JSPROP_ENUMERATE : 0)); - } - void setWritable(bool writable) { - MOZ_ASSERT(!(desc().attrs & (JSPROP_GETTER | JSPROP_SETTER))); - setAttributes((desc().attrs & ~(JSPROP_IGNORE_READONLY | JSPROP_READONLY)) | - (writable ? 0 : JSPROP_READONLY)); - } - void setAttributes(unsigned attrs) { desc().attrs = attrs; } - - void setGetter(JSGetterOp op) { - MOZ_ASSERT(op != JS_PropertyStub); - desc().getter = op; - } - void setSetter(JSSetterOp op) { - MOZ_ASSERT(op != JS_StrictPropertyStub); - desc().setter = op; - } - void setGetterObject(JSObject* obj) { - desc().getter = reinterpret_cast<JSGetterOp>(obj); - desc().attrs &= ~(JSPROP_IGNORE_VALUE | JSPROP_IGNORE_READONLY | JSPROP_READONLY); - desc().attrs |= JSPROP_GETTER | JSPROP_SHARED; - } - void setSetterObject(JSObject* obj) { - desc().setter = reinterpret_cast<JSSetterOp>(obj); - desc().attrs &= ~(JSPROP_IGNORE_VALUE | JSPROP_IGNORE_READONLY | JSPROP_READONLY); - desc().attrs |= JSPROP_SETTER | JSPROP_SHARED; - } - - JS::MutableHandleObject getterObject() { - MOZ_ASSERT(this->hasGetterObject()); - return JS::MutableHandleObject::fromMarkedLocation( - reinterpret_cast<JSObject**>(&desc().getter)); - } - JS::MutableHandleObject setterObject() { - MOZ_ASSERT(this->hasSetterObject()); - return JS::MutableHandleObject::fromMarkedLocation( - reinterpret_cast<JSObject**>(&desc().setter)); - } -}; - -} /* namespace JS */ - -namespace js { - -template <> -class RootedBase<JS::PropertyDescriptor> - : public JS::MutablePropertyDescriptorOperations<JS::Rooted<JS::PropertyDescriptor>> -{}; - -template <> -class HandleBase<JS::PropertyDescriptor> - : public JS::PropertyDescriptorOperations<JS::Handle<JS::PropertyDescriptor>> -{}; - -template <> -class MutableHandleBase<JS::PropertyDescriptor> - : public JS::MutablePropertyDescriptorOperations<JS::MutableHandle<JS::PropertyDescriptor>> -{}; - -} /* namespace js */ - -namespace JS { - -extern JS_PUBLIC_API(bool) -ObjectToCompletePropertyDescriptor(JSContext* cx, - JS::HandleObject obj, - JS::HandleValue descriptor, - JS::MutableHandle<PropertyDescriptor> desc); - -/* - * ES6 draft rev 32 (2015 Feb 2) 6.2.4.4 FromPropertyDescriptor(Desc). - * - * If desc.object() is null, then vp is set to undefined. - */ -extern JS_PUBLIC_API(bool) -FromPropertyDescriptor(JSContext* cx, - JS::Handle<JS::PropertyDescriptor> desc, - JS::MutableHandleValue vp); - -} // namespace JS - - -/*** Standard internal methods ******************************************************************** - * - * The functions below are the fundamental operations on objects. - * - * ES6 specifies 14 internal methods that define how objects behave. The - * standard is actually quite good on this topic, though you may have to read - * it a few times. See ES6 sections 6.1.7.2 and 6.1.7.3. - * - * When 'obj' is an ordinary object, these functions have boring standard - * behavior as specified by ES6 section 9.1; see the section about internal - * methods in js/src/vm/NativeObject.h. - * - * Proxies override the behavior of internal methods. So when 'obj' is a proxy, - * any one of the functions below could do just about anything. See - * js/public/Proxy.h. - */ - -/** - * Get the prototype of obj, storing it in result. - * - * Implements: ES6 [[GetPrototypeOf]] internal method. - */ -extern JS_PUBLIC_API(bool) -JS_GetPrototype(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject result); - -/** - * If |obj| (underneath any functionally-transparent wrapper proxies) has as - * its [[GetPrototypeOf]] trap the ordinary [[GetPrototypeOf]] behavior defined - * for ordinary objects, set |*isOrdinary = true| and store |obj|'s prototype - * in |result|. Otherwise set |*isOrdinary = false|. In case of error, both - * outparams have unspecified value. - */ -extern JS_PUBLIC_API(bool) -JS_GetPrototypeIfOrdinary(JSContext* cx, JS::HandleObject obj, bool* isOrdinary, - JS::MutableHandleObject result); - -/** - * Change the prototype of obj. - * - * Implements: ES6 [[SetPrototypeOf]] internal method. - * - * In cases where ES6 [[SetPrototypeOf]] returns false without an exception, - * JS_SetPrototype throws a TypeError and returns false. - * - * Performance warning: JS_SetPrototype is very bad for performance. It may - * cause compiled jit-code to be invalidated. It also causes not only obj but - * all other objects in the same "group" as obj to be permanently deoptimized. - * It's better to create the object with the right prototype from the start. - */ -extern JS_PUBLIC_API(bool) -JS_SetPrototype(JSContext* cx, JS::HandleObject obj, JS::HandleObject proto); - -/** - * Determine whether obj is extensible. Extensible objects can have new - * properties defined on them. Inextensible objects can't, and their - * [[Prototype]] slot is fixed as well. - * - * Implements: ES6 [[IsExtensible]] internal method. - */ -extern JS_PUBLIC_API(bool) -JS_IsExtensible(JSContext* cx, JS::HandleObject obj, bool* extensible); - -/** - * Attempt to make |obj| non-extensible. - * - * Not all failures are treated as errors. See the comment on - * JS::ObjectOpResult in js/public/Class.h. - * - * Implements: ES6 [[PreventExtensions]] internal method. - */ -extern JS_PUBLIC_API(bool) -JS_PreventExtensions(JSContext* cx, JS::HandleObject obj, JS::ObjectOpResult& result); - -/** - * Attempt to make the [[Prototype]] of |obj| immutable, such that any attempt - * to modify it will fail. If an error occurs during the attempt, return false - * (with a pending exception set, depending upon the nature of the error). If - * no error occurs, return true with |*succeeded| set to indicate whether the - * attempt successfully made the [[Prototype]] immutable. - * - * This is a nonstandard internal method. - */ -extern JS_PUBLIC_API(bool) -JS_SetImmutablePrototype(JSContext* cx, JS::HandleObject obj, bool* succeeded); - -/** - * Get a description of one of obj's own properties. If no such property exists - * on obj, return true with desc.object() set to null. - * - * Implements: ES6 [[GetOwnProperty]] internal method. - */ -extern JS_PUBLIC_API(bool) -JS_GetOwnPropertyDescriptorById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandle<JS::PropertyDescriptor> desc); - -extern JS_PUBLIC_API(bool) -JS_GetOwnPropertyDescriptor(JSContext* cx, JS::HandleObject obj, const char* name, - JS::MutableHandle<JS::PropertyDescriptor> desc); - -extern JS_PUBLIC_API(bool) -JS_GetOwnUCPropertyDescriptor(JSContext* cx, JS::HandleObject obj, const char16_t* name, - JS::MutableHandle<JS::PropertyDescriptor> desc); - -/** - * Like JS_GetOwnPropertyDescriptorById, but also searches the prototype chain - * if no own property is found directly on obj. The object on which the - * property is found is returned in desc.object(). If the property is not found - * on the prototype chain, this returns true with desc.object() set to null. - */ -extern JS_PUBLIC_API(bool) -JS_GetPropertyDescriptorById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandle<JS::PropertyDescriptor> desc); - -extern JS_PUBLIC_API(bool) -JS_GetPropertyDescriptor(JSContext* cx, JS::HandleObject obj, const char* name, - JS::MutableHandle<JS::PropertyDescriptor> desc); - -/** - * Define a property on obj. - * - * This function uses JS::ObjectOpResult to indicate conditions that ES6 - * specifies as non-error failures. This is inconvenient at best, so use this - * function only if you are implementing a proxy handler's defineProperty() - * method. For all other purposes, use one of the many DefineProperty functions - * below that throw an exception in all failure cases. - * - * Implements: ES6 [[DefineOwnProperty]] internal method. - */ -extern JS_PUBLIC_API(bool) -JS_DefinePropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::Handle<JS::PropertyDescriptor> desc, - JS::ObjectOpResult& result); - -/** - * Define a property on obj, throwing a TypeError if the attempt fails. - * This is the C++ equivalent of `Object.defineProperty(obj, id, desc)`. - */ -extern JS_PUBLIC_API(bool) -JS_DefinePropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::Handle<JS::PropertyDescriptor> desc); - -extern JS_PUBLIC_API(bool) -JS_DefinePropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefinePropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefinePropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleString value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefinePropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, int32_t value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefinePropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, uint32_t value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefinePropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, double value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineProperty(JSContext* cx, JS::HandleObject obj, const char* name, JS::HandleValue value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineProperty(JSContext* cx, JS::HandleObject obj, const char* name, JS::HandleObject value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineProperty(JSContext* cx, JS::HandleObject obj, const char* name, JS::HandleString value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineProperty(JSContext* cx, JS::HandleObject obj, const char* name, int32_t value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineProperty(JSContext* cx, JS::HandleObject obj, const char* name, uint32_t value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineProperty(JSContext* cx, JS::HandleObject obj, const char* name, double value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - JS::Handle<JS::PropertyDescriptor> desc, - JS::ObjectOpResult& result); - -extern JS_PUBLIC_API(bool) -JS_DefineUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - JS::Handle<JS::PropertyDescriptor> desc); - -extern JS_PUBLIC_API(bool) -JS_DefineUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - JS::HandleValue value, unsigned attrs, - JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - JS::HandleObject value, unsigned attrs, - JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - JS::HandleString value, unsigned attrs, - JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - int32_t value, unsigned attrs, - JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - uint32_t value, unsigned attrs, - JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - double value, unsigned attrs, - JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineElement(JSContext* cx, JS::HandleObject obj, uint32_t index, JS::HandleValue value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineElement(JSContext* cx, JS::HandleObject obj, uint32_t index, JS::HandleObject value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineElement(JSContext* cx, JS::HandleObject obj, uint32_t index, JS::HandleString value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineElement(JSContext* cx, JS::HandleObject obj, uint32_t index, int32_t value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineElement(JSContext* cx, JS::HandleObject obj, uint32_t index, uint32_t value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -extern JS_PUBLIC_API(bool) -JS_DefineElement(JSContext* cx, JS::HandleObject obj, uint32_t index, double value, - unsigned attrs, JSNative getter = nullptr, JSNative setter = nullptr); - -/** - * Compute the expression `id in obj`. - * - * If obj has an own or inherited property obj[id], set *foundp = true and - * return true. If not, set *foundp = false and return true. On error, return - * false with an exception pending. - * - * Implements: ES6 [[Has]] internal method. - */ -extern JS_PUBLIC_API(bool) -JS_HasPropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* foundp); - -extern JS_PUBLIC_API(bool) -JS_HasProperty(JSContext* cx, JS::HandleObject obj, const char* name, bool* foundp); - -extern JS_PUBLIC_API(bool) -JS_HasUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - bool* vp); - -extern JS_PUBLIC_API(bool) -JS_HasElement(JSContext* cx, JS::HandleObject obj, uint32_t index, bool* foundp); - -/** - * Determine whether obj has an own property with the key `id`. - * - * Implements: ES6 7.3.11 HasOwnProperty(O, P). - */ -extern JS_PUBLIC_API(bool) -JS_HasOwnPropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* foundp); - -extern JS_PUBLIC_API(bool) -JS_HasOwnProperty(JSContext* cx, JS::HandleObject obj, const char* name, bool* foundp); - -/** - * Get the value of the property `obj[id]`, or undefined if no such property - * exists. This is the C++ equivalent of `vp = Reflect.get(obj, id, receiver)`. - * - * Most callers don't need the `receiver` argument. Consider using - * JS_GetProperty instead. (But if you're implementing a proxy handler's set() - * method, it's often correct to call this function and pass the receiver - * through.) - * - * Implements: ES6 [[Get]] internal method. - */ -extern JS_PUBLIC_API(bool) -JS_ForwardGetPropertyTo(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::HandleValue receiver, JS::MutableHandleValue vp); - -extern JS_PUBLIC_API(bool) -JS_ForwardGetElementTo(JSContext* cx, JS::HandleObject obj, uint32_t index, - JS::HandleObject receiver, JS::MutableHandleValue vp); - -/** - * Get the value of the property `obj[id]`, or undefined if no such property - * exists. The result is stored in vp. - * - * Implements: ES6 7.3.1 Get(O, P). - */ -extern JS_PUBLIC_API(bool) -JS_GetPropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandleValue vp); - -extern JS_PUBLIC_API(bool) -JS_GetProperty(JSContext* cx, JS::HandleObject obj, const char* name, JS::MutableHandleValue vp); - -extern JS_PUBLIC_API(bool) -JS_GetUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - JS::MutableHandleValue vp); - -extern JS_PUBLIC_API(bool) -JS_GetElement(JSContext* cx, JS::HandleObject obj, uint32_t index, JS::MutableHandleValue vp); - -/** - * Perform the same property assignment as `Reflect.set(obj, id, v, receiver)`. - * - * This function has a `receiver` argument that most callers don't need. - * Consider using JS_SetProperty instead. - * - * Implements: ES6 [[Set]] internal method. - */ -extern JS_PUBLIC_API(bool) -JS_ForwardSetPropertyTo(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue v, - JS::HandleValue receiver, JS::ObjectOpResult& result); - -/** - * Perform the assignment `obj[id] = v`. - * - * This function performs non-strict assignment, so if the property is - * read-only, nothing happens and no error is thrown. - */ -extern JS_PUBLIC_API(bool) -JS_SetPropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue v); - -extern JS_PUBLIC_API(bool) -JS_SetProperty(JSContext* cx, JS::HandleObject obj, const char* name, JS::HandleValue v); - -extern JS_PUBLIC_API(bool) -JS_SetUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - JS::HandleValue v); - -extern JS_PUBLIC_API(bool) -JS_SetElement(JSContext* cx, JS::HandleObject obj, uint32_t index, JS::HandleValue v); - -extern JS_PUBLIC_API(bool) -JS_SetElement(JSContext* cx, JS::HandleObject obj, uint32_t index, JS::HandleObject v); - -extern JS_PUBLIC_API(bool) -JS_SetElement(JSContext* cx, JS::HandleObject obj, uint32_t index, JS::HandleString v); - -extern JS_PUBLIC_API(bool) -JS_SetElement(JSContext* cx, JS::HandleObject obj, uint32_t index, int32_t v); - -extern JS_PUBLIC_API(bool) -JS_SetElement(JSContext* cx, JS::HandleObject obj, uint32_t index, uint32_t v); - -extern JS_PUBLIC_API(bool) -JS_SetElement(JSContext* cx, JS::HandleObject obj, uint32_t index, double v); - -/** - * Delete a property. This is the C++ equivalent of - * `result = Reflect.deleteProperty(obj, id)`. - * - * This function has a `result` out parameter that most callers don't need. - * Unless you can pass through an ObjectOpResult provided by your caller, it's - * probably best to use the JS_DeletePropertyById signature with just 3 - * arguments. - * - * Implements: ES6 [[Delete]] internal method. - */ -extern JS_PUBLIC_API(bool) -JS_DeletePropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::ObjectOpResult& result); - -extern JS_PUBLIC_API(bool) -JS_DeleteProperty(JSContext* cx, JS::HandleObject obj, const char* name, - JS::ObjectOpResult& result); - -extern JS_PUBLIC_API(bool) -JS_DeleteUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, size_t namelen, - JS::ObjectOpResult& result); - -extern JS_PUBLIC_API(bool) -JS_DeleteElement(JSContext* cx, JS::HandleObject obj, uint32_t index, JS::ObjectOpResult& result); - -/** - * Delete a property, ignoring strict failures. This is the C++ equivalent of - * the JS `delete obj[id]` in non-strict mode code. - */ -extern JS_PUBLIC_API(bool) -JS_DeletePropertyById(JSContext* cx, JS::HandleObject obj, jsid id); - -extern JS_PUBLIC_API(bool) -JS_DeleteProperty(JSContext* cx, JS::HandleObject obj, const char* name); - -extern JS_PUBLIC_API(bool) -JS_DeleteElement(JSContext* cx, JS::HandleObject obj, uint32_t index); - -/** - * Get an array of the non-symbol enumerable properties of obj. - * This function is roughly equivalent to: - * - * var result = []; - * for (key in obj) - * result.push(key); - * return result; - * - * This is the closest thing we currently have to the ES6 [[Enumerate]] - * internal method. - * - * The array of ids returned by JS_Enumerate must be rooted to protect its - * contents from garbage collection. Use JS::Rooted<JS::IdVector>. - */ -extern JS_PUBLIC_API(bool) -JS_Enumerate(JSContext* cx, JS::HandleObject obj, JS::MutableHandle<JS::IdVector> props); - -/* - * API for determining callability and constructability. [[Call]] and - * [[Construct]] are internal methods that aren't present on all objects, so it - * is useful to ask if they are there or not. The standard itself asks these - * questions routinely. - */ -namespace JS { - -/** - * Return true if the given object is callable. In ES6 terms, an object is - * callable if it has a [[Call]] internal method. - * - * Implements: ES6 7.2.3 IsCallable(argument). - * - * Functions are callable. A scripted proxy or wrapper is callable if its - * target is callable. Most other objects aren't callable. - */ -extern JS_PUBLIC_API(bool) -IsCallable(JSObject* obj); - -/** - * Return true if the given object is a constructor. In ES6 terms, an object is - * a constructor if it has a [[Construct]] internal method. The expression - * `new obj()` throws a TypeError if obj is not a constructor. - * - * Implements: ES6 7.2.4 IsConstructor(argument). - * - * JS functions and classes are constructors. Arrow functions and most builtin - * functions are not. A scripted proxy or wrapper is a constructor if its - * target is a constructor. - */ -extern JS_PUBLIC_API(bool) -IsConstructor(JSObject* obj); - -} /* namespace JS */ - -/** - * Call a function, passing a this-value and arguments. This is the C++ - * equivalent of `rval = Reflect.apply(fun, obj, args)`. - * - * Implements: ES6 7.3.12 Call(F, V, [argumentsList]). - * Use this function to invoke the [[Call]] internal method. - */ -extern JS_PUBLIC_API(bool) -JS_CallFunctionValue(JSContext* cx, JS::HandleObject obj, JS::HandleValue fval, - const JS::HandleValueArray& args, JS::MutableHandleValue rval); - -extern JS_PUBLIC_API(bool) -JS_CallFunction(JSContext* cx, JS::HandleObject obj, JS::HandleFunction fun, - const JS::HandleValueArray& args, JS::MutableHandleValue rval); - -/** - * Perform the method call `rval = obj[name](args)`. - */ -extern JS_PUBLIC_API(bool) -JS_CallFunctionName(JSContext* cx, JS::HandleObject obj, const char* name, - const JS::HandleValueArray& args, JS::MutableHandleValue rval); - -namespace JS { - -static inline bool -Call(JSContext* cx, JS::HandleObject thisObj, JS::HandleFunction fun, - const JS::HandleValueArray& args, MutableHandleValue rval) -{ - return !!JS_CallFunction(cx, thisObj, fun, args, rval); -} - -static inline bool -Call(JSContext* cx, JS::HandleObject thisObj, JS::HandleValue fun, const JS::HandleValueArray& args, - MutableHandleValue rval) -{ - return !!JS_CallFunctionValue(cx, thisObj, fun, args, rval); -} - -static inline bool -Call(JSContext* cx, JS::HandleObject thisObj, const char* name, const JS::HandleValueArray& args, - MutableHandleValue rval) -{ - return !!JS_CallFunctionName(cx, thisObj, name, args, rval); -} - -extern JS_PUBLIC_API(bool) -Call(JSContext* cx, JS::HandleValue thisv, JS::HandleValue fun, const JS::HandleValueArray& args, - MutableHandleValue rval); - -static inline bool -Call(JSContext* cx, JS::HandleValue thisv, JS::HandleObject funObj, const JS::HandleValueArray& args, - MutableHandleValue rval) -{ - MOZ_ASSERT(funObj); - JS::RootedValue fun(cx, JS::ObjectValue(*funObj)); - return Call(cx, thisv, fun, args, rval); -} - -/** - * Invoke a constructor. This is the C++ equivalent of - * `rval = Reflect.construct(fun, args, newTarget)`. - * - * JS::Construct() takes a `newTarget` argument that most callers don't need. - * Consider using the four-argument Construct signature instead. (But if you're - * implementing a subclass or a proxy handler's construct() method, this is the - * right function to call.) - * - * Implements: ES6 7.3.13 Construct(F, [argumentsList], [newTarget]). - * Use this function to invoke the [[Construct]] internal method. - */ -extern JS_PUBLIC_API(bool) -Construct(JSContext* cx, JS::HandleValue fun, HandleObject newTarget, - const JS::HandleValueArray &args, MutableHandleObject objp); - -/** - * Invoke a constructor. This is the C++ equivalent of - * `rval = new fun(...args)`. - * - * Implements: ES6 7.3.13 Construct(F, [argumentsList], [newTarget]), when - * newTarget is omitted. - */ -extern JS_PUBLIC_API(bool) -Construct(JSContext* cx, JS::HandleValue fun, const JS::HandleValueArray& args, - MutableHandleObject objp); - -} /* namespace JS */ - -/** - * Invoke a constructor, like the JS expression `new ctor(...args)`. Returns - * the new object, or null on error. - */ -extern JS_PUBLIC_API(JSObject*) -JS_New(JSContext* cx, JS::HandleObject ctor, const JS::HandleValueArray& args); - - -/*** Other property-defining functions ***********************************************************/ - -extern JS_PUBLIC_API(JSObject*) -JS_DefineObject(JSContext* cx, JS::HandleObject obj, const char* name, - const JSClass* clasp = nullptr, unsigned attrs = 0); - -extern JS_PUBLIC_API(bool) -JS_DefineConstDoubles(JSContext* cx, JS::HandleObject obj, const JSConstDoubleSpec* cds); - -extern JS_PUBLIC_API(bool) -JS_DefineConstIntegers(JSContext* cx, JS::HandleObject obj, const JSConstIntegerSpec* cis); - -extern JS_PUBLIC_API(bool) -JS_DefineProperties(JSContext* cx, JS::HandleObject obj, const JSPropertySpec* ps); - - -/* * */ - -extern JS_PUBLIC_API(bool) -JS_AlreadyHasOwnPropertyById(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - bool* foundp); - -extern JS_PUBLIC_API(bool) -JS_AlreadyHasOwnProperty(JSContext* cx, JS::HandleObject obj, const char* name, - bool* foundp); - -extern JS_PUBLIC_API(bool) -JS_AlreadyHasOwnUCProperty(JSContext* cx, JS::HandleObject obj, const char16_t* name, - size_t namelen, bool* foundp); - -extern JS_PUBLIC_API(bool) -JS_AlreadyHasOwnElement(JSContext* cx, JS::HandleObject obj, uint32_t index, bool* foundp); - -extern JS_PUBLIC_API(JSObject*) -JS_NewArrayObject(JSContext* cx, const JS::HandleValueArray& contents); - -extern JS_PUBLIC_API(JSObject*) -JS_NewArrayObject(JSContext* cx, size_t length); - -/** - * Returns true and sets |*isArray| indicating whether |value| is an Array - * object or a wrapper around one, otherwise returns false on failure. - * - * This method returns true with |*isArray == false| when passed a proxy whose - * target is an Array, or when passed a revoked proxy. - */ -extern JS_PUBLIC_API(bool) -JS_IsArrayObject(JSContext* cx, JS::HandleValue value, bool* isArray); - -/** - * Returns true and sets |*isArray| indicating whether |obj| is an Array object - * or a wrapper around one, otherwise returns false on failure. - * - * This method returns true with |*isArray == false| when passed a proxy whose - * target is an Array, or when passed a revoked proxy. - */ -extern JS_PUBLIC_API(bool) -JS_IsArrayObject(JSContext* cx, JS::HandleObject obj, bool* isArray); - -extern JS_PUBLIC_API(bool) -JS_GetArrayLength(JSContext* cx, JS::Handle<JSObject*> obj, uint32_t* lengthp); - -extern JS_PUBLIC_API(bool) -JS_SetArrayLength(JSContext* cx, JS::Handle<JSObject*> obj, uint32_t length); - -namespace JS { - -/** - * Returns true and sets |*isMap| indicating whether |obj| is an Map object - * or a wrapper around one, otherwise returns false on failure. - * - * This method returns true with |*isMap == false| when passed a proxy whose - * target is an Map, or when passed a revoked proxy. - */ -extern JS_PUBLIC_API(bool) -IsMapObject(JSContext* cx, JS::HandleObject obj, bool* isMap); - -/** - * Returns true and sets |*isSet| indicating whether |obj| is an Set object - * or a wrapper around one, otherwise returns false on failure. - * - * This method returns true with |*isSet == false| when passed a proxy whose - * target is an Set, or when passed a revoked proxy. - */ -extern JS_PUBLIC_API(bool) -IsSetObject(JSContext* cx, JS::HandleObject obj, bool* isSet); - -} /* namespace JS */ - -/** - * Assign 'undefined' to all of the object's non-reserved slots. Note: this is - * done for all slots, regardless of the associated property descriptor. - */ -JS_PUBLIC_API(void) -JS_SetAllNonReservedSlotsToUndefined(JSContext* cx, JSObject* objArg); - -/** - * Create a new array buffer with the given contents. It must be legal to pass - * these contents to free(). On success, the ownership is transferred to the - * new array buffer. - */ -extern JS_PUBLIC_API(JSObject*) -JS_NewArrayBufferWithContents(JSContext* cx, size_t nbytes, void* contents); - -/** - * Create a new array buffer with the given contents. The array buffer does not take ownership of - * contents, and JS_DetachArrayBuffer must be called before the contents are disposed of. - */ -extern JS_PUBLIC_API(JSObject*) -JS_NewArrayBufferWithExternalContents(JSContext* cx, size_t nbytes, void* contents); - -/** - * Steal the contents of the given array buffer. The array buffer has its - * length set to 0 and its contents array cleared. The caller takes ownership - * of the return value and must free it or transfer ownership via - * JS_NewArrayBufferWithContents when done using it. - */ -extern JS_PUBLIC_API(void*) -JS_StealArrayBufferContents(JSContext* cx, JS::HandleObject obj); - -/** - * Returns a pointer to the ArrayBuffer |obj|'s data. |obj| and its views will store and expose - * the data in the returned pointer: assigning into the returned pointer will affect values exposed - * by views of |obj| and vice versa. - * - * The caller must ultimately deallocate the returned pointer to avoid leaking. The memory is - * *not* garbage-collected with |obj|. These steps must be followed to deallocate: - * - * 1. The ArrayBuffer |obj| must be detached using JS_DetachArrayBuffer. - * 2. The returned pointer must be freed using JS_free. - * - * To perform step 1, callers *must* hold a reference to |obj| until they finish using the returned - * pointer. They *must not* attempt to let |obj| be GC'd, then JS_free the pointer. - * - * If |obj| isn't an ArrayBuffer, this function returns null and reports an error. - */ -extern JS_PUBLIC_API(void*) -JS_ExternalizeArrayBufferContents(JSContext* cx, JS::HandleObject obj); - -/** - * Create a new mapped array buffer with the given memory mapped contents. It - * must be legal to free the contents pointer by unmapping it. On success, - * ownership is transferred to the new mapped array buffer. - */ -extern JS_PUBLIC_API(JSObject*) -JS_NewMappedArrayBufferWithContents(JSContext* cx, size_t nbytes, void* contents); - -/** - * Create memory mapped array buffer contents. - * Caller must take care of closing fd after calling this function. - */ -extern JS_PUBLIC_API(void*) -JS_CreateMappedArrayBufferContents(int fd, size_t offset, size_t length); - -/** - * Release the allocated resource of mapped array buffer contents before the - * object is created. - * If a new object has been created by JS_NewMappedArrayBufferWithContents() - * with this content, then JS_DetachArrayBuffer() should be used instead to - * release the resource used by the object. - */ -extern JS_PUBLIC_API(void) -JS_ReleaseMappedArrayBufferContents(void* contents, size_t length); - -extern JS_PUBLIC_API(JS::Value) -JS_GetReservedSlot(JSObject* obj, uint32_t index); - -extern JS_PUBLIC_API(void) -JS_SetReservedSlot(JSObject* obj, uint32_t index, const JS::Value& v); - - -/************************************************************************/ - -/* - * Functions and scripts. - */ -extern JS_PUBLIC_API(JSFunction*) -JS_NewFunction(JSContext* cx, JSNative call, unsigned nargs, unsigned flags, - const char* name); - -namespace JS { - -extern JS_PUBLIC_API(JSFunction*) -GetSelfHostedFunction(JSContext* cx, const char* selfHostedName, HandleId id, - unsigned nargs); - -/** - * Create a new function based on the given JSFunctionSpec, *fs. - * id is the result of a successful call to - * `PropertySpecNameToPermanentId(cx, fs->name, &id)`. - * - * Unlike JS_DefineFunctions, this does not treat fs as an array. - * *fs must not be JS_FS_END. - */ -extern JS_PUBLIC_API(JSFunction*) -NewFunctionFromSpec(JSContext* cx, const JSFunctionSpec* fs, HandleId id); - -} /* namespace JS */ - -extern JS_PUBLIC_API(JSObject*) -JS_GetFunctionObject(JSFunction* fun); - -/** - * Return the function's identifier as a JSString, or null if fun is unnamed. - * The returned string lives as long as fun, so you don't need to root a saved - * reference to it if fun is well-connected or rooted, and provided you bound - * the use of the saved reference by fun's lifetime. - */ -extern JS_PUBLIC_API(JSString*) -JS_GetFunctionId(JSFunction* fun); - -/** - * Return a function's display name. This is the defined name if one was given - * where the function was defined, or it could be an inferred name by the JS - * engine in the case that the function was defined to be anonymous. This can - * still return nullptr if a useful display name could not be inferred. The - * same restrictions on rooting as those in JS_GetFunctionId apply. - */ -extern JS_PUBLIC_API(JSString*) -JS_GetFunctionDisplayId(JSFunction* fun); - -/* - * Return the arity (length) of fun. - */ -extern JS_PUBLIC_API(uint16_t) -JS_GetFunctionArity(JSFunction* fun); - -/** - * Infallible predicate to test whether obj is a function object (faster than - * comparing obj's class name to "Function", but equivalent unless someone has - * overwritten the "Function" identifier with a different constructor and then - * created instances using that constructor that might be passed in as obj). - */ -extern JS_PUBLIC_API(bool) -JS_ObjectIsFunction(JSContext* cx, JSObject* obj); - -extern JS_PUBLIC_API(bool) -JS_IsNativeFunction(JSObject* funobj, JSNative call); - -/** Return whether the given function is a valid constructor. */ -extern JS_PUBLIC_API(bool) -JS_IsConstructor(JSFunction* fun); - -extern JS_PUBLIC_API(bool) -JS_DefineFunctions(JSContext* cx, JS::Handle<JSObject*> obj, const JSFunctionSpec* fs); - -extern JS_PUBLIC_API(JSFunction*) -JS_DefineFunction(JSContext* cx, JS::Handle<JSObject*> obj, const char* name, JSNative call, - unsigned nargs, unsigned attrs); - -extern JS_PUBLIC_API(JSFunction*) -JS_DefineUCFunction(JSContext* cx, JS::Handle<JSObject*> obj, - const char16_t* name, size_t namelen, JSNative call, - unsigned nargs, unsigned attrs); - -extern JS_PUBLIC_API(JSFunction*) -JS_DefineFunctionById(JSContext* cx, JS::Handle<JSObject*> obj, JS::Handle<jsid> id, JSNative call, - unsigned nargs, unsigned attrs); - -extern JS_PUBLIC_API(bool) -JS_IsFunctionBound(JSFunction* fun); - -extern JS_PUBLIC_API(JSObject*) -JS_GetBoundFunctionTarget(JSFunction* fun); - -namespace JS { - -/** - * Clone a top-level function into cx's global. This function will dynamically - * fail if funobj was lexically nested inside some other function. - */ -extern JS_PUBLIC_API(JSObject*) -CloneFunctionObject(JSContext* cx, HandleObject funobj); - -/** - * As above, but providing an explicit scope chain. scopeChain must not include - * the global object on it; that's implicit. It needs to contain the other - * objects that should end up on the clone's scope chain. - */ -extern JS_PUBLIC_API(JSObject*) -CloneFunctionObject(JSContext* cx, HandleObject funobj, AutoObjectVector& scopeChain); - -} // namespace JS - -/** - * Given a buffer, return false if the buffer might become a valid - * javascript statement with the addition of more lines. Otherwise return - * true. The intent is to support interactive compilation - accumulate - * lines in a buffer until JS_BufferIsCompilableUnit is true, then pass it to - * the compiler. - */ -extern JS_PUBLIC_API(bool) -JS_BufferIsCompilableUnit(JSContext* cx, JS::Handle<JSObject*> obj, const char* utf8, - size_t length); - -/** - * |script| will always be set. On failure, it will be set to nullptr. - */ -extern JS_PUBLIC_API(bool) -JS_CompileScript(JSContext* cx, const char* ascii, size_t length, - const JS::CompileOptions& options, - JS::MutableHandleScript script); - -/** - * |script| will always be set. On failure, it will be set to nullptr. - */ -extern JS_PUBLIC_API(bool) -JS_CompileUCScript(JSContext* cx, const char16_t* chars, size_t length, - const JS::CompileOptions& options, - JS::MutableHandleScript script); - -extern JS_PUBLIC_API(JSObject*) -JS_GetGlobalFromScript(JSScript* script); - -extern JS_PUBLIC_API(const char*) -JS_GetScriptFilename(JSScript* script); - -extern JS_PUBLIC_API(unsigned) -JS_GetScriptBaseLineNumber(JSContext* cx, JSScript* script); - -extern JS_PUBLIC_API(JSScript*) -JS_GetFunctionScript(JSContext* cx, JS::HandleFunction fun); - -namespace JS { - -/* Options for JavaScript compilation. */ - -/* - * In the most common use case, a CompileOptions instance is allocated on the - * stack, and holds non-owning references to non-POD option values: strings; - * principals; objects; and so on. The code declaring the instance guarantees - * that such option values will outlive the CompileOptions itself: objects are - * otherwise rooted; principals have had their reference counts bumped; strings - * will not be freed until the CompileOptions goes out of scope. In this - * situation, CompileOptions only refers to things others own, so it can be - * lightweight. - * - * In some cases, however, we need to hold compilation options with a - * non-stack-like lifetime. For example, JS::CompileOffThread needs to save - * compilation options where a worker thread can find them, and then return - * immediately. The worker thread will come along at some later point, and use - * the options. - * - * The compiler itself just needs to be able to access a collection of options; - * it doesn't care who owns them, or what's keeping them alive. It does its own - * addrefs/copies/tracing/etc. - * - * Furthermore, in some cases compile options are propagated from one entity to - * another (e.g. from a scriipt to a function defined in that script). This - * involves copying over some, but not all, of the options. - * - * So, we have a class hierarchy that reflects these four use cases: - * - * - TransitiveCompileOptions is the common base class, representing options - * that should get propagated from a script to functions defined in that - * script. This is never instantiated directly. - * - * - ReadOnlyCompileOptions is the only subclass of TransitiveCompileOptions, - * representing a full set of compile options. It can be used by code that - * simply needs to access options set elsewhere, like the compiler. This, - * again, is never instantiated directly. - * - * - The usual CompileOptions class must be stack-allocated, and holds - * non-owning references to the filename, element, and so on. It's derived - * from ReadOnlyCompileOptions, so the compiler can use it. - * - * - OwningCompileOptions roots / copies / reference counts of all its values, - * and unroots / frees / releases them when it is destructed. It too is - * derived from ReadOnlyCompileOptions, so the compiler accepts it. - */ - -enum class AsmJSOption : uint8_t { Enabled, Disabled, DisabledByDebugger }; - -/** - * The common base class for the CompileOptions hierarchy. - * - * Use this in code that needs to propagate compile options from one compilation - * unit to another. - */ -class JS_FRIEND_API(TransitiveCompileOptions) -{ - protected: - // The Web Platform allows scripts to be loaded from arbitrary cross-origin - // sources. This allows an attack by which a malicious website loads a - // sensitive file (say, a bank statement) cross-origin (using the user's - // cookies), and sniffs the generated syntax errors (via a window.onerror - // handler) for juicy morsels of its contents. - // - // To counter this attack, HTML5 specifies that script errors should be - // sanitized ("muted") when the script is not same-origin with the global - // for which it is loaded. Callers should set this flag for cross-origin - // scripts, and it will be propagated appropriately to child scripts and - // passed back in JSErrorReports. - bool mutedErrors_; - const char* filename_; - const char* introducerFilename_; - const char16_t* sourceMapURL_; - - // This constructor leaves 'version' set to JSVERSION_UNKNOWN. The structure - // is unusable until that's set to something more specific; the derived - // classes' constructors take care of that, in ways appropriate to their - // purpose. - TransitiveCompileOptions() - : mutedErrors_(false), - filename_(nullptr), - introducerFilename_(nullptr), - sourceMapURL_(nullptr), - version(JSVERSION_UNKNOWN), - versionSet(false), - utf8(false), - selfHostingMode(false), - canLazilyParse(true), - strictOption(false), - extraWarningsOption(false), - werrorOption(false), - asmJSOption(AsmJSOption::Disabled), - throwOnAsmJSValidationFailureOption(false), - forceAsync(false), - installedFile(false), - sourceIsLazy(false), - introductionType(nullptr), - introductionLineno(0), - introductionOffset(0), - hasIntroductionInfo(false) - { } - - // Set all POD options (those not requiring reference counts, copies, - // rooting, or other hand-holding) to their values in |rhs|. - void copyPODTransitiveOptions(const TransitiveCompileOptions& rhs); - - public: - // Read-only accessors for non-POD options. The proper way to set these - // depends on the derived type. - bool mutedErrors() const { return mutedErrors_; } - const char* filename() const { return filename_; } - const char* introducerFilename() const { return introducerFilename_; } - const char16_t* sourceMapURL() const { return sourceMapURL_; } - virtual JSObject* element() const = 0; - virtual JSString* elementAttributeName() const = 0; - virtual JSScript* introductionScript() const = 0; - - // POD options. - JSVersion version; - bool versionSet; - bool utf8; - bool selfHostingMode; - bool canLazilyParse; - bool strictOption; - bool extraWarningsOption; - bool werrorOption; - AsmJSOption asmJSOption; - bool throwOnAsmJSValidationFailureOption; - bool forceAsync; - bool installedFile; // 'true' iff pre-compiling js file in packaged app - bool sourceIsLazy; - - // |introductionType| is a statically allocated C string: - // one of "eval", "Function", or "GeneratorFunction". - const char* introductionType; - unsigned introductionLineno; - uint32_t introductionOffset; - bool hasIntroductionInfo; - - private: - void operator=(const TransitiveCompileOptions&) = delete; -}; - -/** - * The class representing a full set of compile options. - * - * Use this in code that only needs to access compilation options created - * elsewhere, like the compiler. Don't instantiate this class (the constructor - * is protected anyway); instead, create instances only of the derived classes: - * CompileOptions and OwningCompileOptions. - */ -class JS_FRIEND_API(ReadOnlyCompileOptions) : public TransitiveCompileOptions -{ - friend class CompileOptions; - - protected: - ReadOnlyCompileOptions() - : TransitiveCompileOptions(), - lineno(1), - column(0), - isRunOnce(false), - noScriptRval(false) - { } - - // Set all POD options (those not requiring reference counts, copies, - // rooting, or other hand-holding) to their values in |rhs|. - void copyPODOptions(const ReadOnlyCompileOptions& rhs); - - public: - // Read-only accessors for non-POD options. The proper way to set these - // depends on the derived type. - bool mutedErrors() const { return mutedErrors_; } - const char* filename() const { return filename_; } - const char* introducerFilename() const { return introducerFilename_; } - const char16_t* sourceMapURL() const { return sourceMapURL_; } - virtual JSObject* element() const = 0; - virtual JSString* elementAttributeName() const = 0; - virtual JSScript* introductionScript() const = 0; - - // POD options. - unsigned lineno; - unsigned column; - // isRunOnce only applies to non-function scripts. - bool isRunOnce; - bool noScriptRval; - - private: - void operator=(const ReadOnlyCompileOptions&) = delete; -}; - -/** - * Compilation options, with dynamic lifetime. An instance of this type - * makes a copy of / holds / roots all dynamically allocated resources - * (principals; elements; strings) that it refers to. Its destructor frees - * / drops / unroots them. This is heavier than CompileOptions, below, but - * unlike CompileOptions, it can outlive any given stack frame. - * - * Note that this *roots* any JS values it refers to - they're live - * unconditionally. Thus, instances of this type can't be owned, directly - * or indirectly, by a JavaScript object: if any value that this roots ever - * comes to refer to the object that owns this, then the whole cycle, and - * anything else it entrains, will never be freed. - */ -class JS_FRIEND_API(OwningCompileOptions) : public ReadOnlyCompileOptions -{ - PersistentRootedObject elementRoot; - PersistentRootedString elementAttributeNameRoot; - PersistentRootedScript introductionScriptRoot; - - public: - // A minimal constructor, for use with OwningCompileOptions::copy. This - // leaves |this.version| set to JSVERSION_UNKNOWN; the instance - // shouldn't be used until we've set that to something real (as |copy| - // will). - explicit OwningCompileOptions(JSContext* cx); - ~OwningCompileOptions(); - - JSObject* element() const override { return elementRoot; } - JSString* elementAttributeName() const override { return elementAttributeNameRoot; } - JSScript* introductionScript() const override { return introductionScriptRoot; } - - // Set this to a copy of |rhs|. Return false on OOM. - bool copy(JSContext* cx, const ReadOnlyCompileOptions& rhs); - - /* These setters make copies of their string arguments, and are fallible. */ - bool setFile(JSContext* cx, const char* f); - bool setFileAndLine(JSContext* cx, const char* f, unsigned l); - bool setSourceMapURL(JSContext* cx, const char16_t* s); - bool setIntroducerFilename(JSContext* cx, const char* s); - - /* These setters are infallible, and can be chained. */ - OwningCompileOptions& setLine(unsigned l) { lineno = l; return *this; } - OwningCompileOptions& setElement(JSObject* e) { - elementRoot = e; - return *this; - } - OwningCompileOptions& setElementAttributeName(JSString* p) { - elementAttributeNameRoot = p; - return *this; - } - OwningCompileOptions& setIntroductionScript(JSScript* s) { - introductionScriptRoot = s; - return *this; - } - OwningCompileOptions& setMutedErrors(bool mute) { - mutedErrors_ = mute; - return *this; - } - OwningCompileOptions& setVersion(JSVersion v) { - version = v; - versionSet = true; - return *this; - } - OwningCompileOptions& setUTF8(bool u) { utf8 = u; return *this; } - OwningCompileOptions& setColumn(unsigned c) { column = c; return *this; } - OwningCompileOptions& setIsRunOnce(bool once) { isRunOnce = once; return *this; } - OwningCompileOptions& setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; } - OwningCompileOptions& setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; } - OwningCompileOptions& setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; } - OwningCompileOptions& setSourceIsLazy(bool l) { sourceIsLazy = l; return *this; } - OwningCompileOptions& setIntroductionType(const char* t) { introductionType = t; return *this; } - bool setIntroductionInfo(JSContext* cx, const char* introducerFn, const char* intro, - unsigned line, JSScript* script, uint32_t offset) - { - if (!setIntroducerFilename(cx, introducerFn)) - return false; - introductionType = intro; - introductionLineno = line; - introductionScriptRoot = script; - introductionOffset = offset; - hasIntroductionInfo = true; - return true; - } - - private: - void operator=(const CompileOptions& rhs) = delete; -}; - -/** - * Compilation options stored on the stack. An instance of this type - * simply holds references to dynamically allocated resources (element; - * filename; source map URL) that are owned by something else. If you - * create an instance of this type, it's up to you to guarantee that - * everything you store in it will outlive it. - */ -class MOZ_STACK_CLASS JS_FRIEND_API(CompileOptions) final : public ReadOnlyCompileOptions -{ - RootedObject elementRoot; - RootedString elementAttributeNameRoot; - RootedScript introductionScriptRoot; - - public: - explicit CompileOptions(JSContext* cx, JSVersion version = JSVERSION_UNKNOWN); - CompileOptions(js::ContextFriendFields* cx, const ReadOnlyCompileOptions& rhs) - : ReadOnlyCompileOptions(), elementRoot(cx), elementAttributeNameRoot(cx), - introductionScriptRoot(cx) - { - copyPODOptions(rhs); - - filename_ = rhs.filename(); - introducerFilename_ = rhs.introducerFilename(); - sourceMapURL_ = rhs.sourceMapURL(); - elementRoot = rhs.element(); - elementAttributeNameRoot = rhs.elementAttributeName(); - introductionScriptRoot = rhs.introductionScript(); - } - - CompileOptions(js::ContextFriendFields* cx, const TransitiveCompileOptions& rhs) - : ReadOnlyCompileOptions(), elementRoot(cx), elementAttributeNameRoot(cx), - introductionScriptRoot(cx) - { - copyPODTransitiveOptions(rhs); - - filename_ = rhs.filename(); - introducerFilename_ = rhs.introducerFilename(); - sourceMapURL_ = rhs.sourceMapURL(); - elementRoot = rhs.element(); - elementAttributeNameRoot = rhs.elementAttributeName(); - introductionScriptRoot = rhs.introductionScript(); - } - - JSObject* element() const override { return elementRoot; } - JSString* elementAttributeName() const override { return elementAttributeNameRoot; } - JSScript* introductionScript() const override { return introductionScriptRoot; } - - CompileOptions& setFile(const char* f) { filename_ = f; return *this; } - CompileOptions& setLine(unsigned l) { lineno = l; return *this; } - CompileOptions& setFileAndLine(const char* f, unsigned l) { - filename_ = f; lineno = l; return *this; - } - CompileOptions& setSourceMapURL(const char16_t* s) { sourceMapURL_ = s; return *this; } - CompileOptions& setElement(JSObject* e) { elementRoot = e; return *this; } - CompileOptions& setElementAttributeName(JSString* p) { - elementAttributeNameRoot = p; - return *this; - } - CompileOptions& setIntroductionScript(JSScript* s) { - introductionScriptRoot = s; - return *this; - } - CompileOptions& setMutedErrors(bool mute) { - mutedErrors_ = mute; - return *this; - } - CompileOptions& setVersion(JSVersion v) { - version = v; - versionSet = true; - return *this; - } - CompileOptions& setUTF8(bool u) { utf8 = u; return *this; } - CompileOptions& setColumn(unsigned c) { column = c; return *this; } - CompileOptions& setIsRunOnce(bool once) { isRunOnce = once; return *this; } - CompileOptions& setNoScriptRval(bool nsr) { noScriptRval = nsr; return *this; } - CompileOptions& setSelfHostingMode(bool shm) { selfHostingMode = shm; return *this; } - CompileOptions& setCanLazilyParse(bool clp) { canLazilyParse = clp; return *this; } - CompileOptions& setSourceIsLazy(bool l) { sourceIsLazy = l; return *this; } - CompileOptions& setIntroductionType(const char* t) { introductionType = t; return *this; } - CompileOptions& setIntroductionInfo(const char* introducerFn, const char* intro, - unsigned line, JSScript* script, uint32_t offset) - { - introducerFilename_ = introducerFn; - introductionType = intro; - introductionLineno = line; - introductionScriptRoot = script; - introductionOffset = offset; - hasIntroductionInfo = true; - return *this; - } - CompileOptions& maybeMakeStrictMode(bool strict) { - strictOption = strictOption || strict; - return *this; - } - - private: - void operator=(const CompileOptions& rhs) = delete; -}; - -/** - * |script| will always be set. On failure, it will be set to nullptr. - */ -extern JS_PUBLIC_API(bool) -Compile(JSContext* cx, const ReadOnlyCompileOptions& options, - SourceBufferHolder& srcBuf, JS::MutableHandleScript script); - -extern JS_PUBLIC_API(bool) -Compile(JSContext* cx, const ReadOnlyCompileOptions& options, - const char* bytes, size_t length, JS::MutableHandleScript script); - -extern JS_PUBLIC_API(bool) -Compile(JSContext* cx, const ReadOnlyCompileOptions& options, - const char16_t* chars, size_t length, JS::MutableHandleScript script); - -extern JS_PUBLIC_API(bool) -Compile(JSContext* cx, const ReadOnlyCompileOptions& options, - FILE* file, JS::MutableHandleScript script); - -extern JS_PUBLIC_API(bool) -Compile(JSContext* cx, const ReadOnlyCompileOptions& options, - const char* filename, JS::MutableHandleScript script); - -extern JS_PUBLIC_API(bool) -CompileForNonSyntacticScope(JSContext* cx, const ReadOnlyCompileOptions& options, - SourceBufferHolder& srcBuf, JS::MutableHandleScript script); - -extern JS_PUBLIC_API(bool) -CompileForNonSyntacticScope(JSContext* cx, const ReadOnlyCompileOptions& options, - const char* bytes, size_t length, JS::MutableHandleScript script); - -extern JS_PUBLIC_API(bool) -CompileForNonSyntacticScope(JSContext* cx, const ReadOnlyCompileOptions& options, - const char16_t* chars, size_t length, JS::MutableHandleScript script); - -extern JS_PUBLIC_API(bool) -CompileForNonSyntacticScope(JSContext* cx, const ReadOnlyCompileOptions& options, - FILE* file, JS::MutableHandleScript script); - -extern JS_PUBLIC_API(bool) -CompileForNonSyntacticScope(JSContext* cx, const ReadOnlyCompileOptions& options, - const char* filename, JS::MutableHandleScript script); - -extern JS_PUBLIC_API(bool) -CanCompileOffThread(JSContext* cx, const ReadOnlyCompileOptions& options, size_t length); - -/* - * Off thread compilation control flow. - * - * After successfully triggering an off thread compile of a script, the - * callback will eventually be invoked with the specified data and a token - * for the compilation. The callback will be invoked while off the main thread, - * so must ensure that its operations are thread safe. Afterwards, one of the - * following functions must be invoked on the main thread: - * - * - FinishOffThreadScript, to get the result script (or nullptr on failure). - * - CancelOffThreadScript, to free the resources without creating a script. - * - * The characters passed in to CompileOffThread must remain live until the - * callback is invoked, and the resulting script will be rooted until the call - * to FinishOffThreadScript. - */ - -extern JS_PUBLIC_API(bool) -CompileOffThread(JSContext* cx, const ReadOnlyCompileOptions& options, - const char16_t* chars, size_t length, - OffThreadCompileCallback callback, void* callbackData); - -extern JS_PUBLIC_API(JSScript*) -FinishOffThreadScript(JSContext* cx, void* token); - -extern JS_PUBLIC_API(void) -CancelOffThreadScript(JSContext* cx, void* token); - -extern JS_PUBLIC_API(bool) -CompileOffThreadModule(JSContext* cx, const ReadOnlyCompileOptions& options, - const char16_t* chars, size_t length, - OffThreadCompileCallback callback, void* callbackData); - -extern JS_PUBLIC_API(JSObject*) -FinishOffThreadModule(JSContext* cx, void* token); - -extern JS_PUBLIC_API(void) -CancelOffThreadModule(JSContext* cx, void* token); - -/** - * Compile a function with envChain plus the global as its scope chain. - * envChain must contain objects in the current compartment of cx. The actual - * scope chain used for the function will consist of With wrappers for those - * objects, followed by the current global of the compartment cx is in. This - * global must not be explicitly included in the scope chain. - */ -extern JS_PUBLIC_API(bool) -CompileFunction(JSContext* cx, AutoObjectVector& envChain, - const ReadOnlyCompileOptions& options, - const char* name, unsigned nargs, const char* const* argnames, - const char16_t* chars, size_t length, JS::MutableHandleFunction fun); - -/** - * Same as above, but taking a SourceBufferHolder for the function body. - */ -extern JS_PUBLIC_API(bool) -CompileFunction(JSContext* cx, AutoObjectVector& envChain, - const ReadOnlyCompileOptions& options, - const char* name, unsigned nargs, const char* const* argnames, - SourceBufferHolder& srcBuf, JS::MutableHandleFunction fun); - -/** - * Same as above, but taking a const char * for the function body. - */ -extern JS_PUBLIC_API(bool) -CompileFunction(JSContext* cx, AutoObjectVector& envChain, - const ReadOnlyCompileOptions& options, - const char* name, unsigned nargs, const char* const* argnames, - const char* bytes, size_t length, JS::MutableHandleFunction fun); - -} /* namespace JS */ - -extern JS_PUBLIC_API(JSString*) -JS_DecompileScript(JSContext* cx, JS::Handle<JSScript*> script, const char* name, unsigned indent); - -/* - * API extension: OR this into indent to avoid pretty-printing the decompiled - * source resulting from JS_DecompileFunction. - */ -#define JS_DONT_PRETTY_PRINT ((unsigned)0x8000) - -extern JS_PUBLIC_API(JSString*) -JS_DecompileFunction(JSContext* cx, JS::Handle<JSFunction*> fun, unsigned indent); - - -/* - * NB: JS_ExecuteScript and the JS::Evaluate APIs come in two flavors: either - * they use the global as the scope, or they take an AutoObjectVector of objects - * to use as the scope chain. In the former case, the global is also used as - * the "this" keyword value and the variables object (ECMA parlance for where - * 'var' and 'function' bind names) of the execution context for script. In the - * latter case, the first object in the provided list is used, unless the list - * is empty, in which case the global is used. - * - * Why a runtime option? The alternative is to add APIs duplicating those - * for the other value of flags, and that doesn't seem worth the code bloat - * cost. Such new entry points would probably have less obvious names, too, so - * would not tend to be used. The ContextOptionsRef adjustment, OTOH, can be - * more easily hacked into existing code that does not depend on the bug; such - * code can continue to use the familiar JS::Evaluate, etc., entry points. - */ - -/** - * Evaluate a script in the scope of the current global of cx. - */ -extern JS_PUBLIC_API(bool) -JS_ExecuteScript(JSContext* cx, JS::HandleScript script, JS::MutableHandleValue rval); - -extern JS_PUBLIC_API(bool) -JS_ExecuteScript(JSContext* cx, JS::HandleScript script); - -/** - * As above, but providing an explicit scope chain. envChain must not include - * the global object on it; that's implicit. It needs to contain the other - * objects that should end up on the script's scope chain. - */ -extern JS_PUBLIC_API(bool) -JS_ExecuteScript(JSContext* cx, JS::AutoObjectVector& envChain, - JS::HandleScript script, JS::MutableHandleValue rval); - -extern JS_PUBLIC_API(bool) -JS_ExecuteScript(JSContext* cx, JS::AutoObjectVector& envChain, JS::HandleScript script); - -namespace JS { - -/** - * Like the above, but handles a cross-compartment script. If the script is - * cross-compartment, it is cloned into the current compartment before executing. - */ -extern JS_PUBLIC_API(bool) -CloneAndExecuteScript(JSContext* cx, JS::Handle<JSScript*> script, - JS::MutableHandleValue rval); - -} /* namespace JS */ - -namespace JS { - -/** - * Evaluate the given source buffer in the scope of the current global of cx. - */ -extern JS_PUBLIC_API(bool) -Evaluate(JSContext* cx, const ReadOnlyCompileOptions& options, - SourceBufferHolder& srcBuf, JS::MutableHandleValue rval); - -/** - * As above, but providing an explicit scope chain. envChain must not include - * the global object on it; that's implicit. It needs to contain the other - * objects that should end up on the script's scope chain. - */ -extern JS_PUBLIC_API(bool) -Evaluate(JSContext* cx, AutoObjectVector& envChain, const ReadOnlyCompileOptions& options, - SourceBufferHolder& srcBuf, JS::MutableHandleValue rval); - -/** - * Evaluate the given character buffer in the scope of the current global of cx. - */ -extern JS_PUBLIC_API(bool) -Evaluate(JSContext* cx, const ReadOnlyCompileOptions& options, - const char16_t* chars, size_t length, JS::MutableHandleValue rval); - -/** - * As above, but providing an explicit scope chain. envChain must not include - * the global object on it; that's implicit. It needs to contain the other - * objects that should end up on the script's scope chain. - */ -extern JS_PUBLIC_API(bool) -Evaluate(JSContext* cx, AutoObjectVector& envChain, const ReadOnlyCompileOptions& options, - const char16_t* chars, size_t length, JS::MutableHandleValue rval); - -/** - * Evaluate the given byte buffer in the scope of the current global of cx. - */ -extern JS_PUBLIC_API(bool) -Evaluate(JSContext* cx, const ReadOnlyCompileOptions& options, - const char* bytes, size_t length, JS::MutableHandleValue rval); - -/** - * Evaluate the given file in the scope of the current global of cx. - */ -extern JS_PUBLIC_API(bool) -Evaluate(JSContext* cx, const ReadOnlyCompileOptions& options, - const char* filename, JS::MutableHandleValue rval); - -/** - * Get the HostResolveImportedModule hook for a global. - */ -extern JS_PUBLIC_API(JSFunction*) -GetModuleResolveHook(JSContext* cx); - -/** - * Set the HostResolveImportedModule hook for a global to the given function. - */ -extern JS_PUBLIC_API(void) -SetModuleResolveHook(JSContext* cx, JS::HandleFunction func); - -/** - * Parse the given source buffer as a module in the scope of the current global - * of cx and return a source text module record. - */ -extern JS_PUBLIC_API(bool) -CompileModule(JSContext* cx, const ReadOnlyCompileOptions& options, - SourceBufferHolder& srcBuf, JS::MutableHandleObject moduleRecord); - -/** - * Set the [[HostDefined]] field of a source text module record to the given - * value. - */ -extern JS_PUBLIC_API(void) -SetModuleHostDefinedField(JSObject* module, const JS::Value& value); - -/** - * Get the [[HostDefined]] field of a source text module record. - */ -extern JS_PUBLIC_API(JS::Value) -GetModuleHostDefinedField(JSObject* module); - -/* - * Perform the ModuleDeclarationInstantiation operation on on the give source - * text module record. - * - * This transitively resolves all module dependencies (calling the - * HostResolveImportedModule hook) and initializes the environment record for - * the module. - */ -extern JS_PUBLIC_API(bool) -ModuleDeclarationInstantiation(JSContext* cx, JS::HandleObject moduleRecord); - -/* - * Perform the ModuleEvaluation operation on on the give source text module - * record. - * - * This does nothing if this module has already been evaluated. Otherwise, it - * transitively evaluates all dependences of this module and then evaluates this - * module. - * - * ModuleDeclarationInstantiation must have completed prior to calling this. - */ -extern JS_PUBLIC_API(bool) -ModuleEvaluation(JSContext* cx, JS::HandleObject moduleRecord); - -/* - * Get a list of the module specifiers used by a source text module - * record to request importation of modules. - * - * The result is a JavaScript array of string values. To extract the individual - * values use only JS_GetArrayLength and JS_GetElement with indices 0 to - * length - 1. - */ -extern JS_PUBLIC_API(JSObject*) -GetRequestedModules(JSContext* cx, JS::HandleObject moduleRecord); - -/* - * Get the script associated with a module. - */ -extern JS_PUBLIC_API(JSScript*) -GetModuleScript(JSContext* cx, JS::HandleObject moduleRecord); - -} /* namespace JS */ - -extern JS_PUBLIC_API(bool) -JS_CheckForInterrupt(JSContext* cx); - -/* - * These functions allow setting an interrupt callback that will be called - * from the JS thread some time after any thread triggered the callback using - * JS_RequestInterruptCallback(cx). - * - * To schedule the GC and for other activities the engine internally triggers - * interrupt callbacks. The embedding should thus not rely on callbacks being - * triggered through the external API only. - * - * Important note: Additional callbacks can occur inside the callback handler - * if it re-enters the JS engine. The embedding must ensure that the callback - * is disconnected before attempting such re-entry. - */ -extern JS_PUBLIC_API(bool) -JS_AddInterruptCallback(JSContext* cx, JSInterruptCallback callback); - -extern JS_PUBLIC_API(bool) -JS_DisableInterruptCallback(JSContext* cx); - -extern JS_PUBLIC_API(void) -JS_ResetInterruptCallback(JSContext* cx, bool enable); - -extern JS_PUBLIC_API(void) -JS_RequestInterruptCallback(JSContext* cx); - -namespace JS { - -/** - * Sets the callback that's invoked whenever an incumbent global is required. - * - * SpiderMonkey doesn't itself have a notion of incumbent globals as defined - * by the html spec, so we need the embedding to provide this. - * See dom/base/ScriptSettings.h for details. - */ -extern JS_PUBLIC_API(void) -SetGetIncumbentGlobalCallback(JSContext* cx, JSGetIncumbentGlobalCallback callback); - -/** - * Sets the callback that's invoked whenever a Promise job should be enqeued. - * - * SpiderMonkey doesn't schedule Promise resolution jobs itself; instead, - * using this function the embedding can provide a callback to do that - * scheduling. The provided `callback` is invoked with the promise job, - * the corresponding Promise's allocation stack, and the `data` pointer - * passed here as arguments. - */ -extern JS_PUBLIC_API(void) -SetEnqueuePromiseJobCallback(JSContext* cx, JSEnqueuePromiseJobCallback callback, - void* data = nullptr); - -/** - * Sets the callback that's invoked whenever a Promise is rejected without - * a rejection handler, and when a Promise that was previously rejected - * without a handler gets a handler attached. - */ -extern JS_PUBLIC_API(void) -SetPromiseRejectionTrackerCallback(JSContext* cx, JSPromiseRejectionTrackerCallback callback, - void* data = nullptr); - -/** - * Returns a new instance of the Promise builtin class in the current - * compartment, with the right slot layout. If a `proto` is passed, that gets - * set as the instance's [[Prototype]] instead of the original value of - * `Promise.prototype`. - */ -extern JS_PUBLIC_API(JSObject*) -NewPromiseObject(JSContext* cx, JS::HandleObject executor, JS::HandleObject proto = nullptr); - -/** - * Returns true if the given object is an unwrapped PromiseObject, false - * otherwise. - */ -extern JS_PUBLIC_API(bool) -IsPromiseObject(JS::HandleObject obj); - -/** - * Returns the current compartment's original Promise constructor. - */ -extern JS_PUBLIC_API(JSObject*) -GetPromiseConstructor(JSContext* cx); - -/** - * Returns the current compartment's original Promise.prototype. - */ -extern JS_PUBLIC_API(JSObject*) -GetPromisePrototype(JSContext* cx); - -// Keep this in sync with the PROMISE_STATE defines in SelfHostingDefines.h. -enum class PromiseState { - Pending, - Fulfilled, - Rejected -}; - -/** - * Returns the given Promise's state as a JS::PromiseState enum value. - */ -extern JS_PUBLIC_API(PromiseState) -GetPromiseState(JS::HandleObject promise); - -/** - * Returns the given Promise's process-unique ID. - */ -JS_PUBLIC_API(uint64_t) -GetPromiseID(JS::HandleObject promise); - -/** - * Returns the given Promise's result: either the resolution value for - * fulfilled promises, or the rejection reason for rejected ones. - */ -extern JS_PUBLIC_API(JS::Value) -GetPromiseResult(JS::HandleObject promise); - -/** - * Returns a js::SavedFrame linked list of the stack that lead to the given - * Promise's allocation. - */ -extern JS_PUBLIC_API(JSObject*) -GetPromiseAllocationSite(JS::HandleObject promise); - -extern JS_PUBLIC_API(JSObject*) -GetPromiseResolutionSite(JS::HandleObject promise); - -#ifdef DEBUG -extern JS_PUBLIC_API(void) -DumpPromiseAllocationSite(JSContext* cx, JS::HandleObject promise); - -extern JS_PUBLIC_API(void) -DumpPromiseResolutionSite(JSContext* cx, JS::HandleObject promise); -#endif - -/** - * Calls the current compartment's original Promise.resolve on the original - * Promise constructor, with `resolutionValue` passed as an argument. - */ -extern JS_PUBLIC_API(JSObject*) -CallOriginalPromiseResolve(JSContext* cx, JS::HandleValue resolutionValue); - -/** - * Calls the current compartment's original Promise.reject on the original - * Promise constructor, with `resolutionValue` passed as an argument. - */ -extern JS_PUBLIC_API(JSObject*) -CallOriginalPromiseReject(JSContext* cx, JS::HandleValue rejectionValue); - -/** - * Resolves the given Promise with the given `resolutionValue`. - * - * Calls the `resolve` function that was passed to the executor function when - * the Promise was created. - */ -extern JS_PUBLIC_API(bool) -ResolvePromise(JSContext* cx, JS::HandleObject promise, JS::HandleValue resolutionValue); - -/** - * Rejects the given `promise` with the given `rejectionValue`. - * - * Calls the `reject` function that was passed to the executor function when - * the Promise was created. - */ -extern JS_PUBLIC_API(bool) -RejectPromise(JSContext* cx, JS::HandleObject promise, JS::HandleValue rejectionValue); - -/** - * Calls the current compartment's original Promise.prototype.then on the - * given `promise`, with `onResolve` and `onReject` passed as arguments. - * - * Asserts if the passed-in `promise` object isn't an unwrapped instance of - * `Promise` or a subclass or `onResolve` and `onReject` aren't both either - * `nullptr` or callable objects. - */ -extern JS_PUBLIC_API(JSObject*) -CallOriginalPromiseThen(JSContext* cx, JS::HandleObject promise, - JS::HandleObject onResolve, JS::HandleObject onReject); - -/** - * Unforgeable, optimized version of the JS builtin Promise.prototype.then. - * - * Takes a Promise instance and `onResolve`, `onReject` callables to enqueue - * as reactions for that promise. In difference to Promise.prototype.then, - * this doesn't create and return a new Promise instance. - * - * Asserts if the passed-in `promise` object isn't an unwrapped instance of - * `Promise` or a subclass or `onResolve` and `onReject` aren't both callable - * objects. - */ -extern JS_PUBLIC_API(bool) -AddPromiseReactions(JSContext* cx, JS::HandleObject promise, - JS::HandleObject onResolve, JS::HandleObject onReject); - -/** - * Unforgeable version of the JS builtin Promise.all. - * - * Takes an AutoObjectVector of Promise objects and returns a promise that's - * resolved with an array of resolution values when all those promises ahve - * been resolved, or rejected with the rejection value of the first rejected - * promise. - * - * Asserts if the array isn't dense or one of the entries isn't an unwrapped - * instance of Promise or a subclass. - */ -extern JS_PUBLIC_API(JSObject*) -GetWaitForAllPromise(JSContext* cx, const JS::AutoObjectVector& promises); - -/** - * An AsyncTask represents a SpiderMonkey-internal operation that starts on a - * JSContext's owner thread, possibly executes on other threads, completes, and - * then needs to be scheduled to run again on the JSContext's owner thread. The - * embedding provides for this final dispatch back to the JSContext's owner - * thread by calling methods on this interface when requested. - */ -struct JS_PUBLIC_API(AsyncTask) -{ - AsyncTask() : user(nullptr) {} - virtual ~AsyncTask() {} - - /** - * After the FinishAsyncTaskCallback is called and succeeds, one of these - * two functions will be called on the original JSContext's owner thread. - */ - virtual void finish(JSContext* cx) = 0; - virtual void cancel(JSContext* cx) = 0; - - /* The embedding may use this field to attach arbitrary data to a task. */ - void* user; -}; - -/** - * A new AsyncTask object, created inside SpiderMonkey on the JSContext's owner - * thread, will be passed to the StartAsyncTaskCallback before it is dispatched - * to another thread. The embedding may use the AsyncTask::user field to attach - * additional task state. - * - * If this function succeeds, SpiderMonkey will call the FinishAsyncTaskCallback - * at some point in the future. Otherwise, FinishAsyncTaskCallback will *not* - * be called. SpiderMonkey assumes that, if StartAsyncTaskCallback fails, it is - * because the JSContext is being shut down. - */ -typedef bool -(*StartAsyncTaskCallback)(JSContext* cx, AsyncTask* task); - -/** - * The FinishAsyncTaskCallback may be called from any thread and will only be - * passed AsyncTasks that have already been started via StartAsyncTaskCallback. - * If the embedding returns 'true', indicating success, the embedding must call - * either task->finish() or task->cancel() on the JSContext's owner thread at - * some point in the future. - */ -typedef bool -(*FinishAsyncTaskCallback)(AsyncTask* task); - -/** - * Set the above callbacks for the given context. - */ -extern JS_PUBLIC_API(void) -SetAsyncTaskCallbacks(JSContext* cx, StartAsyncTaskCallback start, FinishAsyncTaskCallback finish); - -} // namespace JS - -extern JS_PUBLIC_API(bool) -JS_IsRunning(JSContext* cx); - -namespace JS { - -/** - * This class can be used to store a pointer to the youngest frame of a saved - * stack in the specified JSContext. This reference will be picked up by any new - * calls performed until the class is destroyed, with the specified asyncCause, - * that must not be empty. - * - * Any stack capture initiated during these new calls will go through the async - * stack instead of the current stack. - * - * Capturing the stack before a new call is performed will not be affected. - * - * The provided chain of SavedFrame objects can live in any compartment, - * although it will be copied to the compartment where the stack is captured. - * - * See also `js/src/doc/SavedFrame/SavedFrame.md` for documentation on async - * stack frames. - */ -class MOZ_STACK_CLASS JS_PUBLIC_API(AutoSetAsyncStackForNewCalls) -{ - JSContext* cx; - RootedObject oldAsyncStack; - const char* oldAsyncCause; - bool oldAsyncCallIsExplicit; - - public: - enum class AsyncCallKind { - // The ordinary kind of call, where we may apply an async - // parent if there is no ordinary parent. - IMPLICIT, - // An explicit async parent, e.g., callFunctionWithAsyncStack, - // where we always want to override any ordinary parent. - EXPLICIT - }; - - // The stack parameter cannot be null by design, because it would be - // ambiguous whether that would clear any scheduled async stack and make the - // normal stack reappear in the new call, or just keep the async stack - // already scheduled for the new call, if any. - // - // asyncCause is owned by the caller and its lifetime must outlive the - // lifetime of the AutoSetAsyncStackForNewCalls object. It is strongly - // encouraged that asyncCause be a string constant or similar statically - // allocated string. - AutoSetAsyncStackForNewCalls(JSContext* cx, HandleObject stack, - const char* asyncCause, - AsyncCallKind kind = AsyncCallKind::IMPLICIT); - ~AutoSetAsyncStackForNewCalls(); -}; - -} // namespace JS - -/************************************************************************/ - -/* - * Strings. - * - * NB: JS_NewUCString takes ownership of bytes on success, avoiding a copy; - * but on error (signified by null return), it leaves chars owned by the - * caller. So the caller must free bytes in the error case, if it has no use - * for them. In contrast, all the JS_New*StringCopy* functions do not take - * ownership of the character memory passed to them -- they copy it. - */ -extern JS_PUBLIC_API(JSString*) -JS_NewStringCopyN(JSContext* cx, const char* s, size_t n); - -extern JS_PUBLIC_API(JSString*) -JS_NewStringCopyZ(JSContext* cx, const char* s); - -extern JS_PUBLIC_API(JSString*) -JS_NewStringCopyUTF8Z(JSContext* cx, const JS::ConstUTF8CharsZ s); - -extern JS_PUBLIC_API(JSString*) -JS_NewStringCopyUTF8N(JSContext* cx, const JS::UTF8Chars s); - -extern JS_PUBLIC_API(JSString*) -JS_AtomizeAndPinJSString(JSContext* cx, JS::HandleString str); - -extern JS_PUBLIC_API(JSString*) -JS_AtomizeStringN(JSContext* cx, const char* s, size_t length); - -extern JS_PUBLIC_API(JSString*) -JS_AtomizeString(JSContext* cx, const char* s); - -extern JS_PUBLIC_API(JSString*) -JS_AtomizeAndPinStringN(JSContext* cx, const char* s, size_t length); - -extern JS_PUBLIC_API(JSString*) -JS_AtomizeAndPinString(JSContext* cx, const char* s); - -extern JS_PUBLIC_API(JSString*) -JS_NewUCString(JSContext* cx, char16_t* chars, size_t length); - -extern JS_PUBLIC_API(JSString*) -JS_NewUCStringCopyN(JSContext* cx, const char16_t* s, size_t n); - -extern JS_PUBLIC_API(JSString*) -JS_NewUCStringCopyZ(JSContext* cx, const char16_t* s); - -extern JS_PUBLIC_API(JSString*) -JS_AtomizeUCStringN(JSContext* cx, const char16_t* s, size_t length); - -extern JS_PUBLIC_API(JSString*) -JS_AtomizeUCString(JSContext* cx, const char16_t* s); - -extern JS_PUBLIC_API(JSString*) -JS_AtomizeAndPinUCStringN(JSContext* cx, const char16_t* s, size_t length); - -extern JS_PUBLIC_API(JSString*) -JS_AtomizeAndPinUCString(JSContext* cx, const char16_t* s); - -extern JS_PUBLIC_API(bool) -JS_CompareStrings(JSContext* cx, JSString* str1, JSString* str2, int32_t* result); - -extern JS_PUBLIC_API(bool) -JS_StringEqualsAscii(JSContext* cx, JSString* str, const char* asciiBytes, bool* match); - -extern JS_PUBLIC_API(size_t) -JS_PutEscapedString(JSContext* cx, char* buffer, size_t size, JSString* str, char quote); - -extern JS_PUBLIC_API(bool) -JS_FileEscapedString(FILE* fp, JSString* str, char quote); - -/* - * Extracting string characters and length. - * - * While getting the length of a string is infallible, getting the chars can - * fail. As indicated by the lack of a JSContext parameter, there are two - * special cases where getting the chars is infallible: - * - * The first case is for strings that have been atomized, e.g. directly by - * JS_AtomizeAndPinString or implicitly because it is stored in a jsid. - * - * The second case is "flat" strings that have been explicitly prepared in a - * fallible context by JS_FlattenString. To catch errors, a separate opaque - * JSFlatString type is returned by JS_FlattenString and expected by - * JS_GetFlatStringChars. Note, though, that this is purely a syntactic - * distinction: the input and output of JS_FlattenString are the same actual - * GC-thing. If a JSString is known to be flat, JS_ASSERT_STRING_IS_FLAT can be - * used to make a debug-checked cast. Example: - * - * // in a fallible context - * JSFlatString* fstr = JS_FlattenString(cx, str); - * if (!fstr) - * return false; - * MOZ_ASSERT(fstr == JS_ASSERT_STRING_IS_FLAT(str)); - * - * // in an infallible context, for the same 'str' - * AutoCheckCannotGC nogc; - * const char16_t* chars = JS_GetTwoByteFlatStringChars(nogc, fstr) - * MOZ_ASSERT(chars); - * - * Flat strings and interned strings are always null-terminated, so - * JS_FlattenString can be used to get a null-terminated string. - * - * Additionally, string characters are stored as either Latin1Char (8-bit) - * or char16_t (16-bit). Clients can use JS_StringHasLatin1Chars and can then - * call either the Latin1* or TwoByte* functions. Some functions like - * JS_CopyStringChars and JS_GetStringCharAt accept both Latin1 and TwoByte - * strings. - */ - -extern JS_PUBLIC_API(size_t) -JS_GetStringLength(JSString* str); - -extern JS_PUBLIC_API(bool) -JS_StringIsFlat(JSString* str); - -/** Returns true iff the string's characters are stored as Latin1. */ -extern JS_PUBLIC_API(bool) -JS_StringHasLatin1Chars(JSString* str); - -extern JS_PUBLIC_API(const JS::Latin1Char*) -JS_GetLatin1StringCharsAndLength(JSContext* cx, const JS::AutoCheckCannotGC& nogc, JSString* str, - size_t* length); - -extern JS_PUBLIC_API(const char16_t*) -JS_GetTwoByteStringCharsAndLength(JSContext* cx, const JS::AutoCheckCannotGC& nogc, JSString* str, - size_t* length); - -extern JS_PUBLIC_API(bool) -JS_GetStringCharAt(JSContext* cx, JSString* str, size_t index, char16_t* res); - -extern JS_PUBLIC_API(char16_t) -JS_GetFlatStringCharAt(JSFlatString* str, size_t index); - -extern JS_PUBLIC_API(const char16_t*) -JS_GetTwoByteExternalStringChars(JSString* str); - -extern JS_PUBLIC_API(bool) -JS_CopyStringChars(JSContext* cx, mozilla::Range<char16_t> dest, JSString* str); - -extern JS_PUBLIC_API(JSFlatString*) -JS_FlattenString(JSContext* cx, JSString* str); - -extern JS_PUBLIC_API(const JS::Latin1Char*) -JS_GetLatin1FlatStringChars(const JS::AutoCheckCannotGC& nogc, JSFlatString* str); - -extern JS_PUBLIC_API(const char16_t*) -JS_GetTwoByteFlatStringChars(const JS::AutoCheckCannotGC& nogc, JSFlatString* str); - -static MOZ_ALWAYS_INLINE JSFlatString* -JSID_TO_FLAT_STRING(jsid id) -{ - MOZ_ASSERT(JSID_IS_STRING(id)); - return (JSFlatString*)(JSID_BITS(id)); -} - -static MOZ_ALWAYS_INLINE JSFlatString* -JS_ASSERT_STRING_IS_FLAT(JSString* str) -{ - MOZ_ASSERT(JS_StringIsFlat(str)); - return (JSFlatString*)str; -} - -static MOZ_ALWAYS_INLINE JSString* -JS_FORGET_STRING_FLATNESS(JSFlatString* fstr) -{ - return (JSString*)fstr; -} - -/* - * Additional APIs that avoid fallibility when given a flat string. - */ - -extern JS_PUBLIC_API(bool) -JS_FlatStringEqualsAscii(JSFlatString* str, const char* asciiBytes); - -extern JS_PUBLIC_API(size_t) -JS_PutEscapedFlatString(char* buffer, size_t size, JSFlatString* str, char quote); - -/** - * Create a dependent string, i.e., a string that owns no character storage, - * but that refers to a slice of another string's chars. Dependent strings - * are mutable by definition, so the thread safety comments above apply. - */ -extern JS_PUBLIC_API(JSString*) -JS_NewDependentString(JSContext* cx, JS::HandleString str, size_t start, - size_t length); - -/** - * Concatenate two strings, possibly resulting in a rope. - * See above for thread safety comments. - */ -extern JS_PUBLIC_API(JSString*) -JS_ConcatStrings(JSContext* cx, JS::HandleString left, JS::HandleString right); - -/** - * For JS_DecodeBytes, set *dstlenp to the size of the destination buffer before - * the call; on return, *dstlenp contains the number of characters actually - * stored. To determine the necessary destination buffer size, make a sizing - * call that passes nullptr for dst. - * - * On errors, the functions report the error. In that case, *dstlenp contains - * the number of characters or bytes transferred so far. If cx is nullptr, no - * error is reported on failure, and the functions simply return false. - * - * NB: This function does not store an additional zero byte or char16_t after the - * transcoded string. - */ -JS_PUBLIC_API(bool) -JS_DecodeBytes(JSContext* cx, const char* src, size_t srclen, char16_t* dst, - size_t* dstlenp); - -/** - * A variation on JS_EncodeCharacters where a null terminated string is - * returned that you are expected to call JS_free on when done. - */ -JS_PUBLIC_API(char*) -JS_EncodeString(JSContext* cx, JSString* str); - -/** - * Same behavior as JS_EncodeString(), but encode into UTF-8 string - */ -JS_PUBLIC_API(char*) -JS_EncodeStringToUTF8(JSContext* cx, JS::HandleString str); - -/** - * Get number of bytes in the string encoding (without accounting for a - * terminating zero bytes. The function returns (size_t) -1 if the string - * can not be encoded into bytes and reports an error using cx accordingly. - */ -JS_PUBLIC_API(size_t) -JS_GetStringEncodingLength(JSContext* cx, JSString* str); - -/** - * Encode string into a buffer. The function does not stores an additional - * zero byte. The function returns (size_t) -1 if the string can not be - * encoded into bytes with no error reported. Otherwise it returns the number - * of bytes that are necessary to encode the string. If that exceeds the - * length parameter, the string will be cut and only length bytes will be - * written into the buffer. - */ -JS_PUBLIC_API(size_t) -JS_EncodeStringToBuffer(JSContext* cx, JSString* str, char* buffer, size_t length); - -class MOZ_RAII JSAutoByteString -{ - public: - JSAutoByteString(JSContext* cx, JSString* str - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : mBytes(JS_EncodeString(cx, str)) - { - MOZ_ASSERT(cx); - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - explicit JSAutoByteString(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) - : mBytes(nullptr) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - ~JSAutoByteString() { - JS_free(nullptr, mBytes); - } - - /* Take ownership of the given byte array. */ - void initBytes(char* bytes) { - MOZ_ASSERT(!mBytes); - mBytes = bytes; - } - - char* encodeLatin1(JSContext* cx, JSString* str) { - MOZ_ASSERT(!mBytes); - MOZ_ASSERT(cx); - mBytes = JS_EncodeString(cx, str); - return mBytes; - } - - char* encodeLatin1(js::ExclusiveContext* cx, JSString* str); - - char* encodeUtf8(JSContext* cx, JS::HandleString str) { - MOZ_ASSERT(!mBytes); - MOZ_ASSERT(cx); - mBytes = JS_EncodeStringToUTF8(cx, str); - return mBytes; - } - - void clear() { - js_free(mBytes); - mBytes = nullptr; - } - - char* ptr() const { - return mBytes; - } - - bool operator!() const { - return !mBytes; - } - - size_t length() const { - if (!mBytes) - return 0; - return strlen(mBytes); - } - - private: - char* mBytes; - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER - - /* Copy and assignment are not supported. */ - JSAutoByteString(const JSAutoByteString& another); - JSAutoByteString& operator=(const JSAutoByteString& another); -}; - -namespace JS { - -extern JS_PUBLIC_API(JSAddonId*) -NewAddonId(JSContext* cx, JS::HandleString str); - -extern JS_PUBLIC_API(JSString*) -StringOfAddonId(JSAddonId* id); - -extern JS_PUBLIC_API(JSAddonId*) -AddonIdOfObject(JSObject* obj); - -} // namespace JS - -/************************************************************************/ -/* - * Symbols - */ - -namespace JS { - -/** - * Create a new Symbol with the given description. This function never returns - * a Symbol that is in the Runtime-wide symbol registry. - * - * If description is null, the new Symbol's [[Description]] attribute is - * undefined. - */ -JS_PUBLIC_API(Symbol*) -NewSymbol(JSContext* cx, HandleString description); - -/** - * Symbol.for as specified in ES6. - * - * Get a Symbol with the description 'key' from the Runtime-wide symbol registry. - * If there is not already a Symbol with that description in the registry, a new - * Symbol is created and registered. 'key' must not be null. - */ -JS_PUBLIC_API(Symbol*) -GetSymbolFor(JSContext* cx, HandleString key); - -/** - * Get the [[Description]] attribute of the given symbol. - * - * This function is infallible. If it returns null, that means the symbol's - * [[Description]] is undefined. - */ -JS_PUBLIC_API(JSString*) -GetSymbolDescription(HandleSymbol symbol); - -/* Well-known symbols. */ -#define JS_FOR_EACH_WELL_KNOWN_SYMBOL(macro) \ - macro(isConcatSpreadable) \ - macro(iterator) \ - macro(match) \ - macro(replace) \ - macro(search) \ - macro(species) \ - macro(hasInstance) \ - macro(split) \ - macro(toPrimitive) \ - macro(toStringTag) \ - macro(unscopables) - -enum class SymbolCode : uint32_t { - // There is one SymbolCode for each well-known symbol. -#define JS_DEFINE_SYMBOL_ENUM(name) name, - JS_FOR_EACH_WELL_KNOWN_SYMBOL(JS_DEFINE_SYMBOL_ENUM) // SymbolCode::iterator, etc. -#undef JS_DEFINE_SYMBOL_ENUM - Limit, - InSymbolRegistry = 0xfffffffe, // created by Symbol.for() or JS::GetSymbolFor() - UniqueSymbol = 0xffffffff // created by Symbol() or JS::NewSymbol() -}; - -/* For use in loops that iterate over the well-known symbols. */ -const size_t WellKnownSymbolLimit = size_t(SymbolCode::Limit); - -/** - * Return the SymbolCode telling what sort of symbol `symbol` is. - * - * A symbol's SymbolCode never changes once it is created. - */ -JS_PUBLIC_API(SymbolCode) -GetSymbolCode(Handle<Symbol*> symbol); - -/** - * Get one of the well-known symbols defined by ES6. A single set of well-known - * symbols is shared by all compartments in a JSRuntime. - * - * `which` must be in the range [0, WellKnownSymbolLimit). - */ -JS_PUBLIC_API(Symbol*) -GetWellKnownSymbol(JSContext* cx, SymbolCode which); - -/** - * Return true if the given JSPropertySpec::name or JSFunctionSpec::name value - * is actually a symbol code and not a string. See JS_SYM_FN. - */ -inline bool -PropertySpecNameIsSymbol(const char* name) -{ - uintptr_t u = reinterpret_cast<uintptr_t>(name); - return u != 0 && u - 1 < WellKnownSymbolLimit; -} - -JS_PUBLIC_API(bool) -PropertySpecNameEqualsId(const char* name, HandleId id); - -/** - * Create a jsid that does not need to be marked for GC. - * - * 'name' is a JSPropertySpec::name or JSFunctionSpec::name value. The - * resulting jsid, on success, is either an interned string or a well-known - * symbol; either way it is immune to GC so there is no need to visit *idp - * during GC marking. - */ -JS_PUBLIC_API(bool) -PropertySpecNameToPermanentId(JSContext* cx, const char* name, jsid* idp); - -} /* namespace JS */ - -/************************************************************************/ -/* - * JSON functions - */ -typedef bool (* JSONWriteCallback)(const char16_t* buf, uint32_t len, void* data); - -/** - * JSON.stringify as specified by ES5. - */ -JS_PUBLIC_API(bool) -JS_Stringify(JSContext* cx, JS::MutableHandleValue value, JS::HandleObject replacer, - JS::HandleValue space, JSONWriteCallback callback, void* data); - -namespace JS { - -/** - * An API akin to JS_Stringify but with the goal of not having observable - * side-effects when the stringification is performed. This means it does not - * allow a replacer or a custom space, and has the following constraints on its - * input: - * - * 1) The input must be a plain object or array, not an abitrary value. - * 2) Every value in the graph reached by the algorithm starting with this - * object must be one of the following: null, undefined, a string (NOT a - * string object!), a boolean, a finite number (i.e. no NaN or Infinity or - * -Infinity), a plain object with no accessor properties, or an Array with - * no holes. - * - * The actual behavior differs from JS_Stringify only in asserting the above and - * NOT attempting to get the "toJSON" property from things, since that could - * clearly have side-effects. - */ -JS_PUBLIC_API(bool) -ToJSONMaybeSafely(JSContext* cx, JS::HandleObject input, - JSONWriteCallback callback, void* data); - -} /* namespace JS */ - -/** - * JSON.parse as specified by ES5. - */ -JS_PUBLIC_API(bool) -JS_ParseJSON(JSContext* cx, const char16_t* chars, uint32_t len, JS::MutableHandleValue vp); - -JS_PUBLIC_API(bool) -JS_ParseJSON(JSContext* cx, JS::HandleString str, JS::MutableHandleValue vp); - -JS_PUBLIC_API(bool) -JS_ParseJSONWithReviver(JSContext* cx, const char16_t* chars, uint32_t len, JS::HandleValue reviver, - JS::MutableHandleValue vp); - -JS_PUBLIC_API(bool) -JS_ParseJSONWithReviver(JSContext* cx, JS::HandleString str, JS::HandleValue reviver, - JS::MutableHandleValue vp); - -/************************************************************************/ - -/** - * The default locale for the ECMAScript Internationalization API - * (Intl.Collator, Intl.NumberFormat, Intl.DateTimeFormat). - * Note that the Internationalization API encourages clients to - * specify their own locales. - * The locale string remains owned by the caller. - */ -extern JS_PUBLIC_API(bool) -JS_SetDefaultLocale(JSContext* cx, const char* locale); - -/** - * Look up the default locale for the ECMAScript Internationalization API. - */ -extern JS_PUBLIC_API(JS::UniqueChars) -JS_GetDefaultLocale(JSContext* cx); - -/** - * Reset the default locale to OS defaults. - */ -extern JS_PUBLIC_API(void) -JS_ResetDefaultLocale(JSContext* cx); - -/** - * Locale specific string conversion and error message callbacks. - */ -struct JSLocaleCallbacks { - JSLocaleToUpperCase localeToUpperCase; - JSLocaleToLowerCase localeToLowerCase; - JSLocaleCompare localeCompare; // not used #if EXPOSE_INTL_API - JSLocaleToUnicode localeToUnicode; -}; - -/** - * Establish locale callbacks. The pointer must persist as long as the - * JSContext. Passing nullptr restores the default behaviour. - */ -extern JS_PUBLIC_API(void) -JS_SetLocaleCallbacks(JSContext* cx, const JSLocaleCallbacks* callbacks); - -/** - * Return the address of the current locale callbacks struct, which may - * be nullptr. - */ -extern JS_PUBLIC_API(const JSLocaleCallbacks*) -JS_GetLocaleCallbacks(JSContext* cx); - -/************************************************************************/ - -/* - * Error reporting. - */ - -namespace JS { -const uint16_t MaxNumErrorArguments = 10; -}; - -/** - * Report an exception represented by the sprintf-like conversion of format - * and its arguments. - */ -extern JS_PUBLIC_API(void) -JS_ReportErrorASCII(JSContext* cx, const char* format, ...) - MOZ_FORMAT_PRINTF(2, 3); - -extern JS_PUBLIC_API(void) -JS_ReportErrorLatin1(JSContext* cx, const char* format, ...) - MOZ_FORMAT_PRINTF(2, 3); - -extern JS_PUBLIC_API(void) -JS_ReportErrorUTF8(JSContext* cx, const char* format, ...) - MOZ_FORMAT_PRINTF(2, 3); - -/* - * Use an errorNumber to retrieve the format string, args are char* - */ -extern JS_PUBLIC_API(void) -JS_ReportErrorNumberASCII(JSContext* cx, JSErrorCallback errorCallback, - void* userRef, const unsigned errorNumber, ...); - -extern JS_PUBLIC_API(void) -JS_ReportErrorNumberASCIIVA(JSContext* cx, JSErrorCallback errorCallback, - void* userRef, const unsigned errorNumber, va_list ap); - -extern JS_PUBLIC_API(void) -JS_ReportErrorNumberLatin1(JSContext* cx, JSErrorCallback errorCallback, - void* userRef, const unsigned errorNumber, ...); - -#ifdef va_start -extern JS_PUBLIC_API(void) -JS_ReportErrorNumberLatin1VA(JSContext* cx, JSErrorCallback errorCallback, - void* userRef, const unsigned errorNumber, va_list ap); -#endif - -extern JS_PUBLIC_API(void) -JS_ReportErrorNumberUTF8(JSContext* cx, JSErrorCallback errorCallback, - void* userRef, const unsigned errorNumber, ...); - -#ifdef va_start -extern JS_PUBLIC_API(void) -JS_ReportErrorNumberUTF8VA(JSContext* cx, JSErrorCallback errorCallback, - void* userRef, const unsigned errorNumber, va_list ap); -#endif - -/* - * Use an errorNumber to retrieve the format string, args are char16_t* - */ -extern JS_PUBLIC_API(void) -JS_ReportErrorNumberUC(JSContext* cx, JSErrorCallback errorCallback, - void* userRef, const unsigned errorNumber, ...); - -extern JS_PUBLIC_API(void) -JS_ReportErrorNumberUCArray(JSContext* cx, JSErrorCallback errorCallback, - void* userRef, const unsigned errorNumber, - const char16_t** args); - -/** - * As above, but report a warning instead (JSREPORT_IS_WARNING(report.flags)). - * Return true if there was no error trying to issue the warning, and if the - * warning was not converted into an error due to the JSOPTION_WERROR option - * being set, false otherwise. - */ -extern JS_PUBLIC_API(bool) -JS_ReportWarningASCII(JSContext* cx, const char* format, ...) - MOZ_FORMAT_PRINTF(2, 3); - -extern JS_PUBLIC_API(bool) -JS_ReportWarningLatin1(JSContext* cx, const char* format, ...) - MOZ_FORMAT_PRINTF(2, 3); - -extern JS_PUBLIC_API(bool) -JS_ReportWarningUTF8(JSContext* cx, const char* format, ...) - MOZ_FORMAT_PRINTF(2, 3); - -extern JS_PUBLIC_API(bool) -JS_ReportErrorFlagsAndNumberASCII(JSContext* cx, unsigned flags, - JSErrorCallback errorCallback, void* userRef, - const unsigned errorNumber, ...); - -extern JS_PUBLIC_API(bool) -JS_ReportErrorFlagsAndNumberLatin1(JSContext* cx, unsigned flags, - JSErrorCallback errorCallback, void* userRef, - const unsigned errorNumber, ...); - -extern JS_PUBLIC_API(bool) -JS_ReportErrorFlagsAndNumberUTF8(JSContext* cx, unsigned flags, - JSErrorCallback errorCallback, void* userRef, - const unsigned errorNumber, ...); - -extern JS_PUBLIC_API(bool) -JS_ReportErrorFlagsAndNumberUC(JSContext* cx, unsigned flags, - JSErrorCallback errorCallback, void* userRef, - const unsigned errorNumber, ...); - -/** - * Complain when out of memory. - */ -extern JS_PUBLIC_API(void) -JS_ReportOutOfMemory(JSContext* cx); - -/** - * Complain when an allocation size overflows the maximum supported limit. - */ -extern JS_PUBLIC_API(void) -JS_ReportAllocationOverflow(JSContext* cx); - -class JSErrorReport -{ - // The (default) error message. - // If ownsMessage_ is true, the it is freed in destructor. - JS::ConstUTF8CharsZ message_; - - // Offending source line without final '\n'. - // If ownsLinebuf__ is true, the buffer is freed in destructor. - const char16_t* linebuf_; - - // Number of chars in linebuf_. Does not include trailing '\0'. - size_t linebufLength_; - - // The 0-based offset of error token in linebuf_. - size_t tokenOffset_; - - public: - JSErrorReport() - : linebuf_(nullptr), linebufLength_(0), tokenOffset_(0), - filename(nullptr), lineno(0), column(0), - flags(0), errorNumber(0), - exnType(0), isMuted(false), - ownsLinebuf_(false), ownsMessage_(false) - {} - - ~JSErrorReport() { - freeLinebuf(); - freeMessage(); - } - - const char* filename; /* source file name, URL, etc., or null */ - unsigned lineno; /* source line number */ - unsigned column; /* zero-based column index in line */ - unsigned flags; /* error/warning, etc. */ - unsigned errorNumber; /* the error number, e.g. see js.msg */ - int16_t exnType; /* One of the JSExnType constants */ - bool isMuted : 1; /* See the comment in ReadOnlyCompileOptions. */ - - private: - bool ownsLinebuf_ : 1; - bool ownsMessage_ : 1; - - public: - const char16_t* linebuf() const { - return linebuf_; - } - size_t linebufLength() const { - return linebufLength_; - } - size_t tokenOffset() const { - return tokenOffset_; - } - void initOwnedLinebuf(const char16_t* linebufArg, size_t linebufLengthArg, size_t tokenOffsetArg) { - initBorrowedLinebuf(linebufArg, linebufLengthArg, tokenOffsetArg); - ownsLinebuf_ = true; - } - void initBorrowedLinebuf(const char16_t* linebufArg, size_t linebufLengthArg, size_t tokenOffsetArg); - void freeLinebuf(); - - const JS::ConstUTF8CharsZ message() const { - return message_; - } - - void initOwnedMessage(const char* messageArg) { - initBorrowedMessage(messageArg); - ownsMessage_ = true; - } - void initBorrowedMessage(const char* messageArg) { - MOZ_ASSERT(!message_); - message_ = JS::ConstUTF8CharsZ(messageArg, strlen(messageArg)); - } - - JSString* newMessageString(JSContext* cx); - - void freeMessage(); -}; - -/* - * JSErrorReport flag values. These may be freely composed. - */ -#define JSREPORT_ERROR 0x0 /* pseudo-flag for default case */ -#define JSREPORT_WARNING 0x1 /* reported via JS_ReportWarning */ -#define JSREPORT_EXCEPTION 0x2 /* exception was thrown */ -#define JSREPORT_STRICT 0x4 /* error or warning due to strict option */ - -#define JSREPORT_USER_1 0x8 /* user-defined flag */ - -/* - * If JSREPORT_EXCEPTION is set, then a JavaScript-catchable exception - * has been thrown for this runtime error, and the host should ignore it. - * Exception-aware hosts should also check for JS_IsExceptionPending if - * JS_ExecuteScript returns failure, and signal or propagate the exception, as - * appropriate. - */ -#define JSREPORT_IS_WARNING(flags) (((flags) & JSREPORT_WARNING) != 0) -#define JSREPORT_IS_EXCEPTION(flags) (((flags) & JSREPORT_EXCEPTION) != 0) -#define JSREPORT_IS_STRICT(flags) (((flags) & JSREPORT_STRICT) != 0) - -namespace JS { - -using WarningReporter = void (*)(JSContext* cx, JSErrorReport* report); - -extern JS_PUBLIC_API(WarningReporter) -SetWarningReporter(JSContext* cx, WarningReporter reporter); - -extern JS_PUBLIC_API(WarningReporter) -GetWarningReporter(JSContext* cx); - -extern JS_PUBLIC_API(bool) -CreateError(JSContext* cx, JSExnType type, HandleObject stack, - HandleString fileName, uint32_t lineNumber, uint32_t columnNumber, - JSErrorReport* report, HandleString message, MutableHandleValue rval); - -/************************************************************************/ - -/* - * Weak Maps. - */ - -extern JS_PUBLIC_API(JSObject*) -NewWeakMapObject(JSContext* cx); - -extern JS_PUBLIC_API(bool) -IsWeakMapObject(JSObject* obj); - -extern JS_PUBLIC_API(bool) -GetWeakMapEntry(JSContext* cx, JS::HandleObject mapObj, JS::HandleObject key, - JS::MutableHandleValue val); - -extern JS_PUBLIC_API(bool) -SetWeakMapEntry(JSContext* cx, JS::HandleObject mapObj, JS::HandleObject key, - JS::HandleValue val); - -/* - * Map - */ -extern JS_PUBLIC_API(JSObject*) -NewMapObject(JSContext* cx); - -extern JS_PUBLIC_API(uint32_t) -MapSize(JSContext* cx, HandleObject obj); - -extern JS_PUBLIC_API(bool) -MapGet(JSContext* cx, HandleObject obj, - HandleValue key, MutableHandleValue rval); - -extern JS_PUBLIC_API(bool) -MapHas(JSContext* cx, HandleObject obj, HandleValue key, bool* rval); - -extern JS_PUBLIC_API(bool) -MapSet(JSContext* cx, HandleObject obj, HandleValue key, HandleValue val); - -extern JS_PUBLIC_API(bool) -MapDelete(JSContext *cx, HandleObject obj, HandleValue key, bool *rval); - -extern JS_PUBLIC_API(bool) -MapClear(JSContext* cx, HandleObject obj); - -extern JS_PUBLIC_API(bool) -MapKeys(JSContext* cx, HandleObject obj, MutableHandleValue rval); - -extern JS_PUBLIC_API(bool) -MapValues(JSContext* cx, HandleObject obj, MutableHandleValue rval); - -extern JS_PUBLIC_API(bool) -MapEntries(JSContext* cx, HandleObject obj, MutableHandleValue rval); - -extern JS_PUBLIC_API(bool) -MapForEach(JSContext *cx, HandleObject obj, HandleValue callbackFn, HandleValue thisVal); - -/* - * Set - */ -extern JS_PUBLIC_API(JSObject *) -NewSetObject(JSContext *cx); - -extern JS_PUBLIC_API(uint32_t) -SetSize(JSContext *cx, HandleObject obj); - -extern JS_PUBLIC_API(bool) -SetHas(JSContext *cx, HandleObject obj, HandleValue key, bool *rval); - -extern JS_PUBLIC_API(bool) -SetDelete(JSContext *cx, HandleObject obj, HandleValue key, bool *rval); - -extern JS_PUBLIC_API(bool) -SetAdd(JSContext *cx, HandleObject obj, HandleValue key); - -extern JS_PUBLIC_API(bool) -SetClear(JSContext *cx, HandleObject obj); - -extern JS_PUBLIC_API(bool) -SetKeys(JSContext *cx, HandleObject obj, MutableHandleValue rval); - -extern JS_PUBLIC_API(bool) -SetValues(JSContext *cx, HandleObject obj, MutableHandleValue rval); - -extern JS_PUBLIC_API(bool) -SetEntries(JSContext *cx, HandleObject obj, MutableHandleValue rval); - -extern JS_PUBLIC_API(bool) -SetForEach(JSContext *cx, HandleObject obj, HandleValue callbackFn, HandleValue thisVal); - -} /* namespace JS */ - -/* - * Dates. - */ - -extern JS_PUBLIC_API(JSObject*) -JS_NewDateObject(JSContext* cx, int year, int mon, int mday, int hour, int min, int sec); - -/** - * Returns true and sets |*isDate| indicating whether |obj| is a Date object or - * a wrapper around one, otherwise returns false on failure. - * - * This method returns true with |*isDate == false| when passed a proxy whose - * target is a Date, or when passed a revoked proxy. - */ -extern JS_PUBLIC_API(bool) -JS_ObjectIsDate(JSContext* cx, JS::HandleObject obj, bool* isDate); - -/************************************************************************/ - -/* - * Regular Expressions. - */ -#define JSREG_FOLD 0x01u /* fold uppercase to lowercase */ -#define JSREG_GLOB 0x02u /* global exec, creates array of matches */ -#define JSREG_MULTILINE 0x04u /* treat ^ and $ as begin and end of line */ -#define JSREG_STICKY 0x08u /* only match starting at lastIndex */ -#define JSREG_UNICODE 0x10u /* unicode */ - -extern JS_PUBLIC_API(JSObject*) -JS_NewRegExpObject(JSContext* cx, const char* bytes, size_t length, unsigned flags); - -extern JS_PUBLIC_API(JSObject*) -JS_NewUCRegExpObject(JSContext* cx, const char16_t* chars, size_t length, unsigned flags); - -extern JS_PUBLIC_API(bool) -JS_SetRegExpInput(JSContext* cx, JS::HandleObject obj, JS::HandleString input); - -extern JS_PUBLIC_API(bool) -JS_ClearRegExpStatics(JSContext* cx, JS::HandleObject obj); - -extern JS_PUBLIC_API(bool) -JS_ExecuteRegExp(JSContext* cx, JS::HandleObject obj, JS::HandleObject reobj, - char16_t* chars, size_t length, size_t* indexp, bool test, - JS::MutableHandleValue rval); - -/* RegExp interface for clients without a global object. */ - -extern JS_PUBLIC_API(bool) -JS_ExecuteRegExpNoStatics(JSContext* cx, JS::HandleObject reobj, char16_t* chars, size_t length, - size_t* indexp, bool test, JS::MutableHandleValue rval); - -/** - * Returns true and sets |*isRegExp| indicating whether |obj| is a RegExp - * object or a wrapper around one, otherwise returns false on failure. - * - * This method returns true with |*isRegExp == false| when passed a proxy whose - * target is a RegExp, or when passed a revoked proxy. - */ -extern JS_PUBLIC_API(bool) -JS_ObjectIsRegExp(JSContext* cx, JS::HandleObject obj, bool* isRegExp); - -extern JS_PUBLIC_API(unsigned) -JS_GetRegExpFlags(JSContext* cx, JS::HandleObject obj); - -extern JS_PUBLIC_API(JSString*) -JS_GetRegExpSource(JSContext* cx, JS::HandleObject obj); - -/************************************************************************/ - -extern JS_PUBLIC_API(bool) -JS_IsExceptionPending(JSContext* cx); - -extern JS_PUBLIC_API(bool) -JS_GetPendingException(JSContext* cx, JS::MutableHandleValue vp); - -extern JS_PUBLIC_API(void) -JS_SetPendingException(JSContext* cx, JS::HandleValue v); - -extern JS_PUBLIC_API(void) -JS_ClearPendingException(JSContext* cx); - -namespace JS { - -/** - * Save and later restore the current exception state of a given JSContext. - * This is useful for implementing behavior in C++ that's like try/catch - * or try/finally in JS. - * - * Typical usage: - * - * bool ok = JS::Evaluate(cx, ...); - * AutoSaveExceptionState savedExc(cx); - * ... cleanup that might re-enter JS ... - * return ok; - */ -class JS_PUBLIC_API(AutoSaveExceptionState) -{ - private: - JSContext* context; - bool wasPropagatingForcedReturn; - bool wasOverRecursed; - bool wasThrowing; - RootedValue exceptionValue; - - public: - /* - * Take a snapshot of cx's current exception state. Then clear any current - * pending exception in cx. - */ - explicit AutoSaveExceptionState(JSContext* cx); - - /* - * If neither drop() nor restore() was called, restore the exception - * state only if no exception is currently pending on cx. - */ - ~AutoSaveExceptionState(); - - /* - * Discard any stored exception state. - * If this is called, the destructor is a no-op. - */ - void drop() { - wasPropagatingForcedReturn = false; - wasOverRecursed = false; - wasThrowing = false; - exceptionValue.setUndefined(); - } - - /* - * Replace cx's exception state with the stored exception state. Then - * discard the stored exception state. If this is called, the - * destructor is a no-op. - */ - void restore(); -}; - -} /* namespace JS */ - -/* Deprecated API. Use AutoSaveExceptionState instead. */ -extern JS_PUBLIC_API(JSExceptionState*) -JS_SaveExceptionState(JSContext* cx); - -extern JS_PUBLIC_API(void) -JS_RestoreExceptionState(JSContext* cx, JSExceptionState* state); - -extern JS_PUBLIC_API(void) -JS_DropExceptionState(JSContext* cx, JSExceptionState* state); - -/** - * If the given object is an exception object, the exception will have (or be - * able to lazily create) an error report struct, and this function will return - * the address of that struct. Otherwise, it returns nullptr. The lifetime - * of the error report struct that might be returned is the same as the - * lifetime of the exception object. - */ -extern JS_PUBLIC_API(JSErrorReport*) -JS_ErrorFromException(JSContext* cx, JS::HandleObject obj); - -/** - * If the given object is an exception object (or an unwrappable - * cross-compartment wrapper for one), return the stack for that exception, if - * any. Will return null if the given object is not an exception object - * (including if it's null or a security wrapper that can't be unwrapped) or if - * the exception has no stack. - */ -extern JS_PUBLIC_API(JSObject*) -ExceptionStackOrNull(JS::HandleObject obj); - -/* - * Throws a StopIteration exception on cx. - */ -extern JS_PUBLIC_API(bool) -JS_ThrowStopIteration(JSContext* cx); - -extern JS_PUBLIC_API(bool) -JS_IsStopIteration(const JS::Value& v); - -/** - * A JS context always has an "owner thread". The owner thread is set when the - * context is created (to the current thread) and practically all entry points - * into the JS engine check that a context (or anything contained in the - * context: runtime, compartment, object, etc) is only touched by its owner - * thread. Embeddings may check this invariant outside the JS engine by calling - * JS_AbortIfWrongThread (which will abort if not on the owner thread, even for - * non-debug builds). - */ - -extern JS_PUBLIC_API(void) -JS_AbortIfWrongThread(JSContext* cx); - -/************************************************************************/ - -/** - * A constructor can request that the JS engine create a default new 'this' - * object of the given class, using the callee to determine parentage and - * [[Prototype]]. - */ -extern JS_PUBLIC_API(JSObject*) -JS_NewObjectForConstructor(JSContext* cx, const JSClass* clasp, const JS::CallArgs& args); - -/************************************************************************/ - -#ifdef JS_GC_ZEAL -#define JS_DEFAULT_ZEAL_FREQ 100 - -extern JS_PUBLIC_API(void) -JS_GetGCZealBits(JSContext* cx, uint32_t* zealBits, uint32_t* frequency, uint32_t* nextScheduled); - -extern JS_PUBLIC_API(void) -JS_SetGCZeal(JSContext* cx, uint8_t zeal, uint32_t frequency); - -extern JS_PUBLIC_API(void) -JS_ScheduleGC(JSContext* cx, uint32_t count); -#endif - -extern JS_PUBLIC_API(void) -JS_SetParallelParsingEnabled(JSContext* cx, bool enabled); - -extern JS_PUBLIC_API(void) -JS_SetOffthreadIonCompilationEnabled(JSContext* cx, bool enabled); - -#define JIT_COMPILER_OPTIONS(Register) \ - Register(BASELINE_WARMUP_TRIGGER, "baseline.warmup.trigger") \ - Register(ION_WARMUP_TRIGGER, "ion.warmup.trigger") \ - Register(ION_GVN_ENABLE, "ion.gvn.enable") \ - Register(ION_FORCE_IC, "ion.forceinlineCaches") \ - Register(ION_ENABLE, "ion.enable") \ - Register(ION_INTERRUPT_WITHOUT_SIGNAL, "ion.interrupt-without-signals") \ - Register(ION_CHECK_RANGE_ANALYSIS, "ion.check-range-analysis") \ - Register(BASELINE_ENABLE, "baseline.enable") \ - Register(OFFTHREAD_COMPILATION_ENABLE, "offthread-compilation.enable") \ - Register(JUMP_THRESHOLD, "jump-threshold") \ - Register(ASMJS_ATOMICS_ENABLE, "asmjs.atomics.enable") \ - Register(WASM_TEST_MODE, "wasm.test-mode") \ - Register(WASM_FOLD_OFFSETS, "wasm.fold-offsets") - -typedef enum JSJitCompilerOption { -#define JIT_COMPILER_DECLARE(key, str) \ - JSJITCOMPILER_ ## key, - - JIT_COMPILER_OPTIONS(JIT_COMPILER_DECLARE) -#undef JIT_COMPILER_DECLARE - - JSJITCOMPILER_NOT_AN_OPTION -} JSJitCompilerOption; - -extern JS_PUBLIC_API(void) -JS_SetGlobalJitCompilerOption(JSContext* cx, JSJitCompilerOption opt, uint32_t value); -extern JS_PUBLIC_API(bool) -JS_GetGlobalJitCompilerOption(JSContext* cx, JSJitCompilerOption opt, uint32_t* valueOut); - -/** - * Convert a uint32_t index into a jsid. - */ -extern JS_PUBLIC_API(bool) -JS_IndexToId(JSContext* cx, uint32_t index, JS::MutableHandleId); - -/** - * Convert chars into a jsid. - * - * |chars| may not be an index. - */ -extern JS_PUBLIC_API(bool) -JS_CharsToId(JSContext* cx, JS::TwoByteChars chars, JS::MutableHandleId); - -/** - * Test if the given string is a valid ECMAScript identifier - */ -extern JS_PUBLIC_API(bool) -JS_IsIdentifier(JSContext* cx, JS::HandleString str, bool* isIdentifier); - -/** - * Test whether the given chars + length are a valid ECMAScript identifier. - * This version is infallible, so just returns whether the chars are an - * identifier. - */ -extern JS_PUBLIC_API(bool) -JS_IsIdentifier(const char16_t* chars, size_t length); - -namespace js { -class ScriptSource; -} // namespace js - -namespace JS { - -class MOZ_RAII JS_PUBLIC_API(AutoFilename) -{ - private: - js::ScriptSource* ss_; - mozilla::Variant<const char*, UniqueChars> filename_; - - AutoFilename(const AutoFilename&) = delete; - AutoFilename& operator=(const AutoFilename&) = delete; - - public: - AutoFilename() - : ss_(nullptr), - filename_(mozilla::AsVariant<const char*>(nullptr)) - {} - - ~AutoFilename() { - reset(); - } - - void reset(); - - void setOwned(UniqueChars&& filename); - void setUnowned(const char* filename); - void setScriptSource(js::ScriptSource* ss); - - const char* get() const; -}; - -/** - * Return the current filename, line number and column number of the most - * currently running frame. Returns true if a scripted frame was found, false - * otherwise. - * - * If a the embedding has hidden the scripted caller for the topmost activation - * record, this will also return false. - */ -extern JS_PUBLIC_API(bool) -DescribeScriptedCaller(JSContext* cx, AutoFilename* filename = nullptr, - unsigned* lineno = nullptr, unsigned* column = nullptr); - -extern JS_PUBLIC_API(JSObject*) -GetScriptedCallerGlobal(JSContext* cx); - -/** - * Informs the JS engine that the scripted caller should be hidden. This can be - * used by the embedding to maintain an override of the scripted caller in its - * calculations, by hiding the scripted caller in the JS engine and pushing data - * onto a separate stack, which it inspects when DescribeScriptedCaller returns - * null. - * - * We maintain a counter on each activation record. Add() increments the counter - * of the topmost activation, and Remove() decrements it. The count may never - * drop below zero, and must always be exactly zero when the activation is - * popped from the stack. - */ -extern JS_PUBLIC_API(void) -HideScriptedCaller(JSContext* cx); - -extern JS_PUBLIC_API(void) -UnhideScriptedCaller(JSContext* cx); - -class MOZ_RAII AutoHideScriptedCaller -{ - public: - explicit AutoHideScriptedCaller(JSContext* cx - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : mContext(cx) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - HideScriptedCaller(mContext); - } - ~AutoHideScriptedCaller() { - UnhideScriptedCaller(mContext); - } - - protected: - JSContext* mContext; - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -/* - * Encode/Decode interpreted scripts and functions to/from memory. - */ - -typedef mozilla::Vector<uint8_t> TranscodeBuffer; - -enum TranscodeResult -{ - // Successful encoding / decoding. - TranscodeResult_Ok = 0, - - // A warning message, is set to the message out-param. - TranscodeResult_Failure = 0x100, - TranscodeResult_Failure_BadBuildId = TranscodeResult_Failure | 0x1, - TranscodeResult_Failure_RunOnceNotSupported = TranscodeResult_Failure | 0x2, - TranscodeResult_Failure_AsmJSNotSupported = TranscodeResult_Failure | 0x3, - TranscodeResult_Failure_UnknownClassKind = TranscodeResult_Failure | 0x4, - - // A error, the JSContext has a pending exception. - TranscodeResult_Throw = 0x200 -}; - -extern JS_PUBLIC_API(TranscodeResult) -EncodeScript(JSContext* cx, TranscodeBuffer& buffer, JS::HandleScript script); - -extern JS_PUBLIC_API(TranscodeResult) -EncodeInterpretedFunction(JSContext* cx, TranscodeBuffer& buffer, JS::HandleObject funobj); - -extern JS_PUBLIC_API(TranscodeResult) -DecodeScript(JSContext* cx, TranscodeBuffer& buffer, JS::MutableHandleScript scriptp, - size_t cursorIndex = 0); - -extern JS_PUBLIC_API(TranscodeResult) -DecodeInterpretedFunction(JSContext* cx, TranscodeBuffer& buffer, JS::MutableHandleFunction funp, - size_t cursorIndex = 0); - -} /* namespace JS */ - -namespace js { - -enum class StackFormat { SpiderMonkey, V8, Default }; - -/* - * Sets the format used for stringifying Error stacks. - * - * The default format is StackFormat::SpiderMonkey. Use StackFormat::V8 - * in order to emulate V8's stack formatting. StackFormat::Default can't be - * used here. - */ -extern JS_PUBLIC_API(void) -SetStackFormat(JSContext* cx, StackFormat format); - -extern JS_PUBLIC_API(StackFormat) -GetStackFormat(JSContext* cx); - -} - -namespace JS { - -/* - * This callback represents a request by the JS engine to open for reading the - * existing cache entry for the given global and char range that may contain a - * module. If a cache entry exists, the callback shall return 'true' and return - * the size, base address and an opaque file handle as outparams. If the - * callback returns 'true', the JS engine guarantees a call to - * CloseAsmJSCacheEntryForReadOp, passing the same base address, size and - * handle. - */ -typedef bool -(* OpenAsmJSCacheEntryForReadOp)(HandleObject global, const char16_t* begin, const char16_t* limit, - size_t* size, const uint8_t** memory, intptr_t* handle); -typedef void -(* CloseAsmJSCacheEntryForReadOp)(size_t size, const uint8_t* memory, intptr_t handle); - -/** The list of reasons why an asm.js module may not be stored in the cache. */ -enum AsmJSCacheResult -{ - AsmJSCache_Success, - AsmJSCache_MIN = AsmJSCache_Success, - AsmJSCache_ModuleTooSmall, - AsmJSCache_SynchronousScript, - AsmJSCache_QuotaExceeded, - AsmJSCache_StorageInitFailure, - AsmJSCache_Disabled_Internal, - AsmJSCache_Disabled_ShellFlags, - AsmJSCache_Disabled_JitInspector, - AsmJSCache_InternalError, - AsmJSCache_Disabled_PrivateBrowsing, - AsmJSCache_LIMIT -}; - -/* - * This callback represents a request by the JS engine to open for writing a - * cache entry of the given size for the given global and char range containing - * the just-compiled module. If cache entry space is available, the callback - * shall return 'true' and return the base address and an opaque file handle as - * outparams. If the callback returns 'true', the JS engine guarantees a call - * to CloseAsmJSCacheEntryForWriteOp passing the same base address, size and - * handle. - * - * If 'installed' is true, then the cache entry is associated with a permanently - * installed JS file (e.g., in a packaged webapp). This information allows the - * embedding to store the cache entry in a installed location associated with - * the principal of 'global' where it will not be evicted until the associated - * installed JS file is removed. - */ -typedef AsmJSCacheResult -(* OpenAsmJSCacheEntryForWriteOp)(HandleObject global, bool installed, - const char16_t* begin, const char16_t* end, - size_t size, uint8_t** memory, intptr_t* handle); -typedef void -(* CloseAsmJSCacheEntryForWriteOp)(size_t size, uint8_t* memory, intptr_t handle); - -struct AsmJSCacheOps -{ - OpenAsmJSCacheEntryForReadOp openEntryForRead; - CloseAsmJSCacheEntryForReadOp closeEntryForRead; - OpenAsmJSCacheEntryForWriteOp openEntryForWrite; - CloseAsmJSCacheEntryForWriteOp closeEntryForWrite; -}; - -extern JS_PUBLIC_API(void) -SetAsmJSCacheOps(JSContext* cx, const AsmJSCacheOps* callbacks); - -/** - * Return the buildId (represented as a sequence of characters) associated with - * the currently-executing build. If the JS engine is embedded such that a - * single cache entry can be observed by different compiled versions of the JS - * engine, it is critical that the buildId shall change for each new build of - * the JS engine. - */ -typedef js::Vector<char, 0, js::SystemAllocPolicy> BuildIdCharVector; - -typedef bool -(* BuildIdOp)(BuildIdCharVector* buildId); - -extern JS_PUBLIC_API(void) -SetBuildIdOp(JSContext* cx, BuildIdOp buildIdOp); - -/** - * The WasmModule interface allows the embedding to hold a reference to the - * underying C++ implementation of a JS WebAssembly.Module object for purposes - * of (de)serialization off the object's JSRuntime's thread. - * - * - Serialization starts when WebAssembly.Module is passed to the - * structured-clone algorithm. JS::GetWasmModule is called on the JSRuntime - * thread that initiated the structured clone to get the JS::WasmModule. - * This interface is then taken to a background thread where serializedSize() - * and serialize() are called to write the object to two files: a bytecode file - * that always allows successful deserialization and a compiled-code file keyed - * on cpu- and build-id that may become invalid if either of these change between - * serialization and deserialization. After serialization, the reference is - * dropped from the background thread. - * - * - Deserialization starts when the structured clone algorithm encounters a - * serialized WebAssembly.Module. On a background thread, the compiled-code file - * is opened and CompiledWasmModuleAssumptionsMatch is called to see if it is - * still valid (as described above). DeserializeWasmModule is then called to - * construct a JS::WasmModule (also on the background thread), passing the - * bytecode file descriptor and, if valid, the compiled-code file descriptor. - * The JS::WasmObject is then transported to the JSRuntime thread (which - * originated the request) and the wrapping WebAssembly.Module object is created - * by calling createObject(). - */ - -struct WasmModule : mozilla::external::AtomicRefCounted<WasmModule> -{ - MOZ_DECLARE_REFCOUNTED_TYPENAME(WasmModule) - virtual ~WasmModule() {} - - virtual void serializedSize(size_t* maybeBytecodeSize, size_t* maybeCompiledSize) const = 0; - virtual void serialize(uint8_t* maybeBytecodeBegin, size_t maybeBytecodeSize, - uint8_t* maybeCompiledBegin, size_t maybeCompiledSize) const = 0; - - virtual JSObject* createObject(JSContext* cx) = 0; -}; - -extern JS_PUBLIC_API(bool) -IsWasmModuleObject(HandleObject obj); - -extern JS_PUBLIC_API(RefPtr<WasmModule>) -GetWasmModule(HandleObject obj); - -extern JS_PUBLIC_API(bool) -CompiledWasmModuleAssumptionsMatch(PRFileDesc* compiled, BuildIdCharVector&& buildId); - -extern JS_PUBLIC_API(RefPtr<WasmModule>) -DeserializeWasmModule(PRFileDesc* bytecode, PRFileDesc* maybeCompiled, BuildIdCharVector&& buildId, - JS::UniqueChars filename, unsigned line, unsigned column); - -/** - * Convenience class for imitating a JS level for-of loop. Typical usage: - * - * ForOfIterator it(cx); - * if (!it.init(iterable)) - * return false; - * RootedValue val(cx); - * while (true) { - * bool done; - * if (!it.next(&val, &done)) - * return false; - * if (done) - * break; - * if (!DoStuff(cx, val)) - * return false; - * } - */ -class MOZ_STACK_CLASS JS_PUBLIC_API(ForOfIterator) { - protected: - JSContext* cx_; - /* - * Use the ForOfPIC on the global object (see vm/GlobalObject.h) to try - * to optimize iteration across arrays. - * - * Case 1: Regular Iteration - * iterator - pointer to the iterator object. - * index - fixed to NOT_ARRAY (== UINT32_MAX) - * - * Case 2: Optimized Array Iteration - * iterator - pointer to the array object. - * index - current position in array. - * - * The cases are distinguished by whether or not |index| is equal to NOT_ARRAY. - */ - JS::RootedObject iterator; - uint32_t index; - - static const uint32_t NOT_ARRAY = UINT32_MAX; - - ForOfIterator(const ForOfIterator&) = delete; - ForOfIterator& operator=(const ForOfIterator&) = delete; - - public: - explicit ForOfIterator(JSContext* cx) : cx_(cx), iterator(cx_), index(NOT_ARRAY) { } - - enum NonIterableBehavior { - ThrowOnNonIterable, - AllowNonIterable - }; - - /** - * Initialize the iterator. If AllowNonIterable is passed then if getting - * the @@iterator property from iterable returns undefined init() will just - * return true instead of throwing. Callers must then check - * valueIsIterable() before continuing with the iteration. - */ - bool init(JS::HandleValue iterable, - NonIterableBehavior nonIterableBehavior = ThrowOnNonIterable); - - /** - * Get the next value from the iterator. If false *done is true - * after this call, do not examine val. - */ - bool next(JS::MutableHandleValue val, bool* done); - - /** - * If initialized with throwOnNonCallable = false, check whether - * the value is iterable. - */ - bool valueIsIterable() const { - return iterator; - } - - private: - inline bool nextFromOptimizedArray(MutableHandleValue val, bool* done); - bool materializeArrayIterator(); -}; - - -/** - * If a large allocation fails when calling pod_{calloc,realloc}CanGC, the JS - * engine may call the large-allocation- failure callback, if set, to allow the - * embedding to flush caches, possibly perform shrinking GCs, etc. to make some - * room. The allocation will then be retried (and may still fail.) - */ - -typedef void -(* LargeAllocationFailureCallback)(void* data); - -extern JS_PUBLIC_API(void) -SetLargeAllocationFailureCallback(JSContext* cx, LargeAllocationFailureCallback afc, void* data); - -/** - * Unlike the error reporter, which is only called if the exception for an OOM - * bubbles up and is not caught, the OutOfMemoryCallback is called immediately - * at the OOM site to allow the embedding to capture the current state of heap - * allocation before anything is freed. If the large-allocation-failure callback - * is called at all (not all allocation sites call the large-allocation-failure - * callback on failure), it is called before the out-of-memory callback; the - * out-of-memory callback is only called if the allocation still fails after the - * large-allocation-failure callback has returned. - */ - -typedef void -(* OutOfMemoryCallback)(JSContext* cx, void* data); - -extern JS_PUBLIC_API(void) -SetOutOfMemoryCallback(JSContext* cx, OutOfMemoryCallback cb, void* data); - -/** - * Capture all frames. - */ -struct AllFrames { }; - -/** - * Capture at most this many frames. - */ -struct MaxFrames -{ - uint32_t maxFrames; - - explicit MaxFrames(uint32_t max) - : maxFrames(max) - { - MOZ_ASSERT(max > 0); - } -}; - -/** - * Capture the first frame with the given principals. By default, do not - * consider self-hosted frames with the given principals as satisfying the stack - * capture. - */ -struct FirstSubsumedFrame -{ - JSContext* cx; - JSPrincipals* principals; - bool ignoreSelfHosted; - - /** - * Use the cx's current compartment's principals. - */ - explicit FirstSubsumedFrame(JSContext* cx, bool ignoreSelfHostedFrames = true); - - explicit FirstSubsumedFrame(JSContext* ctx, JSPrincipals* p, bool ignoreSelfHostedFrames = true) - : cx(ctx) - , principals(p) - , ignoreSelfHosted(ignoreSelfHostedFrames) - { - if (principals) - JS_HoldPrincipals(principals); - } - - // No copying because we want to avoid holding and dropping principals - // unnecessarily. - FirstSubsumedFrame(const FirstSubsumedFrame&) = delete; - FirstSubsumedFrame& operator=(const FirstSubsumedFrame&) = delete; - - FirstSubsumedFrame(FirstSubsumedFrame&& rhs) - : principals(rhs.principals) - , ignoreSelfHosted(rhs.ignoreSelfHosted) - { - MOZ_ASSERT(this != &rhs, "self move disallowed"); - rhs.principals = nullptr; - } - - FirstSubsumedFrame& operator=(FirstSubsumedFrame&& rhs) { - new (this) FirstSubsumedFrame(mozilla::Move(rhs)); - return *this; - } - - ~FirstSubsumedFrame() { - if (principals) - JS_DropPrincipals(cx, principals); - } -}; - -using StackCapture = mozilla::Variant<AllFrames, MaxFrames, FirstSubsumedFrame>; - -/** - * Capture the current call stack as a chain of SavedFrame JSObjects, and set - * |stackp| to the SavedFrame for the youngest stack frame, or nullptr if there - * are no JS frames on the stack. - * - * The |capture| parameter describes the portion of the JS stack to capture: - * - * * |JS::AllFrames|: Capture all frames on the stack. - * - * * |JS::MaxFrames|: Capture no more than |JS::MaxFrames::maxFrames| from the - * stack. - * - * * |JS::FirstSubsumedFrame|: Capture the first frame whose principals are - * subsumed by |JS::FirstSubsumedFrame::principals|. By default, do not - * consider self-hosted frames; this can be controlled via the - * |JS::FirstSubsumedFrame::ignoreSelfHosted| flag. Do not capture any async - * stack. - */ -extern JS_PUBLIC_API(bool) -CaptureCurrentStack(JSContext* cx, MutableHandleObject stackp, - StackCapture&& capture = StackCapture(AllFrames())); - -/* - * This is a utility function for preparing an async stack to be used - * by some other object. This may be used when you need to treat a - * given stack trace as an async parent. If you just need to capture - * the current stack, async parents and all, use CaptureCurrentStack - * instead. - * - * Here |asyncStack| is the async stack to prepare. It is copied into - * |cx|'s current compartment, and the newest frame is given - * |asyncCause| as its asynchronous cause. If |maxFrameCount| is - * non-zero, capture at most the youngest |maxFrameCount| frames. The - * new stack object is written to |stackp|. Returns true on success, - * or sets an exception and returns |false| on error. - */ -extern JS_PUBLIC_API(bool) -CopyAsyncStack(JSContext* cx, HandleObject asyncStack, - HandleString asyncCause, MutableHandleObject stackp, - unsigned maxFrameCount); - -/* - * Accessors for working with SavedFrame JSObjects - * - * Each of these functions assert that if their `HandleObject savedFrame` - * argument is non-null, its JSClass is the SavedFrame class (or it is a - * cross-compartment or Xray wrapper around an object with the SavedFrame class) - * and the object is not the SavedFrame.prototype object. - * - * Each of these functions will find the first SavedFrame object in the chain - * whose underlying stack frame principals are subsumed by the cx's current - * compartment's principals, and operate on that SavedFrame object. This - * prevents leaking information about privileged frames to un-privileged - * callers. As a result, the SavedFrame in parameters do _NOT_ need to be in the - * same compartment as the cx, and the various out parameters are _NOT_ - * guaranteed to be in the same compartment as cx. - * - * You may consider or skip over self-hosted frames by passing - * `SavedFrameSelfHosted::Include` or `SavedFrameSelfHosted::Exclude` - * respectively. - * - * Additionally, it may be the case that there is no such SavedFrame object - * whose captured frame's principals are subsumed by the caller's compartment's - * principals! If the `HandleObject savedFrame` argument is null, or the - * caller's principals do not subsume any of the chained SavedFrame object's - * principals, `SavedFrameResult::AccessDenied` is returned and a (hopefully) - * sane default value is chosen for the out param. - * - * See also `js/src/doc/SavedFrame/SavedFrame.md`. - */ - -enum class SavedFrameResult { - Ok, - AccessDenied -}; - -enum class SavedFrameSelfHosted { - Include, - Exclude -}; - -/** - * Given a SavedFrame JSObject, get its source property. Defaults to the empty - * string. - */ -extern JS_PUBLIC_API(SavedFrameResult) -GetSavedFrameSource(JSContext* cx, HandleObject savedFrame, MutableHandleString sourcep, - SavedFrameSelfHosted selfHosted = SavedFrameSelfHosted::Include); - -/** - * Given a SavedFrame JSObject, get its line property. Defaults to 0. - */ -extern JS_PUBLIC_API(SavedFrameResult) -GetSavedFrameLine(JSContext* cx, HandleObject savedFrame, uint32_t* linep, - SavedFrameSelfHosted selfHosted = SavedFrameSelfHosted::Include); - -/** - * Given a SavedFrame JSObject, get its column property. Defaults to 0. - */ -extern JS_PUBLIC_API(SavedFrameResult) -GetSavedFrameColumn(JSContext* cx, HandleObject savedFrame, uint32_t* columnp, - SavedFrameSelfHosted selfHosted = SavedFrameSelfHosted::Include); - -/** - * Given a SavedFrame JSObject, get its functionDisplayName string, or nullptr - * if SpiderMonkey was unable to infer a name for the captured frame's - * function. Defaults to nullptr. - */ -extern JS_PUBLIC_API(SavedFrameResult) -GetSavedFrameFunctionDisplayName(JSContext* cx, HandleObject savedFrame, MutableHandleString namep, - SavedFrameSelfHosted selfHosted = SavedFrameSelfHosted::Include); - -/** - * Given a SavedFrame JSObject, get its asyncCause string. Defaults to nullptr. - */ -extern JS_PUBLIC_API(SavedFrameResult) -GetSavedFrameAsyncCause(JSContext* cx, HandleObject savedFrame, MutableHandleString asyncCausep, - SavedFrameSelfHosted selfHosted = SavedFrameSelfHosted::Include); - -/** - * Given a SavedFrame JSObject, get its asyncParent SavedFrame object or nullptr - * if there is no asyncParent. The `asyncParentp` out parameter is _NOT_ - * guaranteed to be in the cx's compartment. Defaults to nullptr. - */ -extern JS_PUBLIC_API(SavedFrameResult) -GetSavedFrameAsyncParent(JSContext* cx, HandleObject savedFrame, MutableHandleObject asyncParentp, - SavedFrameSelfHosted selfHosted = SavedFrameSelfHosted::Include); - -/** - * Given a SavedFrame JSObject, get its parent SavedFrame object or nullptr if - * it is the oldest frame in the stack. The `parentp` out parameter is _NOT_ - * guaranteed to be in the cx's compartment. Defaults to nullptr. - */ -extern JS_PUBLIC_API(SavedFrameResult) -GetSavedFrameParent(JSContext* cx, HandleObject savedFrame, MutableHandleObject parentp, - SavedFrameSelfHosted selfHosted = SavedFrameSelfHosted::Include); - -/** - * Given a SavedFrame JSObject stack, stringify it in the same format as - * Error.prototype.stack. The stringified stack out parameter is placed in the - * cx's compartment. Defaults to the empty string. - * - * The same notes above about SavedFrame accessors applies here as well: cx - * doesn't need to be in stack's compartment, and stack can be null, a - * SavedFrame object, or a wrapper (CCW or Xray) around a SavedFrame object. - * - * Optional indent parameter specifies the number of white spaces to indent - * each line. - */ -extern JS_PUBLIC_API(bool) -BuildStackString(JSContext* cx, HandleObject stack, MutableHandleString stringp, - size_t indent = 0, js::StackFormat stackFormat = js::StackFormat::Default); - -/** - * Return true iff the given object is either a SavedFrame object or wrapper - * around a SavedFrame object, and it is not the SavedFrame.prototype object. - */ -extern JS_PUBLIC_API(bool) -IsSavedFrame(JSObject* obj); - -} /* namespace JS */ - - -/* Stopwatch-based performance monitoring. */ - -namespace js { - -class AutoStopwatch; - -/** - * Abstract base class for a representation of the performance of a - * component. Embeddings interested in performance monitoring should - * provide a concrete implementation of this class, as well as the - * relevant callbacks (see below). - */ -struct PerformanceGroup { - PerformanceGroup(); - - // The current iteration of the event loop. - uint64_t iteration() const; - - // `true` if an instance of `AutoStopwatch` is already monitoring - // the performance of this performance group for this iteration - // of the event loop, `false` otherwise. - bool isAcquired(uint64_t it) const; - - // `true` if a specific instance of `AutoStopwatch` is already monitoring - // the performance of this performance group for this iteration - // of the event loop, `false` otherwise. - bool isAcquired(uint64_t it, const AutoStopwatch* owner) const; - - // Mark that an instance of `AutoStopwatch` is monitoring - // the performance of this group for a given iteration. - void acquire(uint64_t it, const AutoStopwatch* owner); - - // Mark that no `AutoStopwatch` is monitoring the - // performance of this group for the iteration. - void release(uint64_t it, const AutoStopwatch* owner); - - // The number of cycles spent in this group during this iteration - // of the event loop. Note that cycles are not a reliable measure, - // especially over short intervals. See Stopwatch.* for a more - // complete discussion on the imprecision of cycle measurement. - uint64_t recentCycles(uint64_t iteration) const; - void addRecentCycles(uint64_t iteration, uint64_t cycles); - - // The number of times this group has been activated during this - // iteration of the event loop. - uint64_t recentTicks(uint64_t iteration) const; - void addRecentTicks(uint64_t iteration, uint64_t ticks); - - // The number of microseconds spent doing CPOW during this - // iteration of the event loop. - uint64_t recentCPOW(uint64_t iteration) const; - void addRecentCPOW(uint64_t iteration, uint64_t CPOW); - - // Get rid of any data that pretends to be recent. - void resetRecentData(); - - // `true` if new measures should be added to this group, `false` - // otherwise. - bool isActive() const; - void setIsActive(bool); - - // `true` if this group has been used in the current iteration, - // `false` otherwise. - bool isUsedInThisIteration() const; - void setIsUsedInThisIteration(bool); - protected: - // An implementation of `delete` for this object. Must be provided - // by the embedding. - virtual void Delete() = 0; - - private: - // The number of cycles spent in this group during this iteration - // of the event loop. Note that cycles are not a reliable measure, - // especially over short intervals. See Runtime.cpp for a more - // complete discussion on the imprecision of cycle measurement. - uint64_t recentCycles_; - - // The number of times this group has been activated during this - // iteration of the event loop. - uint64_t recentTicks_; - - // The number of microseconds spent doing CPOW during this - // iteration of the event loop. - uint64_t recentCPOW_; - - // The current iteration of the event loop. If necessary, - // may safely overflow. - uint64_t iteration_; - - // `true` if new measures should be added to this group, `false` - // otherwise. - bool isActive_; - - // `true` if this group has been used in the current iteration, - // `false` otherwise. - bool isUsedInThisIteration_; - - // The stopwatch currently monitoring the group, - // or `nullptr` if none. Used ony for comparison. - const AutoStopwatch* owner_; - - public: - // Compatibility with RefPtr<> - void AddRef(); - void Release(); - uint64_t refCount_; -}; - -using PerformanceGroupVector = mozilla::Vector<RefPtr<js::PerformanceGroup>, 0, SystemAllocPolicy>; - -/** - * Commit any Performance Monitoring data. - * - * Until `FlushMonitoring` has been called, all PerformanceMonitoring data is invisible - * to the outside world and can cancelled with a call to `ResetMonitoring`. - */ -extern JS_PUBLIC_API(bool) -FlushPerformanceMonitoring(JSContext*); - -/** - * Cancel any measurement that hasn't been committed. - */ -extern JS_PUBLIC_API(void) -ResetPerformanceMonitoring(JSContext*); - -/** - * Cleanup any memory used by performance monitoring. - */ -extern JS_PUBLIC_API(void) -DisposePerformanceMonitoring(JSContext*); - -/** - * Turn on/off stopwatch-based CPU monitoring. - * - * `SetStopwatchIsMonitoringCPOW` or `SetStopwatchIsMonitoringJank` - * may return `false` if monitoring could not be activated, which may - * happen if we are out of memory. - */ -extern JS_PUBLIC_API(bool) -SetStopwatchIsMonitoringCPOW(JSContext*, bool); -extern JS_PUBLIC_API(bool) -GetStopwatchIsMonitoringCPOW(JSContext*); -extern JS_PUBLIC_API(bool) -SetStopwatchIsMonitoringJank(JSContext*, bool); -extern JS_PUBLIC_API(bool) -GetStopwatchIsMonitoringJank(JSContext*); - -// Extract the CPU rescheduling data. -extern JS_PUBLIC_API(void) -GetPerfMonitoringTestCpuRescheduling(JSContext*, uint64_t* stayed, uint64_t* moved); - - -/** - * Add a number of microseconds to the time spent waiting on CPOWs - * since process start. - */ -extern JS_PUBLIC_API(void) -AddCPOWPerformanceDelta(JSContext*, uint64_t delta); - -typedef bool -(*StopwatchStartCallback)(uint64_t, void*); -extern JS_PUBLIC_API(bool) -SetStopwatchStartCallback(JSContext*, StopwatchStartCallback, void*); - -typedef bool -(*StopwatchCommitCallback)(uint64_t, PerformanceGroupVector&, void*); -extern JS_PUBLIC_API(bool) -SetStopwatchCommitCallback(JSContext*, StopwatchCommitCallback, void*); - -typedef bool -(*GetGroupsCallback)(JSContext*, PerformanceGroupVector&, void*); -extern JS_PUBLIC_API(bool) -SetGetPerformanceGroupsCallback(JSContext*, GetGroupsCallback, void*); - -} /* namespace js */ - - -#endif /* jsapi_h */ diff --git a/android/armeabi/include/spidermonkey/jsbytecode.h b/android/armeabi/include/spidermonkey/jsbytecode.h deleted file mode 100644 index 8e4f4cf9..00000000 --- a/android/armeabi/include/spidermonkey/jsbytecode.h +++ /dev/null @@ -1,14 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef jsbytecode_h -#define jsbytecode_h - -#include <stdint.h> - -typedef uint8_t jsbytecode; - -#endif /* jsbytecode_h */ diff --git a/android/armeabi/include/spidermonkey/jsclist.h b/android/armeabi/include/spidermonkey/jsclist.h deleted file mode 100644 index b8455152..00000000 --- a/android/armeabi/include/spidermonkey/jsclist.h +++ /dev/null @@ -1,107 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef jsclist_h -#define jsclist_h - -#include "jstypes.h" - -/* -** Circular linked list -*/ -typedef struct JSCListStr { - struct JSCListStr* next; - struct JSCListStr* prev; -} JSCList; - -/* -** Insert element "_e" into the list, before "_l". -*/ -#define JS_INSERT_BEFORE(_e,_l) \ - JS_BEGIN_MACRO \ - (_e)->next = (_l); \ - (_e)->prev = (_l)->prev; \ - (_l)->prev->next = (_e); \ - (_l)->prev = (_e); \ - JS_END_MACRO - -/* -** Insert element "_e" into the list, after "_l". -*/ -#define JS_INSERT_AFTER(_e,_l) \ - JS_BEGIN_MACRO \ - (_e)->next = (_l)->next; \ - (_e)->prev = (_l); \ - (_l)->next->prev = (_e); \ - (_l)->next = (_e); \ - JS_END_MACRO - -/* -** Return the element following element "_e" -*/ -#define JS_NEXT_LINK(_e) \ - ((_e)->next) -/* -** Return the element preceding element "_e" -*/ -#define JS_PREV_LINK(_e) \ - ((_e)->prev) - -/* -** Append an element "_e" to the end of the list "_l" -*/ -#define JS_APPEND_LINK(_e,_l) JS_INSERT_BEFORE(_e,_l) - -/* -** Insert an element "_e" at the head of the list "_l" -*/ -#define JS_INSERT_LINK(_e,_l) JS_INSERT_AFTER(_e,_l) - -/* Return the head/tail of the list */ -#define JS_LIST_HEAD(_l) (_l)->next -#define JS_LIST_TAIL(_l) (_l)->prev - -/* -** Remove the element "_e" from it's circular list. -*/ -#define JS_REMOVE_LINK(_e) \ - JS_BEGIN_MACRO \ - (_e)->prev->next = (_e)->next; \ - (_e)->next->prev = (_e)->prev; \ - JS_END_MACRO - -/* -** Remove the element "_e" from it's circular list. Also initializes the -** linkage. -*/ -#define JS_REMOVE_AND_INIT_LINK(_e) \ - JS_BEGIN_MACRO \ - (_e)->prev->next = (_e)->next; \ - (_e)->next->prev = (_e)->prev; \ - (_e)->next = (_e); \ - (_e)->prev = (_e); \ - JS_END_MACRO - -/* -** Return non-zero if the given circular list "_l" is empty, zero if the -** circular list is not empty -*/ -#define JS_CLIST_IS_EMPTY(_l) \ - bool((_l)->next == (_l)) - -/* -** Initialize a circular list -*/ -#define JS_INIT_CLIST(_l) \ - JS_BEGIN_MACRO \ - (_l)->next = (_l); \ - (_l)->prev = (_l); \ - JS_END_MACRO - -#define JS_INIT_STATIC_CLIST(_l) \ - {(_l), (_l)} - -#endif /* jsclist_h */ diff --git a/android/armeabi/include/spidermonkey/jscpucfg.h b/android/armeabi/include/spidermonkey/jscpucfg.h deleted file mode 100644 index 80fdf6bb..00000000 --- a/android/armeabi/include/spidermonkey/jscpucfg.h +++ /dev/null @@ -1,20 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef jscpucfg_h -#define jscpucfg_h - -#include "mozilla/EndianUtils.h" - -#ifndef JS_STACK_GROWTH_DIRECTION -# ifdef __hppa -# define JS_STACK_GROWTH_DIRECTION (1) -# else -# define JS_STACK_GROWTH_DIRECTION (-1) -# endif -#endif - -#endif /* jscpucfg_h */ diff --git a/android/armeabi/include/spidermonkey/jsfriendapi.h b/android/armeabi/include/spidermonkey/jsfriendapi.h deleted file mode 100644 index d6463d3d..00000000 --- a/android/armeabi/include/spidermonkey/jsfriendapi.h +++ /dev/null @@ -1,3067 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef jsfriendapi_h -#define jsfriendapi_h - -#include "mozilla/Atomics.h" -#include "mozilla/Casting.h" -#include "mozilla/Maybe.h" -#include "mozilla/MemoryReporting.h" -#include "mozilla/UniquePtr.h" - -#include "jsapi.h" // For JSAutoByteString. See bug 1033916. -#include "jsbytecode.h" -#include "jspubtd.h" - -#include "js/CallArgs.h" -#include "js/CallNonGenericMethod.h" -#include "js/Class.h" -#include "js/Utility.h" - -#if JS_STACK_GROWTH_DIRECTION > 0 -# define JS_CHECK_STACK_SIZE(limit, sp) (MOZ_LIKELY((uintptr_t)(sp) < (limit))) -#else -# define JS_CHECK_STACK_SIZE(limit, sp) (MOZ_LIKELY((uintptr_t)(sp) > (limit))) -#endif - -class JSAtom; -struct JSErrorFormatString; -class JSLinearString; -struct JSJitInfo; -class JSErrorReport; - -namespace JS { -template <class T> -class Heap; -} /* namespace JS */ - -namespace js { -class JS_FRIEND_API(BaseProxyHandler); -class InterpreterFrame; -} /* namespace js */ - -extern JS_FRIEND_API(void) -JS_SetGrayGCRootsTracer(JSContext* cx, JSTraceDataOp traceOp, void* data); - -extern JS_FRIEND_API(JSObject*) -JS_FindCompilationScope(JSContext* cx, JS::HandleObject obj); - -extern JS_FRIEND_API(JSFunction*) -JS_GetObjectFunction(JSObject* obj); - -extern JS_FRIEND_API(bool) -JS_SplicePrototype(JSContext* cx, JS::HandleObject obj, JS::HandleObject proto); - -extern JS_FRIEND_API(JSObject*) -JS_NewObjectWithUniqueType(JSContext* cx, const JSClass* clasp, JS::HandleObject proto); - -/** - * Allocate an object in exactly the same way as JS_NewObjectWithGivenProto, but - * without invoking the metadata callback on it. This allows creation of - * internal bookkeeping objects that are guaranteed to not have metadata - * attached to them. - */ -extern JS_FRIEND_API(JSObject*) -JS_NewObjectWithoutMetadata(JSContext* cx, const JSClass* clasp, JS::Handle<JSObject*> proto); - -extern JS_FRIEND_API(uint32_t) -JS_ObjectCountDynamicSlots(JS::HandleObject obj); - -extern JS_FRIEND_API(size_t) -JS_SetProtoCalled(JSContext* cx); - -extern JS_FRIEND_API(size_t) -JS_GetCustomIteratorCount(JSContext* cx); - -extern JS_FRIEND_API(bool) -JS_NondeterministicGetWeakMapKeys(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject ret); - -extern JS_FRIEND_API(bool) -JS_NondeterministicGetWeakSetKeys(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject ret); - -// Raw JSScript* because this needs to be callable from a signal handler. -extern JS_FRIEND_API(unsigned) -JS_PCToLineNumber(JSScript* script, jsbytecode* pc, unsigned* columnp = nullptr); - -/** - * Determine whether the given object is backed by a DeadObjectProxy. - * - * Such objects hold no other objects (they have no outgoing reference edges) - * and will throw if you touch them (e.g. by reading/writing a property). - */ -extern JS_FRIEND_API(bool) -JS_IsDeadWrapper(JSObject* obj); - -/* - * Used by the cycle collector to trace through a shape or object group and - * all cycle-participating data it reaches, using bounded stack space. - */ -extern JS_FRIEND_API(void) -JS_TraceShapeCycleCollectorChildren(JS::CallbackTracer* trc, JS::GCCellPtr shape); -extern JS_FRIEND_API(void) -JS_TraceObjectGroupCycleCollectorChildren(JS::CallbackTracer* trc, JS::GCCellPtr group); - -enum { - JS_TELEMETRY_GC_REASON, - JS_TELEMETRY_GC_IS_ZONE_GC, - JS_TELEMETRY_GC_MS, - JS_TELEMETRY_GC_BUDGET_MS, - JS_TELEMETRY_GC_ANIMATION_MS, - JS_TELEMETRY_GC_MAX_PAUSE_MS, - JS_TELEMETRY_GC_MARK_MS, - JS_TELEMETRY_GC_SWEEP_MS, - JS_TELEMETRY_GC_COMPACT_MS, - JS_TELEMETRY_GC_MARK_ROOTS_MS, - JS_TELEMETRY_GC_MARK_GRAY_MS, - JS_TELEMETRY_GC_SLICE_MS, - JS_TELEMETRY_GC_SLOW_PHASE, - JS_TELEMETRY_GC_MMU_50, - JS_TELEMETRY_GC_RESET, - JS_TELEMETRY_GC_RESET_REASON, - JS_TELEMETRY_GC_INCREMENTAL_DISABLED, - JS_TELEMETRY_GC_NON_INCREMENTAL, - JS_TELEMETRY_GC_NON_INCREMENTAL_REASON, - JS_TELEMETRY_GC_SCC_SWEEP_TOTAL_MS, - JS_TELEMETRY_GC_SCC_SWEEP_MAX_PAUSE_MS, - JS_TELEMETRY_GC_MINOR_REASON, - JS_TELEMETRY_GC_MINOR_REASON_LONG, - JS_TELEMETRY_GC_MINOR_US, - JS_TELEMETRY_GC_NURSERY_BYTES, - JS_TELEMETRY_GC_PRETENURE_COUNT, - JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_CONTENT, - JS_TELEMETRY_DEPRECATED_LANGUAGE_EXTENSIONS_IN_ADDONS, - JS_TELEMETRY_ADDON_EXCEPTIONS, - JS_TELEMETRY_AOT_USAGE, - JS_TELEMETRY_END -}; - -typedef void -(*JSAccumulateTelemetryDataCallback)(int id, uint32_t sample, const char* key); - -extern JS_FRIEND_API(void) -JS_SetAccumulateTelemetryCallback(JSContext* cx, JSAccumulateTelemetryDataCallback callback); - -extern JS_FRIEND_API(bool) -JS_GetIsSecureContext(JSCompartment* compartment); - -extern JS_FRIEND_API(JSPrincipals*) -JS_GetCompartmentPrincipals(JSCompartment* compartment); - -extern JS_FRIEND_API(void) -JS_SetCompartmentPrincipals(JSCompartment* compartment, JSPrincipals* principals); - -extern JS_FRIEND_API(JSPrincipals*) -JS_GetScriptPrincipals(JSScript* script); - -extern JS_FRIEND_API(bool) -JS_ScriptHasMutedErrors(JSScript* script); - -extern JS_FRIEND_API(JSObject*) -JS_CloneObject(JSContext* cx, JS::HandleObject obj, JS::HandleObject proto); - -/** - * Copy the own properties of src to dst in a fast way. src and dst must both - * be native and must be in the compartment of cx. They must have the same - * class, the same parent, and the same prototype. Class reserved slots will - * NOT be copied. - * - * dst must not have any properties on it before this function is called. - * - * src must have been allocated via JS_NewObjectWithoutMetadata so that we can - * be sure it has no metadata that needs copying to dst. This also means that - * dst needs to have the compartment global as its parent. This function will - * preserve the existing metadata on dst, if any. - */ -extern JS_FRIEND_API(bool) -JS_InitializePropertiesFromCompatibleNativeObject(JSContext* cx, - JS::HandleObject dst, - JS::HandleObject src); - -extern JS_FRIEND_API(JSString*) -JS_BasicObjectToString(JSContext* cx, JS::HandleObject obj); - -namespace js { - -JS_FRIEND_API(bool) -GetBuiltinClass(JSContext* cx, JS::HandleObject obj, ESClass* cls); - -JS_FRIEND_API(const char*) -ObjectClassName(JSContext* cx, JS::HandleObject obj); - -JS_FRIEND_API(void) -ReportOverRecursed(JSContext* maybecx); - -JS_FRIEND_API(bool) -AddRawValueRoot(JSContext* cx, JS::Value* vp, const char* name); - -JS_FRIEND_API(void) -RemoveRawValueRoot(JSContext* cx, JS::Value* vp); - -JS_FRIEND_API(JSAtom*) -GetPropertyNameFromPC(JSScript* script, jsbytecode* pc); - -#ifdef JS_DEBUG - -/* - * Routines to print out values during debugging. These are FRIEND_API to help - * the debugger find them and to support temporarily hacking js::Dump* calls - * into other code. Note that there are overloads that do not require the FILE* - * parameter, which will default to stderr. - */ - -extern JS_FRIEND_API(void) -DumpString(JSString* str, FILE* fp); - -extern JS_FRIEND_API(void) -DumpAtom(JSAtom* atom, FILE* fp); - -extern JS_FRIEND_API(void) -DumpObject(JSObject* obj, FILE* fp); - -extern JS_FRIEND_API(void) -DumpChars(const char16_t* s, size_t n, FILE* fp); - -extern JS_FRIEND_API(void) -DumpValue(const JS::Value& val, FILE* fp); - -extern JS_FRIEND_API(void) -DumpId(jsid id, FILE* fp); - -extern JS_FRIEND_API(void) -DumpInterpreterFrame(JSContext* cx, FILE* fp, InterpreterFrame* start = nullptr); - -extern JS_FRIEND_API(bool) -DumpPC(JSContext* cx, FILE* fp); - -extern JS_FRIEND_API(bool) -DumpScript(JSContext* cx, JSScript* scriptArg, FILE* fp); - -// Versions for use directly in a debugger (default parameters are not handled -// well in gdb; built-in handles like stderr are not handled well in lldb.) -extern JS_FRIEND_API(void) DumpString(JSString* str); -extern JS_FRIEND_API(void) DumpAtom(JSAtom* atom); -extern JS_FRIEND_API(void) DumpObject(JSObject* obj); -extern JS_FRIEND_API(void) DumpChars(const char16_t* s, size_t n); -extern JS_FRIEND_API(void) DumpValue(const JS::Value& val); -extern JS_FRIEND_API(void) DumpId(jsid id); -extern JS_FRIEND_API(void) DumpInterpreterFrame(JSContext* cx, InterpreterFrame* start = nullptr); -extern JS_FRIEND_API(bool) DumpPC(JSContext* cx); -extern JS_FRIEND_API(bool) DumpScript(JSContext* cx, JSScript* scriptArg); - -#endif - -extern JS_FRIEND_API(void) -DumpBacktrace(JSContext* cx, FILE* fp); - -extern JS_FRIEND_API(void) -DumpBacktrace(JSContext* cx); - -} // namespace js - -namespace JS { - -/** Exposed for DumpJSStack */ -extern JS_FRIEND_API(char*) -FormatStackDump(JSContext* cx, char* buf, bool showArgs, bool showLocals, bool showThisProps); - -/** - * Set all of the uninitialized lexicals on an object to undefined. Return - * true if any lexicals were initialized and false otherwise. - * */ -extern JS_FRIEND_API(bool) -ForceLexicalInitialization(JSContext *cx, HandleObject obj); - -} // namespace JS - -/** - * Copies all own properties from |obj| to |target|. |obj| must be a "native" - * object (that is to say, normal-ish - not an Array or a Proxy). - * - * This function immediately enters a compartment, and does not impose any - * restrictions on the compartment of |cx|. - */ -extern JS_FRIEND_API(bool) -JS_CopyPropertiesFrom(JSContext* cx, JS::HandleObject target, JS::HandleObject obj); - -/* - * Single-property version of the above. This function asserts that an |own| - * property of the given name exists on |obj|. - * - * On entry, |cx| must be same-compartment with |obj|. - * - * The copyBehavior argument controls what happens with - * non-configurable properties. - */ -typedef enum { - MakeNonConfigurableIntoConfigurable, - CopyNonConfigurableAsIs -} PropertyCopyBehavior; - -extern JS_FRIEND_API(bool) -JS_CopyPropertyFrom(JSContext* cx, JS::HandleId id, JS::HandleObject target, - JS::HandleObject obj, - PropertyCopyBehavior copyBehavior = CopyNonConfigurableAsIs); - -extern JS_FRIEND_API(bool) -JS_WrapPropertyDescriptor(JSContext* cx, JS::MutableHandle<JS::PropertyDescriptor> desc); - -struct JSFunctionSpecWithHelp { - const char* name; - JSNative call; - uint16_t nargs; - uint16_t flags; - const JSJitInfo* jitInfo; - const char* usage; - const char* help; -}; - -#define JS_FN_HELP(name,call,nargs,flags,usage,help) \ - {name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, nullptr, usage, help} -#define JS_INLINABLE_FN_HELP(name,call,nargs,flags,native,usage,help) \ - {name, call, nargs, (flags) | JSPROP_ENUMERATE | JSFUN_STUB_GSOPS, &js::jit::JitInfo_##native,\ - usage, help} -#define JS_FS_HELP_END \ - {nullptr, nullptr, 0, 0, nullptr, nullptr} - -extern JS_FRIEND_API(bool) -JS_DefineFunctionsWithHelp(JSContext* cx, JS::HandleObject obj, const JSFunctionSpecWithHelp* fs); - -namespace js { - -extern JS_FRIEND_DATA(const js::ClassOps) ProxyClassOps; -extern JS_FRIEND_DATA(const js::ClassExtension) ProxyClassExtension; -extern JS_FRIEND_DATA(const js::ObjectOps) ProxyObjectOps; - -/* - * Helper Macros for creating JSClasses that function as proxies. - * - * NB: The macro invocation must be surrounded by braces, so as to - * allow for potential JSClass extensions. - */ -#define PROXY_MAKE_EXT(objectMoved) \ - { \ - js::proxy_WeakmapKeyDelegate, \ - objectMoved \ - } - -#define PROXY_CLASS_WITH_EXT(name, flags, extPtr) \ - { \ - name, \ - js::Class::NON_NATIVE | \ - JSCLASS_IS_PROXY | \ - JSCLASS_DELAY_METADATA_BUILDER | \ - flags, \ - &js::ProxyClassOps, \ - JS_NULL_CLASS_SPEC, \ - extPtr, \ - &js::ProxyObjectOps \ - } - -#define PROXY_CLASS_DEF(name, flags) \ - PROXY_CLASS_WITH_EXT(name, flags, &js::ProxyClassExtension) - -/* - * Proxy stubs, similar to JS_*Stub, for embedder proxy class definitions. - * - * NB: Should not be called directly. - */ - -extern JS_FRIEND_API(bool) -proxy_LookupProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::MutableHandleObject objp, - JS::MutableHandle<Shape*> propp); -extern JS_FRIEND_API(bool) -proxy_DefineProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::Handle<JS::PropertyDescriptor> desc, - JS::ObjectOpResult& result); -extern JS_FRIEND_API(bool) -proxy_HasProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, bool* foundp); -extern JS_FRIEND_API(bool) -proxy_GetProperty(JSContext* cx, JS::HandleObject obj, JS::HandleValue receiver, JS::HandleId id, - JS::MutableHandleValue vp); -extern JS_FRIEND_API(bool) -proxy_SetProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleValue bp, - JS::HandleValue receiver, JS::ObjectOpResult& result); -extern JS_FRIEND_API(bool) -proxy_GetOwnPropertyDescriptor(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::MutableHandle<JS::PropertyDescriptor> desc); -extern JS_FRIEND_API(bool) -proxy_DeleteProperty(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::ObjectOpResult& result); - -extern JS_FRIEND_API(void) -proxy_Trace(JSTracer* trc, JSObject* obj); -extern JS_FRIEND_API(JSObject*) -proxy_WeakmapKeyDelegate(JSObject* obj); -extern JS_FRIEND_API(bool) -proxy_Convert(JSContext* cx, JS::HandleObject proxy, JSType hint, JS::MutableHandleValue vp); -extern JS_FRIEND_API(void) -proxy_Finalize(FreeOp* fop, JSObject* obj); -extern JS_FRIEND_API(void) -proxy_ObjectMoved(JSObject* obj, const JSObject* old); -extern JS_FRIEND_API(bool) -proxy_HasInstance(JSContext* cx, JS::HandleObject proxy, JS::MutableHandleValue v, bool* bp); -extern JS_FRIEND_API(bool) -proxy_Call(JSContext* cx, unsigned argc, JS::Value* vp); -extern JS_FRIEND_API(bool) -proxy_Construct(JSContext* cx, unsigned argc, JS::Value* vp); -extern JS_FRIEND_API(JSObject*) -proxy_innerObject(JSObject* obj); -extern JS_FRIEND_API(bool) -proxy_Watch(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject callable); -extern JS_FRIEND_API(bool) -proxy_Unwatch(JSContext* cx, JS::HandleObject obj, JS::HandleId id); -extern JS_FRIEND_API(bool) -proxy_GetElements(JSContext* cx, JS::HandleObject proxy, uint32_t begin, uint32_t end, - ElementAdder* adder); -extern JS_FRIEND_API(JSString*) -proxy_FunToString(JSContext* cx, JS::HandleObject proxy, unsigned indent); - -/** - * A class of objects that return source code on demand. - * - * When code is compiled with setSourceIsLazy(true), SpiderMonkey doesn't - * retain the source code (and doesn't do lazy bytecode generation). If we ever - * need the source code, say, in response to a call to Function.prototype. - * toSource or Debugger.Source.prototype.text, then we call the 'load' member - * function of the instance of this class that has hopefully been registered - * with the runtime, passing the code's URL, and hope that it will be able to - * find the source. - */ -class SourceHook { - public: - virtual ~SourceHook() { } - - /** - * Set |*src| and |*length| to refer to the source code for |filename|. - * On success, the caller owns the buffer to which |*src| points, and - * should use JS_free to free it. - */ - virtual bool load(JSContext* cx, const char* filename, char16_t** src, size_t* length) = 0; -}; - -/** - * Have |cx| use |hook| to retrieve lazily-retrieved source code. See the - * comments for SourceHook. The context takes ownership of the hook, and - * will delete it when the context itself is deleted, or when a new hook is - * set. - */ -extern JS_FRIEND_API(void) -SetSourceHook(JSContext* cx, mozilla::UniquePtr<SourceHook> hook); - -/** Remove |cx|'s source hook, and return it. The caller now owns the hook. */ -extern JS_FRIEND_API(mozilla::UniquePtr<SourceHook>) -ForgetSourceHook(JSContext* cx); - -extern JS_FRIEND_API(JS::Zone*) -GetCompartmentZone(JSCompartment* comp); - -typedef bool -(* PreserveWrapperCallback)(JSContext* cx, JSObject* obj); - -typedef enum { - CollectNurseryBeforeDump, - IgnoreNurseryObjects -} DumpHeapNurseryBehaviour; - - /** - * Dump the complete object graph of heap-allocated things. - * fp is the file for the dump output. - */ -extern JS_FRIEND_API(void) -DumpHeap(JSContext* cx, FILE* fp, DumpHeapNurseryBehaviour nurseryBehaviour); - -#ifdef JS_OLD_GETTER_SETTER_METHODS -JS_FRIEND_API(bool) obj_defineGetter(JSContext* cx, unsigned argc, JS::Value* vp); -JS_FRIEND_API(bool) obj_defineSetter(JSContext* cx, unsigned argc, JS::Value* vp); -#endif - -extern JS_FRIEND_API(bool) -IsSystemCompartment(JSCompartment* comp); - -extern JS_FRIEND_API(bool) -IsSystemZone(JS::Zone* zone); - -extern JS_FRIEND_API(bool) -IsAtomsCompartment(JSCompartment* comp); - -extern JS_FRIEND_API(bool) -IsAtomsZone(JS::Zone* zone); - -struct WeakMapTracer -{ - JSContext* context; - - explicit WeakMapTracer(JSContext* cx) : context(cx) {} - - // Weak map tracer callback, called once for every binding of every - // weak map that was live at the time of the last garbage collection. - // - // m will be nullptr if the weak map is not contained in a JS Object. - // - // The callback should not GC (and will assert in a debug build if it does so.) - virtual void trace(JSObject* m, JS::GCCellPtr key, JS::GCCellPtr value) = 0; -}; - -extern JS_FRIEND_API(void) -TraceWeakMaps(WeakMapTracer* trc); - -extern JS_FRIEND_API(bool) -AreGCGrayBitsValid(JSContext* cx); - -extern JS_FRIEND_API(bool) -ZoneGlobalsAreAllGray(JS::Zone* zone); - -typedef void -(*GCThingCallback)(void* closure, JS::GCCellPtr thing); - -extern JS_FRIEND_API(void) -VisitGrayWrapperTargets(JS::Zone* zone, GCThingCallback callback, void* closure); - -extern JS_FRIEND_API(JSObject*) -GetWeakmapKeyDelegate(JSObject* key); - -/** - * Invoke cellCallback on every gray JSObject in the given zone. - */ -extern JS_FRIEND_API(void) -IterateGrayObjects(JS::Zone* zone, GCThingCallback cellCallback, void* data); - -/** - * Invoke cellCallback on every gray JSObject in the given zone while cycle - * collection is in progress. - */ -extern JS_FRIEND_API(void) -IterateGrayObjectsUnderCC(JS::Zone* zone, GCThingCallback cellCallback, void* data); - -#ifdef JS_HAS_CTYPES -extern JS_FRIEND_API(size_t) -SizeOfDataIfCDataObject(mozilla::MallocSizeOf mallocSizeOf, JSObject* obj); -#endif - -extern JS_FRIEND_API(JSCompartment*) -GetAnyCompartmentInZone(JS::Zone* zone); - -/* - * Shadow declarations of JS internal structures, for access by inline access - * functions below. Do not use these structures in any other way. When adding - * new fields for access by inline methods, make sure to add static asserts to - * the original header file to ensure that offsets are consistent. - */ -namespace shadow { - -struct ObjectGroup { - const Class* clasp; - JSObject* proto; - JSCompartment* compartment; -}; - -struct BaseShape { - const js::Class* clasp_; - JSObject* parent; -}; - -class Shape { -public: - shadow::BaseShape* base; - jsid _1; - uint32_t slotInfo; - - static const uint32_t FIXED_SLOTS_SHIFT = 27; -}; - -/** - * This layout is shared by all native objects. For non-native objects, the - * group may always be accessed safely, and other members may be as well, - * depending on the object's specific layout. - */ -struct Object { - shadow::ObjectGroup* group; - shadow::Shape* shape; - JS::Value* slots; - void* _1; - - size_t numFixedSlots() const { return shape->slotInfo >> Shape::FIXED_SLOTS_SHIFT; } - JS::Value* fixedSlots() const { - return (JS::Value*)(uintptr_t(this) + sizeof(shadow::Object)); - } - - JS::Value& slotRef(size_t slot) const { - size_t nfixed = numFixedSlots(); - if (slot < nfixed) - return fixedSlots()[slot]; - return slots[slot - nfixed]; - } -}; - -struct Function { - Object base; - uint16_t nargs; - uint16_t flags; - /* Used only for natives */ - JSNative native; - const JSJitInfo* jitinfo; - void* _1; -}; - -struct String -{ - static const uint32_t INLINE_CHARS_BIT = JS_BIT(2); - static const uint32_t LATIN1_CHARS_BIT = JS_BIT(6); - static const uint32_t ROPE_FLAGS = 0; - static const uint32_t TYPE_FLAGS_MASK = JS_BIT(6) - 1; - uint32_t flags; - uint32_t length; - union { - const JS::Latin1Char* nonInlineCharsLatin1; - const char16_t* nonInlineCharsTwoByte; - JS::Latin1Char inlineStorageLatin1[1]; - char16_t inlineStorageTwoByte[1]; - }; -}; - -} /* namespace shadow */ - -// This is equal to |&JSObject::class_|. Use it in places where you don't want -// to #include jsobj.h. -extern JS_FRIEND_DATA(const js::Class* const) ObjectClassPtr; - -inline const js::Class* -GetObjectClass(const JSObject* obj) -{ - return reinterpret_cast<const shadow::Object*>(obj)->group->clasp; -} - -inline const JSClass* -GetObjectJSClass(JSObject* obj) -{ - return js::Jsvalify(GetObjectClass(obj)); -} - -JS_FRIEND_API(const Class*) -ProtoKeyToClass(JSProtoKey key); - -// Returns the key for the class inherited by a given standard class (that -// is to say, the prototype of this standard class's prototype). -// -// You must be sure that this corresponds to a standard class with a cached -// JSProtoKey before calling this function. In general |key| will match the -// cached proto key, except in cases where multiple JSProtoKeys share a -// JSClass. -inline JSProtoKey -InheritanceProtoKeyForStandardClass(JSProtoKey key) -{ - // [Object] has nothing to inherit from. - if (key == JSProto_Object) - return JSProto_Null; - - // If we're ClassSpec defined return the proto key from that - if (ProtoKeyToClass(key)->specDefined()) - return ProtoKeyToClass(key)->specInheritanceProtoKey(); - - // Otherwise, we inherit [Object]. - return JSProto_Object; -} - -JS_FRIEND_API(bool) -IsFunctionObject(JSObject* obj); - -static MOZ_ALWAYS_INLINE JSCompartment* -GetObjectCompartment(JSObject* obj) -{ - return reinterpret_cast<shadow::Object*>(obj)->group->compartment; -} - -JS_FRIEND_API(JSObject*) -GetGlobalForObjectCrossCompartment(JSObject* obj); - -JS_FRIEND_API(JSObject*) -GetPrototypeNoProxy(JSObject* obj); - -JS_FRIEND_API(void) -AssertSameCompartment(JSContext* cx, JSObject* obj); - -#ifdef JS_DEBUG -JS_FRIEND_API(void) -AssertSameCompartment(JSObject* objA, JSObject* objB); -#else -inline void AssertSameCompartment(JSObject* objA, JSObject* objB) {} -#endif - -JS_FRIEND_API(void) -NotifyAnimationActivity(JSObject* obj); - -/** - * Return the outermost enclosing function (script) of the scripted caller. - * This function returns nullptr in several cases: - * - no script is running on the context - * - the caller is in global or eval code - * In particular, this function will "stop" its outermost search at eval() and - * thus it will really return the outermost enclosing function *since the - * innermost eval*. - */ -JS_FRIEND_API(JSFunction*) -GetOutermostEnclosingFunctionOfScriptedCaller(JSContext* cx); - -JS_FRIEND_API(JSFunction*) -DefineFunctionWithReserved(JSContext* cx, JSObject* obj, const char* name, JSNative call, - unsigned nargs, unsigned attrs); - -JS_FRIEND_API(JSFunction*) -NewFunctionWithReserved(JSContext* cx, JSNative call, unsigned nargs, unsigned flags, - const char* name); - -JS_FRIEND_API(JSFunction*) -NewFunctionByIdWithReserved(JSContext* cx, JSNative native, unsigned nargs, unsigned flags, - jsid id); - -JS_FRIEND_API(const JS::Value&) -GetFunctionNativeReserved(JSObject* fun, size_t which); - -JS_FRIEND_API(void) -SetFunctionNativeReserved(JSObject* fun, size_t which, const JS::Value& val); - -JS_FRIEND_API(bool) -FunctionHasNativeReserved(JSObject* fun); - -JS_FRIEND_API(bool) -GetObjectProto(JSContext* cx, JS::HandleObject obj, JS::MutableHandleObject proto); - -extern JS_FRIEND_API(JSObject*) -GetStaticPrototype(JSObject* obj); - -JS_FRIEND_API(bool) -GetOriginalEval(JSContext* cx, JS::HandleObject scope, - JS::MutableHandleObject eval); - -inline void* -GetObjectPrivate(JSObject* obj) -{ - MOZ_ASSERT(GetObjectClass(obj)->flags & JSCLASS_HAS_PRIVATE); - const shadow::Object* nobj = reinterpret_cast<const shadow::Object*>(obj); - void** addr = reinterpret_cast<void**>(&nobj->fixedSlots()[nobj->numFixedSlots()]); - return *addr; -} - -inline const JS::Value& -GetReservedSlot(JSObject* obj, size_t slot) -{ - MOZ_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); - return reinterpret_cast<const shadow::Object*>(obj)->slotRef(slot); -} - -JS_FRIEND_API(void) -SetReservedOrProxyPrivateSlotWithBarrier(JSObject* obj, size_t slot, const JS::Value& value); - -inline void -SetReservedSlot(JSObject* obj, size_t slot, const JS::Value& value) -{ - MOZ_ASSERT(slot < JSCLASS_RESERVED_SLOTS(GetObjectClass(obj))); - shadow::Object* sobj = reinterpret_cast<shadow::Object*>(obj); - if (sobj->slotRef(slot).isMarkable() || value.isMarkable()) - SetReservedOrProxyPrivateSlotWithBarrier(obj, slot, value); - else - sobj->slotRef(slot) = value; -} - -JS_FRIEND_API(uint32_t) -GetObjectSlotSpan(JSObject* obj); - -inline const JS::Value& -GetObjectSlot(JSObject* obj, size_t slot) -{ - MOZ_ASSERT(slot < GetObjectSlotSpan(obj)); - return reinterpret_cast<const shadow::Object*>(obj)->slotRef(slot); -} - -MOZ_ALWAYS_INLINE size_t -GetAtomLength(JSAtom* atom) -{ - return reinterpret_cast<shadow::String*>(atom)->length; -} - -static const uint32_t MaxStringLength = (1 << 28) - 1; - -MOZ_ALWAYS_INLINE size_t -GetStringLength(JSString* s) -{ - return reinterpret_cast<shadow::String*>(s)->length; -} - -MOZ_ALWAYS_INLINE size_t -GetFlatStringLength(JSFlatString* s) -{ - return reinterpret_cast<shadow::String*>(s)->length; -} - -MOZ_ALWAYS_INLINE size_t -GetLinearStringLength(JSLinearString* s) -{ - return reinterpret_cast<shadow::String*>(s)->length; -} - -MOZ_ALWAYS_INLINE bool -LinearStringHasLatin1Chars(JSLinearString* s) -{ - return reinterpret_cast<shadow::String*>(s)->flags & shadow::String::LATIN1_CHARS_BIT; -} - -MOZ_ALWAYS_INLINE bool -AtomHasLatin1Chars(JSAtom* atom) -{ - return reinterpret_cast<shadow::String*>(atom)->flags & shadow::String::LATIN1_CHARS_BIT; -} - -MOZ_ALWAYS_INLINE bool -StringHasLatin1Chars(JSString* s) -{ - return reinterpret_cast<shadow::String*>(s)->flags & shadow::String::LATIN1_CHARS_BIT; -} - -MOZ_ALWAYS_INLINE const JS::Latin1Char* -GetLatin1LinearStringChars(const JS::AutoCheckCannotGC& nogc, JSLinearString* linear) -{ - MOZ_ASSERT(LinearStringHasLatin1Chars(linear)); - - using shadow::String; - String* s = reinterpret_cast<String*>(linear); - if (s->flags & String::INLINE_CHARS_BIT) - return s->inlineStorageLatin1; - return s->nonInlineCharsLatin1; -} - -MOZ_ALWAYS_INLINE const char16_t* -GetTwoByteLinearStringChars(const JS::AutoCheckCannotGC& nogc, JSLinearString* linear) -{ - MOZ_ASSERT(!LinearStringHasLatin1Chars(linear)); - - using shadow::String; - String* s = reinterpret_cast<String*>(linear); - if (s->flags & String::INLINE_CHARS_BIT) - return s->inlineStorageTwoByte; - return s->nonInlineCharsTwoByte; -} - -MOZ_ALWAYS_INLINE JSLinearString* -AtomToLinearString(JSAtom* atom) -{ - return reinterpret_cast<JSLinearString*>(atom); -} - -MOZ_ALWAYS_INLINE JSFlatString* -AtomToFlatString(JSAtom* atom) -{ - return reinterpret_cast<JSFlatString*>(atom); -} - -MOZ_ALWAYS_INLINE JSLinearString* -FlatStringToLinearString(JSFlatString* s) -{ - return reinterpret_cast<JSLinearString*>(s); -} - -MOZ_ALWAYS_INLINE const JS::Latin1Char* -GetLatin1AtomChars(const JS::AutoCheckCannotGC& nogc, JSAtom* atom) -{ - return GetLatin1LinearStringChars(nogc, AtomToLinearString(atom)); -} - -MOZ_ALWAYS_INLINE const char16_t* -GetTwoByteAtomChars(const JS::AutoCheckCannotGC& nogc, JSAtom* atom) -{ - return GetTwoByteLinearStringChars(nogc, AtomToLinearString(atom)); -} - -JS_FRIEND_API(JSLinearString*) -StringToLinearStringSlow(JSContext* cx, JSString* str); - -MOZ_ALWAYS_INLINE JSLinearString* -StringToLinearString(JSContext* cx, JSString* str) -{ - using shadow::String; - String* s = reinterpret_cast<String*>(str); - if (MOZ_UNLIKELY((s->flags & String::TYPE_FLAGS_MASK) == String::ROPE_FLAGS)) - return StringToLinearStringSlow(cx, str); - return reinterpret_cast<JSLinearString*>(str); -} - -template<typename CharType> -MOZ_ALWAYS_INLINE void -CopyLinearStringChars(CharType* dest, JSLinearString* s, size_t len, size_t start = 0); - -MOZ_ALWAYS_INLINE void -CopyLinearStringChars(char16_t* dest, JSLinearString* s, size_t len, size_t start = 0) -{ - MOZ_ASSERT(start + len <= GetLinearStringLength(s)); - JS::AutoCheckCannotGC nogc; - if (LinearStringHasLatin1Chars(s)) { - const JS::Latin1Char* src = GetLatin1LinearStringChars(nogc, s); - for (size_t i = 0; i < len; i++) - dest[i] = src[start + i]; - } else { - const char16_t* src = GetTwoByteLinearStringChars(nogc, s); - mozilla::PodCopy(dest, src + start, len); - } -} - -MOZ_ALWAYS_INLINE void -CopyLinearStringChars(char* dest, JSLinearString* s, size_t len, size_t start = 0) -{ - MOZ_ASSERT(start + len <= GetLinearStringLength(s)); - JS::AutoCheckCannotGC nogc; - if (LinearStringHasLatin1Chars(s)) { - const JS::Latin1Char* src = GetLatin1LinearStringChars(nogc, s); - for (size_t i = 0; i < len; i++) - dest[i] = char(src[start + i]); - } else { - const char16_t* src = GetTwoByteLinearStringChars(nogc, s); - for (size_t i = 0; i < len; i++) - dest[i] = char(src[start + i]); - } -} - -template<typename CharType> -inline bool -CopyStringChars(JSContext* cx, CharType* dest, JSString* s, size_t len, size_t start = 0) -{ - JSLinearString* linear = StringToLinearString(cx, s); - if (!linear) - return false; - - CopyLinearStringChars(dest, linear, len, start); - return true; -} - -inline void -CopyFlatStringChars(char16_t* dest, JSFlatString* s, size_t len) -{ - CopyLinearStringChars(dest, FlatStringToLinearString(s), len); -} - -/** - * Add some or all property keys of obj to the id vector *props. - * - * The flags parameter controls which property keys are added. Pass a - * combination of the following bits: - * - * JSITER_OWNONLY - Don't also search the prototype chain; only consider - * obj's own properties. - * - * JSITER_HIDDEN - Include nonenumerable properties. - * - * JSITER_SYMBOLS - Include property keys that are symbols. The default - * behavior is to filter out symbols. - * - * JSITER_SYMBOLSONLY - Exclude non-symbol property keys. - * - * This is the closest C++ API we have to `Reflect.ownKeys(obj)`, or - * equivalently, the ES6 [[OwnPropertyKeys]] internal method. Pass - * `JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS` as flags to get - * results that match the output of Reflect.ownKeys. - */ -JS_FRIEND_API(bool) -GetPropertyKeys(JSContext* cx, JS::HandleObject obj, unsigned flags, JS::AutoIdVector* props); - -JS_FRIEND_API(bool) -AppendUnique(JSContext* cx, JS::AutoIdVector& base, JS::AutoIdVector& others); - -JS_FRIEND_API(bool) -StringIsArrayIndex(JSLinearString* str, uint32_t* indexp); - -JS_FRIEND_API(void) -SetPreserveWrapperCallback(JSContext* cx, PreserveWrapperCallback callback); - -JS_FRIEND_API(bool) -IsObjectInContextCompartment(JSObject* obj, const JSContext* cx); - -/* - * NB: keep these in sync with the copy in builtin/SelfHostingDefines.h. - * The first three are omitted because they shouldn't be used in new code. - */ -#define JSITER_ENUMERATE 0x1 /* for-in compatible hidden default iterator */ -#define JSITER_FOREACH 0x2 /* get obj[key] for each property */ -#define JSITER_KEYVALUE 0x4 /* obsolete destructuring for-in wants [key, value] */ -#define JSITER_OWNONLY 0x8 /* iterate over obj's own properties only */ -#define JSITER_HIDDEN 0x10 /* also enumerate non-enumerable properties */ -#define JSITER_SYMBOLS 0x20 /* also include symbol property keys */ -#define JSITER_SYMBOLSONLY 0x40 /* exclude string property keys */ - -JS_FRIEND_API(bool) -RunningWithTrustedPrincipals(JSContext* cx); - -inline uintptr_t -GetNativeStackLimit(JSContext* cx, StackKind kind, int extraAllowance = 0) -{ - uintptr_t limit = ContextFriendFields::get(cx)->nativeStackLimit[kind]; -#if JS_STACK_GROWTH_DIRECTION > 0 - limit += extraAllowance; -#else - limit -= extraAllowance; -#endif - return limit; -} - -inline uintptr_t -GetNativeStackLimit(JSContext* cx, int extraAllowance = 0) -{ - StackKind kind = RunningWithTrustedPrincipals(cx) ? StackForTrustedScript - : StackForUntrustedScript; - return GetNativeStackLimit(cx, kind, extraAllowance); -} - -/* - * These macros report a stack overflow and run |onerror| if we are close to - * using up the C stack. The JS_CHECK_CHROME_RECURSION variant gives us a - * little extra space so that we can ensure that crucial code is able to run. - * JS_CHECK_RECURSION_CONSERVATIVE allows less space than any other check, - * including a safety buffer (as in, it uses the untrusted limit and subtracts - * a little more from it). - */ - -#define JS_CHECK_RECURSION_LIMIT(cx, limit, onerror) \ - JS_BEGIN_MACRO \ - int stackDummy_; \ - if (!JS_CHECK_STACK_SIZE(limit, &stackDummy_)) { \ - js::ReportOverRecursed(cx); \ - onerror; \ - } \ - JS_END_MACRO - -#define JS_CHECK_RECURSION(cx, onerror) \ - JS_CHECK_RECURSION_LIMIT(cx, js::GetNativeStackLimit(cx), onerror) - -#define JS_CHECK_RECURSION_LIMIT_DONT_REPORT(cx, limit, onerror) \ - JS_BEGIN_MACRO \ - int stackDummy_; \ - if (!JS_CHECK_STACK_SIZE(limit, &stackDummy_)) { \ - onerror; \ - } \ - JS_END_MACRO - -#define JS_CHECK_RECURSION_DONT_REPORT(cx, onerror) \ - JS_CHECK_RECURSION_LIMIT_DONT_REPORT(cx, js::GetNativeStackLimit(cx), onerror) - -#define JS_CHECK_RECURSION_WITH_SP_DONT_REPORT(cx, sp, onerror) \ - JS_BEGIN_MACRO \ - if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp)) { \ - onerror; \ - } \ - JS_END_MACRO - -#define JS_CHECK_RECURSION_WITH_SP(cx, sp, onerror) \ - JS_BEGIN_MACRO \ - if (!JS_CHECK_STACK_SIZE(js::GetNativeStackLimit(cx), sp)) { \ - js::ReportOverRecursed(cx); \ - onerror; \ - } \ - JS_END_MACRO - -#define JS_CHECK_SYSTEM_RECURSION(cx, onerror) \ - JS_CHECK_RECURSION_LIMIT(cx, js::GetNativeStackLimit(cx, js::StackForSystemCode), onerror) - -#define JS_CHECK_RECURSION_CONSERVATIVE(cx, onerror) \ - JS_CHECK_RECURSION_LIMIT(cx, \ - js::GetNativeStackLimit(cx, js::StackForUntrustedScript, -1024 * int(sizeof(size_t))), \ - onerror) - -#define JS_CHECK_RECURSION_CONSERVATIVE_DONT_REPORT(cx, onerror) \ - JS_CHECK_RECURSION_LIMIT_DONT_REPORT(cx, \ - js::GetNativeStackLimit(cx, js::StackForUntrustedScript, -1024 * int(sizeof(size_t))), \ - onerror) - -JS_FRIEND_API(void) -StartPCCountProfiling(JSContext* cx); - -JS_FRIEND_API(void) -StopPCCountProfiling(JSContext* cx); - -JS_FRIEND_API(void) -PurgePCCounts(JSContext* cx); - -JS_FRIEND_API(size_t) -GetPCCountScriptCount(JSContext* cx); - -JS_FRIEND_API(JSString*) -GetPCCountScriptSummary(JSContext* cx, size_t script); - -JS_FRIEND_API(JSString*) -GetPCCountScriptContents(JSContext* cx, size_t script); - -/** - * Generate lcov trace file content for the current compartment, and allocate a - * new buffer and return the content in it, the size of the newly allocated - * content within the buffer would be set to the length out-param. - * - * In case of out-of-memory, this function returns nullptr and does not set any - * value to the length out-param. - */ -JS_FRIEND_API(char*) -GetCodeCoverageSummary(JSContext* cx, size_t* length); - -typedef void -(* ActivityCallback)(void* arg, bool active); - -/** - * Sets a callback that is run whenever the runtime goes idle - the - * last active request ceases - and begins activity - when it was - * idle and a request begins. - */ -JS_FRIEND_API(void) -SetActivityCallback(JSContext* cx, ActivityCallback cb, void* arg); - -typedef bool -(* DOMInstanceClassHasProtoAtDepth)(const Class* instanceClass, - uint32_t protoID, uint32_t depth); -struct JSDOMCallbacks { - DOMInstanceClassHasProtoAtDepth instanceClassMatchesProto; -}; -typedef struct JSDOMCallbacks DOMCallbacks; - -extern JS_FRIEND_API(void) -SetDOMCallbacks(JSContext* cx, const DOMCallbacks* callbacks); - -extern JS_FRIEND_API(const DOMCallbacks*) -GetDOMCallbacks(JSContext* cx); - -extern JS_FRIEND_API(JSObject*) -GetTestingFunctions(JSContext* cx); - -/** - * Helper to convert FreeOp to JSFreeOp when the definition of FreeOp is not - * available and the compiler does not know that FreeOp inherits from - * JSFreeOp. - */ -inline JSFreeOp* -CastToJSFreeOp(FreeOp* fop) -{ - return reinterpret_cast<JSFreeOp*>(fop); -} - -/* Implemented in jsexn.cpp. */ - -/** - * Get an error type name from a JSExnType constant. - * Returns nullptr for invalid arguments and JSEXN_INTERNALERR - */ -extern JS_FRIEND_API(JSFlatString*) -GetErrorTypeName(JSContext* cx, int16_t exnType); - -#ifdef JS_DEBUG -extern JS_FRIEND_API(unsigned) -GetEnterCompartmentDepth(JSContext* cx); -#endif - -class RegExpGuard; -extern JS_FRIEND_API(bool) -RegExpToSharedNonInline(JSContext* cx, JS::HandleObject regexp, RegExpGuard* shared); - -/* Implemented in jswrapper.cpp. */ -typedef enum NukeReferencesToWindow { - NukeWindowReferences, - DontNukeWindowReferences -} NukeReferencesToWindow; - -/* - * These filters are designed to be ephemeral stack classes, and thus don't - * do any rooting or holding of their members. - */ -struct CompartmentFilter { - virtual bool match(JSCompartment* c) const = 0; -}; - -struct AllCompartments : public CompartmentFilter { - virtual bool match(JSCompartment* c) const override { return true; } -}; - -struct ContentCompartmentsOnly : public CompartmentFilter { - virtual bool match(JSCompartment* c) const override { - return !IsSystemCompartment(c); - } -}; - -struct ChromeCompartmentsOnly : public CompartmentFilter { - virtual bool match(JSCompartment* c) const override { - return IsSystemCompartment(c); - } -}; - -struct SingleCompartment : public CompartmentFilter { - JSCompartment* ours; - explicit SingleCompartment(JSCompartment* c) : ours(c) {} - virtual bool match(JSCompartment* c) const override { return c == ours; } -}; - -struct CompartmentsWithPrincipals : public CompartmentFilter { - JSPrincipals* principals; - explicit CompartmentsWithPrincipals(JSPrincipals* p) : principals(p) {} - virtual bool match(JSCompartment* c) const override { - return JS_GetCompartmentPrincipals(c) == principals; - } -}; - -extern JS_FRIEND_API(bool) -NukeCrossCompartmentWrappers(JSContext* cx, - const CompartmentFilter& sourceFilter, - const CompartmentFilter& targetFilter, - NukeReferencesToWindow nukeReferencesToWindow); - -/* Specify information about DOMProxy proxies in the DOM, for use by ICs. */ - -/* - * The DOMProxyShadowsCheck function will be called to check if the property for - * id should be gotten from the prototype, or if there is an own property that - * shadows it. - * * If ShadowsViaDirectExpando is returned, then the slot at - * listBaseExpandoSlot contains an expando object which has the property in - * question. - * * If ShadowsViaIndirectExpando is returned, then the slot at - * listBaseExpandoSlot contains a private pointer to an ExpandoAndGeneration - * and the expando object in the ExpandoAndGeneration has the property in - * question. - * * If DoesntShadow is returned then the slot at listBaseExpandoSlot should - * either be undefined or point to an expando object that would contain the - * own property. - * * If DoesntShadowUnique is returned then the slot at listBaseExpandoSlot - * should contain a private pointer to a ExpandoAndGeneration, which contains - * a JS::Value that should either be undefined or point to an expando object, - * and a uint64 value. If that value changes then the IC for getting a - * property will be invalidated. - * * If Shadows is returned, that means the property is an own property of the - * proxy but doesn't live on the expando object. - */ - -struct ExpandoAndGeneration { - ExpandoAndGeneration() - : expando(JS::UndefinedValue()), - generation(0) - {} - - void OwnerUnlinked() - { - ++generation; - } - - static size_t offsetOfExpando() - { - return offsetof(ExpandoAndGeneration, expando); - } - - static size_t offsetOfGeneration() - { - return offsetof(ExpandoAndGeneration, generation); - } - - JS::Heap<JS::Value> expando; - uint64_t generation; -}; - -typedef enum DOMProxyShadowsResult { - ShadowCheckFailed, - Shadows, - DoesntShadow, - DoesntShadowUnique, - ShadowsViaDirectExpando, - ShadowsViaIndirectExpando -} DOMProxyShadowsResult; -typedef DOMProxyShadowsResult -(* DOMProxyShadowsCheck)(JSContext* cx, JS::HandleObject object, JS::HandleId id); -JS_FRIEND_API(void) -SetDOMProxyInformation(const void* domProxyHandlerFamily, uint32_t domProxyExpandoSlot, - DOMProxyShadowsCheck domProxyShadowsCheck); - -const void* GetDOMProxyHandlerFamily(); -uint32_t GetDOMProxyExpandoSlot(); -DOMProxyShadowsCheck GetDOMProxyShadowsCheck(); -inline bool DOMProxyIsShadowing(DOMProxyShadowsResult result) { - return result == Shadows || - result == ShadowsViaDirectExpando || - result == ShadowsViaIndirectExpando; -} - -/* Implemented in jsdate.cpp. */ - -/** Detect whether the internal date value is NaN. */ -extern JS_FRIEND_API(bool) -DateIsValid(JSContext* cx, JS::HandleObject obj, bool* isValid); - -extern JS_FRIEND_API(bool) -DateGetMsecSinceEpoch(JSContext* cx, JS::HandleObject obj, double* msecSinceEpoch); - -} /* namespace js */ - -/* Implemented in jscntxt.cpp. */ - -/** - * Report an exception, which is currently realized as a printf-style format - * string and its arguments. - */ -typedef enum JSErrNum { -#define MSG_DEF(name, count, exception, format) \ - name, -#include "js.msg" -#undef MSG_DEF - JSErr_Limit -} JSErrNum; - -namespace js { - -extern JS_FRIEND_API(const JSErrorFormatString*) -GetErrorMessage(void* userRef, const unsigned errorNumber); - -// AutoStableStringChars is here so we can use it in ErrorReport. It -// should get moved out of here if we can manage it. See bug 1040316. - -/** - * This class provides safe access to a string's chars across a GC. Once - * we allocate strings and chars in the nursery (bug 903519), this class - * will have to make a copy of the string's chars if they are allocated - * in the nursery, so it's best to avoid using this class unless you really - * need it. It's usually more efficient to use the latin1Chars/twoByteChars - * JSString methods and often the code can be rewritten so that only indexes - * instead of char pointers are used in parts of the code that can GC. - */ -class MOZ_STACK_CLASS AutoStableStringChars -{ - /* - * When copying string char, use this many bytes of inline storage. This is - * chosen to allow the inline string types to be copied without allocating. - * This is asserted in AutoStableStringChars::allocOwnChars. - */ - static const size_t InlineCapacity = 24; - - /* Ensure the string is kept alive while we're using its chars. */ - JS::RootedString s_; - union { - const char16_t* twoByteChars_; - const JS::Latin1Char* latin1Chars_; - }; - mozilla::Maybe<Vector<uint8_t, InlineCapacity>> ownChars_; - enum State { Uninitialized, Latin1, TwoByte }; - State state_; - - public: - explicit AutoStableStringChars(JSContext* cx) - : s_(cx), state_(Uninitialized) - {} - - MOZ_MUST_USE - bool init(JSContext* cx, JSString* s); - - /* Like init(), but Latin1 chars are inflated to TwoByte. */ - MOZ_MUST_USE - bool initTwoByte(JSContext* cx, JSString* s); - - bool isLatin1() const { return state_ == Latin1; } - bool isTwoByte() const { return state_ == TwoByte; } - - const char16_t* twoByteChars() const { - MOZ_ASSERT(state_ == TwoByte); - return twoByteChars_; - } - - mozilla::Range<const JS::Latin1Char> latin1Range() const { - MOZ_ASSERT(state_ == Latin1); - return mozilla::Range<const JS::Latin1Char>(latin1Chars_, - GetStringLength(s_)); - } - - mozilla::Range<const char16_t> twoByteRange() const { - MOZ_ASSERT(state_ == TwoByte); - return mozilla::Range<const char16_t>(twoByteChars_, - GetStringLength(s_)); - } - - /* If we own the chars, transfer ownership to the caller. */ - bool maybeGiveOwnershipToCaller() { - MOZ_ASSERT(state_ != Uninitialized); - if (!ownChars_.isSome() || !ownChars_->extractRawBuffer()) - return false; - state_ = Uninitialized; - ownChars_.reset(); - return true; - } - - private: - AutoStableStringChars(const AutoStableStringChars& other) = delete; - void operator=(const AutoStableStringChars& other) = delete; - - bool baseIsInline(JS::Handle<JSLinearString*> linearString); - template <typename T> T* allocOwnChars(JSContext* cx, size_t count); - bool copyLatin1Chars(JSContext* cx, JS::Handle<JSLinearString*> linearString); - bool copyTwoByteChars(JSContext* cx, JS::Handle<JSLinearString*> linearString); - bool copyAndInflateLatin1Chars(JSContext*, JS::Handle<JSLinearString*> linearString); -}; - -struct MOZ_STACK_CLASS JS_FRIEND_API(ErrorReport) -{ - explicit ErrorReport(JSContext* cx); - ~ErrorReport(); - - enum SniffingBehavior { - WithSideEffects, - NoSideEffects - }; - - /** - * Generate a JSErrorReport from the provided thrown value. - * - * If the value is a (possibly wrapped) Error object, the JSErrorReport will - * be exactly initialized from the Error object's information, without - * observable side effects. (The Error object's JSErrorReport is reused, if - * it has one.) - * - * Otherwise various attempts are made to derive JSErrorReport information - * from |exn| and from the current execution state. This process is - * *definitely* inconsistent with any standard, and particulars of the - * behavior implemented here generally shouldn't be relied upon. - * - * If the value of |sniffingBehavior| is |WithSideEffects|, some of these - * attempts *may* invoke user-configurable behavior when |exn| is an object: - * converting |exn| to a string, detecting and getting properties on |exn|, - * accessing |exn|'s prototype chain, and others are possible. Users *must* - * tolerate |ErrorReport::init| potentially having arbitrary effects. Any - * exceptions thrown by these operations will be caught and silently - * ignored, and "default" values will be substituted into the JSErrorReport. - * - * But if the value of |sniffingBehavior| is |NoSideEffects|, these attempts - * *will not* invoke any observable side effects. The JSErrorReport will - * simply contain fewer, less precise details. - * - * Unlike some functions involved in error handling, this function adheres - * to the usual JSAPI return value error behavior. - */ - bool init(JSContext* cx, JS::HandleValue exn, - SniffingBehavior sniffingBehavior); - - JSErrorReport* report() - { - return reportp; - } - - const JS::ConstUTF8CharsZ toStringResult() - { - return toStringResult_; - } - - private: - // More or less an equivalent of JS_ReportErrorNumber/js::ReportErrorNumberVA - // but fills in an ErrorReport instead of reporting it. Uses varargs to - // make it simpler to call js::ExpandErrorArgumentsVA. - // - // Returns false if we fail to actually populate the ErrorReport - // for some reason (probably out of memory). - bool populateUncaughtExceptionReportUTF8(JSContext* cx, ...); - bool populateUncaughtExceptionReportUTF8VA(JSContext* cx, va_list ap); - - // Reports exceptions from add-on scopes to telementry. - void ReportAddonExceptionToTelementry(JSContext* cx); - - // We may have a provided JSErrorReport, so need a way to represent that. - JSErrorReport* reportp; - - // Or we may need to synthesize a JSErrorReport one of our own. - JSErrorReport ownedReport; - - // And we have a string to maybe keep alive that has pointers into - // it from ownedReport. - JS::RootedString str; - - // And keep its chars alive too. - AutoStableStringChars strChars; - - // And we need to root our exception value. - JS::RootedObject exnObject; - - // And for our filename. - JSAutoByteString filename; - - // We may have a result of error.toString(). - // FIXME: We should not call error.toString(), since it could have side - // effect (see bug 633623). - JS::ConstUTF8CharsZ toStringResult_; - JSAutoByteString toStringResultBytesStorage; -}; - -/* Implemented in vm/StructuredClone.cpp. */ -extern JS_FRIEND_API(uint64_t) -GetSCOffset(JSStructuredCloneWriter* writer); - -namespace Scalar { - -/** - * Scalar types that can appear in typed arrays and typed objects. The enum - * values must to be kept in sync with the JS_SCALARTYPEREPR_ constants, as - * well as the TypedArrayObject::classes and TypedArrayObject::protoClasses - * definitions. - */ -enum Type { - Int8 = 0, - Uint8, - Int16, - Uint16, - Int32, - Uint32, - Float32, - Float64, - - /** - * Special type that is a uint8_t, but assignments are clamped to [0, 256). - * Treat the raw data type as a uint8_t. - */ - Uint8Clamped, - - /** - * Types that don't have their own TypedArray equivalent, for now. - */ - MaxTypedArrayViewType, - - Int64, - Float32x4, - Int8x16, - Int16x8, - Int32x4 -}; - -static inline size_t -byteSize(Type atype) -{ - switch (atype) { - case Int8: - case Uint8: - case Uint8Clamped: - return 1; - case Int16: - case Uint16: - return 2; - case Int32: - case Uint32: - case Float32: - return 4; - case Int64: - case Float64: - return 8; - case Int8x16: - case Int16x8: - case Int32x4: - case Float32x4: - return 16; - default: - MOZ_CRASH("invalid scalar type"); - } -} - -static inline bool -isSignedIntType(Type atype) { - switch (atype) { - case Int8: - case Int16: - case Int32: - case Int64: - case Int8x16: - case Int16x8: - case Int32x4: - return true; - case Uint8: - case Uint8Clamped: - case Uint16: - case Uint32: - case Float32: - case Float64: - case Float32x4: - return false; - default: - MOZ_CRASH("invalid scalar type"); - } -} - -static inline bool -isSimdType(Type atype) { - switch (atype) { - case Int8: - case Uint8: - case Uint8Clamped: - case Int16: - case Uint16: - case Int32: - case Uint32: - case Int64: - case Float32: - case Float64: - return false; - case Int8x16: - case Int16x8: - case Int32x4: - case Float32x4: - return true; - case MaxTypedArrayViewType: - break; - } - MOZ_CRASH("invalid scalar type"); -} - -static inline size_t -scalarByteSize(Type atype) { - switch (atype) { - case Int8x16: - return 1; - case Int16x8: - return 2; - case Int32x4: - case Float32x4: - return 4; - case Int8: - case Uint8: - case Uint8Clamped: - case Int16: - case Uint16: - case Int32: - case Uint32: - case Int64: - case Float32: - case Float64: - case MaxTypedArrayViewType: - break; - } - MOZ_CRASH("invalid simd type"); -} - -} /* namespace Scalar */ -} /* namespace js */ - -/* - * Create a new typed array with nelements elements. - * - * These functions (except the WithBuffer variants) fill in the array with zeros. - */ - -extern JS_FRIEND_API(JSObject*) -JS_NewInt8Array(JSContext* cx, uint32_t nelements); -extern JS_FRIEND_API(JSObject*) -JS_NewUint8Array(JSContext* cx, uint32_t nelements); -extern JS_FRIEND_API(JSObject*) -JS_NewUint8ClampedArray(JSContext* cx, uint32_t nelements); -extern JS_FRIEND_API(JSObject*) -JS_NewInt16Array(JSContext* cx, uint32_t nelements); -extern JS_FRIEND_API(JSObject*) -JS_NewUint16Array(JSContext* cx, uint32_t nelements); -extern JS_FRIEND_API(JSObject*) -JS_NewInt32Array(JSContext* cx, uint32_t nelements); -extern JS_FRIEND_API(JSObject*) -JS_NewUint32Array(JSContext* cx, uint32_t nelements); -extern JS_FRIEND_API(JSObject*) -JS_NewFloat32Array(JSContext* cx, uint32_t nelements); -extern JS_FRIEND_API(JSObject*) -JS_NewFloat64Array(JSContext* cx, uint32_t nelements); - -/* - * Create a new typed array and copy in values from the given object. The - * object is used as if it were an array; that is, the new array (if - * successfully created) will have length given by array.length, and its - * elements will be those specified by array[0], array[1], and so on, after - * conversion to the typed array element type. - */ - -extern JS_FRIEND_API(JSObject*) -JS_NewInt8ArrayFromArray(JSContext* cx, JS::HandleObject array); -extern JS_FRIEND_API(JSObject*) -JS_NewUint8ArrayFromArray(JSContext* cx, JS::HandleObject array); -extern JS_FRIEND_API(JSObject*) -JS_NewUint8ClampedArrayFromArray(JSContext* cx, JS::HandleObject array); -extern JS_FRIEND_API(JSObject*) -JS_NewInt16ArrayFromArray(JSContext* cx, JS::HandleObject array); -extern JS_FRIEND_API(JSObject*) -JS_NewUint16ArrayFromArray(JSContext* cx, JS::HandleObject array); -extern JS_FRIEND_API(JSObject*) -JS_NewInt32ArrayFromArray(JSContext* cx, JS::HandleObject array); -extern JS_FRIEND_API(JSObject*) -JS_NewUint32ArrayFromArray(JSContext* cx, JS::HandleObject array); -extern JS_FRIEND_API(JSObject*) -JS_NewFloat32ArrayFromArray(JSContext* cx, JS::HandleObject array); -extern JS_FRIEND_API(JSObject*) -JS_NewFloat64ArrayFromArray(JSContext* cx, JS::HandleObject array); - -/* - * Create a new typed array using the given ArrayBuffer or - * SharedArrayBuffer for storage. The length value is optional; if -1 - * is passed, enough elements to use up the remainder of the byte - * array is used as the default value. - */ - -extern JS_FRIEND_API(JSObject*) -JS_NewInt8ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, - uint32_t byteOffset, int32_t length); -extern JS_FRIEND_API(JSObject*) -JS_NewUint8ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, - uint32_t byteOffset, int32_t length); -extern JS_FRIEND_API(JSObject*) -JS_NewUint8ClampedArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, - uint32_t byteOffset, int32_t length); -extern JS_FRIEND_API(JSObject*) -JS_NewInt16ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, - uint32_t byteOffset, int32_t length); -extern JS_FRIEND_API(JSObject*) -JS_NewUint16ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, - uint32_t byteOffset, int32_t length); -extern JS_FRIEND_API(JSObject*) -JS_NewInt32ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, - uint32_t byteOffset, int32_t length); -extern JS_FRIEND_API(JSObject*) -JS_NewUint32ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, - uint32_t byteOffset, int32_t length); -extern JS_FRIEND_API(JSObject*) -JS_NewFloat32ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, - uint32_t byteOffset, int32_t length); -extern JS_FRIEND_API(JSObject*) -JS_NewFloat64ArrayWithBuffer(JSContext* cx, JS::HandleObject arrayBuffer, - uint32_t byteOffset, int32_t length); - -/** - * Create a new SharedArrayBuffer with the given byte length. This - * may only be called if - * JS::CompartmentCreationOptionsRef(cx).getSharedMemoryAndAtomicsEnabled() is - * true. - */ -extern JS_FRIEND_API(JSObject*) -JS_NewSharedArrayBuffer(JSContext* cx, uint32_t nbytes); - -/** - * Create a new ArrayBuffer with the given byte length. - */ -extern JS_FRIEND_API(JSObject*) -JS_NewArrayBuffer(JSContext* cx, uint32_t nbytes); - -/** - * Check whether obj supports JS_GetTypedArray* APIs. Note that this may return - * false if a security wrapper is encountered that denies the unwrapping. If - * this test or one of the JS_Is*Array tests succeeds, then it is safe to call - * the various accessor JSAPI calls defined below. - */ -extern JS_FRIEND_API(bool) -JS_IsTypedArrayObject(JSObject* obj); - -/** - * Check whether obj supports JS_GetArrayBufferView* APIs. Note that this may - * return false if a security wrapper is encountered that denies the - * unwrapping. If this test or one of the more specific tests succeeds, then it - * is safe to call the various ArrayBufferView accessor JSAPI calls defined - * below. - */ -extern JS_FRIEND_API(bool) -JS_IsArrayBufferViewObject(JSObject* obj); - -/* - * Test for specific typed array types (ArrayBufferView subtypes) - */ - -extern JS_FRIEND_API(bool) -JS_IsInt8Array(JSObject* obj); -extern JS_FRIEND_API(bool) -JS_IsUint8Array(JSObject* obj); -extern JS_FRIEND_API(bool) -JS_IsUint8ClampedArray(JSObject* obj); -extern JS_FRIEND_API(bool) -JS_IsInt16Array(JSObject* obj); -extern JS_FRIEND_API(bool) -JS_IsUint16Array(JSObject* obj); -extern JS_FRIEND_API(bool) -JS_IsInt32Array(JSObject* obj); -extern JS_FRIEND_API(bool) -JS_IsUint32Array(JSObject* obj); -extern JS_FRIEND_API(bool) -JS_IsFloat32Array(JSObject* obj); -extern JS_FRIEND_API(bool) -JS_IsFloat64Array(JSObject* obj); - -/** - * Return the isShared flag of a typed array, which denotes whether - * the underlying buffer is a SharedArrayBuffer. - * - * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow - * be known that it would pass such a test: it is a typed array or a wrapper of - * a typed array, and the unwrapping will succeed. - */ -extern JS_FRIEND_API(bool) -JS_GetTypedArraySharedness(JSObject* obj); - -/* - * Test for specific typed array types (ArrayBufferView subtypes) and return - * the unwrapped object if so, else nullptr. Never throws. - */ - -namespace js { - -extern JS_FRIEND_API(JSObject*) -UnwrapInt8Array(JSObject* obj); -extern JS_FRIEND_API(JSObject*) -UnwrapUint8Array(JSObject* obj); -extern JS_FRIEND_API(JSObject*) -UnwrapUint8ClampedArray(JSObject* obj); -extern JS_FRIEND_API(JSObject*) -UnwrapInt16Array(JSObject* obj); -extern JS_FRIEND_API(JSObject*) -UnwrapUint16Array(JSObject* obj); -extern JS_FRIEND_API(JSObject*) -UnwrapInt32Array(JSObject* obj); -extern JS_FRIEND_API(JSObject*) -UnwrapUint32Array(JSObject* obj); -extern JS_FRIEND_API(JSObject*) -UnwrapFloat32Array(JSObject* obj); -extern JS_FRIEND_API(JSObject*) -UnwrapFloat64Array(JSObject* obj); - -extern JS_FRIEND_API(JSObject*) -UnwrapArrayBuffer(JSObject* obj); - -extern JS_FRIEND_API(JSObject*) -UnwrapArrayBufferView(JSObject* obj); - -extern JS_FRIEND_API(JSObject*) -UnwrapSharedArrayBuffer(JSObject* obj); - - -namespace detail { - -extern JS_FRIEND_DATA(const Class* const) Int8ArrayClassPtr; -extern JS_FRIEND_DATA(const Class* const) Uint8ArrayClassPtr; -extern JS_FRIEND_DATA(const Class* const) Uint8ClampedArrayClassPtr; -extern JS_FRIEND_DATA(const Class* const) Int16ArrayClassPtr; -extern JS_FRIEND_DATA(const Class* const) Uint16ArrayClassPtr; -extern JS_FRIEND_DATA(const Class* const) Int32ArrayClassPtr; -extern JS_FRIEND_DATA(const Class* const) Uint32ArrayClassPtr; -extern JS_FRIEND_DATA(const Class* const) Float32ArrayClassPtr; -extern JS_FRIEND_DATA(const Class* const) Float64ArrayClassPtr; - -const size_t TypedArrayLengthSlot = 1; - -} // namespace detail - -#define JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Type, type) \ -inline void \ -Get ## Type ## ArrayLengthAndData(JSObject* obj, uint32_t* length, bool* isSharedMemory, type** data) \ -{ \ - MOZ_ASSERT(GetObjectClass(obj) == detail::Type ## ArrayClassPtr); \ - const JS::Value& lenSlot = GetReservedSlot(obj, detail::TypedArrayLengthSlot); \ - *length = mozilla::AssertedCast<uint32_t>(lenSlot.toInt32()); \ - *isSharedMemory = JS_GetTypedArraySharedness(obj); \ - *data = static_cast<type*>(GetObjectPrivate(obj)); \ -} - -JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Int8, int8_t) -JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint8, uint8_t) -JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint8Clamped, uint8_t) -JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Int16, int16_t) -JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint16, uint16_t) -JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Int32, int32_t) -JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Uint32, uint32_t) -JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Float32, float) -JS_DEFINE_DATA_AND_LENGTH_ACCESSOR(Float64, double) - -#undef JS_DEFINE_DATA_AND_LENGTH_ACCESSOR - -// This one isn't inlined because it's rather tricky (by dint of having to deal -// with a dozen-plus classes and varying slot layouts. -extern JS_FRIEND_API(void) -GetArrayBufferViewLengthAndData(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data); - -// This one isn't inlined because there are a bunch of different ArrayBuffer -// classes that would have to be individually handled here. -// -// There is an isShared out argument for API consistency (eases use from DOM). -// It will always be set to false. -extern JS_FRIEND_API(void) -GetArrayBufferLengthAndData(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data); - -// Ditto for SharedArrayBuffer. -// -// There is an isShared out argument for API consistency (eases use from DOM). -// It will always be set to true. -extern JS_FRIEND_API(void) -GetSharedArrayBufferLengthAndData(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data); - -} // namespace js - -JS_FRIEND_API(uint8_t*) -JS_GetSharedArrayBufferData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); - -/* - * Unwrap Typed arrays all at once. Return nullptr without throwing if the - * object cannot be viewed as the correct typed array, or the typed array - * object on success, filling both outparameters. - */ -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsInt8Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, int8_t** data); -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsUint8Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data); -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsUint8ClampedArray(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data); -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsInt16Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, int16_t** data); -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsUint16Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint16_t** data); -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsInt32Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, int32_t** data); -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsUint32Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint32_t** data); -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsFloat32Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, float** data); -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsFloat64Array(JSObject* obj, uint32_t* length, bool* isSharedMemory, double** data); -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsArrayBufferView(JSObject* obj, uint32_t* length, bool* isSharedMemory, uint8_t** data); - -/* - * Unwrap an ArrayBuffer, return nullptr if it's a different type. - */ -extern JS_FRIEND_API(JSObject*) -JS_GetObjectAsArrayBuffer(JSObject* obj, uint32_t* length, uint8_t** data); - -/* - * Get the type of elements in a typed array, or MaxTypedArrayViewType if a DataView. - * - * |obj| must have passed a JS_IsArrayBufferView/JS_Is*Array test, or somehow - * be known that it would pass such a test: it is an ArrayBufferView or a - * wrapper of an ArrayBufferView, and the unwrapping will succeed. - */ -extern JS_FRIEND_API(js::Scalar::Type) -JS_GetArrayBufferViewType(JSObject* obj); - -extern JS_FRIEND_API(js::Scalar::Type) -JS_GetSharedArrayBufferViewType(JSObject* obj); - -/* - * Check whether obj supports the JS_GetArrayBuffer* APIs. Note that this may - * return false if a security wrapper is encountered that denies the - * unwrapping. If this test succeeds, then it is safe to call the various - * accessor JSAPI calls defined below. - */ -extern JS_FRIEND_API(bool) -JS_IsArrayBufferObject(JSObject* obj); - -extern JS_FRIEND_API(bool) -JS_IsSharedArrayBufferObject(JSObject* obj); - -/** - * Return the available byte length of an array buffer. - * - * |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known - * that it would pass such a test: it is an ArrayBuffer or a wrapper of an - * ArrayBuffer, and the unwrapping will succeed. - */ -extern JS_FRIEND_API(uint32_t) -JS_GetArrayBufferByteLength(JSObject* obj); - -extern JS_FRIEND_API(uint32_t) -JS_GetSharedArrayBufferByteLength(JSObject* obj); - -/** - * Return true if the arrayBuffer contains any data. This will return false for - * ArrayBuffer.prototype and detached ArrayBuffers. - * - * |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known - * that it would pass such a test: it is an ArrayBuffer or a wrapper of an - * ArrayBuffer, and the unwrapping will succeed. - */ -extern JS_FRIEND_API(bool) -JS_ArrayBufferHasData(JSObject* obj); - -/** - * Return a pointer to the start of the data referenced by a typed array. The - * data is still owned by the typed array, and should not be modified on - * another thread. Furthermore, the pointer can become invalid on GC (if the - * data is small and fits inside the array's GC header), so callers must take - * care not to hold on across anything that could GC. - * - * |obj| must have passed a JS_IsArrayBufferObject test, or somehow be known - * that it would pass such a test: it is an ArrayBuffer or a wrapper of an - * ArrayBuffer, and the unwrapping will succeed. - * - * *isSharedMemory will be set to false, the argument is present to simplify - * its use from code that also interacts with SharedArrayBuffer. - */ -extern JS_FRIEND_API(uint8_t*) -JS_GetArrayBufferData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); - -/** - * Check whether the obj is ArrayBufferObject and memory mapped. Note that this - * may return false if a security wrapper is encountered that denies the - * unwrapping. - */ -extern JS_FRIEND_API(bool) -JS_IsMappedArrayBufferObject(JSObject* obj); - -/** - * Return the number of elements in a typed array. - * - * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow - * be known that it would pass such a test: it is a typed array or a wrapper of - * a typed array, and the unwrapping will succeed. - */ -extern JS_FRIEND_API(uint32_t) -JS_GetTypedArrayLength(JSObject* obj); - -/** - * Return the byte offset from the start of an array buffer to the start of a - * typed array view. - * - * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow - * be known that it would pass such a test: it is a typed array or a wrapper of - * a typed array, and the unwrapping will succeed. - */ -extern JS_FRIEND_API(uint32_t) -JS_GetTypedArrayByteOffset(JSObject* obj); - -/** - * Return the byte length of a typed array. - * - * |obj| must have passed a JS_IsTypedArrayObject/JS_Is*Array test, or somehow - * be known that it would pass such a test: it is a typed array or a wrapper of - * a typed array, and the unwrapping will succeed. - */ -extern JS_FRIEND_API(uint32_t) -JS_GetTypedArrayByteLength(JSObject* obj); - -/** - * Check whether obj supports JS_ArrayBufferView* APIs. Note that this may - * return false if a security wrapper is encountered that denies the - * unwrapping. - */ -extern JS_FRIEND_API(bool) -JS_IsArrayBufferViewObject(JSObject* obj); - -/** - * More generic name for JS_GetTypedArrayByteLength to cover DataViews as well - */ -extern JS_FRIEND_API(uint32_t) -JS_GetArrayBufferViewByteLength(JSObject* obj); - -/* - * Return a pointer to the start of the data referenced by a typed array. The - * data is still owned by the typed array, and should not be modified on - * another thread. Furthermore, the pointer can become invalid on GC (if the - * data is small and fits inside the array's GC header), so callers must take - * care not to hold on across anything that could GC. - * - * |obj| must have passed a JS_Is*Array test, or somehow be known that it would - * pass such a test: it is a typed array or a wrapper of a typed array, and the - * unwrapping will succeed. - * - * *isSharedMemory will be set to true if the typed array maps a - * SharedArrayBuffer, otherwise to false. - */ - -extern JS_FRIEND_API(int8_t*) -JS_GetInt8ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); -extern JS_FRIEND_API(uint8_t*) -JS_GetUint8ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); -extern JS_FRIEND_API(uint8_t*) -JS_GetUint8ClampedArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); -extern JS_FRIEND_API(int16_t*) -JS_GetInt16ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); -extern JS_FRIEND_API(uint16_t*) -JS_GetUint16ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); -extern JS_FRIEND_API(int32_t*) -JS_GetInt32ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); -extern JS_FRIEND_API(uint32_t*) -JS_GetUint32ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); -extern JS_FRIEND_API(float*) -JS_GetFloat32ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); -extern JS_FRIEND_API(double*) -JS_GetFloat64ArrayData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); - -/** - * Same as above, but for any kind of ArrayBufferView. Prefer the type-specific - * versions when possible. - */ -extern JS_FRIEND_API(void*) -JS_GetArrayBufferViewData(JSObject* obj, bool* isSharedMemory, const JS::AutoCheckCannotGC&); - -/** - * Return the ArrayBuffer or SharedArrayBuffer underlying an ArrayBufferView. - * This may return a detached buffer. |obj| must be an object that would - * return true for JS_IsArrayBufferViewObject(). - */ -extern JS_FRIEND_API(JSObject*) -JS_GetArrayBufferViewBuffer(JSContext* cx, JS::HandleObject obj, bool* isSharedMemory); - -/** - * Detach an ArrayBuffer, causing all associated views to no longer refer to - * the ArrayBuffer's original attached memory. - * - * The |changeData| argument is obsolete and ignored. - */ -extern JS_FRIEND_API(bool) -JS_DetachArrayBuffer(JSContext* cx, JS::HandleObject obj); - -/** - * Check whether the obj is a detached ArrayBufferObject. Note that this may - * return false if a security wrapper is encountered that denies the - * unwrapping. - */ -extern JS_FRIEND_API(bool) -JS_IsDetachedArrayBufferObject(JSObject* obj); - -/** - * Check whether obj supports JS_GetDataView* APIs. - */ -JS_FRIEND_API(bool) -JS_IsDataViewObject(JSObject* obj); - -/** - * Create a new DataView using the given ArrayBuffer for storage. The given - * buffer must be an ArrayBuffer (or a cross-compartment wrapper of an - * ArrayBuffer), and the offset and length must fit within the bounds of the - * arrayBuffer. Currently, nullptr will be returned and an exception will be - * thrown if these conditions do not hold, but do not depend on that behavior. - */ -JS_FRIEND_API(JSObject*) -JS_NewDataView(JSContext* cx, JS::HandleObject arrayBuffer, uint32_t byteOffset, int32_t byteLength); - -/** - * Return the byte offset of a data view into its array buffer. |obj| must be a - * DataView. - * - * |obj| must have passed a JS_IsDataViewObject test, or somehow be known that - * it would pass such a test: it is a data view or a wrapper of a data view, - * and the unwrapping will succeed. - */ -JS_FRIEND_API(uint32_t) -JS_GetDataViewByteOffset(JSObject* obj); - -/** - * Return the byte length of a data view. - * - * |obj| must have passed a JS_IsDataViewObject test, or somehow be known that - * it would pass such a test: it is a data view or a wrapper of a data view, - * and the unwrapping will succeed. If cx is nullptr, then DEBUG builds may be - * unable to assert when unwrapping should be disallowed. - */ -JS_FRIEND_API(uint32_t) -JS_GetDataViewByteLength(JSObject* obj); - -/** - * Return a pointer to the beginning of the data referenced by a DataView. - * - * |obj| must have passed a JS_IsDataViewObject test, or somehow be known that - * it would pass such a test: it is a data view or a wrapper of a data view, - * and the unwrapping will succeed. If cx is nullptr, then DEBUG builds may be - * unable to assert when unwrapping should be disallowed. - */ -JS_FRIEND_API(void*) -JS_GetDataViewData(JSObject* obj, const JS::AutoCheckCannotGC&); - -namespace js { - -/** - * Add a watchpoint -- in the Object.prototype.watch sense -- to |obj| for the - * property |id|, using the callable object |callable| as the function to be - * called for notifications. - * - * This is an internal function exposed -- temporarily -- only so that DOM - * proxies can be watchable. Don't use it! We'll soon kill off the - * Object.prototype.{,un}watch functions, at which point this will go too. - */ -extern JS_FRIEND_API(bool) -WatchGuts(JSContext* cx, JS::HandleObject obj, JS::HandleId id, JS::HandleObject callable); - -/** - * Remove a watchpoint -- in the Object.prototype.watch sense -- from |obj| for - * the property |id|. - * - * This is an internal function exposed -- temporarily -- only so that DOM - * proxies can be watchable. Don't use it! We'll soon kill off the - * Object.prototype.{,un}watch functions, at which point this will go too. - */ -extern JS_FRIEND_API(bool) -UnwatchGuts(JSContext* cx, JS::HandleObject obj, JS::HandleId id); - -namespace jit { - -enum class InlinableNative : uint16_t; - -} // namespace jit - -} // namespace js - -/** - * A class, expected to be passed by value, which represents the CallArgs for a - * JSJitGetterOp. - */ -class JSJitGetterCallArgs : protected JS::MutableHandleValue -{ - public: - explicit JSJitGetterCallArgs(const JS::CallArgs& args) - : JS::MutableHandleValue(args.rval()) - {} - - explicit JSJitGetterCallArgs(JS::RootedValue* rooted) - : JS::MutableHandleValue(rooted) - {} - - JS::MutableHandleValue rval() { - return *this; - } -}; - -/** - * A class, expected to be passed by value, which represents the CallArgs for a - * JSJitSetterOp. - */ -class JSJitSetterCallArgs : protected JS::MutableHandleValue -{ - public: - explicit JSJitSetterCallArgs(const JS::CallArgs& args) - : JS::MutableHandleValue(args[0]) - {} - - JS::MutableHandleValue operator[](unsigned i) { - MOZ_ASSERT(i == 0); - return *this; - } - - unsigned length() const { return 1; } - - // Add get() or maybe hasDefined() as needed -}; - -struct JSJitMethodCallArgsTraits; - -/** - * A class, expected to be passed by reference, which represents the CallArgs - * for a JSJitMethodOp. - */ -class JSJitMethodCallArgs : protected JS::detail::CallArgsBase<JS::detail::NoUsedRval> -{ - private: - typedef JS::detail::CallArgsBase<JS::detail::NoUsedRval> Base; - friend struct JSJitMethodCallArgsTraits; - - public: - explicit JSJitMethodCallArgs(const JS::CallArgs& args) { - argv_ = args.array(); - argc_ = args.length(); - } - - JS::MutableHandleValue rval() const { - return Base::rval(); - } - - unsigned length() const { return Base::length(); } - - JS::MutableHandleValue operator[](unsigned i) const { - return Base::operator[](i); - } - - bool hasDefined(unsigned i) const { - return Base::hasDefined(i); - } - - JSObject& callee() const { - // We can't use Base::callee() because that will try to poke at - // this->usedRval_, which we don't have. - return argv_[-2].toObject(); - } - - JS::HandleValue get(unsigned i) const { - return Base::get(i); - } -}; - -struct JSJitMethodCallArgsTraits -{ - static const size_t offsetOfArgv = offsetof(JSJitMethodCallArgs, argv_); - static const size_t offsetOfArgc = offsetof(JSJitMethodCallArgs, argc_); -}; - -typedef bool -(* JSJitGetterOp)(JSContext* cx, JS::HandleObject thisObj, - void* specializedThis, JSJitGetterCallArgs args); -typedef bool -(* JSJitSetterOp)(JSContext* cx, JS::HandleObject thisObj, - void* specializedThis, JSJitSetterCallArgs args); -typedef bool -(* JSJitMethodOp)(JSContext* cx, JS::HandleObject thisObj, - void* specializedThis, const JSJitMethodCallArgs& args); - -/** - * This struct contains metadata passed from the DOM to the JS Engine for JIT - * optimizations on DOM property accessors. Eventually, this should be made - * available to general JSAPI users, but we are not currently ready to do so. - */ -struct JSJitInfo { - enum OpType { - Getter, - Setter, - Method, - StaticMethod, - InlinableNative, - // Must be last - OpTypeCount - }; - - enum ArgType { - // Basic types - String = (1 << 0), - Integer = (1 << 1), // Only 32-bit or less - Double = (1 << 2), // Maybe we want to add Float sometime too - Boolean = (1 << 3), - Object = (1 << 4), - Null = (1 << 5), - - // And derived types - Numeric = Integer | Double, - // Should "Primitive" use the WebIDL definition, which - // excludes string and null, or the typical JS one that includes them? - Primitive = Numeric | Boolean | Null | String, - ObjectOrNull = Object | Null, - Any = ObjectOrNull | Primitive, - - // Our sentinel value. - ArgTypeListEnd = (1 << 31) - }; - - static_assert(Any & String, "Any must include String."); - static_assert(Any & Integer, "Any must include Integer."); - static_assert(Any & Double, "Any must include Double."); - static_assert(Any & Boolean, "Any must include Boolean."); - static_assert(Any & Object, "Any must include Object."); - static_assert(Any & Null, "Any must include Null."); - - /** - * An enum that describes what this getter/setter/method aliases. This - * determines what things can be hoisted past this call, and if this - * call is movable what it can be hoisted past. - */ - enum AliasSet { - /** - * Alias nothing: a constant value, getting it can't affect any other - * values, nothing can affect it. - */ - AliasNone, - - /** - * Alias things that can modify the DOM but nothing else. Doing the - * call can't affect the behavior of any other function. - */ - AliasDOMSets, - - /** - * Alias the world. Calling this can change arbitrary values anywhere - * in the system. Most things fall in this bucket. - */ - AliasEverything, - - /** Must be last. */ - AliasSetCount - }; - - bool needsOuterizedThisObject() const - { - return type() != Getter && type() != Setter; - } - - bool isTypedMethodJitInfo() const - { - return isTypedMethod; - } - - OpType type() const - { - return OpType(type_); - } - - AliasSet aliasSet() const - { - return AliasSet(aliasSet_); - } - - JSValueType returnType() const - { - return JSValueType(returnType_); - } - - union { - JSJitGetterOp getter; - JSJitSetterOp setter; - JSJitMethodOp method; - /** A DOM static method, used for Promise wrappers */ - JSNative staticMethod; - }; - - union { - uint16_t protoID; - js::jit::InlinableNative inlinableNative; - }; - - union { - uint16_t depth; - - // Additional opcode for some InlinableNative functions. - uint16_t nativeOp; - }; - - // These fields are carefully packed to take up 4 bytes. If you need more - // bits for whatever reason, please see if you can steal bits from existing - // fields before adding more members to this structure. - -#define JITINFO_OP_TYPE_BITS 4 -#define JITINFO_ALIAS_SET_BITS 4 -#define JITINFO_RETURN_TYPE_BITS 8 -#define JITINFO_SLOT_INDEX_BITS 10 - - /** The OpType that says what sort of function we are. */ - uint32_t type_ : JITINFO_OP_TYPE_BITS; - - /** - * The alias set for this op. This is a _minimal_ alias set; in - * particular for a method it does not include whatever argument - * conversions might do. That's covered by argTypes and runtime - * analysis of the actual argument types being passed in. - */ - uint32_t aliasSet_ : JITINFO_ALIAS_SET_BITS; - - /** The return type tag. Might be JSVAL_TYPE_UNKNOWN. */ - uint32_t returnType_ : JITINFO_RETURN_TYPE_BITS; - - static_assert(OpTypeCount <= (1 << JITINFO_OP_TYPE_BITS), - "Not enough space for OpType"); - static_assert(AliasSetCount <= (1 << JITINFO_ALIAS_SET_BITS), - "Not enough space for AliasSet"); - static_assert((sizeof(JSValueType) * 8) <= JITINFO_RETURN_TYPE_BITS, - "Not enough space for JSValueType"); - -#undef JITINFO_RETURN_TYPE_BITS -#undef JITINFO_ALIAS_SET_BITS -#undef JITINFO_OP_TYPE_BITS - - /** Is op fallible? False in setters. */ - uint32_t isInfallible : 1; - - /** - * Is op movable? To be movable the op must - * not AliasEverything, but even that might - * not be enough (e.g. in cases when it can - * throw or is explicitly not movable). - */ - uint32_t isMovable : 1; - - /** - * Can op be dead-code eliminated? Again, this - * depends on whether the op can throw, in - * addition to the alias set. - */ - uint32_t isEliminatable : 1; - - // XXXbz should we have a JSValueType for the type of the member? - /** - * True if this is a getter that can always - * get the value from a slot of the "this" object. - */ - uint32_t isAlwaysInSlot : 1; - - /** - * True if this is a getter that can sometimes (if the slot doesn't contain - * UndefinedValue()) get the value from a slot of the "this" object. - */ - uint32_t isLazilyCachedInSlot : 1; - - /** True if this is an instance of JSTypedMethodJitInfo. */ - uint32_t isTypedMethod : 1; - - /** - * If isAlwaysInSlot or isSometimesInSlot is true, - * the index of the slot to get the value from. - * Otherwise 0. - */ - uint32_t slotIndex : JITINFO_SLOT_INDEX_BITS; - - static const size_t maxSlotIndex = (1 << JITINFO_SLOT_INDEX_BITS) - 1; - -#undef JITINFO_SLOT_INDEX_BITS -}; - -static_assert(sizeof(JSJitInfo) == (sizeof(void*) + 2 * sizeof(uint32_t)), - "There are several thousand instances of JSJitInfo stored in " - "a binary. Please don't increase its space requirements without " - "verifying that there is no other way forward (better packing, " - "smaller datatypes for fields, subclassing, etc.)."); - -struct JSTypedMethodJitInfo -{ - // We use C-style inheritance here, rather than C++ style inheritance - // because not all compilers support brace-initialization for non-aggregate - // classes. Using C++ style inheritance and constructors instead of - // brace-initialization would also force the creation of static - // constructors (on some compilers) when JSJitInfo and JSTypedMethodJitInfo - // structures are declared. Since there can be several thousand of these - // structures present and we want to have roughly equivalent performance - // across a range of compilers, we do things manually. - JSJitInfo base; - - const JSJitInfo::ArgType* const argTypes; /* For a method, a list of sets of - types that the function - expects. This can be used, - for example, to figure out - when argument coercions can - have side-effects. */ -}; - -namespace js { - -static MOZ_ALWAYS_INLINE shadow::Function* -FunctionObjectToShadowFunction(JSObject* fun) -{ - MOZ_ASSERT(GetObjectClass(fun) == FunctionClassPtr); - return reinterpret_cast<shadow::Function*>(fun); -} - -/* Statically asserted in jsfun.h. */ -static const unsigned JS_FUNCTION_INTERPRETED_BITS = 0x0201; - -// Return whether the given function object is native. -static MOZ_ALWAYS_INLINE bool -FunctionObjectIsNative(JSObject* fun) -{ - return !(FunctionObjectToShadowFunction(fun)->flags & JS_FUNCTION_INTERPRETED_BITS); -} - -static MOZ_ALWAYS_INLINE JSNative -GetFunctionObjectNative(JSObject* fun) -{ - MOZ_ASSERT(FunctionObjectIsNative(fun)); - return FunctionObjectToShadowFunction(fun)->native; -} - -} // namespace js - -static MOZ_ALWAYS_INLINE const JSJitInfo* -FUNCTION_VALUE_TO_JITINFO(const JS::Value& v) -{ - MOZ_ASSERT(js::FunctionObjectIsNative(&v.toObject())); - return js::FunctionObjectToShadowFunction(&v.toObject())->jitinfo; -} - -static MOZ_ALWAYS_INLINE void -SET_JITINFO(JSFunction * func, const JSJitInfo* info) -{ - js::shadow::Function* fun = reinterpret_cast<js::shadow::Function*>(func); - MOZ_ASSERT(!(fun->flags & js::JS_FUNCTION_INTERPRETED_BITS)); - fun->jitinfo = info; -} - -/* - * Engine-internal extensions of jsid. This code is here only until we - * eliminate Gecko's dependencies on it! - */ - -static MOZ_ALWAYS_INLINE jsid -JSID_FROM_BITS(size_t bits) -{ - jsid id; - JSID_BITS(id) = bits; - return id; -} - -namespace js { -namespace detail { -bool IdMatchesAtom(jsid id, JSAtom* atom); -} // namespace detail -} // namespace js - -/** - * Must not be used on atoms that are representable as integer jsids. - * Prefer NameToId or AtomToId over this function: - * - * A PropertyName is an atom that does not contain an integer in the range - * [0, UINT32_MAX]. However, jsid can only hold an integer in the range - * [0, JSID_INT_MAX] (where JSID_INT_MAX == 2^31-1). Thus, for the range of - * integers (JSID_INT_MAX, UINT32_MAX], to represent as a jsid 'id', it must be - * the case JSID_IS_ATOM(id) and !JSID_TO_ATOM(id)->isPropertyName(). In most - * cases when creating a jsid, code does not have to care about this corner - * case because: - * - * - When given an arbitrary JSAtom*, AtomToId must be used, which checks for - * integer atoms representable as integer jsids, and does this conversion. - * - * - When given a PropertyName*, NameToId can be used which which does not need - * to do any dynamic checks. - * - * Thus, it is only the rare third case which needs this function, which - * handles any JSAtom* that is known not to be representable with an int jsid. - */ -static MOZ_ALWAYS_INLINE jsid -NON_INTEGER_ATOM_TO_JSID(JSAtom* atom) -{ - MOZ_ASSERT(((size_t)atom & 0x7) == 0); - jsid id = JSID_FROM_BITS((size_t)atom); - MOZ_ASSERT(js::detail::IdMatchesAtom(id, atom)); - return id; -} - -/* All strings stored in jsids are atomized, but are not necessarily property names. */ -static MOZ_ALWAYS_INLINE bool -JSID_IS_ATOM(jsid id) -{ - return JSID_IS_STRING(id); -} - -static MOZ_ALWAYS_INLINE bool -JSID_IS_ATOM(jsid id, JSAtom* atom) -{ - return id == JSID_FROM_BITS((size_t)atom); -} - -static MOZ_ALWAYS_INLINE JSAtom* -JSID_TO_ATOM(jsid id) -{ - return (JSAtom*)JSID_TO_STRING(id); -} - -JS_STATIC_ASSERT(sizeof(jsid) == sizeof(void*)); - -namespace js { - -static MOZ_ALWAYS_INLINE JS::Value -IdToValue(jsid id) -{ - if (JSID_IS_STRING(id)) - return JS::StringValue(JSID_TO_STRING(id)); - if (JSID_IS_INT(id)) - return JS::Int32Value(JSID_TO_INT(id)); - if (JSID_IS_SYMBOL(id)) - return JS::SymbolValue(JSID_TO_SYMBOL(id)); - MOZ_ASSERT(JSID_IS_VOID(id)); - return JS::UndefinedValue(); -} - -/** - * If the embedder has registered a ScriptEnvironmentPreparer, - * PrepareScriptEnvironmentAndInvoke will call the preparer's 'invoke' method - * with the given |closure|, with the assumption that the preparer will set up - * any state necessary to run script in |scope|, invoke |closure| with a valid - * JSContext*, report any exceptions thrown from the closure, and return. - * - * If no preparer is registered, PrepareScriptEnvironmentAndInvoke will assert - * that |rt| has exactly one JSContext associated with it, enter the compartment - * of |scope| on that context, and invoke |closure|. - * - * In both cases, PrepareScriptEnvironmentAndInvoke will report any exceptions - * that are thrown by the closure. Consumers who want to propagate back - * whether the closure succeeded should do so via members of the closure - * itself. - */ - -struct ScriptEnvironmentPreparer { - struct Closure { - virtual bool operator()(JSContext* cx) = 0; - }; - - virtual void invoke(JS::HandleObject scope, Closure& closure) = 0; -}; - -extern JS_FRIEND_API(void) -PrepareScriptEnvironmentAndInvoke(JSContext* cx, JS::HandleObject scope, - ScriptEnvironmentPreparer::Closure& closure); - -JS_FRIEND_API(void) -SetScriptEnvironmentPreparer(JSContext* cx, ScriptEnvironmentPreparer* preparer); - -enum CTypesActivityType { - CTYPES_CALL_BEGIN, - CTYPES_CALL_END, - CTYPES_CALLBACK_BEGIN, - CTYPES_CALLBACK_END -}; - -typedef void -(* CTypesActivityCallback)(JSContext* cx, CTypesActivityType type); - -/** - * Sets a callback that is run whenever js-ctypes is about to be used when - * calling into C. - */ -JS_FRIEND_API(void) -SetCTypesActivityCallback(JSContext* cx, CTypesActivityCallback cb); - -class MOZ_RAII JS_FRIEND_API(AutoCTypesActivityCallback) { - private: - JSContext* cx; - CTypesActivityCallback callback; - CTypesActivityType endType; - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER - - public: - AutoCTypesActivityCallback(JSContext* cx, CTypesActivityType beginType, - CTypesActivityType endType - MOZ_GUARD_OBJECT_NOTIFIER_PARAM); - ~AutoCTypesActivityCallback() { - DoEndCallback(); - } - void DoEndCallback() { - if (callback) { - callback(cx, endType); - callback = nullptr; - } - } -}; - -// Abstract base class for objects that build allocation metadata for JavaScript -// values. -struct AllocationMetadataBuilder { - AllocationMetadataBuilder() { } - - // Return a metadata object for the newly constructed object |obj|, or - // nullptr if there's no metadata to attach. - // - // Implementations should treat all errors as fatal; there is no way to - // report errors from this callback. In particular, the caller provides an - // oomUnsafe for overriding implementations to use. - virtual JSObject* build(JSContext* cx, JS::HandleObject obj, - AutoEnterOOMUnsafeRegion& oomUnsafe) const - { - return nullptr; - } -}; - -/** - * Specify a callback to invoke when creating each JS object in the current - * compartment, which may return a metadata object to associate with the - * object. - */ -JS_FRIEND_API(void) -SetAllocationMetadataBuilder(JSContext* cx, const AllocationMetadataBuilder *callback); - -/** Get the metadata associated with an object. */ -JS_FRIEND_API(JSObject*) -GetAllocationMetadata(JSObject* obj); - -JS_FRIEND_API(bool) -GetElementsWithAdder(JSContext* cx, JS::HandleObject obj, JS::HandleObject receiver, - uint32_t begin, uint32_t end, js::ElementAdder* adder); - -JS_FRIEND_API(bool) -ForwardToNative(JSContext* cx, JSNative native, const JS::CallArgs& args); - -/** - * Helper function for HTMLDocument and HTMLFormElement. - * - * These are the only two interfaces that have [OverrideBuiltins], a named - * getter, and no named setter. They're implemented as proxies with a custom - * getOwnPropertyDescriptor() method. Unfortunately, overriding - * getOwnPropertyDescriptor() automatically affects the behavior of set(), - * which normally is just common sense but is *not* desired for these two - * interfaces. - * - * The fix is for these two interfaces to override set() to ignore the - * getOwnPropertyDescriptor() override. - * - * SetPropertyIgnoringNamedGetter is exposed to make it easier to override - * set() in this way. It carries out all the steps of BaseProxyHandler::set() - * except the initial getOwnPropertyDescriptor() call. The caller must supply - * that descriptor as the 'ownDesc' parameter. - * - * Implemented in proxy/BaseProxyHandler.cpp. - */ -JS_FRIEND_API(bool) -SetPropertyIgnoringNamedGetter(JSContext* cx, JS::HandleObject obj, JS::HandleId id, - JS::HandleValue v, JS::HandleValue receiver, - JS::Handle<JS::PropertyDescriptor> ownDesc, - JS::ObjectOpResult& result); - -JS_FRIEND_API(void) -ReportASCIIErrorWithId(JSContext* cx, const char* msg, JS::HandleId id); - -// This function is for one specific use case, please don't use this for anything else! -extern JS_FRIEND_API(bool) -ExecuteInGlobalAndReturnScope(JSContext* cx, JS::HandleObject obj, JS::HandleScript script, - JS::MutableHandleObject scope); - -#if defined(XP_WIN) && defined(_WIN64) -// Parameters use void* types to avoid #including windows.h. The return value of -// this function is returned from the exception handler. -typedef long -(*JitExceptionHandler)(void* exceptionRecord, // PEXECTION_RECORD - void* context); // PCONTEXT - -/** - * Windows uses "structured exception handling" to handle faults. When a fault - * occurs, the stack is searched for a handler (similar to C++ exception - * handling). If the search does not find a handler, the "unhandled exception - * filter" is called. Breakpad uses the unhandled exception filter to do crash - * reporting. Unfortunately, on Win64, JIT code on the stack completely throws - * off this unwinding process and prevents the unhandled exception filter from - * being called. The reason is that Win64 requires unwind information be - * registered for all code regions and JIT code has none. While it is possible - * to register full unwind information for JIT code, this is a lot of work (one - * has to be able to recover the frame pointer at any PC) so instead we register - * a handler for all JIT code that simply calls breakpad's unhandled exception - * filter (which will perform crash reporting and then terminate the process). - * This would be wrong if there was an outer __try block that expected to handle - * the fault, but this is not generally allowed. - * - * Gecko must call SetJitExceptionFilter before any JIT code is compiled and - * only once per process. - */ -extern JS_FRIEND_API(void) -SetJitExceptionHandler(JitExceptionHandler handler); -#endif - -/** - * Get the nearest enclosing with environment object for a given function. If - * the function is not scripted or is not enclosed by a with scope, returns - * the global. - */ -extern JS_FRIEND_API(JSObject*) -GetNearestEnclosingWithEnvironmentObjectForFunction(JSFunction* fun); - -/** - * Get the first SavedFrame object in this SavedFrame stack whose principals are - * subsumed by the cx's principals. If there is no such frame, return nullptr. - * - * Do NOT pass a non-SavedFrame object here. - * - * The savedFrame and cx do not need to be in the same compartment. - */ -extern JS_FRIEND_API(JSObject*) -GetFirstSubsumedSavedFrame(JSContext* cx, JS::HandleObject savedFrame, JS::SavedFrameSelfHosted selfHosted); - -extern JS_FRIEND_API(bool) -ReportIsNotFunction(JSContext* cx, JS::HandleValue v); - -extern JS_FRIEND_API(JSObject*) -ConvertArgsToArray(JSContext* cx, const JS::CallArgs& args); - -/** - * Window and WindowProxy - * - * The functions below have to do with Windows and WindowProxies. There's an - * invariant that actual Window objects (the global objects of web pages) are - * never directly exposed to script. Instead we often substitute a WindowProxy. - * - * The environment chain, on the other hand, contains the Window and never its - * WindowProxy. - * - * As a result, we have calls to these "substitute-this-object-for-that-object" - * functions sprinkled at apparently arbitrary (but actually *very* carefully - * and nervously selected) places throughout the engine and indeed the - * universe. - */ - -/** - * Tell the JS engine which Class is used for WindowProxy objects. Used by the - * functions below. - */ -extern JS_FRIEND_API(void) -SetWindowProxyClass(JSContext* cx, const Class* clasp); - -/** - * Associates a WindowProxy with a Window (global object). `windowProxy` must - * have the Class set by SetWindowProxyClass. - */ -extern JS_FRIEND_API(void) -SetWindowProxy(JSContext* cx, JS::HandleObject global, JS::HandleObject windowProxy); - -namespace detail { - -JS_FRIEND_API(bool) -IsWindowSlow(JSObject* obj); - -} // namespace detail - -/** - * Returns true iff `obj` is a global object with an associated WindowProxy, - * see SetWindowProxy. - */ -inline bool -IsWindow(JSObject* obj) -{ - if (GetObjectClass(obj)->flags & JSCLASS_IS_GLOBAL) - return detail::IsWindowSlow(obj); - return false; -} - -/** - * Returns true iff `obj` has the WindowProxy Class (see SetWindowProxyClass). - */ -JS_FRIEND_API(bool) -IsWindowProxy(JSObject* obj); - -/** - * If `obj` is a Window, get its associated WindowProxy (or a CCW or dead - * wrapper if the page was navigated away from), else return `obj`. This - * function is infallible and never returns nullptr. - */ -extern JS_FRIEND_API(JSObject*) -ToWindowProxyIfWindow(JSObject* obj); - -/** - * If `obj` is a WindowProxy, get its associated Window (the compartment's - * global), else return `obj`. This function is infallible and never returns - * nullptr. - */ -extern JS_FRIEND_API(JSObject*) -ToWindowIfWindowProxy(JSObject* obj); - -} /* namespace js */ - -class NativeProfiler -{ - public: - virtual ~NativeProfiler() {}; - virtual void sampleNative(void* addr, uint32_t size) = 0; - virtual void removeNative(void* addr) = 0; - virtual void reset() = 0; -}; - -class GCHeapProfiler -{ - public: - virtual ~GCHeapProfiler() {}; - virtual void sampleTenured(void* addr, uint32_t size) = 0; - virtual void sampleNursery(void* addr, uint32_t size) = 0; - virtual void markTenuredStart() = 0; - virtual void markTenured(void* addr) = 0; - virtual void sweepTenured() = 0; - virtual void sweepNursery() = 0; - virtual void moveNurseryToTenured(void* addrOld, void* addrNew) = 0; - virtual void reset() = 0; -}; - -class MemProfiler -{ - static mozilla::Atomic<uint32_t, mozilla::Relaxed> sActiveProfilerCount; - static NativeProfiler* sNativeProfiler; - - static GCHeapProfiler* GetGCHeapProfiler(void* addr); - static GCHeapProfiler* GetGCHeapProfiler(JSRuntime* runtime); - - static NativeProfiler* GetNativeProfiler() { - return sNativeProfiler; - } - - GCHeapProfiler* mGCHeapProfiler; - JSRuntime* mRuntime; - - public: - explicit MemProfiler(JSRuntime* aRuntime) : mGCHeapProfiler(nullptr), mRuntime(aRuntime) {} - - void start(GCHeapProfiler* aGCHeapProfiler); - void stop(); - - GCHeapProfiler* getGCHeapProfiler() const { - return mGCHeapProfiler; - } - - static MOZ_ALWAYS_INLINE bool enabled() { - return sActiveProfilerCount > 0; - } - - static MemProfiler* GetMemProfiler(JSContext* context); - - static void SetNativeProfiler(NativeProfiler* aProfiler) { - sNativeProfiler = aProfiler; - } - - static MOZ_ALWAYS_INLINE void SampleNative(void* addr, uint32_t size) { - JS::AutoSuppressGCAnalysis nogc; - - if (MOZ_LIKELY(!enabled())) - return; - - NativeProfiler* profiler = GetNativeProfiler(); - if (profiler) - profiler->sampleNative(addr, size); - } - - static MOZ_ALWAYS_INLINE void SampleTenured(void* addr, uint32_t size) { - JS::AutoSuppressGCAnalysis nogc; - - if (MOZ_LIKELY(!enabled())) - return; - - GCHeapProfiler* profiler = GetGCHeapProfiler(addr); - if (profiler) - profiler->sampleTenured(addr, size); - } - - static MOZ_ALWAYS_INLINE void SampleNursery(void* addr, uint32_t size) { - JS::AutoSuppressGCAnalysis nogc; - - if (MOZ_LIKELY(!enabled())) - return; - - GCHeapProfiler* profiler = GetGCHeapProfiler(addr); - if (profiler) - profiler->sampleNursery(addr, size); - } - - static MOZ_ALWAYS_INLINE void RemoveNative(void* addr) { - JS::AutoSuppressGCAnalysis nogc; - - if (MOZ_LIKELY(!enabled())) - return; - - NativeProfiler* profiler = GetNativeProfiler(); - if (profiler) - profiler->removeNative(addr); - } - - static MOZ_ALWAYS_INLINE void MarkTenuredStart(JSRuntime* runtime) { - JS::AutoSuppressGCAnalysis nogc; - - if (MOZ_LIKELY(!enabled())) - return; - - GCHeapProfiler* profiler = GetGCHeapProfiler(runtime); - if (profiler) - profiler->markTenuredStart(); - } - - static MOZ_ALWAYS_INLINE void MarkTenured(void* addr) { - JS::AutoSuppressGCAnalysis nogc; - - if (MOZ_LIKELY(!enabled())) - return; - - GCHeapProfiler* profiler = GetGCHeapProfiler(addr); - if (profiler) - profiler->markTenured(addr); - } - - static MOZ_ALWAYS_INLINE void SweepTenured(JSRuntime* runtime) { - JS::AutoSuppressGCAnalysis nogc; - - if (MOZ_LIKELY(!enabled())) - return; - - GCHeapProfiler* profiler = GetGCHeapProfiler(runtime); - if (profiler) - profiler->sweepTenured(); - } - - static MOZ_ALWAYS_INLINE void SweepNursery(JSRuntime* runtime) { - JS::AutoSuppressGCAnalysis nogc; - - if (MOZ_LIKELY(!enabled())) - return; - - GCHeapProfiler* profiler = GetGCHeapProfiler(runtime); - if (profiler) - profiler->sweepNursery(); - } - - static MOZ_ALWAYS_INLINE void MoveNurseryToTenured(void* addrOld, void* addrNew) { - JS::AutoSuppressGCAnalysis nogc; - - if (MOZ_LIKELY(!enabled())) - return; - - GCHeapProfiler* profiler = GetGCHeapProfiler(addrOld); - if (profiler) - profiler->moveNurseryToTenured(addrOld, addrNew); - } -}; - -#endif /* jsfriendapi_h */ diff --git a/android/armeabi/include/spidermonkey/jsperf.h b/android/armeabi/include/spidermonkey/jsperf.h deleted file mode 100644 index b8f2909a..00000000 --- a/android/armeabi/include/spidermonkey/jsperf.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef perf_jsperf_h -#define perf_jsperf_h - -#include "jstypes.h" - -#include "js/TypeDecls.h" -#include "js/Utility.h" - -namespace JS { - -/* - * JS::PerfMeasurement is a generic way to access detailed performance - * measurement APIs provided by your operating system. The details of - * exactly how this works and what can be measured are highly - * system-specific, but this interface is (one hopes) implementable - * on top of all of them. - * - * To use this API, create a PerfMeasurement object, passing its - * constructor a bitmask indicating which events you are interested - * in. Thereafter, Start() zeroes all counters and starts timing; - * Stop() stops timing again; and the counters for the events you - * requested are available as data values after calling Stop(). The - * object may be reused for many measurements. - */ -class JS_FRIEND_API(PerfMeasurement) -{ - protected: - // Implementation-specific data, if any. - void* impl; - - public: - /* - * Events that may be measured. Taken directly from the list of - * "generalized hardware performance event types" in the Linux - * perf_event API, plus some of the "software events". - */ - enum EventMask { - CPU_CYCLES = 0x00000001, - INSTRUCTIONS = 0x00000002, - CACHE_REFERENCES = 0x00000004, - CACHE_MISSES = 0x00000008, - BRANCH_INSTRUCTIONS = 0x00000010, - BRANCH_MISSES = 0x00000020, - BUS_CYCLES = 0x00000040, - PAGE_FAULTS = 0x00000080, - MAJOR_PAGE_FAULTS = 0x00000100, - CONTEXT_SWITCHES = 0x00000200, - CPU_MIGRATIONS = 0x00000400, - - ALL = 0x000007ff, - NUM_MEASURABLE_EVENTS = 11 - }; - - /* - * Bitmask of events that will be measured when this object is - * active (between Start() and Stop()). This may differ from the - * bitmask passed to the constructor if the platform does not - * support measuring all of the requested events. - */ - const EventMask eventsMeasured; - - /* - * Counters for each measurable event. - * Immediately after one of these objects is created, all of the - * counters for enabled events will be zero, and all of the - * counters for disabled events will be uint64_t(-1). - */ - uint64_t cpu_cycles; - uint64_t instructions; - uint64_t cache_references; - uint64_t cache_misses; - uint64_t branch_instructions; - uint64_t branch_misses; - uint64_t bus_cycles; - uint64_t page_faults; - uint64_t major_page_faults; - uint64_t context_switches; - uint64_t cpu_migrations; - - /* - * Prepare to measure the indicated set of events. If not all of - * the requested events can be measured on the current platform, - * then the eventsMeasured bitmask will only include the subset of - * |toMeasure| corresponding to the events that can be measured. - */ - explicit PerfMeasurement(EventMask toMeasure); - - /* Done with this set of measurements, tear down OS-level state. */ - ~PerfMeasurement(); - - /* Start a measurement cycle. */ - void start(); - - /* - * End a measurement cycle, and for each enabled counter, add the - * number of measured events of that type to the appropriate - * visible variable. - */ - void stop(); - - /* Reset all enabled counters to zero. */ - void reset(); - - /* - * True if this platform supports measuring _something_, i.e. it's - * not using the stub implementation. - */ - static bool canMeasureSomething(); -}; - -/* Inject a Javascript wrapper around the above C++ class into the - * Javascript object passed as an argument (this will normally be a - * global object). The JS-visible API is identical to the C++ API. - */ -extern JS_FRIEND_API(JSObject*) - RegisterPerfMeasurement(JSContext* cx, JS::HandleObject global); - -/* - * Given a Value which contains an instance of the aforementioned - * wrapper class, extract the C++ object. Returns nullptr if the - * Value is not an instance of the wrapper. - */ -extern JS_FRIEND_API(PerfMeasurement*) - ExtractPerfMeasurement(const Value& wrapper); - -} // namespace JS - -#endif /* perf_jsperf_h */ diff --git a/android/armeabi/include/spidermonkey/jsprf.h b/android/armeabi/include/spidermonkey/jsprf.h deleted file mode 100644 index b84b5a5c..00000000 --- a/android/armeabi/include/spidermonkey/jsprf.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef jsprf_h -#define jsprf_h - -/* -** API for PR printf like routines. Supports the following formats -** %d - decimal -** %u - unsigned decimal -** %x - unsigned hex -** %X - unsigned uppercase hex -** %o - unsigned octal -** %hd, %hu, %hx, %hX, %ho - "short" versions of above -** %ld, %lu, %lx, %lX, %lo - "long" versions of above -** %lld, %llu, %llx, %llX, %llo - "long long" versions of above -** %zd, %zo, %zu, %zx, %zX - size_t versions of above -** %Id, %Io, %Iu, %Ix, %IX - size_t versions of above (for Windows compat) -** You should use PRI*SIZE macros instead -** %s - string -** %c - character -** %p - pointer (deals with machine dependent pointer size) -** %f - float -** %g - float -*/ - -#include "mozilla/IntegerPrintfMacros.h" -#include "mozilla/SizePrintfMacros.h" - -#include <stdarg.h> - -#include "jstypes.h" - -/* -** sprintf into a malloc'd buffer. Return a pointer to the malloc'd -** buffer on success, nullptr on failure. Call "JS_smprintf_free" to release -** the memory returned. -*/ -extern JS_PUBLIC_API(char*) JS_smprintf(const char* fmt, ...) - MOZ_FORMAT_PRINTF(1, 2); - -/* -** Free the memory allocated, for the caller, by JS_smprintf -*/ -extern JS_PUBLIC_API(void) JS_smprintf_free(char* mem); - -/* -** "append" sprintf into a malloc'd buffer. "last" is the last value of -** the malloc'd buffer. sprintf will append data to the end of last, -** growing it as necessary using realloc. If last is nullptr, JS_sprintf_append -** will allocate the initial string. The return value is the new value of -** last for subsequent calls, or nullptr if there is a malloc failure. -*/ -extern JS_PUBLIC_API(char*) JS_sprintf_append(char* last, const char* fmt, ...) - MOZ_FORMAT_PRINTF(2, 3); - -/* -** va_list forms of the above. -*/ -extern JS_PUBLIC_API(char*) JS_vsmprintf(const char* fmt, va_list ap); -extern JS_PUBLIC_API(char*) JS_vsprintf_append(char* last, const char* fmt, va_list ap); - -#endif /* jsprf_h */ diff --git a/android/armeabi/include/spidermonkey/jsprototypes.h b/android/armeabi/include/spidermonkey/jsprototypes.h deleted file mode 100644 index f409dce9..00000000 --- a/android/armeabi/include/spidermonkey/jsprototypes.h +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef jsprototypes_h -#define jsprototypes_h - -/* A higher-order macro for enumerating all JSProtoKey values. */ -/* - * Consumers define macros as follows: - * macro(name, code, init, clasp) - * name: The canonical name of the class. - * code: The enumerator code. There are part of the XDR API, and must not change. - * init: Initialization function. These are |extern "C";|, and clients should use - * |extern "C" {}| as appropriate when using this macro. - * clasp: The JSClass for this object, or "dummy" if it doesn't exist. - * - * - * Consumers wishing to iterate over all the JSProtoKey values, can use - * JS_FOR_EACH_PROTOTYPE. However, there are certain values that don't correspond - * to real constructors, like Null or constructors that are disabled via - * preprocessor directives. We still need to include these in the JSProtoKey list - * in order to maintain binary XDR compatibility, but we need to provide a tool - * to handle them differently. JS_FOR_PROTOTYPES fills this niche. - * - * Consumers pass two macros to JS_FOR_PROTOTYPES - |real| and |imaginary|. The - * former is invoked for entries that have real client-exposed constructors, and - * the latter is called for the rest. Consumers that don't care about this - * distinction can simply pass the same macro to both, which is exactly what - * JS_FOR_EACH_PROTOTYPE does. - */ - -#define CLASP(name) (&name##Class) -#define OCLASP(name) (&name##Object::class_) -#define TYPED_ARRAY_CLASP(type) (&TypedArrayObject::classes[Scalar::type]) -#define ERROR_CLASP(type) (&ErrorObject::classes[type]) - -#ifdef EXPOSE_INTL_API -#define IF_INTL(real,imaginary) real -#else -#define IF_INTL(real,imaginary) imaginary -#endif - -#ifdef ENABLE_BINARYDATA -#define IF_BDATA(real,imaginary) real -#else -#define IF_BDATA(real,imaginary) imaginary -#endif - -#ifdef ENABLE_SIMD -# define IF_SIMD(real,imaginary) real -#else -# define IF_SIMD(real,imaginary) imaginary -#endif - -#ifdef ENABLE_SHARED_ARRAY_BUFFER -#define IF_SAB(real,imaginary) real -#else -#define IF_SAB(real,imaginary) imaginary -#endif - -#ifdef SPIDERMONKEY_PROMISE -#define IF_PROMISE(real,imaginary) real -#else -#define IF_PROMISE(real,imaginary) imaginary -#endif - -#define JS_FOR_PROTOTYPES(real,imaginary) \ - imaginary(Null, 0, InitNullClass, dummy) \ - real(Object, 1, InitViaClassSpec, OCLASP(Plain)) \ - real(Function, 2, InitViaClassSpec, &JSFunction::class_) \ - real(Array, 3, InitViaClassSpec, OCLASP(Array)) \ - real(Boolean, 4, InitBooleanClass, OCLASP(Boolean)) \ - real(JSON, 5, InitJSONClass, CLASP(JSON)) \ - real(Date, 6, InitViaClassSpec, OCLASP(Date)) \ - real(Math, 7, InitMathClass, CLASP(Math)) \ - real(Number, 8, InitNumberClass, OCLASP(Number)) \ - real(String, 9, InitStringClass, OCLASP(String)) \ - real(RegExp, 10, InitViaClassSpec, OCLASP(RegExp)) \ - real(Error, 11, InitViaClassSpec, ERROR_CLASP(JSEXN_ERR)) \ - real(InternalError, 12, InitViaClassSpec, ERROR_CLASP(JSEXN_INTERNALERR)) \ - real(EvalError, 13, InitViaClassSpec, ERROR_CLASP(JSEXN_EVALERR)) \ - real(RangeError, 14, InitViaClassSpec, ERROR_CLASP(JSEXN_RANGEERR)) \ - real(ReferenceError, 15, InitViaClassSpec, ERROR_CLASP(JSEXN_REFERENCEERR)) \ - real(SyntaxError, 16, InitViaClassSpec, ERROR_CLASP(JSEXN_SYNTAXERR)) \ - real(TypeError, 17, InitViaClassSpec, ERROR_CLASP(JSEXN_TYPEERR)) \ - real(URIError, 18, InitViaClassSpec, ERROR_CLASP(JSEXN_URIERR)) \ - real(DebuggeeWouldRun, 19, InitViaClassSpec, ERROR_CLASP(JSEXN_DEBUGGEEWOULDRUN)) \ - real(CompileError, 20, InitViaClassSpec, ERROR_CLASP(JSEXN_WASMCOMPILEERROR)) \ - real(RuntimeError, 21, InitViaClassSpec, ERROR_CLASP(JSEXN_WASMRUNTIMEERROR)) \ - real(Iterator, 22, InitLegacyIteratorClass,OCLASP(PropertyIterator)) \ - real(StopIteration, 23, InitStopIterationClass, OCLASP(StopIteration)) \ - real(ArrayBuffer, 24, InitViaClassSpec, OCLASP(ArrayBuffer)) \ - real(Int8Array, 25, InitViaClassSpec, TYPED_ARRAY_CLASP(Int8)) \ - real(Uint8Array, 26, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8)) \ - real(Int16Array, 27, InitViaClassSpec, TYPED_ARRAY_CLASP(Int16)) \ - real(Uint16Array, 28, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint16)) \ - real(Int32Array, 29, InitViaClassSpec, TYPED_ARRAY_CLASP(Int32)) \ - real(Uint32Array, 30, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint32)) \ - real(Float32Array, 31, InitViaClassSpec, TYPED_ARRAY_CLASP(Float32)) \ - real(Float64Array, 32, InitViaClassSpec, TYPED_ARRAY_CLASP(Float64)) \ - real(Uint8ClampedArray, 33, InitViaClassSpec, TYPED_ARRAY_CLASP(Uint8Clamped)) \ - real(Proxy, 34, InitProxyClass, js::ProxyClassPtr) \ - real(WeakMap, 35, InitWeakMapClass, OCLASP(WeakMap)) \ - real(Map, 36, InitMapClass, OCLASP(Map)) \ - real(Set, 37, InitSetClass, OCLASP(Set)) \ - real(DataView, 38, InitDataViewClass, OCLASP(DataView)) \ - real(Symbol, 39, InitSymbolClass, OCLASP(Symbol)) \ -IF_SAB(real,imaginary)(SharedArrayBuffer, 40, InitViaClassSpec, OCLASP(SharedArrayBuffer)) \ -IF_INTL(real,imaginary) (Intl, 41, InitIntlClass, CLASP(Intl)) \ -IF_BDATA(real,imaginary)(TypedObject, 42, InitTypedObjectModuleObject, OCLASP(TypedObjectModule)) \ - real(Reflect, 43, InitReflect, nullptr) \ -IF_SIMD(real,imaginary)(SIMD, 44, InitSimdClass, OCLASP(Simd)) \ - real(WeakSet, 45, InitWeakSetClass, OCLASP(WeakSet)) \ - real(TypedArray, 46, InitViaClassSpec, &js::TypedArrayObject::sharedTypedArrayPrototypeClass) \ -IF_SAB(real,imaginary)(Atomics, 47, InitAtomicsClass, OCLASP(Atomics)) \ - real(SavedFrame, 48, InitViaClassSpec, &js::SavedFrame::class_) \ - real(WebAssembly, 49, InitWebAssemblyClass, CLASP(WebAssembly)) \ - imaginary(WasmModule, 50, dummy, dummy) \ - imaginary(WasmInstance, 51, dummy, dummy) \ - imaginary(WasmMemory, 52, dummy, dummy) \ - imaginary(WasmTable, 53, dummy, dummy) \ -IF_PROMISE(real,imaginary)(Promise, 54, InitViaClassSpec, OCLASP(Promise)) \ - -#define JS_FOR_EACH_PROTOTYPE(macro) JS_FOR_PROTOTYPES(macro,macro) - -#endif /* jsprototypes_h */ diff --git a/android/armeabi/include/spidermonkey/jspubtd.h b/android/armeabi/include/spidermonkey/jspubtd.h deleted file mode 100644 index 309b9d74..00000000 --- a/android/armeabi/include/spidermonkey/jspubtd.h +++ /dev/null @@ -1,476 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef jspubtd_h -#define jspubtd_h - -/* - * JS public API typedefs. - */ - -#include "mozilla/Assertions.h" -#include "mozilla/EnumeratedArray.h" -#include "mozilla/LinkedList.h" -#include "mozilla/PodOperations.h" - -#include "jsprototypes.h" -#include "jstypes.h" - -#include "js/TraceKind.h" -#include "js/TypeDecls.h" - -#if defined(JS_GC_ZEAL) || defined(DEBUG) -# define JSGC_HASH_TABLE_CHECKS -#endif - -namespace JS { - -class AutoIdVector; -class CallArgs; - -template <typename T> -class Rooted; - -class JS_FRIEND_API(CompileOptions); -class JS_FRIEND_API(ReadOnlyCompileOptions); -class JS_FRIEND_API(OwningCompileOptions); -class JS_FRIEND_API(TransitiveCompileOptions); -class JS_PUBLIC_API(CompartmentOptions); - -struct RootingContext; -class Value; -struct Zone; - -namespace shadow { -struct Runtime; -} // namespace shadow - -} // namespace JS - -namespace js { -class RootLists; -} // namespace js - -/* - * Run-time version enumeration. For compile-time version checking, please use - * the JS_HAS_* macros in jsversion.h, or use MOZJS_MAJOR_VERSION, - * MOZJS_MINOR_VERSION, MOZJS_PATCH_VERSION, and MOZJS_ALPHA definitions. - */ -enum JSVersion { - JSVERSION_ECMA_3 = 148, - JSVERSION_1_6 = 160, - JSVERSION_1_7 = 170, - JSVERSION_1_8 = 180, - JSVERSION_ECMA_5 = 185, - JSVERSION_DEFAULT = 0, - JSVERSION_UNKNOWN = -1, - JSVERSION_LATEST = JSVERSION_ECMA_5 -}; - -/* Result of typeof operator enumeration. */ -enum JSType { - JSTYPE_VOID, /* undefined */ - JSTYPE_OBJECT, /* object */ - JSTYPE_FUNCTION, /* function */ - JSTYPE_STRING, /* string */ - JSTYPE_NUMBER, /* number */ - JSTYPE_BOOLEAN, /* boolean */ - JSTYPE_NULL, /* null */ - JSTYPE_SYMBOL, /* symbol */ - JSTYPE_LIMIT -}; - -/* Dense index into cached prototypes and class atoms for standard objects. */ -enum JSProtoKey { -#define PROTOKEY_AND_INITIALIZER(name,code,init,clasp) JSProto_##name = code, - JS_FOR_EACH_PROTOTYPE(PROTOKEY_AND_INITIALIZER) -#undef PROTOKEY_AND_INITIALIZER - JSProto_LIMIT -}; - -/* Struct forward declarations. */ -struct JSClass; -struct JSCompartment; -struct JSCrossCompartmentCall; -class JSErrorReport; -struct JSExceptionState; -struct JSFunctionSpec; -struct JSLocaleCallbacks; -struct JSObjectMap; -struct JSPrincipals; -struct JSPropertyName; -struct JSPropertySpec; -struct JSRuntime; -struct JSSecurityCallbacks; -struct JSStructuredCloneCallbacks; -struct JSStructuredCloneReader; -struct JSStructuredCloneWriter; -class JS_PUBLIC_API(JSTracer); - -class JSFlatString; - -typedef bool (*JSInitCallback)(void); - -template<typename T> struct JSConstScalarSpec; -typedef JSConstScalarSpec<double> JSConstDoubleSpec; -typedef JSConstScalarSpec<int32_t> JSConstIntegerSpec; - -/* - * Generic trace operation that calls JS::TraceEdge on each traceable thing's - * location reachable from data. - */ -typedef void -(* JSTraceDataOp)(JSTracer* trc, void* data); - -namespace js { -namespace gc { -class AutoTraceSession; -class StoreBuffer; -} // namespace gc - -// Whether the current thread is permitted access to any part of the specified -// runtime or zone. -JS_FRIEND_API(bool) -CurrentThreadCanAccessRuntime(const JSRuntime* rt); - -#ifdef DEBUG -JS_FRIEND_API(bool) -CurrentThreadIsPerformingGC(); -#endif - -} // namespace js - -namespace JS { - -class JS_PUBLIC_API(AutoEnterCycleCollection); -class JS_PUBLIC_API(AutoAssertOnBarrier); -struct JS_PUBLIC_API(PropertyDescriptor); - -typedef void (*OffThreadCompileCallback)(void* token, void* callbackData); - -enum class HeapState { - Idle, // doing nothing with the GC heap - Tracing, // tracing the GC heap without collecting, e.g. IterateCompartments() - MajorCollecting, // doing a GC of the major heap - MinorCollecting, // doing a GC of the minor heap (nursery) - CycleCollecting // in the "Unlink" phase of cycle collection -}; - -namespace shadow { - -struct Runtime -{ - private: - JS::HeapState heapState_; - - protected: - void setHeapState(JS::HeapState newState) { - MOZ_ASSERT(js::CurrentThreadCanAccessRuntime(asRuntime())); - MOZ_ASSERT(heapState_ != newState); - heapState_ = newState; - } - - JS::HeapState heapState() const { - MOZ_ASSERT(js::CurrentThreadCanAccessRuntime(asRuntime()) || - js::CurrentThreadIsPerformingGC()); - return heapState_; - } - - // In some cases, invoking GC barriers (incremental or otherwise) will break - // things. These barriers assert if this flag is set. - bool allowGCBarriers_; - friend class JS::AutoAssertOnBarrier; - - js::gc::StoreBuffer* gcStoreBufferPtr_; - - // The gray bits can become invalid if UnmarkGray overflows the stack. A - // full GC will reset this bit, since it fills in all the gray bits. - bool gcGrayBitsValid_; - - public: - Runtime() - : heapState_(JS::HeapState::Idle) - , allowGCBarriers_(true) - , gcStoreBufferPtr_(nullptr) - , gcGrayBitsValid_(false) - {} - - bool isHeapBusy() const { return heapState() != JS::HeapState::Idle; } - bool isHeapTracing() const { return heapState() == JS::HeapState::Tracing; } - bool isHeapMajorCollecting() const { return heapState() == JS::HeapState::MajorCollecting; } - bool isHeapMinorCollecting() const { return heapState() == JS::HeapState::MinorCollecting; } - bool isHeapCollecting() const { return isHeapMinorCollecting() || isHeapMajorCollecting(); } - bool isCycleCollecting() const { - return heapState() == JS::HeapState::CycleCollecting; - } - - bool allowGCBarriers() const { return allowGCBarriers_; } - - js::gc::StoreBuffer* gcStoreBufferPtr() { return gcStoreBufferPtr_; } - - bool areGCGrayBitsValid() const { return gcGrayBitsValid_; } - void setGCGrayBitsValid(bool valid) { gcGrayBitsValid_ = valid; } - - const JSRuntime* asRuntime() const { - return reinterpret_cast<const JSRuntime*>(this); - } - - static JS::shadow::Runtime* asShadowRuntime(JSRuntime* rt) { - return reinterpret_cast<JS::shadow::Runtime*>(rt); - } - - protected: - void setGCStoreBufferPtr(js::gc::StoreBuffer* storeBuffer) { - gcStoreBufferPtr_ = storeBuffer; - } -}; - -} /* namespace shadow */ - -// Decorates the Unlinking phase of CycleCollection so that accidental use -// of barriered accessors results in assertions instead of leaks. -class MOZ_STACK_CLASS JS_PUBLIC_API(AutoEnterCycleCollection) -{ -#ifdef DEBUG - JSRuntime* runtime; - - public: - explicit AutoEnterCycleCollection(JSContext* cx); - ~AutoEnterCycleCollection(); -#else - public: - explicit AutoEnterCycleCollection(JSContext* cx) {} - ~AutoEnterCycleCollection() {} -#endif -}; - -class JS_PUBLIC_API(AutoGCRooter) -{ - public: - AutoGCRooter(JSContext* cx, ptrdiff_t tag); - AutoGCRooter(JS::RootingContext* cx, ptrdiff_t tag); - - ~AutoGCRooter() { - MOZ_ASSERT(this == *stackTop); - *stackTop = down; - } - - /* Implemented in gc/RootMarking.cpp. */ - inline void trace(JSTracer* trc); - static void traceAll(JSTracer* trc); - static void traceAllWrappers(JSTracer* trc); - - protected: - AutoGCRooter * const down; - - /* - * Discriminates actual subclass of this being used. If non-negative, the - * subclass roots an array of values of the length stored in this field. - * If negative, meaning is indicated by the corresponding value in the enum - * below. Any other negative value indicates some deeper problem such as - * memory corruption. - */ - ptrdiff_t tag_; - - enum { - VALARRAY = -2, /* js::AutoValueArray */ - PARSER = -3, /* js::frontend::Parser */ - VALVECTOR = -10, /* js::AutoValueVector */ - IDVECTOR = -11, /* js::AutoIdVector */ - OBJVECTOR = -14, /* js::AutoObjectVector */ - IONMASM = -19, /* js::jit::MacroAssembler */ - WRAPVECTOR = -20, /* js::AutoWrapperVector */ - WRAPPER = -21, /* js::AutoWrapperRooter */ - CUSTOM = -26 /* js::CustomAutoRooter */ - }; - - static ptrdiff_t GetTag(const Value& value) { return VALVECTOR; } - static ptrdiff_t GetTag(const jsid& id) { return IDVECTOR; } - static ptrdiff_t GetTag(JSObject* obj) { return OBJVECTOR; } - - private: - AutoGCRooter ** const stackTop; - - /* No copy or assignment semantics. */ - AutoGCRooter(AutoGCRooter& ida) = delete; - void operator=(AutoGCRooter& ida) = delete; -}; - -// Our instantiations of Rooted<void*> and PersistentRooted<void*> require an -// instantiation of MapTypeToRootKind. -template <> -struct MapTypeToRootKind<void*> { - static const RootKind kind = RootKind::Traceable; -}; - -} /* namespace JS */ - -namespace js { - -class ExclusiveContext; - -/* - * This list enumerates the different types of conceptual stacks we have in - * SpiderMonkey. In reality, they all share the C stack, but we allow different - * stack limits depending on the type of code running. - */ -enum StackKind -{ - StackForSystemCode, // C++, such as the GC, running on behalf of the VM. - StackForTrustedScript, // Script running with trusted principals. - StackForUntrustedScript, // Script running with untrusted principals. - StackKindCount -}; - -using RootedListHeads = mozilla::EnumeratedArray<JS::RootKind, JS::RootKind::Limit, - JS::Rooted<void*>*>; - -// Abstracts JS rooting mechanisms so they can be shared between the JSContext -// and JSRuntime. -class RootLists -{ - // Stack GC roots for Rooted GC heap pointers. - RootedListHeads stackRoots_; - template <typename T> friend class JS::Rooted; - - // Stack GC roots for AutoFooRooter classes. - JS::AutoGCRooter* autoGCRooters_; - friend class JS::AutoGCRooter; - - // Heap GC roots for PersistentRooted pointers. - mozilla::EnumeratedArray<JS::RootKind, JS::RootKind::Limit, - mozilla::LinkedList<JS::PersistentRooted<void*>>> heapRoots_; - template <typename T> friend class JS::PersistentRooted; - - public: - RootLists() : autoGCRooters_(nullptr) { - for (auto& stackRootPtr : stackRoots_) - stackRootPtr = nullptr; - } - - ~RootLists() { - // The semantics of PersistentRooted containing pointers and tagged - // pointers are somewhat different from those of PersistentRooted - // containing a structure with a trace method. PersistentRooted - // containing pointers are allowed to outlive the owning RootLists, - // whereas those containing a traceable structure are not. - // - // The purpose of this feature is to support lazy initialization of - // global references for the several places in Gecko that do not have - // access to a tighter context, but that still need to refer to GC - // pointers. For such pointers, FinishPersistentRootedChains ensures - // that the contained references are nulled out when the owning - // RootLists dies to prevent UAF errors. - // - // However, for RootKind::Traceable, we do not know the concrete type - // of the held thing, so we simply cannot do this without accruing - // extra overhead and complexity for all users for a case that is - // unlikely to ever be used in practice. For this reason, the following - // assertion disallows usage of PersistentRooted<Traceable> that - // outlives the RootLists. - MOZ_ASSERT(heapRoots_[JS::RootKind::Traceable].isEmpty()); - } - - void traceStackRoots(JSTracer* trc); - void checkNoGCRooters(); - - void tracePersistentRoots(JSTracer* trc); - void finishPersistentRoots(); -}; - -} // namespace js - -namespace JS { - -/* - * JS::RootingContext is a base class of ContextFriendFields and JSContext. - * This class can be used to let code construct a Rooted<> or PersistentRooted<> - * instance, without giving it full access to the JSContext. - */ -struct RootingContext -{ - js::RootLists roots; - -#ifdef DEBUG - // Whether the derived class is a JSContext or an ExclusiveContext. - bool isJSContext; -#endif - - explicit RootingContext(bool isJSContextArg) -#ifdef DEBUG - : isJSContext(isJSContextArg) -#endif - {} - - static RootingContext* get(JSContext* cx) { - return reinterpret_cast<RootingContext*>(cx); - } -}; - -} // namespace JS - -namespace js { - -struct ContextFriendFields : public JS::RootingContext -{ - protected: - /* The current compartment. */ - JSCompartment* compartment_; - - /* The current zone. */ - JS::Zone* zone_; - - public: - /* Limit pointer for checking native stack consumption. */ - uintptr_t nativeStackLimit[js::StackKindCount]; - - explicit ContextFriendFields(bool isJSContext); - - static const ContextFriendFields* get(const JSContext* cx) { - return reinterpret_cast<const ContextFriendFields*>(cx); - } - - static ContextFriendFields* get(JSContext* cx) { - return reinterpret_cast<ContextFriendFields*>(cx); - } - - friend JSCompartment* GetContextCompartment(const JSContext* cx); - friend JS::Zone* GetContextZone(const JSContext* cx); - template <typename T> friend class JS::Rooted; -}; - -/* - * Inlinable accessors for JSContext. - * - * - These must not be available on the more restricted superclasses of - * JSContext, so we can't simply define them on ContextFriendFields. - * - * - They're perfectly ordinary JSContext functionality, so ought to be - * usable without resorting to jsfriendapi.h, and when JSContext is an - * incomplete type. - */ -inline JSCompartment* -GetContextCompartment(const JSContext* cx) -{ - return ContextFriendFields::get(cx)->compartment_; -} - -inline JS::Zone* -GetContextZone(const JSContext* cx) -{ - return ContextFriendFields::get(cx)->zone_; -} - -} /* namespace js */ - -MOZ_BEGIN_EXTERN_C - -// Defined in NSPR prio.h. -typedef struct PRFileDesc PRFileDesc; - -MOZ_END_EXTERN_C - -#endif /* jspubtd_h */ diff --git a/android/armeabi/include/spidermonkey/jstypes.h b/android/armeabi/include/spidermonkey/jstypes.h deleted file mode 100644 index 914674ab..00000000 --- a/android/armeabi/include/spidermonkey/jstypes.h +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* -** File: jstypes.h -** Description: Definitions of NSPR's basic types -** -** Prototypes and macros used to make up for deficiencies in ANSI environments -** that we have found. -** -** Since we do not wrap <stdlib.h> and all the other standard headers, authors -** of portable code will not know in general that they need these definitions. -** Instead of requiring these authors to find the dependent uses in their code -** and take the following steps only in those C files, we take steps once here -** for all C files. -**/ - -#ifndef jstypes_h -#define jstypes_h - -#include "mozilla/Attributes.h" -#include "mozilla/Casting.h" -#include "mozilla/Types.h" - -// jstypes.h is (or should be!) included by every file in SpiderMonkey. -// js-config.h and jsversion.h also should be included by every file. -// So include them here. -// XXX: including them in js/RequiredDefines.h should be a better option, since -// that is by definition the header file that should be included in all -// SpiderMonkey code. However, Gecko doesn't do this! See bug 909576. -#include "js-config.h" -#include "jsversion.h" - -/*********************************************************************** -** MACROS: JS_EXTERN_API -** JS_EXPORT_API -** DESCRIPTION: -** These are only for externally visible routines and globals. For -** internal routines, just use "extern" for type checking and that -** will not export internal cross-file or forward-declared symbols. -** Define a macro for declaring procedures return types. We use this to -** deal with windoze specific type hackery for DLL definitions. Use -** JS_EXTERN_API when the prototype for the method is declared. Use -** JS_EXPORT_API for the implementation of the method. -** -** Example: -** in dowhim.h -** JS_EXTERN_API( void ) DoWhatIMean( void ); -** in dowhim.c -** JS_EXPORT_API( void ) DoWhatIMean( void ) { return; } -** -** -***********************************************************************/ - -#define JS_EXTERN_API(type) extern MOZ_EXPORT type -#define JS_EXPORT_API(type) MOZ_EXPORT type -#define JS_EXPORT_DATA(type) MOZ_EXPORT type -#define JS_IMPORT_API(type) MOZ_IMPORT_API type -#define JS_IMPORT_DATA(type) MOZ_IMPORT_DATA type - -/* - * The linkage of JS API functions differs depending on whether the file is - * used within the JS library or not. Any source file within the JS - * interpreter should define EXPORT_JS_API whereas any client of the library - * should not. STATIC_JS_API is used to build JS as a static library. - */ -#if defined(STATIC_JS_API) -# define JS_PUBLIC_API(t) t -# define JS_PUBLIC_DATA(t) t -# define JS_FRIEND_API(t) t -# define JS_FRIEND_DATA(t) t -#elif defined(EXPORT_JS_API) || defined(STATIC_EXPORTABLE_JS_API) -# define JS_PUBLIC_API(t) MOZ_EXPORT t -# define JS_PUBLIC_DATA(t) MOZ_EXPORT t -# define JS_FRIEND_API(t) MOZ_EXPORT t -# define JS_FRIEND_DATA(t) MOZ_EXPORT t -#else -# define JS_PUBLIC_API(t) MOZ_IMPORT_API t -# define JS_PUBLIC_DATA(t) MOZ_IMPORT_DATA t -# define JS_FRIEND_API(t) MOZ_IMPORT_API t -# define JS_FRIEND_DATA(t) MOZ_IMPORT_DATA t -#endif - -#if defined(_MSC_VER) && defined(_M_IX86) -#define JS_FASTCALL __fastcall -#elif defined(__GNUC__) && defined(__i386__) -#define JS_FASTCALL __attribute__((fastcall)) -#else -#define JS_FASTCALL -#define JS_NO_FASTCALL -#endif - -/*********************************************************************** -** MACROS: JS_BEGIN_MACRO -** JS_END_MACRO -** DESCRIPTION: -** Macro body brackets so that macros with compound statement definitions -** behave syntactically more like functions when called. -***********************************************************************/ -#define JS_BEGIN_MACRO do { - -#if defined(_MSC_VER) -# define JS_END_MACRO \ - } __pragma(warning(push)) __pragma(warning(disable:4127)) \ - while (0) __pragma(warning(pop)) -#else -# define JS_END_MACRO } while (0) -#endif - -/*********************************************************************** -** MACROS: JS_BIT -** JS_BITMASK -** DESCRIPTION: -** Bit masking macros. XXX n must be <= 31 to be portable -***********************************************************************/ -#define JS_BIT(n) ((uint32_t)1 << (n)) -#define JS_BITMASK(n) (JS_BIT(n) - 1) - -/*********************************************************************** -** MACROS: JS_HOWMANY -** JS_ROUNDUP -** DESCRIPTION: -** Commonly used macros for operations on compatible types. -***********************************************************************/ -#define JS_HOWMANY(x,y) (((x)+(y)-1)/(y)) -#define JS_ROUNDUP(x,y) (JS_HOWMANY(x,y)*(y)) - -#include "jscpucfg.h" - -/* - * Define JS_64BIT iff we are building in an environment with 64-bit - * addresses. - */ -#ifdef _MSC_VER -# if defined(_M_X64) || defined(_M_AMD64) -# define JS_64BIT -# endif -#elif defined(__GNUC__) -/* Additional GCC defines are when running on Solaris, AIX, and HPUX */ -# if defined(__x86_64__) || defined(__sparcv9) || \ - defined(__64BIT__) || defined(__LP64__) -# define JS_64BIT -# endif -#elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) /* Sun Studio C/C++ */ -# if defined(__x86_64) || defined(__sparcv9) -# define JS_64BIT -# endif -#elif defined(__xlc__) || defined(__xlC__) /* IBM XL C/C++ */ -# if defined(__64BIT__) -# define JS_64BIT -# endif -#elif defined(__HP_cc) || defined(__HP_aCC) /* HP-UX cc/aCC */ -# if defined(__LP64__) -# define JS_64BIT -# endif -#else -# error "Implement me" -#endif - -/*********************************************************************** -** MACROS: JS_ARRAY_LENGTH -** JS_ARRAY_END -** DESCRIPTION: -** Macros to get the number of elements and the pointer to one past the -** last element of a C array. Use them like this: -** -** char16_t buf[10]; -** JSString* str; -** ... -** for (char16_t* s = buf; s != JS_ARRAY_END(buf); ++s) *s = ...; -** ... -** str = JS_NewStringCopyN(cx, buf, JS_ARRAY_LENGTH(buf)); -** ... -** -***********************************************************************/ - -#define JS_ARRAY_LENGTH(array) (sizeof (array) / sizeof (array)[0]) -#define JS_ARRAY_END(array) ((array) + JS_ARRAY_LENGTH(array)) - -#define JS_BITS_PER_BYTE 8 -#define JS_BITS_PER_BYTE_LOG2 3 - -#if defined(JS_64BIT) -# define JS_BITS_PER_WORD 64 -#else -# define JS_BITS_PER_WORD 32 -#endif - -/*********************************************************************** -** MACROS: JS_FUNC_TO_DATA_PTR -** JS_DATA_TO_FUNC_PTR -** DESCRIPTION: -** Macros to convert between function and data pointers of the same -** size. Use them like this: -** -** JSGetterOp nativeGetter; -** JSObject* scriptedGetter; -** ... -** scriptedGetter = JS_FUNC_TO_DATA_PTR(JSObject*, nativeGetter); -** ... -** nativeGetter = JS_DATA_TO_FUNC_PTR(JSGetterOp, scriptedGetter); -** -***********************************************************************/ - -#define JS_FUNC_TO_DATA_PTR(type, fun) (mozilla::BitwiseCast<type>(fun)) -#define JS_DATA_TO_FUNC_PTR(type, ptr) (mozilla::BitwiseCast<type>(ptr)) - -#ifdef __GNUC__ -# define JS_EXTENSION __extension__ -# define JS_EXTENSION_(s) __extension__ ({ s; }) -#else -# define JS_EXTENSION -# define JS_EXTENSION_(s) s -#endif - -#endif /* jstypes_h */ diff --git a/android/armeabi/include/spidermonkey/jsversion.h b/android/armeabi/include/spidermonkey/jsversion.h deleted file mode 100644 index 8bdfe47b..00000000 --- a/android/armeabi/include/spidermonkey/jsversion.h +++ /dev/null @@ -1,40 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef jsversion_h -#define jsversion_h - -/* - * JS Capability Macros. - */ -#define JS_HAS_STR_HTML_HELPERS 1 /* (no longer used) */ -#define JS_HAS_OBJ_PROTO_PROP 1 /* has o.__proto__ etc. */ -#define JS_HAS_OBJ_WATCHPOINT 1 /* has o.watch and o.unwatch */ -#define JS_HAS_TOSOURCE 1 /* has Object/Array toSource method */ -#define JS_HAS_CATCH_GUARD 1 /* has exception handling catch guard */ -#define JS_HAS_UNEVAL 1 /* has uneval() top-level function */ -#define JS_HAS_CONST 1 /* (no longer used) */ -#define JS_HAS_FUN_EXPR_STMT 1 /* (no longer used) */ -#define JS_HAS_FOR_EACH_IN 1 /* has for each (lhs in iterable) */ -#define JS_HAS_GENERATORS 1 /* (no longer used) */ -#define JS_HAS_BLOCK_SCOPE 1 /* (no longer used) */ -#define JS_HAS_DESTRUCTURING 2 /* (no longer used) */ -#define JS_HAS_GENERATOR_EXPRS 1 /* (no longer used) */ -#define JS_HAS_EXPR_CLOSURES 1 /* has function (formals) listexpr */ - -/* (no longer used) */ -#define JS_HAS_NEW_GLOBAL_OBJECT 1 - -/* (no longer used) */ -#define JS_HAS_DESTRUCTURING_SHORTHAND (JS_HAS_DESTRUCTURING == 2) - -/* - * Feature for Object.prototype.__{define,lookup}{G,S}etter__ legacy support; - * support likely to be made opt-in at some future time. - */ -#define JS_OLD_GETTER_SETTER_METHODS 1 - -#endif /* jsversion_h */ diff --git a/android/armeabi/include/spidermonkey/jswrapper.h b/android/armeabi/include/spidermonkey/jswrapper.h deleted file mode 100644 index 9b14c59e..00000000 --- a/android/armeabi/include/spidermonkey/jswrapper.h +++ /dev/null @@ -1,382 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: set ts=8 sts=4 et sw=4 tw=99: - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef jswrapper_h -#define jswrapper_h - -#include "mozilla/Attributes.h" - -#include "js/Proxy.h" - -namespace js { - -/* - * Helper for Wrapper::New default options. - * - * Callers of Wrapper::New() who wish to specify a prototype for the created - * Wrapper, *MUST* construct a WrapperOptions with a JSContext. - */ -class MOZ_STACK_CLASS WrapperOptions : public ProxyOptions { - public: - WrapperOptions() : ProxyOptions(false), - proto_() - {} - - explicit WrapperOptions(JSContext* cx) : ProxyOptions(false), - proto_() - { - proto_.emplace(cx); - } - - inline JSObject* proto() const; - WrapperOptions& setProto(JSObject* protoArg) { - MOZ_ASSERT(proto_); - *proto_ = protoArg; - return *this; - } - - private: - mozilla::Maybe<JS::RootedObject> proto_; -}; - -/* - * A wrapper is a proxy with a target object to which it generally forwards - * operations, but may restrict access to certain operations or augment those - * operations in various ways. - * - * A wrapper can be "unwrapped" in C++, exposing the underlying object. - * Callers should be careful to avoid unwrapping security wrappers in the wrong - * context. - * - * Important: If you add a method implementation here, you probably also need - * to add an override in CrossCompartmentWrapper. If you don't, you risk - * compartment mismatches. See bug 945826 comment 0. - */ -class JS_FRIEND_API(Wrapper) : public BaseProxyHandler -{ - unsigned mFlags; - - public: - explicit constexpr Wrapper(unsigned aFlags, bool aHasPrototype = false, - bool aHasSecurityPolicy = false) - : BaseProxyHandler(&family, aHasPrototype, aHasSecurityPolicy), - mFlags(aFlags) - { } - - virtual bool finalizeInBackground(const Value& priv) const override; - - /* Standard internal methods. */ - virtual bool getOwnPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id, - MutableHandle<PropertyDescriptor> desc) const override; - virtual bool defineProperty(JSContext* cx, HandleObject proxy, HandleId id, - Handle<PropertyDescriptor> desc, - ObjectOpResult& result) const override; - virtual bool ownPropertyKeys(JSContext* cx, HandleObject proxy, - AutoIdVector& props) const override; - virtual bool delete_(JSContext* cx, HandleObject proxy, HandleId id, - ObjectOpResult& result) const override; - virtual bool enumerate(JSContext* cx, HandleObject proxy, - MutableHandleObject objp) const override; - virtual bool getPrototype(JSContext* cx, HandleObject proxy, - MutableHandleObject protop) const override; - virtual bool setPrototype(JSContext* cx, HandleObject proxy, HandleObject proto, - ObjectOpResult& result) const override; - virtual bool getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy, bool* isOrdinary, - MutableHandleObject protop) const override; - virtual bool setImmutablePrototype(JSContext* cx, HandleObject proxy, - bool* succeeded) const override; - virtual bool preventExtensions(JSContext* cx, HandleObject proxy, - ObjectOpResult& result) const override; - virtual bool isExtensible(JSContext* cx, HandleObject proxy, bool* extensible) const override; - virtual bool has(JSContext* cx, HandleObject proxy, HandleId id, - bool* bp) const override; - virtual bool get(JSContext* cx, HandleObject proxy, HandleValue receiver, - HandleId id, MutableHandleValue vp) const override; - virtual bool set(JSContext* cx, HandleObject proxy, HandleId id, HandleValue v, - HandleValue receiver, ObjectOpResult& result) const override; - virtual bool call(JSContext* cx, HandleObject proxy, const CallArgs& args) const override; - virtual bool construct(JSContext* cx, HandleObject proxy, const CallArgs& args) const override; - - /* SpiderMonkey extensions. */ - virtual bool getPropertyDescriptor(JSContext* cx, HandleObject proxy, HandleId id, - MutableHandle<PropertyDescriptor> desc) const override; - virtual bool hasOwn(JSContext* cx, HandleObject proxy, HandleId id, - bool* bp) const override; - virtual bool getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject proxy, - AutoIdVector& props) const override; - virtual bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl, - const CallArgs& args) const override; - virtual bool hasInstance(JSContext* cx, HandleObject proxy, MutableHandleValue v, - bool* bp) const override; - virtual bool getBuiltinClass(JSContext* cx, HandleObject proxy, ESClass* cls) const override; - virtual bool isArray(JSContext* cx, HandleObject proxy, - JS::IsArrayAnswer* answer) const override; - virtual const char* className(JSContext* cx, HandleObject proxy) const override; - virtual JSString* fun_toString(JSContext* cx, HandleObject proxy, - unsigned indent) const override; - virtual bool regexp_toShared(JSContext* cx, HandleObject proxy, - RegExpGuard* g) const override; - virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy, - MutableHandleValue vp) const override; - virtual bool isCallable(JSObject* obj) const override; - virtual bool isConstructor(JSObject* obj) const override; - virtual JSObject* weakmapKeyDelegate(JSObject* proxy) const override; - - public: - using BaseProxyHandler::Action; - - enum Flags { - CROSS_COMPARTMENT = 1 << 0, - LAST_USED_FLAG = CROSS_COMPARTMENT - }; - - static JSObject* New(JSContext* cx, JSObject* obj, const Wrapper* handler, - const WrapperOptions& options = WrapperOptions()); - - static JSObject* Renew(JSContext* cx, JSObject* existing, JSObject* obj, const Wrapper* handler); - - static const Wrapper* wrapperHandler(JSObject* wrapper); - - static JSObject* wrappedObject(JSObject* wrapper); - - unsigned flags() const { - return mFlags; - } - - static const char family; - static const Wrapper singleton; - static const Wrapper singletonWithPrototype; - - static JSObject* defaultProto; -}; - -inline JSObject* -WrapperOptions::proto() const -{ - return proto_ ? *proto_ : Wrapper::defaultProto; -} - -/* Base class for all cross compartment wrapper handlers. */ -class JS_FRIEND_API(CrossCompartmentWrapper) : public Wrapper -{ - public: - explicit constexpr CrossCompartmentWrapper(unsigned aFlags, bool aHasPrototype = false, - bool aHasSecurityPolicy = false) - : Wrapper(CROSS_COMPARTMENT | aFlags, aHasPrototype, aHasSecurityPolicy) - { } - - /* Standard internal methods. */ - virtual bool getOwnPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id, - MutableHandle<PropertyDescriptor> desc) const override; - virtual bool defineProperty(JSContext* cx, HandleObject wrapper, HandleId id, - Handle<PropertyDescriptor> desc, - ObjectOpResult& result) const override; - virtual bool ownPropertyKeys(JSContext* cx, HandleObject wrapper, - AutoIdVector& props) const override; - virtual bool delete_(JSContext* cx, HandleObject wrapper, HandleId id, - ObjectOpResult& result) const override; - virtual bool enumerate(JSContext* cx, HandleObject wrapper, MutableHandleObject objp) const override; - virtual bool getPrototype(JSContext* cx, HandleObject proxy, - MutableHandleObject protop) const override; - virtual bool setPrototype(JSContext* cx, HandleObject proxy, HandleObject proto, - ObjectOpResult& result) const override; - - virtual bool getPrototypeIfOrdinary(JSContext* cx, HandleObject proxy, bool* isOrdinary, - MutableHandleObject protop) const override; - virtual bool setImmutablePrototype(JSContext* cx, HandleObject proxy, - bool* succeeded) const override; - virtual bool preventExtensions(JSContext* cx, HandleObject wrapper, - ObjectOpResult& result) const override; - virtual bool isExtensible(JSContext* cx, HandleObject wrapper, bool* extensible) const override; - virtual bool has(JSContext* cx, HandleObject wrapper, HandleId id, bool* bp) const override; - virtual bool get(JSContext* cx, HandleObject wrapper, HandleValue receiver, - HandleId id, MutableHandleValue vp) const override; - virtual bool set(JSContext* cx, HandleObject wrapper, HandleId id, HandleValue v, - HandleValue receiver, ObjectOpResult& result) const override; - virtual bool call(JSContext* cx, HandleObject wrapper, const CallArgs& args) const override; - virtual bool construct(JSContext* cx, HandleObject wrapper, const CallArgs& args) const override; - - /* SpiderMonkey extensions. */ - virtual bool getPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id, - MutableHandle<PropertyDescriptor> desc) const override; - virtual bool hasOwn(JSContext* cx, HandleObject wrapper, HandleId id, bool* bp) const override; - virtual bool getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject wrapper, - AutoIdVector& props) const override; - virtual bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl, - const CallArgs& args) const override; - virtual bool hasInstance(JSContext* cx, HandleObject wrapper, MutableHandleValue v, - bool* bp) const override; - virtual const char* className(JSContext* cx, HandleObject proxy) const override; - virtual JSString* fun_toString(JSContext* cx, HandleObject wrapper, - unsigned indent) const override; - virtual bool regexp_toShared(JSContext* cx, HandleObject proxy, RegExpGuard* g) const override; - virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy, MutableHandleValue vp) const override; - - // Allocate CrossCompartmentWrappers in the nursery. - virtual bool canNurseryAllocate() const override { return true; } - - static const CrossCompartmentWrapper singleton; - static const CrossCompartmentWrapper singletonWithPrototype; -}; - -class JS_FRIEND_API(OpaqueCrossCompartmentWrapper) : public CrossCompartmentWrapper -{ - public: - explicit constexpr OpaqueCrossCompartmentWrapper() : CrossCompartmentWrapper(0) - { } - - /* Standard internal methods. */ - virtual bool getOwnPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id, - MutableHandle<PropertyDescriptor> desc) const override; - virtual bool defineProperty(JSContext* cx, HandleObject wrapper, HandleId id, - Handle<PropertyDescriptor> desc, - ObjectOpResult& result) const override; - virtual bool ownPropertyKeys(JSContext* cx, HandleObject wrapper, - AutoIdVector& props) const override; - virtual bool delete_(JSContext* cx, HandleObject wrapper, HandleId id, - ObjectOpResult& result) const override; - virtual bool enumerate(JSContext* cx, HandleObject wrapper, - MutableHandleObject objp) const override; - virtual bool getPrototype(JSContext* cx, HandleObject wrapper, - MutableHandleObject protop) const override; - virtual bool setPrototype(JSContext* cx, HandleObject wrapper, HandleObject proto, - ObjectOpResult& result) const override; - virtual bool getPrototypeIfOrdinary(JSContext* cx, HandleObject wrapper, bool* isOrdinary, - MutableHandleObject protop) const override; - virtual bool setImmutablePrototype(JSContext* cx, HandleObject wrapper, - bool* succeeded) const override; - virtual bool preventExtensions(JSContext* cx, HandleObject wrapper, - ObjectOpResult& result) const override; - virtual bool isExtensible(JSContext* cx, HandleObject wrapper, bool* extensible) const override; - virtual bool has(JSContext* cx, HandleObject wrapper, HandleId id, - bool* bp) const override; - virtual bool get(JSContext* cx, HandleObject wrapper, HandleValue receiver, - HandleId id, MutableHandleValue vp) const override; - virtual bool set(JSContext* cx, HandleObject wrapper, HandleId id, HandleValue v, - HandleValue receiver, ObjectOpResult& result) const override; - virtual bool call(JSContext* cx, HandleObject wrapper, const CallArgs& args) const override; - virtual bool construct(JSContext* cx, HandleObject wrapper, const CallArgs& args) const override; - - /* SpiderMonkey extensions. */ - virtual bool getPropertyDescriptor(JSContext* cx, HandleObject wrapper, HandleId id, - MutableHandle<PropertyDescriptor> desc) const override; - virtual bool hasOwn(JSContext* cx, HandleObject wrapper, HandleId id, - bool* bp) const override; - virtual bool getOwnEnumerablePropertyKeys(JSContext* cx, HandleObject wrapper, - AutoIdVector& props) const override; - virtual bool getBuiltinClass(JSContext* cx, HandleObject wrapper, ESClass* cls) const override; - virtual bool isArray(JSContext* cx, HandleObject obj, - JS::IsArrayAnswer* answer) const override; - virtual const char* className(JSContext* cx, HandleObject wrapper) const override; - virtual JSString* fun_toString(JSContext* cx, HandleObject proxy, unsigned indent) const override; - - static const OpaqueCrossCompartmentWrapper singleton; -}; - -/* - * Base class for security wrappers. A security wrapper is potentially hiding - * all or part of some wrapped object thus SecurityWrapper defaults to denying - * access to the wrappee. This is the opposite of Wrapper which tries to be - * completely transparent. - * - * NB: Currently, only a few ProxyHandler operations are overridden to deny - * access, relying on derived SecurityWrapper to block access when necessary. - */ -template <class Base> -class JS_FRIEND_API(SecurityWrapper) : public Base -{ - public: - explicit constexpr SecurityWrapper(unsigned flags, bool hasPrototype = false) - : Base(flags, hasPrototype, /* hasSecurityPolicy = */ true) - { } - - virtual bool enter(JSContext* cx, HandleObject wrapper, HandleId id, Wrapper::Action act, - bool* bp) const override; - - virtual bool defineProperty(JSContext* cx, HandleObject wrapper, HandleId id, - Handle<PropertyDescriptor> desc, - ObjectOpResult& result) const override; - virtual bool isExtensible(JSContext* cx, HandleObject wrapper, bool* extensible) const override; - virtual bool preventExtensions(JSContext* cx, HandleObject wrapper, - ObjectOpResult& result) const override; - virtual bool setPrototype(JSContext* cx, HandleObject proxy, HandleObject proto, - ObjectOpResult& result) const override; - virtual bool setImmutablePrototype(JSContext* cx, HandleObject proxy, bool* succeeded) const override; - - virtual bool nativeCall(JSContext* cx, IsAcceptableThis test, NativeImpl impl, - const CallArgs& args) const override; - virtual bool getBuiltinClass(JSContext* cx, HandleObject wrapper, ESClass* cls) const override; - virtual bool isArray(JSContext* cx, HandleObject wrapper, JS::IsArrayAnswer* answer) const override; - virtual bool regexp_toShared(JSContext* cx, HandleObject proxy, RegExpGuard* g) const override; - virtual bool boxedValue_unbox(JSContext* cx, HandleObject proxy, MutableHandleValue vp) const override; - - // Allow isCallable and isConstructor. They used to be class-level, and so could not be guarded - // against. - - virtual bool watch(JSContext* cx, JS::HandleObject proxy, JS::HandleId id, - JS::HandleObject callable) const override; - virtual bool unwatch(JSContext* cx, JS::HandleObject proxy, JS::HandleId id) const override; - - /* - * Allow our subclasses to select the superclass behavior they want without - * needing to specify an exact superclass. - */ - typedef Base Permissive; - typedef SecurityWrapper<Base> Restrictive; -}; - -typedef SecurityWrapper<CrossCompartmentWrapper> CrossCompartmentSecurityWrapper; - -extern JSObject* -TransparentObjectWrapper(JSContext* cx, HandleObject existing, HandleObject obj); - -inline bool -IsWrapper(JSObject* obj) -{ - return IsProxy(obj) && GetProxyHandler(obj)->family() == &Wrapper::family; -} - -// Given a JSObject, returns that object stripped of wrappers. If -// stopAtWindowProxy is true, then this returns the WindowProxy if it was -// previously wrapped. Otherwise, this returns the first object for -// which JSObject::isWrapper returns false. -JS_FRIEND_API(JSObject*) -UncheckedUnwrap(JSObject* obj, bool stopAtWindowProxy = true, unsigned* flagsp = nullptr); - -// Given a JSObject, returns that object stripped of wrappers. At each stage, -// the security wrapper has the opportunity to veto the unwrap. If -// stopAtWindowProxy is true, then this returns the WindowProxy if it was -// previously wrapped. -JS_FRIEND_API(JSObject*) -CheckedUnwrap(JSObject* obj, bool stopAtWindowProxy = true); - -// Unwrap only the outermost security wrapper, with the same semantics as -// above. This is the checked version of Wrapper::wrappedObject. -JS_FRIEND_API(JSObject*) -UnwrapOneChecked(JSObject* obj, bool stopAtWindowProxy = true); - -JS_FRIEND_API(bool) -IsCrossCompartmentWrapper(JSObject* obj); - -void -NukeCrossCompartmentWrapper(JSContext* cx, JSObject* wrapper); - -void -RemapWrapper(JSContext* cx, JSObject* wobj, JSObject* newTarget); - -JS_FRIEND_API(bool) -RemapAllWrappersForObject(JSContext* cx, JSObject* oldTarget, - JSObject* newTarget); - -// API to recompute all cross-compartment wrappers whose source and target -// match the given filters. -JS_FRIEND_API(bool) -RecomputeWrappers(JSContext* cx, const CompartmentFilter& sourceFilter, - const CompartmentFilter& targetFilter); - -} /* namespace js */ - -#endif /* jswrapper_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Alignment.h b/android/armeabi/include/spidermonkey/mozilla/Alignment.h deleted file mode 100644 index 4fcda4f3..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Alignment.h +++ /dev/null @@ -1,154 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Functionality related to memory alignment. */ - -#ifndef mozilla_Alignment_h -#define mozilla_Alignment_h - -#include "mozilla/Attributes.h" -#include <stddef.h> -#include <stdint.h> - -namespace mozilla { - -/* - * This class, and the corresponding macro MOZ_ALIGNOF, figures out how many - * bytes of alignment a given type needs. - */ -template<typename T> -class AlignmentFinder -{ - struct Aligner - { - char mChar; - T mT; - }; - -public: - static const size_t alignment = sizeof(Aligner) - sizeof(T); -}; - -#define MOZ_ALIGNOF(T) mozilla::AlignmentFinder<T>::alignment - -/* - * Declare the MOZ_ALIGNED_DECL macro for declaring aligned types. - * - * For instance, - * - * MOZ_ALIGNED_DECL(char arr[2], 8); - * - * will declare a two-character array |arr| aligned to 8 bytes. - */ - -#if defined(__GNUC__) -# define MOZ_ALIGNED_DECL(_type, _align) \ - _type __attribute__((aligned(_align))) -#elif defined(_MSC_VER) -# define MOZ_ALIGNED_DECL(_type, _align) \ - __declspec(align(_align)) _type -#else -# warning "We don't know how to align variables on this compiler." -# define MOZ_ALIGNED_DECL(_type, _align) _type -#endif - -/* - * AlignedElem<N> is a structure whose alignment is guaranteed to be at least N - * bytes. - * - * We support 1, 2, 4, 8, and 16-bit alignment. - */ -template<size_t Align> -struct AlignedElem; - -/* - * We have to specialize this template because GCC doesn't like - * __attribute__((aligned(foo))) where foo is a template parameter. - */ - -template<> -struct AlignedElem<1> -{ - MOZ_ALIGNED_DECL(uint8_t elem, 1); -}; - -template<> -struct AlignedElem<2> -{ - MOZ_ALIGNED_DECL(uint8_t elem, 2); -}; - -template<> -struct AlignedElem<4> -{ - MOZ_ALIGNED_DECL(uint8_t elem, 4); -}; - -template<> -struct AlignedElem<8> -{ - MOZ_ALIGNED_DECL(uint8_t elem, 8); -}; - -template<> -struct AlignedElem<16> -{ - MOZ_ALIGNED_DECL(uint8_t elem, 16); -}; - -/* - * This utility pales in comparison to Boost's aligned_storage. The utility - * simply assumes that uint64_t is enough alignment for anyone. This may need - * to be extended one day... - * - * As an important side effect, pulling the storage into this template is - * enough obfuscation to confuse gcc's strict-aliasing analysis into not giving - * false negatives when we cast from the char buffer to whatever type we've - * constructed using the bytes. - */ -template<size_t Nbytes> -struct AlignedStorage -{ - union U - { - char mBytes[Nbytes]; - uint64_t mDummy; - } u; - - const void* addr() const { return u.mBytes; } - void* addr() { return u.mBytes; } - - AlignedStorage() = default; - - // AlignedStorage is non-copyable: the default copy constructor violates - // strict aliasing rules, per bug 1269319. - AlignedStorage(const AlignedStorage&) = delete; - void operator=(const AlignedStorage&) = delete; -}; - -template<typename T> -struct MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS AlignedStorage2 -{ - union U - { - char mBytes[sizeof(T)]; - uint64_t mDummy; - } u; - - const T* addr() const { return reinterpret_cast<const T*>(u.mBytes); } - T* addr() { return static_cast<T*>(static_cast<void*>(u.mBytes)); } - - AlignedStorage2() = default; - - // AlignedStorage2 is non-copyable: the default copy constructor violates - // strict aliasing rules, per bug 1269319. - AlignedStorage2(const AlignedStorage2&) = delete; - void operator=(const AlignedStorage2&) = delete; -}; - -} /* namespace mozilla */ - -#endif /* mozilla_Alignment_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/AllocPolicy.h b/android/armeabi/include/spidermonkey/mozilla/AllocPolicy.h deleted file mode 100644 index 81f62b03..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/AllocPolicy.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * An allocation policy concept, usable for structures and algorithms to - * control how memory is allocated and how failures are handled. - */ - -#ifndef mozilla_AllocPolicy_h -#define mozilla_AllocPolicy_h - -#include "mozilla/Attributes.h" -#include "mozilla/TemplateLib.h" - -#include <stddef.h> -#include <stdlib.h> - -namespace mozilla { - -/* - * Allocation policies are used to implement the standard allocation behaviors - * in a customizable way. Additionally, custom behaviors may be added to these - * behaviors, such as additionally reporting an error through an out-of-band - * mechanism when OOM occurs. The concept modeled here is as follows: - * - * - public copy constructor, assignment, destructor - * - template <typename T> T* maybe_pod_malloc(size_t) - * Fallible, but doesn't report an error on OOM. - * - template <typename T> T* maybe_pod_calloc(size_t) - * Fallible, but doesn't report an error on OOM. - * - template <typename T> T* maybe_pod_realloc(T*, size_t, size_t) - * Fallible, but doesn't report an error on OOM. The old allocation - * size is passed in, in addition to the new allocation size requested. - * - template <typename T> T* pod_malloc(size_t) - * Responsible for OOM reporting when null is returned. - * - template <typename T> T* pod_calloc(size_t) - * Responsible for OOM reporting when null is returned. - * - template <typename T> T* pod_realloc(T*, size_t, size_t) - * Responsible for OOM reporting when null is returned. The old allocation - * size is passed in, in addition to the new allocation size requested. - * - void free_(void*) - * - void reportAllocOverflow() const - * Called on allocation overflow (that is, an allocation implicitly tried - * to allocate more than the available memory space -- think allocating an - * array of large-size objects, where N * size overflows) before null is - * returned. - * - bool checkSimulatedOOM() const - * Some clients generally allocate memory yet in some circumstances won't - * need to do so. For example, appending to a vector with a small amount of - * inline storage generally allocates memory, but no allocation occurs - * unless appending exceeds inline storage. But for testing purposes, it - * can be useful to treat *every* operation as allocating. - * Clients (such as this hypothetical append method implementation) should - * call this method in situations that don't allocate, but could generally, - * to support this. The default behavior should return true; more - * complicated behavior might be to return false only after a certain - * number of allocations-or-check-simulated-OOMs (coordinating with the - * other AllocPolicy methods) have occurred. - * - * mfbt provides (and typically uses by default) only MallocAllocPolicy, which - * does nothing more than delegate to the malloc/alloc/free functions. - */ - -/* - * A policy that straightforwardly uses malloc/calloc/realloc/free and adds no - * extra behaviors. - */ -class MallocAllocPolicy -{ -public: - template <typename T> - T* maybe_pod_malloc(size_t aNumElems) - { - if (aNumElems & mozilla::tl::MulOverflowMask<sizeof(T)>::value) { - return nullptr; - } - return static_cast<T*>(malloc(aNumElems * sizeof(T))); - } - - template <typename T> - T* maybe_pod_calloc(size_t aNumElems) - { - return static_cast<T*>(calloc(aNumElems, sizeof(T))); - } - - template <typename T> - T* maybe_pod_realloc(T* aPtr, size_t aOldSize, size_t aNewSize) - { - if (aNewSize & mozilla::tl::MulOverflowMask<sizeof(T)>::value) { - return nullptr; - } - return static_cast<T*>(realloc(aPtr, aNewSize * sizeof(T))); - } - - template <typename T> - T* pod_malloc(size_t aNumElems) - { - return maybe_pod_malloc<T>(aNumElems); - } - - template <typename T> - T* pod_calloc(size_t aNumElems) - { - return maybe_pod_calloc<T>(aNumElems); - } - - template <typename T> - T* pod_realloc(T* aPtr, size_t aOldSize, size_t aNewSize) - { - return maybe_pod_realloc<T>(aPtr, aOldSize, aNewSize); - } - - void free_(void* aPtr) - { - free(aPtr); - } - - void reportAllocOverflow() const - { - } - - MOZ_MUST_USE bool checkSimulatedOOM() const - { - return true; - } -}; - -} // namespace mozilla - -#endif /* mozilla_AllocPolicy_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/AlreadyAddRefed.h b/android/armeabi/include/spidermonkey/mozilla/AlreadyAddRefed.h deleted file mode 100644 index 0d7b0cae..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/AlreadyAddRefed.h +++ /dev/null @@ -1,147 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Typed temporary pointers for reference-counted smart pointers. */ - -#ifndef AlreadyAddRefed_h -#define AlreadyAddRefed_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Move.h" - -namespace mozilla { - -struct unused_t; - -} // namespace mozilla - -/** - * already_AddRefed cooperates with reference counting smart pointers to enable - * you to assign in a pointer _without_ |AddRef|ing it. You might want to use - * this as a return type from a function that returns an already |AddRef|ed - * pointer. - * - * TODO Move already_AddRefed to namespace mozilla. This has not yet been done - * because of the sheer number of usages of already_AddRefed. - */ -template<class T> -struct MOZ_MUST_USE_TYPE MOZ_NON_AUTOABLE already_AddRefed -{ - /* - * We want to allow returning nullptr from functions returning - * already_AddRefed<T>, for simplicity. But we also don't want to allow - * returning raw T*, instead preferring creation of already_AddRefed<T> from - * a reference counting smart pointer. - * - * We address the latter requirement by making the (T*) constructor explicit. - * But |return nullptr| won't consider an explicit constructor, so we need - * another constructor to handle it. Plain old (decltype(nullptr)) doesn't - * cut it, because if nullptr is emulated as __null (with type int or long), - * passing nullptr to an int/long parameter triggers compiler warnings. We - * need a type that no one can pass accidentally; a pointer-to-member-function - * (where no such function exists) does the trick nicely. - * - * That handles the return-value case. What about for locals, argument types, - * and so on? |already_AddRefed<T>(nullptr)| considers both overloads (and - * the (already_AddRefed<T>&&) overload as well!), so there's an ambiguity. - * We can target true nullptr using decltype(nullptr), but we can't target - * emulated nullptr the same way, because passing __null to an int/long - * parameter triggers compiler warnings. So just give up on this, and provide - * this behavior through the default constructor. - * - * We can revert to simply explicit (T*) and implicit (decltype(nullptr)) when - * nullptr no longer needs to be emulated to support the ancient b2g compiler. - * (The () overload could also be removed, if desired, if we changed callers.) - */ - already_AddRefed() : mRawPtr(nullptr) {} - - // The return and argument types here are arbitrarily selected so no - // corresponding member function exists. - typedef void (already_AddRefed::* MatchNullptr)(double, float); - MOZ_IMPLICIT already_AddRefed(MatchNullptr aRawPtr) : mRawPtr(nullptr) {} - - explicit already_AddRefed(T* aRawPtr) : mRawPtr(aRawPtr) {} - - // Disallow copy constructor and copy assignment operator: move semantics used instead. - already_AddRefed(const already_AddRefed<T>& aOther) = delete; - already_AddRefed<T>& operator=(const already_AddRefed<T>& aOther) = delete; - - already_AddRefed(already_AddRefed<T>&& aOther) : mRawPtr(aOther.take()) {} - - already_AddRefed<T>& operator=(already_AddRefed<T>&& aOther) - { - mRawPtr = aOther.take(); - return *this; - } - - /** - * This helper is useful in cases like - * - * already_AddRefed<BaseClass> - * Foo() - * { - * RefPtr<SubClass> x = ...; - * return x.forget(); - * } - * - * The autoconversion allows one to omit the idiom - * - * RefPtr<BaseClass> y = x.forget(); - * return y.forget(); - * - * Note that nsRefPtr is the XPCOM reference counting smart pointer class. - */ - template <typename U> - MOZ_IMPLICIT already_AddRefed(already_AddRefed<U>&& aOther) : mRawPtr(aOther.take()) {} - - ~already_AddRefed() { MOZ_ASSERT(!mRawPtr); } - - // Specialize the unused operator<< for already_AddRefed, to allow - // nsCOMPtr<nsIFoo> foo; - // Unused << foo.forget(); - // Note that nsCOMPtr is the XPCOM reference counting smart pointer class. - friend void operator<<(const mozilla::unused_t& aUnused, - const already_AddRefed<T>& aRhs) - { - auto mutableAlreadyAddRefed = const_cast<already_AddRefed<T>*>(&aRhs); - aUnused << mutableAlreadyAddRefed->take(); - } - - MOZ_MUST_USE T* take() - { - T* rawPtr = mRawPtr; - mRawPtr = nullptr; - return rawPtr; - } - - /** - * This helper provides a static_cast replacement for already_AddRefed, so - * if you have - * - * already_AddRefed<Parent> F(); - * - * you can write - * - * already_AddRefed<Child> - * G() - * { - * return F().downcast<Child>(); - * } - */ - template<class U> - already_AddRefed<U> downcast() - { - U* tmp = static_cast<U*>(mRawPtr); - mRawPtr = nullptr; - return already_AddRefed<U>(tmp); - } - -private: - T* MOZ_OWNING_REF mRawPtr; -}; - -#endif // AlreadyAddRefed_h diff --git a/android/armeabi/include/spidermonkey/mozilla/Array.h b/android/armeabi/include/spidermonkey/mozilla/Array.h deleted file mode 100644 index 72b89ede..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Array.h +++ /dev/null @@ -1,88 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A compile-time constant-length array with bounds-checking assertions. */ - -#ifndef mozilla_Array_h -#define mozilla_Array_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Move.h" -#include "mozilla/ReverseIterator.h" - -#include <stddef.h> - -namespace mozilla { - -template<typename T, size_t Length> -class Array -{ - T mArr[Length]; - -public: - Array() {} - - template <typename... Args> - MOZ_IMPLICIT Array(Args&&... aArgs) - : mArr{mozilla::Forward<Args>(aArgs)...} - { - static_assert(sizeof...(aArgs) == Length, - "The number of arguments should be equal to the template parameter Length"); - } - - T& operator[](size_t aIndex) - { - MOZ_ASSERT(aIndex < Length); - return mArr[aIndex]; - } - - const T& operator[](size_t aIndex) const - { - MOZ_ASSERT(aIndex < Length); - return mArr[aIndex]; - } - - typedef T* iterator; - typedef const T* const_iterator; - typedef ReverseIterator<T*> reverse_iterator; - typedef ReverseIterator<const T*> const_reverse_iterator; - - // Methods for range-based for loops. - iterator begin() { return mArr; } - const_iterator begin() const { return mArr; } - const_iterator cbegin() const { return begin(); } - iterator end() { return mArr + Length; } - const_iterator end() const { return mArr + Length; } - const_iterator cend() const { return end(); } - - // Methods for reverse iterating. - reverse_iterator rbegin() { return reverse_iterator(end()); } - const_reverse_iterator rbegin() const { return const_reverse_iterator(end()); } - const_reverse_iterator crbegin() const { return rbegin(); } - reverse_iterator rend() { return reverse_iterator(begin()); } - const_reverse_iterator rend() const { return const_reverse_iterator(begin()); } - const_reverse_iterator crend() const { return rend(); } -}; - -template<typename T> -class Array<T, 0> -{ -public: - T& operator[](size_t aIndex) - { - MOZ_CRASH("indexing into zero-length array"); - } - - const T& operator[](size_t aIndex) const - { - MOZ_CRASH("indexing into zero-length array"); - } -}; - -} /* namespace mozilla */ - -#endif /* mozilla_Array_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/ArrayUtils.h b/android/armeabi/include/spidermonkey/mozilla/ArrayUtils.h deleted file mode 100644 index 50236ccb..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/ArrayUtils.h +++ /dev/null @@ -1,194 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Implements various helper functions related to arrays. - */ - -#ifndef mozilla_ArrayUtils_h -#define mozilla_ArrayUtils_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" - -#include <stddef.h> - -#ifdef __cplusplus - -#include "mozilla/Alignment.h" -#include "mozilla/Array.h" -#include "mozilla/EnumeratedArray.h" -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -/* - * Safely subtract two pointers when it is known that aEnd >= aBegin, yielding a - * size_t result. - * - * Ordinary pointer subtraction yields a ptrdiff_t result, which, being signed, - * has insufficient range to express the distance between pointers at opposite - * ends of the address space. Furthermore, most compilers use ptrdiff_t to - * represent the intermediate byte address distance, before dividing by - * sizeof(T); if that intermediate result overflows, they'll produce results - * with the wrong sign even when the correct scaled distance would fit in a - * ptrdiff_t. - */ -template<class T> -MOZ_ALWAYS_INLINE size_t -PointerRangeSize(T* aBegin, T* aEnd) -{ - MOZ_ASSERT(aEnd >= aBegin); - return (size_t(aEnd) - size_t(aBegin)) / sizeof(T); -} - -/* - * Compute the length of an array with constant length. (Use of this method - * with a non-array pointer will not compile.) - * - * Beware of the implicit trailing '\0' when using this with string constants. - */ -template<typename T, size_t N> -constexpr size_t -ArrayLength(T (&aArr)[N]) -{ - return N; -} - -template<typename T, size_t N> -constexpr size_t -ArrayLength(const Array<T, N>& aArr) -{ - return N; -} - -template<typename E, E N, typename T> -constexpr size_t -ArrayLength(const EnumeratedArray<E, N, T>& aArr) -{ - return size_t(N); -} - -/* - * Compute the address one past the last element of a constant-length array. - * - * Beware of the implicit trailing '\0' when using this with string constants. - */ -template<typename T, size_t N> -constexpr T* -ArrayEnd(T (&aArr)[N]) -{ - return aArr + ArrayLength(aArr); -} - -template<typename T, size_t N> -constexpr T* -ArrayEnd(Array<T, N>& aArr) -{ - return &aArr[0] + ArrayLength(aArr); -} - -template<typename T, size_t N> -constexpr const T* -ArrayEnd(const Array<T, N>& aArr) -{ - return &aArr[0] + ArrayLength(aArr); -} - -namespace detail { - -template<typename AlignType, typename Pointee, - typename = EnableIf<!IsVoid<AlignType>::value>> -struct AlignedChecker -{ - static void - test(const Pointee* aPtr) - { - MOZ_ASSERT((uintptr_t(aPtr) % MOZ_ALIGNOF(AlignType)) == 0, - "performing a range-check with a misaligned pointer"); - } -}; - -template<typename AlignType, typename Pointee> -struct AlignedChecker<AlignType, Pointee> -{ - static void - test(const Pointee* aPtr) - { - } -}; - -} // namespace detail - -/** - * Determines whether |aPtr| points at an object in the range [aBegin, aEnd). - * - * |aPtr| must have the same alignment as |aBegin| and |aEnd|. This usually - * should be achieved by ensuring |aPtr| points at a |U|, not just that it - * points at a |T|. - * - * It is a usage error for any argument to be misaligned. - * - * It's okay for T* to be void*, and if so U* may also be void*. In the latter - * case no argument is required to be aligned (obviously, as void* implies no - * particular alignment). - */ -template<typename T, typename U> -inline typename EnableIf<IsSame<T, U>::value || - IsBaseOf<T, U>::value || - IsVoid<T>::value, - bool>::Type -IsInRange(const T* aPtr, const U* aBegin, const U* aEnd) -{ - MOZ_ASSERT(aBegin <= aEnd); - detail::AlignedChecker<U, T>::test(aPtr); - detail::AlignedChecker<U, U>::test(aBegin); - detail::AlignedChecker<U, U>::test(aEnd); - return aBegin <= reinterpret_cast<const U*>(aPtr) && - reinterpret_cast<const U*>(aPtr) < aEnd; -} - -/** - * Convenience version of the above method when the valid range is specified as - * uintptr_t values. As above, |aPtr| must be aligned, and |aBegin| and |aEnd| - * must be aligned with respect to |T|. - */ -template<typename T> -inline bool -IsInRange(const T* aPtr, uintptr_t aBegin, uintptr_t aEnd) -{ - return IsInRange(aPtr, - reinterpret_cast<const T*>(aBegin), - reinterpret_cast<const T*>(aEnd)); -} - -namespace detail { - -/* - * Helper for the MOZ_ARRAY_LENGTH() macro to make the length a typesafe - * compile-time constant even on compilers lacking constexpr support. - */ -template <typename T, size_t N> -char (&ArrayLengthHelper(T (&array)[N]))[N]; - -} /* namespace detail */ - -} /* namespace mozilla */ - -#endif /* __cplusplus */ - -/* - * MOZ_ARRAY_LENGTH() is an alternative to mozilla::ArrayLength() for C files - * that can't use C++ template functions and for static_assert() calls that - * can't call ArrayLength() when it is not a C++11 constexpr function. - */ -#ifdef __cplusplus -# define MOZ_ARRAY_LENGTH(array) sizeof(mozilla::detail::ArrayLengthHelper(array)) -#else -# define MOZ_ARRAY_LENGTH(array) (sizeof(array)/sizeof((array)[0])) -#endif - -#endif /* mozilla_ArrayUtils_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Assertions.h b/android/armeabi/include/spidermonkey/mozilla/Assertions.h deleted file mode 100644 index e978af3d..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Assertions.h +++ /dev/null @@ -1,585 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Implementations of runtime and static assertion macros for C and C++. */ - -#ifndef mozilla_Assertions_h -#define mozilla_Assertions_h - -#if defined(MOZILLA_INTERNAL_API) && defined(__cplusplus) -#define MOZ_DUMP_ASSERTION_STACK -#endif - -#include "mozilla/Attributes.h" -#include "mozilla/Compiler.h" -#include "mozilla/Likely.h" -#include "mozilla/MacroArgs.h" -#include "mozilla/StaticAnalysisFunctions.h" -#include "mozilla/Types.h" -#ifdef MOZ_DUMP_ASSERTION_STACK -#include "nsTraceRefcnt.h" -#endif - -#if defined(MOZ_HAS_MOZGLUE) || defined(MOZILLA_INTERNAL_API) -/* - * The crash reason set by MOZ_CRASH_ANNOTATE is consumed by the crash reporter - * if present. It is declared here (and defined in Assertions.cpp) to make it - * available to all code, even libraries that don't link with the crash reporter - * directly. - */ -MOZ_BEGIN_EXTERN_C -extern MFBT_DATA const char* gMozCrashReason; -MOZ_END_EXTERN_C - -static inline void -AnnotateMozCrashReason(const char* reason) -{ - gMozCrashReason = reason; -} -# define MOZ_CRASH_ANNOTATE(...) AnnotateMozCrashReason(__VA_ARGS__) -#else -# define MOZ_CRASH_ANNOTATE(...) do { /* nothing */ } while (0) -#endif - -#include <stddef.h> -#include <stdio.h> -#include <stdlib.h> -#ifdef WIN32 - /* - * TerminateProcess and GetCurrentProcess are defined in <winbase.h>, which - * further depends on <windef.h>. We hardcode these few definitions manually - * because those headers clutter the global namespace with a significant - * number of undesired macros and symbols. - */ -# ifdef __cplusplus -extern "C" { -# endif -__declspec(dllimport) int __stdcall -TerminateProcess(void* hProcess, unsigned int uExitCode); -__declspec(dllimport) void* __stdcall GetCurrentProcess(void); -# ifdef __cplusplus -} -# endif -#else -# include <signal.h> -#endif -#ifdef ANDROID -# include <android/log.h> -#endif - -/* - * MOZ_STATIC_ASSERT may be used to assert a condition *at compile time* in C. - * In C++11, static_assert is provided by the compiler to the same effect. - * This can be useful when you make certain assumptions about what must hold for - * optimal, or even correct, behavior. For example, you might assert that the - * size of a struct is a multiple of the target architecture's word size: - * - * struct S { ... }; - * // C - * MOZ_STATIC_ASSERT(sizeof(S) % sizeof(size_t) == 0, - * "S should be a multiple of word size for efficiency"); - * // C++11 - * static_assert(sizeof(S) % sizeof(size_t) == 0, - * "S should be a multiple of word size for efficiency"); - * - * This macro can be used in any location where both an extern declaration and a - * typedef could be used. - */ -#ifndef __cplusplus - /* - * Some of the definitions below create an otherwise-unused typedef. This - * triggers compiler warnings with some versions of gcc, so mark the typedefs - * as permissibly-unused to disable the warnings. - */ -# if defined(__GNUC__) -# define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE __attribute__((unused)) -# else -# define MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE /* nothing */ -# endif -# define MOZ_STATIC_ASSERT_GLUE1(x, y) x##y -# define MOZ_STATIC_ASSERT_GLUE(x, y) MOZ_STATIC_ASSERT_GLUE1(x, y) -# if defined(__SUNPRO_CC) - /* - * The Sun Studio C++ compiler is buggy when declaring, inside a function, - * another extern'd function with an array argument whose length contains a - * sizeof, triggering the error message "sizeof expression not accepted as - * size of array parameter". This bug (6688515, not public yet) would hit - * defining moz_static_assert as a function, so we always define an extern - * array for Sun Studio. - * - * We include the line number in the symbol name in a best-effort attempt - * to avoid conflicts (see below). - */ -# define MOZ_STATIC_ASSERT(cond, reason) \ - extern char MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)[(cond) ? 1 : -1] -# elif defined(__COUNTER__) - /* - * If there was no preferred alternative, use a compiler-agnostic version. - * - * Note that the non-__COUNTER__ version has a bug in C++: it can't be used - * in both |extern "C"| and normal C++ in the same translation unit. (Alas - * |extern "C"| isn't allowed in a function.) The only affected compiler - * we really care about is gcc 4.2. For that compiler and others like it, - * we include the line number in the function name to do the best we can to - * avoid conflicts. These should be rare: a conflict would require use of - * MOZ_STATIC_ASSERT on the same line in separate files in the same - * translation unit, *and* the uses would have to be in code with - * different linkage, *and* the first observed use must be in C++-linkage - * code. - */ -# define MOZ_STATIC_ASSERT(cond, reason) \ - typedef int MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __COUNTER__)[(cond) ? 1 : -1] MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE -# else -# define MOZ_STATIC_ASSERT(cond, reason) \ - extern void MOZ_STATIC_ASSERT_GLUE(moz_static_assert, __LINE__)(int arg[(cond) ? 1 : -1]) MOZ_STATIC_ASSERT_UNUSED_ATTRIBUTE -# endif - -#define MOZ_STATIC_ASSERT_IF(cond, expr, reason) MOZ_STATIC_ASSERT(!(cond) || (expr), reason) -#else -#define MOZ_STATIC_ASSERT_IF(cond, expr, reason) static_assert(!(cond) || (expr), reason) -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * Prints |aStr| as an assertion failure (using aFilename and aLine as the - * location of the assertion) to the standard debug-output channel. - * - * Usually you should use MOZ_ASSERT or MOZ_CRASH instead of this method. This - * method is primarily for internal use in this header, and only secondarily - * for use in implementing release-build assertions. - */ -static MOZ_COLD MOZ_ALWAYS_INLINE void -MOZ_ReportAssertionFailure(const char* aStr, const char* aFilename, int aLine) - MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS -{ -#ifdef ANDROID - __android_log_print(ANDROID_LOG_FATAL, "MOZ_Assert", - "Assertion failure: %s, at %s:%d\n", - aStr, aFilename, aLine); -#else - fprintf(stderr, "Assertion failure: %s, at %s:%d\n", aStr, aFilename, aLine); -#if defined (MOZ_DUMP_ASSERTION_STACK) - nsTraceRefcnt::WalkTheStack(stderr); -#endif - fflush(stderr); -#endif -} - -static MOZ_COLD MOZ_ALWAYS_INLINE void -MOZ_ReportCrash(const char* aStr, const char* aFilename, int aLine) - MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS -{ -#ifdef ANDROID - __android_log_print(ANDROID_LOG_FATAL, "MOZ_CRASH", - "Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine); -#else - fprintf(stderr, "Hit MOZ_CRASH(%s) at %s:%d\n", aStr, aFilename, aLine); -#if defined(MOZ_DUMP_ASSERTION_STACK) - nsTraceRefcnt::WalkTheStack(stderr); -#endif - fflush(stderr); -#endif -} - -/** - * MOZ_REALLY_CRASH is used in the implementation of MOZ_CRASH(). You should - * call MOZ_CRASH instead. - */ -#if defined(_MSC_VER) - /* - * On MSVC use the __debugbreak compiler intrinsic, which produces an inline - * (not nested in a system function) breakpoint. This distinctively invokes - * Breakpad without requiring system library symbols on all stack-processing - * machines, as a nested breakpoint would require. - * - * We use TerminateProcess with the exit code aborting would generate - * because we don't want to invoke atexit handlers, destructors, library - * unload handlers, and so on when our process might be in a compromised - * state. - * - * We don't use abort() because it'd cause Windows to annoyingly pop up the - * process error dialog multiple times. See bug 345118 and bug 426163. - * - * We follow TerminateProcess() with a call to MOZ_NoReturn() so that the - * compiler doesn't hassle us to provide a return statement after a - * MOZ_REALLY_CRASH() call. - * - * (Technically these are Windows requirements, not MSVC requirements. But - * practically you need MSVC for debugging, and we only ship builds created - * by MSVC, so doing it this way reduces complexity.) - */ - -__declspec(noreturn) __inline void MOZ_NoReturn() {} - -# ifdef __cplusplus -# define MOZ_REALLY_CRASH() \ - do { \ - ::__debugbreak(); \ - *((volatile int*) NULL) = __LINE__; \ - ::TerminateProcess(::GetCurrentProcess(), 3); \ - ::MOZ_NoReturn(); \ - } while (0) -# else -# define MOZ_REALLY_CRASH() \ - do { \ - __debugbreak(); \ - *((volatile int*) NULL) = __LINE__; \ - TerminateProcess(GetCurrentProcess(), 3); \ - MOZ_NoReturn(); \ - } while (0) -# endif -#else -# ifdef __cplusplus -# define MOZ_REALLY_CRASH() \ - do { \ - *((volatile int*) NULL) = __LINE__; \ - ::abort(); \ - } while (0) -# else -# define MOZ_REALLY_CRASH() \ - do { \ - *((volatile int*) NULL) = __LINE__; \ - abort(); \ - } while (0) -# endif -#endif - -/* - * MOZ_CRASH([explanation-string]) crashes the program, plain and simple, in a - * Breakpad-compatible way, in both debug and release builds. - * - * MOZ_CRASH is a good solution for "handling" failure cases when you're - * unwilling or unable to handle them more cleanly -- for OOM, for likely memory - * corruption, and so on. It's also a good solution if you need safe behavior - * in release builds as well as debug builds. But if the failure is one that - * should be debugged and fixed, MOZ_ASSERT is generally preferable. - * - * The optional explanation-string, if provided, must be a string literal - * explaining why we're crashing. This argument is intended for use with - * MOZ_CRASH() calls whose rationale is non-obvious; don't use it if it's - * obvious why we're crashing. - * - * If we're a DEBUG build and we crash at a MOZ_CRASH which provides an - * explanation-string, we print the string to stderr. Otherwise, we don't - * print anything; this is because we want MOZ_CRASH to be 100% safe in release - * builds, and it's hard to print to stderr safely when memory might have been - * corrupted. - */ -#ifndef DEBUG -# define MOZ_CRASH(...) \ - do { \ - MOZ_CRASH_ANNOTATE("MOZ_CRASH(" __VA_ARGS__ ")"); \ - MOZ_REALLY_CRASH(); \ - } while (0) -#else -# define MOZ_CRASH(...) \ - do { \ - MOZ_ReportCrash("" __VA_ARGS__, __FILE__, __LINE__); \ - MOZ_CRASH_ANNOTATE("MOZ_CRASH(" __VA_ARGS__ ")"); \ - MOZ_REALLY_CRASH(); \ - } while (0) -#endif - -#ifdef __cplusplus -} /* extern "C" */ -#endif - -/* - * MOZ_ASSERT(expr [, explanation-string]) asserts that |expr| must be truthy in - * debug builds. If it is, execution continues. Otherwise, an error message - * including the expression and the explanation-string (if provided) is printed, - * an attempt is made to invoke any existing debugger, and execution halts. - * MOZ_ASSERT is fatal: no recovery is possible. Do not assert a condition - * which can correctly be falsy. - * - * The optional explanation-string, if provided, must be a string literal - * explaining the assertion. It is intended for use with assertions whose - * correctness or rationale is non-obvious, and for assertions where the "real" - * condition being tested is best described prosaically. Don't provide an - * explanation if it's not actually helpful. - * - * // No explanation needed: pointer arguments often must not be NULL. - * MOZ_ASSERT(arg); - * - * // An explanation can be helpful to explain exactly how we know an - * // assertion is valid. - * MOZ_ASSERT(state == WAITING_FOR_RESPONSE, - * "given that <thingA> and <thingB>, we must have..."); - * - * // Or it might disambiguate multiple identical (save for their location) - * // assertions of the same expression. - * MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(), - * "we already set [[PrimitiveThis]] for this Boolean object"); - * MOZ_ASSERT(getSlot(PRIMITIVE_THIS_SLOT).isUndefined(), - * "we already set [[PrimitiveThis]] for this String object"); - * - * MOZ_ASSERT has no effect in non-debug builds. It is designed to catch bugs - * *only* during debugging, not "in the field". If you want the latter, use - * MOZ_RELEASE_ASSERT, which applies to non-debug builds as well. - * - * MOZ_DIAGNOSTIC_ASSERT works like MOZ_RELEASE_ASSERT in Nightly/Aurora and - * MOZ_ASSERT in Beta/Release - use this when a condition is potentially rare - * enough to require real user testing to hit, but is not security-sensitive. - * This can cause user pain, so use it sparingly. If a MOZ_DIAGNOSTIC_ASSERT - * is firing, it should promptly be converted to a MOZ_ASSERT while the failure - * is being investigated, rather than letting users suffer. - */ - -/* - * Implement MOZ_VALIDATE_ASSERT_CONDITION_TYPE, which is used to guard against - * accidentally passing something unintended in lieu of an assertion condition. - */ - -#ifdef __cplusplus -# include "mozilla/TypeTraits.h" -namespace mozilla { -namespace detail { - -template<typename T> -struct AssertionConditionType -{ - typedef typename RemoveReference<T>::Type ValueT; - static_assert(!IsArray<ValueT>::value, - "Expected boolean assertion condition, got an array or a " - "string!"); - static_assert(!IsFunction<ValueT>::value, - "Expected boolean assertion condition, got a function! Did " - "you intend to call that function?"); - static_assert(!IsFloatingPoint<ValueT>::value, - "It's often a bad idea to assert that a floating-point number " - "is nonzero, because such assertions tend to intermittently " - "fail. Shouldn't your code gracefully handle this case instead " - "of asserting? Anyway, if you really want to do that, write an " - "explicit boolean condition, like !!x or x!=0."); - - static const bool isValid = true; -}; - -} // namespace detail -} // namespace mozilla -# define MOZ_VALIDATE_ASSERT_CONDITION_TYPE(x) \ - static_assert(mozilla::detail::AssertionConditionType<decltype(x)>::isValid, \ - "invalid assertion condition") -#else -# define MOZ_VALIDATE_ASSERT_CONDITION_TYPE(x) -#endif - -/* First the single-argument form. */ -#define MOZ_ASSERT_HELPER1(expr) \ - do { \ - MOZ_VALIDATE_ASSERT_CONDITION_TYPE(expr); \ - if (MOZ_UNLIKELY(!MOZ_CHECK_ASSERT_ASSIGNMENT(expr))) { \ - MOZ_ReportAssertionFailure(#expr, __FILE__, __LINE__); \ - MOZ_CRASH_ANNOTATE("MOZ_RELEASE_ASSERT(" #expr ")"); \ - MOZ_REALLY_CRASH(); \ - } \ - } while (0) -/* Now the two-argument form. */ -#define MOZ_ASSERT_HELPER2(expr, explain) \ - do { \ - MOZ_VALIDATE_ASSERT_CONDITION_TYPE(expr); \ - if (MOZ_UNLIKELY(!MOZ_CHECK_ASSERT_ASSIGNMENT(expr))) { \ - MOZ_ReportAssertionFailure(#expr " (" explain ")", __FILE__, __LINE__); \ - MOZ_CRASH_ANNOTATE("MOZ_RELEASE_ASSERT(" #expr ") (" explain ")"); \ - MOZ_REALLY_CRASH(); \ - } \ - } while (0) - -#define MOZ_RELEASE_ASSERT_GLUE(a, b) a b -#define MOZ_RELEASE_ASSERT(...) \ - MOZ_RELEASE_ASSERT_GLUE( \ - MOZ_PASTE_PREFIX_AND_ARG_COUNT(MOZ_ASSERT_HELPER, __VA_ARGS__), \ - (__VA_ARGS__)) - -#ifdef DEBUG -# define MOZ_ASSERT(...) MOZ_RELEASE_ASSERT(__VA_ARGS__) -#else -# define MOZ_ASSERT(...) do { } while (0) -#endif /* DEBUG */ - -#ifdef RELEASE_OR_BETA -# define MOZ_DIAGNOSTIC_ASSERT MOZ_ASSERT -#else -# define MOZ_DIAGNOSTIC_ASSERT MOZ_RELEASE_ASSERT -#endif - -/* - * MOZ_ASSERT_IF(cond1, cond2) is equivalent to MOZ_ASSERT(cond2) if cond1 is - * true. - * - * MOZ_ASSERT_IF(isPrime(num), num == 2 || isOdd(num)); - * - * As with MOZ_ASSERT, MOZ_ASSERT_IF has effect only in debug builds. It is - * designed to catch bugs during debugging, not "in the field". - */ -#ifdef DEBUG -# define MOZ_ASSERT_IF(cond, expr) \ - do { \ - if (cond) { \ - MOZ_ASSERT(expr); \ - } \ - } while (0) -#else -# define MOZ_ASSERT_IF(cond, expr) do { } while (0) -#endif - -/* - * MOZ_ASSUME_UNREACHABLE_MARKER() expands to an expression which states that - * it is undefined behavior for execution to reach this point. No guarantees - * are made about what will happen if this is reached at runtime. Most code - * should use MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE because it has extra - * asserts. - */ -#if defined(__clang__) || defined(__GNUC__) -# define MOZ_ASSUME_UNREACHABLE_MARKER() __builtin_unreachable() -#elif defined(_MSC_VER) -# define MOZ_ASSUME_UNREACHABLE_MARKER() __assume(0) -#else -# ifdef __cplusplus -# define MOZ_ASSUME_UNREACHABLE_MARKER() ::abort() -# else -# define MOZ_ASSUME_UNREACHABLE_MARKER() abort() -# endif -#endif - -/* - * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE([reason]) tells the compiler that it - * can assume that the macro call cannot be reached during execution. This lets - * the compiler generate better-optimized code under some circumstances, at the - * expense of the program's behavior being undefined if control reaches the - * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE. - * - * In Gecko, you probably should not use this macro outside of performance- or - * size-critical code, because it's unsafe. If you don't care about code size - * or performance, you should probably use MOZ_ASSERT or MOZ_CRASH. - * - * SpiderMonkey is a different beast, and there it's acceptable to use - * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE more widely. - * - * Note that MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE is noreturn, so it's valid - * not to return a value following a MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE - * call. - * - * Example usage: - * - * enum ValueType { - * VALUE_STRING, - * VALUE_INT, - * VALUE_FLOAT - * }; - * - * int ptrToInt(ValueType type, void* value) { - * { - * // We know for sure that type is either INT or FLOAT, and we want this - * // code to run as quickly as possible. - * switch (type) { - * case VALUE_INT: - * return *(int*) value; - * case VALUE_FLOAT: - * return (int) *(float*) value; - * default: - * MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Unexpected ValueType"); - * } - * } - */ - -/* - * Unconditional assert in debug builds for (assumed) unreachable code paths - * that have a safe return without crashing in release builds. - */ -#define MOZ_ASSERT_UNREACHABLE(reason) \ - MOZ_ASSERT(false, "MOZ_ASSERT_UNREACHABLE: " reason) - -#define MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE(reason) \ - do { \ - MOZ_ASSERT_UNREACHABLE(reason); \ - MOZ_ASSUME_UNREACHABLE_MARKER(); \ - } while (0) - -/** - * MOZ_FALLTHROUGH_ASSERT is an annotation to suppress compiler warnings about - * switch cases that MOZ_ASSERT(false) (or its alias MOZ_ASSERT_UNREACHABLE) in - * debug builds, but intentionally fall through in release builds to handle - * unexpected values. - * - * Why do we need MOZ_FALLTHROUGH_ASSERT in addition to MOZ_FALLTHROUGH? In - * release builds, the MOZ_ASSERT(false) will expand to `do { } while (0)`, - * requiring a MOZ_FALLTHROUGH annotation to suppress a -Wimplicit-fallthrough - * warning. In debug builds, the MOZ_ASSERT(false) will expand to something like - * `if (true) { MOZ_CRASH(); }` and the MOZ_FALLTHROUGH annotation will cause - * a -Wunreachable-code warning. The MOZ_FALLTHROUGH_ASSERT macro breaks this - * warning stalemate. - * - * // Example before MOZ_FALLTHROUGH_ASSERT: - * switch (foo) { - * default: - * // This case wants to assert in debug builds, fall through in release. - * MOZ_ASSERT(false); // -Wimplicit-fallthrough warning in release builds! - * MOZ_FALLTHROUGH; // but -Wunreachable-code warning in debug builds! - * case 5: - * return 5; - * } - * - * // Example with MOZ_FALLTHROUGH_ASSERT: - * switch (foo) { - * default: - * // This case asserts in debug builds, falls through in release. - * MOZ_FALLTHROUGH_ASSERT("Unexpected foo value?!"); - * case 5: - * return 5; - * } - */ -#ifdef DEBUG -# define MOZ_FALLTHROUGH_ASSERT(reason) MOZ_CRASH("MOZ_FALLTHROUGH_ASSERT: " reason) -#else -# define MOZ_FALLTHROUGH_ASSERT(...) MOZ_FALLTHROUGH -#endif - -/* - * MOZ_ALWAYS_TRUE(expr) and MOZ_ALWAYS_FALSE(expr) always evaluate the provided - * expression, in debug builds and in release builds both. Then, in debug - * builds only, the value of the expression is asserted either true or false - * using MOZ_ASSERT. - */ -#ifdef DEBUG -# define MOZ_ALWAYS_TRUE(expr) \ - do { \ - if ((expr)) { \ - /* Do nothing. */ \ - } else { \ - MOZ_ASSERT(false, #expr); \ - } \ - } while (0) -# define MOZ_ALWAYS_FALSE(expr) \ - do { \ - if ((expr)) { \ - MOZ_ASSERT(false, #expr); \ - } else { \ - /* Do nothing. */ \ - } \ - } while (0) -#else -# define MOZ_ALWAYS_TRUE(expr) \ - do { \ - if ((expr)) { \ - /* Silence MOZ_MUST_USE. */ \ - } \ - } while (0) -# define MOZ_ALWAYS_FALSE(expr) \ - do { \ - if ((expr)) { \ - /* Silence MOZ_MUST_USE. */ \ - } \ - } while (0) -#endif - -#undef MOZ_DUMP_ASSERTION_STACK -#undef MOZ_CRASH_CRASHREPORT - -#endif /* mozilla_Assertions_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Atomics.h b/android/armeabi/include/spidermonkey/mozilla/Atomics.h deleted file mode 100644 index 213d1b9f..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Atomics.h +++ /dev/null @@ -1,800 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Implements (almost always) lock-free atomic operations. The operations here - * are a subset of that which can be found in C++11's <atomic> header, with a - * different API to enforce consistent memory ordering constraints. - * - * Anyone caught using |volatile| for inter-thread memory safety needs to be - * sent a copy of this header and the C++11 standard. - */ - -#ifndef mozilla_Atomics_h -#define mozilla_Atomics_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Compiler.h" -#include "mozilla/TypeTraits.h" - -#include <stdint.h> - -/* - * Our minimum deployment target on clang/OS X is OS X 10.6, whose SDK - * does not have <atomic>. So be sure to check for <atomic> support - * along with C++0x support. - */ -#if defined(_MSC_VER) -# define MOZ_HAVE_CXX11_ATOMICS -#elif defined(__clang__) || defined(__GNUC__) - /* - * Clang doesn't like <atomic> from libstdc++ before 4.7 due to the - * loose typing of the atomic builtins. GCC 4.5 and 4.6 lacks inline - * definitions for unspecialized std::atomic and causes linking errors. - * Therefore, we require at least 4.7.0 for using libstdc++. - * - * libc++ <atomic> is only functional with clang. - */ -# if MOZ_USING_LIBSTDCXX && MOZ_LIBSTDCXX_VERSION_AT_LEAST(4, 7, 0) -# define MOZ_HAVE_CXX11_ATOMICS -# elif MOZ_USING_LIBCXX && defined(__clang__) -# define MOZ_HAVE_CXX11_ATOMICS -# endif -#endif - -namespace mozilla { - -/** - * An enum of memory ordering possibilities for atomics. - * - * Memory ordering is the observable state of distinct values in memory. - * (It's a separate concept from atomicity, which concerns whether an - * operation can ever be observed in an intermediate state. Don't - * conflate the two!) Given a sequence of operations in source code on - * memory, it is *not* always the case that, at all times and on all - * cores, those operations will appear to have occurred in that exact - * sequence. First, the compiler might reorder that sequence, if it - * thinks another ordering will be more efficient. Second, the CPU may - * not expose so consistent a view of memory. CPUs will often perform - * their own instruction reordering, above and beyond that performed by - * the compiler. And each core has its own memory caches, and accesses - * (reads and writes both) to "memory" may only resolve to out-of-date - * cache entries -- not to the "most recently" performed operation in - * some global sense. Any access to a value that may be used by - * multiple threads, potentially across multiple cores, must therefore - * have a memory ordering imposed on it, for all code on all - * threads/cores to have a sufficiently coherent worldview. - * - * http://gcc.gnu.org/wiki/Atomic/GCCMM/AtomicSync and - * http://en.cppreference.com/w/cpp/atomic/memory_order go into more - * detail on all this, including examples of how each mode works. - * - * Note that for simplicity and practicality, not all of the modes in - * C++11 are supported. The missing C++11 modes are either subsumed by - * the modes we provide below, or not relevant for the CPUs we support - * in Gecko. These three modes are confusing enough as it is! - */ -enum MemoryOrdering { - /* - * Relaxed ordering is the simplest memory ordering: none at all. - * When the result of a write is observed, nothing may be inferred - * about other memory. Writes ostensibly performed "before" on the - * writing thread may not yet be visible. Writes performed "after" on - * the writing thread may already be visible, if the compiler or CPU - * reordered them. (The latter can happen if reads and/or writes get - * held up in per-processor caches.) Relaxed ordering means - * operations can always use cached values (as long as the actual - * updates to atomic values actually occur, correctly, eventually), so - * it's usually the fastest sort of atomic access. For this reason, - * *it's also the most dangerous kind of access*. - * - * Relaxed ordering is good for things like process-wide statistics - * counters that don't need to be consistent with anything else, so - * long as updates themselves are atomic. (And so long as any - * observations of that value can tolerate being out-of-date -- if you - * need some sort of up-to-date value, you need some sort of other - * synchronizing operation.) It's *not* good for locks, mutexes, - * reference counts, etc. that mediate access to other memory, or must - * be observably consistent with other memory. - * - * x86 architectures don't take advantage of the optimization - * opportunities that relaxed ordering permits. Thus it's possible - * that using relaxed ordering will "work" on x86 but fail elsewhere - * (ARM, say, which *does* implement non-sequentially-consistent - * relaxed ordering semantics). Be extra-careful using relaxed - * ordering if you can't easily test non-x86 architectures! - */ - Relaxed, - - /* - * When an atomic value is updated with ReleaseAcquire ordering, and - * that new value is observed with ReleaseAcquire ordering, prior - * writes (atomic or not) are also observable. What ReleaseAcquire - * *doesn't* give you is any observable ordering guarantees for - * ReleaseAcquire-ordered operations on different objects. For - * example, if there are two cores that each perform ReleaseAcquire - * operations on separate objects, each core may or may not observe - * the operations made by the other core. The only way the cores can - * be synchronized with ReleaseAcquire is if they both - * ReleaseAcquire-access the same object. This implies that you can't - * necessarily describe some global total ordering of ReleaseAcquire - * operations. - * - * ReleaseAcquire ordering is good for (as the name implies) atomic - * operations on values controlling ownership of things: reference - * counts, mutexes, and the like. However, if you are thinking about - * using these to implement your own locks or mutexes, you should take - * a good, hard look at actual lock or mutex primitives first. - */ - ReleaseAcquire, - - /* - * When an atomic value is updated with SequentiallyConsistent - * ordering, all writes observable when the update is observed, just - * as with ReleaseAcquire ordering. But, furthermore, a global total - * ordering of SequentiallyConsistent operations *can* be described. - * For example, if two cores perform SequentiallyConsistent operations - * on separate objects, one core will observably perform its update - * (and all previous operations will have completed), then the other - * core will observably perform its update (and all previous - * operations will have completed). (Although those previous - * operations aren't themselves ordered -- they could be intermixed, - * or ordered if they occur on atomic values with ordering - * requirements.) SequentiallyConsistent is the *simplest and safest* - * ordering of atomic operations -- it's always as if one operation - * happens, then another, then another, in some order -- and every - * core observes updates to happen in that single order. Because it - * has the most synchronization requirements, operations ordered this - * way also tend to be slowest. - * - * SequentiallyConsistent ordering can be desirable when multiple - * threads observe objects, and they all have to agree on the - * observable order of changes to them. People expect - * SequentiallyConsistent ordering, even if they shouldn't, when - * writing code, atomic or otherwise. SequentiallyConsistent is also - * the ordering of choice when designing lockless data structures. If - * you don't know what order to use, use this one. - */ - SequentiallyConsistent, -}; - -} // namespace mozilla - -// Build up the underlying intrinsics. -#ifdef MOZ_HAVE_CXX11_ATOMICS - -# include <atomic> - -namespace mozilla { -namespace detail { - -/* - * We provide CompareExchangeFailureOrder to work around a bug in some - * versions of GCC's <atomic> header. See bug 898491. - */ -template<MemoryOrdering Order> struct AtomicOrderConstraints; - -template<> -struct AtomicOrderConstraints<Relaxed> -{ - static const std::memory_order AtomicRMWOrder = std::memory_order_relaxed; - static const std::memory_order LoadOrder = std::memory_order_relaxed; - static const std::memory_order StoreOrder = std::memory_order_relaxed; - static const std::memory_order CompareExchangeFailureOrder = - std::memory_order_relaxed; -}; - -template<> -struct AtomicOrderConstraints<ReleaseAcquire> -{ - static const std::memory_order AtomicRMWOrder = std::memory_order_acq_rel; - static const std::memory_order LoadOrder = std::memory_order_acquire; - static const std::memory_order StoreOrder = std::memory_order_release; - static const std::memory_order CompareExchangeFailureOrder = - std::memory_order_acquire; -}; - -template<> -struct AtomicOrderConstraints<SequentiallyConsistent> -{ - static const std::memory_order AtomicRMWOrder = std::memory_order_seq_cst; - static const std::memory_order LoadOrder = std::memory_order_seq_cst; - static const std::memory_order StoreOrder = std::memory_order_seq_cst; - static const std::memory_order CompareExchangeFailureOrder = - std::memory_order_seq_cst; -}; - -template<typename T, MemoryOrdering Order> -struct IntrinsicBase -{ - typedef std::atomic<T> ValueType; - typedef AtomicOrderConstraints<Order> OrderedOp; -}; - -template<typename T, MemoryOrdering Order> -struct IntrinsicMemoryOps : public IntrinsicBase<T, Order> -{ - typedef IntrinsicBase<T, Order> Base; - - static T load(const typename Base::ValueType& aPtr) - { - return aPtr.load(Base::OrderedOp::LoadOrder); - } - - static void store(typename Base::ValueType& aPtr, T aVal) - { - aPtr.store(aVal, Base::OrderedOp::StoreOrder); - } - - static T exchange(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.exchange(aVal, Base::OrderedOp::AtomicRMWOrder); - } - - static bool compareExchange(typename Base::ValueType& aPtr, - T aOldVal, T aNewVal) - { - return aPtr.compare_exchange_strong(aOldVal, aNewVal, - Base::OrderedOp::AtomicRMWOrder, - Base::OrderedOp::CompareExchangeFailureOrder); - } -}; - -template<typename T, MemoryOrdering Order> -struct IntrinsicAddSub : public IntrinsicBase<T, Order> -{ - typedef IntrinsicBase<T, Order> Base; - - static T add(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.fetch_add(aVal, Base::OrderedOp::AtomicRMWOrder); - } - - static T sub(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.fetch_sub(aVal, Base::OrderedOp::AtomicRMWOrder); - } -}; - -template<typename T, MemoryOrdering Order> -struct IntrinsicAddSub<T*, Order> : public IntrinsicBase<T*, Order> -{ - typedef IntrinsicBase<T*, Order> Base; - - static T* add(typename Base::ValueType& aPtr, ptrdiff_t aVal) - { - return aPtr.fetch_add(aVal, Base::OrderedOp::AtomicRMWOrder); - } - - static T* sub(typename Base::ValueType& aPtr, ptrdiff_t aVal) - { - return aPtr.fetch_sub(aVal, Base::OrderedOp::AtomicRMWOrder); - } -}; - -template<typename T, MemoryOrdering Order> -struct IntrinsicIncDec : public IntrinsicAddSub<T, Order> -{ - typedef IntrinsicBase<T, Order> Base; - - static T inc(typename Base::ValueType& aPtr) - { - return IntrinsicAddSub<T, Order>::add(aPtr, 1); - } - - static T dec(typename Base::ValueType& aPtr) - { - return IntrinsicAddSub<T, Order>::sub(aPtr, 1); - } -}; - -template<typename T, MemoryOrdering Order> -struct AtomicIntrinsics : public IntrinsicMemoryOps<T, Order>, - public IntrinsicIncDec<T, Order> -{ - typedef IntrinsicBase<T, Order> Base; - - static T or_(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.fetch_or(aVal, Base::OrderedOp::AtomicRMWOrder); - } - - static T xor_(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.fetch_xor(aVal, Base::OrderedOp::AtomicRMWOrder); - } - - static T and_(typename Base::ValueType& aPtr, T aVal) - { - return aPtr.fetch_and(aVal, Base::OrderedOp::AtomicRMWOrder); - } -}; - -template<typename T, MemoryOrdering Order> -struct AtomicIntrinsics<T*, Order> - : public IntrinsicMemoryOps<T*, Order>, public IntrinsicIncDec<T*, Order> -{ -}; - -template<typename T> -struct ToStorageTypeArgument -{ - static constexpr T convert (T aT) { return aT; } -}; - -} // namespace detail -} // namespace mozilla - -#elif defined(__GNUC__) - -namespace mozilla { -namespace detail { - -/* - * The __sync_* family of intrinsics is documented here: - * - * http://gcc.gnu.org/onlinedocs/gcc-4.6.4/gcc/Atomic-Builtins.html - * - * While these intrinsics are deprecated in favor of the newer __atomic_* - * family of intrincs: - * - * http://gcc.gnu.org/onlinedocs/gcc-4.7.3/gcc/_005f_005fatomic-Builtins.html - * - * any GCC version that supports the __atomic_* intrinsics will also support - * the <atomic> header and so will be handled above. We provide a version of - * atomics using the __sync_* intrinsics to support older versions of GCC. - * - * All __sync_* intrinsics that we use below act as full memory barriers, for - * both compiler and hardware reordering, except for __sync_lock_test_and_set, - * which is a only an acquire barrier. When we call __sync_lock_test_and_set, - * we add a barrier above it as appropriate. - */ - -template<MemoryOrdering Order> struct Barrier; - -/* - * Some processors (in particular, x86) don't require quite so many calls to - * __sync_sychronize as our specializations of Barrier produce. If - * performance turns out to be an issue, defining these specializations - * on a per-processor basis would be a good first tuning step. - */ - -template<> -struct Barrier<Relaxed> -{ - static void beforeLoad() {} - static void afterLoad() {} - static void beforeStore() {} - static void afterStore() {} -}; - -template<> -struct Barrier<ReleaseAcquire> -{ - static void beforeLoad() {} - static void afterLoad() { __sync_synchronize(); } - static void beforeStore() { __sync_synchronize(); } - static void afterStore() {} -}; - -template<> -struct Barrier<SequentiallyConsistent> -{ - static void beforeLoad() { __sync_synchronize(); } - static void afterLoad() { __sync_synchronize(); } - static void beforeStore() { __sync_synchronize(); } - static void afterStore() { __sync_synchronize(); } -}; - -template<typename T, bool TIsEnum = IsEnum<T>::value> -struct AtomicStorageType -{ - // For non-enums, just use the type directly. - typedef T Type; -}; - -template<typename T> -struct AtomicStorageType<T, true> - : Conditional<sizeof(T) == 4, uint32_t, uint64_t> -{ - static_assert(sizeof(T) == 4 || sizeof(T) == 8, - "wrong type computed in conditional above"); -}; - -template<typename T, MemoryOrdering Order> -struct IntrinsicMemoryOps -{ - typedef typename AtomicStorageType<T>::Type ValueType; - - static T load(const ValueType& aPtr) - { - Barrier<Order>::beforeLoad(); - T val = T(aPtr); - Barrier<Order>::afterLoad(); - return val; - } - - static void store(ValueType& aPtr, T aVal) - { - Barrier<Order>::beforeStore(); - aPtr = ValueType(aVal); - Barrier<Order>::afterStore(); - } - - static T exchange(ValueType& aPtr, T aVal) - { - // __sync_lock_test_and_set is only an acquire barrier; loads and stores - // can't be moved up from after to before it, but they can be moved down - // from before to after it. We may want a stricter ordering, so we need - // an explicit barrier. - Barrier<Order>::beforeStore(); - return T(__sync_lock_test_and_set(&aPtr, ValueType(aVal))); - } - - static bool compareExchange(ValueType& aPtr, T aOldVal, T aNewVal) - { - return __sync_bool_compare_and_swap(&aPtr, ValueType(aOldVal), ValueType(aNewVal)); - } -}; - -template<typename T, MemoryOrdering Order> -struct IntrinsicAddSub - : public IntrinsicMemoryOps<T, Order> -{ - typedef IntrinsicMemoryOps<T, Order> Base; - typedef typename Base::ValueType ValueType; - - static T add(ValueType& aPtr, T aVal) - { - return T(__sync_fetch_and_add(&aPtr, ValueType(aVal))); - } - - static T sub(ValueType& aPtr, T aVal) - { - return T(__sync_fetch_and_sub(&aPtr, ValueType(aVal))); - } -}; - -template<typename T, MemoryOrdering Order> -struct IntrinsicAddSub<T*, Order> - : public IntrinsicMemoryOps<T*, Order> -{ - typedef IntrinsicMemoryOps<T*, Order> Base; - typedef typename Base::ValueType ValueType; - - /* - * The reinterpret_casts are needed so that - * __sync_fetch_and_{add,sub} will properly type-check. - * - * Also, these functions do not provide standard semantics for - * pointer types, so we need to adjust the addend. - */ - static ValueType add(ValueType& aPtr, ptrdiff_t aVal) - { - ValueType amount = reinterpret_cast<ValueType>(aVal * sizeof(T)); - return __sync_fetch_and_add(&aPtr, amount); - } - - static ValueType sub(ValueType& aPtr, ptrdiff_t aVal) - { - ValueType amount = reinterpret_cast<ValueType>(aVal * sizeof(T)); - return __sync_fetch_and_sub(&aPtr, amount); - } -}; - -template<typename T, MemoryOrdering Order> -struct IntrinsicIncDec : public IntrinsicAddSub<T, Order> -{ - typedef IntrinsicAddSub<T, Order> Base; - typedef typename Base::ValueType ValueType; - - static T inc(ValueType& aPtr) { return Base::add(aPtr, 1); } - static T dec(ValueType& aPtr) { return Base::sub(aPtr, 1); } -}; - -template<typename T, MemoryOrdering Order> -struct AtomicIntrinsics : public IntrinsicIncDec<T, Order> -{ - static T or_( T& aPtr, T aVal) { return __sync_fetch_and_or(&aPtr, aVal); } - static T xor_(T& aPtr, T aVal) { return __sync_fetch_and_xor(&aPtr, aVal); } - static T and_(T& aPtr, T aVal) { return __sync_fetch_and_and(&aPtr, aVal); } -}; - -template<typename T, MemoryOrdering Order> -struct AtomicIntrinsics<T*, Order> : public IntrinsicIncDec<T*, Order> -{ -}; - -template<typename T, bool TIsEnum = IsEnum<T>::value> -struct ToStorageTypeArgument -{ - typedef typename AtomicStorageType<T>::Type ResultType; - - static constexpr ResultType convert (T aT) { return ResultType(aT); } -}; - -template<typename T> -struct ToStorageTypeArgument<T, false> -{ - static constexpr T convert (T aT) { return aT; } -}; - -} // namespace detail -} // namespace mozilla - -#else -# error "Atomic compiler intrinsics are not supported on your platform" -#endif - -namespace mozilla { - -namespace detail { - -template<typename T, MemoryOrdering Order> -class AtomicBase -{ - static_assert(sizeof(T) == 4 || sizeof(T) == 8, - "mozilla/Atomics.h only supports 32-bit and 64-bit types"); - -protected: - typedef typename detail::AtomicIntrinsics<T, Order> Intrinsics; - typedef typename Intrinsics::ValueType ValueType; - ValueType mValue; - -public: - constexpr AtomicBase() : mValue() {} - explicit constexpr AtomicBase(T aInit) - : mValue(ToStorageTypeArgument<T>::convert(aInit)) - {} - - // Note: we can't provide operator T() here because Atomic<bool> inherits - // from AtomcBase with T=uint32_t and not T=bool. If we implemented - // operator T() here, it would cause errors when comparing Atomic<bool> with - // a regular bool. - - T operator=(T aVal) - { - Intrinsics::store(mValue, aVal); - return aVal; - } - - /** - * Performs an atomic swap operation. aVal is stored and the previous - * value of this variable is returned. - */ - T exchange(T aVal) - { - return Intrinsics::exchange(mValue, aVal); - } - - /** - * Performs an atomic compare-and-swap operation and returns true if it - * succeeded. This is equivalent to atomically doing - * - * if (mValue == aOldValue) { - * mValue = aNewValue; - * return true; - * } else { - * return false; - * } - */ - bool compareExchange(T aOldValue, T aNewValue) - { - return Intrinsics::compareExchange(mValue, aOldValue, aNewValue); - } - -private: - template<MemoryOrdering AnyOrder> - AtomicBase(const AtomicBase<T, AnyOrder>& aCopy) = delete; -}; - -template<typename T, MemoryOrdering Order> -class AtomicBaseIncDec : public AtomicBase<T, Order> -{ - typedef typename detail::AtomicBase<T, Order> Base; - -public: - constexpr AtomicBaseIncDec() : Base() {} - explicit constexpr AtomicBaseIncDec(T aInit) : Base(aInit) {} - - using Base::operator=; - - operator T() const { return Base::Intrinsics::load(Base::mValue); } - T operator++(int) { return Base::Intrinsics::inc(Base::mValue); } - T operator--(int) { return Base::Intrinsics::dec(Base::mValue); } - T operator++() { return Base::Intrinsics::inc(Base::mValue) + 1; } - T operator--() { return Base::Intrinsics::dec(Base::mValue) - 1; } - -private: - template<MemoryOrdering AnyOrder> - AtomicBaseIncDec(const AtomicBaseIncDec<T, AnyOrder>& aCopy) = delete; -}; - -} // namespace detail - -/** - * A wrapper for a type that enforces that all memory accesses are atomic. - * - * In general, where a variable |T foo| exists, |Atomic<T> foo| can be used in - * its place. Implementations for integral and pointer types are provided - * below. - * - * Atomic accesses are sequentially consistent by default. You should - * use the default unless you are tall enough to ride the - * memory-ordering roller coaster (if you're not sure, you aren't) and - * you have a compelling reason to do otherwise. - * - * There is one exception to the case of atomic memory accesses: providing an - * initial value of the atomic value is not guaranteed to be atomic. This is a - * deliberate design choice that enables static atomic variables to be declared - * without introducing extra static constructors. - */ -template<typename T, - MemoryOrdering Order = SequentiallyConsistent, - typename Enable = void> -class Atomic; - -/** - * Atomic<T> implementation for integral types. - * - * In addition to atomic store and load operations, compound assignment and - * increment/decrement operators are implemented which perform the - * corresponding read-modify-write operation atomically. Finally, an atomic - * swap method is provided. - */ -template<typename T, MemoryOrdering Order> -class Atomic<T, Order, typename EnableIf<IsIntegral<T>::value && - !IsSame<T, bool>::value>::Type> - : public detail::AtomicBaseIncDec<T, Order> -{ - typedef typename detail::AtomicBaseIncDec<T, Order> Base; - -public: - constexpr Atomic() : Base() {} - explicit constexpr Atomic(T aInit) : Base(aInit) {} - - using Base::operator=; - - T operator+=(T aDelta) - { - return Base::Intrinsics::add(Base::mValue, aDelta) + aDelta; - } - - T operator-=(T aDelta) - { - return Base::Intrinsics::sub(Base::mValue, aDelta) - aDelta; - } - - T operator|=(T aVal) - { - return Base::Intrinsics::or_(Base::mValue, aVal) | aVal; - } - - T operator^=(T aVal) - { - return Base::Intrinsics::xor_(Base::mValue, aVal) ^ aVal; - } - - T operator&=(T aVal) - { - return Base::Intrinsics::and_(Base::mValue, aVal) & aVal; - } - -private: - Atomic(Atomic<T, Order>& aOther) = delete; -}; - -/** - * Atomic<T> implementation for pointer types. - * - * An atomic compare-and-swap primitive for pointer variables is provided, as - * are atomic increment and decement operators. Also provided are the compound - * assignment operators for addition and subtraction. Atomic swap (via - * exchange()) is included as well. - */ -template<typename T, MemoryOrdering Order> -class Atomic<T*, Order> : public detail::AtomicBaseIncDec<T*, Order> -{ - typedef typename detail::AtomicBaseIncDec<T*, Order> Base; - -public: - constexpr Atomic() : Base() {} - explicit constexpr Atomic(T* aInit) : Base(aInit) {} - - using Base::operator=; - - T* operator+=(ptrdiff_t aDelta) - { - return Base::Intrinsics::add(Base::mValue, aDelta) + aDelta; - } - - T* operator-=(ptrdiff_t aDelta) - { - return Base::Intrinsics::sub(Base::mValue, aDelta) - aDelta; - } - -private: - Atomic(Atomic<T*, Order>& aOther) = delete; -}; - -/** - * Atomic<T> implementation for enum types. - * - * The atomic store and load operations and the atomic swap method is provided. - */ -template<typename T, MemoryOrdering Order> -class Atomic<T, Order, typename EnableIf<IsEnum<T>::value>::Type> - : public detail::AtomicBase<T, Order> -{ - typedef typename detail::AtomicBase<T, Order> Base; - -public: - constexpr Atomic() : Base() {} - explicit constexpr Atomic(T aInit) : Base(aInit) {} - - operator T() const { return T(Base::Intrinsics::load(Base::mValue)); } - - using Base::operator=; - -private: - Atomic(Atomic<T, Order>& aOther) = delete; -}; - -/** - * Atomic<T> implementation for boolean types. - * - * The atomic store and load operations and the atomic swap method is provided. - * - * Note: - * - * - sizeof(Atomic<bool>) != sizeof(bool) for some implementations of - * bool and/or some implementations of std::atomic. This is allowed in - * [atomic.types.generic]p9. - * - * - It's not obvious whether the 8-bit atomic functions on Windows are always - * inlined or not. If they are not inlined, the corresponding functions in the - * runtime library are not available on Windows XP. This is why we implement - * Atomic<bool> with an underlying type of uint32_t. - */ -template<MemoryOrdering Order> -class Atomic<bool, Order> - : protected detail::AtomicBase<uint32_t, Order> -{ - typedef typename detail::AtomicBase<uint32_t, Order> Base; - -public: - constexpr Atomic() : Base() {} - explicit constexpr Atomic(bool aInit) : Base(aInit) {} - - // We provide boolean wrappers for the underlying AtomicBase methods. - MOZ_IMPLICIT operator bool() const - { - return Base::Intrinsics::load(Base::mValue); - } - - bool operator=(bool aVal) - { - return Base::operator=(aVal); - } - - bool exchange(bool aVal) - { - return Base::exchange(aVal); - } - - bool compareExchange(bool aOldValue, bool aNewValue) - { - return Base::compareExchange(aOldValue, aNewValue); - } - -private: - Atomic(Atomic<bool, Order>& aOther) = delete; -}; - -} // namespace mozilla - -#endif /* mozilla_Atomics_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Attributes.h b/android/armeabi/include/spidermonkey/mozilla/Attributes.h deleted file mode 100644 index df6172f3..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Attributes.h +++ /dev/null @@ -1,604 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Implementations of various class and method modifier attributes. */ - -#ifndef mozilla_Attributes_h -#define mozilla_Attributes_h - -#include "mozilla/Compiler.h" - -/* - * MOZ_ALWAYS_INLINE is a macro which expands to tell the compiler that the - * method decorated with it must be inlined, even if the compiler thinks - * otherwise. This is only a (much) stronger version of the inline hint: - * compilers are not guaranteed to respect it (although they're much more likely - * to do so). - * - * The MOZ_ALWAYS_INLINE_EVEN_DEBUG macro is yet stronger. It tells the - * compiler to inline even in DEBUG builds. It should be used very rarely. - */ -#if defined(_MSC_VER) -# define MOZ_ALWAYS_INLINE_EVEN_DEBUG __forceinline -#elif defined(__GNUC__) -# define MOZ_ALWAYS_INLINE_EVEN_DEBUG __attribute__((always_inline)) inline -#else -# define MOZ_ALWAYS_INLINE_EVEN_DEBUG inline -#endif - -#if !defined(DEBUG) -# define MOZ_ALWAYS_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG -#elif defined(_MSC_VER) && !defined(__cplusplus) -# define MOZ_ALWAYS_INLINE __inline -#else -# define MOZ_ALWAYS_INLINE inline -#endif - -#if defined(_MSC_VER) -/* - * g++ requires -std=c++0x or -std=gnu++0x to support C++11 functionality - * without warnings (functionality used by the macros below). These modes are - * detectable by checking whether __GXX_EXPERIMENTAL_CXX0X__ is defined or, more - * standardly, by checking whether __cplusplus has a C++11 or greater value. - * Current versions of g++ do not correctly set __cplusplus, so we check both - * for forward compatibility. - */ -# define MOZ_HAVE_NEVER_INLINE __declspec(noinline) -# define MOZ_HAVE_NORETURN __declspec(noreturn) -#elif defined(__clang__) - /* - * Per Clang documentation, "Note that marketing version numbers should not - * be used to check for language features, as different vendors use different - * numbering schemes. Instead, use the feature checking macros." - */ -# ifndef __has_extension -# define __has_extension __has_feature /* compatibility, for older versions of clang */ -# endif -# if __has_attribute(noinline) -# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline)) -# endif -# if __has_attribute(noreturn) -# define MOZ_HAVE_NORETURN __attribute__((noreturn)) -# endif -#elif defined(__GNUC__) -# define MOZ_HAVE_NEVER_INLINE __attribute__((noinline)) -# define MOZ_HAVE_NORETURN __attribute__((noreturn)) -#endif - -/* - * When built with clang analyzer (a.k.a scan-build), define MOZ_HAVE_NORETURN - * to mark some false positives - */ -#ifdef __clang_analyzer__ -# if __has_extension(attribute_analyzer_noreturn) -# define MOZ_HAVE_ANALYZER_NORETURN __attribute__((analyzer_noreturn)) -# endif -#endif - -/* - * MOZ_NEVER_INLINE is a macro which expands to tell the compiler that the - * method decorated with it must never be inlined, even if the compiler would - * otherwise choose to inline the method. Compilers aren't absolutely - * guaranteed to support this, but most do. - */ -#if defined(MOZ_HAVE_NEVER_INLINE) -# define MOZ_NEVER_INLINE MOZ_HAVE_NEVER_INLINE -#else -# define MOZ_NEVER_INLINE /* no support */ -#endif - -/* - * MOZ_NORETURN, specified at the start of a function declaration, indicates - * that the given function does not return. (The function definition does not - * need to be annotated.) - * - * MOZ_NORETURN void abort(const char* msg); - * - * This modifier permits the compiler to optimize code assuming a call to such a - * function will never return. It also enables the compiler to avoid spurious - * warnings about not initializing variables, or about any other seemingly-dodgy - * operations performed after the function returns. - * - * This modifier does not affect the corresponding function's linking behavior. - */ -#if defined(MOZ_HAVE_NORETURN) -# define MOZ_NORETURN MOZ_HAVE_NORETURN -#else -# define MOZ_NORETURN /* no support */ -#endif - -/** - * MOZ_COLD tells the compiler that a function is "cold", meaning infrequently - * executed. This may lead it to optimize for size more aggressively than speed, - * or to allocate the body of the function in a distant part of the text segment - * to help keep it from taking up unnecessary icache when it isn't in use. - * - * Place this attribute at the very beginning of a function definition. For - * example, write - * - * MOZ_COLD int foo(); - * - * or - * - * MOZ_COLD int foo() { return 42; } - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_COLD __attribute__ ((cold)) -#else -# define MOZ_COLD -#endif - -/** - * MOZ_NONNULL tells the compiler that some of the arguments to a function are - * known to be non-null. The arguments are a list of 1-based argument indexes - * identifying arguments which are known to be non-null. - * - * Place this attribute at the very beginning of a function definition. For - * example, write - * - * MOZ_NONNULL(1, 2) int foo(char *p, char *q); - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_NONNULL(...) __attribute__ ((nonnull(__VA_ARGS__))) -#else -# define MOZ_NONNULL(...) -#endif - -/* - * MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS, specified at the end of a function - * declaration, indicates that for the purposes of static analysis, this - * function does not return. (The function definition does not need to be - * annotated.) - * - * MOZ_ReportCrash(const char* s, const char* file, int ln) - * MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS - * - * Some static analyzers, like scan-build from clang, can use this information - * to eliminate false positives. From the upstream documentation of scan-build: - * "This attribute is useful for annotating assertion handlers that actually - * can return, but for the purpose of using the analyzer we want to pretend - * that such functions do not return." - * - */ -#if defined(MOZ_HAVE_ANALYZER_NORETURN) -# define MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS MOZ_HAVE_ANALYZER_NORETURN -#else -# define MOZ_PRETEND_NORETURN_FOR_STATIC_ANALYSIS /* no support */ -#endif - -/* - * MOZ_ASAN_BLACKLIST is a macro to tell AddressSanitizer (a compile-time - * instrumentation shipped with Clang and GCC) to not instrument the annotated - * function. Furthermore, it will prevent the compiler from inlining the - * function because inlining currently breaks the blacklisting mechanism of - * AddressSanitizer. - */ -#if defined(__has_feature) -# if __has_feature(address_sanitizer) -# define MOZ_HAVE_ASAN_BLACKLIST -# endif -#elif defined(__GNUC__) -# if defined(__SANITIZE_ADDRESS__) -# define MOZ_HAVE_ASAN_BLACKLIST -# endif -#endif - -#if defined(MOZ_HAVE_ASAN_BLACKLIST) -# define MOZ_ASAN_BLACKLIST MOZ_NEVER_INLINE __attribute__((no_sanitize_address)) -#else -# define MOZ_ASAN_BLACKLIST /* nothing */ -#endif - -/* - * MOZ_TSAN_BLACKLIST is a macro to tell ThreadSanitizer (a compile-time - * instrumentation shipped with Clang) to not instrument the annotated function. - * Furthermore, it will prevent the compiler from inlining the function because - * inlining currently breaks the blacklisting mechanism of ThreadSanitizer. - */ -#if defined(__has_feature) -# if __has_feature(thread_sanitizer) -# define MOZ_TSAN_BLACKLIST MOZ_NEVER_INLINE __attribute__((no_sanitize_thread)) -# else -# define MOZ_TSAN_BLACKLIST /* nothing */ -# endif -#else -# define MOZ_TSAN_BLACKLIST /* nothing */ -#endif - -/** - * MOZ_ALLOCATOR tells the compiler that the function it marks returns either a - * "fresh", "pointer-free" block of memory, or nullptr. "Fresh" means that the - * block is not pointed to by any other reachable pointer in the program. - * "Pointer-free" means that the block contains no pointers to any valid object - * in the program. It may be initialized with other (non-pointer) values. - * - * Placing this attribute on appropriate functions helps GCC analyze pointer - * aliasing more accurately in their callers. - * - * GCC warns if a caller ignores the value returned by a function marked with - * MOZ_ALLOCATOR: it is hard to imagine cases where dropping the value returned - * by a function that meets the criteria above would be intentional. - * - * Place this attribute after the argument list and 'this' qualifiers of a - * function definition. For example, write - * - * void *my_allocator(size_t) MOZ_ALLOCATOR; - * - * or - * - * void *my_allocator(size_t bytes) MOZ_ALLOCATOR { ... } - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_ALLOCATOR __attribute__ ((malloc, warn_unused_result)) -#else -# define MOZ_ALLOCATOR -#endif - -/** - * MOZ_MUST_USE tells the compiler to emit a warning if a function's - * return value is not used by the caller. - * - * Place this attribute at the very beginning of a function declaration. For - * example, write - * - * MOZ_MUST_USE int foo(); - * - * or - * - * MOZ_MUST_USE int foo() { return 42; } - */ -#if defined(__GNUC__) || defined(__clang__) -# define MOZ_MUST_USE __attribute__ ((warn_unused_result)) -#else -# define MOZ_MUST_USE -#endif - -/** - * MOZ_FALLTHROUGH is an annotation to suppress compiler warnings about switch - * cases that fall through without a break or return statement. MOZ_FALLTHROUGH - * is only needed on cases that have code. - * - * MOZ_FALLTHROUGH_ASSERT is an annotation to suppress compiler warnings about - * switch cases that MOZ_ASSERT(false) (or its alias MOZ_ASSERT_UNREACHABLE) in - * debug builds, but intentionally fall through in release builds. See comment - * in Assertions.h for more details. - * - * switch (foo) { - * case 1: // These cases have no code. No fallthrough annotations are needed. - * case 2: - * case 3: // This case has code, so a fallthrough annotation is needed! - * foo++; - * MOZ_FALLTHROUGH; - * case 4: - * return foo; - * - * default: - * // This case asserts in debug builds, falls through in release. - * MOZ_FALLTHROUGH_ASSERT("Unexpected foo value?!"); - * case 5: - * return 5; - * } - */ -#if defined(__clang__) && __cplusplus >= 201103L - /* clang's fallthrough annotations are only available starting in C++11. */ -# define MOZ_FALLTHROUGH [[clang::fallthrough]] -#elif defined(_MSC_VER) - /* - * MSVC's __fallthrough annotations are checked by /analyze (Code Analysis): - * https://msdn.microsoft.com/en-us/library/ms235402%28VS.80%29.aspx - */ -# include <sal.h> -# define MOZ_FALLTHROUGH __fallthrough -#else -# define MOZ_FALLTHROUGH /* FALLTHROUGH */ -#endif - -#ifdef __cplusplus - -/* - * The following macros are attributes that support the static analysis plugin - * included with Mozilla, and will be implemented (when such support is enabled) - * as C++11 attributes. Since such attributes are legal pretty much everywhere - * and have subtly different semantics depending on their placement, the - * following is a guide on where to place the attributes. - * - * Attributes that apply to a struct or class precede the name of the class: - * (Note that this is different from the placement of final for classes!) - * - * class MOZ_CLASS_ATTRIBUTE SomeClass {}; - * - * Attributes that apply to functions follow the parentheses and const - * qualifiers but precede final, override and the function body: - * - * void DeclaredFunction() MOZ_FUNCTION_ATTRIBUTE; - * void SomeFunction() MOZ_FUNCTION_ATTRIBUTE {} - * void PureFunction() const MOZ_FUNCTION_ATTRIBUTE = 0; - * void OverriddenFunction() MOZ_FUNCTION_ATTIRBUTE override; - * - * Attributes that apply to variables or parameters follow the variable's name: - * - * int variable MOZ_VARIABLE_ATTRIBUTE; - * - * Attributes that apply to types follow the type name: - * - * typedef int MOZ_TYPE_ATTRIBUTE MagicInt; - * int MOZ_TYPE_ATTRIBUTE someVariable; - * int* MOZ_TYPE_ATTRIBUTE magicPtrInt; - * int MOZ_TYPE_ATTRIBUTE* ptrToMagicInt; - * - * Attributes that apply to statements precede the statement: - * - * MOZ_IF_ATTRIBUTE if (x == 0) - * MOZ_DO_ATTRIBUTE do { } while (0); - * - * Attributes that apply to labels precede the label: - * - * MOZ_LABEL_ATTRIBUTE target: - * goto target; - * MOZ_CASE_ATTRIBUTE case 5: - * MOZ_DEFAULT_ATTRIBUTE default: - * - * The static analyses that are performed by the plugin are as follows: - * - * MOZ_MUST_OVERRIDE: Applies to all C++ member functions. All immediate - * subclasses must provide an exact override of this method; if a subclass - * does not override this method, the compiler will emit an error. This - * attribute is not limited to virtual methods, so if it is applied to a - * nonvirtual method and the subclass does not provide an equivalent - * definition, the compiler will emit an error. - * MOZ_STACK_CLASS: Applies to all classes. Any class with this annotation is - * expected to live on the stack, so it is a compile-time error to use it, or - * an array of such objects, as a global or static variable, or as the type of - * a new expression (unless placement new is being used). If a member of - * another class uses this class, or if another class inherits from this - * class, then it is considered to be a stack class as well, although this - * attribute need not be provided in such cases. - * MOZ_NONHEAP_CLASS: Applies to all classes. Any class with this annotation is - * expected to live on the stack or in static storage, so it is a compile-time - * error to use it, or an array of such objects, as the type of a new - * expression. If a member of another class uses this class, or if another - * class inherits from this class, then it is considered to be a non-heap class - * as well, although this attribute need not be provided in such cases. - * MOZ_HEAP_CLASS: Applies to all classes. Any class with this annotation is - * expected to live on the heap, so it is a compile-time error to use it, or - * an array of such objects, as the type of a variable declaration, or as a - * temporary object. If a member of another class uses this class, or if - * another class inherits from this class, then it is considered to be a heap - * class as well, although this attribute need not be provided in such cases. - * MOZ_NON_TEMPORARY_CLASS: Applies to all classes. Any class with this - * annotation is expected not to live in a temporary. If a member of another - * class uses this class or if another class inherits from this class, then it - * is considered to be a non-temporary class as well, although this attribute - * need not be provided in such cases. - * MOZ_RAII: Applies to all classes. Any class with this annotation is assumed - * to be a RAII guard, which is expected to live on the stack in an automatic - * allocation. It is prohibited from being allocated in a temporary, static - * storage, or on the heap. This is a combination of MOZ_STACK_CLASS and - * MOZ_NON_TEMPORARY_CLASS. - * MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS: Applies to all classes that are - * intended to prevent introducing static initializers. This attribute - * currently makes it a compile-time error to instantiate these classes - * anywhere other than at the global scope, or as a static member of a class. - * In non-debug mode, it also prohibits non-trivial constructors and - * destructors. - * MOZ_TRIVIAL_CTOR_DTOR: Applies to all classes that must have both a trivial - * or constexpr constructor and a trivial destructor. Setting this attribute - * on a class makes it a compile-time error for that class to get a - * non-trivial constructor or destructor for any reason. - * MOZ_HEAP_ALLOCATOR: Applies to any function. This indicates that the return - * value is allocated on the heap, and will as a result check such allocations - * during MOZ_STACK_CLASS and MOZ_NONHEAP_CLASS annotation checking. - * MOZ_IMPLICIT: Applies to constructors. Implicit conversion constructors - * are disallowed by default unless they are marked as MOZ_IMPLICIT. This - * attribute must be used for constructors which intend to provide implicit - * conversions. - * MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT: Applies to functions. Makes it a compile - * time error to pass arithmetic expressions on variables to the function. - * MOZ_OWNING_REF: Applies to declarations of pointers to reference counted - * types. This attribute tells the compiler that the raw pointer is a strong - * reference, where ownership through methods such as AddRef and Release is - * managed manually. This can make the compiler ignore these pointers when - * validating the usage of pointers otherwise. - * - * Example uses include owned pointers inside of unions, and pointers stored - * in POD types where a using a smart pointer class would make the object - * non-POD. - * MOZ_NON_OWNING_REF: Applies to declarations of pointers to reference counted - * types. This attribute tells the compiler that the raw pointer is a weak - * reference, which is ensured to be valid by a guarantee that the reference - * will be nulled before the pointer becomes invalid. This can make the compiler - * ignore these pointers when validating the usage of pointers otherwise. - * - * Examples include an mOwner pointer, which is nulled by the owning class's - * destructor, and is null-checked before dereferencing. - * MOZ_UNSAFE_REF: Applies to declarations of pointers to reference counted types. - * Occasionally there are non-owning references which are valid, but do not take - * the form of a MOZ_NON_OWNING_REF. Their safety may be dependent on the behaviour - * of API consumers. The string argument passed to this macro documents the safety - * conditions. This can make the compiler ignore these pointers when validating - * the usage of pointers elsewhere. - * - * Examples include an nsIAtom* member which is known at compile time to point to a - * static atom which is valid throughout the lifetime of the program, or an API which - * stores a pointer, but doesn't take ownership over it, instead requiring the API - * consumer to correctly null the value before it becomes invalid. - * - * Use of this annotation is discouraged when a strong reference or one of the above - * two annotations can be used instead. - * MOZ_NO_ADDREF_RELEASE_ON_RETURN: Applies to function declarations. Makes it - * a compile time error to call AddRef or Release on the return value of a - * function. This is intended to be used with operator->() of our smart - * pointer classes to ensure that the refcount of an object wrapped in a - * smart pointer is not manipulated directly. - * MOZ_MUST_USE_TYPE: Applies to type declarations. Makes it a compile time - * error to not use the return value of a function which has this type. This - * is intended to be used with types which it is an error to not use. - * MOZ_NEEDS_NO_VTABLE_TYPE: Applies to template class declarations. Makes it - * a compile time error to instantiate this template with a type parameter which - * has a VTable. - * MOZ_NON_MEMMOVABLE: Applies to class declarations for types that are not safe - * to be moved in memory using memmove(). - * MOZ_NEEDS_MEMMOVABLE_TYPE: Applies to template class declarations where the - * template arguments are required to be safe to move in memory using - * memmove(). Passing MOZ_NON_MEMMOVABLE types to these templates is a - * compile time error. - * MOZ_NEEDS_MEMMOVABLE_MEMBERS: Applies to class declarations where each member - * must be safe to move in memory using memmove(). MOZ_NON_MEMMOVABLE types - * used in members of these classes are compile time errors. - * MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS: Applies to template class - * declarations where an instance of the template should be considered, for - * static analysis purposes, to inherit any type annotations (such as - * MOZ_MUST_USE_TYPE and MOZ_STACK_CLASS) from its template arguments. - * MOZ_INIT_OUTSIDE_CTOR: Applies to class member declarations. Occasionally - * there are class members that are not initialized in the constructor, - * but logic elsewhere in the class ensures they are initialized prior to use. - * Using this attribute on a member disables the check that this member must be - * initialized in constructors via list-initialization, in the constructor body, - * or via functions called from the constructor body. - * MOZ_IS_CLASS_INIT: Applies to class method declarations. Occasionally the - * constructor doesn't initialize all of the member variables and another function - * is used to initialize the rest. This marker is used to make the static analysis - * tool aware that the marked function is part of the initialization process - * and to include the marked function in the scan mechanism that determines witch - * member variables still remain uninitialized. - * MOZ_NON_PARAM: Applies to types. Makes it compile time error to use the type - * in parameter without pointer or reference. - * MOZ_NON_AUTOABLE: Applies to class declarations. Makes it a compile time error to - * use `auto` in place of this type in variable declarations. This is intended to - * be used with types which are intended to be implicitly constructed into other - * other types before being assigned to variables. - * MOZ_REQUIRED_BASE_METHOD: Applies to virtual class method declarations. - * Sometimes derived classes override methods that need to be called by their - * overridden counterparts. This marker indicates that the marked method must - * be called by the method that it overrides. - */ -#ifdef MOZ_CLANG_PLUGIN -# define MOZ_MUST_OVERRIDE __attribute__((annotate("moz_must_override"))) -# define MOZ_STACK_CLASS __attribute__((annotate("moz_stack_class"))) -# define MOZ_NONHEAP_CLASS __attribute__((annotate("moz_nonheap_class"))) -# define MOZ_HEAP_CLASS __attribute__((annotate("moz_heap_class"))) -# define MOZ_NON_TEMPORARY_CLASS __attribute__((annotate("moz_non_temporary_class"))) -# define MOZ_TRIVIAL_CTOR_DTOR __attribute__((annotate("moz_trivial_ctor_dtor"))) -# ifdef DEBUG - /* in debug builds, these classes do have non-trivial constructors. */ -# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class"))) -# else -# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS __attribute__((annotate("moz_global_class"))) \ - MOZ_TRIVIAL_CTOR_DTOR -# endif -# define MOZ_IMPLICIT __attribute__((annotate("moz_implicit"))) -# define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT __attribute__((annotate("moz_no_arith_expr_in_arg"))) -# define MOZ_OWNING_REF __attribute__((annotate("moz_strong_ref"))) -# define MOZ_NON_OWNING_REF __attribute__((annotate("moz_weak_ref"))) -# define MOZ_UNSAFE_REF(reason) __attribute__((annotate("moz_weak_ref"))) -# define MOZ_NO_ADDREF_RELEASE_ON_RETURN __attribute__((annotate("moz_no_addref_release_on_return"))) -# define MOZ_MUST_USE_TYPE __attribute__((annotate("moz_must_use_type"))) -# define MOZ_NEEDS_NO_VTABLE_TYPE __attribute__((annotate("moz_needs_no_vtable_type"))) -# define MOZ_NON_MEMMOVABLE __attribute__((annotate("moz_non_memmovable"))) -# define MOZ_NEEDS_MEMMOVABLE_TYPE __attribute__((annotate("moz_needs_memmovable_type"))) -# define MOZ_NEEDS_MEMMOVABLE_MEMBERS __attribute__((annotate("moz_needs_memmovable_members"))) -# define MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS \ - __attribute__((annotate("moz_inherit_type_annotations_from_template_args"))) -# define MOZ_NON_AUTOABLE __attribute__((annotate("moz_non_autoable"))) -# define MOZ_INIT_OUTSIDE_CTOR \ - __attribute__((annotate("moz_ignore_ctor_initialization"))) -# define MOZ_IS_CLASS_INIT \ - __attribute__((annotate("moz_is_class_init"))) -# define MOZ_NON_PARAM \ - __attribute__((annotate("moz_non_param"))) -# define MOZ_REQUIRED_BASE_METHOD \ - __attribute__((annotate("moz_required_base_method"))) -/* - * It turns out that clang doesn't like void func() __attribute__ {} without a - * warning, so use pragmas to disable the warning. This code won't work on GCC - * anyways, so the warning is safe to ignore. - */ -# define MOZ_HEAP_ALLOCATOR \ - _Pragma("clang diagnostic push") \ - _Pragma("clang diagnostic ignored \"-Wgcc-compat\"") \ - __attribute__((annotate("moz_heap_allocator"))) \ - _Pragma("clang diagnostic pop") -#else -# define MOZ_MUST_OVERRIDE /* nothing */ -# define MOZ_STACK_CLASS /* nothing */ -# define MOZ_NONHEAP_CLASS /* nothing */ -# define MOZ_HEAP_CLASS /* nothing */ -# define MOZ_NON_TEMPORARY_CLASS /* nothing */ -# define MOZ_TRIVIAL_CTOR_DTOR /* nothing */ -# define MOZ_ONLY_USED_TO_AVOID_STATIC_CONSTRUCTORS /* nothing */ -# define MOZ_IMPLICIT /* nothing */ -# define MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT /* nothing */ -# define MOZ_HEAP_ALLOCATOR /* nothing */ -# define MOZ_OWNING_REF /* nothing */ -# define MOZ_NON_OWNING_REF /* nothing */ -# define MOZ_UNSAFE_REF(reason) /* nothing */ -# define MOZ_NO_ADDREF_RELEASE_ON_RETURN /* nothing */ -# define MOZ_MUST_USE_TYPE /* nothing */ -# define MOZ_NEEDS_NO_VTABLE_TYPE /* nothing */ -# define MOZ_NON_MEMMOVABLE /* nothing */ -# define MOZ_NEEDS_MEMMOVABLE_TYPE /* nothing */ -# define MOZ_NEEDS_MEMMOVABLE_MEMBERS /* nothing */ -# define MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS /* nothing */ -# define MOZ_INIT_OUTSIDE_CTOR /* nothing */ -# define MOZ_IS_CLASS_INIT /* nothing */ -# define MOZ_NON_PARAM /* nothing */ -# define MOZ_NON_AUTOABLE /* nothing */ -# define MOZ_REQUIRED_BASE_METHOD /* nothing */ -#endif /* MOZ_CLANG_PLUGIN */ - -#define MOZ_RAII MOZ_NON_TEMPORARY_CLASS MOZ_STACK_CLASS - -/* - * MOZ_HAVE_REF_QUALIFIERS is defined for compilers that support C++11's rvalue - * qualifier, "&&". - */ -#if defined(_MSC_VER) && _MSC_VER >= 1900 -# define MOZ_HAVE_REF_QUALIFIERS -#elif defined(__clang__) -// All supported Clang versions -# define MOZ_HAVE_REF_QUALIFIERS -#elif defined(__GNUC__) -# include "mozilla/Compiler.h" -# if MOZ_GCC_VERSION_AT_LEAST(4, 8, 1) -# define MOZ_HAVE_REF_QUALIFIERS -# endif -#endif - -#endif /* __cplusplus */ - -/** - * Printf style formats. MOZ_FORMAT_PRINTF can be used to annotate a - * function or method that is "printf-like"; this will let (some) - * compilers check that the arguments match the template string. - * - * This macro takes two arguments. The first argument is the argument - * number of the template string. The second argument is the argument - * number of the '...' argument holding the arguments. - * - * Argument numbers start at 1. Note that the implicit "this" - * argument of a non-static member function counts as an argument. - * - * So, for a simple case like: - * void print_something (int whatever, const char *fmt, ...); - * The corresponding annotation would be - * MOZ_FORMAT_PRINTF(2, 3) - * However, if "print_something" were a non-static member function, - * then the annotation would be: - * MOZ_FORMAT_PRINTF(3, 4) - * - * Note that the checking is limited to standards-conforming - * printf-likes, and in particular this should not be used for - * PR_snprintf and friends, which are "printf-like" but which assign - * different meanings to the various formats. - */ -#ifdef __GNUC__ -#define MOZ_FORMAT_PRINTF(stringIndex, firstToCheck) \ - __attribute__ ((format (printf, stringIndex, firstToCheck))) -#else -#define MOZ_FORMAT_PRINTF(stringIndex, firstToCheck) -#endif - -#endif /* mozilla_Attributes_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/BinarySearch.h b/android/armeabi/include/spidermonkey/mozilla/BinarySearch.h deleted file mode 100644 index 1bbe0566..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/BinarySearch.h +++ /dev/null @@ -1,139 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_BinarySearch_h -#define mozilla_BinarySearch_h - -#include "mozilla/Assertions.h" - -#include <stddef.h> - -namespace mozilla { - -/* - * The BinarySearch() algorithm searches the given container |aContainer| over - * the sorted index range [aBegin, aEnd) for an index |i| where - * |aContainer[i] == aTarget|. - * If such an index |i| is found, BinarySearch returns |true| and the index is - * returned via the outparam |aMatchOrInsertionPoint|. If no index is found, - * BinarySearch returns |false| and the outparam returns the first index in - * [aBegin, aEnd] where |aTarget| can be inserted to maintain sorted order. - * - * Example: - * - * Vector<int> sortedInts = ... - * - * size_t match; - * if (BinarySearch(sortedInts, 0, sortedInts.length(), 13, &match)) { - * printf("found 13 at %lu\n", match); - * } - * - * The BinarySearchIf() version behaves similarly, but takes |aComparator|, a - * functor to compare the values with, instead of a value to find. - * That functor should take one argument - the value to compare - and return an - * |int| with the comparison result: - * - * * 0, if the argument is equal to, - * * less than 0, if the argument is greater than, - * * greater than 0, if the argument is less than - * - * the value. - * - * Example: - * - * struct Comparator { - * int operator()(int aVal) const { - * if (mTarget < aVal) { return -1; } - * if (mTarget > aVal) { return 1; } - * return 0; - * } - * explicit Comparator(int aTarget) : mTarget(aTarget) {} - * const int mTarget; - * }; - * - * Vector<int> sortedInts = ... - * - * size_t match; - * if (BinarySearchIf(sortedInts, 0, sortedInts.length(), Comparator(13), &match)) { - * printf("found 13 at %lu\n", match); - * } - * - */ - -template<typename Container, typename Comparator> -bool -BinarySearchIf(const Container& aContainer, size_t aBegin, size_t aEnd, - const Comparator& aCompare, size_t* aMatchOrInsertionPoint) -{ - MOZ_ASSERT(aBegin <= aEnd); - - size_t low = aBegin; - size_t high = aEnd; - while (high != low) { - size_t middle = low + (high - low) / 2; - - // Allow any intermediate type so long as it provides a suitable ordering - // relation. - const int result = aCompare(aContainer[middle]); - - if (result == 0) { - *aMatchOrInsertionPoint = middle; - return true; - } - - if (result < 0) { - high = middle; - } else { - low = middle + 1; - } - } - - *aMatchOrInsertionPoint = low; - return false; -} - -namespace detail { - -template<class T> -class BinarySearchDefaultComparator -{ -public: - explicit BinarySearchDefaultComparator(const T& aTarget) - : mTarget(aTarget) - {} - - template <class U> - int operator()(const U& aVal) const { - if (mTarget == aVal) { - return 0; - } - - if (mTarget < aVal) { - return -1; - } - - return 1; - } - -private: - const T& mTarget; -}; - -} // namespace detail - -template <typename Container, typename T> -bool -BinarySearch(const Container& aContainer, size_t aBegin, size_t aEnd, - T aTarget, size_t* aMatchOrInsertionPoint) -{ - return BinarySearchIf(aContainer, aBegin, aEnd, - detail::BinarySearchDefaultComparator<T>(aTarget), - aMatchOrInsertionPoint); -} - -} // namespace mozilla - -#endif // mozilla_BinarySearch_h diff --git a/android/armeabi/include/spidermonkey/mozilla/BloomFilter.h b/android/armeabi/include/spidermonkey/mozilla/BloomFilter.h deleted file mode 100644 index 6757e411..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/BloomFilter.h +++ /dev/null @@ -1,256 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * A counting Bloom filter implementation. This allows consumers to - * do fast probabilistic "is item X in set Y?" testing which will - * never answer "no" when the correct answer is "yes" (but might - * incorrectly answer "yes" when the correct answer is "no"). - */ - -#ifndef mozilla_BloomFilter_h -#define mozilla_BloomFilter_h - -#include "mozilla/Assertions.h" -#include "mozilla/Likely.h" - -#include <stdint.h> -#include <string.h> - -namespace mozilla { - -/* - * This class implements a counting Bloom filter as described at - * <http://en.wikipedia.org/wiki/Bloom_filter#Counting_filters>, with - * 8-bit counters. This allows quick probabilistic answers to the - * question "is object X in set Y?" where the contents of Y might not - * be time-invariant. The probabilistic nature of the test means that - * sometimes the answer will be "yes" when it should be "no". If the - * answer is "no", then X is guaranteed not to be in Y. - * - * The filter is parametrized on KeySize, which is the size of the key - * generated by each of hash functions used by the filter, in bits, - * and the type of object T being added and removed. T must implement - * a |uint32_t hash() const| method which returns a uint32_t hash key - * that will be used to generate the two separate hash functions for - * the Bloom filter. This hash key MUST be well-distributed for good - * results! KeySize is not allowed to be larger than 16. - * - * The filter uses exactly 2**KeySize bytes of memory. From now on we - * will refer to the memory used by the filter as M. - * - * The expected rate of incorrect "yes" answers depends on M and on - * the number N of objects in set Y. As long as N is small compared - * to M, the rate of such answers is expected to be approximately - * 4*(N/M)**2 for this filter. In practice, if Y has a few hundred - * elements then using a KeySize of 12 gives a reasonably low - * incorrect answer rate. A KeySize of 12 has the additional benefit - * of using exactly one page for the filter in typical hardware - * configurations. - */ - -template<unsigned KeySize, class T> -class BloomFilter -{ - /* - * A counting Bloom filter with 8-bit counters. For now we assume - * that having two hash functions is enough, but we may revisit that - * decision later. - * - * The filter uses an array with 2**KeySize entries. - * - * Assuming a well-distributed hash function, a Bloom filter with - * array size M containing N elements and - * using k hash function has expected false positive rate exactly - * - * $ (1 - (1 - 1/M)^{kN})^k $ - * - * because each array slot has a - * - * $ (1 - 1/M)^{kN} $ - * - * chance of being 0, and the expected false positive rate is the - * probability that all of the k hash functions will hit a nonzero - * slot. - * - * For reasonable assumptions (M large, kN large, which should both - * hold if we're worried about false positives) about M and kN this - * becomes approximately - * - * $$ (1 - \exp(-kN/M))^k $$ - * - * For our special case of k == 2, that's $(1 - \exp(-2N/M))^2$, - * or in other words - * - * $$ N/M = -0.5 * \ln(1 - \sqrt(r)) $$ - * - * where r is the false positive rate. This can be used to compute - * the desired KeySize for a given load N and false positive rate r. - * - * If N/M is assumed small, then the false positive rate can - * further be approximated as 4*N^2/M^2. So increasing KeySize by - * 1, which doubles M, reduces the false positive rate by about a - * factor of 4, and a false positive rate of 1% corresponds to - * about M/N == 20. - * - * What this means in practice is that for a few hundred keys using a - * KeySize of 12 gives false positive rates on the order of 0.25-4%. - * - * Similarly, using a KeySize of 10 would lead to a 4% false - * positive rate for N == 100 and to quite bad false positive - * rates for larger N. - */ -public: - BloomFilter() - { - static_assert(KeySize <= kKeyShift, "KeySize too big"); - - // Should we have a custom operator new using calloc instead and - // require that we're allocated via the operator? - clear(); - } - - /* - * Clear the filter. This should be done before reusing it, because - * just removing all items doesn't clear counters that hit the upper - * bound. - */ - void clear(); - - /* - * Add an item to the filter. - */ - void add(const T* aValue); - - /* - * Remove an item from the filter. - */ - void remove(const T* aValue); - - /* - * Check whether the filter might contain an item. This can - * sometimes return true even if the item is not in the filter, - * but will never return false for items that are actually in the - * filter. - */ - bool mightContain(const T* aValue) const; - - /* - * Methods for add/remove/contain when we already have a hash computed - */ - void add(uint32_t aHash); - void remove(uint32_t aHash); - bool mightContain(uint32_t aHash) const; - -private: - static const size_t kArraySize = (1 << KeySize); - static const uint32_t kKeyMask = (1 << KeySize) - 1; - static const uint32_t kKeyShift = 16; - - static uint32_t hash1(uint32_t aHash) - { - return aHash & kKeyMask; - } - static uint32_t hash2(uint32_t aHash) - { - return (aHash >> kKeyShift) & kKeyMask; - } - - uint8_t& firstSlot(uint32_t aHash) - { - return mCounters[hash1(aHash)]; - } - uint8_t& secondSlot(uint32_t aHash) - { - return mCounters[hash2(aHash)]; - } - - const uint8_t& firstSlot(uint32_t aHash) const - { - return mCounters[hash1(aHash)]; - } - const uint8_t& secondSlot(uint32_t aHash) const - { - return mCounters[hash2(aHash)]; - } - - static bool full(const uint8_t& aSlot) { return aSlot == UINT8_MAX; } - - uint8_t mCounters[kArraySize]; -}; - -template<unsigned KeySize, class T> -inline void -BloomFilter<KeySize, T>::clear() -{ - memset(mCounters, 0, kArraySize); -} - -template<unsigned KeySize, class T> -inline void -BloomFilter<KeySize, T>::add(uint32_t aHash) -{ - uint8_t& slot1 = firstSlot(aHash); - if (MOZ_LIKELY(!full(slot1))) { - ++slot1; - } - uint8_t& slot2 = secondSlot(aHash); - if (MOZ_LIKELY(!full(slot2))) { - ++slot2; - } -} - -template<unsigned KeySize, class T> -MOZ_ALWAYS_INLINE void -BloomFilter<KeySize, T>::add(const T* aValue) -{ - uint32_t hash = aValue->hash(); - return add(hash); -} - -template<unsigned KeySize, class T> -inline void -BloomFilter<KeySize, T>::remove(uint32_t aHash) -{ - // If the slots are full, we don't know whether we bumped them to be - // there when we added or not, so just leave them full. - uint8_t& slot1 = firstSlot(aHash); - if (MOZ_LIKELY(!full(slot1))) { - --slot1; - } - uint8_t& slot2 = secondSlot(aHash); - if (MOZ_LIKELY(!full(slot2))) { - --slot2; - } -} - -template<unsigned KeySize, class T> -MOZ_ALWAYS_INLINE void -BloomFilter<KeySize, T>::remove(const T* aValue) -{ - uint32_t hash = aValue->hash(); - remove(hash); -} - -template<unsigned KeySize, class T> -MOZ_ALWAYS_INLINE bool -BloomFilter<KeySize, T>::mightContain(uint32_t aHash) const -{ - // Check that all the slots for this hash contain something - return firstSlot(aHash) && secondSlot(aHash); -} - -template<unsigned KeySize, class T> -MOZ_ALWAYS_INLINE bool -BloomFilter<KeySize, T>::mightContain(const T* aValue) const -{ - uint32_t hash = aValue->hash(); - return mightContain(hash); -} - -} // namespace mozilla - -#endif /* mozilla_BloomFilter_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/BufferList.h b/android/armeabi/include/spidermonkey/mozilla/BufferList.h deleted file mode 100644 index 42aea12d..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/BufferList.h +++ /dev/null @@ -1,517 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_BufferList_h -#define mozilla_BufferList_h - -#include <algorithm> -#include "mozilla/AllocPolicy.h" -#include "mozilla/Move.h" -#include "mozilla/ScopeExit.h" -#include "mozilla/Types.h" -#include "mozilla/TypeTraits.h" -#include "mozilla/Vector.h" -#include <string.h> - -// BufferList represents a sequence of buffers of data. A BufferList can choose -// to own its buffers or not. The class handles writing to the buffers, -// iterating over them, and reading data out. Unlike SegmentedVector, the -// buffers may be of unequal size. Like SegmentedVector, BufferList is a nice -// way to avoid large contiguous allocations (which can trigger OOMs). - -namespace mozilla { - -template<typename AllocPolicy> -class BufferList : private AllocPolicy -{ - // Each buffer in a BufferList has a size and a capacity. The first mSize - // bytes are initialized and the remaining |mCapacity - mSize| bytes are free. - struct Segment - { - char* mData; - size_t mSize; - size_t mCapacity; - - Segment(char* aData, size_t aSize, size_t aCapacity) - : mData(aData), - mSize(aSize), - mCapacity(aCapacity) - { - } - - Segment(const Segment&) = delete; - Segment& operator=(const Segment&) = delete; - - Segment(Segment&&) = default; - Segment& operator=(Segment&&) = default; - - char* Start() const { return mData; } - char* End() const { return mData + mSize; } - }; - - template<typename OtherAllocPolicy> - friend class BufferList; - - public: - // For the convenience of callers, all segments are required to be a multiple - // of 8 bytes in capacity. Also, every buffer except the last one is required - // to be full (i.e., size == capacity). Therefore, a byte at offset N within - // the BufferList and stored in memory at an address A will satisfy - // (N % Align == A % Align) if Align == 2, 4, or 8. - static const size_t kSegmentAlignment = 8; - - // Allocate a BufferList. The BufferList will free all its buffers when it is - // destroyed. An initial buffer of size aInitialSize and capacity - // aInitialCapacity is allocated automatically. This data will be contiguous - // an can be accessed via |Start()|. Subsequent buffers will be allocated with - // capacity aStandardCapacity. - BufferList(size_t aInitialSize, - size_t aInitialCapacity, - size_t aStandardCapacity, - AllocPolicy aAP = AllocPolicy()) - : AllocPolicy(aAP), - mOwning(true), - mSegments(aAP), - mSize(0), - mStandardCapacity(aStandardCapacity) - { - MOZ_ASSERT(aInitialCapacity % kSegmentAlignment == 0); - MOZ_ASSERT(aStandardCapacity % kSegmentAlignment == 0); - - if (aInitialCapacity) { - AllocateSegment(aInitialSize, aInitialCapacity); - } - } - - BufferList(const BufferList& aOther) = delete; - - BufferList(BufferList&& aOther) - : mOwning(aOther.mOwning), - mSegments(Move(aOther.mSegments)), - mSize(aOther.mSize), - mStandardCapacity(aOther.mStandardCapacity) - { - aOther.mSegments.clear(); - aOther.mSize = 0; - } - - BufferList& operator=(const BufferList& aOther) = delete; - - BufferList& operator=(BufferList&& aOther) - { - Clear(); - - mOwning = aOther.mOwning; - mSegments = Move(aOther.mSegments); - mSize = aOther.mSize; - aOther.mSegments.clear(); - aOther.mSize = 0; - return *this; - } - - ~BufferList() { Clear(); } - - // Returns the sum of the sizes of all the buffers. - size_t Size() const { return mSize; } - - void Clear() - { - if (mOwning) { - for (Segment& segment : mSegments) { - this->free_(segment.mData); - } - } - mSegments.clear(); - - mSize = 0; - } - - // Iterates over bytes in the segments. You can advance it by as many bytes as - // you choose. - class IterImpl - { - // Invariants: - // (0) mSegment <= bufferList.mSegments.size() - // (1) mData <= mDataEnd - // (2) If mSegment is not the last segment, mData < mDataEnd - uintptr_t mSegment; - char* mData; - char* mDataEnd; - - friend class BufferList; - - public: - explicit IterImpl(const BufferList& aBuffers) - : mSegment(0), - mData(nullptr), - mDataEnd(nullptr) - { - if (!aBuffers.mSegments.empty()) { - mData = aBuffers.mSegments[0].Start(); - mDataEnd = aBuffers.mSegments[0].End(); - } - } - - // Returns a pointer to the raw data. It is valid to access up to - // RemainingInSegment bytes of this buffer. - char* Data() const - { - MOZ_RELEASE_ASSERT(!Done()); - return mData; - } - - // Returns true if the memory in the range [Data(), Data() + aBytes) is all - // part of one contiguous buffer. - bool HasRoomFor(size_t aBytes) const - { - MOZ_RELEASE_ASSERT(mData <= mDataEnd); - return size_t(mDataEnd - mData) >= aBytes; - } - - // Returns the maximum value aBytes for which HasRoomFor(aBytes) will be - // true. - size_t RemainingInSegment() const - { - MOZ_RELEASE_ASSERT(mData <= mDataEnd); - return mDataEnd - mData; - } - - // Advances the iterator by aBytes bytes. aBytes must be less than - // RemainingInSegment(). If advancing by aBytes takes the iterator to the - // end of a buffer, it will be moved to the beginning of the next buffer - // unless it is the last buffer. - void Advance(const BufferList& aBuffers, size_t aBytes) - { - const Segment& segment = aBuffers.mSegments[mSegment]; - MOZ_RELEASE_ASSERT(segment.Start() <= mData); - MOZ_RELEASE_ASSERT(mData <= mDataEnd); - MOZ_RELEASE_ASSERT(mDataEnd == segment.End()); - - MOZ_RELEASE_ASSERT(HasRoomFor(aBytes)); - mData += aBytes; - - if (mData == mDataEnd && mSegment + 1 < aBuffers.mSegments.length()) { - mSegment++; - const Segment& nextSegment = aBuffers.mSegments[mSegment]; - mData = nextSegment.Start(); - mDataEnd = nextSegment.End(); - MOZ_RELEASE_ASSERT(mData < mDataEnd); - } - } - - // Advance the iterator by aBytes, possibly crossing segments. This function - // returns false if it runs out of buffers to advance through. Otherwise it - // returns true. - bool AdvanceAcrossSegments(const BufferList& aBuffers, size_t aBytes) - { - size_t bytes = aBytes; - while (bytes) { - size_t toAdvance = std::min(bytes, RemainingInSegment()); - if (!toAdvance) { - return false; - } - Advance(aBuffers, toAdvance); - bytes -= toAdvance; - } - return true; - } - - // Returns true when the iterator reaches the end of the BufferList. - bool Done() const - { - return mData == mDataEnd; - } - - private: - - // Count the bytes we would need to advance in order to reach aTarget. - size_t BytesUntil(const BufferList& aBuffers, const IterImpl& aTarget) const { - size_t offset = 0; - - MOZ_ASSERT(aTarget.IsIn(aBuffers)); - - char* data = mData; - for (uintptr_t segment = mSegment; segment < aTarget.mSegment; segment++) { - offset += aBuffers.mSegments[segment].End() - data; - data = aBuffers.mSegments[segment].mData; - } - - MOZ_RELEASE_ASSERT(IsIn(aBuffers)); - MOZ_RELEASE_ASSERT(aTarget.mData >= data); - - offset += aTarget.mData - data; - return offset; - } - - bool IsIn(const BufferList& aBuffers) const { - return mSegment < aBuffers.mSegments.length() && - mData >= aBuffers.mSegments[mSegment].mData && - mData < aBuffers.mSegments[mSegment].End(); - } - }; - - // Special convenience method that returns Iter().Data(). - char* Start() { return mSegments[0].mData; } - const char* Start() const { return mSegments[0].mData; } - - IterImpl Iter() const { return IterImpl(*this); } - - // Copies aSize bytes from aData into the BufferList. The storage for these - // bytes may be split across multiple buffers. Size() is increased by aSize. - inline bool WriteBytes(const char* aData, size_t aSize); - - // Copies possibly non-contiguous byte range starting at aIter into - // aData. aIter is advanced by aSize bytes. Returns false if it runs out of - // data before aSize. - inline bool ReadBytes(IterImpl& aIter, char* aData, size_t aSize) const; - - // Return a new BufferList that shares storage with this BufferList. The new - // BufferList is read-only. It allows iteration over aSize bytes starting at - // aIter. Borrow can fail, in which case *aSuccess will be false upon - // return. The borrowed BufferList can use a different AllocPolicy than the - // original one. However, it is not responsible for freeing buffers, so the - // AllocPolicy is only used for the buffer vector. - template<typename BorrowingAllocPolicy> - BufferList<BorrowingAllocPolicy> Borrow(IterImpl& aIter, size_t aSize, bool* aSuccess, - BorrowingAllocPolicy aAP = BorrowingAllocPolicy()) const; - - // Return a new BufferList and move storage from this BufferList to it. The - // new BufferList owns the buffers. Move can fail, in which case *aSuccess - // will be false upon return. The new BufferList can use a different - // AllocPolicy than the original one. The new OtherAllocPolicy is responsible - // for freeing buffers, so the OtherAllocPolicy must use freeing method - // compatible to the original one. - template<typename OtherAllocPolicy> - BufferList<OtherAllocPolicy> MoveFallible(bool* aSuccess, OtherAllocPolicy aAP = OtherAllocPolicy()); - - // Return a new BufferList that adopts the byte range starting at Iter so that - // range [aIter, aIter + aSize) is transplanted to the returned BufferList. - // Contents of the buffer before aIter + aSize is left undefined. - // Extract can fail, in which case *aSuccess will be false upon return. The - // moved buffers are erased from the original BufferList. In case of extract - // fails, the original BufferList is intact. All other iterators except aIter - // are invalidated. - // This method requires aIter and aSize to be 8-byte aligned. - BufferList Extract(IterImpl& aIter, size_t aSize, bool* aSuccess); - - // Return the number of bytes from 'start' to 'end', two iterators within - // this BufferList. - size_t RangeLength(const IterImpl& start, const IterImpl& end) const { - MOZ_ASSERT(start.IsIn(*this) && end.IsIn(*this)); - return start.BytesUntil(*this, end); - } - -private: - explicit BufferList(AllocPolicy aAP) - : AllocPolicy(aAP), - mOwning(false), - mSize(0), - mStandardCapacity(0) - { - } - - void* AllocateSegment(size_t aSize, size_t aCapacity) - { - MOZ_RELEASE_ASSERT(mOwning); - - char* data = this->template pod_malloc<char>(aCapacity); - if (!data) { - return nullptr; - } - if (!mSegments.append(Segment(data, aSize, aCapacity))) { - this->free_(data); - return nullptr; - } - mSize += aSize; - return data; - } - - bool mOwning; - Vector<Segment, 1, AllocPolicy> mSegments; - size_t mSize; - size_t mStandardCapacity; -}; - -template<typename AllocPolicy> -bool -BufferList<AllocPolicy>::WriteBytes(const char* aData, size_t aSize) -{ - MOZ_RELEASE_ASSERT(mOwning); - MOZ_RELEASE_ASSERT(mStandardCapacity); - - size_t copied = 0; - size_t remaining = aSize; - - if (!mSegments.empty()) { - Segment& lastSegment = mSegments.back(); - - size_t toCopy = std::min(aSize, lastSegment.mCapacity - lastSegment.mSize); - memcpy(lastSegment.mData + lastSegment.mSize, aData, toCopy); - lastSegment.mSize += toCopy; - mSize += toCopy; - - copied += toCopy; - remaining -= toCopy; - } - - while (remaining) { - size_t toCopy = std::min(remaining, mStandardCapacity); - - void* data = AllocateSegment(toCopy, mStandardCapacity); - if (!data) { - return false; - } - memcpy(data, aData + copied, toCopy); - - copied += toCopy; - remaining -= toCopy; - } - - return true; -} - -template<typename AllocPolicy> -bool -BufferList<AllocPolicy>::ReadBytes(IterImpl& aIter, char* aData, size_t aSize) const -{ - size_t copied = 0; - size_t remaining = aSize; - while (remaining) { - size_t toCopy = std::min(aIter.RemainingInSegment(), remaining); - if (!toCopy) { - // We've run out of data in the last segment. - return false; - } - memcpy(aData + copied, aIter.Data(), toCopy); - copied += toCopy; - remaining -= toCopy; - - aIter.Advance(*this, toCopy); - } - - return true; -} - -template<typename AllocPolicy> template<typename BorrowingAllocPolicy> -BufferList<BorrowingAllocPolicy> -BufferList<AllocPolicy>::Borrow(IterImpl& aIter, size_t aSize, bool* aSuccess, - BorrowingAllocPolicy aAP) const -{ - BufferList<BorrowingAllocPolicy> result(aAP); - - size_t size = aSize; - while (size) { - size_t toAdvance = std::min(size, aIter.RemainingInSegment()); - - if (!toAdvance || !result.mSegments.append(typename BufferList<BorrowingAllocPolicy>::Segment(aIter.mData, toAdvance, toAdvance))) { - *aSuccess = false; - return result; - } - aIter.Advance(*this, toAdvance); - size -= toAdvance; - } - - result.mSize = aSize; - *aSuccess = true; - return result; -} - -template<typename AllocPolicy> template<typename OtherAllocPolicy> -BufferList<OtherAllocPolicy> -BufferList<AllocPolicy>::MoveFallible(bool* aSuccess, OtherAllocPolicy aAP) -{ - BufferList<OtherAllocPolicy> result(0, 0, mStandardCapacity, aAP); - - IterImpl iter = Iter(); - while (!iter.Done()) { - size_t toAdvance = iter.RemainingInSegment(); - - if (!toAdvance || !result.mSegments.append(typename BufferList<OtherAllocPolicy>::Segment(iter.mData, toAdvance, toAdvance))) { - *aSuccess = false; - result.mSegments.clear(); - return result; - } - iter.Advance(*this, toAdvance); - } - - result.mSize = mSize; - mSegments.clear(); - mSize = 0; - *aSuccess = true; - return result; -} - -template<typename AllocPolicy> -BufferList<AllocPolicy> -BufferList<AllocPolicy>::Extract(IterImpl& aIter, size_t aSize, bool* aSuccess) -{ - MOZ_RELEASE_ASSERT(aSize); - MOZ_RELEASE_ASSERT(mOwning); - MOZ_ASSERT(aSize % kSegmentAlignment == 0); - MOZ_ASSERT(intptr_t(aIter.mData) % kSegmentAlignment == 0); - - IterImpl iter = aIter; - size_t size = aSize; - size_t toCopy = std::min(size, aIter.RemainingInSegment()); - MOZ_ASSERT(toCopy % kSegmentAlignment == 0); - - BufferList result(0, toCopy, mStandardCapacity); - BufferList error(0, 0, mStandardCapacity); - - // Copy the head - if (!result.WriteBytes(aIter.mData, toCopy)) { - *aSuccess = false; - return error; - } - iter.Advance(*this, toCopy); - size -= toCopy; - - // Move segments to result - auto resultGuard = MakeScopeExit([&] { - *aSuccess = false; - result.mSegments.erase(result.mSegments.begin()+1, result.mSegments.end()); - }); - - size_t movedSize = 0; - uintptr_t toRemoveStart = iter.mSegment; - uintptr_t toRemoveEnd = iter.mSegment; - while (!iter.Done() && - !iter.HasRoomFor(size)) { - if (!result.mSegments.append(Segment(mSegments[iter.mSegment].mData, - mSegments[iter.mSegment].mSize, - mSegments[iter.mSegment].mCapacity))) { - return error; - } - movedSize += iter.RemainingInSegment(); - size -= iter.RemainingInSegment(); - toRemoveEnd++; - iter.Advance(*this, iter.RemainingInSegment()); - } - - if (size) { - if (!iter.HasRoomFor(size) || - !result.WriteBytes(iter.Data(), size)) { - return error; - } - iter.Advance(*this, size); - } - - mSegments.erase(mSegments.begin() + toRemoveStart, mSegments.begin() + toRemoveEnd); - mSize -= movedSize; - aIter.mSegment = iter.mSegment - (toRemoveEnd - toRemoveStart); - aIter.mData = iter.mData; - aIter.mDataEnd = iter.mDataEnd; - MOZ_ASSERT(aIter.mDataEnd == mSegments[aIter.mSegment].End()); - result.mSize = aSize; - - resultGuard.release(); - *aSuccess = true; - return result; -} - -} // namespace mozilla - -#endif /* mozilla_BufferList_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Casting.h b/android/armeabi/include/spidermonkey/mozilla/Casting.h deleted file mode 100644 index a7d0fb50..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Casting.h +++ /dev/null @@ -1,243 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Cast operations to supplement the built-in casting operations. */ - -#ifndef mozilla_Casting_h -#define mozilla_Casting_h - -#include "mozilla/Assertions.h" -#include "mozilla/TypeTraits.h" - -#include <limits.h> - -namespace mozilla { - -/** - * Sets the outparam value of type |To| with the same underlying bit pattern of - * |aFrom|. - * - * |To| and |From| must be types of the same size; be careful of cross-platform - * size differences, or this might fail to compile on some but not all - * platforms. - * - * There is also a variant that returns the value directly. In most cases, the - * two variants should be identical. However, in the specific case of x86 - * chips, the behavior differs: returning floating-point values directly is done - * through the x87 stack, and x87 loads and stores turn signaling NaNs into - * quiet NaNs... silently. Returning floating-point values via outparam, - * however, is done entirely within the SSE registers when SSE2 floating-point - * is enabled in the compiler, which has semantics-preserving behavior you would - * expect. - * - * If preserving the distinction between signaling NaNs and quiet NaNs is - * important to you, you should use the outparam version. In all other cases, - * you should use the direct return version. - */ -template<typename To, typename From> -inline void -BitwiseCast(const From aFrom, To* aResult) -{ - static_assert(sizeof(From) == sizeof(To), - "To and From must have the same size"); - union - { - From mFrom; - To mTo; - } u; - u.mFrom = aFrom; - *aResult = u.mTo; -} - -template<typename To, typename From> -inline To -BitwiseCast(const From aFrom) -{ - To temp; - BitwiseCast<To, From>(aFrom, &temp); - return temp; -} - -namespace detail { - -enum ToSignedness { ToIsSigned, ToIsUnsigned }; -enum FromSignedness { FromIsSigned, FromIsUnsigned }; - -template<typename From, - typename To, - FromSignedness = IsSigned<From>::value ? FromIsSigned : FromIsUnsigned, - ToSignedness = IsSigned<To>::value ? ToIsSigned : ToIsUnsigned> -struct BoundsCheckImpl; - -// Implicit conversions on operands to binary operations make this all a bit -// hard to verify. Attempt to ease the pain below by *only* comparing values -// that are obviously the same type (and will undergo no further conversions), -// even when it's not strictly necessary, for explicitness. - -enum UUComparison { FromIsBigger, FromIsNotBigger }; - -// Unsigned-to-unsigned range check - -template<typename From, typename To, - UUComparison = (sizeof(From) > sizeof(To)) - ? FromIsBigger - : FromIsNotBigger> -struct UnsignedUnsignedCheck; - -template<typename From, typename To> -struct UnsignedUnsignedCheck<From, To, FromIsBigger> -{ -public: - static bool checkBounds(const From aFrom) - { - return aFrom <= From(To(-1)); - } -}; - -template<typename From, typename To> -struct UnsignedUnsignedCheck<From, To, FromIsNotBigger> -{ -public: - static bool checkBounds(const From aFrom) - { - return true; - } -}; - -template<typename From, typename To> -struct BoundsCheckImpl<From, To, FromIsUnsigned, ToIsUnsigned> -{ -public: - static bool checkBounds(const From aFrom) - { - return UnsignedUnsignedCheck<From, To>::checkBounds(aFrom); - } -}; - -// Signed-to-unsigned range check - -template<typename From, typename To> -struct BoundsCheckImpl<From, To, FromIsSigned, ToIsUnsigned> -{ -public: - static bool checkBounds(const From aFrom) - { - if (aFrom < 0) { - return false; - } - if (sizeof(To) >= sizeof(From)) { - return true; - } - return aFrom <= From(To(-1)); - } -}; - -// Unsigned-to-signed range check - -enum USComparison { FromIsSmaller, FromIsNotSmaller }; - -template<typename From, typename To, - USComparison = (sizeof(From) < sizeof(To)) - ? FromIsSmaller - : FromIsNotSmaller> -struct UnsignedSignedCheck; - -template<typename From, typename To> -struct UnsignedSignedCheck<From, To, FromIsSmaller> -{ -public: - static bool checkBounds(const From aFrom) - { - return true; - } -}; - -template<typename From, typename To> -struct UnsignedSignedCheck<From, To, FromIsNotSmaller> -{ -public: - static bool checkBounds(const From aFrom) - { - const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); - return aFrom <= From(MaxValue); - } -}; - -template<typename From, typename To> -struct BoundsCheckImpl<From, To, FromIsUnsigned, ToIsSigned> -{ -public: - static bool checkBounds(const From aFrom) - { - return UnsignedSignedCheck<From, To>::checkBounds(aFrom); - } -}; - -// Signed-to-signed range check - -template<typename From, typename To> -struct BoundsCheckImpl<From, To, FromIsSigned, ToIsSigned> -{ -public: - static bool checkBounds(const From aFrom) - { - if (sizeof(From) <= sizeof(To)) { - return true; - } - const To MaxValue = To((1ULL << (CHAR_BIT * sizeof(To) - 1)) - 1); - const To MinValue = -MaxValue - To(1); - return From(MinValue) <= aFrom && - From(aFrom) <= From(MaxValue); - } -}; - -template<typename From, typename To, - bool TypesAreIntegral = IsIntegral<From>::value && - IsIntegral<To>::value> -class BoundsChecker; - -template<typename From> -class BoundsChecker<From, From, true> -{ -public: - static bool checkBounds(const From aFrom) { return true; } -}; - -template<typename From, typename To> -class BoundsChecker<From, To, true> -{ -public: - static bool checkBounds(const From aFrom) - { - return BoundsCheckImpl<From, To>::checkBounds(aFrom); - } -}; - -template<typename From, typename To> -inline bool -IsInBounds(const From aFrom) -{ - return BoundsChecker<From, To>::checkBounds(aFrom); -} - -} // namespace detail - -/** - * Cast a value of integral type |From| to a value of integral type |To|, - * asserting that the cast will be a safe cast per C++ (that is, that |to| is in - * the range of values permitted for the type |From|). - */ -template<typename To, typename From> -inline To -AssertedCast(const From aFrom) -{ - MOZ_ASSERT((detail::IsInBounds<From, To>(aFrom))); - return static_cast<To>(aFrom); -} - -} // namespace mozilla - -#endif /* mozilla_Casting_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/ChaosMode.h b/android/armeabi/include/spidermonkey/mozilla/ChaosMode.h deleted file mode 100644 index 94833c39..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/ChaosMode.h +++ /dev/null @@ -1,94 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_ChaosMode_h -#define mozilla_ChaosMode_h - -#include "mozilla/Atomics.h" -#include "mozilla/EnumSet.h" - -#include <stdint.h> -#include <stdlib.h> - -namespace mozilla { - -enum ChaosFeature { - None = 0x0, - // Altering thread scheduling. - ThreadScheduling = 0x1, - // Altering network request scheduling. - NetworkScheduling = 0x2, - // Altering timer scheduling. - TimerScheduling = 0x4, - // Read and write less-than-requested amounts. - IOAmounts = 0x8, - // Iterate over hash tables in random order. - HashTableIteration = 0x10, - // Randomly refuse to use cached version of image (when allowed by spec). - ImageCache = 0x20, - Any = 0xffffffff, -}; - -namespace detail { -extern MFBT_DATA Atomic<uint32_t> gChaosModeCounter; -extern MFBT_DATA ChaosFeature gChaosFeatures; -} // namespace detail - -/** - * When "chaos mode" is activated, code that makes implicitly nondeterministic - * choices is encouraged to make random and extreme choices, to test more - * code paths and uncover bugs. - */ -class ChaosMode -{ -public: - static void SetChaosFeature(ChaosFeature aChaosFeature) - { - detail::gChaosFeatures = aChaosFeature; - } - - static bool isActive(ChaosFeature aFeature) - { - if (detail::gChaosModeCounter > 0) { - return true; - } - return detail::gChaosFeatures & aFeature; - } - - /** - * Increase the chaos mode activation level. An equivalent number of - * calls to leaveChaosMode must be made in order to restore the original - * chaos mode state. If the activation level is nonzero all chaos mode - * features are activated. - */ - static void enterChaosMode() - { - detail::gChaosModeCounter++; - } - - /** - * Decrease the chaos mode activation level. See enterChaosMode(). - */ - static void leaveChaosMode() - { - MOZ_ASSERT(detail::gChaosModeCounter > 0); - detail::gChaosModeCounter--; - } - - /** - * Returns a somewhat (but not uniformly) random uint32_t < aBound. - * Not to be used for anything except ChaosMode, since it's not very random. - */ - static uint32_t randomUint32LessThan(uint32_t aBound) - { - MOZ_ASSERT(aBound != 0); - return uint32_t(rand()) % aBound; - } -}; - -} /* namespace mozilla */ - -#endif /* mozilla_ChaosMode_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Char16.h b/android/armeabi/include/spidermonkey/mozilla/Char16.h deleted file mode 100644 index 3c2f254a..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Char16.h +++ /dev/null @@ -1,194 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Implements a UTF-16 character type. */ - -#ifndef mozilla_Char16_h -#define mozilla_Char16_h - -#ifdef __cplusplus - -/* - * C++11 introduces a char16_t type and support for UTF-16 string and character - * literals. C++11's char16_t is a distinct builtin type. Technically, char16_t - * is a 16-bit code unit of a Unicode code point, not a "character". - */ - -#ifdef WIN32 -# define MOZ_USE_CHAR16_WRAPPER -# include <cstdint> - /** - * Win32 API extensively uses wchar_t, which is represented by a separated - * builtin type than char16_t per spec. It's not the case for MSVC prior to - * MSVC 2015, but other compilers follow the spec. We want to mix wchar_t and - * char16_t on Windows builds. This class is supposed to make it easier. It - * stores char16_t const pointer, but provides implicit casts for wchar_t as - * well. On other platforms, we simply use - * |typedef const char16_t* char16ptr_t|. Here, we want to make the class as - * similar to this typedef, including providing some casts that are allowed - * by the typedef. - */ -class char16ptr_t -{ -private: - const char16_t* mPtr; - static_assert(sizeof(char16_t) == sizeof(wchar_t), - "char16_t and wchar_t sizes differ"); - -public: - char16ptr_t(const char16_t* aPtr) : mPtr(aPtr) {} - char16ptr_t(const wchar_t* aPtr) : - mPtr(reinterpret_cast<const char16_t*>(aPtr)) - {} - - /* Without this, nullptr assignment would be ambiguous. */ - constexpr char16ptr_t(decltype(nullptr)) : mPtr(nullptr) {} - - operator const char16_t*() const - { - return mPtr; - } - operator const wchar_t*() const - { - return reinterpret_cast<const wchar_t*>(mPtr); - } - operator const void*() const - { - return mPtr; - } - operator bool() const - { - return mPtr != nullptr; - } - - /* Explicit cast operators to allow things like (char16_t*)str. */ - explicit operator char16_t*() const - { - return const_cast<char16_t*>(mPtr); - } - explicit operator wchar_t*() const - { - return const_cast<wchar_t*>(static_cast<const wchar_t*>(*this)); - } - explicit operator int() const - { - return reinterpret_cast<intptr_t>(mPtr); - } - explicit operator unsigned int() const - { - return reinterpret_cast<uintptr_t>(mPtr); - } - explicit operator long() const - { - return reinterpret_cast<intptr_t>(mPtr); - } - explicit operator unsigned long() const - { - return reinterpret_cast<uintptr_t>(mPtr); - } - explicit operator long long() const - { - return reinterpret_cast<intptr_t>(mPtr); - } - explicit operator unsigned long long() const - { - return reinterpret_cast<uintptr_t>(mPtr); - } - - /** - * Some Windows API calls accept BYTE* but require that data actually be - * WCHAR*. Supporting this requires explicit operators to support the - * requisite explicit casts. - */ - explicit operator const char*() const - { - return reinterpret_cast<const char*>(mPtr); - } - explicit operator const unsigned char*() const - { - return reinterpret_cast<const unsigned char*>(mPtr); - } - explicit operator unsigned char*() const - { - return - const_cast<unsigned char*>(reinterpret_cast<const unsigned char*>(mPtr)); - } - explicit operator void*() const - { - return const_cast<char16_t*>(mPtr); - } - - /* Some operators used on pointers. */ - char16_t operator[](size_t aIndex) const - { - return mPtr[aIndex]; - } - bool operator==(const char16ptr_t& aOther) const - { - return mPtr == aOther.mPtr; - } - bool operator==(decltype(nullptr)) const - { - return mPtr == nullptr; - } - bool operator!=(const char16ptr_t& aOther) const - { - return mPtr != aOther.mPtr; - } - bool operator!=(decltype(nullptr)) const - { - return mPtr != nullptr; - } - char16ptr_t operator+(int aValue) const - { - return char16ptr_t(mPtr + aValue); - } - char16ptr_t operator+(unsigned int aValue) const - { - return char16ptr_t(mPtr + aValue); - } - char16ptr_t operator+(long aValue) const - { - return char16ptr_t(mPtr + aValue); - } - char16ptr_t operator+(unsigned long aValue) const - { - return char16ptr_t(mPtr + aValue); - } - char16ptr_t operator+(long long aValue) const - { - return char16ptr_t(mPtr + aValue); - } - char16ptr_t operator+(unsigned long long aValue) const - { - return char16ptr_t(mPtr + aValue); - } - ptrdiff_t operator-(const char16ptr_t& aOther) const - { - return mPtr - aOther.mPtr; - } -}; - -inline decltype((char*)0-(char*)0) -operator-(const char16_t* aX, const char16ptr_t aY) -{ - return aX - static_cast<const char16_t*>(aY); -} - -#else - -typedef const char16_t* char16ptr_t; - -#endif - -static_assert(sizeof(char16_t) == 2, "Is char16_t type 16 bits?"); -static_assert(char16_t(-1) > char16_t(0), "Is char16_t type unsigned?"); -static_assert(sizeof(u'A') == 2, "Is unicode char literal 16 bits?"); -static_assert(sizeof(u""[0]) == 2, "Is unicode string char 16 bits?"); - -#endif - -#endif /* mozilla_Char16_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/CheckedInt.h b/android/armeabi/include/spidermonkey/mozilla/CheckedInt.h deleted file mode 100644 index 02ef8d5b..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/CheckedInt.h +++ /dev/null @@ -1,791 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Provides checked integers, detecting integer overflow and divide-by-0. */ - -#ifndef mozilla_CheckedInt_h -#define mozilla_CheckedInt_h - -#include <stdint.h> -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/IntegerTypeTraits.h" - -namespace mozilla { - -template<typename T> class CheckedInt; - -namespace detail { - -/* - * Step 1: manually record supported types - * - * What's nontrivial here is that there are different families of integer - * types: basic integer types and stdint types. It is merrily undefined which - * types from one family may be just typedefs for a type from another family. - * - * For example, on GCC 4.6, aside from the basic integer types, the only other - * type that isn't just a typedef for some of them, is int8_t. - */ - -struct UnsupportedType {}; - -template<typename IntegerType> -struct IsSupportedPass2 -{ - static const bool value = false; -}; - -template<typename IntegerType> -struct IsSupported -{ - static const bool value = IsSupportedPass2<IntegerType>::value; -}; - -template<> -struct IsSupported<int8_t> -{ static const bool value = true; }; - -template<> -struct IsSupported<uint8_t> -{ static const bool value = true; }; - -template<> -struct IsSupported<int16_t> -{ static const bool value = true; }; - -template<> -struct IsSupported<uint16_t> -{ static const bool value = true; }; - -template<> -struct IsSupported<int32_t> -{ static const bool value = true; }; - -template<> -struct IsSupported<uint32_t> -{ static const bool value = true; }; - -template<> -struct IsSupported<int64_t> -{ static const bool value = true; }; - -template<> -struct IsSupported<uint64_t> -{ static const bool value = true; }; - - -template<> -struct IsSupportedPass2<char> -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2<signed char> -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2<unsigned char> -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2<short> -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2<unsigned short> -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2<int> -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2<unsigned int> -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2<long> -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2<unsigned long> -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2<long long> -{ static const bool value = true; }; - -template<> -struct IsSupportedPass2<unsigned long long> -{ static const bool value = true; }; - -/* - * Step 2: Implement the actual validity checks. - * - * Ideas taken from IntegerLib, code different. - */ - -template<typename IntegerType, size_t Size = sizeof(IntegerType)> -struct TwiceBiggerType -{ - typedef typename detail::StdintTypeForSizeAndSignedness< - sizeof(IntegerType) * 2, - IsSigned<IntegerType>::value - >::Type Type; -}; - -template<typename IntegerType> -struct TwiceBiggerType<IntegerType, 8> -{ - typedef UnsupportedType Type; -}; - -template<typename T> -inline bool -HasSignBit(T aX) -{ - // In C++, right bit shifts on negative values is undefined by the standard. - // Notice that signed-to-unsigned conversions are always well-defined in the - // standard, as the value congruent modulo 2**n as expected. By contrast, - // unsigned-to-signed is only well-defined if the value is representable. - return bool(typename MakeUnsigned<T>::Type(aX) >> - PositionOfSignBit<T>::value); -} - -// Bitwise ops may return a larger type, so it's good to use this inline -// helper guaranteeing that the result is really of type T. -template<typename T> -inline T -BinaryComplement(T aX) -{ - return ~aX; -} - -template<typename T, - typename U, - bool IsTSigned = IsSigned<T>::value, - bool IsUSigned = IsSigned<U>::value> -struct DoesRangeContainRange -{ -}; - -template<typename T, typename U, bool Signedness> -struct DoesRangeContainRange<T, U, Signedness, Signedness> -{ - static const bool value = sizeof(T) >= sizeof(U); -}; - -template<typename T, typename U> -struct DoesRangeContainRange<T, U, true, false> -{ - static const bool value = sizeof(T) > sizeof(U); -}; - -template<typename T, typename U> -struct DoesRangeContainRange<T, U, false, true> -{ - static const bool value = false; -}; - -template<typename T, - typename U, - bool IsTSigned = IsSigned<T>::value, - bool IsUSigned = IsSigned<U>::value, - bool DoesTRangeContainURange = DoesRangeContainRange<T, U>::value> -struct IsInRangeImpl {}; - -template<typename T, typename U, bool IsTSigned, bool IsUSigned> -struct IsInRangeImpl<T, U, IsTSigned, IsUSigned, true> -{ - static bool run(U) - { - return true; - } -}; - -template<typename T, typename U> -struct IsInRangeImpl<T, U, true, true, false> -{ - static bool run(U aX) - { - return aX <= MaxValue<T>::value && aX >= MinValue<T>::value; - } -}; - -template<typename T, typename U> -struct IsInRangeImpl<T, U, false, false, false> -{ - static bool run(U aX) - { - return aX <= MaxValue<T>::value; - } -}; - -template<typename T, typename U> -struct IsInRangeImpl<T, U, true, false, false> -{ - static bool run(U aX) - { - return sizeof(T) > sizeof(U) || aX <= U(MaxValue<T>::value); - } -}; - -template<typename T, typename U> -struct IsInRangeImpl<T, U, false, true, false> -{ - static bool run(U aX) - { - return sizeof(T) >= sizeof(U) - ? aX >= 0 - : aX >= 0 && aX <= U(MaxValue<T>::value); - } -}; - -template<typename T, typename U> -inline bool -IsInRange(U aX) -{ - return IsInRangeImpl<T, U>::run(aX); -} - -template<typename T> -inline bool -IsAddValid(T aX, T aY) -{ - // Addition is valid if the sign of aX+aY is equal to either that of aX or - // that of aY. Since the value of aX+aY is undefined if we have a signed - // type, we compute it using the unsigned type of the same size. Beware! - // These bitwise operations can return a larger integer type, if T was a - // small type like int8_t, so we explicitly cast to T. - - typename MakeUnsigned<T>::Type ux = aX; - typename MakeUnsigned<T>::Type uy = aY; - typename MakeUnsigned<T>::Type result = ux + uy; - return IsSigned<T>::value - ? HasSignBit(BinaryComplement(T((result ^ aX) & (result ^ aY)))) - : BinaryComplement(aX) >= aY; -} - -template<typename T> -inline bool -IsSubValid(T aX, T aY) -{ - // Subtraction is valid if either aX and aY have same sign, or aX-aY and aX - // have same sign. Since the value of aX-aY is undefined if we have a signed - // type, we compute it using the unsigned type of the same size. - typename MakeUnsigned<T>::Type ux = aX; - typename MakeUnsigned<T>::Type uy = aY; - typename MakeUnsigned<T>::Type result = ux - uy; - - return IsSigned<T>::value - ? HasSignBit(BinaryComplement(T((result ^ aX) & (aX ^ aY)))) - : aX >= aY; -} - -template<typename T, - bool IsTSigned = IsSigned<T>::value, - bool TwiceBiggerTypeIsSupported = - IsSupported<typename TwiceBiggerType<T>::Type>::value> -struct IsMulValidImpl {}; - -template<typename T, bool IsTSigned> -struct IsMulValidImpl<T, IsTSigned, true> -{ - static bool run(T aX, T aY) - { - typedef typename TwiceBiggerType<T>::Type TwiceBiggerType; - TwiceBiggerType product = TwiceBiggerType(aX) * TwiceBiggerType(aY); - return IsInRange<T>(product); - } -}; - -template<typename T> -struct IsMulValidImpl<T, true, false> -{ - static bool run(T aX, T aY) - { - const T max = MaxValue<T>::value; - const T min = MinValue<T>::value; - - if (aX == 0 || aY == 0) { - return true; - } - if (aX > 0) { - return aY > 0 - ? aX <= max / aY - : aY >= min / aX; - } - - // If we reach this point, we know that aX < 0. - return aY > 0 - ? aX >= min / aY - : aY >= max / aX; - } -}; - -template<typename T> -struct IsMulValidImpl<T, false, false> -{ - static bool run(T aX, T aY) - { - return aY == 0 || aX <= MaxValue<T>::value / aY; - } -}; - -template<typename T> -inline bool -IsMulValid(T aX, T aY) -{ - return IsMulValidImpl<T>::run(aX, aY); -} - -template<typename T> -inline bool -IsDivValid(T aX, T aY) -{ - // Keep in mind that in the signed case, min/-1 is invalid because - // abs(min)>max. - return aY != 0 && - !(IsSigned<T>::value && aX == MinValue<T>::value && aY == T(-1)); -} - -template<typename T, bool IsTSigned = IsSigned<T>::value> -struct IsModValidImpl; - -template<typename T> -inline bool -IsModValid(T aX, T aY) -{ - return IsModValidImpl<T>::run(aX, aY); -} - -/* - * Mod is pretty simple. - * For now, let's just use the ANSI C definition: - * If aX or aY are negative, the results are implementation defined. - * Consider these invalid. - * Undefined for aY=0. - * The result will never exceed either aX or aY. - * - * Checking that aX>=0 is a warning when T is unsigned. - */ - -template<typename T> -struct IsModValidImpl<T, false> -{ - static inline bool run(T aX, T aY) - { - return aY >= 1; - } -}; - -template<typename T> -struct IsModValidImpl<T, true> -{ - static inline bool run(T aX, T aY) - { - if (aX < 0) { - return false; - } - return aY >= 1; - } -}; - -template<typename T, bool IsSigned = IsSigned<T>::value> -struct NegateImpl; - -template<typename T> -struct NegateImpl<T, false> -{ - static CheckedInt<T> negate(const CheckedInt<T>& aVal) - { - // Handle negation separately for signed/unsigned, for simpler code and to - // avoid an MSVC warning negating an unsigned value. - return CheckedInt<T>(0, aVal.isValid() && aVal.mValue == 0); - } -}; - -template<typename T> -struct NegateImpl<T, true> -{ - static CheckedInt<T> negate(const CheckedInt<T>& aVal) - { - // Watch out for the min-value, which (with twos-complement) can't be - // negated as -min-value is then (max-value + 1). - if (!aVal.isValid() || aVal.mValue == MinValue<T>::value) { - return CheckedInt<T>(aVal.mValue, false); - } - return CheckedInt<T>(-aVal.mValue, true); - } -}; - -} // namespace detail - - -/* - * Step 3: Now define the CheckedInt class. - */ - -/** - * @class CheckedInt - * @brief Integer wrapper class checking for integer overflow and other errors - * @param T the integer type to wrap. Can be any type among the following: - * - any basic integer type such as |int| - * - any stdint type such as |int8_t| - * - * This class implements guarded integer arithmetic. Do a computation, check - * that isValid() returns true, you then have a guarantee that no problem, such - * as integer overflow, happened during this computation, and you can call - * value() to get the plain integer value. - * - * The arithmetic operators in this class are guaranteed not to raise a signal - * (e.g. in case of a division by zero). - * - * For example, suppose that you want to implement a function that computes - * (aX+aY)/aZ, that doesn't crash if aZ==0, and that reports on error (divide by - * zero or integer overflow). You could code it as follows: - @code - bool computeXPlusYOverZ(int aX, int aY, int aZ, int* aResult) - { - CheckedInt<int> checkedResult = (CheckedInt<int>(aX) + aY) / aZ; - if (checkedResult.isValid()) { - *aResult = checkedResult.value(); - return true; - } else { - return false; - } - } - @endcode - * - * Implicit conversion from plain integers to checked integers is allowed. The - * plain integer is checked to be in range before being casted to the - * destination type. This means that the following lines all compile, and the - * resulting CheckedInts are correctly detected as valid or invalid: - * @code - // 1 is of type int, is found to be in range for uint8_t, x is valid - CheckedInt<uint8_t> x(1); - // -1 is of type int, is found not to be in range for uint8_t, x is invalid - CheckedInt<uint8_t> x(-1); - // -1 is of type int, is found to be in range for int8_t, x is valid - CheckedInt<int8_t> x(-1); - // 1000 is of type int16_t, is found not to be in range for int8_t, - // x is invalid - CheckedInt<int8_t> x(int16_t(1000)); - // 3123456789 is of type uint32_t, is found not to be in range for int32_t, - // x is invalid - CheckedInt<int32_t> x(uint32_t(3123456789)); - * @endcode - * Implicit conversion from - * checked integers to plain integers is not allowed. As shown in the - * above example, to get the value of a checked integer as a normal integer, - * call value(). - * - * Arithmetic operations between checked and plain integers is allowed; the - * result type is the type of the checked integer. - * - * Checked integers of different types cannot be used in the same arithmetic - * expression. - * - * There are convenience typedefs for all stdint types, of the following form - * (these are just 2 examples): - @code - typedef CheckedInt<int32_t> CheckedInt32; - typedef CheckedInt<uint16_t> CheckedUint16; - @endcode - */ -template<typename T> -class CheckedInt -{ -protected: - T mValue; - bool mIsValid; - - template<typename U> - CheckedInt(U aValue, bool aIsValid) : mValue(aValue), mIsValid(aIsValid) - { - static_assert(detail::IsSupported<T>::value && - detail::IsSupported<U>::value, - "This type is not supported by CheckedInt"); - } - - friend struct detail::NegateImpl<T>; - -public: - /** - * Constructs a checked integer with given @a value. The checked integer is - * initialized as valid or invalid depending on whether the @a value - * is in range. - * - * This constructor is not explicit. Instead, the type of its argument is a - * separate template parameter, ensuring that no conversion is performed - * before this constructor is actually called. As explained in the above - * documentation for class CheckedInt, this constructor checks that its - * argument is valid. - */ - template<typename U> - MOZ_IMPLICIT CheckedInt(U aValue) MOZ_NO_ARITHMETIC_EXPR_IN_ARGUMENT - : mValue(T(aValue)), - mIsValid(detail::IsInRange<T>(aValue)) - { - static_assert(detail::IsSupported<T>::value && - detail::IsSupported<U>::value, - "This type is not supported by CheckedInt"); - } - - template<typename U> - friend class CheckedInt; - - template<typename U> - CheckedInt<U> toChecked() const - { - CheckedInt<U> ret(mValue); - ret.mIsValid = ret.mIsValid && mIsValid; - return ret; - } - - /** Constructs a valid checked integer with initial value 0 */ - CheckedInt() : mValue(0), mIsValid(true) - { - static_assert(detail::IsSupported<T>::value, - "This type is not supported by CheckedInt"); - } - - /** @returns the actual value */ - T value() const - { - MOZ_ASSERT(mIsValid, "Invalid checked integer (division by zero or integer overflow)"); - return mValue; - } - - /** - * @returns true if the checked integer is valid, i.e. is not the result - * of an invalid operation or of an operation involving an invalid checked - * integer - */ - bool isValid() const - { - return mIsValid; - } - - template<typename U> - friend CheckedInt<U> operator +(const CheckedInt<U>& aLhs, - const CheckedInt<U>& aRhs); - template<typename U> - CheckedInt& operator +=(U aRhs); - CheckedInt& operator +=(const CheckedInt<T>& aRhs); - - template<typename U> - friend CheckedInt<U> operator -(const CheckedInt<U>& aLhs, - const CheckedInt<U>& aRhs); - template<typename U> - CheckedInt& operator -=(U aRhs); - CheckedInt& operator -=(const CheckedInt<T>& aRhs); - - template<typename U> - friend CheckedInt<U> operator *(const CheckedInt<U>& aLhs, - const CheckedInt<U>& aRhs); - template<typename U> - CheckedInt& operator *=(U aRhs); - CheckedInt& operator *=(const CheckedInt<T>& aRhs); - - template<typename U> - friend CheckedInt<U> operator /(const CheckedInt<U>& aLhs, - const CheckedInt<U>& aRhs); - template<typename U> - CheckedInt& operator /=(U aRhs); - CheckedInt& operator /=(const CheckedInt<T>& aRhs); - - template<typename U> - friend CheckedInt<U> operator %(const CheckedInt<U>& aLhs, - const CheckedInt<U>& aRhs); - template<typename U> - CheckedInt& operator %=(U aRhs); - CheckedInt& operator %=(const CheckedInt<T>& aRhs); - - CheckedInt operator -() const - { - return detail::NegateImpl<T>::negate(*this); - } - - /** - * @returns true if the left and right hand sides are valid - * and have the same value. - * - * Note that these semantics are the reason why we don't offer - * a operator!=. Indeed, we'd want to have a!=b be equivalent to !(a==b) - * but that would mean that whenever a or b is invalid, a!=b - * is always true, which would be very confusing. - * - * For similar reasons, operators <, >, <=, >= would be very tricky to - * specify, so we just avoid offering them. - * - * Notice that these == semantics are made more reasonable by these facts: - * 1. a==b implies equality at the raw data level - * (the converse is false, as a==b is never true among invalids) - * 2. This is similar to the behavior of IEEE floats, where a==b - * means that a and b have the same value *and* neither is NaN. - */ - bool operator ==(const CheckedInt& aOther) const - { - return mIsValid && aOther.mIsValid && mValue == aOther.mValue; - } - - /** prefix ++ */ - CheckedInt& operator++() - { - *this += 1; - return *this; - } - - /** postfix ++ */ - CheckedInt operator++(int) - { - CheckedInt tmp = *this; - *this += 1; - return tmp; - } - - /** prefix -- */ - CheckedInt& operator--() - { - *this -= 1; - return *this; - } - - /** postfix -- */ - CheckedInt operator--(int) - { - CheckedInt tmp = *this; - *this -= 1; - return tmp; - } - -private: - /** - * The !=, <, <=, >, >= operators are disabled: - * see the comment on operator==. - */ - template<typename U> bool operator !=(U aOther) const = delete; - template<typename U> bool operator < (U aOther) const = delete; - template<typename U> bool operator <=(U aOther) const = delete; - template<typename U> bool operator > (U aOther) const = delete; - template<typename U> bool operator >=(U aOther) const = delete; -}; - -#define MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(NAME, OP) \ - template<typename T> \ - inline CheckedInt<T> \ - operator OP(const CheckedInt<T>& aLhs, const CheckedInt<T>& aRhs) \ - { \ - if (!detail::Is##NAME##Valid(aLhs.mValue, aRhs.mValue)) { \ - return CheckedInt<T>(0, false); \ - } \ - return CheckedInt<T>(aLhs.mValue OP aRhs.mValue, \ - aLhs.mIsValid && aRhs.mIsValid); \ - } - -MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Add, +) -MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Sub, -) -MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mul, *) -MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Div, /) -MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR(Mod, %) - -#undef MOZ_CHECKEDINT_BASIC_BINARY_OPERATOR - -// Implement castToCheckedInt<T>(x), making sure that -// - it allows x to be either a CheckedInt<T> or any integer type -// that can be casted to T -// - if x is already a CheckedInt<T>, we just return a reference to it, -// instead of copying it (optimization) - -namespace detail { - -template<typename T, typename U> -struct CastToCheckedIntImpl -{ - typedef CheckedInt<T> ReturnType; - static CheckedInt<T> run(U aU) { return aU; } -}; - -template<typename T> -struct CastToCheckedIntImpl<T, CheckedInt<T> > -{ - typedef const CheckedInt<T>& ReturnType; - static const CheckedInt<T>& run(const CheckedInt<T>& aU) { return aU; } -}; - -} // namespace detail - -template<typename T, typename U> -inline typename detail::CastToCheckedIntImpl<T, U>::ReturnType -castToCheckedInt(U aU) -{ - static_assert(detail::IsSupported<T>::value && - detail::IsSupported<U>::value, - "This type is not supported by CheckedInt"); - return detail::CastToCheckedIntImpl<T, U>::run(aU); -} - -#define MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(OP, COMPOUND_OP) \ - template<typename T> \ - template<typename U> \ - CheckedInt<T>& CheckedInt<T>::operator COMPOUND_OP(U aRhs) \ - { \ - *this = *this OP castToCheckedInt<T>(aRhs); \ - return *this; \ - } \ - template<typename T> \ - CheckedInt<T>& CheckedInt<T>::operator COMPOUND_OP(const CheckedInt<T>& aRhs) \ - { \ - *this = *this OP aRhs; \ - return *this; \ - } \ - template<typename T, typename U> \ - inline CheckedInt<T> operator OP(const CheckedInt<T>& aLhs, U aRhs) \ - { \ - return aLhs OP castToCheckedInt<T>(aRhs); \ - } \ - template<typename T, typename U> \ - inline CheckedInt<T> operator OP(U aLhs, const CheckedInt<T>& aRhs) \ - { \ - return castToCheckedInt<T>(aLhs) OP aRhs; \ - } - -MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(+, +=) -MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(*, *=) -MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(-, -=) -MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(/, /=) -MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS(%, %=) - -#undef MOZ_CHECKEDINT_CONVENIENCE_BINARY_OPERATORS - -template<typename T, typename U> -inline bool -operator ==(const CheckedInt<T>& aLhs, U aRhs) -{ - return aLhs == castToCheckedInt<T>(aRhs); -} - -template<typename T, typename U> -inline bool -operator ==(U aLhs, const CheckedInt<T>& aRhs) -{ - return castToCheckedInt<T>(aLhs) == aRhs; -} - -// Convenience typedefs. -typedef CheckedInt<int8_t> CheckedInt8; -typedef CheckedInt<uint8_t> CheckedUint8; -typedef CheckedInt<int16_t> CheckedInt16; -typedef CheckedInt<uint16_t> CheckedUint16; -typedef CheckedInt<int32_t> CheckedInt32; -typedef CheckedInt<uint32_t> CheckedUint32; -typedef CheckedInt<int64_t> CheckedInt64; -typedef CheckedInt<uint64_t> CheckedUint64; - -} // namespace mozilla - -#endif /* mozilla_CheckedInt_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Compiler.h b/android/armeabi/include/spidermonkey/mozilla/Compiler.h deleted file mode 100644 index 1bd34d32..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Compiler.h +++ /dev/null @@ -1,113 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Various compiler checks. */ - -#ifndef mozilla_Compiler_h -#define mozilla_Compiler_h - -#define MOZ_IS_GCC 0 -#define MOZ_IS_MSVC 0 - -#if !defined(__clang__) && defined(__GNUC__) - -# undef MOZ_IS_GCC -# define MOZ_IS_GCC 1 - /* - * These macros should simplify gcc version checking. For example, to check - * for gcc 4.7.1 or later, check `#if MOZ_GCC_VERSION_AT_LEAST(4, 7, 1)`. - */ -# define MOZ_GCC_VERSION_AT_LEAST(major, minor, patchlevel) \ - ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \ - >= ((major) * 10000 + (minor) * 100 + (patchlevel))) -# define MOZ_GCC_VERSION_AT_MOST(major, minor, patchlevel) \ - ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) \ - <= ((major) * 10000 + (minor) * 100 + (patchlevel))) -# if !MOZ_GCC_VERSION_AT_LEAST(4, 8, 0) -# error "mfbt (and Gecko) require at least gcc 4.8 to build." -# endif - -#elif defined(_MSC_VER) - -# undef MOZ_IS_MSVC -# define MOZ_IS_MSVC 1 - -#endif - -/* - * The situation with standard libraries is a lot worse than with compilers, - * particularly as clang and gcc could end up using one of three or so standard - * libraries, and they may not be up-to-snuff with newer C++11 versions. To - * detect the library, we're going to include cstddef (which is a small header - * which will be transitively included by everybody else at some point) to grab - * the version macros and deduce macros from there. - */ -#ifdef __cplusplus -# include <cstddef> -# ifdef _STLPORT_MAJOR -# define MOZ_USING_STLPORT 1 -# define MOZ_STLPORT_VERSION_AT_LEAST(major, minor, patch) \ - (_STLPORT_VERSION >= ((major) << 8 | (minor) << 4 | (patch))) -# elif defined(_LIBCPP_VERSION) - /* - * libc++, unfortunately, doesn't appear to have useful versioning macros. - * Hopefully, the recommendations of N3694 with respect to standard libraries - * will get applied instead and we won't need to worry about version numbers - * here. - */ -# define MOZ_USING_LIBCXX 1 -# elif defined(__GLIBCXX__) -# define MOZ_USING_LIBSTDCXX 1 - /* - * libstdc++ is also annoying and doesn't give us useful versioning macros - * for the library. If we're using gcc, then assume that libstdc++ matches - * the compiler version. If we're using clang, we're going to have to fake - * major/minor combinations by looking for newly-defined config macros. - */ -# if MOZ_IS_GCC -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - MOZ_GCC_VERSION_AT_LEAST(major, minor, patch) -# elif defined(_GLIBCXX_THROW_OR_ABORT) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 8)) -# elif defined(_GLIBCXX_NOEXCEPT) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 7)) -# elif defined(_GLIBCXX_USE_DEPRECATED) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 6)) -# elif defined(_GLIBCXX_PSEUDO_VISIBILITY) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 5)) -# elif defined(_GLIBCXX_BEGIN_EXTERN_C) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 4)) -# elif defined(_GLIBCXX_VISIBILITY_ATTR) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 3)) -# elif defined(_GLIBCXX_VISIBILITY) -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) \ - ((major) < 4 || ((major) == 4 && (minor) <= 2)) -# else -# error "Your version of libstdc++ is unknown to us and is likely too old." -# endif -# endif - - // Flesh out the defines for everyone else -# ifndef MOZ_USING_STLPORT -# define MOZ_USING_STLPORT 0 -# define MOZ_STLPORT_VERSION_AT_LEAST(major, minor, patch) 0 -# endif -# ifndef MOZ_USING_LIBCXX -# define MOZ_USING_LIBCXX 0 -# endif -# ifndef MOZ_USING_LIBSTDCXX -# define MOZ_USING_LIBSTDCXX 0 -# define MOZ_LIBSTDCXX_VERSION_AT_LEAST(major, minor, patch) 0 -# endif -#endif /* __cplusplus */ - -#endif /* mozilla_Compiler_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Compression.h b/android/armeabi/include/spidermonkey/mozilla/Compression.h deleted file mode 100644 index aa50211b..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Compression.h +++ /dev/null @@ -1,119 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Various simple compression/decompression functions. */ - -#ifndef mozilla_Compression_h_ -#define mozilla_Compression_h_ - -#include "mozilla/Assertions.h" -#include "mozilla/Types.h" - -namespace mozilla { -namespace Compression { - -/** - * LZ4 is a very fast byte-wise compression algorithm. - * - * Compared to Google's Snappy it is faster to compress and decompress and - * generally produces output of about the same size. - * - * Compared to zlib it compresses at about 10x the speed, decompresses at about - * 4x the speed and produces output of about 1.5x the size. - */ - -class LZ4 -{ -public: - /** - * Compresses |aInputSize| bytes from |aSource| into |aDest|. Destination - * buffer must be already allocated, and must be sized to handle worst cases - * situations (input data not compressible). Worst case size evaluation is - * provided by function maxCompressedSize() - * - * @param aInputSize is the input size. Max supported value is ~1.9GB - * @return the number of bytes written in buffer |aDest| - */ - static MFBT_API size_t - compress(const char* aSource, size_t aInputSize, char* aDest); - - /** - * Compress |aInputSize| bytes from |aSource| into an output buffer - * |aDest| of maximum size |aMaxOutputSize|. If it cannot achieve it, - * compression will stop, and result of the function will be zero, - * |aDest| will still be written to, but since the number of input - * bytes consumed is not returned the result is not usable. - * - * This function never writes outside of provided output buffer. - * - * @param aInputSize is the input size. Max supported value is ~1.9GB - * @param aMaxOutputSize is the size of the destination buffer (which must - * be already allocated) - * @return the number of bytes written in buffer |aDest| or 0 if the - * compression fails - */ - static MFBT_API size_t - compressLimitedOutput(const char* aSource, size_t aInputSize, char* aDest, - size_t aMaxOutputSize); - - /** - * If the source stream is malformed, the function will stop decoding - * and return false. - * - * This function never writes outside of provided buffers, and never - * modifies input buffer. - * - * Note: destination buffer must be already allocated, and its size must be a - * minimum of |aOutputSize| bytes. - * - * @param aOutputSize is the output size, therefore the original size - * @return true on success, false on failure - */ - static MFBT_API MOZ_MUST_USE bool - decompress(const char* aSource, char* aDest, size_t aOutputSize); - - /** - * If the source stream is malformed, the function will stop decoding - * and return false. - * - * This function never writes beyond aDest + aMaxOutputSize, and is - * therefore protected against malicious data packets. - * - * Note: Destination buffer must be already allocated. This version is - * slightly slower than the decompress without the aMaxOutputSize. - * - * @param aInputSize is the length of the input compressed data - * @param aMaxOutputSize is the size of the destination buffer (which must be - * already allocated) - * @param aOutputSize the actual number of bytes decoded in the destination - * buffer (necessarily <= aMaxOutputSize) - * @return true on success, false on failure - */ - static MFBT_API MOZ_MUST_USE bool - decompress(const char* aSource, size_t aInputSize, char* aDest, - size_t aMaxOutputSize, size_t* aOutputSize); - - /* - * Provides the maximum size that LZ4 may output in a "worst case" - * scenario (input data not compressible) primarily useful for memory - * allocation of output buffer. - * note : this function is limited by "int" range (2^31-1) - * - * @param aInputSize is the input size. Max supported value is ~1.9GB - * @return maximum output size in a "worst case" scenario - */ - static inline size_t maxCompressedSize(size_t aInputSize) - { - size_t max = (aInputSize + (aInputSize / 255) + 16); - MOZ_ASSERT(max > aInputSize); - return max; - } -}; - -} /* namespace Compression */ -} /* namespace mozilla */ - -#endif /* mozilla_Compression_h_ */ diff --git a/android/armeabi/include/spidermonkey/mozilla/DebugOnly.h b/android/armeabi/include/spidermonkey/mozilla/DebugOnly.h deleted file mode 100644 index a1a669db..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/DebugOnly.h +++ /dev/null @@ -1,92 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Provides DebugOnly, a type for variables used only in debug builds (i.e. by - * assertions). - */ - -#ifndef mozilla_DebugOnly_h -#define mozilla_DebugOnly_h - -#include "mozilla/Attributes.h" - -namespace mozilla { - -/** - * DebugOnly contains a value of type T, but only in debug builds. In release - * builds, it does not contain a value. This helper is intended to be used with - * MOZ_ASSERT()-style macros, allowing one to write: - * - * DebugOnly<bool> check = func(); - * MOZ_ASSERT(check); - * - * more concisely than declaring |check| conditional on #ifdef DEBUG. - * - * DebugOnly instances can only be coerced to T in debug builds. In release - * builds they don't have a value, so type coercion is not well defined. - * - * NOTE: DebugOnly instances still take up one byte of space, plus padding, even - * in optimized, non-DEBUG builds (see bug 1253094 comment 37 for more info). - * For this reason the class is MOZ_STACK_CLASS to prevent consumers using - * DebugOnly for struct/class members and unwittingly inflating the size of - * their objects in release builds. - */ -template<typename T> -class MOZ_STACK_CLASS DebugOnly -{ -public: -#ifdef DEBUG - T value; - - DebugOnly() { } - MOZ_IMPLICIT DebugOnly(const T& aOther) : value(aOther) { } - DebugOnly(const DebugOnly& aOther) : value(aOther.value) { } - DebugOnly& operator=(const T& aRhs) { - value = aRhs; - return *this; - } - - void operator++(int) { value++; } - void operator--(int) { value--; } - - // Do not define operator+=(), etc. here. These will coerce via the - // implicit cast and built-in operators. Defining explicit methods here - // will create ambiguity the compiler can't deal with. - - T* operator&() { return &value; } - - operator T&() { return value; } - operator const T&() const { return value; } - - T& operator->() { return value; } - const T& operator->() const { return value; } - -#else - DebugOnly() { } - MOZ_IMPLICIT DebugOnly(const T&) { } - DebugOnly(const DebugOnly&) { } - DebugOnly& operator=(const T&) { return *this; } - void operator++(int) { } - void operator--(int) { } - DebugOnly& operator+=(const T&) { return *this; } - DebugOnly& operator-=(const T&) { return *this; } - DebugOnly& operator&=(const T&) { return *this; } - DebugOnly& operator|=(const T&) { return *this; } - DebugOnly& operator^=(const T&) { return *this; } -#endif - - /* - * DebugOnly must always have a destructor or else it will - * generate "unused variable" warnings, exactly what it's intended - * to avoid! - */ - ~DebugOnly() {} -}; - -} // namespace mozilla - -#endif /* mozilla_DebugOnly_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Decimal.h b/android/armeabi/include/spidermonkey/mozilla/Decimal.h deleted file mode 100644 index 10d0e2c7..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Decimal.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (C) 2012 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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. - */ - -/** - * Imported from: - * https://chromium.googlesource.com/chromium/src.git/+/master/third_party/WebKit/Source/platform/Decimal.h - * Check UPSTREAM-GIT-SHA for the commit ID of the last update from Blink core. - */ - -#ifndef Decimal_h -#define Decimal_h - -#include "mozilla/Assertions.h" -#include <stdint.h> -#include "mozilla/Types.h" - -#include <string> - -#ifndef ASSERT -#define DEFINED_ASSERT_FOR_DECIMAL_H 1 -#define ASSERT MOZ_ASSERT -#endif - -#define PLATFORM_EXPORT - -// To use USING_FAST_MALLOC we'd need: -// https://chromium.googlesource.com/chromium/src.git/+/master/third_party/WebKit/Source/wtf/Allocator.h -// Since we don't allocate Decimal objects, no need. -#define USING_FAST_MALLOC(type) \ - void ignore_this_dummy_method() = delete - -#define DISALLOW_NEW() \ - private: \ - void* operator new(size_t) = delete; \ - void* operator new(size_t, void*) = delete; \ - public: - -namespace blink { - -namespace DecimalPrivate { -class SpecialValueHandler; -} - -// This class represents decimal base floating point number. -// -// FIXME: Once all C++ compiler support decimal type, we should replace this -// class to compiler supported one. See below URI for current status of decimal -// type for C++: // http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1977.html -class PLATFORM_EXPORT Decimal { - USING_FAST_MALLOC(Decimal); -public: - enum Sign { - Positive, - Negative, - }; - - // You should not use EncodedData other than unit testing. - class EncodedData { - DISALLOW_NEW(); - // For accessing FormatClass. - friend class Decimal; - friend class DecimalPrivate::SpecialValueHandler; - public: - EncodedData(Sign, int exponent, uint64_t coefficient); - - bool operator==(const EncodedData&) const; - bool operator!=(const EncodedData& another) const { return !operator==(another); } - - uint64_t coefficient() const { return m_coefficient; } - int countDigits() const; - int exponent() const { return m_exponent; } - bool isFinite() const { return !isSpecial(); } - bool isInfinity() const { return m_formatClass == ClassInfinity; } - bool isNaN() const { return m_formatClass == ClassNaN; } - bool isSpecial() const { return m_formatClass == ClassInfinity || m_formatClass == ClassNaN; } - bool isZero() const { return m_formatClass == ClassZero; } - Sign sign() const { return m_sign; } - void setSign(Sign sign) { m_sign = sign; } - - private: - enum FormatClass { - ClassInfinity, - ClassNormal, - ClassNaN, - ClassZero, - }; - - EncodedData(Sign, FormatClass); - FormatClass formatClass() const { return m_formatClass; } - - uint64_t m_coefficient; - int16_t m_exponent; - FormatClass m_formatClass; - Sign m_sign; - }; - - MFBT_API explicit Decimal(int32_t = 0); - MFBT_API Decimal(Sign, int exponent, uint64_t coefficient); - MFBT_API Decimal(const Decimal&); - - MFBT_API Decimal& operator=(const Decimal&); - MFBT_API Decimal& operator+=(const Decimal&); - MFBT_API Decimal& operator-=(const Decimal&); - MFBT_API Decimal& operator*=(const Decimal&); - MFBT_API Decimal& operator/=(const Decimal&); - - MFBT_API Decimal operator-() const; - - MFBT_API bool operator==(const Decimal&) const; - MFBT_API bool operator!=(const Decimal&) const; - MFBT_API bool operator<(const Decimal&) const; - MFBT_API bool operator<=(const Decimal&) const; - MFBT_API bool operator>(const Decimal&) const; - MFBT_API bool operator>=(const Decimal&) const; - - MFBT_API Decimal operator+(const Decimal&) const; - MFBT_API Decimal operator-(const Decimal&) const; - MFBT_API Decimal operator*(const Decimal&) const; - MFBT_API Decimal operator/(const Decimal&) const; - - int exponent() const - { - ASSERT(isFinite()); - return m_data.exponent(); - } - - bool isFinite() const { return m_data.isFinite(); } - bool isInfinity() const { return m_data.isInfinity(); } - bool isNaN() const { return m_data.isNaN(); } - bool isNegative() const { return sign() == Negative; } - bool isPositive() const { return sign() == Positive; } - bool isSpecial() const { return m_data.isSpecial(); } - bool isZero() const { return m_data.isZero(); } - - MFBT_API Decimal abs() const; - MFBT_API Decimal ceil() const; - MFBT_API Decimal floor() const; - MFBT_API Decimal remainder(const Decimal&) const; - MFBT_API Decimal round() const; - - MFBT_API double toDouble() const; - // Note: toString method supports infinity and nan but fromString not. - MFBT_API std::string toString() const; - MFBT_API bool toString(char* strBuf, size_t bufLength) const; - - static MFBT_API Decimal fromDouble(double); - // fromString supports following syntax EBNF: - // number ::= sign? digit+ ('.' digit*) (exponent-marker sign? digit+)? - // | sign? '.' digit+ (exponent-marker sign? digit+)? - // sign ::= '+' | '-' - // exponent-marker ::= 'e' | 'E' - // digit ::= '0' | '1' | ... | '9' - // Note: fromString doesn't support "infinity" and "nan". - static MFBT_API Decimal fromString(const std::string& aValue); - static MFBT_API Decimal infinity(Sign); - static MFBT_API Decimal nan(); - static MFBT_API Decimal zero(Sign); - - // You should not use below methods. We expose them for unit testing. - MFBT_API explicit Decimal(const EncodedData&); - const EncodedData& value() const { return m_data; } - -private: - struct AlignedOperands { - uint64_t lhsCoefficient; - uint64_t rhsCoefficient; - int exponent; - }; - - MFBT_API explicit Decimal(double); - MFBT_API Decimal compareTo(const Decimal&) const; - - static MFBT_API AlignedOperands alignOperands(const Decimal& lhs, const Decimal& rhs); - static inline Sign invertSign(Sign sign) { return sign == Negative ? Positive : Negative; } - - Sign sign() const { return m_data.sign(); } - - EncodedData m_data; -}; - -} // namespace blink - -namespace mozilla { -typedef blink::Decimal Decimal; -} // namespace mozilla - -#undef USING_FAST_MALLOC - -#ifdef DEFINED_ASSERT_FOR_DECIMAL_H -#undef DEFINED_ASSERT_FOR_DECIMAL_H -#undef ASSERT -#endif - -#endif // Decimal_h diff --git a/android/armeabi/include/spidermonkey/mozilla/EndianUtils.h b/android/armeabi/include/spidermonkey/mozilla/EndianUtils.h deleted file mode 100644 index 00815580..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/EndianUtils.h +++ /dev/null @@ -1,695 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Functions for reading and writing integers in various endiannesses. */ - -/* - * The classes LittleEndian and BigEndian expose static methods for - * reading and writing 16-, 32-, and 64-bit signed and unsigned integers - * in their respective endianness. The naming scheme is: - * - * {Little,Big}Endian::{read,write}{Uint,Int}<bitsize> - * - * For instance, LittleEndian::readInt32 will read a 32-bit signed - * integer from memory in little endian format. Similarly, - * BigEndian::writeUint16 will write a 16-bit unsigned integer to memory - * in big-endian format. - * - * The class NativeEndian exposes methods for conversion of existing - * data to and from the native endianness. These methods are intended - * for cases where data needs to be transferred, serialized, etc. - * swap{To,From}{Little,Big}Endian byteswap a single value if necessary. - * Bulk conversion functions are also provided which optimize the - * no-conversion-needed case: - * - * - copyAndSwap{To,From}{Little,Big}Endian; - * - swap{To,From}{Little,Big}EndianInPlace. - * - * The *From* variants are intended to be used for reading data and the - * *To* variants for writing data. - * - * Methods on NativeEndian work with integer data of any type. - * Floating-point data is not supported. - * - * For clarity in networking code, "Network" may be used as a synonym - * for "Big" in any of the above methods or class names. - * - * As an example, reading a file format header whose fields are stored - * in big-endian format might look like: - * - * class ExampleHeader - * { - * private: - * uint32_t mMagic; - * uint32_t mLength; - * uint32_t mTotalRecords; - * uint64_t mChecksum; - * - * public: - * ExampleHeader(const void* data) - * { - * const uint8_t* ptr = static_cast<const uint8_t*>(data); - * mMagic = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); - * mLength = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); - * mTotalRecords = BigEndian::readUint32(ptr); ptr += sizeof(uint32_t); - * mChecksum = BigEndian::readUint64(ptr); - * } - * ... - * }; - */ - -#ifndef mozilla_EndianUtils_h -#define mozilla_EndianUtils_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Compiler.h" -#include "mozilla/DebugOnly.h" -#include "mozilla/TypeTraits.h" - -#include <stdint.h> -#include <string.h> - -#if defined(_MSC_VER) -# include <stdlib.h> -# pragma intrinsic(_byteswap_ushort) -# pragma intrinsic(_byteswap_ulong) -# pragma intrinsic(_byteswap_uint64) -#endif - -#if defined(_WIN64) -# if defined(_M_X64) || defined(_M_AMD64) || defined(_AMD64_) -# define MOZ_LITTLE_ENDIAN 1 -# else -# error "CPU type is unknown" -# endif -#elif defined(_WIN32) -# if defined(_M_IX86) -# define MOZ_LITTLE_ENDIAN 1 -# elif defined(_M_ARM) -# define MOZ_LITTLE_ENDIAN 1 -# else -# error "CPU type is unknown" -# endif -#elif defined(__APPLE__) || defined(__powerpc__) || defined(__ppc__) -# if __LITTLE_ENDIAN__ -# define MOZ_LITTLE_ENDIAN 1 -# elif __BIG_ENDIAN__ -# define MOZ_BIG_ENDIAN 1 -# endif -#elif defined(__GNUC__) && \ - defined(__BYTE_ORDER__) && \ - defined(__ORDER_LITTLE_ENDIAN__) && \ - defined(__ORDER_BIG_ENDIAN__) - /* - * Some versions of GCC provide architecture-independent macros for - * this. Yes, there are more than two values for __BYTE_ORDER__. - */ -# if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ -# define MOZ_LITTLE_ENDIAN 1 -# elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ -# define MOZ_BIG_ENDIAN 1 -# else -# error "Can't handle mixed-endian architectures" -# endif -/* - * We can't include useful headers like <endian.h> or <sys/isa_defs.h> - * here because they're not present on all platforms. Instead we have - * this big conditional that ideally will catch all the interesting - * cases. - */ -#elif defined(__sparc) || defined(__sparc__) || \ - defined(_POWER) || defined(__hppa) || \ - defined(_MIPSEB) || defined(__ARMEB__) || \ - defined(__s390__) || defined(__AARCH64EB__) || \ - (defined(__sh__) && defined(__LITTLE_ENDIAN__)) || \ - (defined(__ia64) && defined(__BIG_ENDIAN__)) -# define MOZ_BIG_ENDIAN 1 -#elif defined(__i386) || defined(__i386__) || \ - defined(__x86_64) || defined(__x86_64__) || \ - defined(_MIPSEL) || defined(__ARMEL__) || \ - defined(__alpha__) || defined(__AARCH64EL__) || \ - (defined(__sh__) && defined(__BIG_ENDIAN__)) || \ - (defined(__ia64) && !defined(__BIG_ENDIAN__)) -# define MOZ_LITTLE_ENDIAN 1 -#endif - -#if MOZ_BIG_ENDIAN -# define MOZ_LITTLE_ENDIAN 0 -#elif MOZ_LITTLE_ENDIAN -# define MOZ_BIG_ENDIAN 0 -#else -# error "Cannot determine endianness" -#endif - -#if defined(__clang__) -# if __has_builtin(__builtin_bswap16) -# define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16 -# endif -#elif defined(__GNUC__) -# define MOZ_HAVE_BUILTIN_BYTESWAP16 __builtin_bswap16 -#elif defined(_MSC_VER) -# define MOZ_HAVE_BUILTIN_BYTESWAP16 _byteswap_ushort -#endif - -namespace mozilla { - -namespace detail { - -/* - * We need wrappers here because free functions with default template - * arguments and/or partial specialization of function templates are not - * supported by all the compilers we use. - */ -template<typename T, size_t Size = sizeof(T)> -struct Swapper; - -template<typename T> -struct Swapper<T, 2> -{ - static T swap(T aValue) - { -#if defined(MOZ_HAVE_BUILTIN_BYTESWAP16) - return MOZ_HAVE_BUILTIN_BYTESWAP16(aValue); -#else - return T(((aValue & 0x00ff) << 8) | ((aValue & 0xff00) >> 8)); -#endif - } -}; - -template<typename T> -struct Swapper<T, 4> -{ - static T swap(T aValue) - { -#if defined(__clang__) || defined(__GNUC__) - return T(__builtin_bswap32(aValue)); -#elif defined(_MSC_VER) - return T(_byteswap_ulong(aValue)); -#else - return T(((aValue & 0x000000ffU) << 24) | - ((aValue & 0x0000ff00U) << 8) | - ((aValue & 0x00ff0000U) >> 8) | - ((aValue & 0xff000000U) >> 24)); -#endif - } -}; - -template<typename T> -struct Swapper<T, 8> -{ - static inline T swap(T aValue) - { -#if defined(__clang__) || defined(__GNUC__) - return T(__builtin_bswap64(aValue)); -#elif defined(_MSC_VER) - return T(_byteswap_uint64(aValue)); -#else - return T(((aValue & 0x00000000000000ffULL) << 56) | - ((aValue & 0x000000000000ff00ULL) << 40) | - ((aValue & 0x0000000000ff0000ULL) << 24) | - ((aValue & 0x00000000ff000000ULL) << 8) | - ((aValue & 0x000000ff00000000ULL) >> 8) | - ((aValue & 0x0000ff0000000000ULL) >> 24) | - ((aValue & 0x00ff000000000000ULL) >> 40) | - ((aValue & 0xff00000000000000ULL) >> 56)); -#endif - } -}; - -enum Endianness { Little, Big }; - -#if MOZ_BIG_ENDIAN -# define MOZ_NATIVE_ENDIANNESS detail::Big -#else -# define MOZ_NATIVE_ENDIANNESS detail::Little -#endif - -class EndianUtils -{ - /** - * Assert that the memory regions [aDest, aDest+aCount) and - * [aSrc, aSrc+aCount] do not overlap. aCount is given in bytes. - */ - static void assertNoOverlap(const void* aDest, const void* aSrc, - size_t aCount) - { - DebugOnly<const uint8_t*> byteDestPtr = static_cast<const uint8_t*>(aDest); - DebugOnly<const uint8_t*> byteSrcPtr = static_cast<const uint8_t*>(aSrc); - MOZ_ASSERT((byteDestPtr <= byteSrcPtr && - byteDestPtr + aCount <= byteSrcPtr) || - (byteSrcPtr <= byteDestPtr && - byteSrcPtr + aCount <= byteDestPtr)); - } - - template<typename T> - static void assertAligned(T* aPtr) - { - MOZ_ASSERT((uintptr_t(aPtr) % sizeof(T)) == 0, "Unaligned pointer!"); - } - -protected: - /** - * Return |aValue| converted from SourceEndian encoding to DestEndian - * encoding. - */ - template<Endianness SourceEndian, Endianness DestEndian, typename T> - static inline T maybeSwap(T aValue) - { - if (SourceEndian == DestEndian) { - return aValue; - } - return Swapper<T>::swap(aValue); - } - - /** - * Convert |aCount| elements at |aPtr| from SourceEndian encoding to - * DestEndian encoding. - */ - template<Endianness SourceEndian, Endianness DestEndian, typename T> - static inline void maybeSwapInPlace(T* aPtr, size_t aCount) - { - assertAligned(aPtr); - - if (SourceEndian == DestEndian) { - return; - } - for (size_t i = 0; i < aCount; i++) { - aPtr[i] = Swapper<T>::swap(aPtr[i]); - } - } - - /** - * Write |aCount| elements to the unaligned address |aDest| in DestEndian - * format, using elements found at |aSrc| in SourceEndian format. - */ - template<Endianness SourceEndian, Endianness DestEndian, typename T> - static void copyAndSwapTo(void* aDest, const T* aSrc, size_t aCount) - { - assertNoOverlap(aDest, aSrc, aCount * sizeof(T)); - assertAligned(aSrc); - - if (SourceEndian == DestEndian) { - memcpy(aDest, aSrc, aCount * sizeof(T)); - return; - } - - uint8_t* byteDestPtr = static_cast<uint8_t*>(aDest); - for (size_t i = 0; i < aCount; ++i) { - union - { - T mVal; - uint8_t mBuffer[sizeof(T)]; - } u; - u.mVal = maybeSwap<SourceEndian, DestEndian>(aSrc[i]); - memcpy(byteDestPtr, u.mBuffer, sizeof(T)); - byteDestPtr += sizeof(T); - } - } - - /** - * Write |aCount| elements to |aDest| in DestEndian format, using elements - * found at the unaligned address |aSrc| in SourceEndian format. - */ - template<Endianness SourceEndian, Endianness DestEndian, typename T> - static void copyAndSwapFrom(T* aDest, const void* aSrc, size_t aCount) - { - assertNoOverlap(aDest, aSrc, aCount * sizeof(T)); - assertAligned(aDest); - - if (SourceEndian == DestEndian) { - memcpy(aDest, aSrc, aCount * sizeof(T)); - return; - } - - const uint8_t* byteSrcPtr = static_cast<const uint8_t*>(aSrc); - for (size_t i = 0; i < aCount; ++i) { - union - { - T mVal; - uint8_t mBuffer[sizeof(T)]; - } u; - memcpy(u.mBuffer, byteSrcPtr, sizeof(T)); - aDest[i] = maybeSwap<SourceEndian, DestEndian>(u.mVal); - byteSrcPtr += sizeof(T); - } - } -}; - -template<Endianness ThisEndian> -class Endian : private EndianUtils -{ -protected: - /** Read a uint16_t in ThisEndian endianness from |aPtr| and return it. */ - static MOZ_MUST_USE uint16_t readUint16(const void* aPtr) - { - return read<uint16_t>(aPtr); - } - - /** Read a uint32_t in ThisEndian endianness from |aPtr| and return it. */ - static MOZ_MUST_USE uint32_t readUint32(const void* aPtr) - { - return read<uint32_t>(aPtr); - } - - /** Read a uint64_t in ThisEndian endianness from |aPtr| and return it. */ - static MOZ_MUST_USE uint64_t readUint64(const void* aPtr) - { - return read<uint64_t>(aPtr); - } - - /** Read an int16_t in ThisEndian endianness from |aPtr| and return it. */ - static MOZ_MUST_USE int16_t readInt16(const void* aPtr) - { - return read<int16_t>(aPtr); - } - - /** Read an int32_t in ThisEndian endianness from |aPtr| and return it. */ - static MOZ_MUST_USE int32_t readInt32(const void* aPtr) - { - return read<uint32_t>(aPtr); - } - - /** Read an int64_t in ThisEndian endianness from |aPtr| and return it. */ - static MOZ_MUST_USE int64_t readInt64(const void* aPtr) - { - return read<int64_t>(aPtr); - } - - /** Write |aValue| to |aPtr| using ThisEndian endianness. */ - static void writeUint16(void* aPtr, uint16_t aValue) - { - write(aPtr, aValue); - } - - /** Write |aValue| to |aPtr| using ThisEndian endianness. */ - static void writeUint32(void* aPtr, uint32_t aValue) - { - write(aPtr, aValue); - } - - /** Write |aValue| to |aPtr| using ThisEndian endianness. */ - static void writeUint64(void* aPtr, uint64_t aValue) - { - write(aPtr, aValue); - } - - /** Write |aValue| to |aPtr| using ThisEndian endianness. */ - static void writeInt16(void* aPtr, int16_t aValue) - { - write(aPtr, aValue); - } - - /** Write |aValue| to |aPtr| using ThisEndian endianness. */ - static void writeInt32(void* aPtr, int32_t aValue) - { - write(aPtr, aValue); - } - - /** Write |aValue| to |aPtr| using ThisEndian endianness. */ - static void writeInt64(void* aPtr, int64_t aValue) - { - write(aPtr, aValue); - } - - /* - * Converts a value of type T to little-endian format. - * - * This function is intended for cases where you have data in your - * native-endian format and you need it to appear in little-endian - * format for transmission. - */ - template<typename T> - MOZ_MUST_USE static T swapToLittleEndian(T aValue) - { - return maybeSwap<ThisEndian, Little>(aValue); - } - - /* - * Copies |aCount| values of type T starting at |aSrc| to |aDest|, converting - * them to little-endian format if ThisEndian is Big. - * As with memcpy, |aDest| and |aSrc| must not overlap. - */ - template<typename T> - static void copyAndSwapToLittleEndian(void* aDest, const T* aSrc, - size_t aCount) - { - copyAndSwapTo<ThisEndian, Little>(aDest, aSrc, aCount); - } - - /* - * Likewise, but converts values in place. - */ - template<typename T> - static void swapToLittleEndianInPlace(T* aPtr, size_t aCount) - { - maybeSwapInPlace<ThisEndian, Little>(aPtr, aCount); - } - - /* - * Converts a value of type T to big-endian format. - */ - template<typename T> - MOZ_MUST_USE static T swapToBigEndian(T aValue) - { - return maybeSwap<ThisEndian, Big>(aValue); - } - - /* - * Copies |aCount| values of type T starting at |aSrc| to |aDest|, converting - * them to big-endian format if ThisEndian is Little. - * As with memcpy, |aDest| and |aSrc| must not overlap. - */ - template<typename T> - static void copyAndSwapToBigEndian(void* aDest, const T* aSrc, - size_t aCount) - { - copyAndSwapTo<ThisEndian, Big>(aDest, aSrc, aCount); - } - - /* - * Likewise, but converts values in place. - */ - template<typename T> - static void swapToBigEndianInPlace(T* aPtr, size_t aCount) - { - maybeSwapInPlace<ThisEndian, Big>(aPtr, aCount); - } - - /* - * Synonyms for the big-endian functions, for better readability - * in network code. - */ - - template<typename T> - MOZ_MUST_USE static T swapToNetworkOrder(T aValue) - { - return swapToBigEndian(aValue); - } - - template<typename T> - static void - copyAndSwapToNetworkOrder(void* aDest, const T* aSrc, size_t aCount) - { - copyAndSwapToBigEndian(aDest, aSrc, aCount); - } - - template<typename T> - static void - swapToNetworkOrderInPlace(T* aPtr, size_t aCount) - { - swapToBigEndianInPlace(aPtr, aCount); - } - - /* - * Converts a value of type T from little-endian format. - */ - template<typename T> - MOZ_MUST_USE static T swapFromLittleEndian(T aValue) - { - return maybeSwap<Little, ThisEndian>(aValue); - } - - /* - * Copies |aCount| values of type T starting at |aSrc| to |aDest|, converting - * them to little-endian format if ThisEndian is Big. - * As with memcpy, |aDest| and |aSrc| must not overlap. - */ - template<typename T> - static void copyAndSwapFromLittleEndian(T* aDest, const void* aSrc, - size_t aCount) - { - copyAndSwapFrom<Little, ThisEndian>(aDest, aSrc, aCount); - } - - /* - * Likewise, but converts values in place. - */ - template<typename T> - static void swapFromLittleEndianInPlace(T* aPtr, size_t aCount) - { - maybeSwapInPlace<Little, ThisEndian>(aPtr, aCount); - } - - /* - * Converts a value of type T from big-endian format. - */ - template<typename T> - MOZ_MUST_USE static T swapFromBigEndian(T aValue) - { - return maybeSwap<Big, ThisEndian>(aValue); - } - - /* - * Copies |aCount| values of type T starting at |aSrc| to |aDest|, converting - * them to big-endian format if ThisEndian is Little. - * As with memcpy, |aDest| and |aSrc| must not overlap. - */ - template<typename T> - static void copyAndSwapFromBigEndian(T* aDest, const void* aSrc, - size_t aCount) - { - copyAndSwapFrom<Big, ThisEndian>(aDest, aSrc, aCount); - } - - /* - * Likewise, but converts values in place. - */ - template<typename T> - static void swapFromBigEndianInPlace(T* aPtr, size_t aCount) - { - maybeSwapInPlace<Big, ThisEndian>(aPtr, aCount); - } - - /* - * Synonyms for the big-endian functions, for better readability - * in network code. - */ - template<typename T> - MOZ_MUST_USE static T swapFromNetworkOrder(T aValue) - { - return swapFromBigEndian(aValue); - } - - template<typename T> - static void copyAndSwapFromNetworkOrder(T* aDest, const void* aSrc, - size_t aCount) - { - copyAndSwapFromBigEndian(aDest, aSrc, aCount); - } - - template<typename T> - static void swapFromNetworkOrderInPlace(T* aPtr, size_t aCount) - { - swapFromBigEndianInPlace(aPtr, aCount); - } - -private: - /** - * Read a value of type T, encoded in endianness ThisEndian from |aPtr|. - * Return that value encoded in native endianness. - */ - template<typename T> - static T read(const void* aPtr) - { - union - { - T mVal; - uint8_t mBuffer[sizeof(T)]; - } u; - memcpy(u.mBuffer, aPtr, sizeof(T)); - return maybeSwap<ThisEndian, MOZ_NATIVE_ENDIANNESS>(u.mVal); - } - - /** - * Write a value of type T, in native endianness, to |aPtr|, in ThisEndian - * endianness. - */ - template<typename T> - static void write(void* aPtr, T aValue) - { - T tmp = maybeSwap<MOZ_NATIVE_ENDIANNESS, ThisEndian>(aValue); - memcpy(aPtr, &tmp, sizeof(T)); - } - - Endian() = delete; - Endian(const Endian& aTther) = delete; - void operator=(const Endian& aOther) = delete; -}; - -template<Endianness ThisEndian> -class EndianReadWrite : public Endian<ThisEndian> -{ -private: - typedef Endian<ThisEndian> super; - -public: - using super::readUint16; - using super::readUint32; - using super::readUint64; - using super::readInt16; - using super::readInt32; - using super::readInt64; - using super::writeUint16; - using super::writeUint32; - using super::writeUint64; - using super::writeInt16; - using super::writeInt32; - using super::writeInt64; -}; - -} /* namespace detail */ - -class LittleEndian final : public detail::EndianReadWrite<detail::Little> -{}; - -class BigEndian final : public detail::EndianReadWrite<detail::Big> -{}; - -typedef BigEndian NetworkEndian; - -class NativeEndian final : public detail::Endian<MOZ_NATIVE_ENDIANNESS> -{ -private: - typedef detail::Endian<MOZ_NATIVE_ENDIANNESS> super; - -public: - /* - * These functions are intended for cases where you have data in your - * native-endian format and you need the data to appear in the appropriate - * endianness for transmission, serialization, etc. - */ - using super::swapToLittleEndian; - using super::copyAndSwapToLittleEndian; - using super::swapToLittleEndianInPlace; - using super::swapToBigEndian; - using super::copyAndSwapToBigEndian; - using super::swapToBigEndianInPlace; - using super::swapToNetworkOrder; - using super::copyAndSwapToNetworkOrder; - using super::swapToNetworkOrderInPlace; - - /* - * These functions are intended for cases where you have data in the - * given endianness (e.g. reading from disk or a file-format) and you - * need the data to appear in native-endian format for processing. - */ - using super::swapFromLittleEndian; - using super::copyAndSwapFromLittleEndian; - using super::swapFromLittleEndianInPlace; - using super::swapFromBigEndian; - using super::copyAndSwapFromBigEndian; - using super::swapFromBigEndianInPlace; - using super::swapFromNetworkOrder; - using super::copyAndSwapFromNetworkOrder; - using super::swapFromNetworkOrderInPlace; -}; - -#undef MOZ_NATIVE_ENDIANNESS - -} /* namespace mozilla */ - -#endif /* mozilla_EndianUtils_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/EnumSet.h b/android/armeabi/include/spidermonkey/mozilla/EnumSet.h deleted file mode 100644 index 5282ab30..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/EnumSet.h +++ /dev/null @@ -1,344 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A set abstraction for enumeration values. */ - -#ifndef mozilla_EnumSet_h -#define mozilla_EnumSet_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" - -#include <initializer_list> - -#include <stdint.h> - -namespace mozilla { - -/** - * EnumSet<T> is a set of values defined by an enumeration. It is implemented - * using a 32 bit mask for each value so it will only work for enums with an int - * representation less than 32. It works both for enum and enum class types. - */ -template<typename T> -class EnumSet -{ -public: - EnumSet() - : mBitField(0) - { - initVersion(); - } - - MOZ_IMPLICIT EnumSet(T aEnum) - : mBitField(bitFor(aEnum)) - { } - - EnumSet(T aEnum1, T aEnum2) - : mBitField(bitFor(aEnum1) | - bitFor(aEnum2)) - { - initVersion(); - } - - EnumSet(T aEnum1, T aEnum2, T aEnum3) - : mBitField(bitFor(aEnum1) | - bitFor(aEnum2) | - bitFor(aEnum3)) - { - initVersion(); - } - - EnumSet(T aEnum1, T aEnum2, T aEnum3, T aEnum4) - : mBitField(bitFor(aEnum1) | - bitFor(aEnum2) | - bitFor(aEnum3) | - bitFor(aEnum4)) - { - initVersion(); - } - - MOZ_IMPLICIT EnumSet(std::initializer_list<T> list) - : mBitField(0) - { - for (auto value : list) { - (*this) += value; - } - initVersion(); - } - - EnumSet(const EnumSet& aEnumSet) - : mBitField(aEnumSet.mBitField) - { - initVersion(); - } - - /** - * Add an element - */ - void operator+=(T aEnum) - { - incVersion(); - mBitField |= bitFor(aEnum); - } - - /** - * Add an element - */ - EnumSet<T> operator+(T aEnum) const - { - EnumSet<T> result(*this); - result += aEnum; - return result; - } - - /** - * Union - */ - void operator+=(const EnumSet<T> aEnumSet) - { - incVersion(); - mBitField |= aEnumSet.mBitField; - } - - /** - * Union - */ - EnumSet<T> operator+(const EnumSet<T> aEnumSet) const - { - EnumSet<T> result(*this); - result += aEnumSet; - return result; - } - - /** - * Remove an element - */ - void operator-=(T aEnum) - { - incVersion(); - mBitField &= ~(bitFor(aEnum)); - } - - /** - * Remove an element - */ - EnumSet<T> operator-(T aEnum) const - { - EnumSet<T> result(*this); - result -= aEnum; - return result; - } - - /** - * Remove a set of elements - */ - void operator-=(const EnumSet<T> aEnumSet) - { - incVersion(); - mBitField &= ~(aEnumSet.mBitField); - } - - /** - * Remove a set of elements - */ - EnumSet<T> operator-(const EnumSet<T> aEnumSet) const - { - EnumSet<T> result(*this); - result -= aEnumSet; - return result; - } - - /** - * Clear - */ - void clear() - { - incVersion(); - mBitField = 0; - } - - /** - * Intersection - */ - void operator&=(const EnumSet<T> aEnumSet) - { - incVersion(); - mBitField &= aEnumSet.mBitField; - } - - /** - * Intersection - */ - EnumSet<T> operator&(const EnumSet<T> aEnumSet) const - { - EnumSet<T> result(*this); - result &= aEnumSet; - return result; - } - - /** - * Equality - */ - bool operator==(const EnumSet<T> aEnumSet) const - { - return mBitField == aEnumSet.mBitField; - } - - /** - * Test is an element is contained in the set. - */ - bool contains(T aEnum) const - { - return mBitField & bitFor(aEnum); - } - - /** - * Return the number of elements in the set. - */ - uint8_t size() const - { - uint8_t count = 0; - for (uint32_t bitField = mBitField; bitField; bitField >>= 1) { - if (bitField & 1) { - count++; - } - } - return count; - } - - bool isEmpty() const - { - return mBitField == 0; - } - - uint32_t serialize() const - { - return mBitField; - } - - void deserialize(uint32_t aValue) - { - incVersion(); - mBitField = aValue; - } - - class ConstIterator - { - const EnumSet<T>* mSet; - uint32_t mPos; -#ifdef DEBUG - uint64_t mVersion; -#endif - - void checkVersion() { - // Check that the set has not been modified while being iterated. - MOZ_ASSERT_IF(mSet, mSet->mVersion == mVersion); - } - - public: - ConstIterator(const EnumSet<T>& aSet, uint32_t aPos) - : mSet(&aSet), mPos(aPos) - { -#ifdef DEBUG - mVersion = mSet->mVersion; -#endif - MOZ_ASSERT(aPos <= kMaxBits); - if (aPos != kMaxBits && !mSet->contains(T(mPos))) - ++*this; - } - - ConstIterator(const ConstIterator& aOther) - : mSet(aOther.mSet), mPos(aOther.mPos) - { -#ifdef DEBUG - mVersion = aOther.mVersion; - checkVersion(); -#endif - } - - ConstIterator(ConstIterator&& aOther) - : mSet(aOther.mSet), mPos(aOther.mPos) - { -#ifdef DEBUG - mVersion = aOther.mVersion; - checkVersion(); -#endif - aOther.mSet = nullptr; - } - - ~ConstIterator() { - checkVersion(); - } - - bool operator==(const ConstIterator& other) { - MOZ_ASSERT(mSet == other.mSet); - checkVersion(); - return mPos == other.mPos; - } - - bool operator!=(const ConstIterator& other) { - return !(*this == other); - } - - T operator*() { - MOZ_ASSERT(mSet); - MOZ_ASSERT(mPos < kMaxBits); - MOZ_ASSERT(mSet->contains(T(mPos))); - checkVersion(); - return T(mPos); - } - - ConstIterator& operator++() { - MOZ_ASSERT(mSet); - MOZ_ASSERT(mPos < kMaxBits); - checkVersion(); - do { - mPos++; - } while (mPos < kMaxBits && !mSet->contains(T(mPos))); - return *this; - } - }; - - ConstIterator begin() const { - return ConstIterator(*this, 0); - } - - ConstIterator end() const { - return ConstIterator(*this, kMaxBits); - } - -private: - static uint32_t bitFor(T aEnum) - { - uint32_t bitNumber = (uint32_t)aEnum; - MOZ_ASSERT(bitNumber < kMaxBits); - return 1U << bitNumber; - } - - void initVersion() { -#ifdef DEBUG - mVersion = 0; -#endif - } - - void incVersion() { -#ifdef DEBUG - mVersion++; -#endif - } - - static const size_t kMaxBits = 32; - uint32_t mBitField; - -#ifdef DEBUG - uint64_t mVersion; -#endif -}; - -} // namespace mozilla - -#endif /* mozilla_EnumSet_h_*/ diff --git a/android/armeabi/include/spidermonkey/mozilla/EnumTypeTraits.h b/android/armeabi/include/spidermonkey/mozilla/EnumTypeTraits.h deleted file mode 100644 index 223eaf8c..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/EnumTypeTraits.h +++ /dev/null @@ -1,70 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Type traits for enums. */ - -#ifndef mozilla_EnumTypeTraits_h -#define mozilla_EnumTypeTraits_h - -#include <type_traits> - -namespace mozilla { - -namespace detail { - -template<size_t EnumSize, bool EnumSigned, size_t StorageSize, bool StorageSigned> -struct EnumFitsWithinHelper; - -// Signed enum, signed storage. -template<size_t EnumSize, size_t StorageSize> -struct EnumFitsWithinHelper<EnumSize, true, StorageSize, true> - : public std::integral_constant<bool, (EnumSize <= StorageSize)> -{}; - -// Signed enum, unsigned storage. -template<size_t EnumSize, size_t StorageSize> -struct EnumFitsWithinHelper<EnumSize, true, StorageSize, false> - : public std::integral_constant<bool, false> -{}; - -// Unsigned enum, signed storage. -template<size_t EnumSize, size_t StorageSize> -struct EnumFitsWithinHelper<EnumSize, false, StorageSize, true> - : public std::integral_constant<bool, (EnumSize * 2 <= StorageSize)> -{}; - -// Unsigned enum, unsigned storage. -template<size_t EnumSize, size_t StorageSize> -struct EnumFitsWithinHelper<EnumSize, false, StorageSize, false> - : public std::integral_constant<bool, (EnumSize <= StorageSize)> -{}; - -} // namespace detail - -/* - * Type trait that determines whether the enum type T can fit within the - * integral type Storage without data loss. This trait should be used with - * caution with an enum type whose underlying type has not been explicitly - * specified: for such enums, the C++ implementation is free to choose a type - * no smaller than int whose range encompasses all possible values of the enum. - * So for an enum with only small non-negative values, the underlying type may - * be either int or unsigned int, depending on the whims of the implementation. - */ -template<typename T, typename Storage> -struct EnumTypeFitsWithin - : public detail::EnumFitsWithinHelper< - sizeof(T), - std::is_signed<typename std::underlying_type<T>::type>::value, - sizeof(Storage), - std::is_signed<Storage>::value - > -{ - static_assert(std::is_enum<T>::value, "must provide an enum type"); - static_assert(std::is_integral<Storage>::value, "must provide an integral type"); -}; - -} // namespace mozilla - -#endif /* mozilla_EnumTypeTraits_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/EnumeratedArray.h b/android/armeabi/include/spidermonkey/mozilla/EnumeratedArray.h deleted file mode 100644 index 9e74b772..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/EnumeratedArray.h +++ /dev/null @@ -1,110 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* EnumeratedArray is like Array, but indexed by a typed enum. */ - -#ifndef mozilla_EnumeratedArray_h -#define mozilla_EnumeratedArray_h - -#include "mozilla/Array.h" -#include "mozilla/Move.h" - -namespace mozilla { - -/** - * EnumeratedArray is a fixed-size array container for use when an - * array is indexed by a specific enum class. - * - * This provides type safety by guarding at compile time against accidentally - * indexing such arrays with unrelated values. This also removes the need - * for manual casting when using a typed enum value to index arrays. - * - * Aside from the typing of indices, EnumeratedArray is similar to Array. - * - * Example: - * - * enum class AnimalSpecies { - * Cow, - * Sheep, - * Count - * }; - * - * EnumeratedArray<AnimalSpecies, AnimalSpecies::Count, int> headCount; - * - * headCount[AnimalSpecies::Cow] = 17; - * headCount[AnimalSpecies::Sheep] = 30; - * - */ -template<typename IndexType, - IndexType SizeAsEnumValue, - typename ValueType> -class EnumeratedArray -{ -public: - static const size_t kSize = size_t(SizeAsEnumValue); - -private: - typedef Array<ValueType, kSize> ArrayType; - - ArrayType mArray; - -public: - EnumeratedArray() {} - - template <typename... Args> - MOZ_IMPLICIT EnumeratedArray(Args&&... aArgs) - : mArray{mozilla::Forward<Args>(aArgs)...} - {} - - explicit EnumeratedArray(const EnumeratedArray& aOther) - { - for (size_t i = 0; i < kSize; i++) { - mArray[i] = aOther.mArray[i]; - } - } - - EnumeratedArray(EnumeratedArray&& aOther) - { - for (size_t i = 0; i < kSize; i++) { - mArray[i] = Move(aOther.mArray[i]); - } - } - - ValueType& operator[](IndexType aIndex) - { - return mArray[size_t(aIndex)]; - } - - const ValueType& operator[](IndexType aIndex) const - { - return mArray[size_t(aIndex)]; - } - - typedef typename ArrayType::iterator iterator; - typedef typename ArrayType::const_iterator const_iterator; - typedef typename ArrayType::reverse_iterator reverse_iterator; - typedef typename ArrayType::const_reverse_iterator const_reverse_iterator; - - // Methods for range-based for loops. - iterator begin() { return mArray.begin(); } - const_iterator begin() const { return mArray.begin(); } - const_iterator cbegin() const { return mArray.cbegin(); } - iterator end() { return mArray.end(); } - const_iterator end() const { return mArray.end(); } - const_iterator cend() const { return mArray.cend(); } - - // Methods for reverse iterating. - reverse_iterator rbegin() { return mArray.rbegin(); } - const_reverse_iterator rbegin() const { return mArray.rbegin(); } - const_reverse_iterator crbegin() const { return mArray.crbegin(); } - reverse_iterator rend() { return mArray.rend(); } - const_reverse_iterator rend() const { return mArray.rend(); } - const_reverse_iterator crend() const { return mArray.crend(); } -}; - -} // namespace mozilla - -#endif // mozilla_EnumeratedArray_h diff --git a/android/armeabi/include/spidermonkey/mozilla/EnumeratedRange.h b/android/armeabi/include/spidermonkey/mozilla/EnumeratedRange.h deleted file mode 100644 index b158f8a3..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/EnumeratedRange.h +++ /dev/null @@ -1,201 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Iterator over contiguous enum values */ - -/* - * Implements generator functions that create a range to iterate over the values - * of a scoped or unscoped enum. Unlike IntegerRange, which can only function on - * the underlying integral type, the elements of the generated sequence will - * have the type of the enum in question. - * - * Note that the enum values should be contiguous in the iterated range; - * unfortunately there exists no way for EnumeratedRange to enforce this - * either dynamically or at compile time. - */ - -#ifndef mozilla_EnumeratedRange_h -#define mozilla_EnumeratedRange_h - -#include <type_traits> - -#include "mozilla/ReverseIterator.h" - -namespace mozilla { - -namespace detail { - -template<typename EnumTypeT> -class EnumeratedIterator -{ -public: - typedef typename std::underlying_type<EnumTypeT>::type IntTypeT; - - template<typename EnumType> - explicit EnumeratedIterator(EnumType aCurrent) - : mCurrent(aCurrent) { } - - template<typename EnumType> - explicit EnumeratedIterator(const EnumeratedIterator<EnumType>& aOther) - : mCurrent(aOther.mCurrent) { } - - EnumTypeT operator*() const { return mCurrent; } - - /* Increment and decrement operators */ - - EnumeratedIterator& operator++() - { - mCurrent = EnumTypeT(IntTypeT(mCurrent) + IntTypeT(1)); - return *this; - } - EnumeratedIterator& operator--() - { - mCurrent = EnumTypeT(IntTypeT(mCurrent) - IntTypeT(1)); - return *this; - } - EnumeratedIterator operator++(int) - { - auto ret = *this; - mCurrent = EnumTypeT(IntTypeT(mCurrent) + IntTypeT(1)); - return ret; - } - EnumeratedIterator operator--(int) - { - auto ret = *this; - mCurrent = EnumTypeT(IntTypeT(mCurrent) - IntTypeT(1)); - return ret; - } - - /* Comparison operators */ - - template<typename EnumType> - friend bool operator==(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - template<typename EnumType> - friend bool operator!=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - template<typename EnumType> - friend bool operator<(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - template<typename EnumType> - friend bool operator<=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - template<typename EnumType> - friend bool operator>(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - template<typename EnumType> - friend bool operator>=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2); - -private: - EnumTypeT mCurrent; -}; - -template<typename EnumType> -bool operator==(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) -{ - return aIter1.mCurrent == aIter2.mCurrent; -} - -template<typename EnumType> -bool operator!=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) -{ - return aIter1.mCurrent != aIter2.mCurrent; -} - -template<typename EnumType> -bool operator<(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) -{ - return aIter1.mCurrent < aIter2.mCurrent; -} - -template<typename EnumType> -bool operator<=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) -{ - return aIter1.mCurrent <= aIter2.mCurrent; -} - -template<typename EnumType> -bool operator>(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) -{ - return aIter1.mCurrent > aIter2.mCurrent; -} - -template<typename EnumType> -bool operator>=(const EnumeratedIterator<EnumType>& aIter1, - const EnumeratedIterator<EnumType>& aIter2) -{ - return aIter1.mCurrent >= aIter2.mCurrent; -} - -template<typename EnumTypeT> -class EnumeratedRange -{ -public: - typedef EnumeratedIterator<EnumTypeT> iterator; - typedef EnumeratedIterator<EnumTypeT> const_iterator; - typedef ReverseIterator<iterator> reverse_iterator; - typedef ReverseIterator<const_iterator> const_reverse_iterator; - - template<typename EnumType> - EnumeratedRange(EnumType aBegin, EnumType aEnd) - : mBegin(aBegin), mEnd(aEnd) { } - - iterator begin() const { return iterator(mBegin); } - const_iterator cbegin() const { return begin(); } - iterator end() const { return iterator(mEnd); } - const_iterator cend() const { return end(); } - reverse_iterator rbegin() const { return reverse_iterator(mEnd); } - const_reverse_iterator crbegin() const { return rbegin(); } - reverse_iterator rend() const { return reverse_iterator(mBegin); } - const_reverse_iterator crend() const { return rend(); } - -private: - EnumTypeT mBegin; - EnumTypeT mEnd; -}; - -} // namespace detail - -#ifdef __GNUC__ -// Enums can have an unsigned underlying type, which makes some of the -// comparisons below always true or always false. Temporarily disable -// -Wtype-limits to avoid breaking -Werror builds. -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wtype-limits" -#endif - -// Create a range to iterate from aBegin to aEnd, exclusive. -template<typename EnumType> -inline detail::EnumeratedRange<EnumType> -MakeEnumeratedRange(EnumType aBegin, EnumType aEnd) -{ - MOZ_ASSERT(aBegin <= aEnd, "Cannot generate invalid, unbounded range!"); - return detail::EnumeratedRange<EnumType>(aBegin, aEnd); -} - -// Create a range to iterate from EnumType(0) to aEnd, exclusive. EnumType(0) -// should exist, but note that there is no way for us to ensure that it does! -template<typename EnumType> -inline detail::EnumeratedRange<EnumType> -MakeEnumeratedRange(EnumType aEnd) -{ - return MakeEnumeratedRange(EnumType(0), aEnd); -} - -#ifdef __GNUC__ -# pragma GCC diagnostic pop -#endif - -} // namespace mozilla - -#endif // mozilla_EnumeratedRange_h - diff --git a/android/armeabi/include/spidermonkey/mozilla/FastBernoulliTrial.h b/android/armeabi/include/spidermonkey/mozilla/FastBernoulliTrial.h deleted file mode 100644 index 7e38b70a..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/FastBernoulliTrial.h +++ /dev/null @@ -1,379 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_FastBernoulliTrial_h -#define mozilla_FastBernoulliTrial_h - -#include "mozilla/Assertions.h" -#include "mozilla/XorShift128PlusRNG.h" - -#include <cmath> -#include <stdint.h> - -namespace mozilla { - -/** - * class FastBernoulliTrial: Efficient sampling with uniform probability - * - * When gathering statistics about a program's behavior, we may be observing - * events that occur very frequently (e.g., function calls or memory - * allocations) and we may be gathering information that is somewhat expensive - * to produce (e.g., call stacks). Sampling all the events could have a - * significant impact on the program's performance. - * - * Why not just sample every N'th event? This technique is called "systematic - * sampling"; it's simple and efficient, and it's fine if we imagine a - * patternless stream of events. But what if we're sampling allocations, and the - * program happens to have a loop where each iteration does exactly N - * allocations? You would end up sampling the same allocation every time through - * the loop; the entire rest of the loop becomes invisible to your measurements! - * More generally, if each iteration does M allocations, and M and N have any - * common divisor at all, most allocation sites will never be sampled. If - * they're both even, say, the odd-numbered allocations disappear from your - * results. - * - * Ideally, we'd like each event to have some probability P of being sampled, - * independent of its neighbors and of its position in the sequence. This is - * called "Bernoulli sampling", and it doesn't suffer from any of the problems - * mentioned above. - * - * One disadvantage of Bernoulli sampling is that you can't be sure exactly how - * many samples you'll get: technically, it's possible that you might sample - * none of them, or all of them. But if the number of events N is large, these - * aren't likely outcomes; you can generally expect somewhere around P * N - * events to be sampled. - * - * The other disadvantage of Bernoulli sampling is that you have to generate a - * random number for every event, which can be slow. - * - * [significant pause] - * - * BUT NOT WITH THIS CLASS! FastBernoulliTrial lets you do true Bernoulli - * sampling, while generating a fresh random number only when we do decide to - * sample an event, not on every trial. When it decides not to sample, a call to - * |FastBernoulliTrial::trial| is nothing but decrementing a counter and - * comparing it to zero. So the lower your sampling probability is, the less - * overhead FastBernoulliTrial imposes. - * - * Probabilities of 0 and 1 are handled efficiently. (In neither case need we - * ever generate a random number at all.) - * - * The essential API: - * - * - FastBernoulliTrial(double P) - * Construct an instance that selects events with probability P. - * - * - FastBernoulliTrial::trial() - * Return true with probability P. Call this each time an event occurs, to - * decide whether to sample it or not. - * - * - FastBernoulliTrial::trial(size_t n) - * Equivalent to calling trial() |n| times, and returning true if any of those - * calls do. However, like trial, this runs in fast constant time. - * - * What is this good for? In some applications, some events are "bigger" than - * others. For example, large allocations are more significant than small - * allocations. Perhaps we'd like to imagine that we're drawing allocations - * from a stream of bytes, and performing a separate Bernoulli trial on every - * byte from the stream. We can accomplish this by calling |t.trial(S)| for - * the number of bytes S, and sampling the event if that returns true. - * - * Of course, this style of sampling needs to be paired with analysis and - * presentation that makes the size of the event apparent, lest trials with - * large values for |n| appear to be indistinguishable from those with small - * values for |n|. - */ -class FastBernoulliTrial { - /* - * This comment should just read, "Generate skip counts with a geometric - * distribution", and leave everyone to go look that up and see why it's the - * right thing to do, if they don't know already. - * - * BUT IF YOU'RE CURIOUS, COMMENTS ARE FREE... - * - * Instead of generating a fresh random number for every trial, we can - * randomly generate a count of how many times we should return false before - * the next time we return true. We call this a "skip count". Once we've - * returned true, we generate a fresh skip count, and begin counting down - * again. - * - * Here's an awesome fact: by exercising a little care in the way we generate - * skip counts, we can produce results indistinguishable from those we would - * get "rolling the dice" afresh for every trial. - * - * In short, skip counts in Bernoulli trials of probability P obey a geometric - * distribution. If a random variable X is uniformly distributed from [0..1), - * then std::floor(std::log(X) / std::log(1-P)) has the appropriate geometric - * distribution for the skip counts. - * - * Why that formula? - * - * Suppose we're to return |true| with some probability P, say, 0.3. Spread - * all possible futures along a line segment of length 1. In portion P of - * those cases, we'll return true on the next call to |trial|; the skip count - * is 0. For the remaining portion 1-P of cases, the skip count is 1 or more. - * - * skip: 0 1 or more - * |------------------^-----------------------------------------| - * portion: 0.3 0.7 - * P 1-P - * - * But the "1 or more" section of the line is subdivided the same way: *within - * that section*, in portion P the second call to |trial()| returns true, and in - * portion 1-P it returns false a second time; the skip count is two or more. - * So we return true on the second call in proportion 0.7 * 0.3, and skip at - * least the first two in proportion 0.7 * 0.7. - * - * skip: 0 1 2 or more - * |------------------^------------^----------------------------| - * portion: 0.3 0.7 * 0.3 0.7 * 0.7 - * P (1-P)*P (1-P)^2 - * - * We can continue to subdivide: - * - * skip >= 0: |------------------------------------------------- (1-P)^0 --| - * skip >= 1: | ------------------------------- (1-P)^1 --| - * skip >= 2: | ------------------ (1-P)^2 --| - * skip >= 3: | ^ ---------- (1-P)^3 --| - * skip >= 4: | . --- (1-P)^4 --| - * . - * ^X, see below - * - * In other words, the likelihood of the next n calls to |trial| returning - * false is (1-P)^n. The longer a run we require, the more the likelihood - * drops. Further calls may return false too, but this is the probability - * we'll skip at least n. - * - * This is interesting, because we can pick a point along this line segment - * and see which skip count's range it falls within; the point X above, for - * example, is within the ">= 2" range, but not within the ">= 3" range, so it - * designates a skip count of 2. So if we pick points on the line at random - * and use the skip counts they fall under, that will be indistinguishable - * from generating a fresh random number between 0 and 1 for each trial and - * comparing it to P. - * - * So to find the skip count for a point X, we must ask: To what whole power - * must we raise 1-P such that we include X, but the next power would exclude - * it? This is exactly std::floor(std::log(X) / std::log(1-P)). - * - * Our algorithm is then, simply: When constructed, compute an initial skip - * count. Return false from |trial| that many times, and then compute a new skip - * count. - * - * For a call to |trial(n)|, if the skip count is greater than n, return false - * and subtract n from the skip count. If the skip count is less than n, - * return true and compute a new skip count. Since each trial is independent, - * it doesn't matter by how much n overshoots the skip count; we can actually - * compute a new skip count at *any* time without affecting the distribution. - * This is really beautiful. - */ - public: - /** - * Construct a fast Bernoulli trial generator. Calls to |trial()| return true - * with probability |aProbability|. Use |aState0| and |aState1| to seed the - * random number generator; both may not be zero. - */ - FastBernoulliTrial(double aProbability, uint64_t aState0, uint64_t aState1) - : mProbability(0) - , mInvLogNotProbability(0) - , mGenerator(aState0, aState1) - , mSkipCount(0) - { - setProbability(aProbability); - } - - /** - * Return true with probability |mProbability|. Call this each time an event - * occurs, to decide whether to sample it or not. The lower |mProbability| is, - * the faster this function runs. - */ - bool trial() { - if (mSkipCount) { - mSkipCount--; - return false; - } - - return chooseSkipCount(); - } - - /** - * Equivalent to calling trial() |n| times, and returning true if any of those - * calls do. However, like trial, this runs in fast constant time. - * - * What is this good for? In some applications, some events are "bigger" than - * others. For example, large allocations are more significant than small - * allocations. Perhaps we'd like to imagine that we're drawing allocations - * from a stream of bytes, and performing a separate Bernoulli trial on every - * byte from the stream. We can accomplish this by calling |t.trial(S)| for - * the number of bytes S, and sampling the event if that returns true. - * - * Of course, this style of sampling needs to be paired with analysis and - * presentation that makes the "size" of the event apparent, lest trials with - * large values for |n| appear to be indistinguishable from those with small - * values for |n|, despite being potentially much more likely to be sampled. - */ - bool trial(size_t aCount) { - if (mSkipCount > aCount) { - mSkipCount -= aCount; - return false; - } - - return chooseSkipCount(); - } - - void setRandomState(uint64_t aState0, uint64_t aState1) { - mGenerator.setState(aState0, aState1); - } - - void setProbability(double aProbability) { - MOZ_ASSERT(0 <= aProbability && aProbability <= 1); - mProbability = aProbability; - if (0 < mProbability && mProbability < 1) { - /* - * Let's look carefully at how this calculation plays out in floating- - * point arithmetic. We'll assume IEEE, but the final C++ code we arrive - * at would still be fine if our numbers were mathematically perfect. So, - * while we've considered IEEE's edge cases, we haven't done anything that - * should be actively bad when using other representations. - * - * (In the below, read comparisons as exact mathematical comparisons: when - * we say something "equals 1", that means it's exactly equal to 1. We - * treat approximation using intervals with open boundaries: saying a - * value is in (0,1) doesn't specify how close to 0 or 1 the value gets. - * When we use closed boundaries like [2**-53, 1], we're careful to ensure - * the boundary values are actually representable.) - * - * - After the comparison above, we know mProbability is in (0,1). - * - * - The gaps below 1 are 2**-53, so that interval is (0, 1-2**-53]. - * - * - Because the floating-point gaps near 1 are wider than those near - * zero, there are many small positive doubles ε such that 1-ε rounds to - * exactly 1. However, 2**-53 can be represented exactly. So - * 1-mProbability is in [2**-53, 1]. - * - * - log(1 - mProbability) is thus in (-37, 0]. - * - * That range includes zero, but when we use mInvLogNotProbability, it - * would be helpful if we could trust that it's negative. So when log(1 - * - mProbability) is 0, we'll just set mProbability to 0, so that - * mInvLogNotProbability is not used in chooseSkipCount. - * - * - How much of the range of mProbability does this cause us to ignore? - * The only value for which log returns 0 is exactly 1; the slope of log - * at 1 is 1, so for small ε such that 1 - ε != 1, log(1 - ε) is -ε, - * never 0. The gaps near one are larger than the gaps near zero, so if - * 1 - ε wasn't 1, then -ε is representable. So if log(1 - mProbability) - * isn't 0, then 1 - mProbability isn't 1, which means that mProbability - * is at least 2**-53, as discussed earlier. This is a sampling - * likelihood of roughly one in ten trillion, which is unlikely to be - * distinguishable from zero in practice. - * - * So by forbidding zero, we've tightened our range to (-37, -2**-53]. - * - * - Finally, 1 / log(1 - mProbability) is in [-2**53, -1/37). This all - * falls readily within the range of an IEEE double. - * - * ALL THAT HAVING BEEN SAID: here are the five lines of actual code: - */ - double logNotProbability = std::log(1 - mProbability); - if (logNotProbability == 0.0) - mProbability = 0.0; - else - mInvLogNotProbability = 1 / logNotProbability; - } - - chooseSkipCount(); - } - - private: - /* The likelihood that any given call to |trial| should return true. */ - double mProbability; - - /* - * The value of 1/std::log(1 - mProbability), cached for repeated use. - * - * If mProbability is exactly 0 or exactly 1, we don't use this value. - * Otherwise, we guarantee this value is in the range [-2**53, -1/37), i.e. - * definitely negative, as required by chooseSkipCount. See setProbability for - * the details. - */ - double mInvLogNotProbability; - - /* Our random number generator. */ - non_crypto::XorShift128PlusRNG mGenerator; - - /* The number of times |trial| should return false before next returning true. */ - size_t mSkipCount; - - /* - * Choose the next skip count. This also returns the value that |trial| should - * return, since we have to check for the extreme values for mProbability - * anyway, and |trial| should never return true at all when mProbability is 0. - */ - bool chooseSkipCount() { - /* - * If the probability is 1.0, every call to |trial| returns true. Make sure - * mSkipCount is 0. - */ - if (mProbability == 1.0) { - mSkipCount = 0; - return true; - } - - /* - * If the probabilility is zero, |trial| never returns true. Don't bother us - * for a while. - */ - if (mProbability == 0.0) { - mSkipCount = SIZE_MAX; - return false; - } - - /* - * What sorts of values can this call to std::floor produce? - * - * Since mGenerator.nextDouble returns a value in [0, 1-2**-53], std::log - * returns a value in the range [-infinity, -2**-53], all negative. Since - * mInvLogNotProbability is negative (see its comments), the product is - * positive and possibly infinite. std::floor returns +infinity unchanged. - * So the result will always be positive. - * - * Converting a double to an integer that is out of range for that integer - * is undefined behavior, so we must clamp our result to SIZE_MAX, to ensure - * we get an acceptable value for mSkipCount. - * - * The clamp is written carefully. Note that if we had said: - * - * if (skipCount > SIZE_MAX) - * skipCount = SIZE_MAX; - * - * that leads to undefined behavior 64-bit machines: SIZE_MAX coerced to - * double is 2^64, not 2^64-1, so this doesn't actually set skipCount to a - * value that can be safely assigned to mSkipCount. - * - * Jakub Oleson cleverly suggested flipping the sense of the comparison: if - * we require that skipCount < SIZE_MAX, then because of the gaps (2048) - * between doubles at that magnitude, the highest double less than 2^64 is - * 2^64 - 2048, which is fine to store in a size_t. - * - * (On 32-bit machines, all size_t values can be represented exactly in - * double, so all is well.) - */ - double skipCount = std::floor(std::log(mGenerator.nextDouble()) - * mInvLogNotProbability); - if (skipCount < SIZE_MAX) - mSkipCount = skipCount; - else - mSkipCount = SIZE_MAX; - - return true; - } -}; - -} /* namespace mozilla */ - -#endif /* mozilla_FastBernoulliTrial_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/FloatingPoint.h b/android/armeabi/include/spidermonkey/mozilla/FloatingPoint.h deleted file mode 100644 index 59afccd1..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/FloatingPoint.h +++ /dev/null @@ -1,479 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Various predicates and operations on IEEE-754 floating point types. */ - -#ifndef mozilla_FloatingPoint_h -#define mozilla_FloatingPoint_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Casting.h" -#include "mozilla/MathAlgorithms.h" -#include "mozilla/Types.h" - -#include <stdint.h> - -namespace mozilla { - -/* - * It's reasonable to ask why we have this header at all. Don't isnan, - * copysign, the built-in comparison operators, and the like solve these - * problems? Unfortunately, they don't. We've found that various compilers - * (MSVC, MSVC when compiling with PGO, and GCC on OS X, at least) miscompile - * the standard methods in various situations, so we can't use them. Some of - * these compilers even have problems compiling seemingly reasonable bitwise - * algorithms! But with some care we've found algorithms that seem to not - * trigger those compiler bugs. - * - * For the aforementioned reasons, be very wary of making changes to any of - * these algorithms. If you must make changes, keep a careful eye out for - * compiler bustage, particularly PGO-specific bustage. - */ - -struct FloatTypeTraits -{ - typedef uint32_t Bits; - - static const unsigned kExponentBias = 127; - static const unsigned kExponentShift = 23; - - static const Bits kSignBit = 0x80000000UL; - static const Bits kExponentBits = 0x7F800000UL; - static const Bits kSignificandBits = 0x007FFFFFUL; -}; - -struct DoubleTypeTraits -{ - typedef uint64_t Bits; - - static const unsigned kExponentBias = 1023; - static const unsigned kExponentShift = 52; - - static const Bits kSignBit = 0x8000000000000000ULL; - static const Bits kExponentBits = 0x7ff0000000000000ULL; - static const Bits kSignificandBits = 0x000fffffffffffffULL; -}; - -template<typename T> struct SelectTrait; -template<> struct SelectTrait<float> : public FloatTypeTraits {}; -template<> struct SelectTrait<double> : public DoubleTypeTraits {}; - -/* - * This struct contains details regarding the encoding of floating-point - * numbers that can be useful for direct bit manipulation. As of now, the - * template parameter has to be float or double. - * - * The nested typedef |Bits| is the unsigned integral type with the same size - * as T: uint32_t for float and uint64_t for double (static assertions - * double-check these assumptions). - * - * kExponentBias is the offset that is subtracted from the exponent when - * computing the value, i.e. one plus the opposite of the mininum possible - * exponent. - * kExponentShift is the shift that one needs to apply to retrieve the - * exponent component of the value. - * - * kSignBit contains a bits mask. Bit-and-ing with this mask will result in - * obtaining the sign bit. - * kExponentBits contains the mask needed for obtaining the exponent bits and - * kSignificandBits contains the mask needed for obtaining the significand - * bits. - * - * Full details of how floating point number formats are encoded are beyond - * the scope of this comment. For more information, see - * http://en.wikipedia.org/wiki/IEEE_floating_point - * http://en.wikipedia.org/wiki/Floating_point#IEEE_754:_floating_point_in_modern_computers - */ -template<typename T> -struct FloatingPoint : public SelectTrait<T> -{ - typedef SelectTrait<T> Base; - typedef typename Base::Bits Bits; - - static_assert((Base::kSignBit & Base::kExponentBits) == 0, - "sign bit shouldn't overlap exponent bits"); - static_assert((Base::kSignBit & Base::kSignificandBits) == 0, - "sign bit shouldn't overlap significand bits"); - static_assert((Base::kExponentBits & Base::kSignificandBits) == 0, - "exponent bits shouldn't overlap significand bits"); - - static_assert((Base::kSignBit | Base::kExponentBits | Base::kSignificandBits) == - ~Bits(0), - "all bits accounted for"); - - /* - * These implementations assume float/double are 32/64-bit single/double - * format number types compatible with the IEEE-754 standard. C++ don't - * require this to be the case. But we required this in implementations of - * these algorithms that preceded this header, so we shouldn't break anything - * if we keep doing so. - */ - static_assert(sizeof(T) == sizeof(Bits), "Bits must be same size as T"); -}; - -/** Determines whether a float/double is NaN. */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -IsNaN(T aValue) -{ - /* - * A float/double is NaN if all exponent bits are 1 and the significand - * contains at least one non-zero bit. - */ - typedef FloatingPoint<T> Traits; - typedef typename Traits::Bits Bits; - return (BitwiseCast<Bits>(aValue) & Traits::kExponentBits) == Traits::kExponentBits && - (BitwiseCast<Bits>(aValue) & Traits::kSignificandBits) != 0; -} - -/** Determines whether a float/double is +Infinity or -Infinity. */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -IsInfinite(T aValue) -{ - /* Infinities have all exponent bits set to 1 and an all-0 significand. */ - typedef FloatingPoint<T> Traits; - typedef typename Traits::Bits Bits; - Bits bits = BitwiseCast<Bits>(aValue); - return (bits & ~Traits::kSignBit) == Traits::kExponentBits; -} - -/** Determines whether a float/double is not NaN or infinite. */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -IsFinite(T aValue) -{ - /* - * NaN and Infinities are the only non-finite floats/doubles, and both have - * all exponent bits set to 1. - */ - typedef FloatingPoint<T> Traits; - typedef typename Traits::Bits Bits; - Bits bits = BitwiseCast<Bits>(aValue); - return (bits & Traits::kExponentBits) != Traits::kExponentBits; -} - -/** - * Determines whether a float/double is negative or -0. It is an error - * to call this method on a float/double which is NaN. - */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -IsNegative(T aValue) -{ - MOZ_ASSERT(!IsNaN(aValue), "NaN does not have a sign"); - - /* The sign bit is set if the double is negative. */ - typedef FloatingPoint<T> Traits; - typedef typename Traits::Bits Bits; - Bits bits = BitwiseCast<Bits>(aValue); - return (bits & Traits::kSignBit) != 0; -} - -/** Determines whether a float/double represents -0. */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -IsNegativeZero(T aValue) -{ - /* Only the sign bit is set if the value is -0. */ - typedef FloatingPoint<T> Traits; - typedef typename Traits::Bits Bits; - Bits bits = BitwiseCast<Bits>(aValue); - return bits == Traits::kSignBit; -} - -/** Determines wether a float/double represents +0. */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -IsPositiveZero(T aValue) -{ - /* All bits are zero if the value is +0. */ - typedef FloatingPoint<T> Traits; - typedef typename Traits::Bits Bits; - Bits bits = BitwiseCast<Bits>(aValue); - return bits == 0; -} - -/** - * Returns 0 if a float/double is NaN or infinite; - * otherwise, the float/double is returned. - */ -template<typename T> -static MOZ_ALWAYS_INLINE T -ToZeroIfNonfinite(T aValue) -{ - return IsFinite(aValue) ? aValue : 0; -} - -/** - * Returns the exponent portion of the float/double. - * - * Zero is not special-cased, so ExponentComponent(0.0) is - * -int_fast16_t(Traits::kExponentBias). - */ -template<typename T> -static MOZ_ALWAYS_INLINE int_fast16_t -ExponentComponent(T aValue) -{ - /* - * The exponent component of a float/double is an unsigned number, biased - * from its actual value. Subtract the bias to retrieve the actual exponent. - */ - typedef FloatingPoint<T> Traits; - typedef typename Traits::Bits Bits; - Bits bits = BitwiseCast<Bits>(aValue); - return int_fast16_t((bits & Traits::kExponentBits) >> Traits::kExponentShift) - - int_fast16_t(Traits::kExponentBias); -} - -/** Returns +Infinity. */ -template<typename T> -static MOZ_ALWAYS_INLINE T -PositiveInfinity() -{ - /* - * Positive infinity has all exponent bits set, sign bit set to 0, and no - * significand. - */ - typedef FloatingPoint<T> Traits; - return BitwiseCast<T>(Traits::kExponentBits); -} - -/** Returns -Infinity. */ -template<typename T> -static MOZ_ALWAYS_INLINE T -NegativeInfinity() -{ - /* - * Negative infinity has all exponent bits set, sign bit set to 1, and no - * significand. - */ - typedef FloatingPoint<T> Traits; - return BitwiseCast<T>(Traits::kSignBit | Traits::kExponentBits); -} - -/** - * Computes the bit pattern for a NaN with the specified sign bit and - * significand bits. - */ -template<typename T, - int SignBit, - typename FloatingPoint<T>::Bits Significand> -struct SpecificNaNBits -{ - using Traits = FloatingPoint<T>; - - static_assert(SignBit == 0 || SignBit == 1, "bad sign bit"); - static_assert((Significand & ~Traits::kSignificandBits) == 0, - "significand must only have significand bits set"); - static_assert(Significand & Traits::kSignificandBits, - "significand must be nonzero"); - - static constexpr typename Traits::Bits value = - (SignBit * Traits::kSignBit) | Traits::kExponentBits | Significand; -}; - -/** - * Constructs a NaN value with the specified sign bit and significand bits. - * - * There is also a variant that returns the value directly. In most cases, the - * two variants should be identical. However, in the specific case of x86 - * chips, the behavior differs: returning floating-point values directly is done - * through the x87 stack, and x87 loads and stores turn signaling NaNs into - * quiet NaNs... silently. Returning floating-point values via outparam, - * however, is done entirely within the SSE registers when SSE2 floating-point - * is enabled in the compiler, which has semantics-preserving behavior you would - * expect. - * - * If preserving the distinction between signaling NaNs and quiet NaNs is - * important to you, you should use the outparam version. In all other cases, - * you should use the direct return version. - */ -template<typename T> -static MOZ_ALWAYS_INLINE void -SpecificNaN(int signbit, typename FloatingPoint<T>::Bits significand, T* result) -{ - typedef FloatingPoint<T> Traits; - MOZ_ASSERT(signbit == 0 || signbit == 1); - MOZ_ASSERT((significand & ~Traits::kSignificandBits) == 0); - MOZ_ASSERT(significand & Traits::kSignificandBits); - - BitwiseCast<T>((signbit ? Traits::kSignBit : 0) | - Traits::kExponentBits | - significand, - result); - MOZ_ASSERT(IsNaN(*result)); -} - -template<typename T> -static MOZ_ALWAYS_INLINE T -SpecificNaN(int signbit, typename FloatingPoint<T>::Bits significand) -{ - T t; - SpecificNaN(signbit, significand, &t); - return t; -} - -/** Computes the smallest non-zero positive float/double value. */ -template<typename T> -static MOZ_ALWAYS_INLINE T -MinNumberValue() -{ - typedef FloatingPoint<T> Traits; - typedef typename Traits::Bits Bits; - return BitwiseCast<T>(Bits(1)); -} - -/** - * If aValue is equal to some int32_t value, set *aInt32 to that value and - * return true; otherwise return false. - * - * Note that negative zero is "equal" to zero here. To test whether a value can - * be losslessly converted to int32_t and back, use NumberIsInt32 instead. - */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -NumberEqualsInt32(T aValue, int32_t* aInt32) -{ - /* - * XXX Casting a floating-point value that doesn't truncate to int32_t, to - * int32_t, induces undefined behavior. We should definitely fix this - * (bug 744965), but as apparently it "works" in practice, it's not a - * pressing concern now. - */ - return aValue == (*aInt32 = int32_t(aValue)); -} - -/** - * If d can be converted to int32_t and back to an identical double value, - * set *aInt32 to that value and return true; otherwise return false. - * - * The difference between this and NumberEqualsInt32 is that this method returns - * false for negative zero. - */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -NumberIsInt32(T aValue, int32_t* aInt32) -{ - return !IsNegativeZero(aValue) && NumberEqualsInt32(aValue, aInt32); -} - -/** - * Computes a NaN value. Do not use this method if you depend upon a particular - * NaN value being returned. - */ -template<typename T> -static MOZ_ALWAYS_INLINE T -UnspecifiedNaN() -{ - /* - * If we can use any quiet NaN, we might as well use the all-ones NaN, - * since it's cheap to materialize on common platforms (such as x64, where - * this value can be represented in a 32-bit signed immediate field, allowing - * it to be stored to memory in a single instruction). - */ - typedef FloatingPoint<T> Traits; - return SpecificNaN<T>(1, Traits::kSignificandBits); -} - -/** - * Compare two doubles for equality, *without* equating -0 to +0, and equating - * any NaN value to any other NaN value. (The normal equality operators equate - * -0 with +0, and they equate NaN to no other value.) - */ -template<typename T> -static inline bool -NumbersAreIdentical(T aValue1, T aValue2) -{ - typedef FloatingPoint<T> Traits; - typedef typename Traits::Bits Bits; - if (IsNaN(aValue1)) { - return IsNaN(aValue2); - } - return BitwiseCast<Bits>(aValue1) == BitwiseCast<Bits>(aValue2); -} - -namespace detail { - -template<typename T> -struct FuzzyEqualsEpsilon; - -template<> -struct FuzzyEqualsEpsilon<float> -{ - // A number near 1e-5 that is exactly representable in a float. - static float value() { return 1.0f / (1 << 17); } -}; - -template<> -struct FuzzyEqualsEpsilon<double> -{ - // A number near 1e-12 that is exactly representable in a double. - static double value() { return 1.0 / (1LL << 40); } -}; - -} // namespace detail - -/** - * Compare two floating point values for equality, modulo rounding error. That - * is, the two values are considered equal if they are both not NaN and if they - * are less than or equal to aEpsilon apart. The default value of aEpsilon is - * near 1e-5. - * - * For most scenarios you will want to use FuzzyEqualsMultiplicative instead, - * as it is more reasonable over the entire range of floating point numbers. - * This additive version should only be used if you know the range of the - * numbers you are dealing with is bounded and stays around the same order of - * magnitude. - */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -FuzzyEqualsAdditive(T aValue1, T aValue2, - T aEpsilon = detail::FuzzyEqualsEpsilon<T>::value()) -{ - static_assert(IsFloatingPoint<T>::value, "floating point type required"); - return Abs(aValue1 - aValue2) <= aEpsilon; -} - -/** - * Compare two floating point values for equality, allowing for rounding error - * relative to the magnitude of the values. That is, the two values are - * considered equal if they are both not NaN and they are less than or equal to - * some aEpsilon apart, where the aEpsilon is scaled by the smaller of the two - * argument values. - * - * In most cases you will want to use this rather than FuzzyEqualsAdditive, as - * this function effectively masks out differences in the bottom few bits of - * the floating point numbers being compared, regardless of what order of - * magnitude those numbers are at. - */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -FuzzyEqualsMultiplicative(T aValue1, T aValue2, - T aEpsilon = detail::FuzzyEqualsEpsilon<T>::value()) -{ - static_assert(IsFloatingPoint<T>::value, "floating point type required"); - // can't use std::min because of bug 965340 - T smaller = Abs(aValue1) < Abs(aValue2) ? Abs(aValue1) : Abs(aValue2); - return Abs(aValue1 - aValue2) <= aEpsilon * smaller; -} - -/** - * Returns true if the given value can be losslessly represented as an IEEE-754 - * single format number, false otherwise. All NaN values are considered - * representable (notwithstanding that the exact bit pattern of a double format - * NaN value can't be exactly represented in single format). - * - * This function isn't inlined to avoid buggy optimizations by MSVC. - */ -MOZ_MUST_USE -extern MFBT_API bool -IsFloat32Representable(double aFloat32); - -} /* namespace mozilla */ - -#endif /* mozilla_FloatingPoint_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Function.h b/android/armeabi/include/spidermonkey/mozilla/Function.h deleted file mode 100644 index d6de9c83..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Function.h +++ /dev/null @@ -1,223 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A type-erased callable wrapper. */ - -#ifndef mozilla_Function_h -#define mozilla_Function_h - -#include "mozilla/Attributes.h" // for MOZ_IMPLICIT -#include "mozilla/Move.h" -#include "mozilla/RefCounted.h" -#include "mozilla/RefPtr.h" - -// |function<Signature>| is a wrapper that can hold any type of callable -// object that can be invoked in a way that's compatible with |Signature|. -// The standard "type erasure" technique is used to avoid the type of the -// wrapper depending on the concrete type of the wrapped callable. -// -// Supported callable types include non-member functions, static member -// functions, and function objects (that is to say, objects with an overloaded -// call operator; this includes C++11 lambdas). Member functions aren't -// directly supported; they first need to be wrapped into a function object -// using |std::mem_fn()| or an equivalent. -// -// |Signature| is a type of the form |ReturnType(Arguments...)|. Syntactically, -// this is a function type; it's not used in any way other than serving as a -// vehicle to encode the return and argument types into a single type. -// -// |function| is default-constructible. A default-constructed instance is -// considered "empty". Invoking an empty instance is undefined behaviour. -// An empty instance can be populated with a callable by assigning to it. -// -// This class is intended to provide functionality similar to the C++11 -// standard library class |std::function|. - -namespace mozilla { - -namespace detail { - -template<typename ReturnType, typename... Arguments> -class FunctionImplBase : public mozilla::RefCounted<FunctionImplBase<ReturnType, Arguments...>> -{ -public: - MOZ_DECLARE_REFCOUNTED_TYPENAME(FunctionImplBase) - - virtual ~FunctionImplBase() {} - virtual ReturnType call(Arguments... aArguments) = 0; -}; - -// Normal Callable Object. -template <typename Callable, typename ReturnType, typename... Arguments> -class FunctionImpl : public FunctionImplBase<ReturnType, Arguments...> -{ - public: - explicit FunctionImpl(const Callable& aCallable) - : mCallable(aCallable) {} - - ReturnType call(Arguments... aArguments) override - { - return mCallable(Forward<Arguments>(aArguments)...); - } - private: - Callable mCallable; -}; - -// Base class for passing pointer to member function. -template <typename Callable, typename ReturnType, typename... Arguments> -class MemberFunctionImplBase : public FunctionImplBase<ReturnType, Arguments...> -{ -public: - explicit MemberFunctionImplBase(const Callable& aCallable) - : mCallable(aCallable) {} - - ReturnType call(Arguments... aArguments) override - { - return callInternal(Forward<Arguments>(aArguments)...); - } -private: - template<typename ThisType, typename... Args> - ReturnType callInternal(ThisType* aThis, Args&&... aArguments) - { - return (aThis->*mCallable)(Forward<Args>(aArguments)...); - } - - template<typename ThisType, typename... Args> - ReturnType callInternal(ThisType&& aThis, Args&&... aArguments) - { - return (aThis.*mCallable)(Forward<Args>(aArguments)...); - } - Callable mCallable; -}; - -// For non-const member function specialization of FunctionImpl. -template <typename ThisType, typename... Args, typename ReturnType, typename... Arguments> -class FunctionImpl<ReturnType(ThisType::*)(Args...), - ReturnType, Arguments...> - : public MemberFunctionImplBase<ReturnType(ThisType::*)(Args...), - ReturnType, Arguments...> -{ -public: - explicit FunctionImpl(ReturnType(ThisType::*aMemberFunc)(Args...)) - : MemberFunctionImplBase<ReturnType(ThisType::*)(Args...), - ReturnType, Arguments...>(aMemberFunc) - {} -}; - -// For const member function specialization of FunctionImpl. -template <typename ThisType, typename... Args, typename ReturnType, typename... Arguments> -class FunctionImpl<ReturnType(ThisType::*)(Args...) const, - ReturnType, Arguments...> - : public MemberFunctionImplBase<ReturnType(ThisType::*)(Args...) const, - ReturnType, Arguments...> -{ -public: - explicit FunctionImpl(ReturnType(ThisType::*aConstMemberFunc)(Args...) const) - : MemberFunctionImplBase<ReturnType(ThisType::*)(Args...) const, - ReturnType, Arguments...>(aConstMemberFunc) - {} -}; - -} // namespace detail - -// The primary template is never defined. As |Signature| is required to be -// of the form |ReturnType(Arguments...)|, we only define a partial -// specialization that matches this form. This allows us to use |ReturnType| -// and |Arguments| in the definition of the specialization without having to -// introspect |Signature|. -template<typename Signature> -class function; - -template<typename ReturnType, typename... Arguments> -class function<ReturnType(Arguments...)> -{ -public: - function() {} - - // This constructor is implicit to match the interface of |std::function|. - template <typename Callable> - MOZ_IMPLICIT function(const Callable& aCallable) - : mImpl(new detail::FunctionImpl<Callable, ReturnType, Arguments...>(aCallable)) - {} - MOZ_IMPLICIT function(const function& aFunction) - : mImpl(aFunction.mImpl) - {} - MOZ_IMPLICIT function(decltype(nullptr)) - {} - - // Move constructor and move assingment operator. - // These should be generated automatically, but MSVC doesn't do that yet. - function(function&& aOther) : mImpl(Move(aOther.mImpl)) {} - function& operator=(function&& aOther) { - mImpl = Move(aOther.mImpl); - return *this; - } - - template <typename Callable> - function& operator=(const Callable& aCallable) - { - mImpl = new detail::FunctionImpl<Callable, ReturnType, Arguments...>(aCallable); - return *this; - } - function& operator=(const function& aFunction) - { - mImpl = aFunction.mImpl; - return *this; - } - function& operator=(decltype(nullptr)) - { - mImpl = nullptr; - return *this; - } - - template<typename... Args> - ReturnType operator()(Args&&... aArguments) const - { - MOZ_ASSERT(mImpl); - return mImpl->call(Forward<Args>(aArguments)...); - } - - explicit operator bool() const - { - return bool(mImpl); - } - -private: - // TODO: Consider implementing a small object optimization. - RefPtr<detail::FunctionImplBase<ReturnType, Arguments...>> mImpl; -}; - -template<typename Signature> -bool -operator==(const function<Signature>& aX, decltype(nullptr)) -{ - return !aX; -} - -template<typename Signature> -bool -operator==(decltype(nullptr), const function<Signature>& aX) -{ - return !aX; -} - -template<typename Signature> -bool -operator!=(const function<Signature>& aX, decltype(nullptr)) -{ - return bool(aX); -} - -template<typename Signature> -bool -operator!=(decltype(nullptr), const function<Signature>& aX) -{ - return bool(aX); -} - -} // namespace mozilla - -#endif /* mozilla_Function_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/GuardObjects.h b/android/armeabi/include/spidermonkey/mozilla/GuardObjects.h deleted file mode 100644 index 9440c71c..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/GuardObjects.h +++ /dev/null @@ -1,167 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Implementation of macros to ensure correct use of RAII Auto* objects. */ - -#ifndef mozilla_GuardObjects_h -#define mozilla_GuardObjects_h - -#include "mozilla/Assertions.h" -#include "mozilla/Move.h" -#include "mozilla/Types.h" - -#ifdef __cplusplus - -#ifdef DEBUG - -/** - * A custom define is used rather than |mozPoisonValue()| due to cascading - * build failures relating to how mfbt is linked on different operating - * systems. See bug 1160253. - */ -#define MOZ_POISON uintptr_t(-1) - -namespace mozilla { -namespace detail { - -/* - * The following classes are designed to cause assertions to detect - * inadvertent use of guard objects as temporaries. In other words, - * when we have a guard object whose only purpose is its constructor and - * destructor (and is never otherwise referenced), the intended use - * might be: - * - * AutoRestore savePainting(mIsPainting); - * - * but is is easy to accidentally write: - * - * AutoRestore(mIsPainting); - * - * which compiles just fine, but runs the destructor well before the - * intended time. - * - * They work by adding (#ifdef DEBUG) an additional parameter to the - * guard object's constructor, with a default value, so that users of - * the guard object's API do not need to do anything. The default value - * of this parameter is a temporary object. C++ (ISO/IEC 14882:1998), - * section 12.2 [class.temporary], clauses 4 and 5 seem to assume a - * guarantee that temporaries are destroyed in the reverse of their - * construction order, but I actually can't find a statement that that - * is true in the general case (beyond the two specific cases mentioned - * there). However, it seems to be true. - * - * These classes are intended to be used only via the macros immediately - * below them: - * - * MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER declares (ifdef DEBUG) a member - * variable, and should be put where a declaration of a private - * member variable would be placed. - * MOZ_GUARD_OBJECT_NOTIFIER_PARAM should be placed at the end of the - * parameters to each constructor of the guard object; it declares - * (ifdef DEBUG) an additional parameter. (But use the *_ONLY_PARAM - * variant for constructors that take no other parameters.) - * MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL should likewise be used in - * the implementation of such constructors when they are not inline. - * MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT should be used in - * the implementation of such constructors to pass the parameter to - * a base class that also uses these macros - * MOZ_GUARD_OBJECT_NOTIFIER_INIT is a statement that belongs in each - * constructor. It uses the parameter declared by - * MOZ_GUARD_OBJECT_NOTIFIER_PARAM. - * - * For more details, and examples of using these macros, see - * https://developer.mozilla.org/en/Using_RAII_classes_in_Mozilla - */ -class GuardObjectNotifier -{ -private: - bool* mStatementDone; - -public: - GuardObjectNotifier() - : mStatementDone(reinterpret_cast<bool*>(MOZ_POISON)) - { - } - - ~GuardObjectNotifier() - { - // Assert that the GuardObjectNotifier has been properly initialized by - // using the |MOZ_GUARD_OBJECT_NOTIFIER_INIT| macro. A poison value is - // used rather than a null check to appease static analyzers that were - // (incorrectly) detecting null pointer dereferences. - MOZ_ASSERT(mStatementDone != reinterpret_cast<bool*>(MOZ_POISON)); - *mStatementDone = true; - } - - void setStatementDone(bool* aStatementIsDone) - { - mStatementDone = aStatementIsDone; - } -}; - -class GuardObjectNotificationReceiver -{ -private: - bool mStatementDone; - -public: - GuardObjectNotificationReceiver() : mStatementDone(false) { } - - ~GuardObjectNotificationReceiver() { - /* - * Assert that the guard object was not used as a temporary. (Note that - * this assert might also fire if init is not called because the guard - * object's implementation is not using the above macros correctly.) - */ - MOZ_ASSERT(mStatementDone); - } - - void init(GuardObjectNotifier& aNotifier) - { - aNotifier.setStatementDone(&mStatementDone); - } -}; - -} /* namespace detail */ -} /* namespace mozilla */ - -#undef MOZ_POISON - -#endif /* DEBUG */ - -#ifdef DEBUG -# define MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER \ - mozilla::detail::GuardObjectNotificationReceiver _mCheckNotUsedAsTemporary; -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM \ - , mozilla::detail::GuardObjectNotifier&& _notifier = \ - mozilla::detail::GuardObjectNotifier() -# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM \ - mozilla::detail::GuardObjectNotifier&& _notifier = \ - mozilla::detail::GuardObjectNotifier() -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL \ - , mozilla::detail::GuardObjectNotifier&& _notifier -# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL \ - mozilla::detail::GuardObjectNotifier&& _notifier -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT \ - , mozilla::Move(_notifier) -# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT \ - mozilla::Move(_notifier) -# define MOZ_GUARD_OBJECT_NOTIFIER_INIT \ - do { _mCheckNotUsedAsTemporary.init(_notifier); } while (0) -#else -# define MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM -# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL -# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_IN_IMPL -# define MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT -# define MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT -# define MOZ_GUARD_OBJECT_NOTIFIER_INIT do { } while (0) -#endif - -#endif /* __cplusplus */ - -#endif /* mozilla_GuardObjects_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/HashFunctions.h b/android/armeabi/include/spidermonkey/mozilla/HashFunctions.h deleted file mode 100644 index eeb192c3..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/HashFunctions.h +++ /dev/null @@ -1,389 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Utilities for hashing. */ - -/* - * This file exports functions for hashing data down to a 32-bit value, - * including: - * - * - HashString Hash a char* or char16_t/wchar_t* of known or unknown - * length. - * - * - HashBytes Hash a byte array of known length. - * - * - HashGeneric Hash one or more values. Currently, we support uint32_t, - * types which can be implicitly cast to uint32_t, data - * pointers, and function pointers. - * - * - AddToHash Add one or more values to the given hash. This supports the - * same list of types as HashGeneric. - * - * - * You can chain these functions together to hash complex objects. For example: - * - * class ComplexObject - * { - * char* mStr; - * uint32_t mUint1, mUint2; - * void (*mCallbackFn)(); - * - * public: - * uint32_t hash() - * { - * uint32_t hash = HashString(mStr); - * hash = AddToHash(hash, mUint1, mUint2); - * return AddToHash(hash, mCallbackFn); - * } - * }; - * - * If you want to hash an nsAString or nsACString, use the HashString functions - * in nsHashKeys.h. - */ - -#ifndef mozilla_HashFunctions_h -#define mozilla_HashFunctions_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Char16.h" -#include "mozilla/MathAlgorithms.h" -#include "mozilla/Types.h" - -#include <stdint.h> - -#ifdef __cplusplus -namespace mozilla { - -/** - * The golden ratio as a 32-bit fixed-point value. - */ -static const uint32_t kGoldenRatioU32 = 0x9E3779B9U; - -inline uint32_t -RotateBitsLeft32(uint32_t aValue, uint8_t aBits) -{ - MOZ_ASSERT(aBits < 32); - return (aValue << aBits) | (aValue >> (32 - aBits)); -} - -namespace detail { - -inline uint32_t -AddU32ToHash(uint32_t aHash, uint32_t aValue) -{ - /* - * This is the meat of all our hash routines. This hash function is not - * particularly sophisticated, but it seems to work well for our mostly - * plain-text inputs. Implementation notes follow. - * - * Our use of the golden ratio here is arbitrary; we could pick almost any - * number which: - * - * * is odd (because otherwise, all our hash values will be even) - * - * * has a reasonably-even mix of 1's and 0's (consider the extreme case - * where we multiply by 0x3 or 0xeffffff -- this will not produce good - * mixing across all bits of the hash). - * - * The rotation length of 5 is also arbitrary, although an odd number is again - * preferable so our hash explores the whole universe of possible rotations. - * - * Finally, we multiply by the golden ratio *after* xor'ing, not before. - * Otherwise, if |aHash| is 0 (as it often is for the beginning of a - * message), the expression - * - * (kGoldenRatioU32 * RotateBitsLeft(aHash, 5)) |xor| aValue - * - * evaluates to |aValue|. - * - * (Number-theoretic aside: Because any odd number |m| is relatively prime to - * our modulus (2^32), the list - * - * [x * m (mod 2^32) for 0 <= x < 2^32] - * - * has no duplicate elements. This means that multiplying by |m| does not - * cause us to skip any possible hash values. - * - * It's also nice if |m| has large-ish order mod 2^32 -- that is, if the - * smallest k such that m^k == 1 (mod 2^32) is large -- so we can safely - * multiply our hash value by |m| a few times without negating the - * multiplicative effect. Our golden ratio constant has order 2^29, which is - * more than enough for our purposes.) - */ - return kGoldenRatioU32 * (RotateBitsLeft32(aHash, 5) ^ aValue); -} - -/** - * AddUintptrToHash takes sizeof(uintptr_t) as a template parameter. - */ -template<size_t PtrSize> -inline uint32_t -AddUintptrToHash(uint32_t aHash, uintptr_t aValue); - -template<> -inline uint32_t -AddUintptrToHash<4>(uint32_t aHash, uintptr_t aValue) -{ - return AddU32ToHash(aHash, static_cast<uint32_t>(aValue)); -} - -template<> -inline uint32_t -AddUintptrToHash<8>(uint32_t aHash, uintptr_t aValue) -{ - /* - * The static cast to uint64_t below is necessary because this function - * sometimes gets compiled on 32-bit platforms (yes, even though it's a - * template and we never call this particular override in a 32-bit build). If - * we do aValue >> 32 on a 32-bit machine, we're shifting a 32-bit uintptr_t - * right 32 bits, and the compiler throws an error. - */ - uint32_t v1 = static_cast<uint32_t>(aValue); - uint32_t v2 = static_cast<uint32_t>(static_cast<uint64_t>(aValue) >> 32); - return AddU32ToHash(AddU32ToHash(aHash, v1), v2); -} - -} /* namespace detail */ - -/** - * AddToHash takes a hash and some values and returns a new hash based on the - * inputs. - * - * Currently, we support hashing uint32_t's, values which we can implicitly - * convert to uint32_t, data pointers, and function pointers. - */ -template<typename A> -MOZ_MUST_USE inline uint32_t -AddToHash(uint32_t aHash, A aA) -{ - /* - * Try to convert |A| to uint32_t implicitly. If this works, great. If not, - * we'll error out. - */ - return detail::AddU32ToHash(aHash, aA); -} - -template<typename A> -MOZ_MUST_USE inline uint32_t -AddToHash(uint32_t aHash, A* aA) -{ - /* - * You might think this function should just take a void*. But then we'd only - * catch data pointers and couldn't handle function pointers. - */ - - static_assert(sizeof(aA) == sizeof(uintptr_t), "Strange pointer!"); - - return detail::AddUintptrToHash<sizeof(uintptr_t)>(aHash, uintptr_t(aA)); -} - -template<> -MOZ_MUST_USE inline uint32_t -AddToHash(uint32_t aHash, uintptr_t aA) -{ - return detail::AddUintptrToHash<sizeof(uintptr_t)>(aHash, aA); -} - -template<typename A, typename... Args> -MOZ_MUST_USE uint32_t -AddToHash(uint32_t aHash, A aArg, Args... aArgs) -{ - return AddToHash(AddToHash(aHash, aArg), aArgs...); -} - -/** - * The HashGeneric class of functions let you hash one or more values. - * - * If you want to hash together two values x and y, calling HashGeneric(x, y) is - * much better than calling AddToHash(x, y), because AddToHash(x, y) assumes - * that x has already been hashed. - */ -template<typename... Args> -MOZ_MUST_USE inline uint32_t -HashGeneric(Args... aArgs) -{ - return AddToHash(0, aArgs...); -} - -namespace detail { - -template<typename T> -uint32_t -HashUntilZero(const T* aStr) -{ - uint32_t hash = 0; - for (T c; (c = *aStr); aStr++) { - hash = AddToHash(hash, c); - } - return hash; -} - -template<typename T> -uint32_t -HashKnownLength(const T* aStr, size_t aLength) -{ - uint32_t hash = 0; - for (size_t i = 0; i < aLength; i++) { - hash = AddToHash(hash, aStr[i]); - } - return hash; -} - -} /* namespace detail */ - -/** - * The HashString overloads below do just what you'd expect. - * - * If you have the string's length, you might as well call the overload which - * includes the length. It may be marginally faster. - */ -MOZ_MUST_USE inline uint32_t -HashString(const char* aStr) -{ - return detail::HashUntilZero(reinterpret_cast<const unsigned char*>(aStr)); -} - -MOZ_MUST_USE inline uint32_t -HashString(const char* aStr, size_t aLength) -{ - return detail::HashKnownLength(reinterpret_cast<const unsigned char*>(aStr), aLength); -} - -MOZ_MUST_USE -inline uint32_t -HashString(const unsigned char* aStr, size_t aLength) -{ - return detail::HashKnownLength(aStr, aLength); -} - -MOZ_MUST_USE inline uint32_t -HashString(const char16_t* aStr) -{ - return detail::HashUntilZero(aStr); -} - -MOZ_MUST_USE inline uint32_t -HashString(const char16_t* aStr, size_t aLength) -{ - return detail::HashKnownLength(aStr, aLength); -} - -/* - * On Windows, wchar_t is not the same as char16_t, even though it's - * the same width! - */ -#ifdef WIN32 -MOZ_MUST_USE inline uint32_t -HashString(const wchar_t* aStr) -{ - return detail::HashUntilZero(aStr); -} - -MOZ_MUST_USE inline uint32_t -HashString(const wchar_t* aStr, size_t aLength) -{ - return detail::HashKnownLength(aStr, aLength); -} -#endif - -/** - * Hash some number of bytes. - * - * This hash walks word-by-word, rather than byte-by-byte, so you won't get the - * same result out of HashBytes as you would out of HashString. - */ -MOZ_MUST_USE extern MFBT_API uint32_t -HashBytes(const void* bytes, size_t aLength); - -/** - * A pseudorandom function mapping 32-bit integers to 32-bit integers. - * - * This is for when you're feeding private data (like pointer values or credit - * card numbers) to a non-crypto hash function (like HashBytes) and then using - * the hash code for something that untrusted parties could observe (like a JS - * Map). Plug in a HashCodeScrambler before that last step to avoid leaking the - * private data. - * - * By itself, this does not prevent hash-flooding DoS attacks, because an - * attacker can still generate many values with exactly equal hash codes by - * attacking the non-crypto hash function alone. Equal hash codes will, of - * course, still be equal however much you scramble them. - * - * The algorithm is SipHash-1-3. See <https://131002.net/siphash/>. - */ -class HashCodeScrambler -{ - struct SipHasher; - - uint64_t mK0, mK1; - -public: - /** Creates a new scrambler with the given 128-bit key. */ - constexpr HashCodeScrambler(uint64_t aK0, uint64_t aK1) : mK0(aK0), mK1(aK1) {} - - /** - * Scramble a hash code. Always produces the same result for the same - * combination of key and hash code. - */ - uint32_t scramble(uint32_t aHashCode) const - { - SipHasher hasher(mK0, mK1); - return uint32_t(hasher.sipHash(aHashCode)); - } - -private: - struct SipHasher - { - SipHasher(uint64_t aK0, uint64_t aK1) - { - // 1. Initialization. - mV0 = aK0 ^ UINT64_C(0x736f6d6570736575); - mV1 = aK1 ^ UINT64_C(0x646f72616e646f6d); - mV2 = aK0 ^ UINT64_C(0x6c7967656e657261); - mV3 = aK1 ^ UINT64_C(0x7465646279746573); - } - - uint64_t sipHash(uint64_t aM) - { - // 2. Compression. - mV3 ^= aM; - sipRound(); - mV0 ^= aM; - - // 3. Finalization. - mV2 ^= 0xff; - for (int i = 0; i < 3; i++) - sipRound(); - return mV0 ^ mV1 ^ mV2 ^ mV3; - } - - void sipRound() - { - mV0 += mV1; - mV1 = RotateLeft(mV1, 13); - mV1 ^= mV0; - mV0 = RotateLeft(mV0, 32); - mV2 += mV3; - mV3 = RotateLeft(mV3, 16); - mV3 ^= mV2; - mV0 += mV3; - mV3 = RotateLeft(mV3, 21); - mV3 ^= mV0; - mV2 += mV1; - mV1 = RotateLeft(mV1, 17); - mV1 ^= mV2; - mV2 = RotateLeft(mV2, 32); - } - - uint64_t mV0, mV1, mV2, mV3; - }; -}; - -} /* namespace mozilla */ -#endif /* __cplusplus */ - -#endif /* mozilla_HashFunctions_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/IndexSequence.h b/android/armeabi/include/spidermonkey/mozilla/IndexSequence.h deleted file mode 100644 index 1ccace02..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/IndexSequence.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A utility for expanding a tuple into a variadic argument list. - * Based on std::index_sequence. */ - -/** - * Example usage: - * - * Problem: - * - * You have a variadic function Foo: - * - * template <typename... Args> void Foo(Args...); - * - * And a variadic function Bar, which contains a tuple: - * - * template <typename... Args> - * void Bar() { - * // ... - * Tuple<Args...> t; - * } - * - * And inside Bar, you want to call Foo with the elements of the tuple as - * arguments to Foo. - * - * You want to write: - * - * Foo(Get<0>(t), Get<1>(t), ..., Get<N>(t)) - * - * but you can't literally write that, because N is different for different - * instantiations of Bar. - * - * Solution: - * - * Write a helper function which takes the tuple, and an index sequence - * containing indices corresponding to the tuple indices. - * - * template <typename... Args, size_t... Indices> - * void Helper(const Tuple<Args...>& t, IndexSequence<Indices>) - * { - * Foo(Get<Indices>(t)...); - * } - * - * Assuming 'Indices...' are 0, 1, ..., N - 1, where N is the size of the - * tuple, pack expansion will expand the pack 'Get<Indices>(t)...' to - * 'Get<0>(t), Get<1>(t), ..., Get<N>(t)'. - * - * Finally, call the helper, creating the index sequence to pass in like so: - * - * template <typename... Args> - * void Bar() { - * // ... - * Tuple<Args...> t; - * Helper(t, typename IndexSequenceFor<Args...>::Type()); - * } - */ - -#ifndef mozilla_IndexSequence_h -#define mozilla_IndexSequence_h - -#include "mozilla/Attributes.h" - -#include <stddef.h> - -namespace mozilla { - -/** - * Represents a compile-time sequence of integer indices. - */ -template<size_t... Indices> -struct IndexSequence -{ - static constexpr size_t Size() { return sizeof...(Indices); } -}; - -namespace detail { - -// Helpers used by MakeIndexSequence. - -template<size_t... Indices> -struct IndexTuple -{ - typedef IndexTuple<Indices..., sizeof...(Indices)> Next; -}; - -// Builds IndexTuple<0, 1, ..., N - 1>. -template<size_t N> -struct BuildIndexTuple -{ - typedef typename BuildIndexTuple<N - 1>::Type::Next Type; -}; - -template<> -struct BuildIndexTuple<0> -{ - typedef IndexTuple<> Type; -}; - -template<size_t N, typename IndexTuple> -struct MakeIndexSequenceImpl; - -template<size_t N, size_t... Indices> -struct MakeIndexSequenceImpl<N, IndexTuple<Indices...>> -{ - typedef IndexSequence<Indices...> Type; -}; - -} // namespace detail - -/** - * A utility for building an IndexSequence of consecutive indices. - * MakeIndexSequence<N>::Type evaluates to IndexSequence<0, 1, .., N - 1>. - * Note: unlike std::make_index_sequence, this is not an alias template - * to work around bugs in MSVC 2013. - */ -template<size_t N> -struct MakeIndexSequence -{ - typedef typename detail::MakeIndexSequenceImpl<N, - typename detail::BuildIndexTuple<N>::Type>::Type Type; -}; - -/** - * A utility for building an IndexSequence of consecutive indices - * corresponding to a variadic argument list. - * IndexSequenceFor<Types...> evaluates to IndexSequence<0, 1, ..., N - 1> - * where N is the number of types in Types. - * Note: unlike std::index_sequence_for, this is not an alias template - * to work around bugs in MSVC 2013. - */ -template<typename... Types> -struct IndexSequenceFor -{ - typedef typename MakeIndexSequence<sizeof...(Types)>::Type Type; -}; - -} // namespace mozilla - -#endif /* mozilla_IndexSequence_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/IntegerPrintfMacros.h b/android/armeabi/include/spidermonkey/mozilla/IntegerPrintfMacros.h deleted file mode 100644 index c534a0ba..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/IntegerPrintfMacros.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Implements the C99 <inttypes.h> interface. */ - -#ifndef mozilla_IntegerPrintfMacros_h_ -#define mozilla_IntegerPrintfMacros_h_ - -/* - * These macros should not be used with the NSPR printf-like functions or their - * users, e.g. mozilla/Logging.h. If you need to use NSPR's facilities, see the - * comment on supported formats at the top of nsprpub/pr/include/prprf.h. - */ - -/* - * scanf is a footgun: if the input number exceeds the bounds of the target - * type, behavior is undefined (in the compiler sense: that is, this code - * could overwrite your hard drive with zeroes): - * - * uint8_t u; - * sscanf("256", "%" SCNu8, &u); // BAD - * - * For this reason, *never* use the SCN* macros provided by this header! - */ - -#include <inttypes.h> - -/* - * Fix up Android's broken [u]intptr_t inttype macros. Android's PRI*PTR - * macros are defined as "ld", but sizeof(long) is 8 and sizeof(intptr_t) - * is 4 on 32-bit Android. TestTypeTraits.cpp asserts that these new macro - * definitions match the actual type sizes seen at compile time. - */ -#if defined(ANDROID) && !defined(__LP64__) -# undef PRIdPTR /* intptr_t */ -# define PRIdPTR "d" /* intptr_t */ -# undef PRIiPTR /* intptr_t */ -# define PRIiPTR "i" /* intptr_t */ -# undef PRIoPTR /* uintptr_t */ -# define PRIoPTR "o" /* uintptr_t */ -# undef PRIuPTR /* uintptr_t */ -# define PRIuPTR "u" /* uintptr_t */ -# undef PRIxPTR /* uintptr_t */ -# define PRIxPTR "x" /* uintptr_t */ -# undef PRIXPTR /* uintptr_t */ -# define PRIXPTR "X" /* uintptr_t */ -#endif - -#endif /* mozilla_IntegerPrintfMacros_h_ */ diff --git a/android/armeabi/include/spidermonkey/mozilla/IntegerRange.h b/android/armeabi/include/spidermonkey/mozilla/IntegerRange.h deleted file mode 100644 index 8d5d2e4d..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/IntegerRange.h +++ /dev/null @@ -1,181 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Iterator over ranges of integers */ - -#ifndef mozilla_IntegerRange_h -#define mozilla_IntegerRange_h - -#include "mozilla/Assertions.h" -#include "mozilla/ReverseIterator.h" -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -namespace detail { - -template<typename IntTypeT> -class IntegerIterator -{ -public: - template<typename IntType> - explicit IntegerIterator(IntType aCurrent) - : mCurrent(aCurrent) { } - - template<typename IntType> - explicit IntegerIterator(const IntegerIterator<IntType>& aOther) - : mCurrent(aOther.mCurrent) { } - - IntTypeT operator*() const { return mCurrent; } - - /* Increment and decrement operators */ - - IntegerIterator& operator++() { ++mCurrent; return *this; } - IntegerIterator& operator--() { --mCurrent; return *this; } - IntegerIterator operator++(int) { auto ret = *this; ++mCurrent; return ret; } - IntegerIterator operator--(int) { auto ret = *this; --mCurrent; return ret; } - - /* Comparison operators */ - - template<typename IntType1, typename IntType2> - friend bool operator==(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2); - template<typename IntType1, typename IntType2> - friend bool operator!=(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2); - template<typename IntType1, typename IntType2> - friend bool operator<(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2); - template<typename IntType1, typename IntType2> - friend bool operator<=(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2); - template<typename IntType1, typename IntType2> - friend bool operator>(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2); - template<typename IntType1, typename IntType2> - friend bool operator>=(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2); - -private: - IntTypeT mCurrent; -}; - -template<typename IntType1, typename IntType2> -bool operator==(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2) -{ - return aIter1.mCurrent == aIter2.mCurrent; -} - -template<typename IntType1, typename IntType2> -bool operator!=(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2) -{ - return aIter1.mCurrent != aIter2.mCurrent; -} - -template<typename IntType1, typename IntType2> -bool operator<(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2) -{ - return aIter1.mCurrent < aIter2.mCurrent; -} - -template<typename IntType1, typename IntType2> -bool operator<=(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2) -{ - return aIter1.mCurrent <= aIter2.mCurrent; -} - -template<typename IntType1, typename IntType2> -bool operator>(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2) -{ - return aIter1.mCurrent > aIter2.mCurrent; -} - -template<typename IntType1, typename IntType2> -bool operator>=(const IntegerIterator<IntType1>& aIter1, - const IntegerIterator<IntType2>& aIter2) -{ - return aIter1.mCurrent >= aIter2.mCurrent; -} - -template<typename IntTypeT> -class IntegerRange -{ -public: - typedef IntegerIterator<IntTypeT> iterator; - typedef IntegerIterator<IntTypeT> const_iterator; - typedef ReverseIterator<IntegerIterator<IntTypeT>> reverse_iterator; - typedef ReverseIterator<IntegerIterator<IntTypeT>> const_reverse_iterator; - - template<typename IntType> - explicit IntegerRange(IntType aEnd) - : mBegin(0), mEnd(aEnd) { } - - template<typename IntType1, typename IntType2> - IntegerRange(IntType1 aBegin, IntType2 aEnd) - : mBegin(aBegin), mEnd(aEnd) { } - - iterator begin() const { return iterator(mBegin); } - const_iterator cbegin() const { return begin(); } - iterator end() const { return iterator(mEnd); } - const_iterator cend() const { return end(); } - reverse_iterator rbegin() const { return reverse_iterator(mEnd); } - const_reverse_iterator crbegin() const { return rbegin(); } - reverse_iterator rend() const { return reverse_iterator(mBegin); } - const_reverse_iterator crend() const { return rend(); } - -private: - IntTypeT mBegin; - IntTypeT mEnd; -}; - -template<typename T, bool = IsUnsigned<T>::value> -struct GeqZero -{ - static bool check(T t) { - return t >= 0; - } -}; - -template<typename T> -struct GeqZero<T, true> -{ - static bool check(T t) { - return true; - } -}; - -} // namespace detail - -template<typename IntType> -detail::IntegerRange<IntType> -MakeRange(IntType aEnd) -{ - static_assert(IsIntegral<IntType>::value, "value must be integral"); - MOZ_ASSERT(detail::GeqZero<IntType>::check(aEnd), - "Should never have negative value here"); - return detail::IntegerRange<IntType>(aEnd); -} - -template<typename IntType1, typename IntType2> -detail::IntegerRange<IntType2> -MakeRange(IntType1 aBegin, IntType2 aEnd) -{ - static_assert(IsIntegral<IntType1>::value && IsIntegral<IntType2>::value, - "values must both be integral"); - static_assert(IsSigned<IntType1>::value == IsSigned<IntType2>::value, - "signed/unsigned mismatch"); - MOZ_ASSERT(aEnd >= aBegin, "End value should be larger than begin value"); - return detail::IntegerRange<IntType2>(aBegin, aEnd); -} - -} // namespace mozilla - -#endif // mozilla_IntegerRange_h diff --git a/android/armeabi/include/spidermonkey/mozilla/IntegerTypeTraits.h b/android/armeabi/include/spidermonkey/mozilla/IntegerTypeTraits.h deleted file mode 100644 index 6144d208..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/IntegerTypeTraits.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Helpers to manipulate integer types that don't fit in TypeTraits.h */ - -#ifndef mozilla_IntegerTypeTraits_h -#define mozilla_IntegerTypeTraits_h - -#include "mozilla/TypeTraits.h" -#include <stdint.h> - -namespace mozilla { - -namespace detail { - -/** - * StdintTypeForSizeAndSignedness returns the stdint integer type - * of given size (can be 1, 2, 4 or 8) and given signedness - * (false means unsigned, true means signed). - */ -template<size_t Size, bool Signedness> -struct StdintTypeForSizeAndSignedness; - -template<> -struct StdintTypeForSizeAndSignedness<1, true> -{ - typedef int8_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<1, false> -{ - typedef uint8_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<2, true> -{ - typedef int16_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<2, false> -{ - typedef uint16_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<4, true> -{ - typedef int32_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<4, false> -{ - typedef uint32_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<8, true> -{ - typedef int64_t Type; -}; - -template<> -struct StdintTypeForSizeAndSignedness<8, false> -{ - typedef uint64_t Type; -}; - -} // namespace detail - -template<size_t Size> -struct UnsignedStdintTypeForSize - : detail::StdintTypeForSizeAndSignedness<Size, false> -{}; - -template<size_t Size> -struct SignedStdintTypeForSize - : detail::StdintTypeForSizeAndSignedness<Size, true> -{}; - -template<typename IntegerType> -struct PositionOfSignBit -{ - static_assert(IsIntegral<IntegerType>::value, - "PositionOfSignBit is only for integral types"); - // 8 here should be CHAR_BIT from limits.h, but the world has moved on. - static const size_t value = 8 * sizeof(IntegerType) - 1; -}; - -/** - * MinValue returns the minimum value of the given integer type as a - * compile-time constant, which std::numeric_limits<IntegerType>::min() - * cannot do in c++98. - */ -template<typename IntegerType> -struct MinValue -{ -private: - static_assert(IsIntegral<IntegerType>::value, - "MinValue is only for integral types"); - - typedef typename MakeUnsigned<IntegerType>::Type UnsignedIntegerType; - static const size_t PosOfSignBit = PositionOfSignBit<IntegerType>::value; - -public: - // Bitwise ops may return a larger type, that's why we cast explicitly. - // In C++, left bit shifts on signed values is undefined by the standard - // unless the shifted value is representable. - // Notice that signed-to-unsigned conversions are always well-defined in - // the standard as the value congruent to 2**n, as expected. By contrast, - // unsigned-to-signed is only well-defined if the value is representable. - static const IntegerType value = - IsSigned<IntegerType>::value - ? IntegerType(UnsignedIntegerType(1) << PosOfSignBit) - : IntegerType(0); -}; - -/** - * MaxValue returns the maximum value of the given integer type as a - * compile-time constant, which std::numeric_limits<IntegerType>::max() - * cannot do in c++98. - */ -template<typename IntegerType> -struct MaxValue -{ - static_assert(IsIntegral<IntegerType>::value, - "MaxValue is only for integral types"); - - // Tricksy, but covered by the CheckedInt unit test. - // Relies on the type of MinValue<IntegerType>::value - // being IntegerType. - static const IntegerType value = ~MinValue<IntegerType>::value; -}; - -} // namespace mozilla - -#endif // mozilla_IntegerTypeTraits_h diff --git a/android/armeabi/include/spidermonkey/mozilla/JSONWriter.h b/android/armeabi/include/spidermonkey/mozilla/JSONWriter.h deleted file mode 100644 index 7d44dc7f..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/JSONWriter.h +++ /dev/null @@ -1,460 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A JSON pretty-printer class. */ - -// A typical JSON-writing library requires you to first build up a data -// structure that represents a JSON object and then serialize it (to file, or -// somewhere else). This approach makes for a clean API, but building the data -// structure takes up memory. Sometimes that isn't desirable, such as when the -// JSON data is produced for memory reporting. -// -// The JSONWriter class instead allows JSON data to be written out -// incrementally without building up large data structures. -// -// The API is slightly uglier than you would see in a typical JSON-writing -// library, but still fairly easy to use. It's possible to generate invalid -// JSON with JSONWriter, but typically the most basic testing will identify any -// such problems. -// -// Similarly, there are no RAII facilities for automatically closing objects -// and arrays. These would be nice if you are generating all your code within -// nested functions, but in other cases you'd have to maintain an explicit -// stack of RAII objects and manually unwind it, which is no better than just -// calling "end" functions. Furthermore, the consequences of forgetting to -// close an object or array are obvious and, again, will be identified via -// basic testing, unlike other cases where RAII is typically used (e.g. smart -// pointers) and the consequences of defects are more subtle. -// -// Importantly, the class does solve the two hard problems of JSON -// pretty-printing, which are (a) correctly escaping strings, and (b) adding -// appropriate indentation and commas between items. -// -// By default, every property is placed on its own line. However, it is -// possible to request that objects and arrays be placed entirely on a single -// line, which can reduce output size significantly in some cases. -// -// Strings used (for property names and string property values) are |const -// char*| throughout, and can be ASCII or UTF-8. -// -// EXAMPLE -// ------- -// Assume that |MyWriteFunc| is a class that implements |JSONWriteFunc|. The -// following code: -// -// JSONWriter w(MakeUnique<MyWriteFunc>()); -// w.Start(); -// { -// w.NullProperty("null"); -// w.BoolProperty("bool", true); -// w.IntProperty("int", 1); -// w.StartArrayProperty("array"); -// { -// w.StringElement("string"); -// w.StartObjectElement(); -// { -// w.DoubleProperty("double", 3.4); -// w.StartArrayProperty("single-line array", w.SingleLineStyle); -// { -// w.IntElement(1); -// w.StartObjectElement(); // SingleLineStyle is inherited from -// w.EndObjectElement(); // above for this collection -// } -// w.EndArray(); -// } -// w.EndObjectElement(); -// } -// w.EndArrayProperty(); -// } -// w.End(); -// -// will produce pretty-printed output for the following JSON object: -// -// { -// "null": null, -// "bool": true, -// "int": 1, -// "array": [ -// "string", -// { -// "double": 3.4, -// "single-line array": [1, {}] -// } -// ] -// } -// -// The nesting in the example code is obviously optional, but can aid -// readability. - -#ifndef mozilla_JSONWriter_h -#define mozilla_JSONWriter_h - -#include "mozilla/double-conversion.h" -#include "mozilla/IntegerPrintfMacros.h" -#include "mozilla/PodOperations.h" -#include "mozilla/Sprintf.h" -#include "mozilla/UniquePtr.h" -#include "mozilla/Vector.h" - -#include <stdio.h> - -namespace mozilla { - -// A quasi-functor for JSONWriter. We don't use a true functor because that -// requires templatizing JSONWriter, and the templatization seeps to lots of -// places we don't want it to. -class JSONWriteFunc -{ -public: - virtual void Write(const char* aStr) = 0; - virtual ~JSONWriteFunc() {} -}; - -// Ideally this would be within |EscapedString| but when compiling with GCC -// on Linux that caused link errors, whereas this formulation didn't. -namespace detail { -extern MFBT_DATA const char gTwoCharEscapes[256]; -} // namespace detail - -class JSONWriter -{ - // From http://www.ietf.org/rfc/rfc4627.txt: - // - // "All Unicode characters may be placed within the quotation marks except - // for the characters that must be escaped: quotation mark, reverse - // solidus, and the control characters (U+0000 through U+001F)." - // - // This implementation uses two-char escape sequences where possible, namely: - // - // \", \\, \b, \f, \n, \r, \t - // - // All control characters not in the above list are represented with a - // six-char escape sequence, e.g. '\u000b' (a.k.a. '\v'). - // - class EscapedString - { - // Only one of |mUnownedStr| and |mOwnedStr| are ever non-null. |mIsOwned| - // indicates which one is in use. They're not within a union because that - // wouldn't work with UniquePtr. - bool mIsOwned; - const char* mUnownedStr; - UniquePtr<char[]> mOwnedStr; - - void SanityCheck() const - { - MOZ_ASSERT_IF( mIsOwned, mOwnedStr.get() && !mUnownedStr); - MOZ_ASSERT_IF(!mIsOwned, !mOwnedStr.get() && mUnownedStr); - } - - static char hexDigitToAsciiChar(uint8_t u) - { - u = u & 0xf; - return u < 10 ? '0' + u : 'a' + (u - 10); - } - - public: - explicit EscapedString(const char* aStr) - : mUnownedStr(nullptr) - , mOwnedStr(nullptr) - { - const char* p; - - // First, see if we need to modify the string. - size_t nExtra = 0; - p = aStr; - while (true) { - uint8_t u = *p; // ensure it can't be interpreted as negative - if (u == 0) { - break; - } - if (detail::gTwoCharEscapes[u]) { - nExtra += 1; - } else if (u <= 0x1f) { - nExtra += 5; - } - p++; - } - - if (nExtra == 0) { - // No escapes needed. Easy. - mIsOwned = false; - mUnownedStr = aStr; - return; - } - - // Escapes are needed. We'll create a new string. - mIsOwned = true; - size_t len = (p - aStr) + nExtra; - mOwnedStr = MakeUnique<char[]>(len + 1); - - p = aStr; - size_t i = 0; - - while (true) { - uint8_t u = *p; // ensure it can't be interpreted as negative - if (u == 0) { - mOwnedStr[i] = 0; - break; - } - if (detail::gTwoCharEscapes[u]) { - mOwnedStr[i++] = '\\'; - mOwnedStr[i++] = detail::gTwoCharEscapes[u]; - } else if (u <= 0x1f) { - mOwnedStr[i++] = '\\'; - mOwnedStr[i++] = 'u'; - mOwnedStr[i++] = '0'; - mOwnedStr[i++] = '0'; - mOwnedStr[i++] = hexDigitToAsciiChar((u & 0x00f0) >> 4); - mOwnedStr[i++] = hexDigitToAsciiChar(u & 0x000f); - } else { - mOwnedStr[i++] = u; - } - p++; - } - } - - ~EscapedString() - { - SanityCheck(); - } - - const char* get() const - { - SanityCheck(); - return mIsOwned ? mOwnedStr.get() : mUnownedStr; - } - }; - -public: - // Collections (objects and arrays) are printed in a multi-line style by - // default. This can be changed to a single-line style if SingleLineStyle is - // specified. If a collection is printed in single-line style, every nested - // collection within it is also printed in single-line style, even if - // multi-line style is requested. - enum CollectionStyle { - MultiLineStyle, // the default - SingleLineStyle - }; - -protected: - const UniquePtr<JSONWriteFunc> mWriter; - Vector<bool, 8> mNeedComma; // do we need a comma at depth N? - Vector<bool, 8> mNeedNewlines; // do we need newlines at depth N? - size_t mDepth; // the current nesting depth - - void Indent() - { - for (size_t i = 0; i < mDepth; i++) { - mWriter->Write(" "); - } - } - - // Adds whatever is necessary (maybe a comma, and then a newline and - // whitespace) to separate an item (property or element) from what's come - // before. - void Separator() - { - if (mNeedComma[mDepth]) { - mWriter->Write(","); - } - if (mDepth > 0 && mNeedNewlines[mDepth]) { - mWriter->Write("\n"); - Indent(); - } else if (mNeedComma[mDepth]) { - mWriter->Write(" "); - } - } - - void PropertyNameAndColon(const char* aName) - { - EscapedString escapedName(aName); - mWriter->Write("\""); - mWriter->Write(escapedName.get()); - mWriter->Write("\": "); - } - - void Scalar(const char* aMaybePropertyName, const char* aStringValue) - { - Separator(); - if (aMaybePropertyName) { - PropertyNameAndColon(aMaybePropertyName); - } - mWriter->Write(aStringValue); - mNeedComma[mDepth] = true; - } - - void QuotedScalar(const char* aMaybePropertyName, const char* aStringValue) - { - Separator(); - if (aMaybePropertyName) { - PropertyNameAndColon(aMaybePropertyName); - } - mWriter->Write("\""); - mWriter->Write(aStringValue); - mWriter->Write("\""); - mNeedComma[mDepth] = true; - } - - void NewVectorEntries() - { - // If these tiny allocations OOM we might as well just crash because we - // must be in serious memory trouble. - MOZ_RELEASE_ASSERT(mNeedComma.resizeUninitialized(mDepth + 1)); - MOZ_RELEASE_ASSERT(mNeedNewlines.resizeUninitialized(mDepth + 1)); - mNeedComma[mDepth] = false; - mNeedNewlines[mDepth] = true; - } - - void StartCollection(const char* aMaybePropertyName, const char* aStartChar, - CollectionStyle aStyle = MultiLineStyle) - { - Separator(); - if (aMaybePropertyName) { - mWriter->Write("\""); - mWriter->Write(aMaybePropertyName); - mWriter->Write("\": "); - } - mWriter->Write(aStartChar); - mNeedComma[mDepth] = true; - mDepth++; - NewVectorEntries(); - mNeedNewlines[mDepth] = - mNeedNewlines[mDepth - 1] && aStyle == MultiLineStyle; - } - - // Adds the whitespace and closing char necessary to end a collection. - void EndCollection(const char* aEndChar) - { - if (mNeedNewlines[mDepth]) { - mWriter->Write("\n"); - mDepth--; - Indent(); - } else { - mDepth--; - } - mWriter->Write(aEndChar); - } - -public: - explicit JSONWriter(UniquePtr<JSONWriteFunc> aWriter) - : mWriter(Move(aWriter)) - , mNeedComma() - , mNeedNewlines() - , mDepth(0) - { - NewVectorEntries(); - } - - // Returns the JSONWriteFunc passed in at creation, for temporary use. The - // JSONWriter object still owns the JSONWriteFunc. - JSONWriteFunc* WriteFunc() const { return mWriter.get(); } - - // For all the following functions, the "Prints:" comment indicates what the - // basic output looks like. However, it doesn't indicate the whitespace and - // trailing commas, which are automatically added as required. - // - // All property names and string properties are escaped as necessary. - - // Prints: { - void Start(CollectionStyle aStyle = MultiLineStyle) - { - StartCollection(nullptr, "{", aStyle); - } - - // Prints: } - void End() { EndCollection("}\n"); } - - // Prints: "<aName>": null - void NullProperty(const char* aName) - { - Scalar(aName, "null"); - } - - // Prints: null - void NullElement() { NullProperty(nullptr); } - - // Prints: "<aName>": <aBool> - void BoolProperty(const char* aName, bool aBool) - { - Scalar(aName, aBool ? "true" : "false"); - } - - // Prints: <aBool> - void BoolElement(bool aBool) { BoolProperty(nullptr, aBool); } - - // Prints: "<aName>": <aInt> - void IntProperty(const char* aName, int64_t aInt) - { - char buf[64]; - SprintfLiteral(buf, "%" PRId64, aInt); - Scalar(aName, buf); - } - - // Prints: <aInt> - void IntElement(int64_t aInt) { IntProperty(nullptr, aInt); } - - // Prints: "<aName>": <aDouble> - void DoubleProperty(const char* aName, double aDouble) - { - static const size_t buflen = 64; - char buf[buflen]; - const double_conversion::DoubleToStringConverter &converter = - double_conversion::DoubleToStringConverter::EcmaScriptConverter(); - double_conversion::StringBuilder builder(buf, buflen); - converter.ToShortest(aDouble, &builder); - Scalar(aName, builder.Finalize()); - } - - // Prints: <aDouble> - void DoubleElement(double aDouble) { DoubleProperty(nullptr, aDouble); } - - // Prints: "<aName>": "<aStr>" - void StringProperty(const char* aName, const char* aStr) - { - EscapedString escapedStr(aStr); - QuotedScalar(aName, escapedStr.get()); - } - - // Prints: "<aStr>" - void StringElement(const char* aStr) { StringProperty(nullptr, aStr); } - - // Prints: "<aName>": [ - void StartArrayProperty(const char* aName, - CollectionStyle aStyle = MultiLineStyle) - { - StartCollection(aName, "[", aStyle); - } - - // Prints: [ - void StartArrayElement(CollectionStyle aStyle = MultiLineStyle) - { - StartArrayProperty(nullptr, aStyle); - } - - // Prints: ] - void EndArray() { EndCollection("]"); } - - // Prints: "<aName>": { - void StartObjectProperty(const char* aName, - CollectionStyle aStyle = MultiLineStyle) - { - StartCollection(aName, "{", aStyle); - } - - // Prints: { - void StartObjectElement(CollectionStyle aStyle = MultiLineStyle) - { - StartObjectProperty(nullptr, aStyle); - } - - // Prints: } - void EndObject() { EndCollection("}"); } -}; - -} // namespace mozilla - -#endif /* mozilla_JSONWriter_h */ - diff --git a/android/armeabi/include/spidermonkey/mozilla/Likely.h b/android/armeabi/include/spidermonkey/mozilla/Likely.h deleted file mode 100644 index 4f216092..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Likely.h +++ /dev/null @@ -1,23 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * MOZ_LIKELY and MOZ_UNLIKELY macros to hint to the compiler how a - * boolean predicate should be branch-predicted. - */ - -#ifndef mozilla_Likely_h -#define mozilla_Likely_h - -#if defined(__clang__) || defined(__GNUC__) -# define MOZ_LIKELY(x) (__builtin_expect(!!(x), 1)) -# define MOZ_UNLIKELY(x) (__builtin_expect(!!(x), 0)) -#else -# define MOZ_LIKELY(x) (!!(x)) -# define MOZ_UNLIKELY(x) (!!(x)) -#endif - -#endif /* mozilla_Likely_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/LinkedList.h b/android/armeabi/include/spidermonkey/mozilla/LinkedList.h deleted file mode 100644 index 6e14aa16..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/LinkedList.h +++ /dev/null @@ -1,659 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A type-safe doubly-linked list class. */ - -/* - * The classes LinkedList<T> and LinkedListElement<T> together form a - * convenient, type-safe doubly-linked list implementation. - * - * The class T which will be inserted into the linked list must inherit from - * LinkedListElement<T>. A given object may be in only one linked list at a - * time. - * - * A LinkedListElement automatically removes itself from the list upon - * destruction, and a LinkedList will fatally assert in debug builds if it's - * non-empty when it's destructed. - * - * For example, you might use LinkedList in a simple observer list class as - * follows. - * - * class Observer : public LinkedListElement<Observer> - * { - * public: - * void observe(char* aTopic) { ... } - * }; - * - * class ObserverContainer - * { - * private: - * LinkedList<Observer> list; - * - * public: - * void addObserver(Observer* aObserver) - * { - * // Will assert if |aObserver| is part of another list. - * list.insertBack(aObserver); - * } - * - * void removeObserver(Observer* aObserver) - * { - * // Will assert if |aObserver| is not part of some list. - * aObserver.remove(); - * // Or, will assert if |aObserver| is not part of |list| specifically. - * // aObserver.removeFrom(list); - * } - * - * void notifyObservers(char* aTopic) - * { - * for (Observer* o = list.getFirst(); o != nullptr; o = o->getNext()) { - * o->observe(aTopic); - * } - * } - * }; - * - * Additionally, the class AutoCleanLinkedList<T> is a LinkedList<T> that will - * remove and delete each element still within itself upon destruction. Note - * that because each element is deleted, elements must have been allocated - * using |new|. - */ - -#ifndef mozilla_LinkedList_h -#define mozilla_LinkedList_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/MemoryReporting.h" -#include "mozilla/Move.h" -#include "mozilla/RefPtr.h" - -#ifdef __cplusplus - -namespace mozilla { - -template<typename T> -class LinkedListElement; - -namespace detail { - -/** - * LinkedList supports refcounted elements using this adapter class. Clients - * using LinkedList<RefPtr<T>> will get a data structure that holds a strong - * reference to T as long as T is in the list. - */ -template<typename T> -struct LinkedListElementTraits -{ - typedef T* RawType; - typedef const T* ConstRawType; - typedef T* ClientType; - typedef const T* ConstClientType; - - // These static methods are called when an element is added to or removed from - // a linked list. It can be used to keep track ownership in lists that are - // supposed to own their elements. If elements are transferred from one list - // to another, no enter or exit calls happen since the elements still belong - // to a list. - static void enterList(LinkedListElement<T>* elt) {} - static void exitList(LinkedListElement<T>* elt) {} -}; - -template<typename T> -struct LinkedListElementTraits<RefPtr<T>> -{ - typedef T* RawType; - typedef const T* ConstRawType; - typedef RefPtr<T> ClientType; - typedef RefPtr<const T> ConstClientType; - - static void enterList(LinkedListElement<RefPtr<T>>* elt) { elt->asT()->AddRef(); } - static void exitList(LinkedListElement<RefPtr<T>>* elt) { elt->asT()->Release(); } -}; - -} /* namespace detail */ - -template<typename T> -class LinkedList; - -template<typename T> -class LinkedListElement -{ - typedef typename detail::LinkedListElementTraits<T> Traits; - typedef typename Traits::RawType RawType; - typedef typename Traits::ConstRawType ConstRawType; - typedef typename Traits::ClientType ClientType; - typedef typename Traits::ConstClientType ConstClientType; - - /* - * It's convenient that we return nullptr when getNext() or getPrevious() - * hits the end of the list, but doing so costs an extra word of storage in - * each linked list node (to keep track of whether |this| is the sentinel - * node) and a branch on this value in getNext/getPrevious. - * - * We could get rid of the extra word of storage by shoving the "is - * sentinel" bit into one of the pointers, although this would, of course, - * have performance implications of its own. - * - * But the goal here isn't to win an award for the fastest or slimmest - * linked list; rather, we want a *convenient* linked list. So we won't - * waste time guessing which micro-optimization strategy is best. - * - * - * Speaking of unnecessary work, it's worth addressing here why we wrote - * mozilla::LinkedList in the first place, instead of using stl::list. - * - * The key difference between mozilla::LinkedList and stl::list is that - * mozilla::LinkedList stores the mPrev/mNext pointers in the object itself, - * while stl::list stores the mPrev/mNext pointers in a list element which - * itself points to the object being stored. - * - * mozilla::LinkedList's approach makes it harder to store an object in more - * than one list. But the upside is that you can call next() / prev() / - * remove() directly on the object. With stl::list, you'd need to store a - * pointer to its iterator in the object in order to accomplish this. Not - * only would this waste space, but you'd have to remember to update that - * pointer every time you added or removed the object from a list. - * - * In-place, constant-time removal is a killer feature of doubly-linked - * lists, and supporting this painlessly was a key design criterion. - */ - -private: - LinkedListElement* mNext; - LinkedListElement* mPrev; - const bool mIsSentinel; - -public: - LinkedListElement() - : mNext(this), - mPrev(this), - mIsSentinel(false) - { } - - /* - * Moves |aOther| into |*this|. If |aOther| is already in a list, then - * |aOther| is removed from the list and replaced by |*this|. - */ - LinkedListElement(LinkedListElement<T>&& aOther) - : mIsSentinel(aOther.mIsSentinel) - { - adjustLinkForMove(Move(aOther)); - } - - LinkedListElement& operator=(LinkedListElement<T>&& aOther) - { - MOZ_ASSERT(mIsSentinel == aOther.mIsSentinel, "Mismatch NodeKind!"); - MOZ_ASSERT(!isInList(), - "Assigning to an element in a list messes up that list!"); - adjustLinkForMove(Move(aOther)); - return *this; - } - - ~LinkedListElement() - { - if (!mIsSentinel && isInList()) { - remove(); - } - } - - /* - * Get the next element in the list, or nullptr if this is the last element - * in the list. - */ - RawType getNext() { return mNext->asT(); } - ConstRawType getNext() const { return mNext->asT(); } - - /* - * Get the previous element in the list, or nullptr if this is the first - * element in the list. - */ - RawType getPrevious() { return mPrev->asT(); } - ConstRawType getPrevious() const { return mPrev->asT(); } - - /* - * Insert aElem after this element in the list. |this| must be part of a - * linked list when you call setNext(); otherwise, this method will assert. - */ - void setNext(RawType aElem) - { - MOZ_ASSERT(isInList()); - setNextUnsafe(aElem); - } - - /* - * Insert aElem before this element in the list. |this| must be part of a - * linked list when you call setPrevious(); otherwise, this method will - * assert. - */ - void setPrevious(RawType aElem) - { - MOZ_ASSERT(isInList()); - setPreviousUnsafe(aElem); - } - - /* - * Remove this element from the list which contains it. If this element is - * not currently part of a linked list, this method asserts. - */ - void remove() - { - MOZ_ASSERT(isInList()); - - mPrev->mNext = mNext; - mNext->mPrev = mPrev; - mNext = this; - mPrev = this; - - Traits::exitList(this); - } - - /* - * Remove this element from the list containing it. Returns a pointer to the - * element that follows this element (before it was removed). This method - * asserts if the element does not belong to a list. - */ - ClientType removeAndGetNext() - { - ClientType r = getNext(); - remove(); - return r; - } - - /* - * Remove this element from the list containing it. Returns a pointer to the - * previous element in the containing list (before the removal). This method - * asserts if the element does not belong to a list. - */ - ClientType removeAndGetPrevious() - { - ClientType r = getPrevious(); - remove(); - return r; - } - - /* - * Identical to remove(), but also asserts in debug builds that this element - * is in aList. - */ - void removeFrom(const LinkedList<T>& aList) - { - aList.assertContains(asT()); - remove(); - } - - /* - * Return true if |this| part is of a linked list, and false otherwise. - */ - bool isInList() const - { - MOZ_ASSERT((mNext == this) == (mPrev == this)); - return mNext != this; - } - -private: - friend class LinkedList<T>; - friend struct detail::LinkedListElementTraits<T>; - - enum class NodeKind { - Normal, - Sentinel - }; - - explicit LinkedListElement(NodeKind nodeKind) - : mNext(this), - mPrev(this), - mIsSentinel(nodeKind == NodeKind::Sentinel) - { } - - /* - * Return |this| cast to T* if we're a normal node, or return nullptr if - * we're a sentinel node. - */ - RawType asT() - { - return mIsSentinel ? nullptr : static_cast<RawType>(this); - } - ConstRawType asT() const - { - return mIsSentinel ? nullptr : static_cast<ConstRawType>(this); - } - - /* - * Insert aElem after this element, but don't check that this element is in - * the list. This is called by LinkedList::insertFront(). - */ - void setNextUnsafe(RawType aElem) - { - LinkedListElement *listElem = static_cast<LinkedListElement*>(aElem); - MOZ_ASSERT(!listElem->isInList()); - - listElem->mNext = this->mNext; - listElem->mPrev = this; - this->mNext->mPrev = listElem; - this->mNext = listElem; - - Traits::enterList(aElem); - } - - /* - * Insert aElem before this element, but don't check that this element is in - * the list. This is called by LinkedList::insertBack(). - */ - void setPreviousUnsafe(RawType aElem) - { - LinkedListElement<T>* listElem = static_cast<LinkedListElement<T>*>(aElem); - MOZ_ASSERT(!listElem->isInList()); - - listElem->mNext = this; - listElem->mPrev = this->mPrev; - this->mPrev->mNext = listElem; - this->mPrev = listElem; - - Traits::enterList(aElem); - } - - /* - * Adjust mNext and mPrev for implementing move constructor and move - * assignment. - */ - void adjustLinkForMove(LinkedListElement<T>&& aOther) - { - if (!aOther.isInList()) { - mNext = this; - mPrev = this; - return; - } - - if (!mIsSentinel) { - Traits::enterList(this); - } - - MOZ_ASSERT(aOther.mNext->mPrev == &aOther); - MOZ_ASSERT(aOther.mPrev->mNext == &aOther); - - /* - * Initialize |this| with |aOther|'s mPrev/mNext pointers, and adjust those - * element to point to this one. - */ - mNext = aOther.mNext; - mPrev = aOther.mPrev; - - mNext->mPrev = this; - mPrev->mNext = this; - - /* - * Adjust |aOther| so it doesn't think it's in a list. This makes it - * safely destructable. - */ - aOther.mNext = &aOther; - aOther.mPrev = &aOther; - - if (!mIsSentinel) { - Traits::exitList(&aOther); - } - } - - LinkedListElement& operator=(const LinkedListElement<T>& aOther) = delete; - LinkedListElement(const LinkedListElement<T>& aOther) = delete; -}; - -template<typename T> -class LinkedList -{ -private: - typedef typename detail::LinkedListElementTraits<T> Traits; - typedef typename Traits::RawType RawType; - typedef typename Traits::ConstRawType ConstRawType; - typedef typename Traits::ClientType ClientType; - typedef typename Traits::ConstClientType ConstClientType; - - LinkedListElement<T> sentinel; - -public: - class Iterator { - RawType mCurrent; - - public: - explicit Iterator(RawType aCurrent) : mCurrent(aCurrent) {} - - RawType operator *() const { - return mCurrent; - } - - const Iterator& operator++() { - mCurrent = mCurrent->getNext(); - return *this; - } - - bool operator!=(Iterator& aOther) const { - return mCurrent != aOther.mCurrent; - } - }; - - LinkedList() : sentinel(LinkedListElement<T>::NodeKind::Sentinel) { } - - LinkedList(LinkedList<T>&& aOther) - : sentinel(mozilla::Move(aOther.sentinel)) - { } - - LinkedList& operator=(LinkedList<T>&& aOther) - { - MOZ_ASSERT(isEmpty(), "Assigning to a non-empty list leaks elements in that list!"); - sentinel = mozilla::Move(aOther.sentinel); - return *this; - } - - ~LinkedList() { - MOZ_ASSERT(isEmpty(), - "failing this assertion means this LinkedList's creator is " - "buggy: it should have removed all this list's elements before " - "the list's destruction"); - } - - /* - * Add aElem to the front of the list. - */ - void insertFront(RawType aElem) - { - /* Bypass setNext()'s this->isInList() assertion. */ - sentinel.setNextUnsafe(aElem); - } - - /* - * Add aElem to the back of the list. - */ - void insertBack(RawType aElem) - { - sentinel.setPreviousUnsafe(aElem); - } - - /* - * Get the first element of the list, or nullptr if the list is empty. - */ - RawType getFirst() { return sentinel.getNext(); } - ConstRawType getFirst() const { return sentinel.getNext(); } - - /* - * Get the last element of the list, or nullptr if the list is empty. - */ - RawType getLast() { return sentinel.getPrevious(); } - ConstRawType getLast() const { return sentinel.getPrevious(); } - - /* - * Get and remove the first element of the list. If the list is empty, - * return nullptr. - */ - ClientType popFirst() - { - ClientType ret = sentinel.getNext(); - if (ret) { - static_cast<LinkedListElement<T>*>(RawType(ret))->remove(); - } - return ret; - } - - /* - * Get and remove the last element of the list. If the list is empty, - * return nullptr. - */ - ClientType popLast() - { - ClientType ret = sentinel.getPrevious(); - if (ret) { - static_cast<LinkedListElement<T>*>(RawType(ret))->remove(); - } - return ret; - } - - /* - * Return true if the list is empty, or false otherwise. - */ - bool isEmpty() const - { - return !sentinel.isInList(); - } - - /* - * Remove all the elements from the list. - * - * This runs in time linear to the list's length, because we have to mark - * each element as not in the list. - */ - void clear() - { - while (popFirst()) { - continue; - } - } - - /* - * Allow range-based iteration: - * - * for (MyElementType* elt : myList) { ... } - */ - Iterator begin() { - return Iterator(getFirst()); - } - Iterator end() { - return Iterator(nullptr); - } - - /* - * Measures the memory consumption of the list excluding |this|. Note that - * it only measures the list elements themselves. If the list elements - * contain pointers to other memory blocks, those blocks must be measured - * separately during a subsequent iteration over the list. - */ - size_t sizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const - { - size_t n = 0; - for (const T* t = getFirst(); t; t = t->getNext()) { - n += aMallocSizeOf(t); - } - return n; - } - - /* - * Like sizeOfExcludingThis(), but measures |this| as well. - */ - size_t sizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const - { - return aMallocSizeOf(this) + sizeOfExcludingThis(aMallocSizeOf); - } - - /* - * In a debug build, make sure that the list is sane (no cycles, consistent - * mNext/mPrev pointers, only one sentinel). Has no effect in release builds. - */ - void debugAssertIsSane() const - { -#ifdef DEBUG - const LinkedListElement<T>* slow; - const LinkedListElement<T>* fast1; - const LinkedListElement<T>* fast2; - - /* - * Check for cycles in the forward singly-linked list using the - * tortoise/hare algorithm. - */ - for (slow = sentinel.mNext, - fast1 = sentinel.mNext->mNext, - fast2 = sentinel.mNext->mNext->mNext; - slow != &sentinel && fast1 != &sentinel && fast2 != &sentinel; - slow = slow->mNext, fast1 = fast2->mNext, fast2 = fast1->mNext) { - MOZ_ASSERT(slow != fast1); - MOZ_ASSERT(slow != fast2); - } - - /* Check for cycles in the backward singly-linked list. */ - for (slow = sentinel.mPrev, - fast1 = sentinel.mPrev->mPrev, - fast2 = sentinel.mPrev->mPrev->mPrev; - slow != &sentinel && fast1 != &sentinel && fast2 != &sentinel; - slow = slow->mPrev, fast1 = fast2->mPrev, fast2 = fast1->mPrev) { - MOZ_ASSERT(slow != fast1); - MOZ_ASSERT(slow != fast2); - } - - /* - * Check that |sentinel| is the only node in the list with - * mIsSentinel == true. - */ - for (const LinkedListElement<T>* elem = sentinel.mNext; - elem != &sentinel; - elem = elem->mNext) { - MOZ_ASSERT(!elem->mIsSentinel); - } - - /* Check that the mNext/mPrev pointers match up. */ - const LinkedListElement<T>* prev = &sentinel; - const LinkedListElement<T>* cur = sentinel.mNext; - do { - MOZ_ASSERT(cur->mPrev == prev); - MOZ_ASSERT(prev->mNext == cur); - - prev = cur; - cur = cur->mNext; - } while (cur != &sentinel); -#endif /* ifdef DEBUG */ - } - -private: - friend class LinkedListElement<T>; - - void assertContains(const RawType aValue) const - { -#ifdef DEBUG - for (ConstRawType elem = getFirst(); elem; elem = elem->getNext()) { - if (elem == aValue) { - return; - } - } - MOZ_CRASH("element wasn't found in this list!"); -#endif - } - - LinkedList& operator=(const LinkedList<T>& aOther) = delete; - LinkedList(const LinkedList<T>& aOther) = delete; -}; - -template <typename T> -class AutoCleanLinkedList : public LinkedList<T> -{ -public: - ~AutoCleanLinkedList() - { - while (T* element = this->popFirst()) { - delete element; - } - } -}; - -} /* namespace mozilla */ - -#endif /* __cplusplus */ - -#endif /* mozilla_LinkedList_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/LinuxSignal.h b/android/armeabi/include/spidermonkey/mozilla/LinuxSignal.h deleted file mode 100644 index 83c2bf81..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/LinuxSignal.h +++ /dev/null @@ -1,45 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_LinuxSignal_h -#define mozilla_LinuxSignal_h - -namespace mozilla { - -#if defined(__arm__) - -// Some (old) Linux kernels on ARM have a bug where a signal handler -// can be called without clearing the IT bits in CPSR first. The result -// is that the first few instructions of the handler could be skipped, -// ultimately resulting in crashes. To workaround this bug, the handler -// on ARM is a trampoline that starts with enough NOP instructions, so -// that even if the IT bits are not cleared, only the NOP instructions -// will be skipped over. - -template <void (*H)(int, siginfo_t*, void*)> -__attribute__((naked)) void -SignalTrampoline(int aSignal, siginfo_t* aInfo, void* aContext) -{ - asm volatile ( - "nop; nop; nop; nop" - : : : "memory"); - - asm volatile ( - "b %0" - : - : "X"(H) - : "memory"); -} - -# define MOZ_SIGNAL_TRAMPOLINE(h) (mozilla::SignalTrampoline<h>) - -#else // __arm__ - -# define MOZ_SIGNAL_TRAMPOLINE(h) (h) - -#endif // __arm__ - -} // namespace mozilla - -#endif // mozilla_LinuxSignal_h diff --git a/android/armeabi/include/spidermonkey/mozilla/MacroArgs.h b/android/armeabi/include/spidermonkey/mozilla/MacroArgs.h deleted file mode 100644 index 52ed1e82..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/MacroArgs.h +++ /dev/null @@ -1,109 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Implements various macros meant to ease the use of variadic macros. - */ - -#ifndef mozilla_MacroArgs_h -#define mozilla_MacroArgs_h - -// Concatenates pre-processor tokens in a way that can be used with __LINE__. -#define MOZ_CONCAT2(x, y) x ## y -#define MOZ_CONCAT(x, y) MOZ_CONCAT2(x, y) - -/* - * MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix, ...) counts the number of variadic - * arguments and prefixes it with |aPrefix|. For example: - * - * MOZ_PASTE_PREFIX_AND_ARG_COUNT(, foo, 42) expands to 2 - * MOZ_PASTE_PREFIX_AND_ARG_COUNT(A, foo, 42, bar) expands to A3 - * - * You must pass in between 1 and 50 (inclusive) variadic arguments, past - * |aPrefix|. It is not legal to do - * - * MOZ_PASTE_PREFIX_AND_ARG_COUNT(prefix) - * - * (that is, pass in 0 variadic arguments). To ensure that a compile-time - * error occurs when these constraints are violated, use the - * MOZ_STATIC_ASSERT_VALID_ARG_COUNT macro with the same variaidc arguments - * wherever this macro is used. - * - * Passing (__VA_ARGS__, <rest of arguments>) rather than simply calling - * MOZ_MACROARGS_ARG_COUNT_HELPER2(__VA_ARGS__, <rest of arguments>) very - * carefully tiptoes around a MSVC bug where it improperly expands __VA_ARGS__ - * as a single token in argument lists. For details, see: - * - * http://connect.microsoft.com/VisualStudio/feedback/details/380090/variadic-macro-replacement - * http://cplusplus.co.il/2010/07/17/variadic-macro-to-count-number-of-arguments/#comment-644 - */ -#define MOZ_PASTE_PREFIX_AND_ARG_COUNT(aPrefix, ...) \ - MOZ_MACROARGS_ARG_COUNT_HELPER((__VA_ARGS__, \ - aPrefix##50, aPrefix##49, aPrefix##48, aPrefix##47, aPrefix##46, \ - aPrefix##45, aPrefix##44, aPrefix##43, aPrefix##42, aPrefix##41, \ - aPrefix##40, aPrefix##39, aPrefix##38, aPrefix##37, aPrefix##36, \ - aPrefix##35, aPrefix##34, aPrefix##33, aPrefix##32, aPrefix##31, \ - aPrefix##30, aPrefix##29, aPrefix##28, aPrefix##27, aPrefix##26, \ - aPrefix##25, aPrefix##24, aPrefix##23, aPrefix##22, aPrefix##21, \ - aPrefix##20, aPrefix##19, aPrefix##18, aPrefix##17, aPrefix##16, \ - aPrefix##15, aPrefix##14, aPrefix##13, aPrefix##12, aPrefix##11, \ - aPrefix##10, aPrefix##9, aPrefix##8, aPrefix##7, aPrefix##6, \ - aPrefix##5, aPrefix##4, aPrefix##3, aPrefix##2, aPrefix##1, aPrefix##0)) - -#define MOZ_MACROARGS_ARG_COUNT_HELPER(aArgs) \ - MOZ_MACROARGS_ARG_COUNT_HELPER2 aArgs - -#define MOZ_MACROARGS_ARG_COUNT_HELPER2( \ - a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, \ - a11, a12, a13, a14, a15, a16, a17, a18, a19, a20, \ - a21, a22, a23, a24, a25, a26, a27, a28, a29, a30, \ - a31, a32, a33, a34, a35, a36, a37, a38, a39, a40, \ - a41, a42, a43, a44, a45, a46, a47, a48, a49, a50, \ - a51, ...) a51 - -/* - * MOZ_STATIC_ASSERT_VALID_ARG_COUNT ensures that a compile-time error occurs - * when the argument count constraints of MOZ_PASTE_PREFIX_AND_ARG_COUNT are - * violated. Use this macro wherever MOZ_PASTE_PREFIX_AND_ARG_COUNT is used - * and pass it the same variadic arguments. - * - * This macro employs a few dirty tricks to function. To detect the zero - * argument case, |(__VA_ARGS__)| is stringified, sizeof-ed, and compared to - * what it should be in the absence of arguments. - * - * Detecting too many arguments is a little trickier. With a valid argument - * count and a prefix of 1, MOZ_PASTE_PREFIX_AND_ARG_COUNT expands to e.g. 14. - * With a prefix of 0.0, it expands to e.g. 0.04. If there are too many - * arguments, it expands to the first argument over the limit. If this - * exceeding argument is a number, the assertion will fail as there is no - * number than can simultaneously be both > 10 and == 0. If the exceeding - * argument is not a number, a compile-time error should still occur due to - * the operations performed on it. - */ -#define MOZ_MACROARGS_STRINGIFY_HELPER(x) #x -#define MOZ_STATIC_ASSERT_VALID_ARG_COUNT(...) \ - static_assert( \ - sizeof(MOZ_MACROARGS_STRINGIFY_HELPER((__VA_ARGS__))) != sizeof("()") && \ - (MOZ_PASTE_PREFIX_AND_ARG_COUNT(1, __VA_ARGS__)) > 10 && \ - (int)(MOZ_PASTE_PREFIX_AND_ARG_COUNT(0.0, __VA_ARGS__)) == 0, \ - "MOZ_STATIC_ASSERT_VALID_ARG_COUNT requires 1 to 50 arguments") /* ; */ - -/* - * MOZ_ARGS_AFTER_N expands to its arguments excluding the first |N| - * arguments. For example: - * - * MOZ_ARGS_AFTER_2(a, b, c, d) expands to: c, d - */ -#define MOZ_ARGS_AFTER_1(a1, ...) __VA_ARGS__ -#define MOZ_ARGS_AFTER_2(a1, a2, ...) __VA_ARGS__ - -/* - * MOZ_ARG_N expands to its |N|th argument. - */ -#define MOZ_ARG_1(a1, ...) a1 -#define MOZ_ARG_2(a1, a2, ...) a2 - -#endif /* mozilla_MacroArgs_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/MacroForEach.h b/android/armeabi/include/spidermonkey/mozilla/MacroForEach.h deleted file mode 100644 index 7c0e3cfb..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/MacroForEach.h +++ /dev/null @@ -1,158 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Implements a higher-order macro for iteratively calling another macro with - * fixed leading arguments, plus a trailing element picked from a second list - * of arguments. - */ - -#ifndef mozilla_MacroForEach_h -#define mozilla_MacroForEach_h - -#include "mozilla/MacroArgs.h" - -/* - * MOZ_FOR_EACH(aMacro, aFixedArgs, aArgs) expands to N calls to the macro - * |aMacro| where N is equal the number of items in the list |aArgs|. The - * arguments for each |aMacro| call are composed of *all* arguments in the list - * |aFixedArgs| as well as a single argument in the list |aArgs|. For example: - * - * #define MACRO_A(x) x + - * int a = MOZ_FOR_EACH(MACRO_A, (), (1, 2, 3)) 0; - * // Expands to: MACRO_A(1) MACRO_A(2) MACRO_A(3) 0; - * // And further to: 1 + 2 + 3 + 0; - * - * #define MACRO_B(k, x) (k + x) + - * int b = MOZ_FOR_EACH(MACRO_B, (5,), (1, 2)) 0; - * // Expands to: MACRO_B(5, 1) MACRO_B(5, 2) 0; - * - * #define MACRO_C(k1, k2, x) (k1 + k2 + x) + - * int c = MOZ_FOR_EACH(MACRO_C, (5, 8,), (1, 2)) 0; - * // Expands to: MACRO_B(5, 8, 1) MACRO_B(5, 8, 2) 0; - * - * If the |aFixedArgs| list is not empty, a trailing comma must be included. - * - * The |aArgs| list must be not be empty and may be up to 50 items long. Use - * MOZ_STATIC_ASSERT_VALID_ARG_COUNT to ensure that violating this constraint - * results in a compile-time error. - */ -#define MOZ_FOR_EACH_EXPAND_HELPER(...) __VA_ARGS__ -#define MOZ_FOR_EACH_GLUE(a, b) a b -#define MOZ_FOR_EACH(aMacro, aFixedArgs, aArgs) \ - MOZ_FOR_EACH_GLUE( \ - MOZ_PASTE_PREFIX_AND_ARG_COUNT(MOZ_FOR_EACH_, \ - MOZ_FOR_EACH_EXPAND_HELPER aArgs), \ - (aMacro, aFixedArgs, aArgs)) - -#define MOZ_FOR_EACH_HELPER_GLUE(a, b) a b -#define MOZ_FOR_EACH_HELPER(aMacro, aFixedArgs, aArgs) \ - MOZ_FOR_EACH_HELPER_GLUE( \ - aMacro, \ - (MOZ_FOR_EACH_EXPAND_HELPER aFixedArgs MOZ_ARG_1 aArgs)) - -#define MOZ_FOR_EACH_1(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) -#define MOZ_FOR_EACH_2(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_1(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_3(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_2(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_4(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_3(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_5(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_4(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_6(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_5(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_7(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_6(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_8(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_7(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_9(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_8(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_10(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_9(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_11(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_10(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_12(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_11(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_13(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_12(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_14(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_13(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_15(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_14(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_16(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_15(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_17(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_16(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_18(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_17(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_19(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_18(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_20(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_19(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_21(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_20(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_22(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_21(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_23(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_22(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_24(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_23(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_25(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_24(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_26(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_25(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_27(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_26(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_28(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_27(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_29(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_28(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_30(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_29(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_31(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_30(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_32(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_31(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_33(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_32(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_34(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_33(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_35(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_34(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_36(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_35(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_37(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_36(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_38(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_37(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_39(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_38(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_40(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_39(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_41(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_40(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_42(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_41(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_43(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_42(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_44(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_43(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_45(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_44(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_46(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_45(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_47(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_46(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_48(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_47(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_49(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_48(m, fa, (MOZ_ARGS_AFTER_1 a)) -#define MOZ_FOR_EACH_50(m, fa, a) \ - MOZ_FOR_EACH_HELPER(m, fa, a) MOZ_FOR_EACH_49(m, fa, (MOZ_ARGS_AFTER_1 a)) - -#endif /* mozilla_MacroForEach_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/MathAlgorithms.h b/android/armeabi/include/spidermonkey/mozilla/MathAlgorithms.h deleted file mode 100644 index 4db6de49..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/MathAlgorithms.h +++ /dev/null @@ -1,547 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* mfbt maths algorithms. */ - -#ifndef mozilla_MathAlgorithms_h -#define mozilla_MathAlgorithms_h - -#include "mozilla/Assertions.h" -#include "mozilla/TypeTraits.h" - -#include <cmath> -#include <limits.h> -#include <stdint.h> - -namespace mozilla { - -// Greatest Common Divisor -template<typename IntegerType> -MOZ_ALWAYS_INLINE IntegerType -EuclidGCD(IntegerType aA, IntegerType aB) -{ - // Euclid's algorithm; O(N) in the worst case. (There are better - // ways, but we don't need them for the current use of this algo.) - MOZ_ASSERT(aA > IntegerType(0)); - MOZ_ASSERT(aB > IntegerType(0)); - - while (aA != aB) { - if (aA > aB) { - aA = aA - aB; - } else { - aB = aB - aA; - } - } - - return aA; -} - -// Least Common Multiple -template<typename IntegerType> -MOZ_ALWAYS_INLINE IntegerType -EuclidLCM(IntegerType aA, IntegerType aB) -{ - // Divide first to reduce overflow risk. - return (aA / EuclidGCD(aA, aB)) * aB; -} - -namespace detail { - -template<typename T> -struct AllowDeprecatedAbsFixed : FalseType {}; - -template<> struct AllowDeprecatedAbsFixed<int32_t> : TrueType {}; -template<> struct AllowDeprecatedAbsFixed<int64_t> : TrueType {}; - -template<typename T> -struct AllowDeprecatedAbs : AllowDeprecatedAbsFixed<T> {}; - -template<> struct AllowDeprecatedAbs<int> : TrueType {}; -template<> struct AllowDeprecatedAbs<long> : TrueType {}; - -} // namespace detail - -// DO NOT USE DeprecatedAbs. It exists only until its callers can be converted -// to Abs below, and it will be removed when all callers have been changed. -template<typename T> -inline typename mozilla::EnableIf<detail::AllowDeprecatedAbs<T>::value, T>::Type -DeprecatedAbs(const T aValue) -{ - // The absolute value of the smallest possible value of a signed-integer type - // won't fit in that type (on twos-complement systems -- and we're blithely - // assuming we're on such systems, for the non-<stdint.h> types listed above), - // so assert that the input isn't that value. - // - // This is the case if: the value is non-negative; or if adding one (giving a - // value in the range [-maxvalue, 0]), then negating (giving a value in the - // range [0, maxvalue]), doesn't produce maxvalue (because in twos-complement, - // (minvalue + 1) == -maxvalue). - MOZ_ASSERT(aValue >= 0 || - -(aValue + 1) != T((1ULL << (CHAR_BIT * sizeof(T) - 1)) - 1), - "You can't negate the smallest possible negative integer!"); - return aValue >= 0 ? aValue : -aValue; -} - -namespace detail { - -// For now mozilla::Abs only takes intN_T, the signed natural types, and -// float/double/long double. Feel free to add overloads for other standard, -// signed types if you need them. - -template<typename T> -struct AbsReturnTypeFixed; - -template<> struct AbsReturnTypeFixed<int8_t> { typedef uint8_t Type; }; -template<> struct AbsReturnTypeFixed<int16_t> { typedef uint16_t Type; }; -template<> struct AbsReturnTypeFixed<int32_t> { typedef uint32_t Type; }; -template<> struct AbsReturnTypeFixed<int64_t> { typedef uint64_t Type; }; - -template<typename T> -struct AbsReturnType : AbsReturnTypeFixed<T> {}; - -template<> struct AbsReturnType<char> : - EnableIf<char(-1) < char(0), unsigned char> {}; -template<> struct AbsReturnType<signed char> { typedef unsigned char Type; }; -template<> struct AbsReturnType<short> { typedef unsigned short Type; }; -template<> struct AbsReturnType<int> { typedef unsigned int Type; }; -template<> struct AbsReturnType<long> { typedef unsigned long Type; }; -template<> struct AbsReturnType<long long> { typedef unsigned long long Type; }; -template<> struct AbsReturnType<float> { typedef float Type; }; -template<> struct AbsReturnType<double> { typedef double Type; }; -template<> struct AbsReturnType<long double> { typedef long double Type; }; - -} // namespace detail - -template<typename T> -inline typename detail::AbsReturnType<T>::Type -Abs(const T aValue) -{ - typedef typename detail::AbsReturnType<T>::Type ReturnType; - return aValue >= 0 ? ReturnType(aValue) : ~ReturnType(aValue) + 1; -} - -template<> -inline float -Abs<float>(const float aFloat) -{ - return std::fabs(aFloat); -} - -template<> -inline double -Abs<double>(const double aDouble) -{ - return std::fabs(aDouble); -} - -template<> -inline long double -Abs<long double>(const long double aLongDouble) -{ - return std::fabs(aLongDouble); -} - -} // namespace mozilla - -#if defined(_MSC_VER) && \ - (defined(_M_IX86) || defined(_M_AMD64) || defined(_M_X64)) -# define MOZ_BITSCAN_WINDOWS - -# include <intrin.h> -# pragma intrinsic(_BitScanForward, _BitScanReverse) - -# if defined(_M_AMD64) || defined(_M_X64) -# define MOZ_BITSCAN_WINDOWS64 -# pragma intrinsic(_BitScanForward64, _BitScanReverse64) -# endif - -#endif - -namespace mozilla { - -namespace detail { - -#if defined(MOZ_BITSCAN_WINDOWS) - -inline uint_fast8_t -CountLeadingZeroes32(uint32_t aValue) -{ - unsigned long index; - if (!_BitScanReverse(&index, static_cast<unsigned long>(aValue))) - return 32; - return uint_fast8_t(31 - index); -} - - -inline uint_fast8_t -CountTrailingZeroes32(uint32_t aValue) -{ - unsigned long index; - if (!_BitScanForward(&index, static_cast<unsigned long>(aValue))) - return 32; - return uint_fast8_t(index); -} - -inline uint_fast8_t -CountPopulation32(uint32_t aValue) -{ - uint32_t x = aValue - ((aValue >> 1) & 0x55555555); - x = (x & 0x33333333) + ((x >> 2) & 0x33333333); - return (((x + (x >> 4)) & 0xf0f0f0f) * 0x1010101) >> 24; -} -inline uint_fast8_t -CountPopulation64(uint64_t aValue) -{ - return uint_fast8_t(CountPopulation32(aValue & 0xffffffff) + - CountPopulation32(aValue >> 32)); -} - -inline uint_fast8_t -CountLeadingZeroes64(uint64_t aValue) -{ -#if defined(MOZ_BITSCAN_WINDOWS64) - unsigned long index; - if (!_BitScanReverse64(&index, static_cast<unsigned __int64>(aValue))) - return 64; - return uint_fast8_t(63 - index); -#else - uint32_t hi = uint32_t(aValue >> 32); - if (hi != 0) { - return CountLeadingZeroes32(hi); - } - return 32u + CountLeadingZeroes32(uint32_t(aValue)); -#endif -} - -inline uint_fast8_t -CountTrailingZeroes64(uint64_t aValue) -{ -#if defined(MOZ_BITSCAN_WINDOWS64) - unsigned long index; - if (!_BitScanForward64(&index, static_cast<unsigned __int64>(aValue))) - return 64; - return uint_fast8_t(index); -#else - uint32_t lo = uint32_t(aValue); - if (lo != 0) { - return CountTrailingZeroes32(lo); - } - return 32u + CountTrailingZeroes32(uint32_t(aValue >> 32)); -#endif -} - -# ifdef MOZ_HAVE_BITSCAN64 -# undef MOZ_HAVE_BITSCAN64 -# endif - -#elif defined(__clang__) || defined(__GNUC__) - -# if defined(__clang__) -# if !__has_builtin(__builtin_ctz) || !__has_builtin(__builtin_clz) -# error "A clang providing __builtin_c[lt]z is required to build" -# endif -# else - // gcc has had __builtin_clz and friends since 3.4: no need to check. -# endif - -inline uint_fast8_t -CountLeadingZeroes32(uint32_t aValue) -{ - return __builtin_clz(aValue); -} - -inline uint_fast8_t -CountTrailingZeroes32(uint32_t aValue) -{ - return __builtin_ctz(aValue); -} - -inline uint_fast8_t -CountPopulation32(uint32_t aValue) -{ - return __builtin_popcount(aValue); -} - -inline uint_fast8_t -CountPopulation64(uint64_t aValue) -{ - return __builtin_popcountll(aValue); -} - -inline uint_fast8_t -CountLeadingZeroes64(uint64_t aValue) -{ - return __builtin_clzll(aValue); -} - -inline uint_fast8_t -CountTrailingZeroes64(uint64_t aValue) -{ - return __builtin_ctzll(aValue); -} - -#else -# error "Implement these!" -inline uint_fast8_t CountLeadingZeroes32(uint32_t aValue) = delete; -inline uint_fast8_t CountTrailingZeroes32(uint32_t aValue) = delete; -inline uint_fast8_t CountPopulation32(uint32_t aValue) = delete; -inline uint_fast8_t CountPopulation64(uint64_t aValue) = delete; -inline uint_fast8_t CountLeadingZeroes64(uint64_t aValue) = delete; -inline uint_fast8_t CountTrailingZeroes64(uint64_t aValue) = delete; -#endif - -} // namespace detail - -/** - * Compute the number of high-order zero bits in the NON-ZERO number |aValue|. - * That is, looking at the bitwise representation of the number, with the - * highest- valued bits at the start, return the number of zeroes before the - * first one is observed. - * - * CountLeadingZeroes32(0xF0FF1000) is 0; - * CountLeadingZeroes32(0x7F8F0001) is 1; - * CountLeadingZeroes32(0x3FFF0100) is 2; - * CountLeadingZeroes32(0x1FF50010) is 3; and so on. - */ -inline uint_fast8_t -CountLeadingZeroes32(uint32_t aValue) -{ - MOZ_ASSERT(aValue != 0); - return detail::CountLeadingZeroes32(aValue); -} - -/** - * Compute the number of low-order zero bits in the NON-ZERO number |aValue|. - * That is, looking at the bitwise representation of the number, with the - * lowest- valued bits at the start, return the number of zeroes before the - * first one is observed. - * - * CountTrailingZeroes32(0x0100FFFF) is 0; - * CountTrailingZeroes32(0x7000FFFE) is 1; - * CountTrailingZeroes32(0x0080FFFC) is 2; - * CountTrailingZeroes32(0x0080FFF8) is 3; and so on. - */ -inline uint_fast8_t -CountTrailingZeroes32(uint32_t aValue) -{ - MOZ_ASSERT(aValue != 0); - return detail::CountTrailingZeroes32(aValue); -} - -/** - * Compute the number of one bits in the number |aValue|, - */ -inline uint_fast8_t -CountPopulation32(uint32_t aValue) -{ - return detail::CountPopulation32(aValue); -} - -/** Analogous to CountPopulation32, but for 64-bit numbers */ -inline uint_fast8_t -CountPopulation64(uint64_t aValue) -{ - return detail::CountPopulation64(aValue); -} - -/** Analogous to CountLeadingZeroes32, but for 64-bit numbers. */ -inline uint_fast8_t -CountLeadingZeroes64(uint64_t aValue) -{ - MOZ_ASSERT(aValue != 0); - return detail::CountLeadingZeroes64(aValue); -} - -/** Analogous to CountTrailingZeroes32, but for 64-bit numbers. */ -inline uint_fast8_t -CountTrailingZeroes64(uint64_t aValue) -{ - MOZ_ASSERT(aValue != 0); - return detail::CountTrailingZeroes64(aValue); -} - -namespace detail { - -template<typename T, size_t Size = sizeof(T)> -class CeilingLog2; - -template<typename T> -class CeilingLog2<T, 4> -{ -public: - static uint_fast8_t compute(const T aValue) - { - // Check for <= 1 to avoid the == 0 undefined case. - return aValue <= 1 ? 0u : 32u - CountLeadingZeroes32(aValue - 1); - } -}; - -template<typename T> -class CeilingLog2<T, 8> -{ -public: - static uint_fast8_t compute(const T aValue) - { - // Check for <= 1 to avoid the == 0 undefined case. - return aValue <= 1 ? 0u : 64u - CountLeadingZeroes64(aValue - 1); - } -}; - -} // namespace detail - -/** - * Compute the log of the least power of 2 greater than or equal to |aValue|. - * - * CeilingLog2(0..1) is 0; - * CeilingLog2(2) is 1; - * CeilingLog2(3..4) is 2; - * CeilingLog2(5..8) is 3; - * CeilingLog2(9..16) is 4; and so on. - */ -template<typename T> -inline uint_fast8_t -CeilingLog2(const T aValue) -{ - return detail::CeilingLog2<T>::compute(aValue); -} - -/** A CeilingLog2 variant that accepts only size_t. */ -inline uint_fast8_t -CeilingLog2Size(size_t aValue) -{ - return CeilingLog2(aValue); -} - -namespace detail { - -template<typename T, size_t Size = sizeof(T)> -class FloorLog2; - -template<typename T> -class FloorLog2<T, 4> -{ -public: - static uint_fast8_t compute(const T aValue) - { - return 31u - CountLeadingZeroes32(aValue | 1); - } -}; - -template<typename T> -class FloorLog2<T, 8> -{ -public: - static uint_fast8_t compute(const T aValue) - { - return 63u - CountLeadingZeroes64(aValue | 1); - } -}; - -} // namespace detail - -/** - * Compute the log of the greatest power of 2 less than or equal to |aValue|. - * - * FloorLog2(0..1) is 0; - * FloorLog2(2..3) is 1; - * FloorLog2(4..7) is 2; - * FloorLog2(8..15) is 3; and so on. - */ -template<typename T> -inline uint_fast8_t -FloorLog2(const T aValue) -{ - return detail::FloorLog2<T>::compute(aValue); -} - -/** A FloorLog2 variant that accepts only size_t. */ -inline uint_fast8_t -FloorLog2Size(size_t aValue) -{ - return FloorLog2(aValue); -} - -/* - * Compute the smallest power of 2 greater than or equal to |x|. |x| must not - * be so great that the computed value would overflow |size_t|. - */ -inline size_t -RoundUpPow2(size_t aValue) -{ - MOZ_ASSERT(aValue <= (size_t(1) << (sizeof(size_t) * CHAR_BIT - 1)), - "can't round up -- will overflow!"); - return size_t(1) << CeilingLog2(aValue); -} - -/** - * Rotates the bits of the given value left by the amount of the shift width. - */ -template<typename T> -inline T -RotateLeft(const T aValue, uint_fast8_t aShift) -{ - MOZ_ASSERT(aShift < sizeof(T) * CHAR_BIT, "Shift value is too large!"); - MOZ_ASSERT(aShift > 0, - "Rotation by value length is undefined behavior, but compilers " - "do not currently fold a test into the rotate instruction. " - "Please remove this restriction when compilers optimize the " - "zero case (http://blog.regehr.org/archives/1063)."); - static_assert(IsUnsigned<T>::value, "Rotates require unsigned values"); - return (aValue << aShift) | (aValue >> (sizeof(T) * CHAR_BIT - aShift)); -} - -/** - * Rotates the bits of the given value right by the amount of the shift width. - */ -template<typename T> -inline T -RotateRight(const T aValue, uint_fast8_t aShift) -{ - MOZ_ASSERT(aShift < sizeof(T) * CHAR_BIT, "Shift value is too large!"); - MOZ_ASSERT(aShift > 0, - "Rotation by value length is undefined behavior, but compilers " - "do not currently fold a test into the rotate instruction. " - "Please remove this restriction when compilers optimize the " - "zero case (http://blog.regehr.org/archives/1063)."); - static_assert(IsUnsigned<T>::value, "Rotates require unsigned values"); - return (aValue >> aShift) | (aValue << (sizeof(T) * CHAR_BIT - aShift)); -} - -/** - * Returns true if |x| is a power of two. - * Zero is not an integer power of two. (-Inf is not an integer) - */ -template<typename T> -constexpr bool -IsPowerOfTwo(T x) -{ - static_assert(IsUnsigned<T>::value, - "IsPowerOfTwo requires unsigned values"); - return x && (x & (x - 1)) == 0; -} - -template<typename T> -inline T -Clamp(const T aValue, const T aMin, const T aMax) -{ - static_assert(IsIntegral<T>::value, - "Clamp accepts only integral types, so that it doesn't have" - " to distinguish differently-signed zeroes (which users may" - " or may not care to distinguish, likely at a perf cost) or" - " to decide how to clamp NaN or a range with a NaN" - " endpoint."); - MOZ_ASSERT(aMin <= aMax); - - if (aValue <= aMin) - return aMin; - if (aValue >= aMax) - return aMax; - return aValue; -} - -} /* namespace mozilla */ - -#endif /* mozilla_MathAlgorithms_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Maybe.h b/android/armeabi/include/spidermonkey/mozilla/Maybe.h deleted file mode 100644 index 2a601ac4..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Maybe.h +++ /dev/null @@ -1,551 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A class for optional values and in-place lazy construction. */ - -#ifndef mozilla_Maybe_h -#define mozilla_Maybe_h - -#include "mozilla/Alignment.h" -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Move.h" -#include "mozilla/TypeTraits.h" - -#include <new> // for placement new -#include <type_traits> - -namespace mozilla { - -struct Nothing { }; - -/* - * Maybe is a container class which contains either zero or one elements. It - * serves two roles. It can represent values which are *semantically* optional, - * augmenting a type with an explicit 'Nothing' value. In this role, it provides - * methods that make it easy to work with values that may be missing, along with - * equality and comparison operators so that Maybe values can be stored in - * containers. Maybe values can be constructed conveniently in expressions using - * type inference, as follows: - * - * void doSomething(Maybe<Foo> aFoo) { - * if (aFoo) // Make sure that aFoo contains a value... - * aFoo->takeAction(); // and then use |aFoo->| to access it. - * } // |*aFoo| also works! - * - * doSomething(Nothing()); // Passes a Maybe<Foo> containing no value. - * doSomething(Some(Foo(100))); // Passes a Maybe<Foo> containing |Foo(100)|. - * - * You'll note that it's important to check whether a Maybe contains a value - * before using it, using conversion to bool, |isSome()|, or |isNothing()|. You - * can avoid these checks, and sometimes write more readable code, using - * |valueOr()|, |ptrOr()|, and |refOr()|, which allow you to retrieve the value - * in the Maybe and provide a default for the 'Nothing' case. You can also use - * |apply()| to call a function only if the Maybe holds a value, and |map()| to - * transform the value in the Maybe, returning another Maybe with a possibly - * different type. - * - * Maybe's other role is to support lazily constructing objects without using - * dynamic storage. A Maybe directly contains storage for a value, but it's - * empty by default. |emplace()|, as mentioned above, can be used to construct a - * value in Maybe's storage. The value a Maybe contains can be destroyed by - * calling |reset()|; this will happen automatically if a Maybe is destroyed - * while holding a value. - * - * It's a common idiom in C++ to use a pointer as a 'Maybe' type, with a null - * value meaning 'Nothing' and any other value meaning 'Some'. You can convert - * from such a pointer to a Maybe value using 'ToMaybe()'. - * - * Maybe is inspired by similar types in the standard library of many other - * languages (e.g. Haskell's Maybe and Rust's Option). In the C++ world it's - * very similar to std::optional, which was proposed for C++14 and originated in - * Boost. The most important differences between Maybe and std::optional are: - * - * - std::optional<T> may be compared with T. We deliberately forbid that. - * - std::optional allows in-place construction without a separate call to - * |emplace()| by using a dummy |in_place_t| value to tag the appropriate - * constructor. - * - std::optional has |valueOr()|, equivalent to Maybe's |valueOr()|, but - * lacks corresponding methods for |refOr()| and |ptrOr()|. - * - std::optional lacks |map()| and |apply()|, making it less suitable for - * functional-style code. - * - std::optional lacks many convenience functions that Maybe has. Most - * unfortunately, it lacks equivalents of the type-inferred constructor - * functions |Some()| and |Nothing()|. - * - * N.B. GCC has missed optimizations with Maybe in the past and may generate - * extra branches/loads/stores. Use with caution on hot paths; it's not known - * whether or not this is still a problem. - */ -template<class T> -class Maybe -{ - bool mIsSome; - AlignedStorage2<T> mStorage; - -public: - typedef T ValueType; - - Maybe() : mIsSome(false) { } - ~Maybe() { reset(); } - - MOZ_IMPLICIT Maybe(Nothing) : mIsSome(false) { } - - Maybe(const Maybe& aOther) - : mIsSome(false) - { - if (aOther.mIsSome) { - emplace(*aOther); - } - } - - /** - * Maybe<T*> can be copy-constructed from a Maybe<U*> if U* and T* are - * compatible, or from Maybe<decltype(nullptr)>. - */ - template<typename U, - typename = - typename std::enable_if<std::is_pointer<T>::value && - (std::is_same<U, decltype(nullptr)>::value || - (std::is_pointer<U>::value && - std::is_base_of<typename std::remove_pointer<T>::type, - typename std::remove_pointer<U>::type>::value))>::type> - MOZ_IMPLICIT - Maybe(const Maybe<U>& aOther) - : mIsSome(false) - { - if (aOther.isSome()) { - emplace(*aOther); - } - } - - Maybe(Maybe&& aOther) - : mIsSome(false) - { - if (aOther.mIsSome) { - emplace(Move(*aOther)); - aOther.reset(); - } - } - - /** - * Maybe<T*> can be move-constructed from a Maybe<U*> if U* and T* are - * compatible, or from Maybe<decltype(nullptr)>. - */ - template<typename U, - typename = - typename std::enable_if<std::is_pointer<T>::value && - (std::is_same<U, decltype(nullptr)>::value || - (std::is_pointer<U>::value && - std::is_base_of<typename std::remove_pointer<T>::type, - typename std::remove_pointer<U>::type>::value))>::type> - MOZ_IMPLICIT - Maybe(Maybe<U>&& aOther) - : mIsSome(false) - { - if (aOther.isSome()) { - emplace(Move(*aOther)); - aOther.reset(); - } - } - - Maybe& operator=(const Maybe& aOther) - { - if (&aOther != this) { - if (aOther.mIsSome) { - if (mIsSome) { - // XXX(seth): The correct code for this branch, below, can't be used - // due to a bug in Visual Studio 2010. See bug 1052940. - /* - ref() = aOther.ref(); - */ - reset(); - emplace(*aOther); - } else { - emplace(*aOther); - } - } else { - reset(); - } - } - return *this; - } - - Maybe& operator=(Maybe&& aOther) - { - MOZ_ASSERT(this != &aOther, "Self-moves are prohibited"); - - if (aOther.mIsSome) { - if (mIsSome) { - ref() = Move(aOther.ref()); - } else { - emplace(Move(*aOther)); - } - aOther.reset(); - } else { - reset(); - } - - return *this; - } - - /* Methods that check whether this Maybe contains a value */ - explicit operator bool() const { return isSome(); } - bool isSome() const { return mIsSome; } - bool isNothing() const { return !mIsSome; } - - /* Returns the contents of this Maybe<T> by value. Unsafe unless |isSome()|. */ - T value() const - { - MOZ_ASSERT(mIsSome); - return ref(); - } - - /* - * Returns the contents of this Maybe<T> by value. If |isNothing()|, returns - * the default value provided. - */ - template<typename V> - T valueOr(V&& aDefault) const - { - if (isSome()) { - return ref(); - } - return Forward<V>(aDefault); - } - - /* - * Returns the contents of this Maybe<T> by value. If |isNothing()|, returns - * the value returned from the function or functor provided. - */ - template<typename F> - T valueOrFrom(F&& aFunc) const - { - if (isSome()) { - return ref(); - } - return aFunc(); - } - - /* Returns the contents of this Maybe<T> by pointer. Unsafe unless |isSome()|. */ - T* ptr() - { - MOZ_ASSERT(mIsSome); - return &ref(); - } - - const T* ptr() const - { - MOZ_ASSERT(mIsSome); - return &ref(); - } - - /* - * Returns the contents of this Maybe<T> by pointer. If |isNothing()|, - * returns the default value provided. - */ - T* ptrOr(T* aDefault) - { - if (isSome()) { - return ptr(); - } - return aDefault; - } - - const T* ptrOr(const T* aDefault) const - { - if (isSome()) { - return ptr(); - } - return aDefault; - } - - /* - * Returns the contents of this Maybe<T> by pointer. If |isNothing()|, - * returns the value returned from the function or functor provided. - */ - template<typename F> - T* ptrOrFrom(F&& aFunc) - { - if (isSome()) { - return ptr(); - } - return aFunc(); - } - - template<typename F> - const T* ptrOrFrom(F&& aFunc) const - { - if (isSome()) { - return ptr(); - } - return aFunc(); - } - - T* operator->() - { - MOZ_ASSERT(mIsSome); - return ptr(); - } - - const T* operator->() const - { - MOZ_ASSERT(mIsSome); - return ptr(); - } - - /* Returns the contents of this Maybe<T> by ref. Unsafe unless |isSome()|. */ - T& ref() - { - MOZ_ASSERT(mIsSome); - return *mStorage.addr(); - } - - const T& ref() const - { - MOZ_ASSERT(mIsSome); - return *mStorage.addr(); - } - - /* - * Returns the contents of this Maybe<T> by ref. If |isNothing()|, returns - * the default value provided. - */ - T& refOr(T& aDefault) - { - if (isSome()) { - return ref(); - } - return aDefault; - } - - const T& refOr(const T& aDefault) const - { - if (isSome()) { - return ref(); - } - return aDefault; - } - - /* - * Returns the contents of this Maybe<T> by ref. If |isNothing()|, returns the - * value returned from the function or functor provided. - */ - template<typename F> - T& refOrFrom(F&& aFunc) - { - if (isSome()) { - return ref(); - } - return aFunc(); - } - - template<typename F> - const T& refOrFrom(F&& aFunc) const - { - if (isSome()) { - return ref(); - } - return aFunc(); - } - - T& operator*() - { - MOZ_ASSERT(mIsSome); - return ref(); - } - - const T& operator*() const - { - MOZ_ASSERT(mIsSome); - return ref(); - } - - /* If |isSome()|, runs the provided function or functor on the contents of - * this Maybe. */ - template<typename Func> - Maybe& apply(Func aFunc) - { - if (isSome()) { - aFunc(ref()); - } - return *this; - } - - template<typename Func> - const Maybe& apply(Func aFunc) const - { - if (isSome()) { - aFunc(ref()); - } - return *this; - } - - /* - * If |isSome()|, runs the provided function and returns the result wrapped - * in a Maybe. If |isNothing()|, returns an empty Maybe value. - */ - template<typename Func> - auto map(Func aFunc) -> Maybe<decltype(aFunc(DeclVal<Maybe<T>>().ref()))> - { - using ReturnType = decltype(aFunc(ref())); - if (isSome()) { - Maybe<ReturnType> val; - val.emplace(aFunc(ref())); - return val; - } - return Maybe<ReturnType>(); - } - - template<typename Func> - auto map(Func aFunc) const -> Maybe<decltype(aFunc(DeclVal<Maybe<T>>().ref()))> - { - using ReturnType = decltype(aFunc(ref())); - if (isSome()) { - Maybe<ReturnType> val; - val.emplace(aFunc(ref())); - return val; - } - return Maybe<ReturnType>(); - } - - /* If |isSome()|, empties this Maybe and destroys its contents. */ - void reset() - { - if (isSome()) { - ref().T::~T(); - mIsSome = false; - } - } - - /* - * Constructs a T value in-place in this empty Maybe<T>'s storage. The - * arguments to |emplace()| are the parameters to T's constructor. - */ - template<typename... Args> - void emplace(Args&&... aArgs) - { - MOZ_ASSERT(!mIsSome); - ::new (mStorage.addr()) T(Forward<Args>(aArgs)...); - mIsSome = true; - } -}; - -/* - * Some() creates a Maybe<T> value containing the provided T value. If T has a - * move constructor, it's used to make this as efficient as possible. - * - * Some() selects the type of Maybe it returns by removing any const, volatile, - * or reference qualifiers from the type of the value you pass to it. This gives - * it more intuitive behavior when used in expressions, but it also means that - * if you need to construct a Maybe value that holds a const, volatile, or - * reference value, you need to use emplace() instead. - */ -template<typename T> -Maybe<typename RemoveCV<typename RemoveReference<T>::Type>::Type> -Some(T&& aValue) -{ - typedef typename RemoveCV<typename RemoveReference<T>::Type>::Type U; - Maybe<U> value; - value.emplace(Forward<T>(aValue)); - return value; -} - -template<typename T> -Maybe<typename RemoveCV<typename RemoveReference<T>::Type>::Type> -ToMaybe(T* aPtr) -{ - if (aPtr) { - return Some(*aPtr); - } - return Nothing(); -} - -/* - * Two Maybe<T> values are equal if - * - both are Nothing, or - * - both are Some, and the values they contain are equal. - */ -template<typename T> bool -operator==(const Maybe<T>& aLHS, const Maybe<T>& aRHS) -{ - if (aLHS.isNothing() != aRHS.isNothing()) { - return false; - } - return aLHS.isNothing() || *aLHS == *aRHS; -} - -template<typename T> bool -operator!=(const Maybe<T>& aLHS, const Maybe<T>& aRHS) -{ - return !(aLHS == aRHS); -} - -/* - * We support comparison to Nothing to allow reasonable expressions like: - * if (maybeValue == Nothing()) { ... } - */ -template<typename T> bool -operator==(const Maybe<T>& aLHS, const Nothing& aRHS) -{ - return aLHS.isNothing(); -} - -template<typename T> bool -operator!=(const Maybe<T>& aLHS, const Nothing& aRHS) -{ - return !(aLHS == aRHS); -} - -template<typename T> bool -operator==(const Nothing& aLHS, const Maybe<T>& aRHS) -{ - return aRHS.isNothing(); -} - -template<typename T> bool -operator!=(const Nothing& aLHS, const Maybe<T>& aRHS) -{ - return !(aLHS == aRHS); -} - -/* - * Maybe<T> values are ordered in the same way T values are ordered, except that - * Nothing comes before anything else. - */ -template<typename T> bool -operator<(const Maybe<T>& aLHS, const Maybe<T>& aRHS) -{ - if (aLHS.isNothing()) { - return aRHS.isSome(); - } - if (aRHS.isNothing()) { - return false; - } - return *aLHS < *aRHS; -} - -template<typename T> bool -operator>(const Maybe<T>& aLHS, const Maybe<T>& aRHS) -{ - return !(aLHS < aRHS || aLHS == aRHS); -} - -template<typename T> bool -operator<=(const Maybe<T>& aLHS, const Maybe<T>& aRHS) -{ - return aLHS < aRHS || aLHS == aRHS; -} - -template<typename T> bool -operator>=(const Maybe<T>& aLHS, const Maybe<T>& aRHS) -{ - return !(aLHS < aRHS); -} - -} // namespace mozilla - -#endif /* mozilla_Maybe_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/MaybeOneOf.h b/android/armeabi/include/spidermonkey/mozilla/MaybeOneOf.h deleted file mode 100644 index 9c38ff8b..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/MaybeOneOf.h +++ /dev/null @@ -1,143 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_MaybeOneOf_h -#define mozilla_MaybeOneOf_h - -#include "mozilla/Alignment.h" -#include "mozilla/Assertions.h" -#include "mozilla/Move.h" -#include "mozilla/TemplateLib.h" - -#include <new> // For placement new - -namespace mozilla { - -/* - * MaybeOneOf<T1, T2> is like Maybe, but it supports constructing either T1 - * or T2. When a MaybeOneOf<T1, T2> is constructed, it is |empty()|, i.e., - * no value has been constructed and no destructor will be called when the - * MaybeOneOf<T1, T2> is destroyed. Upon calling |construct<T1>()| or - * |construct<T2>()|, a T1 or T2 object will be constructed with the given - * arguments and that object will be destroyed when the owning MaybeOneOf is - * destroyed. - */ -template<class T1, class T2> -class MaybeOneOf -{ - AlignedStorage<tl::Max<sizeof(T1), sizeof(T2)>::value> storage; - - enum State { None, SomeT1, SomeT2 } state; - template <class T, class Ignored = void> struct Type2State {}; - - template <class T> - T& as() - { - MOZ_ASSERT(state == Type2State<T>::result); - return *(T*)storage.addr(); - } - - template <class T> - const T& as() const - { - MOZ_ASSERT(state == Type2State<T>::result); - return *(T*)storage.addr(); - } - -public: - MaybeOneOf() : state(None) {} - ~MaybeOneOf() { destroyIfConstructed(); } - - MaybeOneOf(MaybeOneOf&& rhs) - : state(None) - { - if (!rhs.empty()) { - if (rhs.constructed<T1>()) { - construct<T1>(Move(rhs.as<T1>())); - rhs.as<T1>().~T1(); - } else { - construct<T2>(Move(rhs.as<T2>())); - rhs.as<T2>().~T2(); - } - rhs.state = None; - } - } - - MaybeOneOf &operator=(MaybeOneOf&& rhs) - { - MOZ_ASSERT(this != &rhs, "Self-move is prohibited"); - this->~MaybeOneOf(); - new(this) MaybeOneOf(Move(rhs)); - return *this; - } - - bool empty() const { return state == None; } - - template <class T> - bool constructed() const { return state == Type2State<T>::result; } - - template <class T, class... Args> - void construct(Args&&... aArgs) - { - MOZ_ASSERT(state == None); - state = Type2State<T>::result; - ::new (storage.addr()) T(Forward<Args>(aArgs)...); - } - - template <class T> - T& ref() - { - return as<T>(); - } - - template <class T> - const T& ref() const - { - return as<T>(); - } - - void destroy() - { - MOZ_ASSERT(state == SomeT1 || state == SomeT2); - if (state == SomeT1) { - as<T1>().~T1(); - } else if (state == SomeT2) { - as<T2>().~T2(); - } - state = None; - } - - void destroyIfConstructed() - { - if (!empty()) { - destroy(); - } - } - -private: - MaybeOneOf(const MaybeOneOf& aOther) = delete; - const MaybeOneOf& operator=(const MaybeOneOf& aOther) = delete; -}; - -template <class T1, class T2> -template <class Ignored> -struct MaybeOneOf<T1, T2>::Type2State<T1, Ignored> -{ - typedef MaybeOneOf<T1, T2> Enclosing; - static const typename Enclosing::State result = Enclosing::SomeT1; -}; - -template <class T1, class T2> -template <class Ignored> -struct MaybeOneOf<T1, T2>::Type2State<T2, Ignored> -{ - typedef MaybeOneOf<T1, T2> Enclosing; - static const typename Enclosing::State result = Enclosing::SomeT2; -}; - -} // namespace mozilla - -#endif /* mozilla_MaybeOneOf_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/MemoryChecking.h b/android/armeabi/include/spidermonkey/mozilla/MemoryChecking.h deleted file mode 100644 index ff42d7f1..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/MemoryChecking.h +++ /dev/null @@ -1,129 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Provides a common interface to the ASan (AddressSanitizer) and Valgrind - * functions used to mark memory in certain ways. In detail, the following - * three macros are provided: - * - * MOZ_MAKE_MEM_NOACCESS - Mark memory as unsafe to access (e.g. freed) - * MOZ_MAKE_MEM_UNDEFINED - Mark memory as accessible, with content undefined - * MOZ_MAKE_MEM_DEFINED - Mark memory as accessible, with content defined - * - * With Valgrind in use, these directly map to the three respective Valgrind - * macros. With ASan in use, the NOACCESS macro maps to poisoning the memory, - * while the UNDEFINED/DEFINED macros unpoison memory. - * - * With no memory checker available, all macros expand to the empty statement. - */ - -#ifndef mozilla_MemoryChecking_h -#define mozilla_MemoryChecking_h - -#if defined(MOZ_VALGRIND) -#include "valgrind/memcheck.h" -#endif - -#if defined(MOZ_ASAN) || defined(MOZ_VALGRIND) -#define MOZ_HAVE_MEM_CHECKS 1 -#endif - -#if defined(MOZ_ASAN) -#include <stddef.h> - -#include "mozilla/Attributes.h" -#include "mozilla/Types.h" - -#ifdef _MSC_VER -// In clang-cl based ASAN, we link against the memory poisoning functions -// statically. -#define MOZ_ASAN_VISIBILITY -#else -#define MOZ_ASAN_VISIBILITY MOZ_EXPORT -#endif - -extern "C" { -/* These definitions are usually provided through the - * sanitizer/asan_interface.h header installed by ASan. - */ -void MOZ_ASAN_VISIBILITY -__asan_poison_memory_region(void const volatile *addr, size_t size); -void MOZ_ASAN_VISIBILITY -__asan_unpoison_memory_region(void const volatile *addr, size_t size); - -#define MOZ_MAKE_MEM_NOACCESS(addr, size) \ - __asan_poison_memory_region((addr), (size)) - -#define MOZ_MAKE_MEM_UNDEFINED(addr, size) \ - __asan_unpoison_memory_region((addr), (size)) - -#define MOZ_MAKE_MEM_DEFINED(addr, size) \ - __asan_unpoison_memory_region((addr), (size)) - -/* - * These definitions are usually provided through the - * sanitizer/lsan_interface.h header installed by LSan. - */ -void MOZ_EXPORT -__lsan_ignore_object(const void *p); - -} -#elif defined(MOZ_MSAN) -#include <stddef.h> - -#include "mozilla/Types.h" - -extern "C" { -/* These definitions are usually provided through the - * sanitizer/msan_interface.h header installed by MSan. - */ -void MOZ_EXPORT -__msan_poison(void const volatile *addr, size_t size); -void MOZ_EXPORT -__msan_unpoison(void const volatile *addr, size_t size); - -#define MOZ_MAKE_MEM_NOACCESS(addr, size) \ - __msan_poison((addr), (size)) - -#define MOZ_MAKE_MEM_UNDEFINED(addr, size) \ - __msan_poison((addr), (size)) - -#define MOZ_MAKE_MEM_DEFINED(addr, size) \ - __msan_unpoison((addr), (size)) -} -#elif defined(MOZ_VALGRIND) -#define MOZ_MAKE_MEM_NOACCESS(addr, size) \ - VALGRIND_MAKE_MEM_NOACCESS((addr), (size)) - -#define MOZ_MAKE_MEM_UNDEFINED(addr, size) \ - VALGRIND_MAKE_MEM_UNDEFINED((addr), (size)) - -#define MOZ_MAKE_MEM_DEFINED(addr, size) \ - VALGRIND_MAKE_MEM_DEFINED((addr), (size)) -#else - -#define MOZ_MAKE_MEM_NOACCESS(addr, size) do {} while (0) -#define MOZ_MAKE_MEM_UNDEFINED(addr, size) do {} while (0) -#define MOZ_MAKE_MEM_DEFINED(addr, size) do {} while (0) - -#endif - -/* - * MOZ_LSAN_INTENTIONAL_LEAK(X) is a macro to tell LeakSanitizer that X - * points to a value that will intentionally never be deallocated during - * the execution of the process. - * - * Additional uses of this macro should be reviewed by people - * conversant in leak-checking and/or MFBT peers. - */ -#if defined(MOZ_ASAN) -# define MOZ_LSAN_INTENTIONALLY_LEAK_OBJECT(X) __lsan_ignore_object(X) -#else -# define MOZ_LSAN_INTENTIONALLY_LEAK_OBJECT(X) /* nothing */ -#endif // defined(MOZ_ASAN) - - -#endif /* mozilla_MemoryChecking_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/MemoryReporting.h b/android/armeabi/include/spidermonkey/mozilla/MemoryReporting.h deleted file mode 100644 index d2340ecf..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/MemoryReporting.h +++ /dev/null @@ -1,30 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Memory reporting infrastructure. */ - -#ifndef mozilla_MemoryReporting_h -#define mozilla_MemoryReporting_h - -#include <stddef.h> - -#ifdef __cplusplus - -namespace mozilla { - -/* - * This is for functions that are like malloc_usable_size. Such functions are - * used for measuring the size of data structures. - */ -typedef size_t (*MallocSizeOf)(const void* p); - -} /* namespace mozilla */ - -#endif /* __cplusplus */ - -typedef size_t (*MozMallocSizeOf)(const void* p); - -#endif /* mozilla_MemoryReporting_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Move.h b/android/armeabi/include/spidermonkey/mozilla/Move.h deleted file mode 100644 index f6d0bfc1..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Move.h +++ /dev/null @@ -1,238 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* C++11-style, but C++98-usable, "move references" implementation. */ - -#ifndef mozilla_Move_h -#define mozilla_Move_h - -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -/* - * "Move" References - * - * Some types can be copied much more efficiently if we know the original's - * value need not be preserved --- that is, if we are doing a "move", not a - * "copy". For example, if we have: - * - * Vector<T> u; - * Vector<T> v(u); - * - * the constructor for v must apply a copy constructor to each element of u --- - * taking time linear in the length of u. However, if we know we will not need u - * any more once v has been initialized, then we could initialize v very - * efficiently simply by stealing u's dynamically allocated buffer and giving it - * to v --- a constant-time operation, regardless of the size of u. - * - * Moves often appear in container implementations. For example, when we append - * to a vector, we may need to resize its buffer. This entails moving each of - * its extant elements from the old, smaller buffer to the new, larger buffer. - * But once the elements have been migrated, we're just going to throw away the - * old buffer; we don't care if they still have their values. So if the vector's - * element type can implement "move" more efficiently than "copy", the vector - * resizing should by all means use a "move" operation. Hash tables should also - * use moves when resizing their internal array as entries are added and - * removed. - * - * The details of the optimization, and whether it's worth applying, vary - * from one type to the next: copying an 'int' is as cheap as moving it, so - * there's no benefit in distinguishing 'int' moves from copies. And while - * some constructor calls for complex types are moves, many really have to - * be copies, and can't be optimized this way. So we need: - * - * 1) a way for a type (like Vector) to announce that it can be moved more - * efficiently than it can be copied, and provide an implementation of that - * move operation; and - * - * 2) a way for a particular invocation of a copy constructor to say that it's - * really a move, not a copy, and that the value of the original isn't - * important afterwards (although it must still be safe to destroy). - * - * If a constructor has a single argument of type 'T&&' (an 'rvalue reference - * to T'), that indicates that it is a 'move constructor'. That's 1). It should - * move, not copy, its argument into the object being constructed. It may leave - * the original in any safely-destructible state. - * - * If a constructor's argument is an rvalue, as in 'C(f(x))' or 'C(x + y)', as - * opposed to an lvalue, as in 'C(x)', then overload resolution will prefer the - * move constructor, if there is one. The 'mozilla::Move' function, defined in - * this file, is an identity function you can use in a constructor invocation to - * make any argument into an rvalue, like this: C(Move(x)). That's 2). (You - * could use any function that works, but 'Move' indicates your intention - * clearly.) - * - * Where we might define a copy constructor for a class C like this: - * - * C(const C& rhs) { ... copy rhs to this ... } - * - * we would declare a move constructor like this: - * - * C(C&& rhs) { .. move rhs to this ... } - * - * And where we might perform a copy like this: - * - * C c2(c1); - * - * we would perform a move like this: - * - * C c2(Move(c1)); - * - * Note that 'T&&' implicitly converts to 'T&'. So you can pass a 'T&&' to an - * ordinary copy constructor for a type that doesn't support a special move - * constructor, and you'll just get a copy. This means that templates can use - * Move whenever they know they won't use the original value any more, even if - * they're not sure whether the type at hand has a specialized move constructor. - * If it doesn't, the 'T&&' will just convert to a 'T&', and the ordinary copy - * constructor will apply. - * - * A class with a move constructor can also provide a move assignment operator. - * A generic definition would run this's destructor, and then apply the move - * constructor to *this's memory. A typical definition: - * - * C& operator=(C&& rhs) { - * MOZ_ASSERT(&rhs != this, "self-moves are prohibited"); - * this->~C(); - * new(this) C(Move(rhs)); - * return *this; - * } - * - * With that in place, one can write move assignments like this: - * - * c2 = Move(c1); - * - * This destroys c2, moves c1's value to c2, and leaves c1 in an undefined but - * destructible state. - * - * As we say, a move must leave the original in a "destructible" state. The - * original's destructor will still be called, so if a move doesn't - * actually steal all its resources, that's fine. We require only that the - * move destination must take on the original's value; and that destructing - * the original must not break the move destination. - * - * (Opinions differ on whether move assignment operators should deal with move - * assignment of an object onto itself. It seems wise to either handle that - * case, or assert that it does not occur.) - * - * Forwarding: - * - * Sometimes we want copy construction or assignment if we're passed an ordinary - * value, but move construction if passed an rvalue reference. For example, if - * our constructor takes two arguments and either could usefully be a move, it - * seems silly to write out all four combinations: - * - * C::C(X& x, Y& y) : x(x), y(y) { } - * C::C(X& x, Y&& y) : x(x), y(Move(y)) { } - * C::C(X&& x, Y& y) : x(Move(x)), y(y) { } - * C::C(X&& x, Y&& y) : x(Move(x)), y(Move(y)) { } - * - * To avoid this, C++11 has tweaks to make it possible to write what you mean. - * The four constructor overloads above can be written as one constructor - * template like so[0]: - * - * template <typename XArg, typename YArg> - * C::C(XArg&& x, YArg&& y) : x(Forward<XArg>(x)), y(Forward<YArg>(y)) { } - * - * ("'Don't Repeat Yourself'? What's that?") - * - * This takes advantage of two new rules in C++11: - * - * - First, when a function template takes an argument that is an rvalue - * reference to a template argument (like 'XArg&& x' and 'YArg&& y' above), - * then when the argument is applied to an lvalue, the template argument - * resolves to 'T&'; and when it is applied to an rvalue, the template - * argument resolves to 'T'. Thus, in a call to C::C like: - * - * X foo(int); - * Y yy; - * - * C(foo(5), yy) - * - * XArg would resolve to 'X', and YArg would resolve to 'Y&'. - * - * - Second, Whereas C++ used to forbid references to references, C++11 defines - * 'collapsing rules': 'T& &', 'T&& &', and 'T& &&' (that is, any combination - * involving an lvalue reference) now collapse to simply 'T&'; and 'T&& &&' - * collapses to 'T&&'. - * - * Thus, in the call above, 'XArg&&' is 'X&&'; and 'YArg&&' is 'Y& &&', which - * collapses to 'Y&'. Because the arguments are declared as rvalue references - * to template arguments, the lvalue-ness "shines through" where present. - * - * Then, the 'Forward<T>' function --- you must invoke 'Forward' with its type - * argument --- returns an lvalue reference or an rvalue reference to its - * argument, depending on what T is. In our unified constructor definition, that - * means that we'll invoke either the copy or move constructors for x and y, - * depending on what we gave C's constructor. In our call, we'll move 'foo()' - * into 'x', but copy 'yy' into 'y'. - * - * This header file defines Move and Forward in the mozilla namespace. It's up - * to individual containers to annotate moves as such, by calling Move; and it's - * up to individual types to define move constructors and assignment operators - * when valuable. - * - * (C++11 says that the <utility> header file should define 'std::move' and - * 'std::forward', which are just like our 'Move' and 'Forward'; but those - * definitions aren't available in that header on all our platforms, so we - * define them ourselves here.) - * - * 0. This pattern is known as "perfect forwarding". Interestingly, it is not - * actually perfect, and it can't forward all possible argument expressions! - * There is a C++11 issue: you can't form a reference to a bit-field. As a - * workaround, assign the bit-field to a local variable and use that: - * - * // C is as above - * struct S { int x : 1; } s; - * C(s.x, 0); // BAD: s.x is a reference to a bit-field, can't form those - * int tmp = s.x; - * C(tmp, 0); // OK: tmp not a bit-field - */ - -/** - * Identical to std::Move(); this is necessary until our stlport supports - * std::move(). - */ -template<typename T> -inline typename RemoveReference<T>::Type&& -Move(T&& aX) -{ - return static_cast<typename RemoveReference<T>::Type&&>(aX); -} - -/** - * These two overloads are identical to std::forward(); they are necessary until - * our stlport supports std::forward(). - */ -template<typename T> -inline T&& -Forward(typename RemoveReference<T>::Type& aX) -{ - return static_cast<T&&>(aX); -} - -template<typename T> -inline T&& -Forward(typename RemoveReference<T>::Type&& aX) -{ - static_assert(!IsLvalueReference<T>::value, - "misuse of Forward detected! try the other overload"); - return static_cast<T&&>(aX); -} - -/** Swap |aX| and |aY| using move-construction if possible. */ -template<typename T> -inline void -Swap(T& aX, T& aY) -{ - T tmp(Move(aX)); - aX = Move(aY); - aY = Move(tmp); -} - -} // namespace mozilla - -#endif /* mozilla_Move_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/NotNull.h b/android/armeabi/include/spidermonkey/mozilla/NotNull.h deleted file mode 100644 index 0c3c333e..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/NotNull.h +++ /dev/null @@ -1,209 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_NotNull_h -#define mozilla_NotNull_h - -// It's often unclear if a particular pointer, be it raw (T*) or smart -// (RefPtr<T>, nsCOMPtr<T>, etc.) can be null. This leads to missing null -// checks (which can cause crashes) and unnecessary null checks (which clutter -// the code). -// -// C++ has a built-in alternative that avoids these problems: references. This -// module defines another alternative, NotNull, which can be used in cases -// where references are not suitable. -// -// In the comments below we use the word "handle" to cover all varieties of -// pointers and references. -// -// References -// ---------- -// References are always non-null. (You can do |T& r = *p;| where |p| is null, -// but that's undefined behaviour. C++ doesn't provide any built-in, ironclad -// guarantee of non-nullness.) -// -// A reference works well when you need a temporary handle to an existing -// single object, e.g. for passing a handle to a function, or as a local handle -// within another object. (In Rust parlance, this is a "borrow".) -// -// A reference is less appropriate in the following cases. -// -// - As a primary handle to an object. E.g. code such as this is possible but -// strange: |T& t = *new T(); ...; delete &t;| -// -// - As a handle to an array. It's common for |T*| to refer to either a single -// |T| or an array of |T|, but |T&| cannot refer to an array of |T| because -// you can't index off a reference (at least, not without first converting it -// to a pointer). -// -// - When the handle identity is meaningful, e.g. if you have a hashtable of -// handles, because you have to use |&| on the reference to convert it to a -// pointer. -// -// - Some people don't like using non-const references as function parameters, -// because it is not clear at the call site that the argument might be -// modified. -// -// - When you need "smart" behaviour. E.g. we lack reference equivalents to -// RefPtr and nsCOMPtr. -// -// - When interfacing with code that uses pointers a lot, sometimes using a -// reference just feels like an odd fit. -// -// Furthermore, a reference is impossible in the following cases. -// -// - When the handle is rebound to another object. References don't allow this. -// -// - When the handle has type |void|. |void&| is not allowed. -// -// NotNull is an alternative that can be used in any of the above cases except -// for the last one, where the handle type is |void|. See below. - -#include "mozilla/Assertions.h" - -namespace mozilla { - -// NotNull can be used to wrap a "base" pointer (raw or smart) to indicate it -// is not null. Some examples: -// -// - NotNull<char*> -// - NotNull<RefPtr<Event>> -// - NotNull<nsCOMPtr<Event>> -// -// NotNull has the following notable properties. -// -// - It has zero space overhead. -// -// - It must be initialized explicitly. There is no default initialization. -// -// - It auto-converts to the base pointer type. -// -// - It does not auto-convert from a base pointer. Implicit conversion from a -// less-constrained type (e.g. T*) to a more-constrained type (e.g. -// NotNull<T*>) is dangerous. Creation and assignment from a base pointer can -// only be done with WrapNotNull(), which makes them impossible to overlook, -// both when writing and reading code. -// -// - When initialized (or assigned) it is checked, and if it is null we abort. -// This guarantees that it cannot be null. -// -// - |operator bool()| is deleted. This means you cannot check a NotNull in a -// boolean context, which eliminates the possibility of unnecessary null -// checks. -// -// NotNull currently doesn't work with UniquePtr. See -// https://github.com/Microsoft/GSL/issues/89 for some discussion. -// -template <typename T> -class NotNull -{ - template <typename U> friend NotNull<U> WrapNotNull(U aBasePtr); - - T mBasePtr; - - // This constructor is only used by WrapNotNull(). - template <typename U> - explicit NotNull(U aBasePtr) : mBasePtr(aBasePtr) {} - -public: - // Disallow default construction. - NotNull() = delete; - - // Construct/assign from another NotNull with a compatible base pointer type. - template <typename U> - MOZ_IMPLICIT NotNull(const NotNull<U>& aOther) : mBasePtr(aOther.get()) {} - - // Default copy/move construction and assignment. - NotNull(const NotNull<T>&) = default; - NotNull<T>& operator=(const NotNull<T>&) = default; - NotNull(NotNull<T>&&) = default; - NotNull<T>& operator=(NotNull<T>&&) = default; - - // Disallow null checks, which are unnecessary for this type. - explicit operator bool() const = delete; - - // Explicit conversion to a base pointer. Use only to resolve ambiguity or to - // get a castable pointer. - const T& get() const { return mBasePtr; } - - // Implicit conversion to a base pointer. Preferable to get(). - operator const T&() const { return get(); } - - // Dereference operators. - const T& operator->() const { return get(); } - decltype(*mBasePtr) operator*() const { return *mBasePtr; } -}; - -template <typename T> -NotNull<T> -WrapNotNull(const T aBasePtr) -{ - NotNull<T> notNull(aBasePtr); - MOZ_RELEASE_ASSERT(aBasePtr); - return notNull; -} - -// Compare two NotNulls. -template <typename T, typename U> -inline bool -operator==(const NotNull<T>& aLhs, const NotNull<U>& aRhs) -{ - return aLhs.get() == aRhs.get(); -} -template <typename T, typename U> -inline bool -operator!=(const NotNull<T>& aLhs, const NotNull<U>& aRhs) -{ - return aLhs.get() != aRhs.get(); -} - -// Compare a NotNull to a base pointer. -template <typename T, typename U> -inline bool -operator==(const NotNull<T>& aLhs, const U& aRhs) -{ - return aLhs.get() == aRhs; -} -template <typename T, typename U> -inline bool -operator!=(const NotNull<T>& aLhs, const U& aRhs) -{ - return aLhs.get() != aRhs; -} - -// Compare a base pointer to a NotNull. -template <typename T, typename U> -inline bool -operator==(const T& aLhs, const NotNull<U>& aRhs) -{ - return aLhs == aRhs.get(); -} -template <typename T, typename U> -inline bool -operator!=(const T& aLhs, const NotNull<U>& aRhs) -{ - return aLhs != aRhs.get(); -} - -// Disallow comparing a NotNull to a nullptr. -template <typename T> -bool -operator==(const NotNull<T>&, decltype(nullptr)) = delete; -template <typename T> -bool -operator!=(const NotNull<T>&, decltype(nullptr)) = delete; - -// Disallow comparing a nullptr to a NotNull. -template <typename T> -bool -operator==(decltype(nullptr), const NotNull<T>&) = delete; -template <typename T> -bool -operator!=(decltype(nullptr), const NotNull<T>&) = delete; - -} // namespace mozilla - -#endif /* mozilla_NotNull_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/NullPtr.h b/android/armeabi/include/spidermonkey/mozilla/NullPtr.h deleted file mode 100644 index d2248f4b..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/NullPtr.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Implements a mozilla::IsNullPointer<T> type trait. */ - -#ifndef mozilla_NullPtr_h -#define mozilla_NullPtr_h - -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -/** - * IsNullPointer<T>::value is true iff T is decltype(nullptr). - * - * Ideally this would be in TypeTraits.h, but C++11 omitted std::is_null_pointer - * (fixed in C++14), so in the interests of easing a switch to <type_traits>, - * this trait lives elsewhere. - */ -template<typename T> -struct IsNullPointer : FalseType {}; - -template<> -struct IsNullPointer<decltype(nullptr)> : TrueType {}; - -} // namespace mozilla - -#endif /* mozilla_NullPtr_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Opaque.h b/android/armeabi/include/spidermonkey/mozilla/Opaque.h deleted file mode 100644 index d7239ee7..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Opaque.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* An opaque integral type supporting only comparison operators. */ - -#ifndef mozilla_Opaque_h -#define mozilla_Opaque_h - -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -/** - * Opaque<T> is a replacement for integral T in cases where only comparisons - * must be supported, and it's desirable to prevent accidental dependency on - * exact values. - */ -template<typename T> -class Opaque final -{ - static_assert(mozilla::IsIntegral<T>::value, - "mozilla::Opaque only supports integral types"); - - T mValue; - -public: - Opaque() {} - explicit Opaque(T aValue) : mValue(aValue) {} - - bool operator==(const Opaque& aOther) const { - return mValue == aOther.mValue; - } - - bool operator!=(const Opaque& aOther) const { - return !(*this == aOther); - } -}; - -} // namespace mozilla - -#endif /* mozilla_Opaque_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/OperatorNewExtensions.h b/android/armeabi/include/spidermonkey/mozilla/OperatorNewExtensions.h deleted file mode 100644 index 52fd88a6..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/OperatorNewExtensions.h +++ /dev/null @@ -1,52 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A version of |operator new| that eschews mandatory null-checks. */ - -#ifndef mozilla_OperatorNewExtensions_h -#define mozilla_OperatorNewExtensions_h - -#include "mozilla/Assertions.h" - -// Credit goes to WebKit for this implementation, cf. -// https://bugs.webkit.org/show_bug.cgi?id=74676 -namespace mozilla { -enum NotNullTag { - KnownNotNull, -}; -} // namespace mozilla - -/* - * The logic here is a little subtle. [expr.new] states that if the allocation - * function being called returns null, then object initialization must not be - * done, and the entirety of the new expression must return null. Non-throwing - * (noexcept) functions are defined to return null to indicate failure. The - * standard placement operator new is defined in such a way, and so it requires - * a null check, even when that null check would be extraneous. Functions - * declared without such a specification are defined to throw std::bad_alloc if - * they fail, and return a non-null pointer otherwise. We compile without - * exceptions, so any placement new overload we define that doesn't declare - * itself as noexcept must therefore avoid generating a null check. Below is - * just such an overload. - * - * You might think that MOZ_NONNULL might perform the same function, but - * MOZ_NONNULL isn't supported on all of our compilers, and even when it is - * supported, doesn't work on all the versions we support. And even keeping - * those limitations in mind, we can't put MOZ_NONNULL on the global, - * standardized placement new function in any event. - * - * We deliberately don't add MOZ_NONNULL(3) to tag |p| as non-null, to benefit - * hypothetical static analyzers. Doing so makes |MOZ_ASSERT(p)|'s internal - * test vacuous, and some compilers warn about such vacuous tests. - */ -inline void* -operator new(size_t, mozilla::NotNullTag, void* p) -{ - MOZ_ASSERT(p); - return p; -} - -#endif // mozilla_OperatorNewExtensions_h diff --git a/android/armeabi/include/spidermonkey/mozilla/Pair.h b/android/armeabi/include/spidermonkey/mozilla/Pair.h deleted file mode 100644 index ad7b86a2..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Pair.h +++ /dev/null @@ -1,219 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A class holding a pair of objects that tries to conserve storage space. */ - -#ifndef mozilla_Pair_h -#define mozilla_Pair_h - -#include "mozilla/Attributes.h" -#include "mozilla/Move.h" -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -namespace detail { - -enum StorageType { AsBase, AsMember }; - -// Optimize storage using the Empty Base Optimization -- that empty base classes -// don't take up space -- to optimize size when one or the other class is -// stateless and can be used as a base class. -// -// The extra conditions on storage for B are necessary so that PairHelper won't -// ambiguously inherit from either A or B, such that one or the other base class -// would be inaccessible. -template<typename A, typename B, - detail::StorageType = - IsEmpty<A>::value ? detail::AsBase : detail::AsMember, - detail::StorageType = - IsEmpty<B>::value && !IsBaseOf<A, B>::value && !IsBaseOf<B, A>::value - ? detail::AsBase - : detail::AsMember> -struct PairHelper; - -template<typename A, typename B> -struct PairHelper<A, B, AsMember, AsMember> -{ -protected: - template<typename AArg, typename BArg> - PairHelper(AArg&& aA, BArg&& aB) - : mFirstA(Forward<AArg>(aA)), - mSecondB(Forward<BArg>(aB)) - {} - - A& first() { return mFirstA; } - const A& first() const { return mFirstA; } - B& second() { return mSecondB; } - const B& second() const { return mSecondB; } - - void swap(PairHelper& aOther) - { - Swap(mFirstA, aOther.mFirstA); - Swap(mSecondB, aOther.mSecondB); - } - -private: - A mFirstA; - B mSecondB; -}; - -template<typename A, typename B> -struct PairHelper<A, B, AsMember, AsBase> : private B -{ -protected: - template<typename AArg, typename BArg> - PairHelper(AArg&& aA, BArg&& aB) - : B(Forward<BArg>(aB)), - mFirstA(Forward<AArg>(aA)) - {} - - A& first() { return mFirstA; } - const A& first() const { return mFirstA; } - B& second() { return *this; } - const B& second() const { return *this; } - - void swap(PairHelper& aOther) - { - Swap(mFirstA, aOther.mFirstA); - Swap(static_cast<B&>(*this), static_cast<B&>(aOther)); - } - -private: - A mFirstA; -}; - -template<typename A, typename B> -struct PairHelper<A, B, AsBase, AsMember> : private A -{ -protected: - template<typename AArg, typename BArg> - PairHelper(AArg&& aA, BArg&& aB) - : A(Forward<AArg>(aA)), - mSecondB(Forward<BArg>(aB)) - {} - - A& first() { return *this; } - const A& first() const { return *this; } - B& second() { return mSecondB; } - const B& second() const { return mSecondB; } - - void swap(PairHelper& aOther) - { - Swap(static_cast<A&>(*this), static_cast<A&>(aOther)); - Swap(mSecondB, aOther.mSecondB); - } - -private: - B mSecondB; -}; - -template<typename A, typename B> -struct PairHelper<A, B, AsBase, AsBase> : private A, private B -{ -protected: - template<typename AArg, typename BArg> - PairHelper(AArg&& aA, BArg&& aB) - : A(Forward<AArg>(aA)), - B(Forward<BArg>(aB)) - {} - - A& first() { return static_cast<A&>(*this); } - const A& first() const { return static_cast<A&>(*this); } - B& second() { return static_cast<B&>(*this); } - const B& second() const { return static_cast<B&>(*this); } - - void swap(PairHelper& aOther) - { - Swap(static_cast<A&>(*this), static_cast<A&>(aOther)); - Swap(static_cast<B&>(*this), static_cast<B&>(aOther)); - } -}; - -} // namespace detail - -/** - * Pair is the logical concatenation of an instance of A with an instance B. - * Space is conserved when possible. Neither A nor B may be a final class. - * - * It's typically clearer to have individual A and B member fields. Except if - * you want the space-conserving qualities of Pair, you're probably better off - * not using this! - * - * No guarantees are provided about the memory layout of A and B, the order of - * initialization or destruction of A and B, and so on. (This is approximately - * required to optimize space usage.) The first/second names are merely - * conceptual! - */ -template<typename A, typename B> -struct Pair - : private detail::PairHelper<A, B> -{ - typedef typename detail::PairHelper<A, B> Base; - -public: - template<typename AArg, typename BArg> - Pair(AArg&& aA, BArg&& aB) - : Base(Forward<AArg>(aA), Forward<BArg>(aB)) - {} - - Pair(Pair&& aOther) - : Base(Move(aOther.first()), Move(aOther.second())) - { } - - Pair(const Pair& aOther) = default; - - Pair& operator=(Pair&& aOther) - { - MOZ_ASSERT(this != &aOther, "Self-moves are prohibited"); - - first() = Move(aOther.first()); - second() = Move(aOther.second()); - - return *this; - } - - Pair& operator=(const Pair& aOther) = default; - - /** The A instance. */ - using Base::first; - /** The B instance. */ - using Base::second; - - /** Swap this pair with another pair. */ - void swap(Pair& aOther) { Base::swap(aOther); } -}; - -template<typename A, class B> -void -Swap(Pair<A, B>& aX, Pair<A, B>& aY) -{ - aX.swap(aY); -} - -/** - * MakePair allows you to construct a Pair instance using type inference. A call - * like this: - * - * MakePair(Foo(), Bar()) - * - * will return a Pair<Foo, Bar>. - */ -template<typename A, typename B> -Pair<typename RemoveCV<typename RemoveReference<A>::Type>::Type, - typename RemoveCV<typename RemoveReference<B>::Type>::Type> -MakePair(A&& aA, B&& aB) -{ - return - Pair<typename RemoveCV<typename RemoveReference<A>::Type>::Type, - typename RemoveCV<typename RemoveReference<B>::Type>::Type>( - Forward<A>(aA), - Forward<B>(aB)); -} - -} // namespace mozilla - -#endif /* mozilla_Pair_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/PodOperations.h b/android/armeabi/include/spidermonkey/mozilla/PodOperations.h deleted file mode 100644 index e6f4df21..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/PodOperations.h +++ /dev/null @@ -1,196 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Operations for zeroing POD types, arrays, and so on. - * - * These operations are preferable to memset, memcmp, and the like because they - * don't require remembering to multiply by sizeof(T), array lengths, and so on - * everywhere. - */ - -#ifndef mozilla_PodOperations_h -#define mozilla_PodOperations_h - -#include "mozilla/Array.h" -#include "mozilla/ArrayUtils.h" -#include "mozilla/Attributes.h" - -#include <stdint.h> -#include <string.h> - -namespace mozilla { - -/** Set the contents of |aT| to 0. */ -template<typename T> -static MOZ_ALWAYS_INLINE void -PodZero(T* aT) -{ - memset(aT, 0, sizeof(T)); -} - -/** Set the contents of |aNElem| elements starting at |aT| to 0. */ -template<typename T> -static MOZ_ALWAYS_INLINE void -PodZero(T* aT, size_t aNElem) -{ - /* - * This function is often called with 'aNElem' small; we use an inline loop - * instead of calling 'memset' with a non-constant length. The compiler - * should inline the memset call with constant size, though. - */ - for (T* end = aT + aNElem; aT < end; aT++) { - memset(aT, 0, sizeof(T)); - } -} - -/* - * Arrays implicitly convert to pointers to their first element, which is - * dangerous when combined with the above PodZero definitions. Adding an - * overload for arrays is ambiguous, so we need another identifier. The - * ambiguous overload is left to catch mistaken uses of PodZero; if you get a - * compile error involving PodZero and array types, use PodArrayZero instead. - */ -template<typename T, size_t N> -static void PodZero(T (&aT)[N]) = delete; -template<typename T, size_t N> -static void PodZero(T (&aT)[N], size_t aNElem) = delete; - -/** Set the contents of the array |aT| to zero. */ -template <class T, size_t N> -static MOZ_ALWAYS_INLINE void -PodArrayZero(T (&aT)[N]) -{ - memset(aT, 0, N * sizeof(T)); -} - -template <typename T, size_t N> -static MOZ_ALWAYS_INLINE void -PodArrayZero(Array<T, N>& aArr) -{ - memset(&aArr[0], 0, N * sizeof(T)); -} - -/** - * Assign |*aSrc| to |*aDst|. The locations must not be the same and must not - * overlap. - */ -template<typename T> -static MOZ_ALWAYS_INLINE void -PodAssign(T* aDst, const T* aSrc) -{ - MOZ_ASSERT(aDst + 1 <= aSrc || aSrc + 1 <= aDst, - "destination and source must not overlap"); - memcpy(reinterpret_cast<char*>(aDst), reinterpret_cast<const char*>(aSrc), - sizeof(T)); -} - -/** - * Copy |aNElem| T elements from |aSrc| to |aDst|. The two memory ranges must - * not overlap! - */ -template<typename T> -static MOZ_ALWAYS_INLINE void -PodCopy(T* aDst, const T* aSrc, size_t aNElem) -{ - MOZ_ASSERT(aDst + aNElem <= aSrc || aSrc + aNElem <= aDst, - "destination and source must not overlap"); - if (aNElem < 128) { - /* - * Avoid using operator= in this loop, as it may have been - * intentionally deleted by the POD type. - */ - for (const T* srcend = aSrc + aNElem; aSrc < srcend; aSrc++, aDst++) { - PodAssign(aDst, aSrc); - } - } else { - memcpy(aDst, aSrc, aNElem * sizeof(T)); - } -} - -template<typename T> -static MOZ_ALWAYS_INLINE void -PodCopy(volatile T* aDst, const volatile T* aSrc, size_t aNElem) -{ - MOZ_ASSERT(aDst + aNElem <= aSrc || aSrc + aNElem <= aDst, - "destination and source must not overlap"); - - /* - * Volatile |aDst| requires extra work, because it's undefined behavior to - * modify volatile objects using the mem* functions. Just write out the - * loops manually, using operator= rather than memcpy for the same reason, - * and let the compiler optimize to the extent it can. - */ - for (const volatile T* srcend = aSrc + aNElem; - aSrc < srcend; - aSrc++, aDst++) { - *aDst = *aSrc; - } -} - -/* - * Copy the contents of the array |aSrc| into the array |aDst|, both of size N. - * The arrays must not overlap! - */ -template <class T, size_t N> -static MOZ_ALWAYS_INLINE void -PodArrayCopy(T (&aDst)[N], const T (&aSrc)[N]) -{ - PodCopy(aDst, aSrc, N); -} - -/** - * Copy the memory for |aNElem| T elements from |aSrc| to |aDst|. If the two - * memory ranges overlap, then the effect is as if the |aNElem| elements are - * first copied from |aSrc| to a temporary array, and then from the temporary - * array to |aDst|. - */ -template<typename T> -static MOZ_ALWAYS_INLINE void -PodMove(T* aDst, const T* aSrc, size_t aNElem) -{ - MOZ_ASSERT(aNElem <= SIZE_MAX / sizeof(T), - "trying to move an impossible number of elements"); - memmove(aDst, aSrc, aNElem * sizeof(T)); -} - -/** - * Determine whether the |len| elements at |one| are memory-identical to the - * |len| elements at |two|. - */ -template<typename T> -static MOZ_ALWAYS_INLINE bool -PodEqual(const T* one, const T* two, size_t len) -{ - if (len < 128) { - const T* p1end = one + len; - const T* p1 = one; - const T* p2 = two; - for (; p1 < p1end; p1++, p2++) { - if (*p1 != *p2) { - return false; - } - } - return true; - } - - return !memcmp(one, two, len * sizeof(T)); -} - -/* - * Determine whether the |N| elements at |one| are memory-identical to the - * |N| elements at |two|. - */ -template <class T, size_t N> -static MOZ_ALWAYS_INLINE bool -PodEqual(const T (&one)[N], const T (&two)[N]) -{ - return PodEqual(one, two, N); -} - -} // namespace mozilla - -#endif /* mozilla_PodOperations_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Poison.h b/android/armeabi/include/spidermonkey/mozilla/Poison.h deleted file mode 100644 index aae56765..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Poison.h +++ /dev/null @@ -1,108 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * A poison value that can be used to fill a memory space with - * an address that leads to a safe crash when dereferenced. - */ - -#ifndef mozilla_Poison_h -#define mozilla_Poison_h - -#include "mozilla/Assertions.h" -#include "mozilla/Types.h" - -#include <stdint.h> - -MOZ_BEGIN_EXTERN_C - -extern MFBT_DATA uintptr_t gMozillaPoisonValue; - -/** - * @return the poison value. - */ -inline uintptr_t mozPoisonValue() -{ - return gMozillaPoisonValue; -} - -/** - * Overwrite the memory block of aSize bytes at aPtr with the poison value. - * aPtr MUST be aligned at a sizeof(uintptr_t) boundary. - * Only an even number of sizeof(uintptr_t) bytes are overwritten, the last - * few bytes (if any) is not overwritten. - */ -inline void mozWritePoison(void* aPtr, size_t aSize) -{ - const uintptr_t POISON = mozPoisonValue(); - char* p = (char*)aPtr; - char* limit = p + aSize; - MOZ_ASSERT((uintptr_t)aPtr % sizeof(uintptr_t) == 0, "bad alignment"); - MOZ_ASSERT(aSize >= sizeof(uintptr_t), "poisoning this object has no effect"); - for (; p < limit; p += sizeof(uintptr_t)) { - *((uintptr_t*)p) = POISON; - } -} - -/** - * Initialize the poison value. - * This should only be called once. - */ -extern MFBT_API void mozPoisonValueInit(); - -/* Values annotated by CrashReporter */ -extern MFBT_DATA uintptr_t gMozillaPoisonBase; -extern MFBT_DATA uintptr_t gMozillaPoisonSize; - -MOZ_END_EXTERN_C - -#if defined(__cplusplus) - -namespace mozilla { - -/** - * This class is designed to cause crashes when various kinds of memory - * corruption are observed. For instance, let's say we have a class C where we - * suspect out-of-bounds writes to some members. We can insert a member of type - * Poison near the members we suspect are being corrupted by out-of-bounds - * writes. Or perhaps we have a class K we suspect is subject to use-after-free - * violations, in which case it doesn't particularly matter where in the class - * we add the member of type Poison. - * - * In either case, we then insert calls to Check() throughout the code. Doing - * so enables us to narrow down the location where the corruption is occurring. - * A pleasant side-effect of these additional Check() calls is that crash - * signatures may become more regular, as crashes will ideally occur - * consolidated at the point of a Check(), rather than scattered about at - * various uses of the corrupted memory. - */ -class CorruptionCanary { -public: - CorruptionCanary() { - mValue = kCanarySet; - } - - ~CorruptionCanary() { - Check(); - mValue = mozPoisonValue(); - } - - void Check() const { - if (mValue != kCanarySet) { - MOZ_CRASH("Canary check failed, check lifetime"); - } - } - -private: - static const uintptr_t kCanarySet = 0x0f0b0f0b; - uintptr_t mValue; -}; - -} // mozilla - -#endif - -#endif /* mozilla_Poison_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Range.h b/android/armeabi/include/spidermonkey/mozilla/Range.h deleted file mode 100644 index 47d91bb0..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Range.h +++ /dev/null @@ -1,58 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_Range_h -#define mozilla_Range_h - -#include "mozilla/RangedPtr.h" -#include "mozilla/TypeTraits.h" - -#include <stddef.h> - -namespace mozilla { - -// Range<T> is a tuple containing a pointer and a length. -template <typename T> -class Range -{ - const RangedPtr<T> mStart; - const RangedPtr<T> mEnd; - -public: - Range() : mStart(nullptr, 0), mEnd(nullptr, 0) {} - Range(T* aPtr, size_t aLength) - : mStart(aPtr, aPtr, aPtr + aLength), - mEnd(aPtr + aLength, aPtr, aPtr + aLength) - {} - Range(const RangedPtr<T>& aStart, const RangedPtr<T>& aEnd) - : mStart(aStart.get(), aStart.get(), aEnd.get()), - mEnd(aEnd.get(), aStart.get(), aEnd.get()) - { - // Only accept two RangedPtrs within the same range. - aStart.checkIdenticalRange(aEnd); - MOZ_ASSERT(aStart <= aEnd); - } - - template<typename U, - class = typename EnableIf<IsConvertible<U (*)[], T (*)[]>::value, - int>::Type> - MOZ_IMPLICIT Range(const Range<U>& aOther) - : mStart(aOther.mStart), - mEnd(aOther.mEnd) - {} - - RangedPtr<T> begin() const { return mStart; } - RangedPtr<T> end() const { return mEnd; } - size_t length() const { return mEnd - mStart; } - - T& operator[](size_t aOffset) const { return mStart[aOffset]; } - - explicit operator bool() const { return mStart != nullptr; } -}; - -} // namespace mozilla - -#endif /* mozilla_Range_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/RangedArray.h b/android/armeabi/include/spidermonkey/mozilla/RangedArray.h deleted file mode 100644 index afe6267f..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/RangedArray.h +++ /dev/null @@ -1,66 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * A compile-time constant-length array, with bounds-checking assertions -- but - * unlike mozilla::Array, with indexes biased by a constant. - * - * Thus where mozilla::Array<int, 3> is a three-element array indexed by [0, 3), - * mozilla::RangedArray<int, 8, 3> is a three-element array indexed by [8, 11). - */ - -#ifndef mozilla_RangedArray_h -#define mozilla_RangedArray_h - -#include "mozilla/Array.h" - -namespace mozilla { - -template<typename T, size_t MinIndex, size_t Length> -class RangedArray -{ -private: - typedef Array<T, Length> ArrayType; - ArrayType mArr; - -public: - T& operator[](size_t aIndex) - { - MOZ_ASSERT(aIndex == MinIndex || aIndex > MinIndex); - return mArr[aIndex - MinIndex]; - } - - const T& operator[](size_t aIndex) const - { - MOZ_ASSERT(aIndex == MinIndex || aIndex > MinIndex); - return mArr[aIndex - MinIndex]; - } - - typedef typename ArrayType::iterator iterator; - typedef typename ArrayType::const_iterator const_iterator; - typedef typename ArrayType::reverse_iterator reverse_iterator; - typedef typename ArrayType::const_reverse_iterator const_reverse_iterator; - - // Methods for range-based for loops. - iterator begin() { return mArr.begin(); } - const_iterator begin() const { return mArr.begin(); } - const_iterator cbegin() const { return mArr.cbegin(); } - iterator end() { return mArr.end(); } - const_iterator end() const { return mArr.end(); } - const_iterator cend() const { return mArr.cend(); } - - // Methods for reverse iterating. - reverse_iterator rbegin() { return mArr.rbegin(); } - const_reverse_iterator rbegin() const { return mArr.rbegin(); } - const_reverse_iterator crbegin() const { return mArr.crbegin(); } - reverse_iterator rend() { return mArr.rend(); } - const_reverse_iterator rend() const { return mArr.rend(); } - const_reverse_iterator crend() const { return mArr.crend(); } -}; - -} // namespace mozilla - -#endif // mozilla_RangedArray_h diff --git a/android/armeabi/include/spidermonkey/mozilla/RangedPtr.h b/android/armeabi/include/spidermonkey/mozilla/RangedPtr.h deleted file mode 100644 index a07c1f4f..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/RangedPtr.h +++ /dev/null @@ -1,292 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Implements a smart pointer asserted to remain within a range specified at - * construction. - */ - -#ifndef mozilla_RangedPtr_h -#define mozilla_RangedPtr_h - -#include "mozilla/ArrayUtils.h" -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" - -#include <stdint.h> - -namespace mozilla { - -/* - * RangedPtr is a smart pointer restricted to an address range specified at - * creation. The pointer (and any smart pointers derived from it) must remain - * within the range [start, end] (inclusive of end to facilitate use as - * sentinels). Dereferencing or indexing into the pointer (or pointers derived - * from it) must remain within the range [start, end). All the standard pointer - * operators are defined on it; in debug builds these operations assert that the - * range specified at construction is respected. - * - * In theory passing a smart pointer instance as an argument can be slightly - * slower than passing a T* (due to ABI requirements for passing structs versus - * passing pointers), if the method being called isn't inlined. If you are in - * extremely performance-critical code, you may want to be careful using this - * smart pointer as an argument type. - * - * RangedPtr<T> intentionally does not implicitly convert to T*. Use get() to - * explicitly convert to T*. Keep in mind that the raw pointer of course won't - * implement bounds checking in debug builds. - */ -template<typename T> -class RangedPtr -{ - T* mPtr; - -#ifdef DEBUG - T* const mRangeStart; - T* const mRangeEnd; -#endif - - void checkSanity() - { - MOZ_ASSERT(mRangeStart <= mPtr); - MOZ_ASSERT(mPtr <= mRangeEnd); - } - - /* Creates a new pointer for |aPtr|, restricted to this pointer's range. */ - RangedPtr<T> create(T* aPtr) const - { -#ifdef DEBUG - return RangedPtr<T>(aPtr, mRangeStart, mRangeEnd); -#else - return RangedPtr<T>(aPtr, nullptr, size_t(0)); -#endif - } - - uintptr_t asUintptr() const { return reinterpret_cast<uintptr_t>(mPtr); } - -public: - RangedPtr(T* aPtr, T* aStart, T* aEnd) - : mPtr(aPtr) -#ifdef DEBUG - , mRangeStart(aStart), mRangeEnd(aEnd) -#endif - { - MOZ_ASSERT(mRangeStart <= mRangeEnd); - checkSanity(); - } - RangedPtr(T* aPtr, T* aStart, size_t aLength) - : mPtr(aPtr) -#ifdef DEBUG - , mRangeStart(aStart), mRangeEnd(aStart + aLength) -#endif - { - MOZ_ASSERT(aLength <= size_t(-1) / sizeof(T)); - MOZ_ASSERT(reinterpret_cast<uintptr_t>(mRangeStart) + aLength * sizeof(T) >= - reinterpret_cast<uintptr_t>(mRangeStart)); - checkSanity(); - } - - /* Equivalent to RangedPtr(aPtr, aPtr, aLength). */ - RangedPtr(T* aPtr, size_t aLength) - : mPtr(aPtr) -#ifdef DEBUG - , mRangeStart(aPtr), mRangeEnd(aPtr + aLength) -#endif - { - MOZ_ASSERT(aLength <= size_t(-1) / sizeof(T)); - MOZ_ASSERT(reinterpret_cast<uintptr_t>(mRangeStart) + aLength * sizeof(T) >= - reinterpret_cast<uintptr_t>(mRangeStart)); - checkSanity(); - } - - /* Equivalent to RangedPtr(aArr, aArr, N). */ - template<size_t N> - explicit RangedPtr(T (&aArr)[N]) - : mPtr(aArr) -#ifdef DEBUG - , mRangeStart(aArr), mRangeEnd(aArr + N) -#endif - { - checkSanity(); - } - - T* get() const { return mPtr; } - - explicit operator bool() const { return mPtr != nullptr; } - - void checkIdenticalRange(const RangedPtr<T>& aOther) const - { - MOZ_ASSERT(mRangeStart == aOther.mRangeStart); - MOZ_ASSERT(mRangeEnd == aOther.mRangeEnd); - } - - /* - * You can only assign one RangedPtr into another if the two pointers have - * the same valid range: - * - * char arr1[] = "hi"; - * char arr2[] = "bye"; - * RangedPtr<char> p1(arr1, 2); - * p1 = RangedPtr<char>(arr1 + 1, arr1, arr1 + 2); // works - * p1 = RangedPtr<char>(arr2, 3); // asserts - */ - RangedPtr<T>& operator=(const RangedPtr<T>& aOther) - { - checkIdenticalRange(aOther); - mPtr = aOther.mPtr; - checkSanity(); - return *this; - } - - RangedPtr<T> operator+(size_t aInc) const - { - MOZ_ASSERT(aInc <= size_t(-1) / sizeof(T)); - MOZ_ASSERT(asUintptr() + aInc * sizeof(T) >= asUintptr()); - return create(mPtr + aInc); - } - - RangedPtr<T> operator-(size_t aDec) const - { - MOZ_ASSERT(aDec <= size_t(-1) / sizeof(T)); - MOZ_ASSERT(asUintptr() - aDec * sizeof(T) <= asUintptr()); - return create(mPtr - aDec); - } - - /* - * You can assign a raw pointer into a RangedPtr if the raw pointer is - * within the range specified at creation. - */ - template <typename U> - RangedPtr<T>& operator=(U* aPtr) - { - *this = create(aPtr); - return *this; - } - - template <typename U> - RangedPtr<T>& operator=(const RangedPtr<U>& aPtr) - { - MOZ_ASSERT(mRangeStart <= aPtr.mPtr); - MOZ_ASSERT(aPtr.mPtr <= mRangeEnd); - mPtr = aPtr.mPtr; - checkSanity(); - return *this; - } - - RangedPtr<T>& operator++() - { - return (*this += 1); - } - - RangedPtr<T> operator++(int) - { - RangedPtr<T> rcp = *this; - ++*this; - return rcp; - } - - RangedPtr<T>& operator--() - { - return (*this -= 1); - } - - RangedPtr<T> operator--(int) - { - RangedPtr<T> rcp = *this; - --*this; - return rcp; - } - - RangedPtr<T>& operator+=(size_t aInc) - { - *this = *this + aInc; - return *this; - } - - RangedPtr<T>& operator-=(size_t aDec) - { - *this = *this - aDec; - return *this; - } - - T& operator[](int aIndex) const - { - MOZ_ASSERT(size_t(aIndex > 0 ? aIndex : -aIndex) <= size_t(-1) / sizeof(T)); - return *create(mPtr + aIndex); - } - - T& operator*() const - { - MOZ_ASSERT(mPtr >= mRangeStart); - MOZ_ASSERT(mPtr < mRangeEnd); - return *mPtr; - } - - T* operator->() const - { - MOZ_ASSERT(mPtr >= mRangeStart); - MOZ_ASSERT(mPtr < mRangeEnd); - return mPtr; - } - - template <typename U> - bool operator==(const RangedPtr<U>& aOther) const - { - return mPtr == aOther.mPtr; - } - template <typename U> - bool operator!=(const RangedPtr<U>& aOther) const - { - return !(*this == aOther); - } - - template<typename U> - bool operator==(const U* u) const - { - return mPtr == u; - } - template<typename U> - bool operator!=(const U* u) const - { - return !(*this == u); - } - - template <typename U> - bool operator<(const RangedPtr<U>& aOther) const - { - return mPtr < aOther.mPtr; - } - template <typename U> - bool operator<=(const RangedPtr<U>& aOther) const - { - return mPtr <= aOther.mPtr; - } - - template <typename U> - bool operator>(const RangedPtr<U>& aOther) const - { - return mPtr > aOther.mPtr; - } - template <typename U> - bool operator>=(const RangedPtr<U>& aOther) const - { - return mPtr >= aOther.mPtr; - } - - size_t operator-(const RangedPtr<T>& aOther) const - { - MOZ_ASSERT(mPtr >= aOther.mPtr); - return PointerRangeSize(aOther.mPtr, mPtr); - } - -private: - RangedPtr() = delete; - T* operator&() = delete; -}; - -} /* namespace mozilla */ - -#endif /* mozilla_RangedPtr_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/ReentrancyGuard.h b/android/armeabi/include/spidermonkey/mozilla/ReentrancyGuard.h deleted file mode 100644 index 9963974e..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/ReentrancyGuard.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Small helper class for asserting uses of a class are non-reentrant. */ - -#ifndef mozilla_ReentrancyGuard_h -#define mozilla_ReentrancyGuard_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/GuardObjects.h" - -namespace mozilla { - -/* Useful for implementing containers that assert non-reentrancy */ -class MOZ_RAII ReentrancyGuard -{ - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -#ifdef DEBUG - bool& mEntered; -#endif - -public: - template<class T> -#ifdef DEBUG - explicit ReentrancyGuard(T& aObj - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : mEntered(aObj.mEntered) -#else - explicit ReentrancyGuard(T& - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) -#endif - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; -#ifdef DEBUG - MOZ_ASSERT(!mEntered); - mEntered = true; -#endif - } - ~ReentrancyGuard() - { -#ifdef DEBUG - mEntered = false; -#endif - } - -private: - ReentrancyGuard(const ReentrancyGuard&) = delete; - void operator=(const ReentrancyGuard&) = delete; -}; - -} // namespace mozilla - -#endif /* mozilla_ReentrancyGuard_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/RefCountType.h b/android/armeabi/include/spidermonkey/mozilla/RefCountType.h deleted file mode 100644 index e95a22a0..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/RefCountType.h +++ /dev/null @@ -1,37 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_RefCountType_h -#define mozilla_RefCountType_h - -#include <stdint.h> - -/** - * MozRefCountType is Mozilla's reference count type. - * - * We use the same type to represent the refcount of RefCounted objects - * as well, in order to be able to use the leak detection facilities - * that are implemented by XPCOM. - * - * Note that this type is not in the mozilla namespace so that it is - * usable for both C and C++ code. - */ -typedef uintptr_t MozRefCountType; - -/* - * This is the return type for AddRef() and Release() in nsISupports. - * IUnknown of COM returns an unsigned long from equivalent functions. - * - * The following ifdef exists to maintain binary compatibility with - * IUnknown, the base interface in Microsoft COM. - */ -#ifdef XP_WIN -typedef unsigned long MozExternalRefCountType; -#else -typedef uint32_t MozExternalRefCountType; -#endif - -#endif diff --git a/android/armeabi/include/spidermonkey/mozilla/RefCounted.h b/android/armeabi/include/spidermonkey/mozilla/RefCounted.h deleted file mode 100644 index ae05f1e0..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/RefCounted.h +++ /dev/null @@ -1,210 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* CRTP refcounting templates. Do not use unless you are an Expert. */ - -#ifndef mozilla_RefCounted_h -#define mozilla_RefCounted_h - -#include "mozilla/AlreadyAddRefed.h" -#include "mozilla/Assertions.h" -#include "mozilla/Atomics.h" -#include "mozilla/Attributes.h" -#include "mozilla/Move.h" -#include "mozilla/RefCountType.h" -#include "mozilla/TypeTraits.h" - -#if defined(MOZILLA_INTERNAL_API) -#include "nsXPCOM.h" -#endif - -#if defined(MOZILLA_INTERNAL_API) && \ - (defined(DEBUG) || defined(FORCE_BUILD_REFCNT_LOGGING)) -#define MOZ_REFCOUNTED_LEAK_CHECKING -#endif - -namespace mozilla { - -/** - * RefCounted<T> is a sort of a "mixin" for a class T. RefCounted - * manages, well, refcounting for T, and because RefCounted is - * parameterized on T, RefCounted<T> can call T's destructor directly. - * This means T doesn't need to have a virtual dtor and so doesn't - * need a vtable. - * - * RefCounted<T> is created with refcount == 0. Newly-allocated - * RefCounted<T> must immediately be assigned to a RefPtr to make the - * refcount > 0. It's an error to allocate and free a bare - * RefCounted<T>, i.e. outside of the RefPtr machinery. Attempts to - * do so will abort DEBUG builds. - * - * Live RefCounted<T> have refcount > 0. The lifetime (refcounts) of - * live RefCounted<T> are controlled by RefPtr<T> and - * RefPtr<super/subclass of T>. Upon a transition from refcounted==1 - * to 0, the RefCounted<T> "dies" and is destroyed. The "destroyed" - * state is represented in DEBUG builds by refcount==0xffffdead. This - * state distinguishes use-before-ref (refcount==0) from - * use-after-destroy (refcount==0xffffdead). - * - * Note that when deriving from RefCounted or AtomicRefCounted, you - * should add MOZ_DECLARE_REFCOUNTED_TYPENAME(ClassName) to the public - * section of your class, where ClassName is the name of your class. - */ -namespace detail { -const MozRefCountType DEAD = 0xffffdead; - -// When building code that gets compiled into Gecko, try to use the -// trace-refcount leak logging facilities. -#ifdef MOZ_REFCOUNTED_LEAK_CHECKING -class RefCountLogger -{ -public: - static void logAddRef(const void* aPointer, MozRefCountType aRefCount, - const char* aTypeName, uint32_t aInstanceSize) - { - MOZ_ASSERT(aRefCount != DEAD); - NS_LogAddRef(const_cast<void*>(aPointer), aRefCount, aTypeName, - aInstanceSize); - } - - static void logRelease(const void* aPointer, MozRefCountType aRefCount, - const char* aTypeName) - { - MOZ_ASSERT(aRefCount != DEAD); - NS_LogRelease(const_cast<void*>(aPointer), aRefCount, aTypeName); - } -}; -#endif - -// This is used WeakPtr.h as well as this file. -enum RefCountAtomicity -{ - AtomicRefCount, - NonAtomicRefCount -}; - -template<typename T, RefCountAtomicity Atomicity> -class RefCounted -{ -protected: - RefCounted() : mRefCnt(0) {} - ~RefCounted() { MOZ_ASSERT(mRefCnt == detail::DEAD); } - -public: - // Compatibility with nsRefPtr. - void AddRef() const - { - // Note: this method must be thread safe for AtomicRefCounted. - MOZ_ASSERT(int32_t(mRefCnt) >= 0); -#ifndef MOZ_REFCOUNTED_LEAK_CHECKING - ++mRefCnt; -#else - const char* type = static_cast<const T*>(this)->typeName(); - uint32_t size = static_cast<const T*>(this)->typeSize(); - const void* ptr = static_cast<const T*>(this); - MozRefCountType cnt = ++mRefCnt; - detail::RefCountLogger::logAddRef(ptr, cnt, type, size); -#endif - } - - void Release() const - { - // Note: this method must be thread safe for AtomicRefCounted. - MOZ_ASSERT(int32_t(mRefCnt) > 0); -#ifndef MOZ_REFCOUNTED_LEAK_CHECKING - MozRefCountType cnt = --mRefCnt; -#else - const char* type = static_cast<const T*>(this)->typeName(); - const void* ptr = static_cast<const T*>(this); - MozRefCountType cnt = --mRefCnt; - // Note: it's not safe to touch |this| after decrementing the refcount, - // except for below. - detail::RefCountLogger::logRelease(ptr, cnt, type); -#endif - if (0 == cnt) { - // Because we have atomically decremented the refcount above, only - // one thread can get a 0 count here, so as long as we can assume that - // everything else in the system is accessing this object through - // RefPtrs, it's safe to access |this| here. -#ifdef DEBUG - mRefCnt = detail::DEAD; -#endif - delete static_cast<const T*>(this); - } - } - - // Compatibility with wtf::RefPtr. - void ref() { AddRef(); } - void deref() { Release(); } - MozRefCountType refCount() const { return mRefCnt; } - bool hasOneRef() const - { - MOZ_ASSERT(mRefCnt > 0); - return mRefCnt == 1; - } - -private: - mutable typename Conditional<Atomicity == AtomicRefCount, - Atomic<MozRefCountType>, - MozRefCountType>::Type mRefCnt; -}; - -#ifdef MOZ_REFCOUNTED_LEAK_CHECKING -// Passing override for the optional argument marks the typeName and -// typeSize functions defined by this macro as overrides. -#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T, ...) \ - virtual const char* typeName() const __VA_ARGS__ { return #T; } \ - virtual size_t typeSize() const __VA_ARGS__ { return sizeof(*this); } -#else -#define MOZ_DECLARE_REFCOUNTED_VIRTUAL_TYPENAME(T, ...) -#endif - -// Note that this macro is expanded unconditionally because it declares only -// two small inline functions which will hopefully get eliminated by the linker -// in non-leak-checking builds. -#define MOZ_DECLARE_REFCOUNTED_TYPENAME(T) \ - const char* typeName() const { return #T; } \ - size_t typeSize() const { return sizeof(*this); } - -} // namespace detail - -template<typename T> -class RefCounted : public detail::RefCounted<T, detail::NonAtomicRefCount> -{ -public: - ~RefCounted() - { - static_assert(IsBaseOf<RefCounted, T>::value, - "T must derive from RefCounted<T>"); - } -}; - -namespace external { - -/** - * AtomicRefCounted<T> is like RefCounted<T>, with an atomically updated - * reference counter. - * - * NOTE: Please do not use this class, use NS_INLINE_DECL_THREADSAFE_REFCOUNTING - * instead. - */ -template<typename T> -class AtomicRefCounted : - public mozilla::detail::RefCounted<T, mozilla::detail::AtomicRefCount> -{ -public: - ~AtomicRefCounted() - { - static_assert(IsBaseOf<AtomicRefCounted, T>::value, - "T must derive from AtomicRefCounted<T>"); - } -}; - -} // namespace external - -} // namespace mozilla - -#endif // mozilla_RefCounted_h diff --git a/android/armeabi/include/spidermonkey/mozilla/RefPtr.h b/android/armeabi/include/spidermonkey/mozilla/RefPtr.h deleted file mode 100644 index bfa8f6e0..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/RefPtr.h +++ /dev/null @@ -1,656 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_RefPtr_h -#define mozilla_RefPtr_h - -#include "mozilla/AlreadyAddRefed.h" -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" - -/*****************************************************************************/ - -// template <class T> class RefPtrGetterAddRefs; - -class nsCOMPtr_helper; - -namespace mozilla { -template<class T> class OwningNonNull; -template<class T> class StaticRefPtr; - -// Traditionally, RefPtr supports automatic refcounting of any pointer type -// with AddRef() and Release() methods that follow the traditional semantics. -// -// This traits class can be specialized to operate on other pointer types. For -// example, we specialize this trait for opaque FFI types that represent -// refcounted objects in Rust. -// -// Given the use of ConstRemovingRefPtrTraits below, U should not be a const- -// qualified type. -template<class U> -struct RefPtrTraits -{ - static void AddRef(U* aPtr) { - aPtr->AddRef(); - } - static void Release(U* aPtr) { - aPtr->Release(); - } -}; - -} // namespace mozilla - -template <class T> -class RefPtr -{ -private: - void - assign_with_AddRef(T* aRawPtr) - { - if (aRawPtr) { - ConstRemovingRefPtrTraits<T>::AddRef(aRawPtr); - } - assign_assuming_AddRef(aRawPtr); - } - - void - assign_assuming_AddRef(T* aNewPtr) - { - T* oldPtr = mRawPtr; - mRawPtr = aNewPtr; - if (oldPtr) { - ConstRemovingRefPtrTraits<T>::Release(oldPtr); - } - } - -private: - T* MOZ_OWNING_REF mRawPtr; - -public: - typedef T element_type; - - ~RefPtr() - { - if (mRawPtr) { - ConstRemovingRefPtrTraits<T>::Release(mRawPtr); - } - } - - // Constructors - - RefPtr() - : mRawPtr(nullptr) - // default constructor - { - } - - RefPtr(const RefPtr<T>& aSmartPtr) - : mRawPtr(aSmartPtr.mRawPtr) - // copy-constructor - { - if (mRawPtr) { - ConstRemovingRefPtrTraits<T>::AddRef(mRawPtr); - } - } - - RefPtr(RefPtr<T>&& aRefPtr) - : mRawPtr(aRefPtr.mRawPtr) - { - aRefPtr.mRawPtr = nullptr; - } - - // construct from a raw pointer (of the right type) - - MOZ_IMPLICIT RefPtr(T* aRawPtr) - : mRawPtr(aRawPtr) - { - if (mRawPtr) { - ConstRemovingRefPtrTraits<T>::AddRef(mRawPtr); - } - } - - MOZ_IMPLICIT RefPtr(decltype(nullptr)) - : mRawPtr(nullptr) - { - } - - template <typename I> - MOZ_IMPLICIT RefPtr(already_AddRefed<I>& aSmartPtr) - : mRawPtr(aSmartPtr.take()) - // construct from |already_AddRefed| - { - } - - template <typename I> - MOZ_IMPLICIT RefPtr(already_AddRefed<I>&& aSmartPtr) - : mRawPtr(aSmartPtr.take()) - // construct from |otherRefPtr.forget()| - { - } - - template <typename I> - MOZ_IMPLICIT RefPtr(const RefPtr<I>& aSmartPtr) - : mRawPtr(aSmartPtr.get()) - // copy-construct from a smart pointer with a related pointer type - { - if (mRawPtr) { - ConstRemovingRefPtrTraits<T>::AddRef(mRawPtr); - } - } - - template <typename I> - MOZ_IMPLICIT RefPtr(RefPtr<I>&& aSmartPtr) - : mRawPtr(aSmartPtr.forget().take()) - // construct from |Move(RefPtr<SomeSubclassOfT>)|. - { - } - - MOZ_IMPLICIT RefPtr(const nsCOMPtr_helper& aHelper); - - // Defined in OwningNonNull.h - template<class U> - MOZ_IMPLICIT RefPtr(const mozilla::OwningNonNull<U>& aOther); - - // Defined in StaticPtr.h - template<class U> - MOZ_IMPLICIT RefPtr(const mozilla::StaticRefPtr<U>& aOther); - - // Assignment operators - - RefPtr<T>& - operator=(decltype(nullptr)) - { - assign_assuming_AddRef(nullptr); - return *this; - } - - RefPtr<T>& - operator=(const RefPtr<T>& aRhs) - // copy assignment operator - { - assign_with_AddRef(aRhs.mRawPtr); - return *this; - } - - template <typename I> - RefPtr<T>& - operator=(const RefPtr<I>& aRhs) - // assign from an RefPtr of a related pointer type - { - assign_with_AddRef(aRhs.get()); - return *this; - } - - RefPtr<T>& - operator=(T* aRhs) - // assign from a raw pointer (of the right type) - { - assign_with_AddRef(aRhs); - return *this; - } - - template <typename I> - RefPtr<T>& - operator=(already_AddRefed<I>& aRhs) - // assign from |already_AddRefed| - { - assign_assuming_AddRef(aRhs.take()); - return *this; - } - - template <typename I> - RefPtr<T>& - operator=(already_AddRefed<I> && aRhs) - // assign from |otherRefPtr.forget()| - { - assign_assuming_AddRef(aRhs.take()); - return *this; - } - - RefPtr<T>& operator=(const nsCOMPtr_helper& aHelper); - - RefPtr<T>& - operator=(RefPtr<T> && aRefPtr) - { - assign_assuming_AddRef(aRefPtr.mRawPtr); - aRefPtr.mRawPtr = nullptr; - return *this; - } - - // Defined in OwningNonNull.h - template<class U> - RefPtr<T>& - operator=(const mozilla::OwningNonNull<U>& aOther); - - // Defined in StaticPtr.h - template<class U> - RefPtr<T>& - operator=(const mozilla::StaticRefPtr<U>& aOther); - - // Other pointer operators - - void - swap(RefPtr<T>& aRhs) - // ...exchange ownership with |aRhs|; can save a pair of refcount operations - { - T* temp = aRhs.mRawPtr; - aRhs.mRawPtr = mRawPtr; - mRawPtr = temp; - } - - void - swap(T*& aRhs) - // ...exchange ownership with |aRhs|; can save a pair of refcount operations - { - T* temp = aRhs; - aRhs = mRawPtr; - mRawPtr = temp; - } - - already_AddRefed<T> - forget() - // return the value of mRawPtr and null out mRawPtr. Useful for - // already_AddRefed return values. - { - T* temp = nullptr; - swap(temp); - return already_AddRefed<T>(temp); - } - - template <typename I> - void - forget(I** aRhs) - // Set the target of aRhs to the value of mRawPtr and null out mRawPtr. - // Useful to avoid unnecessary AddRef/Release pairs with "out" - // parameters where aRhs bay be a T** or an I** where I is a base class - // of T. - { - MOZ_ASSERT(aRhs, "Null pointer passed to forget!"); - *aRhs = mRawPtr; - mRawPtr = nullptr; - } - - T* - get() const - /* - Prefer the implicit conversion provided automatically by |operator T*() const|. - Use |get()| to resolve ambiguity or to get a castable pointer. - */ - { - return const_cast<T*>(mRawPtr); - } - - operator T*() const -#ifdef MOZ_HAVE_REF_QUALIFIERS - & -#endif - /* - ...makes an |RefPtr| act like its underlying raw pointer type whenever it - is used in a context where a raw pointer is expected. It is this operator - that makes an |RefPtr| substitutable for a raw pointer. - - Prefer the implicit use of this operator to calling |get()|, except where - necessary to resolve ambiguity. - */ - { - return get(); - } - -#ifdef MOZ_HAVE_REF_QUALIFIERS - // Don't allow implicit conversion of temporary RefPtr to raw pointer, - // because the refcount might be one and the pointer will immediately become - // invalid. - operator T*() const && = delete; - - // These are needed to avoid the deleted operator above. XXX Why is operator! - // needed separately? Shouldn't the compiler prefer using the non-deleted - // operator bool instead of the deleted operator T*? - explicit operator bool() const { return !!mRawPtr; } - bool operator!() const { return !mRawPtr; } -#endif - - T* - operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN - { - MOZ_ASSERT(mRawPtr != nullptr, - "You can't dereference a NULL RefPtr with operator->()."); - return get(); - } - - template <typename R, typename... Args> - class Proxy - { - typedef R (T::*member_function)(Args...); - T* mRawPtr; - member_function mFunction; - public: - Proxy(T* aRawPtr, member_function aFunction) - : mRawPtr(aRawPtr), - mFunction(aFunction) - { - } - template<typename... ActualArgs> - R operator()(ActualArgs&&... aArgs) - { - return ((*mRawPtr).*mFunction)(mozilla::Forward<ActualArgs>(aArgs)...); - } - }; - - template <typename R, typename... Args> - Proxy<R, Args...> operator->*(R (T::*aFptr)(Args...)) const - { - MOZ_ASSERT(mRawPtr != nullptr, - "You can't dereference a NULL RefPtr with operator->*()."); - return Proxy<R, Args...>(get(), aFptr); - } - - RefPtr<T>* - get_address() - // This is not intended to be used by clients. See |address_of| - // below. - { - return this; - } - - const RefPtr<T>* - get_address() const - // This is not intended to be used by clients. See |address_of| - // below. - { - return this; - } - -public: - T& - operator*() const - { - MOZ_ASSERT(mRawPtr != nullptr, - "You can't dereference a NULL RefPtr with operator*()."); - return *get(); - } - - T** - StartAssignment() - { - assign_assuming_AddRef(nullptr); - return reinterpret_cast<T**>(&mRawPtr); - } -private: - // This helper class makes |RefPtr<const T>| possible by casting away - // the constness from the pointer when calling AddRef() and Release(). - // - // This is necessary because AddRef() and Release() implementations can't - // generally expected to be const themselves (without heavy use of |mutable| - // and |const_cast| in their own implementations). - // - // This should be sound because while |RefPtr<const T>| provides a - // const view of an object, the object itself should not be const (it - // would have to be allocated as |new const T| or similar to be const). - template<class U> - struct ConstRemovingRefPtrTraits - { - static void AddRef(U* aPtr) { - mozilla::RefPtrTraits<U>::AddRef(aPtr); - } - static void Release(U* aPtr) { - mozilla::RefPtrTraits<U>::Release(aPtr); - } - }; - template<class U> - struct ConstRemovingRefPtrTraits<const U> - { - static void AddRef(const U* aPtr) { - mozilla::RefPtrTraits<U>::AddRef(const_cast<U*>(aPtr)); - } - static void Release(const U* aPtr) { - mozilla::RefPtrTraits<U>::Release(const_cast<U*>(aPtr)); - } - }; -}; - -class nsCycleCollectionTraversalCallback; -template <typename T> -void -CycleCollectionNoteChild(nsCycleCollectionTraversalCallback& aCallback, - T* aChild, const char* aName, uint32_t aFlags); - -template <typename T> -inline void -ImplCycleCollectionUnlink(RefPtr<T>& aField) -{ - aField = nullptr; -} - -template <typename T> -inline void -ImplCycleCollectionTraverse(nsCycleCollectionTraversalCallback& aCallback, - RefPtr<T>& aField, - const char* aName, - uint32_t aFlags = 0) -{ - CycleCollectionNoteChild(aCallback, aField.get(), aName, aFlags); -} - -template <class T> -inline RefPtr<T>* -address_of(RefPtr<T>& aPtr) -{ - return aPtr.get_address(); -} - -template <class T> -inline const RefPtr<T>* -address_of(const RefPtr<T>& aPtr) -{ - return aPtr.get_address(); -} - -template <class T> -class RefPtrGetterAddRefs -/* - ... - - This class is designed to be used for anonymous temporary objects in the - argument list of calls that return COM interface pointers, e.g., - - RefPtr<IFoo> fooP; - ...->GetAddRefedPointer(getter_AddRefs(fooP)) - - DO NOT USE THIS TYPE DIRECTLY IN YOUR CODE. Use |getter_AddRefs()| instead. - - When initialized with a |RefPtr|, as in the example above, it returns - a |void**|, a |T**|, or an |nsISupports**| as needed, that the - outer call (|GetAddRefedPointer| in this case) can fill in. - - This type should be a nested class inside |RefPtr<T>|. -*/ -{ -public: - explicit - RefPtrGetterAddRefs(RefPtr<T>& aSmartPtr) - : mTargetSmartPtr(aSmartPtr) - { - // nothing else to do - } - - operator void**() - { - return reinterpret_cast<void**>(mTargetSmartPtr.StartAssignment()); - } - - operator T**() - { - return mTargetSmartPtr.StartAssignment(); - } - - T*& - operator*() - { - return *(mTargetSmartPtr.StartAssignment()); - } - -private: - RefPtr<T>& mTargetSmartPtr; -}; - -template <class T> -inline RefPtrGetterAddRefs<T> -getter_AddRefs(RefPtr<T>& aSmartPtr) -/* - Used around a |RefPtr| when - ...makes the class |RefPtrGetterAddRefs<T>| invisible. -*/ -{ - return RefPtrGetterAddRefs<T>(aSmartPtr); -} - - -// Comparing two |RefPtr|s - -template <class T, class U> -inline bool -operator==(const RefPtr<T>& aLhs, const RefPtr<U>& aRhs) -{ - return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs.get()); -} - - -template <class T, class U> -inline bool -operator!=(const RefPtr<T>& aLhs, const RefPtr<U>& aRhs) -{ - return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs.get()); -} - - -// Comparing an |RefPtr| to a raw pointer - -template <class T, class U> -inline bool -operator==(const RefPtr<T>& aLhs, const U* aRhs) -{ - return static_cast<const T*>(aLhs.get()) == static_cast<const U*>(aRhs); -} - -template <class T, class U> -inline bool -operator==(const U* aLhs, const RefPtr<T>& aRhs) -{ - return static_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get()); -} - -template <class T, class U> -inline bool -operator!=(const RefPtr<T>& aLhs, const U* aRhs) -{ - return static_cast<const T*>(aLhs.get()) != static_cast<const U*>(aRhs); -} - -template <class T, class U> -inline bool -operator!=(const U* aLhs, const RefPtr<T>& aRhs) -{ - return static_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get()); -} - -template <class T, class U> -inline bool -operator==(const RefPtr<T>& aLhs, U* aRhs) -{ - return static_cast<const T*>(aLhs.get()) == const_cast<const U*>(aRhs); -} - -template <class T, class U> -inline bool -operator==(U* aLhs, const RefPtr<T>& aRhs) -{ - return const_cast<const U*>(aLhs) == static_cast<const T*>(aRhs.get()); -} - -template <class T, class U> -inline bool -operator!=(const RefPtr<T>& aLhs, U* aRhs) -{ - return static_cast<const T*>(aLhs.get()) != const_cast<const U*>(aRhs); -} - -template <class T, class U> -inline bool -operator!=(U* aLhs, const RefPtr<T>& aRhs) -{ - return const_cast<const U*>(aLhs) != static_cast<const T*>(aRhs.get()); -} - -// Comparing an |RefPtr| to |nullptr| - -template <class T> -inline bool -operator==(const RefPtr<T>& aLhs, decltype(nullptr)) -{ - return aLhs.get() == nullptr; -} - -template <class T> -inline bool -operator==(decltype(nullptr), const RefPtr<T>& aRhs) -{ - return nullptr == aRhs.get(); -} - -template <class T> -inline bool -operator!=(const RefPtr<T>& aLhs, decltype(nullptr)) -{ - return aLhs.get() != nullptr; -} - -template <class T> -inline bool -operator!=(decltype(nullptr), const RefPtr<T>& aRhs) -{ - return nullptr != aRhs.get(); -} - -/*****************************************************************************/ - -template <class T> -inline already_AddRefed<T> -do_AddRef(T* aObj) -{ - RefPtr<T> ref(aObj); - return ref.forget(); -} - -template <class T> -inline already_AddRefed<T> -do_AddRef(const RefPtr<T>& aObj) -{ - RefPtr<T> ref(aObj); - return ref.forget(); -} - -namespace mozilla { - -/** - * Helper function to be able to conveniently write things like: - * - * already_AddRefed<T> - * f(...) - * { - * return MakeAndAddRef<T>(...); - * } - */ -template<typename T, typename... Args> -already_AddRefed<T> -MakeAndAddRef(Args&&... aArgs) -{ - RefPtr<T> p(new T(Forward<Args>(aArgs)...)); - return p.forget(); -} - -} // namespace mozilla - -#endif /* mozilla_RefPtr_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/ReverseIterator.h b/android/armeabi/include/spidermonkey/mozilla/ReverseIterator.h deleted file mode 100644 index 49c2e279..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/ReverseIterator.h +++ /dev/null @@ -1,168 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* An iterator that acts like another iterator, but iterating in - * the negative direction. (Note that not all iterators can iterate - * in the negative direction.) */ - -#ifndef mozilla_ReverseIterator_h -#define mozilla_ReverseIterator_h - -#include "mozilla/Attributes.h" -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -template<typename IteratorT> -class ReverseIterator -{ -public: - template<typename Iterator> - explicit ReverseIterator(Iterator aIter) - : mCurrent(aIter) { } - - template<typename Iterator> - MOZ_IMPLICIT ReverseIterator(const ReverseIterator<Iterator>& aOther) - : mCurrent(aOther.mCurrent) { } - - decltype(*DeclVal<IteratorT>()) operator*() const - { - IteratorT tmp = mCurrent; - return *--tmp; - } - - /* Increments and decrements operators */ - - ReverseIterator& operator++() { --mCurrent; return *this; } - ReverseIterator& operator--() { ++mCurrent; return *this; } - ReverseIterator operator++(int) { auto ret = *this; mCurrent--; return ret; } - ReverseIterator operator--(int) { auto ret = *this; mCurrent++; return ret; } - - /* Comparison operators */ - - template<typename Iterator1, typename Iterator2> - friend bool operator==(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2); - template<typename Iterator1, typename Iterator2> - friend bool operator!=(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2); - template<typename Iterator1, typename Iterator2> - friend bool operator<(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2); - template<typename Iterator1, typename Iterator2> - friend bool operator<=(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2); - template<typename Iterator1, typename Iterator2> - friend bool operator>(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2); - template<typename Iterator1, typename Iterator2> - friend bool operator>=(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2); - -private: - IteratorT mCurrent; -}; - -template<typename Iterator1, typename Iterator2> -bool -operator==(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2) -{ - return aIter1.mCurrent == aIter2.mCurrent; -} - -template<typename Iterator1, typename Iterator2> -bool -operator!=(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2) -{ - return aIter1.mCurrent != aIter2.mCurrent; -} - -template<typename Iterator1, typename Iterator2> -bool -operator<(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2) -{ - return aIter1.mCurrent > aIter2.mCurrent; -} - -template<typename Iterator1, typename Iterator2> -bool -operator<=(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2) -{ - return aIter1.mCurrent >= aIter2.mCurrent; -} - -template<typename Iterator1, typename Iterator2> -bool -operator>(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2) -{ - return aIter1.mCurrent < aIter2.mCurrent; -} - -template<typename Iterator1, typename Iterator2> -bool -operator>=(const ReverseIterator<Iterator1>& aIter1, - const ReverseIterator<Iterator2>& aIter2) -{ - return aIter1.mCurrent <= aIter2.mCurrent; -} - -namespace detail { - -template<typename IteratorT> -class IteratorRange -{ -public: - typedef IteratorT iterator; - typedef IteratorT const_iterator; - typedef ReverseIterator<IteratorT> reverse_iterator; - typedef ReverseIterator<IteratorT> const_reverse_iterator; - - template<typename Iterator1, typename Iterator2> - MOZ_IMPLICIT IteratorRange(Iterator1 aIterBegin, Iterator2 aIterEnd) - : mIterBegin(aIterBegin), mIterEnd(aIterEnd) { } - - template<typename Iterator> - MOZ_IMPLICIT IteratorRange(const IteratorRange<Iterator>& aOther) - : mIterBegin(aOther.mIterBegin), mIterEnd(aOther.mIterEnd) { } - - iterator begin() const { return mIterBegin; } - const_iterator cbegin() const { return begin(); } - iterator end() const { return mIterEnd; } - const_iterator cend() const { return end(); } - reverse_iterator rbegin() const { return reverse_iterator(mIterEnd); } - const_reverse_iterator crbegin() const { return rbegin(); } - reverse_iterator rend() const { return reverse_iterator(mIterBegin); } - const_reverse_iterator crend() const { return rend(); } - -private: - IteratorT mIterBegin; - IteratorT mIterEnd; -}; - -} // namespace detail - -template<typename Range> -detail::IteratorRange<typename Range::reverse_iterator> -Reversed(Range& aRange) -{ - return {aRange.rbegin(), aRange.rend()}; -} - -template<typename Range> -detail::IteratorRange<typename Range::const_reverse_iterator> -Reversed(const Range& aRange) -{ - return {aRange.rbegin(), aRange.rend()}; -} - -} // namespace mozilla - -#endif // mozilla_ReverseIterator_h diff --git a/android/armeabi/include/spidermonkey/mozilla/RollingMean.h b/android/armeabi/include/spidermonkey/mozilla/RollingMean.h deleted file mode 100644 index 8cc3148e..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/RollingMean.h +++ /dev/null @@ -1,115 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A set abstraction for enumeration values. */ - -#ifndef mozilla_RollingMean_h_ -#define mozilla_RollingMean_h_ - -#include "mozilla/Assertions.h" -#include "mozilla/TypeTraits.h" -#include "mozilla/Vector.h" - -#include <stddef.h> - -namespace mozilla { - -/** - * RollingMean<T> calculates a rolling mean of the values it is given. It - * accumulates the total as values are added and removed. The second type - * argument S specifies the type of the total. This may need to be a bigger - * type in order to maintain that the sum of all values in the average doesn't - * exceed the maximum input value. - * - * WARNING: Float types are not supported due to rounding errors. - */ -template<typename T, typename S> -class RollingMean -{ -private: - size_t mInsertIndex; - size_t mMaxValues; - Vector<T> mValues; - S mTotal; - -public: - static_assert(!IsFloatingPoint<T>::value, - "floating-point types are unsupported due to rounding " - "errors"); - - explicit RollingMean(size_t aMaxValues) - : mInsertIndex(0), - mMaxValues(aMaxValues), - mTotal(0) - { - MOZ_ASSERT(aMaxValues > 0); - } - - RollingMean& operator=(RollingMean&& aOther) - { - MOZ_ASSERT(this != &aOther, "self-assignment is forbidden"); - this->~RollingMean(); - new(this) RollingMean(aOther.mMaxValues); - mInsertIndex = aOther.mInsertIndex; - mTotal = aOther.mTotal; - mValues.swap(aOther.mValues); - return *this; - } - - /** - * Insert a value into the rolling mean. - */ - bool insert(T aValue) - { - MOZ_ASSERT(mValues.length() <= mMaxValues); - - if (mValues.length() == mMaxValues) { - mTotal = mTotal - mValues[mInsertIndex] + aValue; - mValues[mInsertIndex] = aValue; - } else { - if (!mValues.append(aValue)) { - return false; - } - mTotal = mTotal + aValue; - } - - mInsertIndex = (mInsertIndex + 1) % mMaxValues; - return true; - } - - /** - * Calculate the rolling mean. - */ - T mean() - { - MOZ_ASSERT(!empty()); - return T(mTotal / int64_t(mValues.length())); - } - - bool empty() - { - return mValues.empty(); - } - - /** - * Remove all values from the rolling mean. - */ - void clear() - { - mValues.clear(); - mInsertIndex = 0; - mTotal = T(0); - } - - size_t maxValues() - { - return mMaxValues; - } -}; - -} // namespace mozilla - -#endif // mozilla_RollingMean_h_ diff --git a/android/armeabi/include/spidermonkey/mozilla/SHA1.h b/android/armeabi/include/spidermonkey/mozilla/SHA1.h deleted file mode 100644 index ddccaa67..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/SHA1.h +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Simple class for computing SHA1. */ - -#ifndef mozilla_SHA1_h -#define mozilla_SHA1_h - -#include "mozilla/Types.h" - -#include <stddef.h> -#include <stdint.h> - -namespace mozilla { - -/** - * This class computes the SHA1 hash of a byte sequence, or of the concatenation - * of multiple sequences. For example, computing the SHA1 of two sequences of - * bytes could be done as follows: - * - * void SHA1(const uint8_t* buf1, uint32_t size1, - * const uint8_t* buf2, uint32_t size2, - * SHA1Sum::Hash& hash) - * { - * SHA1Sum s; - * s.update(buf1, size1); - * s.update(buf2, size2); - * s.finish(hash); - * } - * - * The finish method may only be called once and cannot be followed by calls - * to update. - */ -class SHA1Sum -{ - union - { - uint32_t mW[16]; /* input buffer */ - uint8_t mB[64]; - } mU; - uint64_t mSize; /* count of hashed bytes. */ - unsigned mH[22]; /* 5 state variables, 16 tmp values, 1 extra */ - bool mDone; - -public: - MFBT_API SHA1Sum(); - - static const size_t kHashSize = 20; - typedef uint8_t Hash[kHashSize]; - - /* Add len bytes of dataIn to the data sequence being hashed. */ - MFBT_API void update(const void* aData, uint32_t aLength); - - /* Compute the final hash of all data into hashOut. */ - MFBT_API void finish(SHA1Sum::Hash& aHashOut); -}; - -} /* namespace mozilla */ - -#endif /* mozilla_SHA1_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Saturate.h b/android/armeabi/include/spidermonkey/mozilla/Saturate.h deleted file mode 100644 index b79364d2..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Saturate.h +++ /dev/null @@ -1,288 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Provides saturation arithmetics for scalar types. */ - -#ifndef mozilla_Saturate_h -#define mozilla_Saturate_h - -#include "mozilla/Attributes.h" -#include "mozilla/Move.h" -#include "mozilla/TypeTraits.h" - -#include <limits> - -namespace mozilla { -namespace detail { - -/** - * |SaturateOp<T>| wraps scalar values for saturation arithmetics. Usage: - * - * uint32_t value = 1; - * - * ++SaturateOp<uint32_t>(value); // value is 2 - * --SaturateOp<uint32_t>(value); // value is 1 - * --SaturateOp<uint32_t>(value); // value is 0 - * --SaturateOp<uint32_t>(value); // value is still 0 - * - * Please add new operators when required. - * - * |SaturateOp<T>| will saturate at the minimum and maximum values of - * type T. If you need other bounds, implement a clamped-type class and - * specialize the type traits accordingly. - */ -template <typename T> -class SaturateOp -{ -public: - explicit SaturateOp(T& aValue) - : mValue(aValue) - { - // We should actually check for |std::is_scalar<T>::value| to be - // true, but this type trait is not available everywhere. Relax - // this assertion if you want to use floating point values as well. - static_assert(IsIntegral<T>::value, - "Integral type required in instantiation"); - } - - // Add and subtract operators - - T operator+(const T& aRhs) const - { - return T(mValue) += aRhs; - } - - T operator-(const T& aRhs) const - { - return T(mValue) -= aRhs; - } - - // Compound operators - - const T& operator+=(const T& aRhs) const - { - const T min = std::numeric_limits<T>::min(); - const T max = std::numeric_limits<T>::max(); - - if (aRhs > static_cast<T>(0)) { - mValue = (max - aRhs) < mValue ? max : mValue + aRhs; - } else { - mValue = (min - aRhs) > mValue ? min : mValue + aRhs; - } - return mValue; - } - - const T& operator-=(const T& aRhs) const - { - const T min = std::numeric_limits<T>::min(); - const T max = std::numeric_limits<T>::max(); - - if (aRhs > static_cast<T>(0)) { - mValue = (min + aRhs) > mValue ? min : mValue - aRhs; - } else { - mValue = (max + aRhs) < mValue ? max : mValue - aRhs; - } - return mValue; - } - - // Increment and decrement operators - - const T& operator++() const // prefix - { - return operator+=(static_cast<T>(1)); - } - - T operator++(int) const // postfix - { - const T value(mValue); - operator++(); - return value; - } - - const T& operator--() const // prefix - { - return operator-=(static_cast<T>(1)); - } - - T operator--(int) const // postfix - { - const T value(mValue); - operator--(); - return value; - } - -private: - SaturateOp(const SaturateOp<T>&) = delete; - SaturateOp(SaturateOp<T>&&) = delete; - SaturateOp& operator=(const SaturateOp<T>&) = delete; - SaturateOp& operator=(SaturateOp<T>&&) = delete; - - T& mValue; -}; - -/** - * |Saturate<T>| is a value type for saturation arithmetics. It's - * build on top of |SaturateOp<T>|. - */ -template <typename T> -class Saturate -{ -public: - Saturate() = default; - MOZ_IMPLICIT Saturate(const Saturate<T>&) = default; - - MOZ_IMPLICIT Saturate(Saturate<T>&& aValue) - { - mValue = Move(aValue.mValue); - } - - explicit Saturate(const T& aValue) - : mValue(aValue) - { } - - const T& value() const - { - return mValue; - } - - // Compare operators - - bool operator==(const Saturate<T>& aRhs) const - { - return mValue == aRhs.mValue; - } - - bool operator!=(const Saturate<T>& aRhs) const - { - return !operator==(aRhs); - } - - bool operator==(const T& aRhs) const - { - return mValue == aRhs; - } - - bool operator!=(const T& aRhs) const - { - return !operator==(aRhs); - } - - // Assignment operators - - Saturate<T>& operator=(const Saturate<T>&) = default; - - Saturate<T>& operator=(Saturate<T>&& aRhs) - { - mValue = Move(aRhs.mValue); - return *this; - } - - // Add and subtract operators - - Saturate<T> operator+(const Saturate<T>& aRhs) const - { - Saturate<T> lhs(mValue); - return lhs += aRhs.mValue; - } - - Saturate<T> operator+(const T& aRhs) const - { - Saturate<T> lhs(mValue); - return lhs += aRhs; - } - - Saturate<T> operator-(const Saturate<T>& aRhs) const - { - Saturate<T> lhs(mValue); - return lhs -= aRhs.mValue; - } - - Saturate<T> operator-(const T& aRhs) const - { - Saturate<T> lhs(mValue); - return lhs -= aRhs; - } - - // Compound operators - - Saturate<T>& operator+=(const Saturate<T>& aRhs) - { - SaturateOp<T>(mValue) += aRhs.mValue; - return *this; - } - - Saturate<T>& operator+=(const T& aRhs) - { - SaturateOp<T>(mValue) += aRhs; - return *this; - } - - Saturate<T>& operator-=(const Saturate<T>& aRhs) - { - SaturateOp<T>(mValue) -= aRhs.mValue; - return *this; - } - - Saturate<T>& operator-=(const T& aRhs) - { - SaturateOp<T>(mValue) -= aRhs; - return *this; - } - - // Increment and decrement operators - - Saturate<T>& operator++() // prefix - { - ++SaturateOp<T>(mValue); - return *this; - } - - Saturate<T> operator++(int) // postfix - { - return Saturate<T>(SaturateOp<T>(mValue)++); - } - - Saturate<T>& operator--() // prefix - { - --SaturateOp<T>(mValue); - return *this; - } - - Saturate<T> operator--(int) // postfix - { - return Saturate<T>(SaturateOp<T>(mValue)--); - } - -private: - T mValue; -}; - -} // namespace detail - -typedef detail::Saturate<int8_t> SaturateInt8; -typedef detail::Saturate<int16_t> SaturateInt16; -typedef detail::Saturate<int32_t> SaturateInt32; -typedef detail::Saturate<uint8_t> SaturateUint8; -typedef detail::Saturate<uint16_t> SaturateUint16; -typedef detail::Saturate<uint32_t> SaturateUint32; - -} // namespace mozilla - -template<typename LhsT, typename RhsT> -bool -operator==(LhsT aLhs, const mozilla::detail::Saturate<RhsT>& aRhs) -{ - return aRhs.operator==(static_cast<RhsT>(aLhs)); -} - -template<typename LhsT, typename RhsT> -bool -operator!=(LhsT aLhs, const mozilla::detail::Saturate<RhsT>& aRhs) -{ - return !(aLhs == aRhs); -} - -#endif // mozilla_Saturate_h diff --git a/android/armeabi/include/spidermonkey/mozilla/ScopeExit.h b/android/armeabi/include/spidermonkey/mozilla/ScopeExit.h deleted file mode 100644 index 7aff82d8..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/ScopeExit.h +++ /dev/null @@ -1,135 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* RAII class for executing arbitrary actions at scope end. */ - -#ifndef mozilla_ScopeExit_h -#define mozilla_ScopeExit_h - -/* - * See http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n4189.pdf for a - * standards-track version of this. - * - * Error handling can be complex when various actions need to be performed that - * need to be undone if an error occurs midway. This can be handled with a - * collection of boolean state variables and gotos, which can get clunky and - * error-prone: - * - * { - * if (!a.setup()) - * goto fail; - * isASetup = true; - * - * if (!b.setup()) - * goto fail; - * isBSetup = true; - * - * ... - * return true; - * - * fail: - * if (isASetup) - * a.teardown(); - * if (isBSetup) - * b.teardown(); - * return false; - * } - * - * ScopeExit is a mechanism to simplify this pattern by keeping an RAII guard - * class that will perform the teardown on destruction, unless released. So the - * above would become: - * - * { - * if (!a.setup()) { - * return false; - * } - * auto guardA = MakeScopeExit([&] { - * a.teardown(); - * }); - * - * if (!b.setup()) { - * return false; - * } - * auto guardB = MakeScopeExit([&] { - * b.teardown(); - * }); - * - * ... - * guardA.release(); - * guardB.release(); - * return true; - * } - * - * This header provides: - * - * - |ScopeExit| - a container for a cleanup call, automically called at the - * end of the scope; - * - |MakeScopeExit| - a convenience function for constructing a |ScopeExit| - * with a given cleanup routine, commonly used with a lambda function. - * - * Note that the RAII classes defined in this header do _not_ perform any form - * of reference-counting or garbage-collection. These classes have exactly two - * behaviors: - * - * - if |release()| has not been called, the cleanup is always performed at - * the end of the scope; - * - if |release()| has been called, nothing will happen at the end of the - * scope. - */ - -#include "mozilla/GuardObjects.h" -#include "mozilla/Move.h" - -namespace mozilla { - -template <typename ExitFunction> -class MOZ_STACK_CLASS ScopeExit { - ExitFunction mExitFunction; - bool mExecuteOnDestruction; - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER - -public: - explicit ScopeExit(ExitFunction&& cleanup - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : mExitFunction(cleanup) - , mExecuteOnDestruction(true) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - ScopeExit(ScopeExit&& rhs) - : mExitFunction(mozilla::Move(rhs.mExitFunction)) - , mExecuteOnDestruction(rhs.mExecuteOnDestruction) - { - rhs.release(); - } - - ~ScopeExit() { - if (mExecuteOnDestruction) { - mExitFunction(); - } - } - - void release() { - mExecuteOnDestruction = false; - } - -private: - explicit ScopeExit(const ScopeExit&) = delete; - ScopeExit& operator=(const ScopeExit&) = delete; - ScopeExit& operator=(ScopeExit&&) = delete; -}; - -template <typename ExitFunction> -ScopeExit<ExitFunction> -MakeScopeExit(ExitFunction&& exitFunction) -{ - return ScopeExit<ExitFunction>(mozilla::Move(exitFunction)); -} - -} /* namespace mozilla */ - -#endif /* mozilla_ScopeExit_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Scoped.h b/android/armeabi/include/spidermonkey/mozilla/Scoped.h deleted file mode 100644 index c935434a..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Scoped.h +++ /dev/null @@ -1,255 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* DEPRECATED: Use UniquePtr.h instead. */ - -#ifndef mozilla_Scoped_h -#define mozilla_Scoped_h - -/* - * DEPRECATED: Use UniquePtr.h instead. - * - * Resource Acquisition Is Initialization is a programming idiom used - * to write robust code that is able to deallocate resources properly, - * even in presence of execution errors or exceptions that need to be - * propagated. The Scoped* classes defined via the |SCOPED_TEMPLATE| - * and |MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLTE| macros perform the - * deallocation of the resource they hold once program execution - * reaches the end of the scope for which they have been defined. - * These macros have been used to automatically close file - * descriptors/file handles when reaching the end of the scope, - * graphics contexts, etc. - * - * The general scenario for RAII classes created by the above macros - * is the following: - * - * ScopedClass foo(create_value()); - * // ... In this scope, |foo| is defined. Use |foo.get()| or |foo.rwget()| - * to access the value. - * // ... In case of |return| or |throw|, |foo| is deallocated automatically. - * // ... If |foo| needs to be returned or stored, use |foo.forget()| - * - * Note that the RAII classes defined in this header do _not_ perform any form - * of reference-counting or garbage-collection. These classes have exactly two - * behaviors: - * - * - if |forget()| has not been called, the resource is always deallocated at - * the end of the scope; - * - if |forget()| has been called, any control on the resource is unbound - * and the resource is not deallocated by the class. - */ - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/GuardObjects.h" -#include "mozilla/Move.h" - -namespace mozilla { - -/* - * Scoped is a helper to create RAII wrappers - * Type argument |Traits| is expected to have the following structure: - * - * struct Traits - * { - * // Define the type of the value stored in the wrapper - * typedef value_type type; - * // Returns the value corresponding to the uninitialized or freed state - * const static type empty(); - * // Release resources corresponding to the wrapped value - * // This function is responsible for not releasing an |empty| value - * const static void release(type); - * } - */ -template<typename Traits> -class MOZ_NON_TEMPORARY_CLASS Scoped -{ -public: - typedef typename Traits::type Resource; - - explicit Scoped(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) - : mValue(Traits::empty()) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - explicit Scoped(const Resource& aValue - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : mValue(aValue) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - } - - /* Move constructor. */ - Scoped(Scoped&& aOther - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) - : mValue(Move(aOther.mValue)) - { - MOZ_GUARD_OBJECT_NOTIFIER_INIT; - aOther.mValue = Traits::empty(); - } - - ~Scoped() { Traits::release(mValue); } - - // Constant getter - operator const Resource&() const { return mValue; } - const Resource& operator->() const { return mValue; } - const Resource& get() const { return mValue; } - // Non-constant getter. - Resource& rwget() { return mValue; } - - /* - * Forget the resource. - * - * Once |forget| has been called, the |Scoped| is neutralized, i.e. it will - * have no effect at destruction (unless it is reset to another resource by - * |operator=|). - * - * @return The original resource. - */ - Resource forget() - { - Resource tmp = mValue; - mValue = Traits::empty(); - return tmp; - } - - /* - * Perform immediate clean-up of this |Scoped|. - * - * If this |Scoped| is currently empty, this method has no effect. - */ - void dispose() - { - Traits::release(mValue); - mValue = Traits::empty(); - } - - bool operator==(const Resource& aOther) const { return mValue == aOther; } - - /* - * Replace the resource with another resource. - * - * Calling |operator=| has the side-effect of triggering clean-up. If you do - * not want to trigger clean-up, you should first invoke |forget|. - * - * @return this - */ - Scoped& operator=(const Resource& aOther) { return reset(aOther); } - - Scoped& reset(const Resource& aOther) - { - Traits::release(mValue); - mValue = aOther; - return *this; - } - - /* Move assignment operator. */ - Scoped& operator=(Scoped&& aRhs) - { - MOZ_ASSERT(&aRhs != this, "self-move-assignment not allowed"); - this->~Scoped(); - new(this) Scoped(Move(aRhs)); - return *this; - } - -private: - explicit Scoped(const Scoped& aValue) = delete; - Scoped& operator=(const Scoped& aValue) = delete; - -private: - Resource mValue; - MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER -}; - -/* - * SCOPED_TEMPLATE defines a templated class derived from Scoped - * This allows to implement templates such as ScopedFreePtr. - * - * @param name The name of the class to define. - * @param Traits A struct implementing clean-up. See the implementations - * for more details. - */ -#define SCOPED_TEMPLATE(name, Traits) \ -template<typename Type> \ -struct MOZ_NON_TEMPORARY_CLASS name : public mozilla::Scoped<Traits<Type> > \ -{ \ - typedef mozilla::Scoped<Traits<Type> > Super; \ - typedef typename Super::Resource Resource; \ - name& operator=(Resource aRhs) \ - { \ - Super::operator=(aRhs); \ - return *this; \ - } \ - name& operator=(name&& aRhs) \ - { \ - Super::operator=(Move(aRhs)); \ - return *this; \ - } \ - explicit name(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM) \ - : Super(MOZ_GUARD_OBJECT_NOTIFIER_ONLY_PARAM_TO_PARENT) \ - {} \ - explicit name(Resource aRhs \ - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) \ - : Super(aRhs \ - MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) \ - {} \ - name(name&& aRhs \ - MOZ_GUARD_OBJECT_NOTIFIER_PARAM) \ - : Super(Move(aRhs) \ - MOZ_GUARD_OBJECT_NOTIFIER_PARAM_TO_PARENT) \ - {} \ -private: \ - explicit name(name&) = delete; \ - name& operator=(name&) = delete; \ -}; - -/* - * MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE makes it easy to create scoped - * pointers for types with custom deleters; just overload - * TypeSpecificDelete(T*) in the same namespace as T to call the deleter for - * type T. - * - * @param name The name of the class to define. - * @param Type A struct implementing clean-up. See the implementations - * for more details. - * *param Deleter The function that is used to delete/destroy/free a - * non-null value of Type*. - * - * Example: - * - * MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(ScopedPRFileDesc, PRFileDesc, \ - * PR_Close) - * ... - * { - * ScopedPRFileDesc file(PR_OpenFile(...)); - * ... - * } // file is closed with PR_Close here - */ -#define MOZ_TYPE_SPECIFIC_SCOPED_POINTER_TEMPLATE(name, Type, Deleter) \ -template <> inline void TypeSpecificDelete(Type* aValue) { Deleter(aValue); } \ -typedef ::mozilla::TypeSpecificScopedPointer<Type> name; - -template <typename T> void TypeSpecificDelete(T* aValue); - -template <typename T> -struct TypeSpecificScopedPointerTraits -{ - typedef T* type; - static type empty() { return nullptr; } - static void release(type aValue) - { - if (aValue) { - TypeSpecificDelete(aValue); - } - } -}; - -SCOPED_TEMPLATE(TypeSpecificScopedPointer, TypeSpecificScopedPointerTraits) - -} /* namespace mozilla */ - -#endif /* mozilla_Scoped_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/SegmentedVector.h b/android/armeabi/include/spidermonkey/mozilla/SegmentedVector.h deleted file mode 100644 index 1bf60e46..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/SegmentedVector.h +++ /dev/null @@ -1,339 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// A simple segmented vector class. -// -// This class should be used in preference to mozilla::Vector or nsTArray when -// you are simply gathering items in order to later iterate over them. -// -// - In the case where you don't know the final size in advance, using -// SegmentedVector avoids the need to repeatedly allocate increasingly large -// buffers and copy the data into them. -// -// - In the case where you know the final size in advance and so can set the -// capacity appropriately, using SegmentedVector still avoids the need for -// large allocations (which can trigger OOMs). - -#ifndef mozilla_SegmentedVector_h -#define mozilla_SegmentedVector_h - -#include "mozilla/Alignment.h" -#include "mozilla/AllocPolicy.h" -#include "mozilla/Array.h" -#include "mozilla/LinkedList.h" -#include "mozilla/MemoryReporting.h" -#include "mozilla/Move.h" -#include "mozilla/TypeTraits.h" - -#include <new> // for placement new - -namespace mozilla { - -// |IdealSegmentSize| specifies how big each segment will be in bytes (or as -// close as is possible). Use the following guidelines to choose a size. -// -// - It should be a power-of-two, to avoid slop. -// -// - It should not be too small, so that segment allocations are infrequent, -// and so that per-segment bookkeeping overhead is low. Typically each -// segment should be able to hold hundreds of elements, at least. -// -// - It should not be too large, so that OOMs are unlikely when allocating -// segments, and so that not too much space is wasted when the final segment -// is not full. -// -// The ideal size depends on how the SegmentedVector is used and the size of -// |T|, but reasonable sizes include 1024, 4096 (the default), 8192, and 16384. -// -template<typename T, - size_t IdealSegmentSize = 4096, - typename AllocPolicy = MallocAllocPolicy> -class SegmentedVector : private AllocPolicy -{ - template<size_t SegmentCapacity> - struct SegmentImpl - : public mozilla::LinkedListElement<SegmentImpl<SegmentCapacity>> - { - SegmentImpl() : mLength(0) {} - - ~SegmentImpl() - { - for (uint32_t i = 0; i < mLength; i++) { - (*this)[i].~T(); - } - } - - uint32_t Length() const { return mLength; } - - T* Elems() { return reinterpret_cast<T*>(&mStorage.mBuf); } - - T& operator[](size_t aIndex) - { - MOZ_ASSERT(aIndex < mLength); - return Elems()[aIndex]; - } - - const T& operator[](size_t aIndex) const - { - MOZ_ASSERT(aIndex < mLength); - return Elems()[aIndex]; - } - - template<typename U> - void Append(U&& aU) - { - MOZ_ASSERT(mLength < SegmentCapacity); - // Pre-increment mLength so that the bounds-check in operator[] passes. - mLength++; - T* elem = &(*this)[mLength - 1]; - new (elem) T(mozilla::Forward<U>(aU)); - } - - void PopLast() - { - MOZ_ASSERT(mLength > 0); - (*this)[mLength - 1].~T(); - mLength--; - } - - uint32_t mLength; - - // The union ensures that the elements are appropriately aligned. - union Storage - { - char mBuf[sizeof(T) * SegmentCapacity]; - mozilla::AlignedElem<MOZ_ALIGNOF(T)> mAlign; - } mStorage; - - static_assert(MOZ_ALIGNOF(T) == MOZ_ALIGNOF(Storage), - "SegmentedVector provides incorrect alignment"); - }; - - // See how many we elements we can fit in a segment of IdealSegmentSize. If - // IdealSegmentSize is too small, it'll be just one. The +1 is because - // kSingleElementSegmentSize already accounts for one element. - static const size_t kSingleElementSegmentSize = sizeof(SegmentImpl<1>); - static const size_t kSegmentCapacity = - kSingleElementSegmentSize <= IdealSegmentSize - ? (IdealSegmentSize - kSingleElementSegmentSize) / sizeof(T) + 1 - : 1; - - typedef SegmentImpl<kSegmentCapacity> Segment; - -public: - // The |aIdealSegmentSize| is only for sanity checking. If it's specified, we - // check that the actual segment size is as close as possible to it. This - // serves as a sanity check for SegmentedVectorCapacity's capacity - // computation. - explicit SegmentedVector(size_t aIdealSegmentSize = 0) - { - // The difference between the actual segment size and the ideal segment - // size should be less than the size of a single element... unless the - // ideal size was too small, in which case the capacity should be one. - MOZ_ASSERT_IF( - aIdealSegmentSize != 0, - (sizeof(Segment) > aIdealSegmentSize && kSegmentCapacity == 1) || - aIdealSegmentSize - sizeof(Segment) < sizeof(T)); - } - - ~SegmentedVector() { Clear(); } - - bool IsEmpty() const { return !mSegments.getFirst(); } - - // Note that this is O(n) rather than O(1), but the constant factor is very - // small because it only has to do one addition per segment. - size_t Length() const - { - size_t n = 0; - for (auto segment = mSegments.getFirst(); - segment; - segment = segment->getNext()) { - n += segment->Length(); - } - return n; - } - - // Returns false if the allocation failed. (If you are using an infallible - // allocation policy, use InfallibleAppend() instead.) - template<typename U> - MOZ_MUST_USE bool Append(U&& aU) - { - Segment* last = mSegments.getLast(); - if (!last || last->Length() == kSegmentCapacity) { - last = this->template pod_malloc<Segment>(1); - if (!last) { - return false; - } - new (last) Segment(); - mSegments.insertBack(last); - } - last->Append(mozilla::Forward<U>(aU)); - return true; - } - - // You should probably only use this instead of Append() if you are using an - // infallible allocation policy. It will crash if the allocation fails. - template<typename U> - void InfallibleAppend(U&& aU) - { - bool ok = Append(mozilla::Forward<U>(aU)); - MOZ_RELEASE_ASSERT(ok); - } - - void Clear() - { - Segment* segment; - while ((segment = mSegments.popFirst())) { - segment->~Segment(); - this->free_(segment); - } - } - - T& GetLast() - { - MOZ_ASSERT(!IsEmpty()); - Segment* last = mSegments.getLast(); - return (*last)[last->Length() - 1]; - } - - const T& GetLast() const - { - MOZ_ASSERT(!IsEmpty()); - Segment* last = mSegments.getLast(); - return (*last)[last->Length() - 1]; - } - - void PopLast() - { - MOZ_ASSERT(!IsEmpty()); - Segment* last = mSegments.getLast(); - last->PopLast(); - if (!last->Length()) { - mSegments.popLast(); - last->~Segment(); - this->free_(last); - } - } - - // Equivalent to calling |PopLast| |aNumElements| times, but potentially - // more efficient. - void PopLastN(uint32_t aNumElements) - { - MOZ_ASSERT(aNumElements <= Length()); - - Segment* last; - - // Pop full segments for as long as we can. Note that this loop - // cleanly handles the case when the initial last segment is not - // full and we are popping more elements than said segment contains. - do { - last = mSegments.getLast(); - - // The list is empty. We're all done. - if (!last) { - return; - } - - // Check to see if the list contains too many elements. Handle - // that in the epilogue. - uint32_t segmentLen = last->Length(); - if (segmentLen > aNumElements) { - break; - } - - // Destroying the segment destroys all elements contained therein. - mSegments.popLast(); - last->~Segment(); - this->free_(last); - - MOZ_ASSERT(aNumElements >= segmentLen); - aNumElements -= segmentLen; - if (aNumElements == 0) { - return; - } - } while (true); - - // Handle the case where the last segment contains more elements - // than we want to pop. - MOZ_ASSERT(last); - MOZ_ASSERT(last == mSegments.getLast()); - MOZ_ASSERT(aNumElements != 0); - MOZ_ASSERT(aNumElements < last->Length()); - for (uint32_t i = 0; i < aNumElements; ++i) { - last->PopLast(); - } - MOZ_ASSERT(last->Length() != 0); - } - - // Use this class to iterate over a SegmentedVector, like so: - // - // for (auto iter = v.Iter(); !iter.Done(); iter.Next()) { - // MyElem& elem = iter.Get(); - // f(elem); - // } - // - class IterImpl - { - friend class SegmentedVector; - - Segment* mSegment; - size_t mIndex; - - explicit IterImpl(SegmentedVector* aVector) - : mSegment(aVector->mSegments.getFirst()) - , mIndex(0) - {} - - public: - bool Done() const { return !mSegment; } - - T& Get() - { - MOZ_ASSERT(!Done()); - return (*mSegment)[mIndex]; - } - - const T& Get() const - { - MOZ_ASSERT(!Done()); - return (*mSegment)[mIndex]; - } - - void Next() - { - MOZ_ASSERT(!Done()); - mIndex++; - if (mIndex == mSegment->Length()) { - mSegment = mSegment->getNext(); - mIndex = 0; - } - } - }; - - IterImpl Iter() { return IterImpl(this); } - - // Measure the memory consumption of the vector excluding |this|. Note that - // it only measures the vector itself. If the vector elements contain - // pointers to other memory blocks, those blocks must be measured separately - // during a subsequent iteration over the vector. - size_t SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf) const - { - return mSegments.sizeOfExcludingThis(aMallocSizeOf); - } - - // Like sizeOfExcludingThis(), but measures |this| as well. - size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const - { - return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf); - } - -private: - mozilla::LinkedList<Segment> mSegments; -}; - -} // namespace mozilla - -#endif /* mozilla_SegmentedVector_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/SizePrintfMacros.h b/android/armeabi/include/spidermonkey/mozilla/SizePrintfMacros.h deleted file mode 100644 index ec55c62c..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/SizePrintfMacros.h +++ /dev/null @@ -1,33 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Implements (nonstandard) PRI{ouxX}SIZE format macros for size_t types. */ - -#ifndef mozilla_SizePrintfMacros_h_ -#define mozilla_SizePrintfMacros_h_ - -/* - * MSVC's libc does not support C99's %z format length modifier for size_t - * types. Instead, we use Microsoft's nonstandard %I modifier for size_t, which - * is unsigned __int32 on 32-bit platforms and unsigned __int64 on 64-bit - * platforms: - * - * http://msdn.microsoft.com/en-us/library/tcxf1dw6.aspx - */ - -#if defined(XP_WIN) -# define PRIoSIZE "Io" -# define PRIuSIZE "Iu" -# define PRIxSIZE "Ix" -# define PRIXSIZE "IX" -#else -# define PRIoSIZE "zo" -# define PRIuSIZE "zu" -# define PRIxSIZE "zx" -# define PRIXSIZE "zX" -#endif - -#endif /* mozilla_SizePrintfMacros_h_ */ diff --git a/android/armeabi/include/spidermonkey/mozilla/SplayTree.h b/android/armeabi/include/spidermonkey/mozilla/SplayTree.h deleted file mode 100644 index 2b3b838b..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/SplayTree.h +++ /dev/null @@ -1,330 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/** - * A sorted tree with optimal access times, where recently-accessed elements - * are faster to access again. - */ - -#ifndef mozilla_SplayTree_h -#define mozilla_SplayTree_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" - -namespace mozilla { - -template<class T, class C> -class SplayTree; - -template<typename T> -class SplayTreeNode -{ -public: - template<class A, class B> - friend class SplayTree; - - SplayTreeNode() - : mLeft(nullptr) - , mRight(nullptr) - , mParent(nullptr) - {} - -private: - T* mLeft; - T* mRight; - T* mParent; -}; - - -/** - * Class which represents a splay tree. - * Splay trees are balanced binary search trees for which search, insert and - * remove are all amortized O(log n), but where accessing a node makes it - * faster to access that node in the future. - * - * T indicates the type of tree elements, Comparator must have a static - * compare(const T&, const T&) method ordering the elements. The compare - * method must be free from side effects. - */ -template<typename T, class Comparator> -class SplayTree -{ - T* mRoot; - -public: - constexpr SplayTree() - : mRoot(nullptr) - {} - - bool empty() const - { - return !mRoot; - } - - T* find(const T& aValue) - { - if (empty()) { - return nullptr; - } - - T* last = lookup(aValue); - splay(last); - return Comparator::compare(aValue, *last) == 0 ? last : nullptr; - } - - void insert(T* aValue) - { - MOZ_ASSERT(!find(*aValue), "Duplicate elements are not allowed."); - - if (!mRoot) { - mRoot = aValue; - return; - } - T* last = lookup(*aValue); - int cmp = Comparator::compare(*aValue, *last); - - finishInsertion(last, cmp, aValue); - return; - } - - T* findOrInsert(const T& aValue); - - T* remove(const T& aValue) - { - T* last = lookup(aValue); - MOZ_ASSERT(last, "This tree must contain the element being removed."); - MOZ_ASSERT(Comparator::compare(aValue, *last) == 0); - - // Splay the tree so that the item to remove is the root. - splay(last); - MOZ_ASSERT(last == mRoot); - - // Find another node which can be swapped in for the root: either the - // rightmost child of the root's left, or the leftmost child of the - // root's right. - T* swap; - T* swapChild; - if (mRoot->mLeft) { - swap = mRoot->mLeft; - while (swap->mRight) { - swap = swap->mRight; - } - swapChild = swap->mLeft; - } else if (mRoot->mRight) { - swap = mRoot->mRight; - while (swap->mLeft) { - swap = swap->mLeft; - } - swapChild = swap->mRight; - } else { - T* result = mRoot; - mRoot = nullptr; - return result; - } - - // The selected node has at most one child, in swapChild. Detach it - // from the subtree by replacing it with that child. - if (swap == swap->mParent->mLeft) { - swap->mParent->mLeft = swapChild; - } else { - swap->mParent->mRight = swapChild; - } - if (swapChild) { - swapChild->mParent = swap->mParent; - } - - // Make the selected node the new root. - mRoot = swap; - mRoot->mParent = nullptr; - mRoot->mLeft = last->mLeft; - mRoot->mRight = last->mRight; - if (mRoot->mLeft) { - mRoot->mLeft->mParent = mRoot; - } - if (mRoot->mRight) { - mRoot->mRight->mParent = mRoot; - } - - return last; - } - - T* removeMin() - { - MOZ_ASSERT(mRoot, "No min to remove!"); - - T* min = mRoot; - while (min->mLeft) { - min = min->mLeft; - } - return remove(*min); - } - - // For testing purposes only. - void checkCoherency() - { - checkCoherency(mRoot, nullptr); - } - -private: - /** - * Returns the node in this comparing equal to |aValue|, or a node just - * greater or just less than |aValue| if there is no such node. - */ - T* lookup(const T& aValue) - { - MOZ_ASSERT(!empty()); - - T* node = mRoot; - T* parent; - do { - parent = node; - int c = Comparator::compare(aValue, *node); - if (c == 0) { - return node; - } else if (c < 0) { - node = node->mLeft; - } else { - node = node->mRight; - } - } while (node); - return parent; - } - - void finishInsertion(T* aLast, int32_t aCmp, T* aNew) - { - MOZ_ASSERT(aCmp, "Nodes shouldn't be equal!"); - - T** parentPointer = (aCmp < 0) ? &aLast->mLeft : &aLast->mRight; - MOZ_ASSERT(!*parentPointer); - *parentPointer = aNew; - aNew->mParent = aLast; - - splay(aNew); - } - - /** - * Rotate the tree until |node| is at the root of the tree. Performing - * the rotations in this fashion preserves the amortized balancing of - * the tree. - */ - void splay(T* aNode) - { - MOZ_ASSERT(aNode); - - while (aNode != mRoot) { - T* parent = aNode->mParent; - if (parent == mRoot) { - // Zig rotation. - rotate(aNode); - MOZ_ASSERT(aNode == mRoot); - return; - } - T* grandparent = parent->mParent; - if ((parent->mLeft == aNode) == (grandparent->mLeft == parent)) { - // Zig-zig rotation. - rotate(parent); - rotate(aNode); - } else { - // Zig-zag rotation. - rotate(aNode); - rotate(aNode); - } - } - } - - void rotate(T* aNode) - { - // Rearrange nodes so that aNode becomes the parent of its current - // parent, while preserving the sortedness of the tree. - T* parent = aNode->mParent; - if (parent->mLeft == aNode) { - // x y - // y c ==> a x - // a b b c - parent->mLeft = aNode->mRight; - if (aNode->mRight) { - aNode->mRight->mParent = parent; - } - aNode->mRight = parent; - } else { - MOZ_ASSERT(parent->mRight == aNode); - // x y - // a y ==> x c - // b c a b - parent->mRight = aNode->mLeft; - if (aNode->mLeft) { - aNode->mLeft->mParent = parent; - } - aNode->mLeft = parent; - } - aNode->mParent = parent->mParent; - parent->mParent = aNode; - if (T* grandparent = aNode->mParent) { - if (grandparent->mLeft == parent) { - grandparent->mLeft = aNode; - } else { - grandparent->mRight = aNode; - } - } else { - mRoot = aNode; - } - } - - T* checkCoherency(T* aNode, T* aMinimum) - { - if (mRoot) { - MOZ_RELEASE_ASSERT(!mRoot->mParent); - } - if (!aNode) { - MOZ_RELEASE_ASSERT(!mRoot); - return nullptr; - } - if (!aNode->mParent) { - MOZ_RELEASE_ASSERT(aNode == mRoot); - } - if (aMinimum) { - MOZ_RELEASE_ASSERT(Comparator::compare(*aMinimum, *aNode) < 0); - } - if (aNode->mLeft) { - MOZ_RELEASE_ASSERT(aNode->mLeft->mParent == aNode); - T* leftMaximum = checkCoherency(aNode->mLeft, aMinimum); - MOZ_RELEASE_ASSERT(Comparator::compare(*leftMaximum, *aNode) < 0); - } - if (aNode->mRight) { - MOZ_RELEASE_ASSERT(aNode->mRight->mParent == aNode); - return checkCoherency(aNode->mRight, aNode); - } - return aNode; - } - - SplayTree(const SplayTree&) = delete; - void operator=(const SplayTree&) = delete; -}; - -template<typename T, class Comparator> -T* -SplayTree<T, Comparator>::findOrInsert(const T& aValue) -{ - if (!mRoot) { - mRoot = new T(aValue); - return mRoot; - } - - T* last = lookup(aValue); - int cmp = Comparator::compare(aValue, *last); - if (!cmp) { - return last; - } - - T* t = new T(aValue); - finishInsertion(last, cmp, t); - return t; -} - -} /* namespace mozilla */ - -#endif /* mozilla_SplayTree_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Sprintf.h b/android/armeabi/include/spidermonkey/mozilla/Sprintf.h deleted file mode 100644 index e0be271e..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Sprintf.h +++ /dev/null @@ -1,41 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Provides a safer sprintf for printing to fixed-size character arrays. */ - -#ifndef mozilla_Sprintf_h_ -#define mozilla_Sprintf_h_ - -#include <stdio.h> -#include <stdarg.h> - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" - -#ifdef __cplusplus - -template <size_t N> -int VsprintfLiteral(char (&buffer)[N], const char* format, va_list args) -{ - MOZ_ASSERT(format != buffer); - int result = vsnprintf(buffer, N, format, args); - buffer[N - 1] = '\0'; - return result; -} - -template <size_t N> -MOZ_FORMAT_PRINTF(2, 3) -int SprintfLiteral(char (&buffer)[N], const char* format, ...) -{ - va_list args; - va_start(args, format); - int result = VsprintfLiteral(buffer, format, args); - va_end(args); - return result; -} - -#endif -#endif /* mozilla_Sprintf_h_ */ diff --git a/android/armeabi/include/spidermonkey/mozilla/StackWalk.h b/android/armeabi/include/spidermonkey/mozilla/StackWalk.h deleted file mode 100644 index 534c0bd8..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/StackWalk.h +++ /dev/null @@ -1,163 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* API for getting a stack trace of the C/C++ stack on the current thread */ - -#ifndef mozilla_StackWalk_h -#define mozilla_StackWalk_h - -/* WARNING: This file is intended to be included from C or C++ files. */ - -#include "mozilla/Types.h" -#include <stdint.h> - -/** - * The callback for MozStackWalk. - * - * @param aFrameNumber The frame number (starts at 1, not 0). - * @param aPC The program counter value. - * @param aSP The best approximation possible of what the stack - * pointer will be pointing to when the execution returns - * to executing that at aPC. If no approximation can - * be made it will be nullptr. - * @param aClosure Extra data passed in via MozStackWalk(). - */ -typedef void -(*MozWalkStackCallback)(uint32_t aFrameNumber, void* aPC, void* aSP, - void* aClosure); - -/** - * Call aCallback for the C/C++ stack frames on the current thread, from - * the caller of MozStackWalk to main (or above). - * - * @param aCallback Callback function, called once per frame. - * @param aSkipFrames Number of initial frames to skip. 0 means that - * the first callback will be for the caller of - * MozStackWalk. - * @param aMaxFrames Maximum number of frames to trace. 0 means no limit. - * @param aClosure Caller-supplied data passed through to aCallback. - * @param aThread The thread for which the stack is to be retrieved. - * Passing null causes us to walk the stack of the - * current thread. On Windows, this is a thread HANDLE. - * It is currently not supported on any other platform. - * @param aPlatformData Platform specific data that can help in walking the - * stack, this should be nullptr unless you really know - * what you're doing! This needs to be a pointer to a - * CONTEXT on Windows and should not be passed on other - * platforms. - * - * May skip some stack frames due to compiler optimizations or code - * generation. - * - */ -MFBT_API bool -MozStackWalk(MozWalkStackCallback aCallback, uint32_t aSkipFrames, - uint32_t aMaxFrames, void* aClosure, uintptr_t aThread, - void* aPlatformData); - -typedef struct -{ - /* - * The name of the shared library or executable containing an - * address and the address's offset within that library, or empty - * string and zero if unknown. - */ - char library[256]; - ptrdiff_t loffset; - /* - * The name of the file name and line number of the code - * corresponding to the address, or empty string and zero if - * unknown. - */ - char filename[256]; - unsigned long lineno; - /* - * The name of the function containing an address and the address's - * offset within that function, or empty string and zero if unknown. - */ - char function[256]; - ptrdiff_t foffset; -} MozCodeAddressDetails; - -/** - * For a given pointer to code, fill in the pieces of information used - * when printing a stack trace. - * - * @param aPC The code address. - * @param aDetails A structure to be filled in with the result. - */ -MFBT_API bool -MozDescribeCodeAddress(void* aPC, MozCodeAddressDetails* aDetails); - -/** - * Format the information about a code address in a format suitable for - * stack traces on the current platform. When available, this string - * should contain the function name, source file, and line number. When - * these are not available, library and offset should be reported, if - * possible. - * - * Note that this output is parsed by several scripts including the fix*.py and - * make-tree.pl scripts in tools/rb/. It should only be change with care, and - * in conjunction with those scripts. - * - * @param aBuffer A string to be filled in with the description. - * The string will always be null-terminated. - * @param aBufferSize The size, in bytes, of aBuffer, including - * room for the terminating null. If the information - * to be printed would be larger than aBuffer, it - * will be truncated so that aBuffer[aBufferSize-1] - * is the terminating null. - * @param aFrameNumber The frame number. - * @param aPC The code address. - * @param aFunction The function name. Possibly null or the empty string. - * @param aLibrary The library name. Possibly null or the empty string. - * @param aLOffset The library offset. - * @param aFileName The filename. Possibly null or the empty string. - * @param aLineNo The line number. Possibly zero. - */ -MFBT_API void -MozFormatCodeAddress(char* aBuffer, uint32_t aBufferSize, uint32_t aFrameNumber, - const void* aPC, const char* aFunction, - const char* aLibrary, ptrdiff_t aLOffset, - const char* aFileName, uint32_t aLineNo); - -/** - * Format the information about a code address in the same fashion as - * MozFormatCodeAddress. - * - * @param aBuffer A string to be filled in with the description. - * The string will always be null-terminated. - * @param aBufferSize The size, in bytes, of aBuffer, including - * room for the terminating null. If the information - * to be printed would be larger than aBuffer, it - * will be truncated so that aBuffer[aBufferSize-1] - * is the terminating null. - * @param aFrameNumber The frame number. - * @param aPC The code address. - * @param aDetails The value filled in by MozDescribeCodeAddress(aPC). - */ -MFBT_API void -MozFormatCodeAddressDetails(char* aBuffer, uint32_t aBufferSize, - uint32_t aFrameNumber, void* aPC, - const MozCodeAddressDetails* aDetails); - -namespace mozilla { - -MFBT_API bool -FramePointerStackWalk(MozWalkStackCallback aCallback, uint32_t aSkipFrames, - uint32_t aMaxFrames, void* aClosure, void** aBp, - void* aStackEnd); - -} // namespace mozilla - -/** - * Initialize the critical sections for this platform so that we can - * abort stack walks when needed. - */ -MFBT_API void -StackWalkInitCriticalAddress(void); - -#endif diff --git a/android/armeabi/include/spidermonkey/mozilla/StaticAnalysisFunctions.h b/android/armeabi/include/spidermonkey/mozilla/StaticAnalysisFunctions.h deleted file mode 100644 index a06809dc..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/StaticAnalysisFunctions.h +++ /dev/null @@ -1,49 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_StaticAnalysisFunctions_h -#define mozilla_StaticAnalysisFunctions_h - -#ifndef __cplusplus -#ifndef bool -#include <stdbool.h> -#endif -#endif -/* - * Functions that are used as markers in Gecko code for static analysis. Their - * purpose is to have different AST nodes generated during compile time and to - * match them based on different checkers implemented in build/clang-plugin - */ - -#ifdef MOZ_CLANG_PLUGIN - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * MOZ_AssertAssignmentTest - used in MOZ_ASSERT in order to test the possible - * presence of assignment instead of logical comparisons. - * - * Example: - * MOZ_ASSERT(retVal = true); - */ -static MOZ_ALWAYS_INLINE bool MOZ_AssertAssignmentTest(bool exprResult) { - return exprResult; -} - -#ifdef __cplusplus -} -#endif /* __cplusplus */ - -#define MOZ_CHECK_ASSERT_ASSIGNMENT(expr) MOZ_AssertAssignmentTest(!!(expr)) - -#else - -#define MOZ_CHECK_ASSERT_ASSIGNMENT(expr) (!!(expr)) - -#endif /* MOZ_CLANG_PLUGIN */ -#endif /* StaticAnalysisFunctions_h */ \ No newline at end of file diff --git a/android/armeabi/include/spidermonkey/mozilla/TaggedAnonymousMemory.h b/android/armeabi/include/spidermonkey/mozilla/TaggedAnonymousMemory.h deleted file mode 100644 index d26b06df..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/TaggedAnonymousMemory.h +++ /dev/null @@ -1,86 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -// Some Linux kernels -- specifically, newer versions of Android and -// some B2G devices -- have a feature for assigning names to ranges of -// anonymous memory (i.e., memory that doesn't have a "name" in the -// form of an underlying mapped file). These names are reported in -// /proc/<pid>/smaps alongside system-level memory usage information -// such as Proportional Set Size (memory usage adjusted for sharing -// between processes), which allows reporting this information at a -// finer granularity than would otherwise be possible (e.g., -// separating malloc() heap from JS heap). -// -// Existing memory can be tagged with MozTagAnonymousMemory(); it will -// tag the range of complete pages containing the given interval, so -// the results may be inexact if the range isn't page-aligned. -// MozTaggedAnonymousMmap() can be used like mmap() with an extra -// parameter, and will tag the returned memory if the mapping was -// successful (and if it was in fact anonymous). -// -// NOTE: The pointer given as the "tag" argument MUST remain valid as -// long as the mapping exists. The referenced string is read when -// /proc/<pid>/smaps or /proc/<pid>/maps is read, not when the tag is -// established, so freeing it or changing its contents will have -// unexpected results. Using a static string is probably best. -// -// Also note that this header can be used by both C and C++ code. - -#ifndef mozilla_TaggedAnonymousMemory_h -#define mozilla_TaggedAnonymousMemory_h - -#ifndef XP_WIN - -#include <sys/types.h> -#include <sys/mman.h> - -#include "mozilla/Types.h" - -#ifdef ANDROID - -#ifdef __cplusplus -extern "C" { -#endif - -MFBT_API void -MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag); - -MFBT_API void* -MozTaggedAnonymousMmap(void* aAddr, size_t aLength, int aProt, int aFlags, - int aFd, off_t aOffset, const char* aTag); - -MFBT_API int -MozTaggedMemoryIsSupported(void); - -#ifdef __cplusplus -} // extern "C" -#endif - -#else // ANDROID - -static inline void -MozTagAnonymousMemory(const void* aPtr, size_t aLength, const char* aTag) -{ -} - -static inline void* -MozTaggedAnonymousMmap(void* aAddr, size_t aLength, int aProt, int aFlags, - int aFd, off_t aOffset, const char* aTag) -{ - return mmap(aAddr, aLength, aProt, aFlags, aFd, aOffset); -} - -static inline int -MozTaggedMemoryIsSupported(void) -{ - return 0; -} - -#endif // ANDROID - -#endif // !XP_WIN - -#endif // mozilla_TaggedAnonymousMemory_h diff --git a/android/armeabi/include/spidermonkey/mozilla/TemplateLib.h b/android/armeabi/include/spidermonkey/mozilla/TemplateLib.h deleted file mode 100644 index 6286452d..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/TemplateLib.h +++ /dev/null @@ -1,133 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * Reusable template meta-functions on types and compile-time values. Meta- - * functions are placed inside the 'tl' namespace to avoid conflict with non- - * meta functions of the same name (e.g., mozilla::tl::FloorLog2 vs. - * mozilla::FloorLog2). - * - * When constexpr support becomes universal, we should probably use that instead - * of some of these templates, for simplicity. - */ - -#ifndef mozilla_TemplateLib_h -#define mozilla_TemplateLib_h - -#include <limits.h> -#include <stddef.h> - -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -namespace tl { - -/** Compute min/max. */ -template<size_t I, size_t J> -struct Min -{ - static const size_t value = I < J ? I : J; -}; -template<size_t I, size_t J> -struct Max -{ - static const size_t value = I > J ? I : J; -}; - -/** Compute floor(log2(i)). */ -template<size_t I> -struct FloorLog2 -{ - static const size_t value = 1 + FloorLog2<I / 2>::value; -}; -template<> struct FloorLog2<0> { /* Error */ }; -template<> struct FloorLog2<1> { static const size_t value = 0; }; - -/** Compute ceiling(log2(i)). */ -template<size_t I> -struct CeilingLog2 -{ - static const size_t value = FloorLog2<2 * I - 1>::value; -}; - -/** Round up to the nearest power of 2. */ -template<size_t I> -struct RoundUpPow2 -{ - static const size_t value = size_t(1) << CeilingLog2<I>::value; -}; -template<> -struct RoundUpPow2<0> -{ - static const size_t value = 1; -}; - -/** Compute the number of bits in the given unsigned type. */ -template<typename T> -struct BitSize -{ - static const size_t value = sizeof(T) * CHAR_BIT; -}; - -/** - * Produce an N-bit mask, where N <= BitSize<size_t>::value. Handle the - * language-undefined edge case when N = BitSize<size_t>::value. - */ -template<size_t N> -struct NBitMask -{ - // Assert the precondition. On success this evaluates to 0. Otherwise it - // triggers divide-by-zero at compile time: a guaranteed compile error in - // C++11, and usually one in C++98. Add this value to |value| to assure - // its computation. - static const size_t checkPrecondition = - 0 / size_t(N < BitSize<size_t>::value); - static const size_t value = (size_t(1) << N) - 1 + checkPrecondition; -}; -template<> -struct NBitMask<BitSize<size_t>::value> -{ - static const size_t value = size_t(-1); -}; - -/** - * For the unsigned integral type size_t, compute a mask M for N such that - * for all X, !(X & M) implies X * N will not overflow (w.r.t size_t) - */ -template<size_t N> -struct MulOverflowMask -{ - static const size_t value = - ~NBitMask<BitSize<size_t>::value - CeilingLog2<N>::value>::value; -}; -template<> struct MulOverflowMask<0> { /* Error */ }; -template<> struct MulOverflowMask<1> { static const size_t value = 0; }; - -/** - * And<bool...> computes the logical 'and' of its argument booleans. - * - * Examples: - * mozilla::t1::And<true, true>::value is true. - * mozilla::t1::And<true, false>::value is false. - * mozilla::t1::And<>::value is true. - */ - -template<bool...> -struct And; - -template<> -struct And<> : public TrueType { }; - -template<bool C1, bool... Cn> -struct And<C1, Cn...> - : public Conditional<C1, And<Cn...>, FalseType>::Type { }; - -} // namespace tl - -} // namespace mozilla - -#endif /* mozilla_TemplateLib_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/ThreadLocal.h b/android/armeabi/include/spidermonkey/mozilla/ThreadLocal.h deleted file mode 100644 index 880e6773..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/ThreadLocal.h +++ /dev/null @@ -1,222 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Cross-platform lightweight thread local data wrappers. */ - -#ifndef mozilla_ThreadLocal_h -#define mozilla_ThreadLocal_h - -#if defined(XP_WIN) -// This file will get included in any file that wants to add a profiler mark. -// In order to not bring <windows.h> together we could include windef.h and -// winbase.h which are sufficient to get the prototypes for the Tls* functions. -// # include <windef.h> -// # include <winbase.h> -// Unfortunately, even including these headers causes us to add a bunch of ugly -// stuff to our namespace e.g #define CreateEvent CreateEventW -extern "C" { -__declspec(dllimport) void* __stdcall TlsGetValue(unsigned long); -__declspec(dllimport) int __stdcall TlsSetValue(unsigned long, void*); -__declspec(dllimport) unsigned long __stdcall TlsAlloc(); -} -#else -# include <pthread.h> -# include <signal.h> -#endif - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -// sig_safe_t denotes an atomic type which can be read or stored in a single -// instruction. This means that data of this type is safe to be manipulated -// from a signal handler, or other similar asynchronous execution contexts. -#if defined(XP_WIN) -typedef unsigned long sig_safe_t; -#else -typedef sig_atomic_t sig_safe_t; -#endif - -namespace detail { - -#if defined(HAVE_THREAD_TLS_KEYWORD) -#define MOZ_HAS_THREAD_LOCAL -#endif - -/* - * Thread Local Storage helpers. - * - * Usage: - * - * Do not directly instantiate this class. Instead, use the - * MOZ_THREAD_LOCAL macro to declare or define instances. The macro - * takes a type name as its argument. - * - * Declare like this: - * extern MOZ_THREAD_LOCAL(int) tlsInt; - * Define like this: - * MOZ_THREAD_LOCAL(int) tlsInt; - * or: - * static MOZ_THREAD_LOCAL(int) tlsInt; - * - * Only static-storage-duration (e.g. global variables, or static class members) - * objects of this class should be instantiated. This class relies on - * zero-initialization, which is implicit for static-storage-duration objects. - * It doesn't have a custom default constructor, to avoid static initializers. - * - * API usage: - * - * // Create a TLS item. - * // - * // Note that init() should be invoked before the first use of set() - * // or get(). It is ok to call it multiple times. This must be - * // called in a way that avoids possible races with other threads. - * MOZ_THREAD_LOCAL(int) tlsKey; - * if (!tlsKey.init()) { - * // deal with the error - * } - * - * // Set the TLS value - * tlsKey.set(123); - * - * // Get the TLS value - * int value = tlsKey.get(); - */ -template<typename T> -class ThreadLocal -{ -#ifndef MOZ_HAS_THREAD_LOCAL -#if defined(XP_WIN) - typedef unsigned long key_t; -#else - typedef pthread_key_t key_t; -#endif - - // Integral types narrower than void* must be extended to avoid - // warnings from valgrind on some platforms. This helper type - // achieves that without penalizing the common case of ThreadLocals - // instantiated using a pointer type. - template<typename S> - struct Helper - { - typedef uintptr_t Type; - }; - - template<typename S> - struct Helper<S *> - { - typedef S *Type; - }; -#endif - - bool initialized() const { -#ifdef MOZ_HAS_THREAD_LOCAL - return true; -#else - return mInited; -#endif - } - -public: - // __thread does not allow non-trivial constructors, but we can - // instead rely on zero-initialization. -#ifndef MOZ_HAS_THREAD_LOCAL - ThreadLocal() - : mKey(0), mInited(false) - {} -#endif - - MOZ_MUST_USE inline bool init(); - - inline T get() const; - - inline void set(const T aValue); - -private: -#ifdef MOZ_HAS_THREAD_LOCAL - T mValue; -#else - key_t mKey; - bool mInited; -#endif -}; - -template<typename T> -inline bool -ThreadLocal<T>::init() -{ - static_assert(mozilla::IsPointer<T>::value || mozilla::IsIntegral<T>::value, - "mozilla::ThreadLocal must be used with a pointer or " - "integral type"); - static_assert(sizeof(T) <= sizeof(void*), - "mozilla::ThreadLocal can't be used for types larger than " - "a pointer"); - -#ifdef MOZ_HAS_THREAD_LOCAL - return true; -#else - if (!initialized()) { -#ifdef XP_WIN - mKey = TlsAlloc(); - mInited = mKey != 0xFFFFFFFFUL; // TLS_OUT_OF_INDEXES -#else - mInited = !pthread_key_create(&mKey, nullptr); -#endif - } - return mInited; -#endif -} - -template<typename T> -inline T -ThreadLocal<T>::get() const -{ -#ifdef MOZ_HAS_THREAD_LOCAL - return mValue; -#else - MOZ_ASSERT(initialized()); - void* h; -#ifdef XP_WIN - h = TlsGetValue(mKey); -#else - h = pthread_getspecific(mKey); -#endif - return static_cast<T>(reinterpret_cast<typename Helper<T>::Type>(h)); -#endif -} - -template<typename T> -inline void -ThreadLocal<T>::set(const T aValue) -{ -#ifdef MOZ_HAS_THREAD_LOCAL - mValue = aValue; -#else - MOZ_ASSERT(initialized()); - void* h = reinterpret_cast<void*>(static_cast<typename Helper<T>::Type>(aValue)); -#ifdef XP_WIN - bool succeeded = TlsSetValue(mKey, h); -#else - bool succeeded = !pthread_setspecific(mKey, h); -#endif - if (!succeeded) { - MOZ_CRASH(); - } -#endif -} - -#ifdef MOZ_HAS_THREAD_LOCAL -#define MOZ_THREAD_LOCAL(TYPE) __thread mozilla::detail::ThreadLocal<TYPE> -#else -#define MOZ_THREAD_LOCAL(TYPE) mozilla::detail::ThreadLocal<TYPE> -#endif - -} // namespace detail -} // namespace mozilla - -#endif /* mozilla_ThreadLocal_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/TimeStamp.h b/android/armeabi/include/spidermonkey/mozilla/TimeStamp.h deleted file mode 100644 index a1a0eb36..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/TimeStamp.h +++ /dev/null @@ -1,609 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_TimeStamp_h -#define mozilla_TimeStamp_h - -#include <stdint.h> -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/FloatingPoint.h" -#include "mozilla/TypeTraits.h" -#include "mozilla/Types.h" - -namespace IPC { -template<typename T> struct ParamTraits; -} // namespace IPC - -#ifdef XP_WIN -// defines TimeStampValue as a complex value keeping both -// GetTickCount and QueryPerformanceCounter values -#include "TimeStamp_windows.h" -#endif - -namespace mozilla { - -#ifndef XP_WIN -typedef uint64_t TimeStampValue; -#endif - -class TimeStamp; - -/** - * Platform-specific implementation details of BaseTimeDuration. - */ -class BaseTimeDurationPlatformUtils -{ -public: - static MFBT_API double ToSeconds(int64_t aTicks); - static MFBT_API double ToSecondsSigDigits(int64_t aTicks); - static MFBT_API int64_t TicksFromMilliseconds(double aMilliseconds); - static MFBT_API int64_t ResolutionInTicks(); -}; - -/** - * Instances of this class represent the length of an interval of time. - * Negative durations are allowed, meaning the end is before the start. - * - * Internally the duration is stored as a int64_t in units of - * PR_TicksPerSecond() when building with NSPR interval timers, or a - * system-dependent unit when building with system clocks. The - * system-dependent unit must be constant, otherwise the semantics of - * this class would be broken. - * - * The ValueCalculator template parameter determines how arithmetic - * operations are performed on the integer count of ticks (mValue). - */ -template <typename ValueCalculator> -class BaseTimeDuration -{ -public: - // The default duration is 0. - constexpr BaseTimeDuration() : mValue(0) {} - // Allow construction using '0' as the initial value, for readability, - // but no other numbers (so we don't have any implicit unit conversions). - struct _SomethingVeryRandomHere; - MOZ_IMPLICIT BaseTimeDuration(_SomethingVeryRandomHere* aZero) : mValue(0) - { - MOZ_ASSERT(!aZero, "Who's playing funny games here?"); - } - // Default copy-constructor and assignment are OK - - // Converting copy-constructor and assignment operator - template <typename E> - explicit BaseTimeDuration(const BaseTimeDuration<E>& aOther) - : mValue(aOther.mValue) - { } - - template <typename E> - BaseTimeDuration& operator=(const BaseTimeDuration<E>& aOther) - { - mValue = aOther.mValue; - return *this; - } - - double ToSeconds() const - { - if (mValue == INT64_MAX) { - return PositiveInfinity<double>(); - } - if (mValue == INT64_MIN) { - return NegativeInfinity<double>(); - } - return BaseTimeDurationPlatformUtils::ToSeconds(mValue); - } - // Return a duration value that includes digits of time we think to - // be significant. This method should be used when displaying a - // time to humans. - double ToSecondsSigDigits() const - { - if (mValue == INT64_MAX) { - return PositiveInfinity<double>(); - } - if (mValue == INT64_MIN) { - return NegativeInfinity<double>(); - } - return BaseTimeDurationPlatformUtils::ToSecondsSigDigits(mValue); - } - double ToMilliseconds() const { return ToSeconds() * 1000.0; } - double ToMicroseconds() const { return ToMilliseconds() * 1000.0; } - - // Using a double here is safe enough; with 53 bits we can represent - // durations up to over 280,000 years exactly. If the units of - // mValue do not allow us to represent durations of that length, - // long durations are clamped to the max/min representable value - // instead of overflowing. - static inline BaseTimeDuration FromSeconds(double aSeconds) - { - return FromMilliseconds(aSeconds * 1000.0); - } - static BaseTimeDuration FromMilliseconds(double aMilliseconds) - { - if (aMilliseconds == PositiveInfinity<double>()) { - return Forever(); - } - if (aMilliseconds == NegativeInfinity<double>()) { - return FromTicks(INT64_MIN); - } - return FromTicks( - BaseTimeDurationPlatformUtils::TicksFromMilliseconds(aMilliseconds)); - } - static inline BaseTimeDuration FromMicroseconds(double aMicroseconds) - { - return FromMilliseconds(aMicroseconds / 1000.0); - } - - static BaseTimeDuration Forever() - { - return FromTicks(INT64_MAX); - } - - BaseTimeDuration operator+(const BaseTimeDuration& aOther) const - { - return FromTicks(ValueCalculator::Add(mValue, aOther.mValue)); - } - BaseTimeDuration operator-(const BaseTimeDuration& aOther) const - { - return FromTicks(ValueCalculator::Subtract(mValue, aOther.mValue)); - } - BaseTimeDuration& operator+=(const BaseTimeDuration& aOther) - { - mValue = ValueCalculator::Add(mValue, aOther.mValue); - return *this; - } - BaseTimeDuration& operator-=(const BaseTimeDuration& aOther) - { - mValue = ValueCalculator::Subtract(mValue, aOther.mValue); - return *this; - } - BaseTimeDuration operator-() const - { - // We don't just use FromTicks(ValueCalculator::Subtract(0, mValue)) - // since that won't give the correct result for -TimeDuration::Forever(). - int64_t ticks; - if (mValue == INT64_MAX) { - ticks = INT64_MIN; - } else if (mValue == INT64_MIN) { - ticks = INT64_MAX; - } else { - ticks = -mValue; - } - - return FromTicks(ticks); - } - -private: - // Block double multiplier (slower, imprecise if long duration) - Bug 853398. - // If required, use MultDouble explicitly and with care. - BaseTimeDuration operator*(const double aMultiplier) const = delete; - - // Block double divisor (for the same reason, and because dividing by - // fractional values would otherwise invoke the int64_t variant, and rounding - // the passed argument can then cause divide-by-zero) - Bug 1147491. - BaseTimeDuration operator/(const double aDivisor) const = delete; - -public: - BaseTimeDuration MultDouble(double aMultiplier) const - { - return FromTicks(ValueCalculator::Multiply(mValue, aMultiplier)); - } - BaseTimeDuration operator*(const int32_t aMultiplier) const - { - return FromTicks(ValueCalculator::Multiply(mValue, aMultiplier)); - } - BaseTimeDuration operator*(const uint32_t aMultiplier) const - { - return FromTicks(ValueCalculator::Multiply(mValue, aMultiplier)); - } - BaseTimeDuration operator*(const int64_t aMultiplier) const - { - return FromTicks(ValueCalculator::Multiply(mValue, aMultiplier)); - } - BaseTimeDuration operator*(const uint64_t aMultiplier) const - { - if (aMultiplier > INT64_MAX) { - return Forever(); - } - return FromTicks(ValueCalculator::Multiply(mValue, aMultiplier)); - } - BaseTimeDuration operator/(const int64_t aDivisor) const - { - MOZ_ASSERT(aDivisor != 0, "Division by zero"); - return FromTicks(ValueCalculator::Divide(mValue, aDivisor)); - } - double operator/(const BaseTimeDuration& aOther) const - { -#ifndef MOZ_B2G - // Bug 1066388 - This fails on B2G ICS Emulator - MOZ_ASSERT(aOther.mValue != 0, "Division by zero"); -#endif - return ValueCalculator::DivideDouble(mValue, aOther.mValue); - } - BaseTimeDuration operator%(const BaseTimeDuration& aOther) const - { - MOZ_ASSERT(aOther.mValue != 0, "Division by zero"); - return FromTicks(ValueCalculator::Modulo(mValue, aOther.mValue)); - } - - template<typename E> - bool operator<(const BaseTimeDuration<E>& aOther) const - { - return mValue < aOther.mValue; - } - template<typename E> - bool operator<=(const BaseTimeDuration<E>& aOther) const - { - return mValue <= aOther.mValue; - } - template<typename E> - bool operator>=(const BaseTimeDuration<E>& aOther) const - { - return mValue >= aOther.mValue; - } - template<typename E> - bool operator>(const BaseTimeDuration<E>& aOther) const - { - return mValue > aOther.mValue; - } - template<typename E> - bool operator==(const BaseTimeDuration<E>& aOther) const - { - return mValue == aOther.mValue; - } - template<typename E> - bool operator!=(const BaseTimeDuration<E>& aOther) const - { - return mValue != aOther.mValue; - } - bool IsZero() const - { - return mValue == 0; - } - explicit operator bool() const - { - return mValue != 0; - } - - // Return a best guess at the system's current timing resolution, - // which might be variable. BaseTimeDurations below this order of - // magnitude are meaningless, and those at the same order of - // magnitude or just above are suspect. - static BaseTimeDuration Resolution() { - return FromTicks(BaseTimeDurationPlatformUtils::ResolutionInTicks()); - } - - // We could define additional operators here: - // -- convert to/from other time units - // -- scale duration by a float - // but let's do that on demand. - // Comparing durations for equality will only lead to bugs on - // platforms with high-resolution timers. - -private: - friend class TimeStamp; - friend struct IPC::ParamTraits<mozilla::BaseTimeDuration<ValueCalculator>>; - template <typename> - friend class BaseTimeDuration; - - static BaseTimeDuration FromTicks(int64_t aTicks) - { - BaseTimeDuration t; - t.mValue = aTicks; - return t; - } - - static BaseTimeDuration FromTicks(double aTicks) - { - // NOTE: this MUST be a >= test, because int64_t(double(INT64_MAX)) - // overflows and gives INT64_MIN. - if (aTicks >= double(INT64_MAX)) { - return FromTicks(INT64_MAX); - } - - // This MUST be a <= test. - if (aTicks <= double(INT64_MIN)) { - return FromTicks(INT64_MIN); - } - - return FromTicks(int64_t(aTicks)); - } - - // Duration, result is implementation-specific difference of two TimeStamps - int64_t mValue; -}; - -/** - * Perform arithmetic operations on the value of a BaseTimeDuration without - * doing strict checks on the range of values. - */ -class TimeDurationValueCalculator -{ -public: - static int64_t Add(int64_t aA, int64_t aB) { return aA + aB; } - static int64_t Subtract(int64_t aA, int64_t aB) { return aA - aB; } - - template <typename T> - static int64_t Multiply(int64_t aA, T aB) - { - static_assert(IsIntegral<T>::value, - "Using integer multiplication routine with non-integer type." - " Further specialization required"); - return aA * static_cast<int64_t>(aB); - } - - static int64_t Divide(int64_t aA, int64_t aB) { return aA / aB; } - static double DivideDouble(int64_t aA, int64_t aB) - { - return static_cast<double>(aA) / aB; - } - static int64_t Modulo(int64_t aA, int64_t aB) { return aA % aB; } -}; - -template <> -inline int64_t -TimeDurationValueCalculator::Multiply<double>(int64_t aA, double aB) -{ - return static_cast<int64_t>(aA * aB); -} - -/** - * Specialization of BaseTimeDuration that uses TimeDurationValueCalculator for - * arithmetic on the mValue member. - * - * Use this class for time durations that are *not* expected to hold values of - * Forever (or the negative equivalent) or when such time duration are *not* - * expected to be used in arithmetic operations. - */ -typedef BaseTimeDuration<TimeDurationValueCalculator> TimeDuration; - -/** - * Instances of this class represent moments in time, or a special - * "null" moment. We do not use the non-monotonic system clock or - * local time, since they can be reset, causing apparent backward - * travel in time, which can confuse algorithms. Instead we measure - * elapsed time according to the system. This time can never go - * backwards (i.e. it never wraps around, at least not in less than - * five million years of system elapsed time). It might not advance - * while the system is sleeping. If TimeStamp::SetNow() is not called - * at all for hours or days, we might not notice the passage of some - * of that time. - * - * We deliberately do not expose a way to convert TimeStamps to some - * particular unit. All you can do is compute a difference between two - * TimeStamps to get a TimeDuration. You can also add a TimeDuration - * to a TimeStamp to get a new TimeStamp. You can't do something - * meaningless like add two TimeStamps. - * - * Internally this is implemented as either a wrapper around - * - high-resolution, monotonic, system clocks if they exist on this - * platform - * - PRIntervalTime otherwise. We detect wraparounds of - * PRIntervalTime and work around them. - * - * This class is similar to C++11's time_point, however it is - * explicitly nullable and provides an IsNull() method. time_point - * is initialized to the clock's epoch and provides a - * time_since_epoch() method that functions similiarly. i.e. - * t.IsNull() is equivalent to t.time_since_epoch() == decltype(t)::duration::zero(); - */ -class TimeStamp -{ -public: - /** - * Initialize to the "null" moment - */ - constexpr TimeStamp() : mValue(0) {} - // Default copy-constructor and assignment are OK - - /** - * The system timestamps are the same as the TimeStamp - * retrieved by mozilla::TimeStamp. Since we need this for - * vsync timestamps, we enable the creation of mozilla::TimeStamps - * on platforms that support vsync aligned refresh drivers / compositors - * Verified true as of Jan 31, 2015: B2G and OS X - * False on Windows 7 - * UNTESTED ON OTHER PLATFORMS - */ -#if defined(MOZ_WIDGET_GONK) || defined(XP_DARWIN) - static TimeStamp FromSystemTime(int64_t aSystemTime) - { - static_assert(sizeof(aSystemTime) == sizeof(TimeStampValue), - "System timestamp should be same units as TimeStampValue"); - return TimeStamp(aSystemTime); - } -#endif - - /** - * Return true if this is the "null" moment - */ - bool IsNull() const { return mValue == 0; } - - /** - * Return true if this is not the "null" moment, may be used in tests, e.g.: - * |if (timestamp) { ... }| - */ - explicit operator bool() const - { - return mValue != 0; - } - - /** - * Return a timestamp reflecting the current elapsed system time. This - * is monotonically increasing (i.e., does not decrease) over the - * lifetime of this process' XPCOM session. - * - * Now() is trying to ensure the best possible precision on each platform, - * at least one millisecond. - * - * NowLoRes() has been introduced to workaround performance problems of - * QueryPerformanceCounter on the Windows platform. NowLoRes() is giving - * lower precision, usually 15.6 ms, but with very good performance benefit. - * Use it for measurements of longer times, like >200ms timeouts. - */ - static TimeStamp Now() { return Now(true); } - static TimeStamp NowLoRes() { return Now(false); } - - /** - * Return a timestamp representing the time when the current process was - * created which will be comparable with other timestamps taken with this - * class. If the actual process creation time is detected to be inconsistent - * the @a aIsInconsistent parameter will be set to true, the returned - * timestamp however will still be valid though inaccurate. - * - * @param aIsInconsistent Set to true if an inconsistency was detected in the - * process creation time - * @returns A timestamp representing the time when the process was created, - * this timestamp is always valid even when errors are reported - */ - static MFBT_API TimeStamp ProcessCreation(bool& aIsInconsistent); - - /** - * Records a process restart. After this call ProcessCreation() will return - * the time when the browser was restarted instead of the actual time when - * the process was created. - */ - static MFBT_API void RecordProcessRestart(); - - /** - * Compute the difference between two timestamps. Both must be non-null. - */ - TimeDuration operator-(const TimeStamp& aOther) const - { - MOZ_ASSERT(!IsNull(), "Cannot compute with a null value"); - MOZ_ASSERT(!aOther.IsNull(), "Cannot compute with aOther null value"); - static_assert(-INT64_MAX > INT64_MIN, "int64_t sanity check"); - int64_t ticks = int64_t(mValue - aOther.mValue); - // Check for overflow. - if (mValue > aOther.mValue) { - if (ticks < 0) { - ticks = INT64_MAX; - } - } else { - if (ticks > 0) { - ticks = INT64_MIN; - } - } - return TimeDuration::FromTicks(ticks); - } - - TimeStamp operator+(const TimeDuration& aOther) const - { - TimeStamp result = *this; - result += aOther; - return result; - } - TimeStamp operator-(const TimeDuration& aOther) const - { - TimeStamp result = *this; - result -= aOther; - return result; - } - TimeStamp& operator+=(const TimeDuration& aOther) - { - MOZ_ASSERT(!IsNull(), "Cannot compute with a null value"); - TimeStampValue value = mValue + aOther.mValue; - // Check for underflow. - // (We don't check for overflow because it's not obvious what the error - // behavior should be in that case.) - if (aOther.mValue < 0 && value > mValue) { - value = 0; - } - mValue = value; - return *this; - } - TimeStamp& operator-=(const TimeDuration& aOther) - { - MOZ_ASSERT(!IsNull(), "Cannot compute with a null value"); - TimeStampValue value = mValue - aOther.mValue; - // Check for underflow. - // (We don't check for overflow because it's not obvious what the error - // behavior should be in that case.) - if (aOther.mValue > 0 && value > mValue) { - value = 0; - } - mValue = value; - return *this; - } - - bool operator<(const TimeStamp& aOther) const - { - MOZ_ASSERT(!IsNull(), "Cannot compute with a null value"); - MOZ_ASSERT(!aOther.IsNull(), "Cannot compute with aOther null value"); - return mValue < aOther.mValue; - } - bool operator<=(const TimeStamp& aOther) const - { - MOZ_ASSERT(!IsNull(), "Cannot compute with a null value"); - MOZ_ASSERT(!aOther.IsNull(), "Cannot compute with aOther null value"); - return mValue <= aOther.mValue; - } - bool operator>=(const TimeStamp& aOther) const - { - MOZ_ASSERT(!IsNull(), "Cannot compute with a null value"); - MOZ_ASSERT(!aOther.IsNull(), "Cannot compute with aOther null value"); - return mValue >= aOther.mValue; - } - bool operator>(const TimeStamp& aOther) const - { - MOZ_ASSERT(!IsNull(), "Cannot compute with a null value"); - MOZ_ASSERT(!aOther.IsNull(), "Cannot compute with aOther null value"); - return mValue > aOther.mValue; - } - bool operator==(const TimeStamp& aOther) const - { - return IsNull() - ? aOther.IsNull() - : !aOther.IsNull() && mValue == aOther.mValue; - } - bool operator!=(const TimeStamp& aOther) const - { - return !(*this == aOther); - } - - // Comparing TimeStamps for equality should be discouraged. Adding - // two TimeStamps, or scaling TimeStamps, is nonsense and must never - // be allowed. - - static MFBT_API void Startup(); - static MFBT_API void Shutdown(); - -private: - friend struct IPC::ParamTraits<mozilla::TimeStamp>; - friend void StartupTimelineRecordExternal(int, uint64_t); - - MOZ_IMPLICIT TimeStamp(TimeStampValue aValue) : mValue(aValue) {} - - static MFBT_API TimeStamp Now(bool aHighResolution); - - /** - * Computes the uptime of the current process in microseconds. The result - * is platform-dependent and needs to be checked against existing timestamps - * for consistency. - * - * @returns The number of microseconds since the calling process was started - * or 0 if an error was encountered while computing the uptime - */ - static MFBT_API uint64_t ComputeProcessUptime(); - - /** - * When built with PRIntervalTime, a value of 0 means this instance - * is "null". Otherwise, the low 32 bits represent a PRIntervalTime, - * and the high 32 bits represent a counter of the number of - * rollovers of PRIntervalTime that we've seen. This counter starts - * at 1 to avoid a real time colliding with the "null" value. - * - * PR_INTERVAL_MAX is set at 100,000 ticks per second. So the minimum - * time to wrap around is about 2^64/100000 seconds, i.e. about - * 5,849,424 years. - * - * When using a system clock, a value is system dependent. - */ - TimeStampValue mValue; -}; - -} // namespace mozilla - -#endif /* mozilla_TimeStamp_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/ToString.h b/android/armeabi/include/spidermonkey/mozilla/ToString.h deleted file mode 100644 index f11cad5c..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/ToString.h +++ /dev/null @@ -1,32 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Utilities for converting an object to a string representation. */ - -#ifndef mozilla_ToString_h -#define mozilla_ToString_h - -#include <string> -#include <sstream> - -namespace mozilla { - -/** - * A convenience function for converting an object to a string representation. - * Supports any object which can be streamed to an std::ostream. - */ -template<typename T> -std::string -ToString(const T& aValue) -{ - std::ostringstream stream; - stream << aValue; - return stream.str(); -} - -} // namespace mozilla - -#endif /* mozilla_ToString_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Tuple.h b/android/armeabi/include/spidermonkey/mozilla/Tuple.h deleted file mode 100644 index a7f9bee6..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Tuple.h +++ /dev/null @@ -1,461 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A variadic tuple class. */ - -#ifndef mozilla_Tuple_h -#define mozilla_Tuple_h - -#include "mozilla/Move.h" -#include "mozilla/Pair.h" -#include "mozilla/TemplateLib.h" -#include "mozilla/TypeTraits.h" - -#include <stddef.h> -#include <utility> - -namespace mozilla { - -namespace detail { - -/* - * A helper class that allows passing around multiple variadic argument lists - * by grouping them. - */ -template<typename... Ts> -struct Group; - -/* - * CheckConvertibility checks whether each type in a source pack of types - * is convertible to the corresponding type in a target pack of types. - * - * It is intended to be invoked like this: - * CheckConvertibility<Group<SourceTypes...>, Group<TargetTypes...>> - * 'Group' is used to separate types in the two packs (otherwise if we just - * wrote 'CheckConvertibility<SourceTypes..., TargetTypes...', it couldn't - * know where the first pack ends and the second begins). - * - * Note that we need to check explicitly that the two packs are of the same - * size, because attempting to simultaneously expand two parameter packs - * is an error (and it would be a hard error, because it wouldn't be in the - * immediate context of the caller). - */ - -template<typename Source, typename Target, bool SameSize> -struct CheckConvertibilityImpl; - -template<typename Source, typename Target> -struct CheckConvertibilityImpl<Source, Target, false> - : FalseType {}; - -template<typename... SourceTypes, typename... TargetTypes> -struct CheckConvertibilityImpl<Group<SourceTypes...>, Group<TargetTypes...>, true> - : IntegralConstant<bool, tl::And<IsConvertible<SourceTypes, TargetTypes>::value...>::value> { }; - -template<typename Source, typename Target> -struct CheckConvertibility; - -template<typename... SourceTypes, typename... TargetTypes> -struct CheckConvertibility<Group<SourceTypes...>, Group<TargetTypes...>> - : CheckConvertibilityImpl<Group<SourceTypes...>, Group<TargetTypes...>, - sizeof...(SourceTypes) == sizeof...(TargetTypes)> { }; - -/* - * TupleImpl is a helper class used to implement mozilla::Tuple. - * It represents one node in a recursive inheritance hierarchy. - * 'Index' is the 0-based index of the tuple element stored in this node; - * 'Elements...' are the types of the elements stored in this node and its - * base classes. - * - * Example: - * Tuple<int, float, char> inherits from - * TupleImpl<0, int, float, char>, which stores the 'int' and inherits from - * TupleImpl<1, float, char>, which stores the 'float' and inherits from - * TupleImpl<2, char>, which stores the 'char' and inherits from - * TupleImpl<3>, which stores nothing and terminates the recursion. - * - * The purpose of the 'Index' parameter is to allow efficient index-based - * access to a tuple element: given a tuple, and an index 'I' that we wish to - * access, we can cast the tuple to the base which stores the I'th element - * by performing template argument deduction against 'TupleImpl<I, E...>', - * where 'I' is specified explicitly and 'E...' is deduced (this is what the - * non-member 'Get<N>(t)' function does). - * - * This implementation strategy is borrowed from libstdc++'s std::tuple - * implementation. - */ -template<std::size_t Index, typename... Elements> -struct TupleImpl; - -/* - * The base case of the inheritance recursion (and also the implementation - * of an empty tuple). - */ -template<std::size_t Index> -struct TupleImpl<Index> { - bool operator==(const TupleImpl<Index>& aOther) const - { - return true; - } -}; - -/* - * One node of the recursive inheritance hierarchy. It stores the element at - * index 'Index' of a tuple, of type 'HeadT', and inherits from the nodes - * that store the remaining elements, of types 'TailT...'. - */ -template<std::size_t Index, typename HeadT, typename... TailT> -struct TupleImpl<Index, HeadT, TailT...> - : public TupleImpl<Index + 1, TailT...> -{ - typedef TupleImpl<Index + 1, TailT...> Base; - - // Accessors for the head and the tail. - // These are static, because the intended usage is for the caller to, - // given a tuple, obtain the type B of the base class which stores the - // element of interest, and then call B::Head(tuple) to access it. - // (Tail() is mostly for internal use, but is exposed for consistency.) - static HeadT& Head(TupleImpl& aTuple) { return aTuple.mHead; } - static const HeadT& Head(const TupleImpl& aTuple) { return aTuple.mHead; } - static Base& Tail(TupleImpl& aTuple) { return aTuple; } - static const Base& Tail(const TupleImpl& aTuple) { return aTuple; } - - TupleImpl() : Base(), mHead() { } - - // Construct from const references to the elements. - explicit TupleImpl(const HeadT& aHead, const TailT&... aTail) - : Base(aTail...), mHead(aHead) { } - - // Construct from objects that are convertible to the elements. - // This constructor is enabled only when the argument types are actually - // convertible to the element types, otherwise it could become a better - // match for certain invocations than the copy constructor. - template <typename OtherHeadT, typename... OtherTailT, - typename = typename EnableIf< - CheckConvertibility< - Group<OtherHeadT, OtherTailT...>, - Group<HeadT, TailT...>>::value>::Type> - explicit TupleImpl(OtherHeadT&& aHead, OtherTailT&&... aTail) - : Base(Forward<OtherTailT>(aTail)...), mHead(Forward<OtherHeadT>(aHead)) { } - - // Copy and move constructors. - // We'd like to use '= default' to implement these, but MSVC 2013's support - // for '= default' is incomplete and this doesn't work. - TupleImpl(const TupleImpl& aOther) - : Base(Tail(aOther)) - , mHead(Head(aOther)) {} - TupleImpl(TupleImpl&& aOther) - : Base(Move(Tail(aOther))) - , mHead(Forward<HeadT>(Head(aOther))) {} - - // Assign from a tuple whose elements are convertible to the elements - // of this tuple. - template <typename... OtherElements, - typename = typename EnableIf< - sizeof...(OtherElements) == sizeof...(TailT) + 1>::Type> - TupleImpl& operator=(const TupleImpl<Index, OtherElements...>& aOther) - { - typedef TupleImpl<Index, OtherElements...> OtherT; - Head(*this) = OtherT::Head(aOther); - Tail(*this) = OtherT::Tail(aOther); - return *this; - } - template <typename... OtherElements, - typename = typename EnableIf< - sizeof...(OtherElements) == sizeof...(TailT) + 1>::Type> - TupleImpl& operator=(TupleImpl<Index, OtherElements...>&& aOther) - { - typedef TupleImpl<Index, OtherElements...> OtherT; - Head(*this) = Move(OtherT::Head(aOther)); - Tail(*this) = Move(OtherT::Tail(aOther)); - return *this; - } - - // Copy and move assignment operators. - TupleImpl& operator=(const TupleImpl& aOther) - { - Head(*this) = Head(aOther); - Tail(*this) = Tail(aOther); - return *this; - } - TupleImpl& operator=(TupleImpl&& aOther) - { - Head(*this) = Move(Head(aOther)); - Tail(*this) = Move(Tail(aOther)); - return *this; - } - bool operator==(const TupleImpl& aOther) const - { - return Head(*this) == Head(aOther) && Tail(*this) == Tail(aOther); - } -private: - HeadT mHead; // The element stored at this index in the tuple. -}; - -} // namespace detail - -/** - * Tuple is a class that stores zero or more objects, whose types are specified - * as template parameters. It can be thought of as a generalization of Pair, - * (which can be thought of as a 2-tuple). - * - * Tuple allows index-based access to its elements (with the index having to be - * known at compile time) via the non-member function 'Get<N>(tuple)'. - */ -template<typename... Elements> -class Tuple : public detail::TupleImpl<0, Elements...> -{ - typedef detail::TupleImpl<0, Elements...> Impl; -public: - // The constructors and assignment operators here are simple wrappers - // around those in TupleImpl. - - Tuple() : Impl() { } - explicit Tuple(const Elements&... aElements) : Impl(aElements...) { } - // Here, we can't just use 'typename... OtherElements' because MSVC will give - // a warning "C4520: multiple default constructors specified" (even if no one - // actually instantiates the constructor with an empty parameter pack - - // that's probably a bug) and we compile with warnings-as-errors. - template <typename OtherHead, typename... OtherTail, - typename = typename EnableIf< - detail::CheckConvertibility< - detail::Group<OtherHead, OtherTail...>, - detail::Group<Elements...>>::value>::Type> - explicit Tuple(OtherHead&& aHead, OtherTail&&... aTail) - : Impl(Forward<OtherHead>(aHead), Forward<OtherTail>(aTail)...) { } - Tuple(const Tuple& aOther) : Impl(aOther) { } - Tuple(Tuple&& aOther) : Impl(Move(aOther)) { } - - template <typename... OtherElements, - typename = typename EnableIf< - sizeof...(OtherElements) == sizeof...(Elements)>::Type> - Tuple& operator=(const Tuple<OtherElements...>& aOther) - { - static_cast<Impl&>(*this) = aOther; - return *this; - } - template <typename... OtherElements, - typename = typename EnableIf< - sizeof...(OtherElements) == sizeof...(Elements)>::Type> - Tuple& operator=(Tuple<OtherElements...>&& aOther) - { - static_cast<Impl&>(*this) = Move(aOther); - return *this; - } - Tuple& operator=(const Tuple& aOther) - { - static_cast<Impl&>(*this) = aOther; - return *this; - } - Tuple& operator=(Tuple&& aOther) - { - static_cast<Impl&>(*this) = Move(aOther); - return *this; - } - bool operator==(const Tuple& aOther) const - { - return static_cast<const Impl&>(*this) == static_cast<const Impl&>(aOther); - } -}; - -/** - * Specialization of Tuple for two elements. - * This is created to support construction and assignment from a Pair or std::pair. - */ -template <typename A, typename B> -class Tuple<A, B> : public detail::TupleImpl<0, A, B> -{ - typedef detail::TupleImpl<0, A, B> Impl; - -public: - // The constructors and assignment operators here are simple wrappers - // around those in TupleImpl. - - Tuple() : Impl() { } - explicit Tuple(const A& aA, const B& aB) : Impl(aA, aB) { } - template <typename AArg, typename BArg, - typename = typename EnableIf< - detail::CheckConvertibility< - detail::Group<AArg, BArg>, - detail::Group<A, B>>::value>::Type> - explicit Tuple(AArg&& aA, BArg&& aB) - : Impl(Forward<AArg>(aA), Forward<BArg>(aB)) { } - Tuple(const Tuple& aOther) : Impl(aOther) { } - Tuple(Tuple&& aOther) : Impl(Move(aOther)) { } - explicit Tuple(const Pair<A, B>& aOther) - : Impl(aOther.first(), aOther.second()) { } - explicit Tuple(Pair<A, B>&& aOther) : Impl(Forward<A>(aOther.first()), - Forward<B>(aOther.second())) { } - explicit Tuple(const std::pair<A, B>& aOther) - : Impl(aOther.first, aOther.second) { } - explicit Tuple(std::pair<A, B>&& aOther) : Impl(Forward<A>(aOther.first), - Forward<B>(aOther.second)) { } - - template <typename AArg, typename BArg> - Tuple& operator=(const Tuple<AArg, BArg>& aOther) - { - static_cast<Impl&>(*this) = aOther; - return *this; - } - template <typename AArg, typename BArg> - Tuple& operator=(Tuple<AArg, BArg>&& aOther) - { - static_cast<Impl&>(*this) = Move(aOther); - return *this; - } - Tuple& operator=(const Tuple& aOther) - { - static_cast<Impl&>(*this) = aOther; - return *this; - } - Tuple& operator=(Tuple&& aOther) - { - static_cast<Impl&>(*this) = Move(aOther); - return *this; - } - template <typename AArg, typename BArg> - Tuple& operator=(const Pair<AArg, BArg>& aOther) - { - Impl::Head(*this) = aOther.first(); - Impl::Tail(*this).Head(*this) = aOther.second(); - return *this; - } - template <typename AArg, typename BArg> - Tuple& operator=(Pair<AArg, BArg>&& aOther) - { - Impl::Head(*this) = Forward<AArg>(aOther.first()); - Impl::Tail(*this).Head(*this) = Forward<BArg>(aOther.second()); - return *this; - } - template <typename AArg, typename BArg> - Tuple& operator=(const std::pair<AArg, BArg>& aOther) - { - Impl::Head(*this) = aOther.first; - Impl::Tail(*this).Head(*this) = aOther.second; - return *this; - } - template <typename AArg, typename BArg> - Tuple& operator=(std::pair<AArg, BArg>&& aOther) - { - Impl::Head(*this) = Forward<AArg>(aOther.first); - Impl::Tail(*this).Head(*this) = Forward<BArg>(aOther.second); - return *this; - } -}; - -/** - * Specialization of Tuple for zero arguments. - * This is necessary because if the primary template were instantiated with - * an empty parameter pack, the 'Tuple(Elements...)' constructors would - * become illegal overloads of the default constructor. - */ -template <> -class Tuple<> {}; - -namespace detail { - -/* - * Helper functions for implementing Get<N>(tuple). - * These functions take a TupleImpl<Index, Elements...>, with Index being - * explicitly specified, and Elements being deduced. By passing a Tuple - * object as argument, template argument deduction will do its magic and - * cast the tuple to the base class which stores the element at Index. - */ - -// Const reference version. -template<std::size_t Index, typename... Elements> -auto TupleGetHelper(TupleImpl<Index, Elements...>& aTuple) - -> decltype(TupleImpl<Index, Elements...>::Head(aTuple)) -{ - return TupleImpl<Index, Elements...>::Head(aTuple); -} - -// Non-const reference version. -template<std::size_t Index, typename... Elements> -auto TupleGetHelper(const TupleImpl<Index, Elements...>& aTuple) - -> decltype(TupleImpl<Index, Elements...>::Head(aTuple)) -{ - return TupleImpl<Index, Elements...>::Head(aTuple); -} - -} // namespace detail - -/** - * Index-based access to an element of a tuple. - * The syntax is Get<Index>(tuple). The index is zero-based. - * - * Example: - * - * Tuple<int, float, char> t; - * ... - * float f = Get<1>(t); - */ - -// Non-const reference version. -template<std::size_t Index, typename... Elements> -auto Get(Tuple<Elements...>& aTuple) - -> decltype(detail::TupleGetHelper<Index>(aTuple)) -{ - return detail::TupleGetHelper<Index>(aTuple); -} - -// Const reference version. -template<std::size_t Index, typename... Elements> -auto Get(const Tuple<Elements...>& aTuple) - -> decltype(detail::TupleGetHelper<Index>(aTuple)) -{ - return detail::TupleGetHelper<Index>(aTuple); -} - -// Rvalue reference version. -template<std::size_t Index, typename... Elements> -auto Get(Tuple<Elements...>&& aTuple) - -> decltype(Move(mozilla::Get<Index>(aTuple))) -{ - // We need a 'mozilla::' qualification here to avoid - // name lookup only finding the current function. - return Move(mozilla::Get<Index>(aTuple)); -} - -/** - * A convenience function for constructing a tuple out of a sequence of - * values without specifying the type of the tuple. - * The type of the tuple is deduced from the types of its elements. - * - * Example: - * - * auto tuple = MakeTuple(42, 0.5f, 'c'); // has type Tuple<int, float, char> - */ -template<typename... Elements> -inline Tuple<typename Decay<Elements>::Type...> -MakeTuple(Elements&&... aElements) -{ - return Tuple<typename Decay<Elements>::Type...>(Forward<Elements>(aElements)...); -} - -/** - * A convenience function for constructing a tuple of references to a - * sequence of variables. Since assignments to the elements of the tuple - * "go through" to the referenced variables, this can be used to "unpack" - * a tuple into individual variables. - * - * Example: - * - * int i; - * float f; - * char c; - * Tie(i, f, c) = FunctionThatReturnsATuple(); - */ -template<typename... Elements> -inline Tuple<Elements&...> -Tie(Elements&... aVariables) -{ - return Tuple<Elements&...>(aVariables...); -} - -} // namespace mozilla - -#endif /* mozilla_Tuple_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/TypeTraits.h b/android/armeabi/include/spidermonkey/mozilla/TypeTraits.h deleted file mode 100644 index 084f608c..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/TypeTraits.h +++ /dev/null @@ -1,1262 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Template-based metaprogramming and type-testing facilities. */ - -#ifndef mozilla_TypeTraits_h -#define mozilla_TypeTraits_h - -#include "mozilla/Types.h" - -/* - * These traits are approximate copies of the traits and semantics from C++11's - * <type_traits> header. Don't add traits not in that header! When all - * platforms provide that header, we can convert all users and remove this one. - */ - -#include <wchar.h> - -namespace mozilla { - -/* Forward declarations. */ - -template<typename> struct RemoveCV; -template<typename> struct AddRvalueReference; - -/* 20.2.4 Function template declval [declval] */ - -/** - * DeclVal simplifies the definition of expressions which occur as unevaluated - * operands. It converts T to a reference type, making it possible to use in - * decltype expressions even if T does not have a default constructor, e.g.: - * decltype(DeclVal<TWithNoDefaultConstructor>().foo()) - */ -template<typename T> -typename AddRvalueReference<T>::Type DeclVal(); - -/* 20.9.3 Helper classes [meta.help] */ - -/** - * Helper class used as a base for various type traits, exposed publicly - * because <type_traits> exposes it as well. - */ -template<typename T, T Value> -struct IntegralConstant -{ - static const T value = Value; - typedef T ValueType; - typedef IntegralConstant<T, Value> Type; -}; - -/** Convenient aliases. */ -typedef IntegralConstant<bool, true> TrueType; -typedef IntegralConstant<bool, false> FalseType; - -/* 20.9.4 Unary type traits [meta.unary] */ - -/* 20.9.4.1 Primary type categories [meta.unary.cat] */ - -namespace detail { - -template<typename T> -struct IsVoidHelper : FalseType {}; - -template<> -struct IsVoidHelper<void> : TrueType {}; - -} // namespace detail - -/** - * IsVoid determines whether a type is void. - * - * mozilla::IsVoid<int>::value is false; - * mozilla::IsVoid<void>::value is true; - * mozilla::IsVoid<void*>::value is false; - * mozilla::IsVoid<volatile void>::value is true. - */ -template<typename T> -struct IsVoid : detail::IsVoidHelper<typename RemoveCV<T>::Type> {}; - -namespace detail { - -template <typename T> -struct IsIntegralHelper : FalseType {}; - -template<> struct IsIntegralHelper<char> : TrueType {}; -template<> struct IsIntegralHelper<signed char> : TrueType {}; -template<> struct IsIntegralHelper<unsigned char> : TrueType {}; -template<> struct IsIntegralHelper<short> : TrueType {}; -template<> struct IsIntegralHelper<unsigned short> : TrueType {}; -template<> struct IsIntegralHelper<int> : TrueType {}; -template<> struct IsIntegralHelper<unsigned int> : TrueType {}; -template<> struct IsIntegralHelper<long> : TrueType {}; -template<> struct IsIntegralHelper<unsigned long> : TrueType {}; -template<> struct IsIntegralHelper<long long> : TrueType {}; -template<> struct IsIntegralHelper<unsigned long long> : TrueType {}; -template<> struct IsIntegralHelper<bool> : TrueType {}; -template<> struct IsIntegralHelper<wchar_t> : TrueType {}; -template<> struct IsIntegralHelper<char16_t> : TrueType {}; - -} /* namespace detail */ - -/** - * IsIntegral determines whether a type is an integral type. - * - * mozilla::IsIntegral<int>::value is true; - * mozilla::IsIntegral<unsigned short>::value is true; - * mozilla::IsIntegral<const long>::value is true; - * mozilla::IsIntegral<int*>::value is false; - * mozilla::IsIntegral<double>::value is false; - */ -template<typename T> -struct IsIntegral : detail::IsIntegralHelper<typename RemoveCV<T>::Type> -{}; - -template<typename T, typename U> -struct IsSame; - -namespace detail { - -template<typename T> -struct IsFloatingPointHelper - : IntegralConstant<bool, - IsSame<T, float>::value || - IsSame<T, double>::value || - IsSame<T, long double>::value> -{}; - -} // namespace detail - -/** - * IsFloatingPoint determines whether a type is a floating point type (float, - * double, long double). - * - * mozilla::IsFloatingPoint<int>::value is false; - * mozilla::IsFloatingPoint<const float>::value is true; - * mozilla::IsFloatingPoint<long double>::value is true; - * mozilla::IsFloatingPoint<double*>::value is false. - */ -template<typename T> -struct IsFloatingPoint - : detail::IsFloatingPointHelper<typename RemoveCV<T>::Type> -{}; - -namespace detail { - -template<typename T> -struct IsArrayHelper : FalseType {}; - -template<typename T, decltype(sizeof(1)) N> -struct IsArrayHelper<T[N]> : TrueType {}; - -template<typename T> -struct IsArrayHelper<T[]> : TrueType {}; - -} // namespace detail - -/** - * IsArray determines whether a type is an array type, of known or unknown - * length. - * - * mozilla::IsArray<int>::value is false; - * mozilla::IsArray<int[]>::value is true; - * mozilla::IsArray<int[5]>::value is true. - */ -template<typename T> -struct IsArray : detail::IsArrayHelper<typename RemoveCV<T>::Type> -{}; - -namespace detail { - -template<typename T> -struct IsFunPtr; - -template<typename> -struct IsFunPtr - : public FalseType -{}; - -template<typename Result, typename... ArgTypes> -struct IsFunPtr<Result(*)(ArgTypes...)> - : public TrueType -{}; - -}; // namespace detail - -/** - * IsFunction determines whether a type is a function type. Function pointers - * don't qualify here--only the type of an actual function symbol. We do not - * correctly handle varags function types because of a bug in MSVC. - * - * Given the function: - * void f(int) {} - * - * mozilla::IsFunction<void(int)> is true; - * mozilla::IsFunction<void(*)(int)> is false; - * mozilla::IsFunction<decltype(f)> is true. - */ -template<typename T> -struct IsFunction - : public detail::IsFunPtr<typename RemoveCV<T>::Type *> -{}; - -namespace detail { - -template<typename T> -struct IsPointerHelper : FalseType {}; - -template<typename T> -struct IsPointerHelper<T*> : TrueType {}; - -} // namespace detail - -/** - * IsPointer determines whether a type is a possibly-CV-qualified pointer type - * (but not a pointer-to-member type). - * - * mozilla::IsPointer<struct S*>::value is true; - * mozilla::IsPointer<int*>::value is true; - * mozilla::IsPointer<int**>::value is true; - * mozilla::IsPointer<const int*>::value is true; - * mozilla::IsPointer<int* const>::value is true; - * mozilla::IsPointer<int* volatile>::value is true; - * mozilla::IsPointer<void (*)(void)>::value is true; - * mozilla::IsPointer<int>::value is false; - * mozilla::IsPointer<struct S>::value is false. - * mozilla::IsPointer<int(struct S::*)>::value is false - */ -template<typename T> -struct IsPointer : detail::IsPointerHelper<typename RemoveCV<T>::Type> -{}; - -/** - * IsLvalueReference determines whether a type is an lvalue reference. - * - * mozilla::IsLvalueReference<struct S*>::value is false; - * mozilla::IsLvalueReference<int**>::value is false; - * mozilla::IsLvalueReference<void (*)(void)>::value is false; - * mozilla::IsLvalueReference<int>::value is false; - * mozilla::IsLvalueReference<struct S>::value is false; - * mozilla::IsLvalueReference<struct S*&>::value is true; - * mozilla::IsLvalueReference<struct S&&>::value is false. - */ -template<typename T> -struct IsLvalueReference : FalseType {}; - -template<typename T> -struct IsLvalueReference<T&> : TrueType {}; - -/** - * IsRvalueReference determines whether a type is an rvalue reference. - * - * mozilla::IsRvalueReference<struct S*>::value is false; - * mozilla::IsRvalueReference<int**>::value is false; - * mozilla::IsRvalueReference<void (*)(void)>::value is false; - * mozilla::IsRvalueReference<int>::value is false; - * mozilla::IsRvalueReference<struct S>::value is false; - * mozilla::IsRvalueReference<struct S*&>::value is false; - * mozilla::IsRvalueReference<struct S&&>::value is true. - */ -template<typename T> -struct IsRvalueReference : FalseType {}; - -template<typename T> -struct IsRvalueReference<T&&> : TrueType {}; - -namespace detail { - -// __is_enum is a supported extension across all of our supported compilers. -template<typename T> -struct IsEnumHelper - : IntegralConstant<bool, __is_enum(T)> -{}; - -} // namespace detail - -/** - * IsEnum determines whether a type is an enum type. - * - * mozilla::IsEnum<enum S>::value is true; - * mozilla::IsEnum<enum S*>::value is false; - * mozilla::IsEnum<int>::value is false; - */ -template<typename T> -struct IsEnum - : detail::IsEnumHelper<typename RemoveCV<T>::Type> -{}; - -namespace detail { - -// __is_class is a supported extension across all of our supported compilers: -// http://llvm.org/releases/3.0/docs/ClangReleaseNotes.html -// http://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Type-Traits.html#Type-Traits -// http://msdn.microsoft.com/en-us/library/ms177194%28v=vs.100%29.aspx -template<typename T> -struct IsClassHelper - : IntegralConstant<bool, __is_class(T)> -{}; - -} // namespace detail - -/** - * IsClass determines whether a type is a class type (but not a union). - * - * struct S {}; - * union U {}; - * mozilla::IsClass<int>::value is false; - * mozilla::IsClass<const S>::value is true; - * mozilla::IsClass<U>::value is false; - */ -template<typename T> -struct IsClass - : detail::IsClassHelper<typename RemoveCV<T>::Type> -{}; - -/* 20.9.4.2 Composite type traits [meta.unary.comp] */ - -/** - * IsReference determines whether a type is an lvalue or rvalue reference. - * - * mozilla::IsReference<struct S*>::value is false; - * mozilla::IsReference<int**>::value is false; - * mozilla::IsReference<int&>::value is true; - * mozilla::IsReference<void (*)(void)>::value is false; - * mozilla::IsReference<const int&>::value is true; - * mozilla::IsReference<int>::value is false; - * mozilla::IsReference<struct S>::value is false; - * mozilla::IsReference<struct S&>::value is true; - * mozilla::IsReference<struct S*&>::value is true; - * mozilla::IsReference<struct S&&>::value is true. - */ -template<typename T> -struct IsReference - : IntegralConstant<bool, - IsLvalueReference<T>::value || IsRvalueReference<T>::value> -{}; - -/** - * IsArithmetic determines whether a type is arithmetic. A type is arithmetic - * iff it is an integral type or a floating point type. - * - * mozilla::IsArithmetic<int>::value is true; - * mozilla::IsArithmetic<double>::value is true; - * mozilla::IsArithmetic<long double*>::value is false. - */ -template<typename T> -struct IsArithmetic - : IntegralConstant<bool, IsIntegral<T>::value || IsFloatingPoint<T>::value> -{}; - -namespace detail { - -template<typename T> -struct IsMemberPointerHelper : FalseType {}; - -template<typename T, typename U> -struct IsMemberPointerHelper<T U::*> : TrueType {}; - -} // namespace detail - -/** - * IsMemberPointer determines whether a type is pointer to non-static member - * object or a pointer to non-static member function. - * - * mozilla::IsMemberPointer<int(cls::*)>::value is true - * mozilla::IsMemberPointer<int*>::value is false - */ -template<typename T> -struct IsMemberPointer - : detail::IsMemberPointerHelper<typename RemoveCV<T>::Type> -{}; - -/** - * IsScalar determines whether a type is a scalar type. - * - * mozilla::IsScalar<int>::value is true - * mozilla::IsScalar<int*>::value is true - * mozilla::IsScalar<cls>::value is false - */ -template<typename T> -struct IsScalar - : IntegralConstant<bool, IsArithmetic<T>::value || IsEnum<T>::value || - IsPointer<T>::value || IsMemberPointer<T>::value> -{}; - -/* 20.9.4.3 Type properties [meta.unary.prop] */ - -/** - * IsConst determines whether a type is const or not. - * - * mozilla::IsConst<int>::value is false; - * mozilla::IsConst<void* const>::value is true; - * mozilla::IsConst<const char*>::value is false. - */ -template<typename T> -struct IsConst : FalseType {}; - -template<typename T> -struct IsConst<const T> : TrueType {}; - -/** - * IsVolatile determines whether a type is volatile or not. - * - * mozilla::IsVolatile<int>::value is false; - * mozilla::IsVolatile<void* volatile>::value is true; - * mozilla::IsVolatile<volatile char*>::value is false. - */ -template<typename T> -struct IsVolatile : FalseType {}; - -template<typename T> -struct IsVolatile<volatile T> : TrueType {}; - -/** - * Traits class for identifying POD types. Until C++11 there's no automatic - * way to detect PODs, so for the moment this is done manually. Users may - * define specializations of this class that inherit from mozilla::TrueType and - * mozilla::FalseType (or equivalently mozilla::IntegralConstant<bool, true or - * false>, or conveniently from mozilla::IsPod for composite types) as needed to - * ensure correct IsPod behavior. - */ -template<typename T> -struct IsPod : public FalseType {}; - -template<> struct IsPod<char> : TrueType {}; -template<> struct IsPod<signed char> : TrueType {}; -template<> struct IsPod<unsigned char> : TrueType {}; -template<> struct IsPod<short> : TrueType {}; -template<> struct IsPod<unsigned short> : TrueType {}; -template<> struct IsPod<int> : TrueType {}; -template<> struct IsPod<unsigned int> : TrueType {}; -template<> struct IsPod<long> : TrueType {}; -template<> struct IsPod<unsigned long> : TrueType {}; -template<> struct IsPod<long long> : TrueType {}; -template<> struct IsPod<unsigned long long> : TrueType {}; -template<> struct IsPod<bool> : TrueType {}; -template<> struct IsPod<float> : TrueType {}; -template<> struct IsPod<double> : TrueType {}; -template<> struct IsPod<wchar_t> : TrueType {}; -template<> struct IsPod<char16_t> : TrueType {}; -template<typename T> struct IsPod<T*> : TrueType {}; - -namespace detail { - -// __is_empty is a supported extension across all of our supported compilers: -// http://llvm.org/releases/3.0/docs/ClangReleaseNotes.html -// http://gcc.gnu.org/onlinedocs/gcc-4.4.7/gcc/Type-Traits.html#Type-Traits -// http://msdn.microsoft.com/en-us/library/ms177194%28v=vs.100%29.aspx -template<typename T> -struct IsEmptyHelper - : IntegralConstant<bool, IsClass<T>::value && __is_empty(T)> -{}; - -} // namespace detail - -/** - * IsEmpty determines whether a type is a class (but not a union) that is empty. - * - * A class is empty iff it and all its base classes have no non-static data - * members (except bit-fields of length 0) and no virtual member functions, and - * no base class is empty or a virtual base class. - * - * Intuitively, empty classes don't have any data that has to be stored in - * instances of those classes. (The size of the class must still be non-zero, - * because distinct array elements of any type must have different addresses. - * However, if the Empty Base Optimization is implemented by the compiler [most - * compilers implement it, and in certain cases C++11 requires it], the size of - * a class inheriting from an empty |Base| class need not be inflated by - * |sizeof(Base)|.) And intuitively, non-empty classes have data members and/or - * vtable pointers that must be stored in each instance for proper behavior. - * - * static_assert(!mozilla::IsEmpty<int>::value, "not a class => not empty"); - * union U1 { int x; }; - * static_assert(!mozilla::IsEmpty<U1>::value, "not a class => not empty"); - * struct E1 {}; - * struct E2 { int : 0 }; - * struct E3 : E1 {}; - * struct E4 : E2 {}; - * static_assert(mozilla::IsEmpty<E1>::value && - * mozilla::IsEmpty<E2>::value && - * mozilla::IsEmpty<E3>::value && - * mozilla::IsEmpty<E4>::value, - * "all empty"); - * union U2 { E1 e1; }; - * static_assert(!mozilla::IsEmpty<U2>::value, "not a class => not empty"); - * struct NE1 { int x; }; - * struct NE2 : virtual E1 {}; - * struct NE3 : E2 { virtual ~NE3() {} }; - * struct NE4 { virtual void f() {} }; - * static_assert(!mozilla::IsEmpty<NE1>::value && - * !mozilla::IsEmpty<NE2>::value && - * !mozilla::IsEmpty<NE3>::value && - * !mozilla::IsEmpty<NE4>::value, - * "all empty"); - */ -template<typename T> -struct IsEmpty : detail::IsEmptyHelper<typename RemoveCV<T>::Type> -{}; - - -namespace detail { - -template<typename T, - bool = IsFloatingPoint<T>::value, - bool = IsIntegral<T>::value, - typename NoCV = typename RemoveCV<T>::Type> -struct IsSignedHelper; - -// Floating point is signed. -template<typename T, typename NoCV> -struct IsSignedHelper<T, true, false, NoCV> : TrueType {}; - -// Integral is conditionally signed. -template<typename T, typename NoCV> -struct IsSignedHelper<T, false, true, NoCV> - : IntegralConstant<bool, bool(NoCV(-1) < NoCV(1))> -{}; - -// Non-floating point, non-integral is not signed. -template<typename T, typename NoCV> -struct IsSignedHelper<T, false, false, NoCV> : FalseType {}; - -} // namespace detail - -/** - * IsSigned determines whether a type is a signed arithmetic type. |char| is - * considered a signed type if it has the same representation as |signed char|. - * - * mozilla::IsSigned<int>::value is true; - * mozilla::IsSigned<const unsigned int>::value is false; - * mozilla::IsSigned<unsigned char>::value is false; - * mozilla::IsSigned<float>::value is true. - */ -template<typename T> -struct IsSigned : detail::IsSignedHelper<T> {}; - -namespace detail { - -template<typename T, - bool = IsFloatingPoint<T>::value, - bool = IsIntegral<T>::value, - typename NoCV = typename RemoveCV<T>::Type> -struct IsUnsignedHelper; - -// Floating point is not unsigned. -template<typename T, typename NoCV> -struct IsUnsignedHelper<T, true, false, NoCV> : FalseType {}; - -// Integral is conditionally unsigned. -template<typename T, typename NoCV> -struct IsUnsignedHelper<T, false, true, NoCV> - : IntegralConstant<bool, - (IsSame<NoCV, bool>::value || bool(NoCV(1) < NoCV(-1)))> -{}; - -// Non-floating point, non-integral is not unsigned. -template<typename T, typename NoCV> -struct IsUnsignedHelper<T, false, false, NoCV> : FalseType {}; - -} // namespace detail - -/** - * IsUnsigned determines whether a type is an unsigned arithmetic type. - * - * mozilla::IsUnsigned<int>::value is false; - * mozilla::IsUnsigned<const unsigned int>::value is true; - * mozilla::IsUnsigned<unsigned char>::value is true; - * mozilla::IsUnsigned<float>::value is false. - */ -template<typename T> -struct IsUnsigned : detail::IsUnsignedHelper<T> {}; - -namespace detail { - -struct DoIsDestructibleImpl -{ - template<typename T, typename = decltype(DeclVal<T&>().~T())> - static TrueType test(int); - template<typename T> - static FalseType test(...); -}; - -template<typename T> -struct IsDestructibleImpl : public DoIsDestructibleImpl -{ - typedef decltype(test<T>(0)) Type; -}; - -} // namespace detail - -template<typename T> -struct IsDestructible : public detail::IsDestructibleImpl<T>::Type {}; - -/* 20.9.5 Type property queries [meta.unary.prop.query] */ - -/* 20.9.6 Relationships between types [meta.rel] */ - -/** - * IsSame tests whether two types are the same type. - * - * mozilla::IsSame<int, int>::value is true; - * mozilla::IsSame<int*, int*>::value is true; - * mozilla::IsSame<int, unsigned int>::value is false; - * mozilla::IsSame<void, void>::value is true; - * mozilla::IsSame<const int, int>::value is false; - * mozilla::IsSame<struct S, struct S>::value is true. - */ -template<typename T, typename U> -struct IsSame : FalseType {}; - -template<typename T> -struct IsSame<T, T> : TrueType {}; - -namespace detail { - -#if defined(__GNUC__) || defined(__clang__) || defined(_MSC_VER) - -template<class Base, class Derived> -struct BaseOfTester : IntegralConstant<bool, __is_base_of(Base, Derived)> {}; - -#else - -// The trickery used to implement IsBaseOf here makes it possible to use it for -// the cases of private and multiple inheritance. This code was inspired by the -// sample code here: -// -// http://stackoverflow.com/questions/2910979/how-is-base-of-works -template<class Base, class Derived> -struct BaseOfHelper -{ -public: - operator Base*() const; - operator Derived*(); -}; - -template<class Base, class Derived> -struct BaseOfTester -{ -private: - template<class T> - static char test(Derived*, T); - static int test(Base*, int); - -public: - static const bool value = - sizeof(test(BaseOfHelper<Base, Derived>(), int())) == sizeof(char); -}; - -template<class Base, class Derived> -struct BaseOfTester<Base, const Derived> -{ -private: - template<class T> - static char test(Derived*, T); - static int test(Base*, int); - -public: - static const bool value = - sizeof(test(BaseOfHelper<Base, Derived>(), int())) == sizeof(char); -}; - -template<class Base, class Derived> -struct BaseOfTester<Base&, Derived&> : FalseType {}; - -template<class Type> -struct BaseOfTester<Type, Type> : TrueType {}; - -template<class Type> -struct BaseOfTester<Type, const Type> : TrueType {}; - -#endif - -} /* namespace detail */ - -/* - * IsBaseOf allows to know whether a given class is derived from another. - * - * Consider the following class definitions: - * - * class A {}; - * class B : public A {}; - * class C {}; - * - * mozilla::IsBaseOf<A, B>::value is true; - * mozilla::IsBaseOf<A, C>::value is false; - */ -template<class Base, class Derived> -struct IsBaseOf - : IntegralConstant<bool, detail::BaseOfTester<Base, Derived>::value> -{}; - -namespace detail { - -template<typename From, typename To> -struct ConvertibleTester -{ -private: - template<typename To1> - static char test_helper(To1); - - template<typename From1, typename To1> - static decltype(test_helper<To1>(DeclVal<From1>())) test(int); - - template<typename From1, typename To1> - static int test(...); - -public: - static const bool value = - sizeof(test<From, To>(0)) == sizeof(char); -}; - -} // namespace detail - -/** - * IsConvertible determines whether a value of type From will implicitly convert - * to a value of type To. For example: - * - * struct A {}; - * struct B : public A {}; - * struct C {}; - * - * mozilla::IsConvertible<A, A>::value is true; - * mozilla::IsConvertible<A*, A*>::value is true; - * mozilla::IsConvertible<B, A>::value is true; - * mozilla::IsConvertible<B*, A*>::value is true; - * mozilla::IsConvertible<C, A>::value is false; - * mozilla::IsConvertible<A, C>::value is false; - * mozilla::IsConvertible<A*, C*>::value is false; - * mozilla::IsConvertible<C*, A*>::value is false. - * - * For obscure reasons, you can't use IsConvertible when the types being tested - * are related through private inheritance, and you'll get a compile error if - * you try. Just don't do it! - * - * Note - we need special handling for void, which ConvertibleTester doesn't - * handle. The void handling here doesn't handle const/volatile void correctly, - * which could be easily fixed if the need arises. - */ -template<typename From, typename To> -struct IsConvertible - : IntegralConstant<bool, detail::ConvertibleTester<From, To>::value> -{}; - -template<typename B> -struct IsConvertible<void, B> - : IntegralConstant<bool, IsVoid<B>::value> -{}; - -template<typename A> -struct IsConvertible<A, void> - : IntegralConstant<bool, IsVoid<A>::value> -{}; - -template<> -struct IsConvertible<void, void> - : TrueType -{}; - -/* 20.9.7 Transformations between types [meta.trans] */ - -/* 20.9.7.1 Const-volatile modifications [meta.trans.cv] */ - -/** - * RemoveConst removes top-level const qualifications on a type. - * - * mozilla::RemoveConst<int>::Type is int; - * mozilla::RemoveConst<const int>::Type is int; - * mozilla::RemoveConst<const int*>::Type is const int*; - * mozilla::RemoveConst<int* const>::Type is int*. - */ -template<typename T> -struct RemoveConst -{ - typedef T Type; -}; - -template<typename T> -struct RemoveConst<const T> -{ - typedef T Type; -}; - -/** - * RemoveVolatile removes top-level volatile qualifications on a type. - * - * mozilla::RemoveVolatile<int>::Type is int; - * mozilla::RemoveVolatile<volatile int>::Type is int; - * mozilla::RemoveVolatile<volatile int*>::Type is volatile int*; - * mozilla::RemoveVolatile<int* volatile>::Type is int*. - */ -template<typename T> -struct RemoveVolatile -{ - typedef T Type; -}; - -template<typename T> -struct RemoveVolatile<volatile T> -{ - typedef T Type; -}; - -/** - * RemoveCV removes top-level const and volatile qualifications on a type. - * - * mozilla::RemoveCV<int>::Type is int; - * mozilla::RemoveCV<const int>::Type is int; - * mozilla::RemoveCV<volatile int>::Type is int; - * mozilla::RemoveCV<int* const volatile>::Type is int*. - */ -template<typename T> -struct RemoveCV -{ - typedef typename RemoveConst<typename RemoveVolatile<T>::Type>::Type Type; -}; - -/* 20.9.7.2 Reference modifications [meta.trans.ref] */ - -/** - * Converts reference types to the underlying types. - * - * mozilla::RemoveReference<T>::Type is T; - * mozilla::RemoveReference<T&>::Type is T; - * mozilla::RemoveReference<T&&>::Type is T; - */ - -template<typename T> -struct RemoveReference -{ - typedef T Type; -}; - -template<typename T> -struct RemoveReference<T&> -{ - typedef T Type; -}; - -template<typename T> -struct RemoveReference<T&&> -{ - typedef T Type; -}; - -template<bool Condition, typename A, typename B> -struct Conditional; - -namespace detail { - -enum Voidness { TIsVoid, TIsNotVoid }; - -template<typename T, Voidness V = IsVoid<T>::value ? TIsVoid : TIsNotVoid> -struct AddLvalueReferenceHelper; - -template<typename T> -struct AddLvalueReferenceHelper<T, TIsVoid> -{ - typedef void Type; -}; - -template<typename T> -struct AddLvalueReferenceHelper<T, TIsNotVoid> -{ - typedef T& Type; -}; - -} // namespace detail - -/** - * AddLvalueReference adds an lvalue & reference to T if one isn't already - * present. (Note: adding an lvalue reference to an rvalue && reference in - * essence replaces the && with a &&, per C+11 reference collapsing rules. For - * example, int&& would become int&.) - * - * The final computed type will only *not* be an lvalue reference if T is void. - * - * mozilla::AddLvalueReference<int>::Type is int&; - * mozilla::AddLvalueRference<volatile int&>::Type is volatile int&; - * mozilla::AddLvalueReference<void*>::Type is void*&; - * mozilla::AddLvalueReference<void>::Type is void; - * mozilla::AddLvalueReference<struct S&&>::Type is struct S&. - */ -template<typename T> -struct AddLvalueReference - : detail::AddLvalueReferenceHelper<T> -{}; - -namespace detail { - -template<typename T, Voidness V = IsVoid<T>::value ? TIsVoid : TIsNotVoid> -struct AddRvalueReferenceHelper; - -template<typename T> -struct AddRvalueReferenceHelper<T, TIsVoid> -{ - typedef void Type; -}; - -template<typename T> -struct AddRvalueReferenceHelper<T, TIsNotVoid> -{ - typedef T&& Type; -}; - -} // namespace detail - -/** - * AddRvalueReference adds an rvalue && reference to T if one isn't already - * present. (Note: adding an rvalue reference to an lvalue & reference in - * essence keeps the &, per C+11 reference collapsing rules. For example, - * int& would remain int&.) - * - * The final computed type will only *not* be a reference if T is void. - * - * mozilla::AddRvalueReference<int>::Type is int&&; - * mozilla::AddRvalueRference<volatile int&>::Type is volatile int&; - * mozilla::AddRvalueRference<const int&&>::Type is const int&&; - * mozilla::AddRvalueReference<void*>::Type is void*&&; - * mozilla::AddRvalueReference<void>::Type is void; - * mozilla::AddRvalueReference<struct S&>::Type is struct S&. - */ -template<typename T> -struct AddRvalueReference - : detail::AddRvalueReferenceHelper<T> -{}; - -/* 20.9.7.3 Sign modifications [meta.trans.sign] */ - -template<bool B, typename T = void> -struct EnableIf; - -namespace detail { - -template<bool MakeConst, typename T> -struct WithC : Conditional<MakeConst, const T, T> -{}; - -template<bool MakeVolatile, typename T> -struct WithV : Conditional<MakeVolatile, volatile T, T> -{}; - - -template<bool MakeConst, bool MakeVolatile, typename T> -struct WithCV : WithC<MakeConst, typename WithV<MakeVolatile, T>::Type> -{}; - -template<typename T> -struct CorrespondingSigned; - -template<> -struct CorrespondingSigned<char> { typedef signed char Type; }; -template<> -struct CorrespondingSigned<unsigned char> { typedef signed char Type; }; -template<> -struct CorrespondingSigned<unsigned short> { typedef short Type; }; -template<> -struct CorrespondingSigned<unsigned int> { typedef int Type; }; -template<> -struct CorrespondingSigned<unsigned long> { typedef long Type; }; -template<> -struct CorrespondingSigned<unsigned long long> { typedef long long Type; }; - -template<typename T, - typename CVRemoved = typename RemoveCV<T>::Type, - bool IsSignedIntegerType = IsSigned<CVRemoved>::value && - !IsSame<char, CVRemoved>::value> -struct MakeSigned; - -template<typename T, typename CVRemoved> -struct MakeSigned<T, CVRemoved, true> -{ - typedef T Type; -}; - -template<typename T, typename CVRemoved> -struct MakeSigned<T, CVRemoved, false> - : WithCV<IsConst<T>::value, IsVolatile<T>::value, - typename CorrespondingSigned<CVRemoved>::Type> -{}; - -} // namespace detail - -/** - * MakeSigned produces the corresponding signed integer type for a given - * integral type T, with the const/volatile qualifiers of T. T must be a - * possibly-const/volatile-qualified integral type that isn't bool. - * - * If T is already a signed integer type (not including char!), then T is - * produced. - * - * Otherwise, if T is an unsigned integer type, the signed variety of T, with - * T's const/volatile qualifiers, is produced. - * - * Otherwise, the integral type of the same size as T, with the lowest rank, - * with T's const/volatile qualifiers, is produced. (This basically only acts - * to produce signed char when T = char.) - * - * mozilla::MakeSigned<unsigned long>::Type is signed long; - * mozilla::MakeSigned<volatile int>::Type is volatile int; - * mozilla::MakeSigned<const unsigned short>::Type is const signed short; - * mozilla::MakeSigned<const char>::Type is const signed char; - * mozilla::MakeSigned<bool> is an error; - * mozilla::MakeSigned<void*> is an error. - */ -template<typename T> -struct MakeSigned - : EnableIf<IsIntegral<T>::value && - !IsSame<bool, typename RemoveCV<T>::Type>::value, - typename detail::MakeSigned<T> - >::Type -{}; - -namespace detail { - -template<typename T> -struct CorrespondingUnsigned; - -template<> -struct CorrespondingUnsigned<char> { typedef unsigned char Type; }; -template<> -struct CorrespondingUnsigned<signed char> { typedef unsigned char Type; }; -template<> -struct CorrespondingUnsigned<short> { typedef unsigned short Type; }; -template<> -struct CorrespondingUnsigned<int> { typedef unsigned int Type; }; -template<> -struct CorrespondingUnsigned<long> { typedef unsigned long Type; }; -template<> -struct CorrespondingUnsigned<long long> { typedef unsigned long long Type; }; - - -template<typename T, - typename CVRemoved = typename RemoveCV<T>::Type, - bool IsUnsignedIntegerType = IsUnsigned<CVRemoved>::value && - !IsSame<char, CVRemoved>::value> -struct MakeUnsigned; - -template<typename T, typename CVRemoved> -struct MakeUnsigned<T, CVRemoved, true> -{ - typedef T Type; -}; - -template<typename T, typename CVRemoved> -struct MakeUnsigned<T, CVRemoved, false> - : WithCV<IsConst<T>::value, IsVolatile<T>::value, - typename CorrespondingUnsigned<CVRemoved>::Type> -{}; - -} // namespace detail - -/** - * MakeUnsigned produces the corresponding unsigned integer type for a given - * integral type T, with the const/volatile qualifiers of T. T must be a - * possibly-const/volatile-qualified integral type that isn't bool. - * - * If T is already an unsigned integer type (not including char!), then T is - * produced. - * - * Otherwise, if T is an signed integer type, the unsigned variety of T, with - * T's const/volatile qualifiers, is produced. - * - * Otherwise, the unsigned integral type of the same size as T, with the lowest - * rank, with T's const/volatile qualifiers, is produced. (This basically only - * acts to produce unsigned char when T = char.) - * - * mozilla::MakeUnsigned<signed long>::Type is unsigned long; - * mozilla::MakeUnsigned<volatile unsigned int>::Type is volatile unsigned int; - * mozilla::MakeUnsigned<const signed short>::Type is const unsigned short; - * mozilla::MakeUnsigned<const char>::Type is const unsigned char; - * mozilla::MakeUnsigned<bool> is an error; - * mozilla::MakeUnsigned<void*> is an error. - */ -template<typename T> -struct MakeUnsigned - : EnableIf<IsIntegral<T>::value && - !IsSame<bool, typename RemoveCV<T>::Type>::value, - typename detail::MakeUnsigned<T> - >::Type -{}; - -/* 20.9.7.4 Array modifications [meta.trans.arr] */ - -/** - * RemoveExtent produces either the type of the elements of the array T, or T - * itself. - * - * mozilla::RemoveExtent<int>::Type is int; - * mozilla::RemoveExtent<const int[]>::Type is const int; - * mozilla::RemoveExtent<volatile int[5]>::Type is volatile int; - * mozilla::RemoveExtent<long[][17]>::Type is long[17]. - */ -template<typename T> -struct RemoveExtent -{ - typedef T Type; -}; - -template<typename T> -struct RemoveExtent<T[]> -{ - typedef T Type; -}; - -template<typename T, decltype(sizeof(1)) N> -struct RemoveExtent<T[N]> -{ - typedef T Type; -}; - -/* 20.9.7.5 Pointer modifications [meta.trans.ptr] */ - -namespace detail { - -template<typename T, typename CVRemoved> -struct RemovePointerHelper -{ - typedef T Type; -}; - -template<typename T, typename Pointee> -struct RemovePointerHelper<T, Pointee*> -{ - typedef Pointee Type; -}; - -} // namespace detail - -/** - * Produces the pointed-to type if a pointer is provided, else returns the input - * type. Note that this does not dereference pointer-to-member pointers. - * - * struct S { bool m; void f(); }; - * mozilla::RemovePointer<int>::Type is int; - * mozilla::RemovePointer<int*>::Type is int; - * mozilla::RemovePointer<int* const>::Type is int; - * mozilla::RemovePointer<int* volatile>::Type is int; - * mozilla::RemovePointer<const long*>::Type is const long; - * mozilla::RemovePointer<void* const>::Type is void; - * mozilla::RemovePointer<void (S::*)()>::Type is void (S::*)(); - * mozilla::RemovePointer<void (*)()>::Type is void(); - * mozilla::RemovePointer<bool S::*>::Type is bool S::*. - */ -template<typename T> -struct RemovePointer - : detail::RemovePointerHelper<T, typename RemoveCV<T>::Type> -{}; - -/** - * Converts T& to T*. Otherwise returns T* given T. Note that C++17 wants - * std::add_pointer to work differently for function types. We don't implement - * that behavior here. - * - * mozilla::AddPointer<int> is int*; - * mozilla::AddPointer<int*> is int**; - * mozilla::AddPointer<int&> is int*; - * mozilla::AddPointer<int* const> is int** const. - */ -template<typename T> -struct AddPointer -{ - typedef typename RemoveReference<T>::Type* Type; -}; - -/* 20.9.7.6 Other transformations [meta.trans.other] */ - -/** - * EnableIf is a struct containing a typedef of T if and only if B is true. - * - * mozilla::EnableIf<true, int>::Type is int; - * mozilla::EnableIf<false, int>::Type is a compile-time error. - * - * Use this template to implement SFINAE-style (Substitution Failure Is not An - * Error) requirements. For example, you might use it to impose a restriction - * on a template parameter: - * - * template<typename T> - * class PodVector // vector optimized to store POD (memcpy-able) types - * { - * EnableIf<IsPod<T>::value, T>::Type* vector; - * size_t length; - * ... - * }; - */ -template<bool B, typename T> -struct EnableIf -{}; - -template<typename T> -struct EnableIf<true, T> -{ - typedef T Type; -}; - -/** - * Conditional selects a class between two, depending on a given boolean value. - * - * mozilla::Conditional<true, A, B>::Type is A; - * mozilla::Conditional<false, A, B>::Type is B; - */ -template<bool Condition, typename A, typename B> -struct Conditional -{ - typedef A Type; -}; - -template<class A, class B> -struct Conditional<false, A, B> -{ - typedef B Type; -}; - -namespace detail { - -template<typename U, - bool IsArray = IsArray<U>::value, - bool IsFunction = IsFunction<U>::value> -struct DecaySelector; - -template<typename U> -struct DecaySelector<U, false, false> -{ - typedef typename RemoveCV<U>::Type Type; -}; - -template<typename U> -struct DecaySelector<U, true, false> -{ - typedef typename RemoveExtent<U>::Type* Type; -}; - -template<typename U> -struct DecaySelector<U, false, true> -{ - typedef typename AddPointer<U>::Type Type; -}; - -}; // namespace detail - -/** - * Strips const/volatile off a type and decays it from an lvalue to an - * rvalue. So function types are converted to function pointers, arrays to - * pointers, and references are removed. - * - * mozilla::Decay<int>::Type is int - * mozilla::Decay<int&>::Type is int - * mozilla::Decay<int&&>::Type is int - * mozilla::Decay<const int&>::Type is int - * mozilla::Decay<int[2]>::Type is int* - * mozilla::Decay<int(int)>::Type is int(*)(int) - */ -template<typename T> -class Decay - : public detail::DecaySelector<typename RemoveReference<T>::Type> -{ -}; - -} /* namespace mozilla */ - -#endif /* mozilla_TypeTraits_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/TypedEnumBits.h b/android/armeabi/include/spidermonkey/mozilla/TypedEnumBits.h deleted file mode 100644 index 5ee6315c..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/TypedEnumBits.h +++ /dev/null @@ -1,156 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* - * MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS allows using a typed enum as bit flags. - */ - -#ifndef mozilla_TypedEnumBits_h -#define mozilla_TypedEnumBits_h - -#include "mozilla/Attributes.h" -#include "mozilla/IntegerTypeTraits.h" - -namespace mozilla { - -/* - * The problem that CastableTypedEnumResult aims to solve is that - * typed enums are not convertible to bool, and there is no way to make them - * be, yet user code wants to be able to write - * - * if (myFlags & Flags::SOME_PARTICULAR_FLAG) (1) - * - * There are different approaches to solving this. Most of them require - * adapting user code. For example, we could implement operator! and have - * the user write - * - * if (!!(myFlags & Flags::SOME_PARTICULAR_FLAG)) (2) - * - * Or we could supply a IsNonZero() or Any() function returning whether - * an enum value is nonzero, and have the user write - * - * if (Any(Flags & Flags::SOME_PARTICULAR_FLAG)) (3) - * - * But instead, we choose to preserve the original user syntax (1) as it - * is inherently more readable, and to ease porting existing code to typed - * enums. We achieve this by having operator& and other binary bitwise - * operators have as return type a class, CastableTypedEnumResult, - * that wraps a typed enum but adds bool convertibility. - */ -template<typename E> -class CastableTypedEnumResult -{ -private: - const E mValue; - -public: - explicit constexpr CastableTypedEnumResult(E aValue) - : mValue(aValue) - {} - - constexpr operator E() const { return mValue; } - - template<typename DestinationType> - explicit constexpr - operator DestinationType() const { return DestinationType(mValue); } - - constexpr bool operator !() const { return !bool(mValue); } -}; - -#define MOZ_CASTABLETYPEDENUMRESULT_BINOP(Op, OtherType, ReturnType) \ -template<typename E> \ -constexpr ReturnType \ -operator Op(const OtherType& aE, const CastableTypedEnumResult<E>& aR) \ -{ \ - return ReturnType(aE Op OtherType(aR)); \ -} \ -template<typename E> \ -constexpr ReturnType \ -operator Op(const CastableTypedEnumResult<E>& aR, const OtherType& aE) \ -{ \ - return ReturnType(OtherType(aR) Op aE); \ -} \ -template<typename E> \ -constexpr ReturnType \ -operator Op(const CastableTypedEnumResult<E>& aR1, \ - const CastableTypedEnumResult<E>& aR2) \ -{ \ - return ReturnType(OtherType(aR1) Op OtherType(aR2)); \ -} - -MOZ_CASTABLETYPEDENUMRESULT_BINOP(|, E, CastableTypedEnumResult<E>) -MOZ_CASTABLETYPEDENUMRESULT_BINOP(&, E, CastableTypedEnumResult<E>) -MOZ_CASTABLETYPEDENUMRESULT_BINOP(^, E, CastableTypedEnumResult<E>) -MOZ_CASTABLETYPEDENUMRESULT_BINOP(==, E, bool) -MOZ_CASTABLETYPEDENUMRESULT_BINOP(!=, E, bool) -MOZ_CASTABLETYPEDENUMRESULT_BINOP(||, bool, bool) -MOZ_CASTABLETYPEDENUMRESULT_BINOP(&&, bool, bool) - -template <typename E> -constexpr CastableTypedEnumResult<E> -operator ~(const CastableTypedEnumResult<E>& aR) -{ - return CastableTypedEnumResult<E>(~(E(aR))); -} - -#define MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(Op) \ -template<typename E> \ -E& \ -operator Op(E& aR1, \ - const CastableTypedEnumResult<E>& aR2) \ -{ \ - return aR1 Op E(aR2); \ -} - -MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(&=) -MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(|=) -MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP(^=) - -#undef MOZ_CASTABLETYPEDENUMRESULT_COMPOUND_ASSIGN_OP - -#undef MOZ_CASTABLETYPEDENUMRESULT_BINOP - -namespace detail { -template<typename E> -struct UnsignedIntegerTypeForEnum - : UnsignedStdintTypeForSize<sizeof(E)> -{}; -} // namespace detail - -} // namespace mozilla - -#define MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, Op) \ - inline constexpr mozilla::CastableTypedEnumResult<Name> \ - operator Op(Name a, Name b) \ - { \ - typedef mozilla::CastableTypedEnumResult<Name> Result; \ - typedef mozilla::detail::UnsignedIntegerTypeForEnum<Name>::Type U; \ - return Result(Name(U(a) Op U(b))); \ - } \ - \ - inline Name& \ - operator Op##=(Name& a, Name b) \ - { \ - return a = a Op b; \ - } - -/** - * MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS generates standard bitwise operators - * for the given enum type. Use this to enable using an enum type as bit-field. - */ -#define MOZ_MAKE_ENUM_CLASS_BITWISE_OPERATORS(Name) \ - MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, |) \ - MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, &) \ - MOZ_MAKE_ENUM_CLASS_BINOP_IMPL(Name, ^) \ - inline constexpr mozilla::CastableTypedEnumResult<Name> \ - operator~(Name a) \ - { \ - typedef mozilla::CastableTypedEnumResult<Name> Result; \ - typedef mozilla::detail::UnsignedIntegerTypeForEnum<Name>::Type U; \ - return Result(Name(~(U(a)))); \ - } - -#endif // mozilla_TypedEnumBits_h diff --git a/android/armeabi/include/spidermonkey/mozilla/Types.h b/android/armeabi/include/spidermonkey/mozilla/Types.h deleted file mode 100644 index e7e18abb..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Types.h +++ /dev/null @@ -1,134 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* mfbt foundational types and macros. */ - -#ifndef mozilla_Types_h -#define mozilla_Types_h - -/* - * This header must be valid C and C++, includable by code embedding either - * SpiderMonkey or Gecko. - */ - -/* Expose all <stdint.h> types and size_t. */ -#include <stddef.h> -#include <stdint.h> - -/* Implement compiler and linker macros needed for APIs. */ - -/* - * MOZ_EXPORT is used to declare and define a symbol or type which is externally - * visible to users of the current library. It encapsulates various decorations - * needed to properly export the method's symbol. - * - * api.h: - * extern MOZ_EXPORT int MeaningOfLife(void); - * extern MOZ_EXPORT int LuggageCombination; - * - * api.c: - * int MeaningOfLife(void) { return 42; } - * int LuggageCombination = 12345; - * - * If you are merely sharing a method across files, just use plain |extern|. - * These macros are designed for use by library interfaces -- not for normal - * methods or data used cross-file. - */ -#if defined(WIN32) -# define MOZ_EXPORT __declspec(dllexport) -#else /* Unix */ -# ifdef HAVE_VISIBILITY_ATTRIBUTE -# define MOZ_EXPORT __attribute__((visibility("default"))) -# elif defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# define MOZ_EXPORT __global -# else -# define MOZ_EXPORT /* nothing */ -# endif -#endif - - -/* - * Whereas implementers use MOZ_EXPORT to declare and define library symbols, - * users use MOZ_IMPORT_API and MOZ_IMPORT_DATA to access them. Most often the - * implementer of the library will expose an API macro which expands to either - * the export or import version of the macro, depending upon the compilation - * mode. - */ -#ifdef _WIN32 -# if defined(__MWERKS__) -# define MOZ_IMPORT_API /* nothing */ -# else -# define MOZ_IMPORT_API __declspec(dllimport) -# endif -#else -# define MOZ_IMPORT_API MOZ_EXPORT -#endif - -#if defined(_WIN32) && !defined(__MWERKS__) -# define MOZ_IMPORT_DATA __declspec(dllimport) -#else -# define MOZ_IMPORT_DATA MOZ_EXPORT -#endif - -/* - * Consistent with the above comment, the MFBT_API and MFBT_DATA macros expose - * export mfbt declarations when building mfbt, and they expose import mfbt - * declarations when using mfbt. - */ -#if defined(IMPL_MFBT) -# define MFBT_API MOZ_EXPORT -# define MFBT_DATA MOZ_EXPORT -#else - /* - * On linux mozglue is linked in the program and we link libxul.so with - * -z,defs. Normally that causes the linker to reject undefined references in - * libxul.so, but as a loophole it allows undefined references to weak - * symbols. We add the weak attribute to the import version of the MFBT API - * macros to exploit this. - */ -# if defined(MOZ_GLUE_IN_PROGRAM) -# define MFBT_API __attribute__((weak)) MOZ_IMPORT_API -# define MFBT_DATA __attribute__((weak)) MOZ_IMPORT_DATA -# else -# define MFBT_API MOZ_IMPORT_API -# define MFBT_DATA MOZ_IMPORT_DATA -# endif -#endif - -/* - * C symbols in C++ code must be declared immediately within |extern "C"| - * blocks. However, in C code, they need not be declared specially. This - * difference is abstracted behind the MOZ_BEGIN_EXTERN_C and MOZ_END_EXTERN_C - * macros, so that the user need not know whether he is being used in C or C++ - * code. - * - * MOZ_BEGIN_EXTERN_C - * - * extern MOZ_EXPORT int MostRandomNumber(void); - * ...other declarations... - * - * MOZ_END_EXTERN_C - * - * This said, it is preferable to just use |extern "C"| in C++ header files for - * its greater clarity. - */ -#ifdef __cplusplus -# define MOZ_BEGIN_EXTERN_C extern "C" { -# define MOZ_END_EXTERN_C } -#else -# define MOZ_BEGIN_EXTERN_C -# define MOZ_END_EXTERN_C -#endif - -/* - * GCC's typeof is available when decltype is not. - */ -#if defined(__GNUC__) && defined(__cplusplus) && \ - !defined(__GXX_EXPERIMENTAL_CXX0X__) && __cplusplus < 201103L -# define decltype __typeof__ -#endif - -#endif /* mozilla_Types_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/UniquePtr.h b/android/armeabi/include/spidermonkey/mozilla/UniquePtr.h deleted file mode 100644 index 7e1035bc..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/UniquePtr.h +++ /dev/null @@ -1,697 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Smart pointer managing sole ownership of a resource. */ - -#ifndef mozilla_UniquePtr_h -#define mozilla_UniquePtr_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/Compiler.h" -#include "mozilla/Move.h" -#include "mozilla/Pair.h" -#include "mozilla/TypeTraits.h" - -namespace mozilla { - -template<typename T> class DefaultDelete; -template<typename T, class D = DefaultDelete<T>> class UniquePtr; - -} // namespace mozilla - -namespace mozilla { - -namespace detail { - -struct HasPointerTypeHelper -{ - template <class U> static double Test(...); - template <class U> static char Test(typename U::pointer* = 0); -}; - -template <class T> -class HasPointerType : public IntegralConstant<bool, sizeof(HasPointerTypeHelper::Test<T>(0)) == 1> -{ -}; - -template <class T, class D, bool = HasPointerType<D>::value> -struct PointerTypeImpl -{ - typedef typename D::pointer Type; -}; - -template <class T, class D> -struct PointerTypeImpl<T, D, false> -{ - typedef T* Type; -}; - -template <class T, class D> -struct PointerType -{ - typedef typename PointerTypeImpl<T, typename RemoveReference<D>::Type>::Type Type; -}; - -} // namespace detail - -/** - * UniquePtr is a smart pointer that wholly owns a resource. Ownership may be - * transferred out of a UniquePtr through explicit action, but otherwise the - * resource is destroyed when the UniquePtr is destroyed. - * - * UniquePtr is similar to C++98's std::auto_ptr, but it improves upon auto_ptr - * in one crucial way: it's impossible to copy a UniquePtr. Copying an auto_ptr - * obviously *can't* copy ownership of its singly-owned resource. So what - * happens if you try to copy one? Bizarrely, ownership is implicitly - * *transferred*, preserving single ownership but breaking code that assumes a - * copy of an object is identical to the original. (This is why auto_ptr is - * prohibited in STL containers.) - * - * UniquePtr solves this problem by being *movable* rather than copyable. - * Instead of passing a |UniquePtr u| directly to the constructor or assignment - * operator, you pass |Move(u)|. In doing so you indicate that you're *moving* - * ownership out of |u|, into the target of the construction/assignment. After - * the transfer completes, |u| contains |nullptr| and may be safely destroyed. - * This preserves single ownership but also allows UniquePtr to be moved by - * algorithms that have been made move-safe. (Note: if |u| is instead a - * temporary expression, don't use |Move()|: just pass the expression, because - * it's already move-ready. For more information see Move.h.) - * - * UniquePtr is also better than std::auto_ptr in that the deletion operation is - * customizable. An optional second template parameter specifies a class that - * (through its operator()(T*)) implements the desired deletion policy. If no - * policy is specified, mozilla::DefaultDelete<T> is used -- which will either - * |delete| or |delete[]| the resource, depending whether the resource is an - * array. Custom deletion policies ideally should be empty classes (no member - * fields, no member fields in base classes, no virtual methods/inheritance), - * because then UniquePtr can be just as efficient as a raw pointer. - * - * Use of UniquePtr proceeds like so: - * - * UniquePtr<int> g1; // initializes to nullptr - * g1.reset(new int); // switch resources using reset() - * g1 = nullptr; // clears g1, deletes the int - * - * UniquePtr<int> g2(new int); // owns that int - * int* p = g2.release(); // g2 leaks its int -- still requires deletion - * delete p; // now freed - * - * struct S { int x; S(int x) : x(x) {} }; - * UniquePtr<S> g3, g4(new S(5)); - * g3 = Move(g4); // g3 owns the S, g4 cleared - * S* p = g3.get(); // g3 still owns |p| - * assert(g3->x == 5); // operator-> works (if .get() != nullptr) - * assert((*g3).x == 5); // also operator* (again, if not cleared) - * Swap(g3, g4); // g4 now owns the S, g3 cleared - * g3.swap(g4); // g3 now owns the S, g4 cleared - * UniquePtr<S> g5(Move(g3)); // g5 owns the S, g3 cleared - * g5.reset(); // deletes the S, g5 cleared - * - * struct FreePolicy { void operator()(void* p) { free(p); } }; - * UniquePtr<int, FreePolicy> g6(static_cast<int*>(malloc(sizeof(int)))); - * int* ptr = g6.get(); - * g6 = nullptr; // calls free(ptr) - * - * Now, carefully note a few things you *can't* do: - * - * UniquePtr<int> b1; - * b1 = new int; // BAD: can only assign another UniquePtr - * int* ptr = b1; // BAD: no auto-conversion to pointer, use get() - * - * UniquePtr<int> b2(b1); // BAD: can't copy a UniquePtr - * UniquePtr<int> b3 = b1; // BAD: can't copy-assign a UniquePtr - * - * (Note that changing a UniquePtr to store a direct |new| expression is - * permitted, but usually you should use MakeUnique, defined at the end of this - * header.) - * - * A few miscellaneous notes: - * - * UniquePtr, when not instantiated for an array type, can be move-constructed - * and move-assigned, not only from itself but from "derived" UniquePtr<U, E> - * instantiations where U converts to T and E converts to D. If you want to use - * this, you're going to have to specify a deletion policy for both UniquePtr - * instantations, and T pretty much has to have a virtual destructor. In other - * words, this doesn't work: - * - * struct Base { virtual ~Base() {} }; - * struct Derived : Base {}; - * - * UniquePtr<Base> b1; - * // BAD: DefaultDelete<Base> and DefaultDelete<Derived> don't interconvert - * UniquePtr<Derived> d1(Move(b)); - * - * UniquePtr<Base> b2; - * UniquePtr<Derived, DefaultDelete<Base>> d2(Move(b2)); // okay - * - * UniquePtr is specialized for array types. Specializing with an array type - * creates a smart-pointer version of that array -- not a pointer to such an - * array. - * - * UniquePtr<int[]> arr(new int[5]); - * arr[0] = 4; - * - * What else is different? Deletion of course uses |delete[]|. An operator[] - * is provided. Functionality that doesn't make sense for arrays is removed. - * The constructors and mutating methods only accept array pointers (not T*, U* - * that converts to T*, or UniquePtr<U[]> or UniquePtr<U>) or |nullptr|. - * - * It's perfectly okay for a function to return a UniquePtr. This transfers - * the UniquePtr's sole ownership of the data, to the fresh UniquePtr created - * in the calling function, that will then solely own that data. Such functions - * can return a local variable UniquePtr, |nullptr|, |UniquePtr(ptr)| where - * |ptr| is a |T*|, or a UniquePtr |Move()|'d from elsewhere. - * - * UniquePtr will commonly be a member of a class, with lifetime equivalent to - * that of that class. If you want to expose the related resource, you could - * expose a raw pointer via |get()|, but ownership of a raw pointer is - * inherently unclear. So it's better to expose a |const UniquePtr&| instead. - * This prohibits mutation but still allows use of |get()| when needed (but - * operator-> is preferred). Of course, you can only use this smart pointer as - * long as the enclosing class instance remains live -- no different than if you - * exposed the |get()| raw pointer. - * - * To pass a UniquePtr-managed resource as a pointer, use a |const UniquePtr&| - * argument. To specify an inout parameter (where the method may or may not - * take ownership of the resource, or reset it), or to specify an out parameter - * (where simply returning a |UniquePtr| isn't possible), use a |UniquePtr&| - * argument. To unconditionally transfer ownership of a UniquePtr - * into a method, use a |UniquePtr| argument. To conditionally transfer - * ownership of a resource into a method, should the method want it, use a - * |UniquePtr&&| argument. - */ -template<typename T, class D> -class UniquePtr -{ -public: - typedef T ElementType; - typedef D DeleterType; - typedef typename detail::PointerType<T, DeleterType>::Type Pointer; - -private: - Pair<Pointer, DeleterType> mTuple; - - Pointer& ptr() { return mTuple.first(); } - const Pointer& ptr() const { return mTuple.first(); } - - DeleterType& del() { return mTuple.second(); } - const DeleterType& del() const { return mTuple.second(); } - -public: - /** - * Construct a UniquePtr containing |nullptr|. - */ - constexpr UniquePtr() - : mTuple(static_cast<Pointer>(nullptr), DeleterType()) - { - static_assert(!IsPointer<D>::value, "must provide a deleter instance"); - static_assert(!IsReference<D>::value, "must provide a deleter instance"); - } - - /** - * Construct a UniquePtr containing |aPtr|. - */ - explicit UniquePtr(Pointer aPtr) - : mTuple(aPtr, DeleterType()) - { - static_assert(!IsPointer<D>::value, "must provide a deleter instance"); - static_assert(!IsReference<D>::value, "must provide a deleter instance"); - } - - UniquePtr(Pointer aPtr, - typename Conditional<IsReference<D>::value, - D, - const D&>::Type aD1) - : mTuple(aPtr, aD1) - {} - - // If you encounter an error with MSVC10 about RemoveReference below, along - // the lines that "more than one partial specialization matches the template - // argument list": don't use UniquePtr<T, reference to function>! Ideally - // you should make deletion use the same function every time, using a - // deleter policy: - // - // // BAD, won't compile with MSVC10, deleter doesn't need to be a - // // variable at all - // typedef void (&FreeSignature)(void*); - // UniquePtr<int, FreeSignature> ptr((int*) malloc(sizeof(int)), free); - // - // // GOOD, compiles with MSVC10, deletion behavior statically known and - // // optimizable - // struct DeleteByFreeing - // { - // void operator()(void* aPtr) { free(aPtr); } - // }; - // - // If deletion really, truly, must be a variable: you might be able to work - // around this with a deleter class that contains the function reference. - // But this workaround is untried and untested, because variable deletion - // behavior really isn't something you should use. - UniquePtr(Pointer aPtr, - typename RemoveReference<D>::Type&& aD2) - : mTuple(aPtr, Move(aD2)) - { - static_assert(!IsReference<D>::value, - "rvalue deleter can't be stored by reference"); - } - - UniquePtr(UniquePtr&& aOther) - : mTuple(aOther.release(), Forward<DeleterType>(aOther.get_deleter())) - {} - - MOZ_IMPLICIT - UniquePtr(decltype(nullptr)) - : mTuple(nullptr, DeleterType()) - { - static_assert(!IsPointer<D>::value, "must provide a deleter instance"); - static_assert(!IsReference<D>::value, "must provide a deleter instance"); - } - - template<typename U, class E> - MOZ_IMPLICIT - UniquePtr(UniquePtr<U, E>&& aOther, - typename EnableIf<IsConvertible<typename UniquePtr<U, E>::Pointer, - Pointer>::value && - !IsArray<U>::value && - (IsReference<D>::value - ? IsSame<D, E>::value - : IsConvertible<E, D>::value), - int>::Type aDummy = 0) - : mTuple(aOther.release(), Forward<E>(aOther.get_deleter())) - { - } - - ~UniquePtr() { reset(nullptr); } - - UniquePtr& operator=(UniquePtr&& aOther) - { - reset(aOther.release()); - get_deleter() = Forward<DeleterType>(aOther.get_deleter()); - return *this; - } - - template<typename U, typename E> - UniquePtr& operator=(UniquePtr<U, E>&& aOther) - { - static_assert(IsConvertible<typename UniquePtr<U, E>::Pointer, - Pointer>::value, - "incompatible UniquePtr pointees"); - static_assert(!IsArray<U>::value, - "can't assign from UniquePtr holding an array"); - - reset(aOther.release()); - get_deleter() = Forward<E>(aOther.get_deleter()); - return *this; - } - - UniquePtr& operator=(decltype(nullptr)) - { - reset(nullptr); - return *this; - } - - T& operator*() const { return *get(); } - Pointer operator->() const - { - MOZ_ASSERT(get(), "dereferencing a UniquePtr containing nullptr"); - return get(); - } - - explicit operator bool() const { return get() != nullptr; } - - Pointer get() const { return ptr(); } - - DeleterType& get_deleter() { return del(); } - const DeleterType& get_deleter() const { return del(); } - - MOZ_MUST_USE Pointer release() - { - Pointer p = ptr(); - ptr() = nullptr; - return p; - } - - void reset(Pointer aPtr = Pointer()) - { - Pointer old = ptr(); - ptr() = aPtr; - if (old != nullptr) { - get_deleter()(old); - } - } - - void swap(UniquePtr& aOther) - { - mTuple.swap(aOther.mTuple); - } - - UniquePtr(const UniquePtr& aOther) = delete; // construct using Move()! - void operator=(const UniquePtr& aOther) = delete; // assign using Move()! -}; - -// In case you didn't read the comment by the main definition (you should!): the -// UniquePtr<T[]> specialization exists to manage array pointers. It deletes -// such pointers using delete[], it will reject construction and modification -// attempts using U* or U[]. Otherwise it works like the normal UniquePtr. -template<typename T, class D> -class UniquePtr<T[], D> -{ -public: - typedef T* Pointer; - typedef T ElementType; - typedef D DeleterType; - -private: - Pair<Pointer, DeleterType> mTuple; - -public: - /** - * Construct a UniquePtr containing nullptr. - */ - constexpr UniquePtr() - : mTuple(static_cast<Pointer>(nullptr), DeleterType()) - { - static_assert(!IsPointer<D>::value, "must provide a deleter instance"); - static_assert(!IsReference<D>::value, "must provide a deleter instance"); - } - - /** - * Construct a UniquePtr containing |aPtr|. - */ - explicit UniquePtr(Pointer aPtr) - : mTuple(aPtr, DeleterType()) - { - static_assert(!IsPointer<D>::value, "must provide a deleter instance"); - static_assert(!IsReference<D>::value, "must provide a deleter instance"); - } - - // delete[] knows how to handle *only* an array of a single class type. For - // delete[] to work correctly, it must know the size of each element, the - // fields and base classes of each element requiring destruction, and so on. - // So forbid all overloads which would end up invoking delete[] on a pointer - // of the wrong type. - template<typename U> - UniquePtr(U&& aU, - typename EnableIf<IsPointer<U>::value && - IsConvertible<U, Pointer>::value, - int>::Type aDummy = 0) - = delete; - - UniquePtr(Pointer aPtr, - typename Conditional<IsReference<D>::value, - D, - const D&>::Type aD1) - : mTuple(aPtr, aD1) - {} - - // If you encounter an error with MSVC10 about RemoveReference below, along - // the lines that "more than one partial specialization matches the template - // argument list": don't use UniquePtr<T[], reference to function>! See the - // comment by this constructor in the non-T[] specialization above. - UniquePtr(Pointer aPtr, - typename RemoveReference<D>::Type&& aD2) - : mTuple(aPtr, Move(aD2)) - { - static_assert(!IsReference<D>::value, - "rvalue deleter can't be stored by reference"); - } - - // Forbidden for the same reasons as stated above. - template<typename U, typename V> - UniquePtr(U&& aU, V&& aV, - typename EnableIf<IsPointer<U>::value && - IsConvertible<U, Pointer>::value, - int>::Type aDummy = 0) - = delete; - - UniquePtr(UniquePtr&& aOther) - : mTuple(aOther.release(), Forward<DeleterType>(aOther.get_deleter())) - {} - - MOZ_IMPLICIT - UniquePtr(decltype(nullptr)) - : mTuple(nullptr, DeleterType()) - { - static_assert(!IsPointer<D>::value, "must provide a deleter instance"); - static_assert(!IsReference<D>::value, "must provide a deleter instance"); - } - - ~UniquePtr() { reset(nullptr); } - - UniquePtr& operator=(UniquePtr&& aOther) - { - reset(aOther.release()); - get_deleter() = Forward<DeleterType>(aOther.get_deleter()); - return *this; - } - - UniquePtr& operator=(decltype(nullptr)) - { - reset(); - return *this; - } - - explicit operator bool() const { return get() != nullptr; } - - T& operator[](decltype(sizeof(int)) aIndex) const { return get()[aIndex]; } - Pointer get() const { return mTuple.first(); } - - DeleterType& get_deleter() { return mTuple.second(); } - const DeleterType& get_deleter() const { return mTuple.second(); } - - MOZ_MUST_USE Pointer release() - { - Pointer p = mTuple.first(); - mTuple.first() = nullptr; - return p; - } - - void reset(Pointer aPtr = Pointer()) - { - Pointer old = mTuple.first(); - mTuple.first() = aPtr; - if (old != nullptr) { - mTuple.second()(old); - } - } - - void reset(decltype(nullptr)) - { - Pointer old = mTuple.first(); - mTuple.first() = nullptr; - if (old != nullptr) { - mTuple.second()(old); - } - } - - template<typename U> - void reset(U) = delete; - - void swap(UniquePtr& aOther) { mTuple.swap(aOther.mTuple); } - - UniquePtr(const UniquePtr& aOther) = delete; // construct using Move()! - void operator=(const UniquePtr& aOther) = delete; // assign using Move()! -}; - -/** - * A default deletion policy using plain old operator delete. - * - * Note that this type can be specialized, but authors should beware of the risk - * that the specialization may at some point cease to match (either because it - * gets moved to a different compilation unit or the signature changes). If the - * non-specialized (|delete|-based) version compiles for that type but does the - * wrong thing, bad things could happen. - * - * This is a non-issue for types which are always incomplete (i.e. opaque handle - * types), since |delete|-ing such a type will always trigger a compilation - * error. - */ -template<typename T> -class DefaultDelete -{ -public: - constexpr DefaultDelete() {} - - template<typename U> - MOZ_IMPLICIT DefaultDelete(const DefaultDelete<U>& aOther, - typename EnableIf<mozilla::IsConvertible<U*, T*>::value, - int>::Type aDummy = 0) - {} - - void operator()(T* aPtr) const - { - static_assert(sizeof(T) > 0, "T must be complete"); - delete aPtr; - } -}; - -/** A default deletion policy using operator delete[]. */ -template<typename T> -class DefaultDelete<T[]> -{ -public: - constexpr DefaultDelete() {} - - void operator()(T* aPtr) const - { - static_assert(sizeof(T) > 0, "T must be complete"); - delete[] aPtr; - } - - template<typename U> - void operator()(U* aPtr) const = delete; -}; - -template<typename T, class D> -void -Swap(UniquePtr<T, D>& aX, UniquePtr<T, D>& aY) -{ - aX.swap(aY); -} - -template<typename T, class D, typename U, class E> -bool -operator==(const UniquePtr<T, D>& aX, const UniquePtr<U, E>& aY) -{ - return aX.get() == aY.get(); -} - -template<typename T, class D, typename U, class E> -bool -operator!=(const UniquePtr<T, D>& aX, const UniquePtr<U, E>& aY) -{ - return aX.get() != aY.get(); -} - -template<typename T, class D> -bool -operator==(const UniquePtr<T, D>& aX, decltype(nullptr)) -{ - return !aX; -} - -template<typename T, class D> -bool -operator==(decltype(nullptr), const UniquePtr<T, D>& aX) -{ - return !aX; -} - -template<typename T, class D> -bool -operator!=(const UniquePtr<T, D>& aX, decltype(nullptr)) -{ - return bool(aX); -} - -template<typename T, class D> -bool -operator!=(decltype(nullptr), const UniquePtr<T, D>& aX) -{ - return bool(aX); -} - -// No operator<, operator>, operator<=, operator>= for now because simplicity. - -namespace detail { - -template<typename T> -struct UniqueSelector -{ - typedef UniquePtr<T> SingleObject; -}; - -template<typename T> -struct UniqueSelector<T[]> -{ - typedef UniquePtr<T[]> UnknownBound; -}; - -template<typename T, decltype(sizeof(int)) N> -struct UniqueSelector<T[N]> -{ - typedef UniquePtr<T[N]> KnownBound; -}; - -} // namespace detail - -/** - * MakeUnique is a helper function for allocating new'd objects and arrays, - * returning a UniquePtr containing the resulting pointer. The semantics of - * MakeUnique<Type>(...) are as follows. - * - * If Type is an array T[n]: - * Disallowed, deleted, no overload for you! - * If Type is an array T[]: - * MakeUnique<T[]>(size_t) is the only valid overload. The pointer returned - * is as if by |new T[n]()|, which value-initializes each element. (If T - * isn't a class type, this will zero each element. If T is a class type, - * then roughly speaking, each element will be constructed using its default - * constructor. See C++11 [dcl.init]p7 for the full gory details.) - * If Type is non-array T: - * The arguments passed to MakeUnique<T>(...) are forwarded into a - * |new T(...)| call, initializing the T as would happen if executing - * |T(...)|. - * - * There are various benefits to using MakeUnique instead of |new| expressions. - * - * First, MakeUnique eliminates use of |new| from code entirely. If objects are - * only created through UniquePtr, then (assuming all explicit release() calls - * are safe, including transitively, and no type-safety casting funniness) - * correctly maintained ownership of the UniquePtr guarantees no leaks are - * possible. (This pays off best if a class is only ever created through a - * factory method on the class, using a private constructor.) - * - * Second, initializing a UniquePtr using a |new| expression requires repeating - * the name of the new'd type, whereas MakeUnique in concert with the |auto| - * keyword names it only once: - * - * UniquePtr<char> ptr1(new char()); // repetitive - * auto ptr2 = MakeUnique<char>(); // shorter - * - * Of course this assumes the reader understands the operation MakeUnique - * performs. In the long run this is probably a reasonable assumption. In the - * short run you'll have to use your judgment about what readers can be expected - * to know, or to quickly look up. - * - * Third, a call to MakeUnique can be assigned directly to a UniquePtr. In - * contrast you can't assign a pointer into a UniquePtr without using the - * cumbersome reset(). - * - * UniquePtr<char> p; - * p = new char; // ERROR - * p.reset(new char); // works, but fugly - * p = MakeUnique<char>(); // preferred - * - * (And third, although not relevant to Mozilla: MakeUnique is exception-safe. - * An exception thrown after |new T| succeeds will leak that memory, unless the - * pointer is assigned to an object that will manage its ownership. UniquePtr - * ably serves this function.) - */ - -template<typename T, typename... Args> -typename detail::UniqueSelector<T>::SingleObject -MakeUnique(Args&&... aArgs) -{ - return UniquePtr<T>(new T(Forward<Args>(aArgs)...)); -} - -template<typename T> -typename detail::UniqueSelector<T>::UnknownBound -MakeUnique(decltype(sizeof(int)) aN) -{ - typedef typename RemoveExtent<T>::Type ArrayType; - return UniquePtr<T>(new ArrayType[aN]()); -} - -template<typename T, typename... Args> -typename detail::UniqueSelector<T>::KnownBound -MakeUnique(Args&&... aArgs) = delete; - -} // namespace mozilla - -#endif /* mozilla_UniquePtr_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/UniquePtrExtensions.h b/android/armeabi/include/spidermonkey/mozilla/UniquePtrExtensions.h deleted file mode 100644 index d94f33ee..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/UniquePtrExtensions.h +++ /dev/null @@ -1,57 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Useful extensions to UniquePtr. */ - -#ifndef mozilla_UniquePtrExtensions_h -#define mozilla_UniquePtrExtensions_h - -#include "mozilla/fallible.h" -#include "mozilla/UniquePtr.h" - -namespace mozilla { - -/** - * MakeUniqueFallible works exactly like MakeUnique, except that the memory - * allocation performed is done fallibly, i.e. it can return nullptr. - */ -template<typename T, typename... Args> -typename detail::UniqueSelector<T>::SingleObject -MakeUniqueFallible(Args&&... aArgs) -{ - return UniquePtr<T>(new (fallible) T(Forward<Args>(aArgs)...)); -} - -template<typename T> -typename detail::UniqueSelector<T>::UnknownBound -MakeUniqueFallible(decltype(sizeof(int)) aN) -{ - typedef typename RemoveExtent<T>::Type ArrayType; - return UniquePtr<T>(new (fallible) ArrayType[aN]()); -} - -template<typename T, typename... Args> -typename detail::UniqueSelector<T>::KnownBound -MakeUniqueFallible(Args&&... aArgs) = delete; - -namespace detail { - -template<typename T> -struct FreePolicy -{ - void operator()(const void* ptr) { - free(const_cast<void*>(ptr)); - } -}; - -} // namespace detail - -template<typename T> -using UniqueFreePtr = UniquePtr<T, detail::FreePolicy<T>>; - -} // namespace mozilla - -#endif // mozilla_UniquePtrExtensions_h diff --git a/android/armeabi/include/spidermonkey/mozilla/Unused.h b/android/armeabi/include/spidermonkey/mozilla/Unused.h deleted file mode 100644 index e693e32a..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Unused.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_unused_h -#define mozilla_unused_h - -#include "mozilla/Types.h" - -#ifdef __cplusplus - -namespace mozilla { - -// -// Suppress GCC warnings about unused return values with -// Unused << SomeFuncDeclaredWarnUnusedReturnValue(); -// -struct unused_t -{ - template<typename T> - inline void - operator<<(const T& /*unused*/) const {} -}; - -extern MFBT_DATA const unused_t Unused; - -} // namespace mozilla - -#endif // __cplusplus - -// An alternative to mozilla::Unused for use in (a) C code and (b) code where -// linking with unused.o is difficult. -#define MOZ_UNUSED(expr) \ - do { if (expr) { (void)0; } } while (0) - -#endif // mozilla_unused_h diff --git a/android/armeabi/include/spidermonkey/mozilla/Variant.h b/android/armeabi/include/spidermonkey/mozilla/Variant.h deleted file mode 100644 index 8a33286e..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Variant.h +++ /dev/null @@ -1,625 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A template class for tagged unions. */ - -#include <new> -#include <stdint.h> - -#include "mozilla/Alignment.h" -#include "mozilla/Assertions.h" -#include "mozilla/Move.h" -#include "mozilla/TypeTraits.h" - -#ifndef mozilla_Variant_h -#define mozilla_Variant_h - -namespace mozilla { - -template<typename... Ts> -class Variant; - -namespace detail { - -// MaxSizeOf computes the maximum sizeof(T) for each T in Ts. - -template<typename T, typename... Ts> -struct MaxSizeOf -{ - static const size_t size = sizeof(T) > MaxSizeOf<Ts...>::size - ? sizeof(T) - : MaxSizeOf<Ts...>::size; -}; - -template<typename T> -struct MaxSizeOf<T> -{ - static const size_t size = sizeof(T); -}; - -// The `IsVariant` helper is used in conjunction with static_assert and -// `mozilla::EnableIf` to catch passing non-variant types to `Variant::is<T>()` -// and friends at compile time, rather than at runtime. It ensures that the -// given type `Needle` is one of the types in the set of types `Haystack`. - -template<typename Needle, typename... Haystack> -struct IsVariant; - -template<typename Needle> -struct IsVariant<Needle> -{ - static const bool value = false; -}; - -template<typename Needle, typename... Haystack> -struct IsVariant<Needle, Needle, Haystack...> -{ - static const bool value = true; -}; - -template<typename Needle, typename T, typename... Haystack> -struct IsVariant<Needle, T, Haystack...> : public IsVariant<Needle, Haystack...> { }; - -/// SelectVariantTypeHelper is used in the implementation of SelectVariantType. -template<typename T, typename... Variants> -struct SelectVariantTypeHelper; - -template<typename T> -struct SelectVariantTypeHelper<T> -{ }; - -template<typename T, typename... Variants> -struct SelectVariantTypeHelper<T, T, Variants...> -{ - typedef T Type; -}; - -template<typename T, typename... Variants> -struct SelectVariantTypeHelper<T, const T, Variants...> -{ - typedef const T Type; -}; - -template<typename T, typename... Variants> -struct SelectVariantTypeHelper<T, const T&, Variants...> -{ - typedef const T& Type; -}; - -template<typename T, typename... Variants> -struct SelectVariantTypeHelper<T, T&&, Variants...> -{ - typedef T&& Type; -}; - -template<typename T, typename Head, typename... Variants> -struct SelectVariantTypeHelper<T, Head, Variants...> - : public SelectVariantTypeHelper<T, Variants...> -{ }; - -/** - * SelectVariantType takes a type T and a list of variant types Variants and - * yields a type Type, selected from Variants, that can store a value of type T - * or a reference to type T. If no such type was found, Type is not defined. - */ -template <typename T, typename... Variants> -struct SelectVariantType - : public SelectVariantTypeHelper<typename RemoveConst<typename RemoveReference<T>::Type>::Type, - Variants...> -{ }; - -// Compute a fast, compact type that can be used to hold integral values that -// distinctly map to every type in Ts. -template<typename... Ts> -struct VariantTag -{ -private: - static const size_t TypeCount = sizeof...(Ts); - -public: - using Type = - typename Conditional<TypeCount < 3, - bool, - typename Conditional<TypeCount < (1 << 8), - uint_fast8_t, - size_t // stop caring past a certain point :-) - >::Type - >::Type; -}; - -// TagHelper gets the given sentinel tag value for the given type T. This has to -// be split out from VariantImplementation because you can't nest a partial -// template specialization within a template class. - -template<typename Tag, size_t N, typename T, typename U, typename Next, bool isMatch> -struct TagHelper; - -// In the case where T != U, we continue recursion. -template<typename Tag, size_t N, typename T, typename U, typename Next> -struct TagHelper<Tag, N, T, U, Next, false> -{ - static Tag tag() { return Next::template tag<U>(); } -}; - -// In the case where T == U, return the tag number. -template<typename Tag, size_t N, typename T, typename U, typename Next> -struct TagHelper<Tag, N, T, U, Next, true> -{ - static Tag tag() { return Tag(N); } -}; - -// The VariantImplementation template provides the guts of mozilla::Variant. We -// create a VariantImplementation for each T in Ts... which handles -// construction, destruction, etc for when the Variant's type is T. If the -// Variant's type isn't T, it punts the request on to the next -// VariantImplementation. - -template<typename Tag, size_t N, typename... Ts> -struct VariantImplementation; - -// The singly typed Variant / recursion base case. -template<typename Tag, size_t N, typename T> -struct VariantImplementation<Tag, N, T> -{ - template<typename U> - static Tag tag() { - static_assert(mozilla::IsSame<T, U>::value, - "mozilla::Variant: tag: bad type!"); - return Tag(N); - } - - template<typename Variant> - static void copyConstruct(void* aLhs, const Variant& aRhs) { - new (aLhs) T(aRhs.template as<T>()); - } - - template<typename Variant> - static void moveConstruct(void* aLhs, Variant&& aRhs) { - new (aLhs) T(aRhs.template extract<T>()); - } - - template<typename Variant> - static void destroy(Variant& aV) { - aV.template as<T>().~T(); - } - - template<typename Variant> - static bool - equal(const Variant& aLhs, const Variant& aRhs) { - return aLhs.template as<T>() == aRhs.template as<T>(); - } - - template<typename Matcher, typename ConcreteVariant> - static auto - match(Matcher&& aMatcher, ConcreteVariant& aV) - -> decltype(aMatcher.match(aV.template as<T>())) - { - return aMatcher.match(aV.template as<T>()); - } -}; - -// VariantImplementation for some variant type T. -template<typename Tag, size_t N, typename T, typename... Ts> -struct VariantImplementation<Tag, N, T, Ts...> -{ - // The next recursive VariantImplementation. - using Next = VariantImplementation<Tag, N + 1, Ts...>; - - template<typename U> - static Tag tag() { - return TagHelper<Tag, N, T, U, Next, IsSame<T, U>::value>::tag(); - } - - template<typename Variant> - static void copyConstruct(void* aLhs, const Variant& aRhs) { - if (aRhs.template is<T>()) { - new (aLhs) T(aRhs.template as<T>()); - } else { - Next::copyConstruct(aLhs, aRhs); - } - } - - template<typename Variant> - static void moveConstruct(void* aLhs, Variant&& aRhs) { - if (aRhs.template is<T>()) { - new (aLhs) T(aRhs.template extract<T>()); - } else { - Next::moveConstruct(aLhs, aRhs); - } - } - - template<typename Variant> - static void destroy(Variant& aV) { - if (aV.template is<T>()) { - aV.template as<T>().~T(); - } else { - Next::destroy(aV); - } - } - - template<typename Variant> - static bool equal(const Variant& aLhs, const Variant& aRhs) { - if (aLhs.template is<T>()) { - MOZ_ASSERT(aRhs.template is<T>()); - return aLhs.template as<T>() == aRhs.template as<T>(); - } else { - return Next::equal(aLhs, aRhs); - } - } - - template<typename Matcher, typename ConcreteVariant> - static auto - match(Matcher&& aMatcher, ConcreteVariant& aV) - -> decltype(aMatcher.match(aV.template as<T>())) - { - if (aV.template is<T>()) { - return aMatcher.match(aV.template as<T>()); - } else { - // If you're seeing compilation errors here like "no matching - // function for call to 'match'" then that means that the - // Matcher doesn't exhaust all variant types. There must exist a - // Matcher::match(T&) for every variant type T. - // - // If you're seeing compilation errors here like "cannot - // initialize return object of type <...> with an rvalue of type - // <...>" then that means that the Matcher::match(T&) overloads - // are returning different types. They must all return the same - // Matcher::ReturnType type. - return Next::match(aMatcher, aV); - } - } -}; - -/** - * AsVariantTemporary stores a value of type T to allow construction of a - * Variant value via type inference. Because T is copied and there's no - * guarantee that the copy can be elided, AsVariantTemporary is best used with - * primitive or very small types. - */ -template <typename T> -struct AsVariantTemporary -{ - explicit AsVariantTemporary(const T& aValue) - : mValue(aValue) - {} - - template<typename U> - explicit AsVariantTemporary(U&& aValue) - : mValue(Forward<U>(aValue)) - {} - - AsVariantTemporary(const AsVariantTemporary& aOther) - : mValue(aOther.mValue) - {} - - AsVariantTemporary(AsVariantTemporary&& aOther) - : mValue(Move(aOther.mValue)) - {} - - AsVariantTemporary() = delete; - void operator=(const AsVariantTemporary&) = delete; - void operator=(AsVariantTemporary&&) = delete; - - typename RemoveConst<typename RemoveReference<T>::Type>::Type mValue; -}; - -} // namespace detail - -/** - * # mozilla::Variant - * - * A variant / tagged union / heterogenous disjoint union / sum-type template - * class. Similar in concept to (but not derived from) `boost::variant`. - * - * Sometimes, you may wish to use a C union with non-POD types. However, this is - * forbidden in C++ because it is not clear which type in the union should have - * its constructor and destructor run on creation and deletion - * respectively. This is the problem that `mozilla::Variant` solves. - * - * ## Usage - * - * A `mozilla::Variant` instance is constructed (via move or copy) from one of - * its variant types (ignoring const and references). It does *not* support - * construction from subclasses of variant types or types that coerce to one of - * the variant types. - * - * Variant<char, uint32_t> v1('a'); - * Variant<UniquePtr<A>, B, C> v2(MakeUnique<A>()); - * - * Because specifying the full type of a Variant value is often verbose, - * AsVariant() can be used to construct a Variant value using type inference in - * contexts such as expressions or when returning values from functions. Because - * AsVariant() must copy or move the value into a temporary and this cannot - * necessarily be elided by the compiler, it's mostly appropriate only for use - * with primitive or very small types. - * - * - * Variant<char, uint32_t> Foo() { return AsVariant('x'); } - * // ... - * Variant<char, uint32_t> v1 = Foo(); // v1 holds char('x'). - * - * All access to the contained value goes through type-safe accessors. - * - * void - * Foo(Variant<A, B, C> v) - * { - * if (v.is<A>()) { - * A& ref = v.as<A>(); - * ... - * } else { - * ... - * } - * } - * - * Attempting to use the contained value as type `T1` when the `Variant` - * instance contains a value of type `T2` causes an assertion failure. - * - * A a; - * Variant<A, B, C> v(a); - * v.as<B>(); // <--- Assertion failure! - * - * Trying to use a `Variant<Ts...>` instance as some type `U` that is not a - * member of the set of `Ts...` is a compiler error. - * - * A a; - * Variant<A, B, C> v(a); - * v.as<SomeRandomType>(); // <--- Compiler error! - * - * Additionally, you can turn a `Variant` that `is<T>` into a `T` by moving it - * out of the containing `Variant` instance with the `extract<T>` method: - * - * Variant<UniquePtr<A>, B, C> v(MakeUnique<A>()); - * auto ptr = v.extract<UniquePtr<A>>(); - * - * Finally, you can exhaustively match on the contained variant and branch into - * different code paths depending which type is contained. This is preferred to - * manually checking every variant type T with is<T>() because it provides - * compile-time checking that you handled every type, rather than runtime - * assertion failures. - * - * // Bad! - * char* foo(Variant<A, B, C, D>& v) { - * if (v.is<A>()) { - * return ...; - * } else if (v.is<B>()) { - * return ...; - * } else { - * return doSomething(v.as<C>()); // Forgot about case D! - * } - * } - * - * // Good! - * struct FooMatcher - * { - * // The return type of all matchers must be identical. - * char* match(A& a) { ... } - * char* match(B& b) { ... } - * char* match(C& c) { ... } - * char* match(D& d) { ... } // Compile-time error to forget D! - * } - * char* foo(Variant<A, B, C, D>& v) { - * return v.match(FooMatcher()); - * } - * - * ## Examples - * - * A tree is either an empty leaf, or a node with a value and two children: - * - * struct Leaf { }; - * - * template<typename T> - * struct Node - * { - * T value; - * Tree<T>* left; - * Tree<T>* right; - * }; - * - * template<typename T> - * using Tree = Variant<Leaf, Node<T>>; - * - * A copy-on-write string is either a non-owning reference to some existing - * string, or an owning reference to our copy: - * - * class CopyOnWriteString - * { - * Variant<const char*, UniquePtr<char[]>> string; - * - * ... - * }; - */ -template<typename... Ts> -class MOZ_INHERIT_TYPE_ANNOTATIONS_FROM_TEMPLATE_ARGS Variant -{ - using Tag = typename detail::VariantTag<Ts...>::Type; - using Impl = detail::VariantImplementation<Tag, 0, Ts...>; - using RawData = AlignedStorage<detail::MaxSizeOf<Ts...>::size>; - - // Raw storage for the contained variant value. - RawData raw; - - // Each type is given a unique tag value that lets us keep track of the - // contained variant value's type. - Tag tag; - - void* ptr() { - return reinterpret_cast<void*>(&raw); - } - -public: - /** Perfect forwarding construction for some variant type T. */ - template<typename RefT, - // RefT captures both const& as well as && (as intended, to support - // perfect forwarding), so we have to remove those qualifiers here - // when ensuring that T is a variant of this type, and getting T's - // tag, etc. - typename T = typename detail::SelectVariantType<RefT, Ts...>::Type> - explicit Variant(RefT&& aT) - : tag(Impl::template tag<T>()) - { - new (ptr()) T(Forward<RefT>(aT)); - } - - /** - * Constructs this Variant from an AsVariantTemporary<T> such that T can be - * stored in one of the types allowable in this Variant. This is used in the - * implementation of AsVariant(). - */ - template<typename RefT, - typename T = typename detail::SelectVariantType<RefT, Ts...>::Type> - MOZ_IMPLICIT Variant(detail::AsVariantTemporary<RefT>&& aValue) - : tag(Impl::template tag<T>()) - { - new (ptr()) T(Move(aValue.mValue)); - } - - /** Copy construction. */ - Variant(const Variant& aRhs) - : tag(aRhs.tag) - { - Impl::copyConstruct(ptr(), aRhs); - } - - /** Move construction. */ - Variant(Variant&& aRhs) - : tag(aRhs.tag) - { - Impl::moveConstruct(ptr(), Move(aRhs)); - } - - /** Copy assignment. */ - Variant& operator=(const Variant& aRhs) { - MOZ_ASSERT(&aRhs != this, "self-assign disallowed"); - this->~Variant(); - new (this) Variant(aRhs); - return *this; - } - - /** Move assignment. */ - Variant& operator=(Variant&& aRhs) { - MOZ_ASSERT(&aRhs != this, "self-assign disallowed"); - this->~Variant(); - new (this) Variant(Move(aRhs)); - return *this; - } - - /** Move assignment from AsVariant(). */ - template <typename T> - Variant& operator=(detail::AsVariantTemporary<T>&& aValue) - { - this->~Variant(); - new (this) Variant(Move(aValue)); - return *this; - } - - ~Variant() - { - Impl::destroy(*this); - } - - /** Check which variant type is currently contained. */ - template<typename T> - bool is() const { - static_assert(detail::IsVariant<T, Ts...>::value, - "provided a type not found in this Variant's type list"); - return Impl::template tag<T>() == tag; - } - - /** - * Operator == overload that defers to the variant type's operator== - * implementation if the rhs is tagged as the same type as this one. - */ - bool operator==(const Variant& aRhs) const { - return tag == aRhs.tag && Impl::equal(*this, aRhs); - } - - /** - * Operator != overload that defers to the negation of the variant type's - * operator== implementation if the rhs is tagged as the same type as this - * one. - */ - bool operator!=(const Variant& aRhs) const { - return !(*this == aRhs); - } - - // Accessors for working with the contained variant value. - - /** Mutable reference. */ - template<typename T> - T& as() { - static_assert(detail::IsVariant<T, Ts...>::value, - "provided a type not found in this Variant's type list"); - MOZ_ASSERT(is<T>()); - return *reinterpret_cast<T*>(&raw); - } - - /** Immutable const reference. */ - template<typename T> - const T& as() const { - static_assert(detail::IsVariant<T, Ts...>::value, - "provided a type not found in this Variant's type list"); - MOZ_ASSERT(is<T>()); - return *reinterpret_cast<const T*>(&raw); - } - - /** - * Extract the contained variant value from this container into a temporary - * value. On completion, the value in the variant will be in a - * safely-destructible state, as determined by the behavior of T's move - * constructor when provided the variant's internal value. - */ - template<typename T> - T extract() { - static_assert(detail::IsVariant<T, Ts...>::value, - "provided a type not found in this Variant's type list"); - MOZ_ASSERT(is<T>()); - return T(Move(as<T>())); - } - - // Exhaustive matching of all variant types on the contained value. - - /** Match on an immutable const reference. */ - template<typename Matcher> - auto - match(Matcher&& aMatcher) const - -> decltype(Impl::match(aMatcher, *this)) - { - return Impl::match(aMatcher, *this); - } - - /** Match on a mutable non-const reference. */ - template<typename Matcher> - auto - match(Matcher&& aMatcher) - -> decltype(Impl::match(aMatcher, *this)) - { - return Impl::match(aMatcher, *this); - } -}; - -/* - * AsVariant() is used to construct a Variant<T,...> value containing the - * provided T value using type inference. It can be used to construct Variant - * values in expressions or return them from functions without specifying the - * entire Variant type. - * - * Because AsVariant() must copy or move the value into a temporary and this - * cannot necessarily be elided by the compiler, it's mostly appropriate only - * for use with primitive or very small types. - * - * AsVariant() returns a AsVariantTemporary value which is implicitly - * convertible to any Variant that can hold a value of type T. - */ -template<typename T> -detail::AsVariantTemporary<T> -AsVariant(T&& aValue) -{ - return detail::AsVariantTemporary<T>(Forward<T>(aValue)); -} - -} // namespace mozilla - -#endif /* mozilla_Variant_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/Vector.h b/android/armeabi/include/spidermonkey/mozilla/Vector.h deleted file mode 100644 index fc43afcf..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/Vector.h +++ /dev/null @@ -1,1491 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* A type/length-parametrized vector class. */ - -#ifndef mozilla_Vector_h -#define mozilla_Vector_h - -#include "mozilla/Alignment.h" -#include "mozilla/AllocPolicy.h" -#include "mozilla/ArrayUtils.h" // for PointerRangeSize -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/MathAlgorithms.h" -#include "mozilla/MemoryReporting.h" -#include "mozilla/Move.h" -#include "mozilla/OperatorNewExtensions.h" -#include "mozilla/ReentrancyGuard.h" -#include "mozilla/TemplateLib.h" -#include "mozilla/TypeTraits.h" - -#include <new> // for placement new - -/* Silence dire "bugs in previous versions of MSVC have been fixed" warnings */ -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4345) -#endif - -namespace mozilla { - -template<typename T, size_t N, class AllocPolicy> -class Vector; - -namespace detail { - -/* - * Check that the given capacity wastes the minimal amount of space if - * allocated on the heap. This means that aCapacity*sizeof(T) is as close to a - * power-of-two as possible. growStorageBy() is responsible for ensuring this. - */ -template<typename T> -static bool CapacityHasExcessSpace(size_t aCapacity) -{ - size_t size = aCapacity * sizeof(T); - return RoundUpPow2(size) - size >= sizeof(T); -} - -/* - * This template class provides a default implementation for vector operations - * when the element type is not known to be a POD, as judged by IsPod. - */ -template<typename T, size_t N, class AP, bool IsPod> -struct VectorImpl -{ - /* - * Constructs an object in the uninitialized memory at *aDst with aArgs. - */ - template<typename... Args> - MOZ_NONNULL(1) - static inline void new_(T* aDst, Args&&... aArgs) - { - new(KnownNotNull, aDst) T(Forward<Args>(aArgs)...); - } - - /* Destroys constructed objects in the range [aBegin, aEnd). */ - static inline void destroy(T* aBegin, T* aEnd) - { - MOZ_ASSERT(aBegin <= aEnd); - for (T* p = aBegin; p < aEnd; ++p) { - p->~T(); - } - } - - /* Constructs objects in the uninitialized range [aBegin, aEnd). */ - static inline void initialize(T* aBegin, T* aEnd) - { - MOZ_ASSERT(aBegin <= aEnd); - for (T* p = aBegin; p < aEnd; ++p) { - new_(p); - } - } - - /* - * Copy-constructs objects in the uninitialized range - * [aDst, aDst+(aSrcEnd-aSrcStart)) from the range [aSrcStart, aSrcEnd). - */ - template<typename U> - static inline void copyConstruct(T* aDst, - const U* aSrcStart, const U* aSrcEnd) - { - MOZ_ASSERT(aSrcStart <= aSrcEnd); - for (const U* p = aSrcStart; p < aSrcEnd; ++p, ++aDst) { - new_(aDst, *p); - } - } - - /* - * Move-constructs objects in the uninitialized range - * [aDst, aDst+(aSrcEnd-aSrcStart)) from the range [aSrcStart, aSrcEnd). - */ - template<typename U> - static inline void moveConstruct(T* aDst, U* aSrcStart, U* aSrcEnd) - { - MOZ_ASSERT(aSrcStart <= aSrcEnd); - for (U* p = aSrcStart; p < aSrcEnd; ++p, ++aDst) { - new_(aDst, Move(*p)); - } - } - - /* - * Copy-constructs objects in the uninitialized range [aDst, aDst+aN) from - * the same object aU. - */ - template<typename U> - static inline void copyConstructN(T* aDst, size_t aN, const U& aU) - { - for (T* end = aDst + aN; aDst < end; ++aDst) { - new_(aDst, aU); - } - } - - /* - * Grows the given buffer to have capacity aNewCap, preserving the objects - * constructed in the range [begin, end) and updating aV. Assumes that (1) - * aNewCap has not overflowed, and (2) multiplying aNewCap by sizeof(T) will - * not overflow. - */ - static inline MOZ_MUST_USE bool - growTo(Vector<T, N, AP>& aV, size_t aNewCap) - { - MOZ_ASSERT(!aV.usingInlineStorage()); - MOZ_ASSERT(!CapacityHasExcessSpace<T>(aNewCap)); - T* newbuf = aV.template pod_malloc<T>(aNewCap); - if (MOZ_UNLIKELY(!newbuf)) { - return false; - } - T* dst = newbuf; - T* src = aV.beginNoCheck(); - for (; src < aV.endNoCheck(); ++dst, ++src) { - new_(dst, Move(*src)); - } - VectorImpl::destroy(aV.beginNoCheck(), aV.endNoCheck()); - aV.free_(aV.mBegin); - aV.mBegin = newbuf; - /* aV.mLength is unchanged. */ - aV.mCapacity = aNewCap; - return true; - } -}; - -/* - * This partial template specialization provides a default implementation for - * vector operations when the element type is known to be a POD, as judged by - * IsPod. - */ -template<typename T, size_t N, class AP> -struct VectorImpl<T, N, AP, true> -{ - template<typename... Args> - MOZ_NONNULL(1) - static inline void new_(T* aDst, Args&&... aArgs) - { - // Explicitly construct a local object instead of using a temporary since - // T(args...) will be treated like a C-style cast in the unary case and - // allow unsafe conversions. Both forms should be equivalent to an - // optimizing compiler. - T temp(Forward<Args>(aArgs)...); - *aDst = temp; - } - - static inline void destroy(T*, T*) {} - - static inline void initialize(T* aBegin, T* aEnd) - { - /* - * You would think that memset would be a big win (or even break even) - * when we know T is a POD. But currently it's not. This is probably - * because |append| tends to be given small ranges and memset requires - * a function call that doesn't get inlined. - * - * memset(aBegin, 0, sizeof(T) * (aEnd - aBegin)); - */ - MOZ_ASSERT(aBegin <= aEnd); - for (T* p = aBegin; p < aEnd; ++p) { - new_(p); - } - } - - template<typename U> - static inline void copyConstruct(T* aDst, - const U* aSrcStart, const U* aSrcEnd) - { - /* - * See above memset comment. Also, notice that copyConstruct is - * currently templated (T != U), so memcpy won't work without - * requiring T == U. - * - * memcpy(aDst, aSrcStart, sizeof(T) * (aSrcEnd - aSrcStart)); - */ - MOZ_ASSERT(aSrcStart <= aSrcEnd); - for (const U* p = aSrcStart; p < aSrcEnd; ++p, ++aDst) { - new_(aDst, *p); - } - } - - template<typename U> - static inline void moveConstruct(T* aDst, - const U* aSrcStart, const U* aSrcEnd) - { - copyConstruct(aDst, aSrcStart, aSrcEnd); - } - - static inline void copyConstructN(T* aDst, size_t aN, const T& aT) - { - for (T* end = aDst + aN; aDst < end; ++aDst) { - new_(aDst, aT); - } - } - - static inline MOZ_MUST_USE bool - growTo(Vector<T, N, AP>& aV, size_t aNewCap) - { - MOZ_ASSERT(!aV.usingInlineStorage()); - MOZ_ASSERT(!CapacityHasExcessSpace<T>(aNewCap)); - T* newbuf = aV.template pod_realloc<T>(aV.mBegin, aV.mCapacity, aNewCap); - if (MOZ_UNLIKELY(!newbuf)) { - return false; - } - aV.mBegin = newbuf; - /* aV.mLength is unchanged. */ - aV.mCapacity = aNewCap; - return true; - } - - static inline void - podResizeToFit(Vector<T, N, AP>& aV) - { - if (aV.usingInlineStorage() || aV.mLength == aV.mCapacity) { - return; - } - T* newbuf = aV.template pod_realloc<T>(aV.mBegin, aV.mCapacity, aV.mLength); - if (MOZ_UNLIKELY(!newbuf)) { - return; - } - aV.mBegin = newbuf; - aV.mCapacity = aV.mLength; - } -}; - -// A struct for TestVector.cpp to access private internal fields. -// DO NOT DEFINE IN YOUR OWN CODE. -struct VectorTesting; - -} // namespace detail - -/* - * STL-like container providing a short-lived, dynamic buffer. Vector calls the - * constructors/destructors of all elements stored in its internal buffer, so - * non-PODs may be safely used. Additionally, Vector will store the first N - * elements in-place before resorting to dynamic allocation. - * - * T requirements: - * - default and copy constructible, assignable, destructible - * - operations do not throw - * MinInlineCapacity requirements: - * - any value, however, MinInlineCapacity is clamped to min/max values - * AllocPolicy: - * - see "Allocation policies" in AllocPolicy.h (defaults to - * mozilla::MallocAllocPolicy) - * - * Vector is not reentrant: T member functions called during Vector member - * functions must not call back into the same object! - */ -template<typename T, - size_t MinInlineCapacity = 0, - class AllocPolicy = MallocAllocPolicy> -class Vector final : private AllocPolicy -{ - /* utilities */ - - static const bool kElemIsPod = IsPod<T>::value; - typedef detail::VectorImpl<T, MinInlineCapacity, AllocPolicy, kElemIsPod> Impl; - friend struct detail::VectorImpl<T, MinInlineCapacity, AllocPolicy, kElemIsPod>; - - friend struct detail::VectorTesting; - - MOZ_MUST_USE bool growStorageBy(size_t aIncr); - MOZ_MUST_USE bool convertToHeapStorage(size_t aNewCap); - MOZ_MUST_USE bool maybeCheckSimulatedOOM(size_t aRequestedSize); - - /* magic constants */ - - static const int kMaxInlineBytes = 1024; - - /* compute constants */ - - /* - * Consider element size to be 1 for buffer sizing if there are 0 inline - * elements. This allows us to compile when the definition of the element - * type is not visible here. - * - * Explicit specialization is only allowed at namespace scope, so in order - * to keep everything here, we use a dummy template parameter with partial - * specialization. - */ - template<int M, int Dummy> - struct ElemSize - { - static const size_t value = sizeof(T); - }; - template<int Dummy> - struct ElemSize<0, Dummy> - { - static const size_t value = 1; - }; - - static const size_t kInlineCapacity = - tl::Min<MinInlineCapacity, kMaxInlineBytes / ElemSize<MinInlineCapacity, 0>::value>::value; - - /* Calculate inline buffer size; avoid 0-sized array. */ - static const size_t kInlineBytes = - tl::Max<1, kInlineCapacity * ElemSize<MinInlineCapacity, 0>::value>::value; - - /* member data */ - - /* - * Pointer to the buffer, be it inline or heap-allocated. Only [mBegin, - * mBegin + mLength) hold valid constructed T objects. The range [mBegin + - * mLength, mBegin + mCapacity) holds uninitialized memory. The range - * [mBegin + mLength, mBegin + mReserved) also holds uninitialized memory - * previously allocated by a call to reserve(). - */ - T* mBegin; - - /* Number of elements in the vector. */ - size_t mLength; - - /* Max number of elements storable in the vector without resizing. */ - size_t mCapacity; - -#ifdef DEBUG - /* Max elements of reserved or used space in this vector. */ - size_t mReserved; -#endif - - /* Memory used for inline storage. */ - AlignedStorage<kInlineBytes> mStorage; - -#ifdef DEBUG - friend class ReentrancyGuard; - bool mEntered; -#endif - - /* private accessors */ - - bool usingInlineStorage() const - { - return mBegin == const_cast<Vector*>(this)->inlineStorage(); - } - - T* inlineStorage() - { - return static_cast<T*>(mStorage.addr()); - } - - T* beginNoCheck() const - { - return mBegin; - } - - T* endNoCheck() - { - return mBegin + mLength; - } - - const T* endNoCheck() const - { - return mBegin + mLength; - } - -#ifdef DEBUG - /** - * The amount of explicitly allocated space in this vector that is immediately - * available to be filled by appending additional elements. This value is - * always greater than or equal to |length()| -- the vector's actual elements - * are implicitly reserved. This value is always less than or equal to - * |capacity()|. It may be explicitly increased using the |reserve()| method. - */ - size_t reserved() const - { - MOZ_ASSERT(mLength <= mReserved); - MOZ_ASSERT(mReserved <= mCapacity); - return mReserved; - } -#endif - - /* Append operations guaranteed to succeed due to pre-reserved space. */ - template<typename U> void internalAppend(U&& aU); - template<typename U, size_t O, class BP> - void internalAppendAll(const Vector<U, O, BP>& aU); - void internalAppendN(const T& aT, size_t aN); - template<typename U> void internalAppend(const U* aBegin, size_t aLength); - -public: - static const size_t sMaxInlineStorage = MinInlineCapacity; - - typedef T ElementType; - - explicit Vector(AllocPolicy = AllocPolicy()); - Vector(Vector&&); /* Move constructor. */ - Vector& operator=(Vector&&); /* Move assignment. */ - ~Vector(); - - /* accessors */ - - const AllocPolicy& allocPolicy() const { return *this; } - - AllocPolicy& allocPolicy() { return *this; } - - enum { InlineLength = MinInlineCapacity }; - - size_t length() const { return mLength; } - - bool empty() const { return mLength == 0; } - - size_t capacity() const { return mCapacity; } - - T* begin() - { - MOZ_ASSERT(!mEntered); - return mBegin; - } - - const T* begin() const - { - MOZ_ASSERT(!mEntered); - return mBegin; - } - - T* end() - { - MOZ_ASSERT(!mEntered); - return mBegin + mLength; - } - - const T* end() const - { - MOZ_ASSERT(!mEntered); - return mBegin + mLength; - } - - T& operator[](size_t aIndex) - { - MOZ_ASSERT(!mEntered); - MOZ_ASSERT(aIndex < mLength); - return begin()[aIndex]; - } - - const T& operator[](size_t aIndex) const - { - MOZ_ASSERT(!mEntered); - MOZ_ASSERT(aIndex < mLength); - return begin()[aIndex]; - } - - T& back() - { - MOZ_ASSERT(!mEntered); - MOZ_ASSERT(!empty()); - return *(end() - 1); - } - - const T& back() const - { - MOZ_ASSERT(!mEntered); - MOZ_ASSERT(!empty()); - return *(end() - 1); - } - - class Range - { - friend class Vector; - T* mCur; - T* mEnd; - Range(T* aCur, T* aEnd) - : mCur(aCur) - , mEnd(aEnd) - { - MOZ_ASSERT(aCur <= aEnd); - } - - public: - bool empty() const { return mCur == mEnd; } - size_t remain() const { return PointerRangeSize(mCur, mEnd); } - T& front() const { MOZ_ASSERT(!empty()); return *mCur; } - void popFront() { MOZ_ASSERT(!empty()); ++mCur; } - T popCopyFront() { MOZ_ASSERT(!empty()); return *mCur++; } - }; - - class ConstRange - { - friend class Vector; - const T* mCur; - const T* mEnd; - ConstRange(const T* aCur, const T* aEnd) - : mCur(aCur) - , mEnd(aEnd) - { - MOZ_ASSERT(aCur <= aEnd); - } - - public: - bool empty() const { return mCur == mEnd; } - size_t remain() const { return PointerRangeSize(mCur, mEnd); } - const T& front() const { MOZ_ASSERT(!empty()); return *mCur; } - void popFront() { MOZ_ASSERT(!empty()); ++mCur; } - T popCopyFront() { MOZ_ASSERT(!empty()); return *mCur++; } - }; - - Range all() { return Range(begin(), end()); } - ConstRange all() const { return ConstRange(begin(), end()); } - - /* mutators */ - - /** - * Reverse the order of the elements in the vector in place. - */ - void reverse(); - - /** - * Given that the vector is empty, grow the internal capacity to |aRequest|, - * keeping the length 0. - */ - MOZ_MUST_USE bool initCapacity(size_t aRequest); - - /** - * Given that the vector is empty, grow the internal capacity and length to - * |aRequest| leaving the elements' memory completely uninitialized (with all - * the associated hazards and caveats). This avoids the usual allocation-size - * rounding that happens in resize and overhead of initialization for elements - * that are about to be overwritten. - */ - MOZ_MUST_USE bool initLengthUninitialized(size_t aRequest); - - /** - * If reserve(aRequest) succeeds and |aRequest >= length()|, then appending - * |aRequest - length()| elements, in any sequence of append/appendAll calls, - * is guaranteed to succeed. - * - * A request to reserve an amount less than the current length does not affect - * reserved space. - */ - MOZ_MUST_USE bool reserve(size_t aRequest); - - /** - * Destroy elements in the range [end() - aIncr, end()). Does not deallocate - * or unreserve storage for those elements. - */ - void shrinkBy(size_t aIncr); - - /** - * Destroy elements in the range [aNewLength, end()). Does not deallocate - * or unreserve storage for those elements. - */ - void shrinkTo(size_t aNewLength); - - /** Grow the vector by aIncr elements. */ - MOZ_MUST_USE bool growBy(size_t aIncr); - - /** Call shrinkBy or growBy based on whether newSize > length(). */ - MOZ_MUST_USE bool resize(size_t aNewLength); - - /** - * Increase the length of the vector, but don't initialize the new elements - * -- leave them as uninitialized memory. - */ - MOZ_MUST_USE bool growByUninitialized(size_t aIncr); - void infallibleGrowByUninitialized(size_t aIncr); - MOZ_MUST_USE bool resizeUninitialized(size_t aNewLength); - - /** Shorthand for shrinkBy(length()). */ - void clear(); - - /** Clears and releases any heap-allocated storage. */ - void clearAndFree(); - - /** - * Calls the AllocPolicy's pod_realloc to release excess capacity. Since - * realloc is only safe on PODs, this method fails to compile if IsPod<T> - * is false. - */ - void podResizeToFit(); - - /** - * If true, appending |aNeeded| elements won't reallocate elements storage. - * This *doesn't* mean that infallibleAppend may be used! You still must - * reserve the extra space, even if this method indicates that appends won't - * need to reallocate elements storage. - */ - bool canAppendWithoutRealloc(size_t aNeeded) const; - - /** Potentially fallible append operations. */ - - /** - * This can take either a T& or a T&&. Given a T&&, it moves |aU| into the - * vector, instead of copying it. If it fails, |aU| is left unmoved. ("We are - * not amused.") - */ - template<typename U> MOZ_MUST_USE bool append(U&& aU); - - /** - * Construct a T in-place as a new entry at the end of this vector. - */ - template<typename... Args> - MOZ_MUST_USE bool emplaceBack(Args&&... aArgs) - { - if (!growByUninitialized(1)) - return false; - Impl::new_(&back(), Forward<Args>(aArgs)...); - return true; - } - - template<typename U, size_t O, class BP> - MOZ_MUST_USE bool appendAll(const Vector<U, O, BP>& aU); - MOZ_MUST_USE bool appendN(const T& aT, size_t aN); - template<typename U> MOZ_MUST_USE bool append(const U* aBegin, const U* aEnd); - template<typename U> MOZ_MUST_USE bool append(const U* aBegin, size_t aLength); - - /* - * Guaranteed-infallible append operations for use upon vectors whose - * memory has been pre-reserved. Don't use this if you haven't reserved the - * memory! - */ - template<typename U> void infallibleAppend(U&& aU) - { - internalAppend(Forward<U>(aU)); - } - void infallibleAppendN(const T& aT, size_t aN) - { - internalAppendN(aT, aN); - } - template<typename U> void infallibleAppend(const U* aBegin, const U* aEnd) - { - internalAppend(aBegin, PointerRangeSize(aBegin, aEnd)); - } - template<typename U> void infallibleAppend(const U* aBegin, size_t aLength) - { - internalAppend(aBegin, aLength); - } - template<typename... Args> - void infallibleEmplaceBack(Args&&... aArgs) - { - infallibleGrowByUninitialized(1); - Impl::new_(&back(), Forward<Args>(aArgs)...); - } - - void popBack(); - - T popCopy(); - - /** - * If elements are stored in-place, return nullptr and leave this vector - * unmodified. - * - * Otherwise return this vector's elements buffer, and clear this vector as if - * by clearAndFree(). The caller now owns the buffer and is responsible for - * deallocating it consistent with this vector's AllocPolicy. - * - * N.B. Although a T*, only the range [0, length()) is constructed. - */ - MOZ_MUST_USE T* extractRawBuffer(); - - /** - * If elements are stored in-place, allocate a new buffer, move this vector's - * elements into it, and return that buffer. - * - * Otherwise return this vector's elements buffer. The caller now owns the - * buffer and is responsible for deallocating it consistent with this vector's - * AllocPolicy. - * - * This vector is cleared, as if by clearAndFree(), when this method - * succeeds. This method fails and returns nullptr only if new elements buffer - * allocation fails. - * - * N.B. Only the range [0, length()) of the returned buffer is constructed. - * If any of these elements are uninitialized (as growByUninitialized - * enables), behavior is undefined. - */ - MOZ_MUST_USE T* extractOrCopyRawBuffer(); - - /** - * Transfer ownership of an array of objects into the vector. The caller - * must have allocated the array in accordance with this vector's - * AllocPolicy. - * - * N.B. This call assumes that there are no uninitialized elements in the - * passed array. - */ - void replaceRawBuffer(T* aP, size_t aLength); - - /** - * Places |aVal| at position |aP|, shifting existing elements from |aP| onward - * one position higher. On success, |aP| should not be reused because it'll - * be a dangling pointer if reallocation of the vector storage occurred; the - * return value should be used instead. On failure, nullptr is returned. - * - * Example usage: - * - * if (!(p = vec.insert(p, val))) { - * <handle failure> - * } - * <keep working with p> - * - * This is inherently a linear-time operation. Be careful! - */ - template<typename U> - MOZ_MUST_USE T* insert(T* aP, U&& aVal); - - /** - * Removes the element |aT|, which must fall in the bounds [begin, end), - * shifting existing elements from |aT + 1| onward one position lower. - */ - void erase(T* aT); - - /** - * Removes the elements [|aBegin|, |aEnd|), which must fall in the bounds - * [begin, end), shifting existing elements from |aEnd + 1| onward to aBegin's - * old position. - */ - void erase(T* aBegin, T* aEnd); - - /** - * Measure the size of the vector's heap-allocated storage. - */ - size_t sizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const; - - /** - * Like sizeOfExcludingThis, but also measures the size of the vector - * object (which must be heap-allocated) itself. - */ - size_t sizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const; - - void swap(Vector& aOther); - -private: - Vector(const Vector&) = delete; - void operator=(const Vector&) = delete; -}; - -/* This does the re-entrancy check plus several other sanity checks. */ -#define MOZ_REENTRANCY_GUARD_ET_AL \ - ReentrancyGuard g(*this); \ - MOZ_ASSERT_IF(usingInlineStorage(), mCapacity == kInlineCapacity); \ - MOZ_ASSERT(reserved() <= mCapacity); \ - MOZ_ASSERT(mLength <= reserved()); \ - MOZ_ASSERT(mLength <= mCapacity) - -/* Vector Implementation */ - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE -Vector<T, N, AP>::Vector(AP aAP) - : AP(aAP) - , mLength(0) - , mCapacity(kInlineCapacity) -#ifdef DEBUG - , mReserved(0) - , mEntered(false) -#endif -{ - mBegin = static_cast<T*>(mStorage.addr()); -} - -/* Move constructor. */ -template<typename T, size_t N, class AllocPolicy> -MOZ_ALWAYS_INLINE -Vector<T, N, AllocPolicy>::Vector(Vector&& aRhs) - : AllocPolicy(Move(aRhs)) -#ifdef DEBUG - , mEntered(false) -#endif -{ - mLength = aRhs.mLength; - mCapacity = aRhs.mCapacity; -#ifdef DEBUG - mReserved = aRhs.mReserved; -#endif - - if (aRhs.usingInlineStorage()) { - /* We can't move the buffer over in this case, so copy elements. */ - mBegin = static_cast<T*>(mStorage.addr()); - Impl::moveConstruct(mBegin, aRhs.beginNoCheck(), aRhs.endNoCheck()); - /* - * Leave aRhs's mLength, mBegin, mCapacity, and mReserved as they are. - * The elements in its in-line storage still need to be destroyed. - */ - } else { - /* - * Take src's buffer, and turn src into an empty vector using - * in-line storage. - */ - mBegin = aRhs.mBegin; - aRhs.mBegin = static_cast<T*>(aRhs.mStorage.addr()); - aRhs.mCapacity = kInlineCapacity; - aRhs.mLength = 0; -#ifdef DEBUG - aRhs.mReserved = 0; -#endif - } -} - -/* Move assignment. */ -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE Vector<T, N, AP>& -Vector<T, N, AP>::operator=(Vector&& aRhs) -{ - MOZ_ASSERT(this != &aRhs, "self-move assignment is prohibited"); - this->~Vector(); - new(KnownNotNull, this) Vector(Move(aRhs)); - return *this; -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE -Vector<T, N, AP>::~Vector() -{ - MOZ_REENTRANCY_GUARD_ET_AL; - Impl::destroy(beginNoCheck(), endNoCheck()); - if (!usingInlineStorage()) { - this->free_(beginNoCheck()); - } -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE void -Vector<T, N, AP>::reverse() { - MOZ_REENTRANCY_GUARD_ET_AL; - T* elems = mBegin; - size_t len = mLength; - size_t mid = len / 2; - for (size_t i = 0; i < mid; i++) { - Swap(elems[i], elems[len - i - 1]); - } -} - -/* - * This function will create a new heap buffer with capacity aNewCap, - * move all elements in the inline buffer to this new buffer, - * and fail on OOM. - */ -template<typename T, size_t N, class AP> -inline bool -Vector<T, N, AP>::convertToHeapStorage(size_t aNewCap) -{ - MOZ_ASSERT(usingInlineStorage()); - - /* Allocate buffer. */ - MOZ_ASSERT(!detail::CapacityHasExcessSpace<T>(aNewCap)); - T* newBuf = this->template pod_malloc<T>(aNewCap); - if (MOZ_UNLIKELY(!newBuf)) { - return false; - } - - /* Copy inline elements into heap buffer. */ - Impl::moveConstruct(newBuf, beginNoCheck(), endNoCheck()); - Impl::destroy(beginNoCheck(), endNoCheck()); - - /* Switch in heap buffer. */ - mBegin = newBuf; - /* mLength is unchanged. */ - mCapacity = aNewCap; - return true; -} - -template<typename T, size_t N, class AP> -MOZ_NEVER_INLINE bool -Vector<T, N, AP>::growStorageBy(size_t aIncr) -{ - MOZ_ASSERT(mLength + aIncr > mCapacity); - - /* - * When choosing a new capacity, its size should is as close to 2**N bytes - * as possible. 2**N-sized requests are best because they are unlikely to - * be rounded up by the allocator. Asking for a 2**N number of elements - * isn't as good, because if sizeof(T) is not a power-of-two that would - * result in a non-2**N request size. - */ - - size_t newCap; - - if (aIncr == 1) { - if (usingInlineStorage()) { - /* This case occurs in ~70--80% of the calls to this function. */ - size_t newSize = - tl::RoundUpPow2<(kInlineCapacity + 1) * sizeof(T)>::value; - newCap = newSize / sizeof(T); - goto convert; - } - - if (mLength == 0) { - /* This case occurs in ~0--10% of the calls to this function. */ - newCap = 1; - goto grow; - } - - /* This case occurs in ~15--20% of the calls to this function. */ - - /* - * Will mLength * 4 *sizeof(T) overflow? This condition limits a vector - * to 1GB of memory on a 32-bit system, which is a reasonable limit. It - * also ensures that - * - * static_cast<char*>(end()) - static_cast<char*>(begin()) - * - * doesn't overflow ptrdiff_t (see bug 510319). - */ - if (MOZ_UNLIKELY(mLength & tl::MulOverflowMask<4 * sizeof(T)>::value)) { - this->reportAllocOverflow(); - return false; - } - - /* - * If we reach here, the existing capacity will have a size that is already - * as close to 2^N as sizeof(T) will allow. Just double the capacity, and - * then there might be space for one more element. - */ - newCap = mLength * 2; - if (detail::CapacityHasExcessSpace<T>(newCap)) { - newCap += 1; - } - } else { - /* This case occurs in ~2% of the calls to this function. */ - size_t newMinCap = mLength + aIncr; - - /* Did mLength + aIncr overflow? Will newCap * sizeof(T) overflow? */ - if (MOZ_UNLIKELY(newMinCap < mLength || - newMinCap & tl::MulOverflowMask<2 * sizeof(T)>::value)) - { - this->reportAllocOverflow(); - return false; - } - - size_t newMinSize = newMinCap * sizeof(T); - size_t newSize = RoundUpPow2(newMinSize); - newCap = newSize / sizeof(T); - } - - if (usingInlineStorage()) { -convert: - return convertToHeapStorage(newCap); - } - -grow: - return Impl::growTo(*this, newCap); -} - -template<typename T, size_t N, class AP> -inline bool -Vector<T, N, AP>::initCapacity(size_t aRequest) -{ - MOZ_ASSERT(empty()); - MOZ_ASSERT(usingInlineStorage()); - if (aRequest == 0) { - return true; - } - T* newbuf = this->template pod_malloc<T>(aRequest); - if (MOZ_UNLIKELY(!newbuf)) { - return false; - } - mBegin = newbuf; - mCapacity = aRequest; -#ifdef DEBUG - mReserved = aRequest; -#endif - return true; -} - -template<typename T, size_t N, class AP> -inline bool -Vector<T, N, AP>::initLengthUninitialized(size_t aRequest) -{ - if (!initCapacity(aRequest)) { - return false; - } - infallibleGrowByUninitialized(aRequest); - return true; -} - -template<typename T, size_t N, class AP> -inline bool -Vector<T, N, AP>::maybeCheckSimulatedOOM(size_t aRequestedSize) -{ - if (aRequestedSize <= N) { - return true; - } - -#ifdef DEBUG - if (aRequestedSize <= mReserved) { - return true; - } -#endif - - return allocPolicy().checkSimulatedOOM(); -} - -template<typename T, size_t N, class AP> -inline bool -Vector<T, N, AP>::reserve(size_t aRequest) -{ - MOZ_REENTRANCY_GUARD_ET_AL; - if (aRequest > mCapacity) { - if (MOZ_UNLIKELY(!growStorageBy(aRequest - mLength))) { - return false; - } - } else if (!maybeCheckSimulatedOOM(aRequest)) { - return false; - } -#ifdef DEBUG - if (aRequest > mReserved) { - mReserved = aRequest; - } - MOZ_ASSERT(mLength <= mReserved); - MOZ_ASSERT(mReserved <= mCapacity); -#endif - return true; -} - -template<typename T, size_t N, class AP> -inline void -Vector<T, N, AP>::shrinkBy(size_t aIncr) -{ - MOZ_REENTRANCY_GUARD_ET_AL; - MOZ_ASSERT(aIncr <= mLength); - Impl::destroy(endNoCheck() - aIncr, endNoCheck()); - mLength -= aIncr; -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE void -Vector<T, N, AP>::shrinkTo(size_t aNewLength) -{ - MOZ_ASSERT(aNewLength <= mLength); - shrinkBy(mLength - aNewLength); -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE bool -Vector<T, N, AP>::growBy(size_t aIncr) -{ - MOZ_REENTRANCY_GUARD_ET_AL; - if (aIncr > mCapacity - mLength) { - if (MOZ_UNLIKELY(!growStorageBy(aIncr))) { - return false; - } - } else if (!maybeCheckSimulatedOOM(mLength + aIncr)) { - return false; - } - MOZ_ASSERT(mLength + aIncr <= mCapacity); - T* newend = endNoCheck() + aIncr; - Impl::initialize(endNoCheck(), newend); - mLength += aIncr; -#ifdef DEBUG - if (mLength > mReserved) { - mReserved = mLength; - } -#endif - return true; -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE bool -Vector<T, N, AP>::growByUninitialized(size_t aIncr) -{ - MOZ_REENTRANCY_GUARD_ET_AL; - if (aIncr > mCapacity - mLength) { - if (MOZ_UNLIKELY(!growStorageBy(aIncr))) { - return false; - } - } else if (!maybeCheckSimulatedOOM(mLength + aIncr)) { - return false; - } -#ifdef DEBUG - if (mLength + aIncr > mReserved) { - mReserved = mLength + aIncr; - } -#endif - infallibleGrowByUninitialized(aIncr); - return true; -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE void -Vector<T, N, AP>::infallibleGrowByUninitialized(size_t aIncr) -{ - MOZ_ASSERT(mLength + aIncr <= reserved()); - mLength += aIncr; -} - -template<typename T, size_t N, class AP> -inline bool -Vector<T, N, AP>::resize(size_t aNewLength) -{ - size_t curLength = mLength; - if (aNewLength > curLength) { - return growBy(aNewLength - curLength); - } - shrinkBy(curLength - aNewLength); - return true; -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE bool -Vector<T, N, AP>::resizeUninitialized(size_t aNewLength) -{ - size_t curLength = mLength; - if (aNewLength > curLength) { - return growByUninitialized(aNewLength - curLength); - } - shrinkBy(curLength - aNewLength); - return true; -} - -template<typename T, size_t N, class AP> -inline void -Vector<T, N, AP>::clear() -{ - MOZ_REENTRANCY_GUARD_ET_AL; - Impl::destroy(beginNoCheck(), endNoCheck()); - mLength = 0; -} - -template<typename T, size_t N, class AP> -inline void -Vector<T, N, AP>::clearAndFree() -{ - clear(); - - if (usingInlineStorage()) { - return; - } - this->free_(beginNoCheck()); - mBegin = static_cast<T*>(mStorage.addr()); - mCapacity = kInlineCapacity; -#ifdef DEBUG - mReserved = 0; -#endif -} - -template<typename T, size_t N, class AP> -inline void -Vector<T, N, AP>::podResizeToFit() -{ - // This function is only defined if IsPod is true and will fail to compile - // otherwise. - Impl::podResizeToFit(*this); -} - -template<typename T, size_t N, class AP> -inline bool -Vector<T, N, AP>::canAppendWithoutRealloc(size_t aNeeded) const -{ - return mLength + aNeeded <= mCapacity; -} - -template<typename T, size_t N, class AP> -template<typename U, size_t O, class BP> -MOZ_ALWAYS_INLINE void -Vector<T, N, AP>::internalAppendAll(const Vector<U, O, BP>& aOther) -{ - internalAppend(aOther.begin(), aOther.length()); -} - -template<typename T, size_t N, class AP> -template<typename U> -MOZ_ALWAYS_INLINE void -Vector<T, N, AP>::internalAppend(U&& aU) -{ - MOZ_ASSERT(mLength + 1 <= mReserved); - MOZ_ASSERT(mReserved <= mCapacity); - Impl::new_(endNoCheck(), Forward<U>(aU)); - ++mLength; -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE bool -Vector<T, N, AP>::appendN(const T& aT, size_t aNeeded) -{ - MOZ_REENTRANCY_GUARD_ET_AL; - if (mLength + aNeeded > mCapacity) { - if (MOZ_UNLIKELY(!growStorageBy(aNeeded))) { - return false; - } - } else if (!maybeCheckSimulatedOOM(mLength + aNeeded)) { - return false; - } -#ifdef DEBUG - if (mLength + aNeeded > mReserved) { - mReserved = mLength + aNeeded; - } -#endif - internalAppendN(aT, aNeeded); - return true; -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE void -Vector<T, N, AP>::internalAppendN(const T& aT, size_t aNeeded) -{ - MOZ_ASSERT(mLength + aNeeded <= mReserved); - MOZ_ASSERT(mReserved <= mCapacity); - Impl::copyConstructN(endNoCheck(), aNeeded, aT); - mLength += aNeeded; -} - -template<typename T, size_t N, class AP> -template<typename U> -inline T* -Vector<T, N, AP>::insert(T* aP, U&& aVal) -{ - MOZ_ASSERT(begin() <= aP); - MOZ_ASSERT(aP <= end()); - size_t pos = aP - begin(); - MOZ_ASSERT(pos <= mLength); - size_t oldLength = mLength; - if (pos == oldLength) { - if (!append(Forward<U>(aVal))) { - return nullptr; - } - } else { - T oldBack = Move(back()); - if (!append(Move(oldBack))) { /* Dup the last element. */ - return nullptr; - } - for (size_t i = oldLength; i > pos; --i) { - (*this)[i] = Move((*this)[i - 1]); - } - (*this)[pos] = Forward<U>(aVal); - } - return begin() + pos; -} - -template<typename T, size_t N, class AP> -inline void -Vector<T, N, AP>::erase(T* aIt) -{ - MOZ_ASSERT(begin() <= aIt); - MOZ_ASSERT(aIt < end()); - while (aIt + 1 < end()) { - *aIt = Move(*(aIt + 1)); - ++aIt; - } - popBack(); -} - -template<typename T, size_t N, class AP> -inline void -Vector<T, N, AP>::erase(T* aBegin, T* aEnd) -{ - MOZ_ASSERT(begin() <= aBegin); - MOZ_ASSERT(aBegin <= aEnd); - MOZ_ASSERT(aEnd <= end()); - while (aEnd < end()) { - *aBegin++ = Move(*aEnd++); - } - shrinkBy(aEnd - aBegin); -} - -template<typename T, size_t N, class AP> -template<typename U> -MOZ_ALWAYS_INLINE bool -Vector<T, N, AP>::append(const U* aInsBegin, const U* aInsEnd) -{ - MOZ_REENTRANCY_GUARD_ET_AL; - size_t aNeeded = PointerRangeSize(aInsBegin, aInsEnd); - if (mLength + aNeeded > mCapacity) { - if (MOZ_UNLIKELY(!growStorageBy(aNeeded))) { - return false; - } - } else if (!maybeCheckSimulatedOOM(mLength + aNeeded)) { - return false; - } -#ifdef DEBUG - if (mLength + aNeeded > mReserved) { - mReserved = mLength + aNeeded; - } -#endif - internalAppend(aInsBegin, aNeeded); - return true; -} - -template<typename T, size_t N, class AP> -template<typename U> -MOZ_ALWAYS_INLINE void -Vector<T, N, AP>::internalAppend(const U* aInsBegin, size_t aInsLength) -{ - MOZ_ASSERT(mLength + aInsLength <= mReserved); - MOZ_ASSERT(mReserved <= mCapacity); - Impl::copyConstruct(endNoCheck(), aInsBegin, aInsBegin + aInsLength); - mLength += aInsLength; -} - -template<typename T, size_t N, class AP> -template<typename U> -MOZ_ALWAYS_INLINE bool -Vector<T, N, AP>::append(U&& aU) -{ - MOZ_REENTRANCY_GUARD_ET_AL; - if (mLength == mCapacity) { - if (MOZ_UNLIKELY(!growStorageBy(1))) { - return false; - } - } else if (!maybeCheckSimulatedOOM(mLength + 1)) { - return false; - } -#ifdef DEBUG - if (mLength + 1 > mReserved) { - mReserved = mLength + 1; - } -#endif - internalAppend(Forward<U>(aU)); - return true; -} - -template<typename T, size_t N, class AP> -template<typename U, size_t O, class BP> -MOZ_ALWAYS_INLINE bool -Vector<T, N, AP>::appendAll(const Vector<U, O, BP>& aOther) -{ - return append(aOther.begin(), aOther.length()); -} - -template<typename T, size_t N, class AP> -template<class U> -MOZ_ALWAYS_INLINE bool -Vector<T, N, AP>::append(const U* aInsBegin, size_t aInsLength) -{ - return append(aInsBegin, aInsBegin + aInsLength); -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE void -Vector<T, N, AP>::popBack() -{ - MOZ_REENTRANCY_GUARD_ET_AL; - MOZ_ASSERT(!empty()); - --mLength; - endNoCheck()->~T(); -} - -template<typename T, size_t N, class AP> -MOZ_ALWAYS_INLINE T -Vector<T, N, AP>::popCopy() -{ - T ret = back(); - popBack(); - return ret; -} - -template<typename T, size_t N, class AP> -inline T* -Vector<T, N, AP>::extractRawBuffer() -{ - MOZ_REENTRANCY_GUARD_ET_AL; - - if (usingInlineStorage()) { - return nullptr; - } - - T* ret = mBegin; - mBegin = static_cast<T*>(mStorage.addr()); - mLength = 0; - mCapacity = kInlineCapacity; -#ifdef DEBUG - mReserved = 0; -#endif - return ret; -} - -template<typename T, size_t N, class AP> -inline T* -Vector<T, N, AP>::extractOrCopyRawBuffer() -{ - if (T* ret = extractRawBuffer()) { - return ret; - } - - MOZ_REENTRANCY_GUARD_ET_AL; - - T* copy = this->template pod_malloc<T>(mLength); - if (!copy) { - return nullptr; - } - - Impl::moveConstruct(copy, beginNoCheck(), endNoCheck()); - Impl::destroy(beginNoCheck(), endNoCheck()); - mBegin = static_cast<T*>(mStorage.addr()); - mLength = 0; - mCapacity = kInlineCapacity; -#ifdef DEBUG - mReserved = 0; -#endif - return copy; -} - -template<typename T, size_t N, class AP> -inline void -Vector<T, N, AP>::replaceRawBuffer(T* aP, size_t aLength) -{ - MOZ_REENTRANCY_GUARD_ET_AL; - - /* Destroy what we have. */ - Impl::destroy(beginNoCheck(), endNoCheck()); - if (!usingInlineStorage()) { - this->free_(beginNoCheck()); - } - - /* Take in the new buffer. */ - if (aLength <= kInlineCapacity) { - /* - * We convert to inline storage if possible, even though aP might - * otherwise be acceptable. Maybe this behaviour should be - * specifiable with an argument to this function. - */ - mBegin = static_cast<T*>(mStorage.addr()); - mLength = aLength; - mCapacity = kInlineCapacity; - Impl::moveConstruct(mBegin, aP, aP + aLength); - Impl::destroy(aP, aP + aLength); - this->free_(aP); - } else { - mBegin = aP; - mLength = aLength; - mCapacity = aLength; - } -#ifdef DEBUG - mReserved = aLength; -#endif -} - -template<typename T, size_t N, class AP> -inline size_t -Vector<T, N, AP>::sizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const -{ - return usingInlineStorage() ? 0 : aMallocSizeOf(beginNoCheck()); -} - -template<typename T, size_t N, class AP> -inline size_t -Vector<T, N, AP>::sizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const -{ - return aMallocSizeOf(this) + sizeOfExcludingThis(aMallocSizeOf); -} - -template<typename T, size_t N, class AP> -inline void -Vector<T, N, AP>::swap(Vector& aOther) -{ - static_assert(N == 0, - "still need to implement this for N != 0"); - - // This only works when inline storage is always empty. - if (!usingInlineStorage() && aOther.usingInlineStorage()) { - aOther.mBegin = mBegin; - mBegin = inlineStorage(); - } else if (usingInlineStorage() && !aOther.usingInlineStorage()) { - mBegin = aOther.mBegin; - aOther.mBegin = aOther.inlineStorage(); - } else if (!usingInlineStorage() && !aOther.usingInlineStorage()) { - Swap(mBegin, aOther.mBegin); - } else { - // This case is a no-op, since we'd set both to use their inline storage. - } - - Swap(mLength, aOther.mLength); - Swap(mCapacity, aOther.mCapacity); -#ifdef DEBUG - Swap(mReserved, aOther.mReserved); -#endif -} - -} // namespace mozilla - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -#endif /* mozilla_Vector_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/WeakPtr.h b/android/armeabi/include/spidermonkey/mozilla/WeakPtr.h deleted file mode 100644 index ef0c19f4..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/WeakPtr.h +++ /dev/null @@ -1,283 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* Weak pointer functionality, implemented as a mixin for use with any class. */ - -/** - * SupportsWeakPtr lets you have a pointer to an object 'Foo' without affecting - * its lifetime. It works by creating a single shared reference counted object - * (WeakReference) that each WeakPtr will access 'Foo' through. This lets 'Foo' - * clear the pointer in the WeakReference without having to know about all of - * the WeakPtrs to it and allows the WeakReference to live beyond the lifetime - * of 'Foo'. - * - * PLEASE NOTE: This weak pointer implementation is not thread-safe. - * - * Note that when deriving from SupportsWeakPtr you should add - * MOZ_DECLARE_WEAKREFERENCE_TYPENAME(ClassName) to the public section of your - * class, where ClassName is the name of your class. - * - * The overhead of WeakPtr is that accesses to 'Foo' becomes an additional - * dereference, and an additional heap allocated pointer sized object shared - * between all of the WeakPtrs. - * - * Example of usage: - * - * // To have a class C support weak pointers, inherit from - * // SupportsWeakPtr<C>. - * class C : public SupportsWeakPtr<C> - * { - * public: - * MOZ_DECLARE_WEAKREFERENCE_TYPENAME(C) - * int mNum; - * void act(); - * }; - * - * C* ptr = new C(); - * - * // Get weak pointers to ptr. The first time a weak pointer - * // is obtained, a reference counted WeakReference object is created that - * // can live beyond the lifetime of 'ptr'. The WeakReference - * // object will be notified of 'ptr's destruction. - * WeakPtr<C> weak = ptr; - * WeakPtr<C> other = ptr; - * - * // Test a weak pointer for validity before using it. - * if (weak) { - * weak->mNum = 17; - * weak->act(); - * } - * - * // Destroying the underlying object clears weak pointers to it. - * delete ptr; - * - * MOZ_ASSERT(!weak, "Deleting |ptr| clears weak pointers to it."); - * MOZ_ASSERT(!other, "Deleting |ptr| clears all weak pointers to it."); - * - * WeakPtr is typesafe and may be used with any class. It is not required that - * the class be reference-counted or allocated in any particular way. - * - * The API was loosely inspired by Chromium's weak_ptr.h: - * http://src.chromium.org/svn/trunk/src/base/memory/weak_ptr.h - */ - -#ifndef mozilla_WeakPtr_h -#define mozilla_WeakPtr_h - -#include "mozilla/ArrayUtils.h" -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/RefCounted.h" -#include "mozilla/RefPtr.h" -#include "mozilla/TypeTraits.h" - -#include <string.h> - -// Weak referencing is not implemeted as thread safe. When a WeakPtr -// is created or dereferenced on thread A but the real object is just -// being Released() on thread B, there is a possibility of a race -// when the proxy object (detail::WeakReference) is notified about -// the real object destruction just between when thread A is storing -// the object pointer locally and is about to add a reference to it. -// -// Hence, a non-null weak proxy object is considered to have a single -// "owning thread". It means that each query for a weak reference, -// its dereference, and destruction of the real object must all happen -// on a single thread. The following macros implement assertions for -// checking these conditions. -// -// We disable this on MinGW. MinGW has two threading models: win32 -// API based, which disables std::thread; and POSIX based which -// enables it but requires an emulation library (winpthreads). -// Rather than attempting to switch to pthread emulation at this point, -// we are disabling the std::thread based assertion checking. -// -// In the future, to enable it we could -// a. have libgcc/stdc++ support win32 threads natively -// b. switch to POSIX-based threading in MinGW with pthread emulation -// c. refactor it to not use std::thread - -#if !defined(__MINGW32__) && (defined(DEBUG) || (defined(NIGHTLY_BUILD) && !defined(MOZ_PROFILING))) - -#include <thread> -#define MOZ_WEAKPTR_DECLARE_THREAD_SAFETY_CHECK \ - std::thread::id _owningThread; \ - bool _empty; // If it was initialized as a placeholder with mPtr = nullptr. -#define MOZ_WEAKPTR_INIT_THREAD_SAFETY_CHECK() \ - do { \ - _owningThread = std::this_thread::get_id(); \ - _empty = !p; \ - } while (false) -#define MOZ_WEAKPTR_ASSERT_THREAD_SAFETY() \ - MOZ_DIAGNOSTIC_ASSERT(_empty || _owningThread == std::this_thread::get_id(), \ - "WeakPtr used on multiple threads") -#define MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED(that) \ - (that)->AssertThreadSafety(); - -#define MOZ_WEAKPTR_THREAD_SAFETY_CHECKING 1 - -#else - -#define MOZ_WEAKPTR_DECLARE_THREAD_SAFETY_CHECK -#define MOZ_WEAKPTR_INIT_THREAD_SAFETY_CHECK() do { } while (false) -#define MOZ_WEAKPTR_ASSERT_THREAD_SAFETY() do { } while (false) -#define MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED(that) do { } while (false) - -#endif - -namespace mozilla { - -template <typename T> class WeakPtr; -template <typename T> class SupportsWeakPtr; - -#ifdef MOZ_REFCOUNTED_LEAK_CHECKING -#define MOZ_DECLARE_WEAKREFERENCE_TYPENAME(T) \ - static const char* weakReferenceTypeName() { return "WeakReference<" #T ">"; } -#else -#define MOZ_DECLARE_WEAKREFERENCE_TYPENAME(T) -#endif - -namespace detail { - -// This can live beyond the lifetime of the class derived from -// SupportsWeakPtr. -template<class T> -class WeakReference : public ::mozilla::RefCounted<WeakReference<T> > -{ -public: - explicit WeakReference(T* p) : mPtr(p) - { - MOZ_WEAKPTR_INIT_THREAD_SAFETY_CHECK(); - } - - T* get() const { - MOZ_WEAKPTR_ASSERT_THREAD_SAFETY(); - return mPtr; - } - -#ifdef MOZ_REFCOUNTED_LEAK_CHECKING - const char* typeName() const - { - // The first time this is called mPtr is null, so don't - // invoke any methods on mPtr. - return T::weakReferenceTypeName(); - } - size_t typeSize() const { return sizeof(*this); } -#endif - -#ifdef MOZ_WEAKPTR_THREAD_SAFETY_CHECKING - void AssertThreadSafety() { MOZ_WEAKPTR_ASSERT_THREAD_SAFETY(); } -#endif - -private: - friend class mozilla::SupportsWeakPtr<T>; - - void detach() { - MOZ_WEAKPTR_ASSERT_THREAD_SAFETY(); - mPtr = nullptr; - } - - T* MOZ_NON_OWNING_REF mPtr; - MOZ_WEAKPTR_DECLARE_THREAD_SAFETY_CHECK -}; - -} // namespace detail - -template <typename T> -class SupportsWeakPtr -{ -protected: - ~SupportsWeakPtr() - { - static_assert(IsBaseOf<SupportsWeakPtr<T>, T>::value, - "T must derive from SupportsWeakPtr<T>"); - if (mSelfReferencingWeakPtr) { - mSelfReferencingWeakPtr.mRef->detach(); - } - } - -private: - const WeakPtr<T>& SelfReferencingWeakPtr() - { - if (!mSelfReferencingWeakPtr) { - mSelfReferencingWeakPtr.mRef = new detail::WeakReference<T>(static_cast<T*>(this)); - } else { - MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED(mSelfReferencingWeakPtr.mRef); - } - return mSelfReferencingWeakPtr; - } - - const WeakPtr<const T>& SelfReferencingWeakPtr() const - { - const WeakPtr<T>& p = const_cast<SupportsWeakPtr*>(this)->SelfReferencingWeakPtr(); - return reinterpret_cast<const WeakPtr<const T>&>(p); - } - - friend class WeakPtr<T>; - friend class WeakPtr<const T>; - - WeakPtr<T> mSelfReferencingWeakPtr; -}; - -template <typename T> -class WeakPtr -{ - typedef detail::WeakReference<T> WeakReference; - -public: - WeakPtr& operator=(const WeakPtr& aOther) - { - mRef = aOther.mRef; - MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED(mRef); - return *this; - } - - WeakPtr(const WeakPtr& aOther) - { - // The thread safety check is performed inside of the operator= method. - *this = aOther; - } - - WeakPtr& operator=(T* aOther) - { - if (aOther) { - *this = aOther->SelfReferencingWeakPtr(); - } else if (!mRef || mRef->get()) { - // Ensure that mRef is dereferenceable in the uninitialized state. - mRef = new WeakReference(nullptr); - } - // The thread safety check happens inside SelfReferencingWeakPtr - // or is initialized in the WeakReference constructor. - return *this; - } - - MOZ_IMPLICIT WeakPtr(T* aOther) - { - *this = aOther; - MOZ_WEAKPTR_ASSERT_THREAD_SAFETY_DELEGATED(mRef); - } - - // Ensure that mRef is dereferenceable in the uninitialized state. - WeakPtr() : mRef(new WeakReference(nullptr)) {} - - operator T*() const { return mRef->get(); } - T& operator*() const { return *mRef->get(); } - - T* operator->() const MOZ_NO_ADDREF_RELEASE_ON_RETURN { return mRef->get(); } - - T* get() const { return mRef->get(); } - -private: - friend class SupportsWeakPtr<T>; - - explicit WeakPtr(const RefPtr<WeakReference>& aOther) : mRef(aOther) {} - - RefPtr<WeakReference> mRef; -}; - -} // namespace mozilla - -#endif /* mozilla_WeakPtr_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/XorShift128PlusRNG.h b/android/armeabi/include/spidermonkey/mozilla/XorShift128PlusRNG.h deleted file mode 100644 index 2f182f0f..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/XorShift128PlusRNG.h +++ /dev/null @@ -1,121 +0,0 @@ -/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set ts=8 sts=2 et sw=2 tw=80: */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -/* The xorshift128+ pseudo-random number generator. */ - -#ifndef mozilla_XorShift128Plus_h -#define mozilla_XorShift128Plus_h - -#include "mozilla/Assertions.h" -#include "mozilla/Attributes.h" -#include "mozilla/FloatingPoint.h" - -#include <inttypes.h> - -namespace mozilla { -namespace non_crypto { - -/* - * A stream of pseudo-random numbers generated using the xorshift+ technique - * described here: - * - * Vigna, Sebastiano (2014). "Further scramblings of Marsaglia's xorshift - * generators". arXiv:1404.0390 (http://arxiv.org/abs/1404.0390) - * - * That paper says: - * - * In particular, we propose a tightly coded xorshift128+ generator that - * does not fail systematically any test from the BigCrush suite of TestU01 - * (even reversed) and generates 64 pseudorandom bits in 1.10 ns on an - * Intel(R) Core(TM) i7-4770 CPU @3.40GHz (Haswell). It is the fastest - * generator we are aware of with such empirical statistical properties. - * - * The stream of numbers produced by this method repeats every 2**128 - 1 calls - * (i.e. never, for all practical purposes). Zero appears 2**64 - 1 times in - * this period; all other numbers appear 2**64 times. Additionally, each *bit* - * in the produced numbers repeats every 2**128 - 1 calls. - * - * This generator is not suitable as a cryptographically secure random number - * generator. - */ -class XorShift128PlusRNG { - uint64_t mState[2]; - - public: - /* - * Construct a xorshift128+ pseudo-random number stream using |aInitial0| and - * |aInitial1| as the initial state. These MUST NOT both be zero. - * - * If the initial states contain many zeros, for a few iterations you'll see - * many zeroes in the generated numbers. It's suggested to seed a SplitMix64 - * generator <http://xorshift.di.unimi.it/splitmix64.c> and use its first two - * outputs to seed xorshift128+. - */ - XorShift128PlusRNG(uint64_t aInitial0, uint64_t aInitial1) { - setState(aInitial0, aInitial1); - } - - /** - * Return a pseudo-random 64-bit number. - */ - uint64_t next() { - /* - * The offsetOfState*() methods below are provided so that exceedingly-rare - * callers that want to observe or poke at RNG state in C++ type-system- - * ignoring means can do so. Don't change the next() or nextDouble() - * algorithms without altering code that uses offsetOfState*()! - */ - uint64_t s1 = mState[0]; - const uint64_t s0 = mState[1]; - mState[0] = s0; - s1 ^= s1 << 23; - mState[1] = s1 ^ s0 ^ (s1 >> 17) ^ (s0 >> 26); - return mState[1] + s0; - } - - /* - * Return a pseudo-random floating-point value in the range [0, 1). More - * precisely, choose an integer in the range [0, 2**53) and divide it by - * 2**53. Given the 2**128 - 1 period noted above, the produced doubles are - * all but uniformly distributed in this range. - */ - double nextDouble() { - /* - * Because the IEEE 64-bit floating point format stores the leading '1' bit - * of the mantissa implicitly, it effectively represents a mantissa in the - * range [0, 2**53) in only 52 bits. FloatingPoint<double>::kExponentShift - * is the width of the bitfield in the in-memory format, so we must add one - * to get the mantissa's range. - */ - static constexpr int kMantissaBits = - mozilla::FloatingPoint<double>::kExponentShift + 1; - uint64_t mantissa = next() & ((UINT64_C(1) << kMantissaBits) - 1); - return double(mantissa) / (UINT64_C(1) << kMantissaBits); - } - - /* - * Set the stream's current state to |aState0| and |aState1|. These must not - * both be zero; ideally, they should have an almost even mix of zero and one - * bits. - */ - void setState(uint64_t aState0, uint64_t aState1) { - MOZ_ASSERT(aState0 || aState1); - mState[0] = aState0; - mState[1] = aState1; - } - - static size_t offsetOfState0() { - return offsetof(XorShift128PlusRNG, mState[0]); - } - static size_t offsetOfState1() { - return offsetof(XorShift128PlusRNG, mState[1]); - } -}; - -} // namespace non_crypto -} // namespace mozilla - -#endif // mozilla_XorShift128Plus_h diff --git a/android/armeabi/include/spidermonkey/mozilla/double-conversion.h b/android/armeabi/include/spidermonkey/mozilla/double-conversion.h deleted file mode 100644 index 957575cf..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/double-conversion.h +++ /dev/null @@ -1,538 +0,0 @@ -// Copyright 2012 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ -#define DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ - -#include "mozilla/Types.h" -#include "utils.h" - -namespace double_conversion { - -class DoubleToStringConverter { - public: - // When calling ToFixed with a double > 10^kMaxFixedDigitsBeforePoint - // or a requested_digits parameter > kMaxFixedDigitsAfterPoint then the - // function returns false. - static const int kMaxFixedDigitsBeforePoint = 60; - static const int kMaxFixedDigitsAfterPoint = 60; - - // When calling ToExponential with a requested_digits - // parameter > kMaxExponentialDigits then the function returns false. - static const int kMaxExponentialDigits = 120; - - // When calling ToPrecision with a requested_digits - // parameter < kMinPrecisionDigits or requested_digits > kMaxPrecisionDigits - // then the function returns false. - static const int kMinPrecisionDigits = 1; - static const int kMaxPrecisionDigits = 120; - - enum Flags { - NO_FLAGS = 0, - EMIT_POSITIVE_EXPONENT_SIGN = 1, - EMIT_TRAILING_DECIMAL_POINT = 2, - EMIT_TRAILING_ZERO_AFTER_POINT = 4, - UNIQUE_ZERO = 8 - }; - - // Flags should be a bit-or combination of the possible Flags-enum. - // - NO_FLAGS: no special flags. - // - EMIT_POSITIVE_EXPONENT_SIGN: when the number is converted into exponent - // form, emits a '+' for positive exponents. Example: 1.2e+2. - // - EMIT_TRAILING_DECIMAL_POINT: when the input number is an integer and is - // converted into decimal format then a trailing decimal point is appended. - // Example: 2345.0 is converted to "2345.". - // - EMIT_TRAILING_ZERO_AFTER_POINT: in addition to a trailing decimal point - // emits a trailing '0'-character. This flag requires the - // EXMIT_TRAILING_DECIMAL_POINT flag. - // Example: 2345.0 is converted to "2345.0". - // - UNIQUE_ZERO: "-0.0" is converted to "0.0". - // - // Infinity symbol and nan_symbol provide the string representation for these - // special values. If the string is NULL and the special value is encountered - // then the conversion functions return false. - // - // The exponent_character is used in exponential representations. It is - // usually 'e' or 'E'. - // - // When converting to the shortest representation the converter will - // represent input numbers in decimal format if they are in the interval - // [10^decimal_in_shortest_low; 10^decimal_in_shortest_high[ - // (lower boundary included, greater boundary excluded). - // Example: with decimal_in_shortest_low = -6 and - // decimal_in_shortest_high = 21: - // ToShortest(0.000001) -> "0.000001" - // ToShortest(0.0000001) -> "1e-7" - // ToShortest(111111111111111111111.0) -> "111111111111111110000" - // ToShortest(100000000000000000000.0) -> "100000000000000000000" - // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21" - // - // When converting to precision mode the converter may add - // max_leading_padding_zeroes before returning the number in exponential - // format. - // Example with max_leading_padding_zeroes_in_precision_mode = 6. - // ToPrecision(0.0000012345, 2) -> "0.0000012" - // ToPrecision(0.00000012345, 2) -> "1.2e-7" - // Similarily the converter may add up to - // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid - // returning an exponential representation. A zero added by the - // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit. - // Examples for max_trailing_padding_zeroes_in_precision_mode = 1: - // ToPrecision(230.0, 2) -> "230" - // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT. - // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT. - DoubleToStringConverter(int flags, - const char* infinity_symbol, - const char* nan_symbol, - char exponent_character, - int decimal_in_shortest_low, - int decimal_in_shortest_high, - int max_leading_padding_zeroes_in_precision_mode, - int max_trailing_padding_zeroes_in_precision_mode) - : flags_(flags), - infinity_symbol_(infinity_symbol), - nan_symbol_(nan_symbol), - exponent_character_(exponent_character), - decimal_in_shortest_low_(decimal_in_shortest_low), - decimal_in_shortest_high_(decimal_in_shortest_high), - max_leading_padding_zeroes_in_precision_mode_( - max_leading_padding_zeroes_in_precision_mode), - max_trailing_padding_zeroes_in_precision_mode_( - max_trailing_padding_zeroes_in_precision_mode) { - // When 'trailing zero after the point' is set, then 'trailing point' - // must be set too. - ASSERT(((flags & EMIT_TRAILING_DECIMAL_POINT) != 0) || - !((flags & EMIT_TRAILING_ZERO_AFTER_POINT) != 0)); - } - - // Returns a converter following the EcmaScript specification. - static MFBT_API const DoubleToStringConverter& EcmaScriptConverter(); - - // Computes the shortest string of digits that correctly represent the input - // number. Depending on decimal_in_shortest_low and decimal_in_shortest_high - // (see constructor) it then either returns a decimal representation, or an - // exponential representation. - // Example with decimal_in_shortest_low = -6, - // decimal_in_shortest_high = 21, - // EMIT_POSITIVE_EXPONENT_SIGN activated, and - // EMIT_TRAILING_DECIMAL_POINT deactived: - // ToShortest(0.000001) -> "0.000001" - // ToShortest(0.0000001) -> "1e-7" - // ToShortest(111111111111111111111.0) -> "111111111111111110000" - // ToShortest(100000000000000000000.0) -> "100000000000000000000" - // ToShortest(1111111111111111111111.0) -> "1.1111111111111111e+21" - // - // Note: the conversion may round the output if the returned string - // is accurate enough to uniquely identify the input-number. - // For example the most precise representation of the double 9e59 equals - // "899999999999999918767229449717619953810131273674690656206848", but - // the converter will return the shorter (but still correct) "9e59". - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except when the input value is special and no infinity_symbol or - // nan_symbol has been given to the constructor. - bool ToShortest(double value, StringBuilder* result_builder) const { - return ToShortestIeeeNumber(value, result_builder, SHORTEST); - } - - // Same as ToShortest, but for single-precision floats. - bool ToShortestSingle(float value, StringBuilder* result_builder) const { - return ToShortestIeeeNumber(value, result_builder, SHORTEST_SINGLE); - } - - - // Computes a decimal representation with a fixed number of digits after the - // decimal point. The last emitted digit is rounded. - // - // Examples: - // ToFixed(3.12, 1) -> "3.1" - // ToFixed(3.1415, 3) -> "3.142" - // ToFixed(1234.56789, 4) -> "1234.5679" - // ToFixed(1.23, 5) -> "1.23000" - // ToFixed(0.1, 4) -> "0.1000" - // ToFixed(1e30, 2) -> "1000000000000000019884624838656.00" - // ToFixed(0.1, 30) -> "0.100000000000000005551115123126" - // ToFixed(0.1, 17) -> "0.10000000000000001" - // - // If requested_digits equals 0, then the tail of the result depends on - // the EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT. - // Examples, for requested_digits == 0, - // let EMIT_TRAILING_DECIMAL_POINT and EMIT_TRAILING_ZERO_AFTER_POINT be - // - false and false: then 123.45 -> 123 - // 0.678 -> 1 - // - true and false: then 123.45 -> 123. - // 0.678 -> 1. - // - true and true: then 123.45 -> 123.0 - // 0.678 -> 1.0 - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except for the following cases: - // - the input value is special and no infinity_symbol or nan_symbol has - // been provided to the constructor, - // - 'value' > 10^kMaxFixedDigitsBeforePoint, or - // - 'requested_digits' > kMaxFixedDigitsAfterPoint. - // The last two conditions imply that the result will never contain more than - // 1 + kMaxFixedDigitsBeforePoint + 1 + kMaxFixedDigitsAfterPoint characters - // (one additional character for the sign, and one for the decimal point). - MFBT_API bool ToFixed(double value, - int requested_digits, - StringBuilder* result_builder) const; - - // Computes a representation in exponential format with requested_digits - // after the decimal point. The last emitted digit is rounded. - // If requested_digits equals -1, then the shortest exponential representation - // is computed. - // - // Examples with EMIT_POSITIVE_EXPONENT_SIGN deactivated, and - // exponent_character set to 'e'. - // ToExponential(3.12, 1) -> "3.1e0" - // ToExponential(5.0, 3) -> "5.000e0" - // ToExponential(0.001, 2) -> "1.00e-3" - // ToExponential(3.1415, -1) -> "3.1415e0" - // ToExponential(3.1415, 4) -> "3.1415e0" - // ToExponential(3.1415, 3) -> "3.142e0" - // ToExponential(123456789000000, 3) -> "1.235e14" - // ToExponential(1000000000000000019884624838656.0, -1) -> "1e30" - // ToExponential(1000000000000000019884624838656.0, 32) -> - // "1.00000000000000001988462483865600e30" - // ToExponential(1234, 0) -> "1e3" - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except for the following cases: - // - the input value is special and no infinity_symbol or nan_symbol has - // been provided to the constructor, - // - 'requested_digits' > kMaxExponentialDigits. - // The last condition implies that the result will never contain more than - // kMaxExponentialDigits + 8 characters (the sign, the digit before the - // decimal point, the decimal point, the exponent character, the - // exponent's sign, and at most 3 exponent digits). - MFBT_API bool ToExponential(double value, - int requested_digits, - StringBuilder* result_builder) const; - - // Computes 'precision' leading digits of the given 'value' and returns them - // either in exponential or decimal format, depending on - // max_{leading|trailing}_padding_zeroes_in_precision_mode (given to the - // constructor). - // The last computed digit is rounded. - // - // Example with max_leading_padding_zeroes_in_precision_mode = 6. - // ToPrecision(0.0000012345, 2) -> "0.0000012" - // ToPrecision(0.00000012345, 2) -> "1.2e-7" - // Similarily the converter may add up to - // max_trailing_padding_zeroes_in_precision_mode in precision mode to avoid - // returning an exponential representation. A zero added by the - // EMIT_TRAILING_ZERO_AFTER_POINT flag is counted for this limit. - // Examples for max_trailing_padding_zeroes_in_precision_mode = 1: - // ToPrecision(230.0, 2) -> "230" - // ToPrecision(230.0, 2) -> "230." with EMIT_TRAILING_DECIMAL_POINT. - // ToPrecision(230.0, 2) -> "2.3e2" with EMIT_TRAILING_ZERO_AFTER_POINT. - // Examples for max_trailing_padding_zeroes_in_precision_mode = 3, and no - // EMIT_TRAILING_ZERO_AFTER_POINT: - // ToPrecision(123450.0, 6) -> "123450" - // ToPrecision(123450.0, 5) -> "123450" - // ToPrecision(123450.0, 4) -> "123500" - // ToPrecision(123450.0, 3) -> "123000" - // ToPrecision(123450.0, 2) -> "1.2e5" - // - // Returns true if the conversion succeeds. The conversion always succeeds - // except for the following cases: - // - the input value is special and no infinity_symbol or nan_symbol has - // been provided to the constructor, - // - precision < kMinPericisionDigits - // - precision > kMaxPrecisionDigits - // The last condition implies that the result will never contain more than - // kMaxPrecisionDigits + 7 characters (the sign, the decimal point, the - // exponent character, the exponent's sign, and at most 3 exponent digits). - MFBT_API bool ToPrecision(double value, - int precision, - bool* used_exponential_notation, - StringBuilder* result_builder) const; - - enum DtoaMode { - // Produce the shortest correct representation. - // For example the output of 0.299999999999999988897 is (the less accurate - // but correct) 0.3. - SHORTEST, - // Same as SHORTEST, but for single-precision floats. - SHORTEST_SINGLE, - // Produce a fixed number of digits after the decimal point. - // For instance fixed(0.1, 4) becomes 0.1000 - // If the input number is big, the output will be big. - FIXED, - // Fixed number of digits (independent of the decimal point). - PRECISION - }; - - // The maximal number of digits that are needed to emit a double in base 10. - // A higher precision can be achieved by using more digits, but the shortest - // accurate representation of any double will never use more digits than - // kBase10MaximalLength. - // Note that DoubleToAscii null-terminates its input. So the given buffer - // should be at least kBase10MaximalLength + 1 characters long. - static const MFBT_DATA int kBase10MaximalLength = 17; - - // Converts the given double 'v' to ascii. 'v' must not be NaN, +Infinity, or - // -Infinity. In SHORTEST_SINGLE-mode this restriction also applies to 'v' - // after it has been casted to a single-precision float. That is, in this - // mode static_cast<float>(v) must not be NaN, +Infinity or -Infinity. - // - // The result should be interpreted as buffer * 10^(point-length). - // - // The output depends on the given mode: - // - SHORTEST: produce the least amount of digits for which the internal - // identity requirement is still satisfied. If the digits are printed - // (together with the correct exponent) then reading this number will give - // 'v' again. The buffer will choose the representation that is closest to - // 'v'. If there are two at the same distance, than the one farther away - // from 0 is chosen (halfway cases - ending with 5 - are rounded up). - // In this mode the 'requested_digits' parameter is ignored. - // - SHORTEST_SINGLE: same as SHORTEST but with single-precision. - // - FIXED: produces digits necessary to print a given number with - // 'requested_digits' digits after the decimal point. The produced digits - // might be too short in which case the caller has to fill the remainder - // with '0's. - // Example: toFixed(0.001, 5) is allowed to return buffer="1", point=-2. - // Halfway cases are rounded towards +/-Infinity (away from 0). The call - // toFixed(0.15, 2) thus returns buffer="2", point=0. - // The returned buffer may contain digits that would be truncated from the - // shortest representation of the input. - // - PRECISION: produces 'requested_digits' where the first digit is not '0'. - // Even though the length of produced digits usually equals - // 'requested_digits', the function is allowed to return fewer digits, in - // which case the caller has to fill the missing digits with '0's. - // Halfway cases are again rounded away from 0. - // DoubleToAscii expects the given buffer to be big enough to hold all - // digits and a terminating null-character. In SHORTEST-mode it expects a - // buffer of at least kBase10MaximalLength + 1. In all other modes the - // requested_digits parameter and the padding-zeroes limit the size of the - // output. Don't forget the decimal point, the exponent character and the - // terminating null-character when computing the maximal output size. - // The given length is only used in debug mode to ensure the buffer is big - // enough. - static MFBT_API void DoubleToAscii(double v, - DtoaMode mode, - int requested_digits, - char* buffer, - int buffer_length, - bool* sign, - int* length, - int* point); - - private: - // Implementation for ToShortest and ToShortestSingle. - MFBT_API bool ToShortestIeeeNumber(double value, - StringBuilder* result_builder, - DtoaMode mode) const; - - // If the value is a special value (NaN or Infinity) constructs the - // corresponding string using the configured infinity/nan-symbol. - // If either of them is NULL or the value is not special then the - // function returns false. - MFBT_API bool HandleSpecialValues(double value, StringBuilder* result_builder) const; - // Constructs an exponential representation (i.e. 1.234e56). - // The given exponent assumes a decimal point after the first decimal digit. - MFBT_API void CreateExponentialRepresentation(const char* decimal_digits, - int length, - int exponent, - StringBuilder* result_builder) const; - // Creates a decimal representation (i.e 1234.5678). - MFBT_API void CreateDecimalRepresentation(const char* decimal_digits, - int length, - int decimal_point, - int digits_after_point, - StringBuilder* result_builder) const; - - const int flags_; - const char* const infinity_symbol_; - const char* const nan_symbol_; - const char exponent_character_; - const int decimal_in_shortest_low_; - const int decimal_in_shortest_high_; - const int max_leading_padding_zeroes_in_precision_mode_; - const int max_trailing_padding_zeroes_in_precision_mode_; - - DISALLOW_IMPLICIT_CONSTRUCTORS(DoubleToStringConverter); -}; - - -class StringToDoubleConverter { - public: - // Enumeration for allowing octals and ignoring junk when converting - // strings to numbers. - enum Flags { - NO_FLAGS = 0, - ALLOW_HEX = 1, - ALLOW_OCTALS = 2, - ALLOW_TRAILING_JUNK = 4, - ALLOW_LEADING_SPACES = 8, - ALLOW_TRAILING_SPACES = 16, - ALLOW_SPACES_AFTER_SIGN = 32 - }; - - // Flags should be a bit-or combination of the possible Flags-enum. - // - NO_FLAGS: no special flags. - // - ALLOW_HEX: recognizes the prefix "0x". Hex numbers may only be integers. - // Ex: StringToDouble("0x1234") -> 4660.0 - // In StringToDouble("0x1234.56") the characters ".56" are trailing - // junk. The result of the call is hence dependent on - // the ALLOW_TRAILING_JUNK flag and/or the junk value. - // With this flag "0x" is a junk-string. Even with ALLOW_TRAILING_JUNK, - // the string will not be parsed as "0" followed by junk. - // - // - ALLOW_OCTALS: recognizes the prefix "0" for octals: - // If a sequence of octal digits starts with '0', then the number is - // read as octal integer. Octal numbers may only be integers. - // Ex: StringToDouble("01234") -> 668.0 - // StringToDouble("012349") -> 12349.0 // Not a sequence of octal - // // digits. - // In StringToDouble("01234.56") the characters ".56" are trailing - // junk. The result of the call is hence dependent on - // the ALLOW_TRAILING_JUNK flag and/or the junk value. - // In StringToDouble("01234e56") the characters "e56" are trailing - // junk, too. - // - ALLOW_TRAILING_JUNK: ignore trailing characters that are not part of - // a double literal. - // - ALLOW_LEADING_SPACES: skip over leading spaces. - // - ALLOW_TRAILING_SPACES: ignore trailing spaces. - // - ALLOW_SPACES_AFTER_SIGN: ignore spaces after the sign. - // Ex: StringToDouble("- 123.2") -> -123.2. - // StringToDouble("+ 123.2") -> 123.2 - // - // empty_string_value is returned when an empty string is given as input. - // If ALLOW_LEADING_SPACES or ALLOW_TRAILING_SPACES are set, then a string - // containing only spaces is converted to the 'empty_string_value', too. - // - // junk_string_value is returned when - // a) ALLOW_TRAILING_JUNK is not set, and a junk character (a character not - // part of a double-literal) is found. - // b) ALLOW_TRAILING_JUNK is set, but the string does not start with a - // double literal. - // - // infinity_symbol and nan_symbol are strings that are used to detect - // inputs that represent infinity and NaN. They can be null, in which case - // they are ignored. - // The conversion routine first reads any possible signs. Then it compares the - // following character of the input-string with the first character of - // the infinity, and nan-symbol. If either matches, the function assumes, that - // a match has been found, and expects the following input characters to match - // the remaining characters of the special-value symbol. - // This means that the following restrictions apply to special-value symbols: - // - they must not start with signs ('+', or '-'), - // - they must not have the same first character. - // - they must not start with digits. - // - // Examples: - // flags = ALLOW_HEX | ALLOW_TRAILING_JUNK, - // empty_string_value = 0.0, - // junk_string_value = NaN, - // infinity_symbol = "infinity", - // nan_symbol = "nan": - // StringToDouble("0x1234") -> 4660.0. - // StringToDouble("0x1234K") -> 4660.0. - // StringToDouble("") -> 0.0 // empty_string_value. - // StringToDouble(" ") -> NaN // junk_string_value. - // StringToDouble(" 1") -> NaN // junk_string_value. - // StringToDouble("0x") -> NaN // junk_string_value. - // StringToDouble("-123.45") -> -123.45. - // StringToDouble("--123.45") -> NaN // junk_string_value. - // StringToDouble("123e45") -> 123e45. - // StringToDouble("123E45") -> 123e45. - // StringToDouble("123e+45") -> 123e45. - // StringToDouble("123E-45") -> 123e-45. - // StringToDouble("123e") -> 123.0 // trailing junk ignored. - // StringToDouble("123e-") -> 123.0 // trailing junk ignored. - // StringToDouble("+NaN") -> NaN // NaN string literal. - // StringToDouble("-infinity") -> -inf. // infinity literal. - // StringToDouble("Infinity") -> NaN // junk_string_value. - // - // flags = ALLOW_OCTAL | ALLOW_LEADING_SPACES, - // empty_string_value = 0.0, - // junk_string_value = NaN, - // infinity_symbol = NULL, - // nan_symbol = NULL: - // StringToDouble("0x1234") -> NaN // junk_string_value. - // StringToDouble("01234") -> 668.0. - // StringToDouble("") -> 0.0 // empty_string_value. - // StringToDouble(" ") -> 0.0 // empty_string_value. - // StringToDouble(" 1") -> 1.0 - // StringToDouble("0x") -> NaN // junk_string_value. - // StringToDouble("0123e45") -> NaN // junk_string_value. - // StringToDouble("01239E45") -> 1239e45. - // StringToDouble("-infinity") -> NaN // junk_string_value. - // StringToDouble("NaN") -> NaN // junk_string_value. - StringToDoubleConverter(int flags, - double empty_string_value, - double junk_string_value, - const char* infinity_symbol, - const char* nan_symbol) - : flags_(flags), - empty_string_value_(empty_string_value), - junk_string_value_(junk_string_value), - infinity_symbol_(infinity_symbol), - nan_symbol_(nan_symbol) { - } - - // Performs the conversion. - // The output parameter 'processed_characters_count' is set to the number - // of characters that have been processed to read the number. - // Spaces than are processed with ALLOW_{LEADING|TRAILING}_SPACES are included - // in the 'processed_characters_count'. Trailing junk is never included. - double StringToDouble(const char* buffer, - int length, - int* processed_characters_count) const { - return StringToIeee(buffer, length, processed_characters_count, true); - } - - // Same as StringToDouble but reads a float. - // Note that this is not equivalent to static_cast<float>(StringToDouble(...)) - // due to potential double-rounding. - float StringToFloat(const char* buffer, - int length, - int* processed_characters_count) const { - return static_cast<float>(StringToIeee(buffer, length, - processed_characters_count, false)); - } - - private: - const int flags_; - const double empty_string_value_; - const double junk_string_value_; - const char* const infinity_symbol_; - const char* const nan_symbol_; - - double StringToIeee(const char* buffer, - int length, - int* processed_characters_count, - bool read_as_double) const; - - DISALLOW_IMPLICIT_CONSTRUCTORS(StringToDoubleConverter); -}; - -} // namespace double_conversion - -#endif // DOUBLE_CONVERSION_DOUBLE_CONVERSION_H_ diff --git a/android/armeabi/include/spidermonkey/mozilla/fallible.h b/android/armeabi/include/spidermonkey/mozilla/fallible.h deleted file mode 100644 index c028360b..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/fallible.h +++ /dev/null @@ -1,68 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_fallible_h -#define mozilla_fallible_h - -#if defined(__cplusplus) - -/* Explicit fallible allocation - * - * Memory allocation (normally) defaults to abort in case of failed - * allocation. That is, it never returns NULL, and crashes instead. - * - * Code can explicitely request for fallible memory allocation thanks - * to the declarations below. - * - * The typical use of the mozilla::fallible const is with placement new, - * like the following: - * - * foo = new (mozilla::fallible) Foo(); - * - * The following forms, or derivatives, are also possible but deprecated: - * - * foo = new ((mozilla::fallible_t())) Foo(); - * - * const mozilla::fallible_t fallible = mozilla::fallible_t(); - * bar = new (f) Bar(); - * - * It is also possible to declare method overloads with fallible allocation - * alternatives, like so: - * - * class Foo { - * public: - * void Method(void *); - * void Method(void *, const mozilla::fallible_t&); - * }; - * - * Foo foo; - * foo.Method(nullptr, mozilla::fallible); - * - * If that last method call is in a method that itself takes a const - * fallible_t& argument, it is recommended to propagate that argument - * instead of using mozilla::fallible: - * - * void Func(Foo &foo, const mozilla::fallible_t& aFallible) { - * foo.Method(nullptr, aFallible); - * } - * - */ -namespace mozilla { - -struct fallible_t { }; - -/* This symbol is kept unexported, such that in corner cases where the - * compiler can't remove its use (essentially, cross compilation-unit - * calls), the smallest machine code is used. - * Depending how the linker packs symbols, it will consume between 1 and - * 8 bytes of read-only data in each executable or shared library, but - * only in those where it's actually not optimized out by the compiler. - */ -extern const fallible_t fallible; - -} // namespace mozilla - -#endif - -#endif // mozilla_fallible_h diff --git a/android/armeabi/include/spidermonkey/mozilla/mozalloc.h b/android/armeabi/include/spidermonkey/mozilla/mozalloc.h deleted file mode 100644 index f7ddb7e6..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/mozalloc.h +++ /dev/null @@ -1,361 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 et : - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_mozalloc_h -#define mozilla_mozalloc_h - -/* - * https://bugzilla.mozilla.org/show_bug.cgi?id=427099 - */ - -#if defined(__cplusplus) -# include <new> -// Since libstdc++ 6, including the C headers (e.g. stdlib.h) instead of the -// corresponding C++ header (e.g. cstdlib) can cause confusion in C++ code -// using things defined there. Specifically, with stdlib.h, the use of abs() -// in gfx/graphite2/src/inc/UtfCodec.h somehow ends up picking the wrong abs() -# include <cstdlib> -# include <cstring> -#else -# include <stdlib.h> -# include <string.h> -#endif - -#if defined(__cplusplus) -#include "mozilla/fallible.h" -#include "mozilla/mozalloc_abort.h" -#include "mozilla/TemplateLib.h" -#endif -#include "mozilla/Attributes.h" -#include "mozilla/Types.h" - -#define MOZALLOC_HAVE_XMALLOC - -#if defined(MOZ_ALWAYS_INLINE_EVEN_DEBUG) -# define MOZALLOC_INLINE MOZ_ALWAYS_INLINE_EVEN_DEBUG -#elif defined(HAVE_FORCEINLINE) -# define MOZALLOC_INLINE __forceinline -#else -# define MOZALLOC_INLINE inline -#endif - -/* Workaround build problem with Sun Studio 12 */ -#if defined(__SUNPRO_C) || defined(__SUNPRO_CC) -# undef MOZ_MUST_USE -# define MOZ_MUST_USE -# undef MOZ_ALLOCATOR -# define MOZ_ALLOCATOR -#endif - -#if defined(__cplusplus) -extern "C" { -#endif /* ifdef __cplusplus */ - -/* - * We need to use malloc_impl and free_impl in this file when they are - * defined, because of how mozglue.dll is linked on Windows, where using - * malloc/free would end up using the symbols from the MSVCRT instead of - * ours. - */ -#ifndef free_impl -#define free_impl free -#define free_impl_ -#endif -#ifndef malloc_impl -#define malloc_impl malloc -#define malloc_impl_ -#endif - -/* - * Each declaration below is analogous to a "standard" allocation - * function, except that the out-of-memory handling is made explicit. - * The |moz_x| versions will never return a NULL pointer; if memory - * is exhausted, they abort. The |moz_| versions may return NULL - * pointers if memory is exhausted: their return value must be checked. - * - * All these allocation functions are *guaranteed* to return a pointer - * to memory allocated in such a way that that memory can be freed by - * passing that pointer to |free()|. - */ - -MFBT_API void* moz_xmalloc(size_t size) - MOZ_ALLOCATOR; - -MFBT_API void* moz_xcalloc(size_t nmemb, size_t size) - MOZ_ALLOCATOR; - -MFBT_API void* moz_xrealloc(void* ptr, size_t size) - MOZ_ALLOCATOR; - -MFBT_API char* moz_xstrdup(const char* str) - MOZ_ALLOCATOR; - -MFBT_API size_t moz_malloc_usable_size(void *ptr); - -MFBT_API size_t moz_malloc_size_of(const void *ptr); - -#if defined(HAVE_STRNDUP) -MFBT_API char* moz_xstrndup(const char* str, size_t strsize) - MOZ_ALLOCATOR; -#endif /* if defined(HAVE_STRNDUP) */ - - -#if defined(HAVE_POSIX_MEMALIGN) -MFBT_API MOZ_MUST_USE -int moz_xposix_memalign(void **ptr, size_t alignment, size_t size); - -MFBT_API MOZ_MUST_USE -int moz_posix_memalign(void **ptr, size_t alignment, size_t size); -#endif /* if defined(HAVE_POSIX_MEMALIGN) */ - - -#if defined(HAVE_MEMALIGN) -MFBT_API void* moz_xmemalign(size_t boundary, size_t size) - MOZ_ALLOCATOR; -#endif /* if defined(HAVE_MEMALIGN) */ - - -#if defined(HAVE_VALLOC) -MFBT_API void* moz_xvalloc(size_t size) - MOZ_ALLOCATOR; -#endif /* if defined(HAVE_VALLOC) */ - - -#ifdef __cplusplus -} /* extern "C" */ -#endif /* ifdef __cplusplus */ - - -#ifdef __cplusplus - -/* - * We implement the default operators new/delete as part of - * libmozalloc, replacing their definitions in libstdc++. The - * operator new* definitions in libmozalloc will never return a NULL - * pointer. - * - * Each operator new immediately below returns a pointer to memory - * that can be delete'd by any of - * - * (1) the matching infallible operator delete immediately below - * (2) the matching "fallible" operator delete further below - * (3) the matching system |operator delete(void*, std::nothrow)| - * (4) the matching system |operator delete(void*) throw(std::bad_alloc)| - * - * NB: these are declared |throw(std::bad_alloc)|, though they will never - * throw that exception. This declaration is consistent with the rule - * that |::operator new() throw(std::bad_alloc)| will never return NULL. - */ - -/* NB: This is defined just to silence vacuous warnings about symbol - * visibility on OS X/gcc. These symbols are force-inline and not - * exported. */ -#if defined(XP_MACOSX) -# define MOZALLOC_EXPORT_NEW MFBT_API -#else -# define MOZALLOC_EXPORT_NEW -#endif - -#if defined(ANDROID) -/* - * It's important to always specify 'throw()' in GCC because it's used to tell - * GCC that 'new' may return null. That makes GCC null-check the result before - * potentially initializing the memory to zero. - * Also, the Android minimalistic headers don't include std::bad_alloc. - */ -#define MOZALLOC_THROW_IF_HAS_EXCEPTIONS throw() -#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS -#elif defined(_MSC_VER) -/* - * Suppress build warning spam (bug 578546). - */ -#define MOZALLOC_THROW_IF_HAS_EXCEPTIONS -#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS -#else -#define MOZALLOC_THROW_IF_HAS_EXCEPTIONS throw() -#define MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS throw(std::bad_alloc) -#endif - -#define MOZALLOC_THROW_BAD_ALLOC MOZALLOC_THROW_BAD_ALLOC_IF_HAS_EXCEPTIONS - -MOZALLOC_EXPORT_NEW -#if defined(__GNUC__) && !defined(__clang__) && defined(__SANITIZE_ADDRESS__) -/* gcc's asan somehow doesn't like always_inline on this function. */ -__attribute__((gnu_inline)) inline -#else -MOZALLOC_INLINE -#endif -void* operator new(size_t size) MOZALLOC_THROW_BAD_ALLOC -{ - return moz_xmalloc(size); -} - -MOZALLOC_EXPORT_NEW MOZALLOC_INLINE -void* operator new(size_t size, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS -{ - return malloc_impl(size); -} - -MOZALLOC_EXPORT_NEW MOZALLOC_INLINE -void* operator new[](size_t size) MOZALLOC_THROW_BAD_ALLOC -{ - return moz_xmalloc(size); -} - -MOZALLOC_EXPORT_NEW MOZALLOC_INLINE -void* operator new[](size_t size, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS -{ - return malloc_impl(size); -} - -MOZALLOC_EXPORT_NEW MOZALLOC_INLINE -void operator delete(void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS -{ - return free_impl(ptr); -} - -MOZALLOC_EXPORT_NEW MOZALLOC_INLINE -void operator delete(void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS -{ - return free_impl(ptr); -} - -MOZALLOC_EXPORT_NEW MOZALLOC_INLINE -void operator delete[](void* ptr) MOZALLOC_THROW_IF_HAS_EXCEPTIONS -{ - return free_impl(ptr); -} - -MOZALLOC_EXPORT_NEW MOZALLOC_INLINE -void operator delete[](void* ptr, const std::nothrow_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS -{ - return free_impl(ptr); -} - - -/* - * We also add a new allocator variant: "fallible operator new." - * Unlike libmozalloc's implementations of the standard nofail - * allocators, this allocator is allowed to return NULL. It can be used - * as follows - * - * Foo* f = new (mozilla::fallible) Foo(...); - * - * operator delete(fallible) is defined for completeness only. - * - * Each operator new below returns a pointer to memory that can be - * delete'd by any of - * - * (1) the matching "fallible" operator delete below - * (2) the matching infallible operator delete above - * (3) the matching system |operator delete(void*, std::nothrow)| - * (4) the matching system |operator delete(void*) throw(std::bad_alloc)| - */ - -MOZALLOC_INLINE -void* operator new(size_t size, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS -{ - return malloc_impl(size); -} - -MOZALLOC_INLINE -void* operator new[](size_t size, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS -{ - return malloc_impl(size); -} - -MOZALLOC_INLINE -void operator delete(void* ptr, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS -{ - free_impl(ptr); -} - -MOZALLOC_INLINE -void operator delete[](void* ptr, const mozilla::fallible_t&) MOZALLOC_THROW_IF_HAS_EXCEPTIONS -{ - free_impl(ptr); -} - - -/* - * This policy is identical to MallocAllocPolicy, except it uses - * moz_xmalloc/moz_xcalloc/moz_xrealloc instead of - * malloc/calloc/realloc. - */ -class InfallibleAllocPolicy -{ -public: - template <typename T> - T* maybe_pod_malloc(size_t aNumElems) - { - return pod_malloc<T>(aNumElems); - } - - template <typename T> - T* maybe_pod_calloc(size_t aNumElems) - { - return pod_calloc<T>(aNumElems); - } - - template <typename T> - T* maybe_pod_realloc(T* aPtr, size_t aOldSize, size_t aNewSize) - { - return pod_realloc<T>(aPtr, aOldSize, aNewSize); - } - - template <typename T> - T* pod_malloc(size_t aNumElems) - { - if (aNumElems & mozilla::tl::MulOverflowMask<sizeof(T)>::value) { - reportAllocOverflow(); - } - return static_cast<T*>(moz_xmalloc(aNumElems * sizeof(T))); - } - - template <typename T> - T* pod_calloc(size_t aNumElems) - { - return static_cast<T*>(moz_xcalloc(aNumElems, sizeof(T))); - } - - template <typename T> - T* pod_realloc(T* aPtr, size_t aOldSize, size_t aNewSize) - { - if (aNewSize & mozilla::tl::MulOverflowMask<sizeof(T)>::value) { - reportAllocOverflow(); - } - return static_cast<T*>(moz_xrealloc(aPtr, aNewSize * sizeof(T))); - } - - void free_(void* aPtr) - { - free_impl(aPtr); - } - - void reportAllocOverflow() const - { - mozalloc_abort("alloc overflow"); - } - - bool checkSimulatedOOM() const - { - return true; - } -}; - -#endif /* ifdef __cplusplus */ - -#ifdef malloc_impl_ -#undef malloc_impl_ -#undef malloc_impl -#endif -#ifdef free_impl_ -#undef free_impl_ -#undef free_impl -#endif - -#endif /* ifndef mozilla_mozalloc_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/mozalloc_abort.h b/android/armeabi/include/spidermonkey/mozilla/mozalloc_abort.h deleted file mode 100644 index 065cebcb..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/mozalloc_abort.h +++ /dev/null @@ -1,28 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 et : - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_mozalloc_abort_h -#define mozilla_mozalloc_abort_h - -#include "mozilla/Attributes.h" -#include "mozilla/Types.h" - -/** - * Terminate this process in such a way that breakpad is triggered, if - * at all possible. - * - * Note: MOZ_NORETURN seems to break crash stacks on ARM, so we don't - * use that annotation there. - */ -MFBT_API -#if !defined(__arm__) - MOZ_NORETURN -#endif - void mozalloc_abort(const char* const msg); - - -#endif /* ifndef mozilla_mozalloc_abort_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/mozalloc_oom.h b/android/armeabi/include/spidermonkey/mozilla/mozalloc_oom.h deleted file mode 100644 index 35bb9acc..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/mozalloc_oom.h +++ /dev/null @@ -1,31 +0,0 @@ -/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * vim: sw=4 ts=4 et : - */ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozilla_mozalloc_oom_h -#define mozilla_mozalloc_oom_h - -#include "mozalloc.h" - -/** - * Called when memory is critically low. Returns iff it was able to - * remedy the critical memory situation; if not, it will abort(). - */ -MFBT_API void mozalloc_handle_oom(size_t requestedSize); - -/** - * Called by embedders (specifically Mozilla breakpad) which wants to be - * notified of an intentional abort, to annotate any crash report with - * the size of the allocation on which we aborted. - */ -typedef void (*mozalloc_oom_abort_handler)(size_t size); -MFBT_API void mozalloc_set_oom_abort_handler(mozalloc_oom_abort_handler handler); - -/* TODO: functions to query system memory usage and register - * critical-memory handlers. */ - - -#endif /* ifndef mozilla_mozalloc_oom_h */ diff --git a/android/armeabi/include/spidermonkey/mozilla/utils.h b/android/armeabi/include/spidermonkey/mozilla/utils.h deleted file mode 100644 index 15dd4bfb..00000000 --- a/android/armeabi/include/spidermonkey/mozilla/utils.h +++ /dev/null @@ -1,298 +0,0 @@ -// Copyright 2010 the V8 project authors. All rights reserved. -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are -// met: -// -// * Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// * Redistributions in binary form must reproduce the above -// copyright notice, this list of conditions and the following -// disclaimer in the documentation and/or other materials provided -// with the distribution. -// * Neither the name of Google Inc. nor the names of its -// contributors may be used to endorse or promote products derived -// from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 DOUBLE_CONVERSION_UTILS_H_ -#define DOUBLE_CONVERSION_UTILS_H_ - -#include <stdlib.h> -#include <string.h> - -#include "mozilla/Assertions.h" -#ifndef ASSERT -#define ASSERT(condition) MOZ_ASSERT(condition) -#endif -#ifndef UNIMPLEMENTED -#define UNIMPLEMENTED() MOZ_CRASH() -#endif -#ifndef UNREACHABLE -#define UNREACHABLE() MOZ_CRASH() -#endif - -// Double operations detection based on target architecture. -// Linux uses a 80bit wide floating point stack on x86. This induces double -// rounding, which in turn leads to wrong results. -// An easy way to test if the floating-point operations are correct is to -// evaluate: 89255.0/1e22. If the floating-point stack is 64 bits wide then -// the result is equal to 89255e-22. -// The best way to test this, is to create a division-function and to compare -// the output of the division with the expected result. (Inlining must be -// disabled.) -// On Linux,x86 89255e-22 != Div_double(89255.0/1e22) -#if defined(_M_X64) || defined(__x86_64__) || \ - defined(__ARMEL__) || defined(__avr32__) || \ - defined(__hppa__) || defined(__ia64__) || \ - defined(__mips__) || \ - defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) || \ - defined(__sparc__) || defined(__sparc) || defined(__s390__) || \ - defined(__SH4__) || defined(__alpha__) || \ - defined(_MIPS_ARCH_MIPS32R2) || \ - defined(__AARCH64EL__) || defined(__aarch64__) -#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 -#elif defined(_M_IX86) || defined(__i386__) || defined(__i386) -#if defined(_WIN32) -// Windows uses a 64bit wide floating point stack. -#define DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS 1 -#else -#undef DOUBLE_CONVERSION_CORRECT_DOUBLE_OPERATIONS -#endif // _WIN32 -#else -#error Target architecture was not detected as supported by Double-Conversion. -#endif - - -#include <stdint.h> - -// The following macro works on both 32 and 64-bit platforms. -// Usage: instead of writing 0x1234567890123456 -// write UINT64_2PART_C(0x12345678,90123456); -#define UINT64_2PART_C(a, b) (((static_cast<uint64_t>(a) << 32) + 0x##b##u)) - - -// The expression ARRAY_SIZE(a) is a compile-time constant of type -// size_t which represents the number of elements of the given -// array. You should only use ARRAY_SIZE on statically allocated -// arrays. -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(a) \ - ((sizeof(a) / sizeof(*(a))) / \ - static_cast<size_t>(!(sizeof(a) % sizeof(*(a))))) -#endif - -// A macro to disallow the evil copy constructor and operator= functions -// This should be used in the private: declarations for a class -#ifndef DISALLOW_COPY_AND_ASSIGN -#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ - TypeName(const TypeName&); \ - void operator=(const TypeName&) -#endif - -// A macro to disallow all the implicit constructors, namely the -// default constructor, copy constructor and operator= functions. -// -// This should be used in the private: declarations for a class -// that wants to prevent anyone from instantiating it. This is -// especially useful for classes containing only static methods. -#ifndef DISALLOW_IMPLICIT_CONSTRUCTORS -#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName) \ - TypeName(); \ - DISALLOW_COPY_AND_ASSIGN(TypeName) -#endif - -namespace double_conversion { - -static const int kCharSize = sizeof(char); - -// Returns the maximum of the two parameters. -template <typename T> -static T Max(T a, T b) { - return a < b ? b : a; -} - - -// Returns the minimum of the two parameters. -template <typename T> -static T Min(T a, T b) { - return a < b ? a : b; -} - - -inline int StrLength(const char* string) { - size_t length = strlen(string); - ASSERT(length == static_cast<size_t>(static_cast<int>(length))); - return static_cast<int>(length); -} - -// This is a simplified version of V8's Vector class. -template <typename T> -class Vector { - public: - Vector() : start_(NULL), length_(0) {} - Vector(T* data, int len) : start_(data), length_(len) { - ASSERT(len == 0 || (len > 0 && data != NULL)); - } - - // Returns a vector using the same backing storage as this one, - // spanning from and including 'from', to but not including 'to'. - Vector<T> SubVector(int from, int to) { - ASSERT(to <= length_); - ASSERT(from < to); - ASSERT(0 <= from); - return Vector<T>(start() + from, to - from); - } - - // Returns the length of the vector. - int length() const { return length_; } - - // Returns whether or not the vector is empty. - bool is_empty() const { return length_ == 0; } - - // Returns the pointer to the start of the data in the vector. - T* start() const { return start_; } - - // Access individual vector elements - checks bounds in debug mode. - T& operator[](int index) const { - ASSERT(0 <= index && index < length_); - return start_[index]; - } - - T& first() { return start_[0]; } - - T& last() { return start_[length_ - 1]; } - - private: - T* start_; - int length_; -}; - - -// Helper class for building result strings in a character buffer. The -// purpose of the class is to use safe operations that checks the -// buffer bounds on all operations in debug mode. -class StringBuilder { - public: - StringBuilder(char* buffer, int buffer_size) - : buffer_(buffer, buffer_size), position_(0) { } - - ~StringBuilder() { if (!is_finalized()) Finalize(); } - - int size() const { return buffer_.length(); } - - // Get the current position in the builder. - int position() const { - ASSERT(!is_finalized()); - return position_; - } - - // Reset the position. - void Reset() { position_ = 0; } - - // Add a single character to the builder. It is not allowed to add - // 0-characters; use the Finalize() method to terminate the string - // instead. - void AddCharacter(char c) { - ASSERT(c != '\0'); - ASSERT(!is_finalized() && position_ < buffer_.length()); - buffer_[position_++] = c; - } - - // Add an entire string to the builder. Uses strlen() internally to - // compute the length of the input string. - void AddString(const char* s) { - AddSubstring(s, StrLength(s)); - } - - // Add the first 'n' characters of the given string 's' to the - // builder. The input string must have enough characters. - void AddSubstring(const char* s, int n) { - ASSERT(!is_finalized() && position_ + n < buffer_.length()); - ASSERT(static_cast<size_t>(n) <= strlen(s)); - memmove(&buffer_[position_], s, n * kCharSize); - position_ += n; - } - - - // Add character padding to the builder. If count is non-positive, - // nothing is added to the builder. - void AddPadding(char c, int count) { - for (int i = 0; i < count; i++) { - AddCharacter(c); - } - } - - // Finalize the string by 0-terminating it and returning the buffer. - char* Finalize() { - ASSERT(!is_finalized() && position_ < buffer_.length()); - buffer_[position_] = '\0'; - // Make sure nobody managed to add a 0-character to the - // buffer while building the string. - ASSERT(strlen(buffer_.start()) == static_cast<size_t>(position_)); - position_ = -1; - ASSERT(is_finalized()); - return buffer_.start(); - } - - private: - Vector<char> buffer_; - int position_; - - bool is_finalized() const { return position_ < 0; } - - DISALLOW_IMPLICIT_CONSTRUCTORS(StringBuilder); -}; - -// The type-based aliasing rule allows the compiler to assume that pointers of -// different types (for some definition of different) never alias each other. -// Thus the following code does not work: -// -// float f = foo(); -// int fbits = *(int*)(&f); -// -// The compiler 'knows' that the int pointer can't refer to f since the types -// don't match, so the compiler may cache f in a register, leaving random data -// in fbits. Using C++ style casts makes no difference, however a pointer to -// char data is assumed to alias any other pointer. This is the 'memcpy -// exception'. -// -// Bit_cast uses the memcpy exception to move the bits from a variable of one -// type of a variable of another type. Of course the end result is likely to -// be implementation dependent. Most compilers (gcc-4.2 and MSVC 2005) -// will completely optimize BitCast away. -// -// There is an additional use for BitCast. -// Recent gccs will warn when they see casts that may result in breakage due to -// the type-based aliasing rule. If you have checked that there is no breakage -// you can use BitCast to cast one pointer type to another. This confuses gcc -// enough that it can no longer see that you have cast one pointer type to -// another thus avoiding the warning. -template <class Dest, class Source> -inline Dest BitCast(const Source& source) { - static_assert(sizeof(Dest) == sizeof(Source), - "BitCast's source and destination types must be the same size"); - - Dest dest; - memmove(&dest, &source, sizeof(dest)); - return dest; -} - -template <class Dest, class Source> -inline Dest BitCast(Source* source) { - return BitCast<Dest>(reinterpret_cast<uintptr_t>(source)); -} - -} // namespace double_conversion - -#endif // DOUBLE_CONVERSION_UTILS_H_ diff --git a/android/armeabi/include/spidermonkey/mozmemory.h b/android/armeabi/include/spidermonkey/mozmemory.h deleted file mode 100644 index 84007fff..00000000 --- a/android/armeabi/include/spidermonkey/mozmemory.h +++ /dev/null @@ -1,91 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozmemory_h -#define mozmemory_h - -/* - * This header is meant to be used when the following functions are - * necessary: - * - malloc_good_size (used to be called je_malloc_usable_in_advance) - * - jemalloc_stats - * - jemalloc_purge_freed_pages - * - jemalloc_free_dirty_pages - */ - -#ifndef MOZ_MEMORY -# error Should not include mozmemory.h when MOZ_MEMORY is not set -#endif - -#include "mozmemory_wrap.h" -#include "mozilla/Attributes.h" -#include "mozilla/Types.h" -#include "jemalloc_types.h" - -MOZ_BEGIN_EXTERN_C - -/* - * On OSX, malloc/malloc.h contains the declaration for malloc_good_size, - * which will call back in jemalloc, through the zone allocator so just use it. - */ -#ifdef XP_DARWIN -# include <malloc/malloc.h> -#else -MOZ_MEMORY_API size_t malloc_good_size_impl(size_t size); - -/* Note: the MOZ_GLUE_IN_PROGRAM ifdef below is there to avoid -Werror turning - * the protective if into errors. MOZ_GLUE_IN_PROGRAM is what triggers MFBT_API - * to use weak imports. */ - -static inline size_t _malloc_good_size(size_t size) { -# if defined(MOZ_GLUE_IN_PROGRAM) && !defined(IMPL_MFBT) - if (!malloc_good_size) - return size; -# endif - return malloc_good_size_impl(size); -} - -# define malloc_good_size _malloc_good_size -#endif - -MOZ_JEMALLOC_API void jemalloc_stats(jemalloc_stats_t *stats); - -/* - * On some operating systems (Mac), we use madvise(MADV_FREE) to hand pages - * back to the operating system. On Mac, the operating system doesn't take - * this memory back immediately; instead, the OS takes it back only when the - * machine is running out of physical memory. - * - * This is great from the standpoint of efficiency, but it makes measuring our - * actual RSS difficult, because pages which we've MADV_FREE'd shouldn't count - * against our RSS. - * - * This function explicitly purges any MADV_FREE'd pages from physical memory, - * causing our reported RSS match the amount of memory we're actually using. - * - * Note that this call is expensive in two ways. First, it may be slow to - * execute, because it may make a number of slow syscalls to free memory. This - * function holds the big jemalloc locks, so basically all threads are blocked - * while this function runs. - * - * This function is also expensive in that the next time we go to access a page - * which we've just explicitly decommitted, the operating system has to attach - * to it a physical page! If we hadn't run this function, the OS would have - * less work to do. - * - * If MALLOC_DOUBLE_PURGE is not defined, this function does nothing. - */ -MOZ_JEMALLOC_API void jemalloc_purge_freed_pages(); - -/* - * Free all unused dirty pages in all arenas. Calling this function will slow - * down subsequent allocations so it is recommended to use it only when - * memory needs to be reclaimed at all costs (see bug 805855). This function - * provides functionality similar to mallctl("arenas.purge") in jemalloc 3. - */ -MOZ_JEMALLOC_API void jemalloc_free_dirty_pages(); - -MOZ_END_EXTERN_C - -#endif /* mozmemory_h */ diff --git a/android/armeabi/include/spidermonkey/mozmemory_wrap.h b/android/armeabi/include/spidermonkey/mozmemory_wrap.h deleted file mode 100644 index 066d5778..00000000 --- a/android/armeabi/include/spidermonkey/mozmemory_wrap.h +++ /dev/null @@ -1,219 +0,0 @@ -/* This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this file, - * You can obtain one at http://mozilla.org/MPL/2.0/. */ - -#ifndef mozmemory_wrap_h -#define mozmemory_wrap_h - -/* - * This header contains #defines which tweak the names of various memory - * allocation functions. - * - * There are several types of functions related to memory allocation - * that are meant to be used publicly by the Gecko codebase: - * - * - malloc implementation functions: - * - malloc - * - posix_memalign - * - aligned_alloc - * - calloc - * - realloc - * - free - * - memalign - * - valloc - * - malloc_usable_size - * - malloc_good_size - * Some of these functions are specific to some systems, but for - * convenience, they are treated as being cross-platform, and available - * as such. - * - * - duplication functions: - * - strndup - * - strdup - * - wcsdup (Windows only) - * - * - jemalloc specific functions: - * - jemalloc_stats - * - jemalloc_purge_freed_pages - * - jemalloc_free_dirty_pages - * (these functions are native to mozjemalloc, and have compatibility - * implementations for jemalloc3) - * - * These functions are all exported as part of libmozglue (see - * $(topsrcdir)/mozglue/build/Makefile.in), with a few implementation - * peculiarities: - * - * - On Windows, the malloc implementation functions are all prefixed with - * "je_", the duplication functions are prefixed with "wrap_", and jemalloc - * specific functions are left unprefixed. All these functions are however - * aliased when exporting them, such that the resulting mozglue.dll exports - * them unprefixed (see $(topsrcdir)/mozglue/build/mozglue.def.in). The - * prefixed malloc implementation and duplication functions are not - * exported. - * - * - On MacOSX, the system libc has a zone allocator, which allows us to - * hook custom malloc implementation functions without exporting them. - * The malloc implementation functions are all prefixed with "je_" and used - * this way from the custom zone allocator. They are not exported. - * Duplication functions are not included, since they will call the custom - * zone allocator anyways. Jemalloc-specific functions are also left - * unprefixed. - * - * - On Android and Gonk, all functions are left unprefixed. Additionally, - * C++ allocation functions (operator new/delete) are also exported and - * unprefixed. - * - * - On other systems (mostly Linux), all functions are left unprefixed. - * - * Only Android and Gonk add C++ allocation functions. - * - * Proper exporting of the various functions is done with the MOZ_MEMORY_API - * and MOZ_JEMALLOC_API macros. MOZ_MEMORY_API is meant to be used for malloc - * implementation and duplication functions, while MOZ_JEMALLOC_API is - * dedicated to jemalloc specific functions. - * - * - * All these functions are meant to be called with no prefix from Gecko code. - * In most cases, this is because that's how they are available at runtime. - * However, on Android, this relies on faulty.lib (the custom dynamic linker) - * resolving mozglue symbols before libc symbols, which is guaranteed by the - * way faulty.lib works (it respects the DT_NEEDED order, and libc always - * appears after mozglue ; which we double check when building anyways) - * - * - * Within libmozglue (when MOZ_MEMORY_IMPL is defined), all the functions - * should be suffixed with "_impl" both for declarations and use. - * That is, the implementation declaration for e.g. strdup would look like: - * char* strdup_impl(const char *) - * That implementation would call malloc by using "malloc_impl". - * - * While mozjemalloc uses these "_impl" suffixed helpers, jemalloc3, being - * third-party code, doesn't, but instead has an elaborate way to mangle - * individual functions. See under "Run jemalloc configure script" in - * $(topsrcdir)/configure.in. - * - * - * When building with replace-malloc support, the above still holds, but - * the malloc implementation and jemalloc specific functions are the - * replace-malloc functions from replace_malloc.c. - * - * The actual jemalloc/mozjemalloc implementation is prefixed with "je_". - * - * Thus, when MOZ_REPLACE_MALLOC is defined, the "_impl" suffixed macros - * expand to "je_" prefixed function when building mozjemalloc or - * jemalloc3/mozjemalloc_compat, where MOZ_JEMALLOC_IMPL is defined. - * - * In other cases, the "_impl" suffixed macros follow the original scheme, - * except on Windows and MacOSX, where they would expand to "je_" prefixed - * functions. Instead, they are left unmodified (malloc_impl expands to - * malloc_impl). - */ - -#ifndef MOZ_MEMORY -# error Should only include mozmemory_wrap.h when MOZ_MEMORY is set. -#endif - -#if defined(MOZ_JEMALLOC_IMPL) && !defined(MOZ_MEMORY_IMPL) -# define MOZ_MEMORY_IMPL -#endif -#if defined(MOZ_MEMORY_IMPL) && !defined(IMPL_MFBT) -# ifdef MFBT_API /* mozilla/Types.h was already included */ -# error mozmemory_wrap.h has to be included before mozilla/Types.h when MOZ_MEMORY_IMPL is set and IMPL_MFBT is not. -# endif -# define IMPL_MFBT -#endif - -#include "mozilla/Types.h" - -#if !defined(MOZ_SYSTEM_JEMALLOC) -# ifdef MOZ_MEMORY_IMPL -# if defined(MOZ_JEMALLOC_IMPL) && defined(MOZ_REPLACE_MALLOC) && !defined(MOZ_REPLACE_JEMALLOC) -# define mozmem_malloc_impl(a) je_ ## a -# define mozmem_jemalloc_impl(a) je_ ## a -# else -# define MOZ_JEMALLOC_API MFBT_API -# ifdef MOZ_REPLACE_JEMALLOC -# define MOZ_MEMORY_API MFBT_API -# define mozmem_malloc_impl(a) replace_ ## a -# define mozmem_jemalloc_impl(a) replace_ ## a -# elif (defined(XP_WIN) || defined(XP_DARWIN)) -# if defined(MOZ_REPLACE_MALLOC) -# define mozmem_malloc_impl(a) a ## _impl -# else -# define mozmem_malloc_impl(a) je_ ## a -# endif -# else -# define MOZ_MEMORY_API MFBT_API -# if defined(MOZ_WIDGET_ANDROID) || defined(MOZ_WIDGET_GONK) -# define MOZ_WRAP_NEW_DELETE -# endif -# endif -# endif -# ifdef XP_WIN -# define mozmem_dup_impl(a) wrap_ ## a -# endif -# endif - -/* All other jemalloc3 functions are prefixed with "je_", except when - * building against an unprefixed system jemalloc library */ -# define je_(a) je_ ## a -#else /* defined(MOZ_SYSTEM_JEMALLOC) */ -# define je_(a) a -#endif - -#if !defined(MOZ_MEMORY_IMPL) || defined(MOZ_SYSTEM_JEMALLOC) -# define MOZ_MEMORY_API MFBT_API -# define MOZ_JEMALLOC_API MFBT_API -#endif - -#ifndef MOZ_MEMORY_API -# define MOZ_MEMORY_API -#endif -#ifndef MOZ_JEMALLOC_API -# define MOZ_JEMALLOC_API -#endif - -#ifndef mozmem_malloc_impl -# define mozmem_malloc_impl(a) a -#endif -#ifndef mozmem_dup_impl -# define mozmem_dup_impl(a) a -#endif -#ifndef mozmem_jemalloc_impl -# define mozmem_jemalloc_impl(a) a -#endif - -/* Malloc implementation functions */ -#define malloc_impl mozmem_malloc_impl(malloc) -#define posix_memalign_impl mozmem_malloc_impl(posix_memalign) -#define aligned_alloc_impl mozmem_malloc_impl(aligned_alloc) -#define calloc_impl mozmem_malloc_impl(calloc) -#define realloc_impl mozmem_malloc_impl(realloc) -#define free_impl mozmem_malloc_impl(free) -#define memalign_impl mozmem_malloc_impl(memalign) -#define valloc_impl mozmem_malloc_impl(valloc) -#define malloc_usable_size_impl mozmem_malloc_impl(malloc_usable_size) -#define malloc_good_size_impl mozmem_malloc_impl(malloc_good_size) - -/* Duplication functions */ -#define strndup_impl mozmem_dup_impl(strndup) -#define strdup_impl mozmem_dup_impl(strdup) -#ifdef XP_WIN -# define wcsdup_impl mozmem_dup_impl(wcsdup) -#endif - -/* String functions */ -#ifdef ANDROID -/* Bug 801571 and Bug 879668, libstagefright uses vasprintf, causing malloc()/ - * free() to be mismatched between bionic and mozglue implementation. - */ -#define vasprintf_impl mozmem_dup_impl(vasprintf) -#define asprintf_impl mozmem_dup_impl(asprintf) -#endif - -/* Jemalloc specific function */ -#define jemalloc_stats_impl mozmem_jemalloc_impl(jemalloc_stats) -#define jemalloc_purge_freed_pages_impl mozmem_jemalloc_impl(jemalloc_purge_freed_pages) -#define jemalloc_free_dirty_pages_impl mozmem_jemalloc_impl(jemalloc_free_dirty_pages) - -#endif /* mozmemory_wrap_h */ diff --git a/android/armeabi/include/tiff/tiff.h b/android/armeabi/include/tiff/tiff.h deleted file mode 100644 index bc46acd0..00000000 --- a/android/armeabi/include/tiff/tiff.h +++ /dev/null @@ -1,681 +0,0 @@ -/* $Id: tiff.h,v 1.69 2014-04-02 17:23:06 fwarmerdam Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFF_ -#define _TIFF_ - -#include "tiffconf.h" - -/* - * Tag Image File Format (TIFF) - * - * Based on Rev 6.0 from: - * Developer's Desk - * Aldus Corporation - * 411 First Ave. South - * Suite 200 - * Seattle, WA 98104 - * 206-622-5500 - * - * (http://partners.adobe.com/asn/developer/PDFS/TN/TIFF6.pdf) - * - * For BigTIFF design notes see the following links - * http://www.remotesensing.org/libtiff/bigtiffdesign.html - * http://www.awaresystems.be/imaging/tiff/bigtiff.html - */ - -#define TIFF_VERSION_CLASSIC 42 -#define TIFF_VERSION_BIG 43 - -#define TIFF_BIGENDIAN 0x4d4d -#define TIFF_LITTLEENDIAN 0x4949 -#define MDI_LITTLEENDIAN 0x5045 -#define MDI_BIGENDIAN 0x4550 - -/* - * Intrinsic data types required by the file format: - * - * 8-bit quantities int8/uint8 - * 16-bit quantities int16/uint16 - * 32-bit quantities int32/uint32 - * 64-bit quantities int64/uint64 - * strings unsigned char* - */ - -typedef TIFF_INT8_T int8; -typedef TIFF_UINT8_T uint8; - -typedef TIFF_INT16_T int16; -typedef TIFF_UINT16_T uint16; - -typedef TIFF_INT32_T int32; -typedef TIFF_UINT32_T uint32; - -typedef TIFF_INT64_T int64; -typedef TIFF_UINT64_T uint64; - -/* - * Some types as promoted in a variable argument list - * We use uint16_vap rather then directly using int, because this way - * we document the type we actually want to pass through, conceptually, - * rather then confusing the issue by merely stating the type it gets - * promoted to - */ - -typedef int uint16_vap; - -/* - * TIFF header. - */ -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ -} TIFFHeaderCommon; -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint32 tiff_diroff; /* byte offset to first directory */ -} TIFFHeaderClassic; -typedef struct { - uint16 tiff_magic; /* magic number (defines byte order) */ - uint16 tiff_version; /* TIFF version number */ - uint16 tiff_offsetsize; /* size of offsets, should be 8 */ - uint16 tiff_unused; /* unused word, should be 0 */ - uint64 tiff_diroff; /* byte offset to first directory */ -} TIFFHeaderBig; - - -/* - * NB: In the comments below, - * - items marked with a + are obsoleted by revision 5.0, - * - items marked with a ! are introduced in revision 6.0. - * - items marked with a % are introduced post revision 6.0. - * - items marked with a $ are obsoleted by revision 6.0. - * - items marked with a & are introduced by Adobe DNG specification. - */ - -/* - * Tag data type information. - * - * Note: RATIONALs are the ratio of two 32-bit integer values. - */ -typedef enum { - TIFF_NOTYPE = 0, /* placeholder */ - TIFF_BYTE = 1, /* 8-bit unsigned integer */ - TIFF_ASCII = 2, /* 8-bit bytes w/ last byte null */ - TIFF_SHORT = 3, /* 16-bit unsigned integer */ - TIFF_LONG = 4, /* 32-bit unsigned integer */ - TIFF_RATIONAL = 5, /* 64-bit unsigned fraction */ - TIFF_SBYTE = 6, /* !8-bit signed integer */ - TIFF_UNDEFINED = 7, /* !8-bit untyped data */ - TIFF_SSHORT = 8, /* !16-bit signed integer */ - TIFF_SLONG = 9, /* !32-bit signed integer */ - TIFF_SRATIONAL = 10, /* !64-bit signed fraction */ - TIFF_FLOAT = 11, /* !32-bit IEEE floating point */ - TIFF_DOUBLE = 12, /* !64-bit IEEE floating point */ - TIFF_IFD = 13, /* %32-bit unsigned integer (offset) */ - TIFF_LONG8 = 16, /* BigTIFF 64-bit unsigned integer */ - TIFF_SLONG8 = 17, /* BigTIFF 64-bit signed integer */ - TIFF_IFD8 = 18 /* BigTIFF 64-bit unsigned integer (offset) */ -} TIFFDataType; - -/* - * TIFF Tag Definitions. - */ -#define TIFFTAG_SUBFILETYPE 254 /* subfile data descriptor */ -#define FILETYPE_REDUCEDIMAGE 0x1 /* reduced resolution version */ -#define FILETYPE_PAGE 0x2 /* one page of many */ -#define FILETYPE_MASK 0x4 /* transparency mask */ -#define TIFFTAG_OSUBFILETYPE 255 /* +kind of data in subfile */ -#define OFILETYPE_IMAGE 1 /* full resolution image data */ -#define OFILETYPE_REDUCEDIMAGE 2 /* reduced size image data */ -#define OFILETYPE_PAGE 3 /* one page of many */ -#define TIFFTAG_IMAGEWIDTH 256 /* image width in pixels */ -#define TIFFTAG_IMAGELENGTH 257 /* image height in pixels */ -#define TIFFTAG_BITSPERSAMPLE 258 /* bits per channel (sample) */ -#define TIFFTAG_COMPRESSION 259 /* data compression technique */ -#define COMPRESSION_NONE 1 /* dump mode */ -#define COMPRESSION_CCITTRLE 2 /* CCITT modified Huffman RLE */ -#define COMPRESSION_CCITTFAX3 3 /* CCITT Group 3 fax encoding */ -#define COMPRESSION_CCITT_T4 3 /* CCITT T.4 (TIFF 6 name) */ -#define COMPRESSION_CCITTFAX4 4 /* CCITT Group 4 fax encoding */ -#define COMPRESSION_CCITT_T6 4 /* CCITT T.6 (TIFF 6 name) */ -#define COMPRESSION_LZW 5 /* Lempel-Ziv & Welch */ -#define COMPRESSION_OJPEG 6 /* !6.0 JPEG */ -#define COMPRESSION_JPEG 7 /* %JPEG DCT compression */ -#define COMPRESSION_T85 9 /* !TIFF/FX T.85 JBIG compression */ -#define COMPRESSION_T43 10 /* !TIFF/FX T.43 colour by layered JBIG compression */ -#define COMPRESSION_NEXT 32766 /* NeXT 2-bit RLE */ -#define COMPRESSION_CCITTRLEW 32771 /* #1 w/ word alignment */ -#define COMPRESSION_PACKBITS 32773 /* Macintosh RLE */ -#define COMPRESSION_THUNDERSCAN 32809 /* ThunderScan RLE */ -/* codes 32895-32898 are reserved for ANSI IT8 TIFF/IT <dkelly@apago.com) */ -#define COMPRESSION_IT8CTPAD 32895 /* IT8 CT w/padding */ -#define COMPRESSION_IT8LW 32896 /* IT8 Linework RLE */ -#define COMPRESSION_IT8MP 32897 /* IT8 Monochrome picture */ -#define COMPRESSION_IT8BL 32898 /* IT8 Binary line art */ -/* compression codes 32908-32911 are reserved for Pixar */ -#define COMPRESSION_PIXARFILM 32908 /* Pixar companded 10bit LZW */ -#define COMPRESSION_PIXARLOG 32909 /* Pixar companded 11bit ZIP */ -#define COMPRESSION_DEFLATE 32946 /* Deflate compression */ -#define COMPRESSION_ADOBE_DEFLATE 8 /* Deflate compression, - as recognized by Adobe */ -/* compression code 32947 is reserved for Oceana Matrix <dev@oceana.com> */ -#define COMPRESSION_DCS 32947 /* Kodak DCS encoding */ -#define COMPRESSION_JBIG 34661 /* ISO JBIG */ -#define COMPRESSION_SGILOG 34676 /* SGI Log Luminance RLE */ -#define COMPRESSION_SGILOG24 34677 /* SGI Log 24-bit packed */ -#define COMPRESSION_JP2000 34712 /* Leadtools JPEG2000 */ -#define COMPRESSION_LZMA 34925 /* LZMA2 */ -#define TIFFTAG_PHOTOMETRIC 262 /* photometric interpretation */ -#define PHOTOMETRIC_MINISWHITE 0 /* min value is white */ -#define PHOTOMETRIC_MINISBLACK 1 /* min value is black */ -#define PHOTOMETRIC_RGB 2 /* RGB color model */ -#define PHOTOMETRIC_PALETTE 3 /* color map indexed */ -#define PHOTOMETRIC_MASK 4 /* $holdout mask */ -#define PHOTOMETRIC_SEPARATED 5 /* !color separations */ -#define PHOTOMETRIC_YCBCR 6 /* !CCIR 601 */ -#define PHOTOMETRIC_CIELAB 8 /* !1976 CIE L*a*b* */ -#define PHOTOMETRIC_ICCLAB 9 /* ICC L*a*b* [Adobe TIFF Technote 4] */ -#define PHOTOMETRIC_ITULAB 10 /* ITU L*a*b* */ -#define PHOTOMETRIC_CFA 32803 /* color filter array */ -#define PHOTOMETRIC_LOGL 32844 /* CIE Log2(L) */ -#define PHOTOMETRIC_LOGLUV 32845 /* CIE Log2(L) (u',v') */ -#define TIFFTAG_THRESHHOLDING 263 /* +thresholding used on data */ -#define THRESHHOLD_BILEVEL 1 /* b&w art scan */ -#define THRESHHOLD_HALFTONE 2 /* or dithered scan */ -#define THRESHHOLD_ERRORDIFFUSE 3 /* usually floyd-steinberg */ -#define TIFFTAG_CELLWIDTH 264 /* +dithering matrix width */ -#define TIFFTAG_CELLLENGTH 265 /* +dithering matrix height */ -#define TIFFTAG_FILLORDER 266 /* data order within a byte */ -#define FILLORDER_MSB2LSB 1 /* most significant -> least */ -#define FILLORDER_LSB2MSB 2 /* least significant -> most */ -#define TIFFTAG_DOCUMENTNAME 269 /* name of doc. image is from */ -#define TIFFTAG_IMAGEDESCRIPTION 270 /* info about image */ -#define TIFFTAG_MAKE 271 /* scanner manufacturer name */ -#define TIFFTAG_MODEL 272 /* scanner model name/number */ -#define TIFFTAG_STRIPOFFSETS 273 /* offsets to data strips */ -#define TIFFTAG_ORIENTATION 274 /* +image orientation */ -#define ORIENTATION_TOPLEFT 1 /* row 0 top, col 0 lhs */ -#define ORIENTATION_TOPRIGHT 2 /* row 0 top, col 0 rhs */ -#define ORIENTATION_BOTRIGHT 3 /* row 0 bottom, col 0 rhs */ -#define ORIENTATION_BOTLEFT 4 /* row 0 bottom, col 0 lhs */ -#define ORIENTATION_LEFTTOP 5 /* row 0 lhs, col 0 top */ -#define ORIENTATION_RIGHTTOP 6 /* row 0 rhs, col 0 top */ -#define ORIENTATION_RIGHTBOT 7 /* row 0 rhs, col 0 bottom */ -#define ORIENTATION_LEFTBOT 8 /* row 0 lhs, col 0 bottom */ -#define TIFFTAG_SAMPLESPERPIXEL 277 /* samples per pixel */ -#define TIFFTAG_ROWSPERSTRIP 278 /* rows per strip of data */ -#define TIFFTAG_STRIPBYTECOUNTS 279 /* bytes counts for strips */ -#define TIFFTAG_MINSAMPLEVALUE 280 /* +minimum sample value */ -#define TIFFTAG_MAXSAMPLEVALUE 281 /* +maximum sample value */ -#define TIFFTAG_XRESOLUTION 282 /* pixels/resolution in x */ -#define TIFFTAG_YRESOLUTION 283 /* pixels/resolution in y */ -#define TIFFTAG_PLANARCONFIG 284 /* storage organization */ -#define PLANARCONFIG_CONTIG 1 /* single image plane */ -#define PLANARCONFIG_SEPARATE 2 /* separate planes of data */ -#define TIFFTAG_PAGENAME 285 /* page name image is from */ -#define TIFFTAG_XPOSITION 286 /* x page offset of image lhs */ -#define TIFFTAG_YPOSITION 287 /* y page offset of image lhs */ -#define TIFFTAG_FREEOFFSETS 288 /* +byte offset to free block */ -#define TIFFTAG_FREEBYTECOUNTS 289 /* +sizes of free blocks */ -#define TIFFTAG_GRAYRESPONSEUNIT 290 /* $gray scale curve accuracy */ -#define GRAYRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define GRAYRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define GRAYRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define GRAYRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define GRAYRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_GRAYRESPONSECURVE 291 /* $gray scale response curve */ -#define TIFFTAG_GROUP3OPTIONS 292 /* 32 flag bits */ -#define TIFFTAG_T4OPTIONS 292 /* TIFF 6.0 proper name alias */ -#define GROUP3OPT_2DENCODING 0x1 /* 2-dimensional coding */ -#define GROUP3OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define GROUP3OPT_FILLBITS 0x4 /* fill to byte boundary */ -#define TIFFTAG_GROUP4OPTIONS 293 /* 32 flag bits */ -#define TIFFTAG_T6OPTIONS 293 /* TIFF 6.0 proper name */ -#define GROUP4OPT_UNCOMPRESSED 0x2 /* data not compressed */ -#define TIFFTAG_RESOLUTIONUNIT 296 /* units of resolutions */ -#define RESUNIT_NONE 1 /* no meaningful units */ -#define RESUNIT_INCH 2 /* english */ -#define RESUNIT_CENTIMETER 3 /* metric */ -#define TIFFTAG_PAGENUMBER 297 /* page numbers of multi-page */ -#define TIFFTAG_COLORRESPONSEUNIT 300 /* $color curve accuracy */ -#define COLORRESPONSEUNIT_10S 1 /* tenths of a unit */ -#define COLORRESPONSEUNIT_100S 2 /* hundredths of a unit */ -#define COLORRESPONSEUNIT_1000S 3 /* thousandths of a unit */ -#define COLORRESPONSEUNIT_10000S 4 /* ten-thousandths of a unit */ -#define COLORRESPONSEUNIT_100000S 5 /* hundred-thousandths */ -#define TIFFTAG_TRANSFERFUNCTION 301 /* !colorimetry info */ -#define TIFFTAG_SOFTWARE 305 /* name & release */ -#define TIFFTAG_DATETIME 306 /* creation date and time */ -#define TIFFTAG_ARTIST 315 /* creator of image */ -#define TIFFTAG_HOSTCOMPUTER 316 /* machine where created */ -#define TIFFTAG_PREDICTOR 317 /* prediction scheme w/ LZW */ -#define PREDICTOR_NONE 1 /* no prediction scheme used */ -#define PREDICTOR_HORIZONTAL 2 /* horizontal differencing */ -#define PREDICTOR_FLOATINGPOINT 3 /* floating point predictor */ -#define TIFFTAG_WHITEPOINT 318 /* image white point */ -#define TIFFTAG_PRIMARYCHROMATICITIES 319 /* !primary chromaticities */ -#define TIFFTAG_COLORMAP 320 /* RGB map for pallette image */ -#define TIFFTAG_HALFTONEHINTS 321 /* !highlight+shadow info */ -#define TIFFTAG_TILEWIDTH 322 /* !tile width in pixels */ -#define TIFFTAG_TILELENGTH 323 /* !tile height in pixels */ -#define TIFFTAG_TILEOFFSETS 324 /* !offsets to data tiles */ -#define TIFFTAG_TILEBYTECOUNTS 325 /* !byte counts for tiles */ -#define TIFFTAG_BADFAXLINES 326 /* lines w/ wrong pixel count */ -#define TIFFTAG_CLEANFAXDATA 327 /* regenerated line info */ -#define CLEANFAXDATA_CLEAN 0 /* no errors detected */ -#define CLEANFAXDATA_REGENERATED 1 /* receiver regenerated lines */ -#define CLEANFAXDATA_UNCLEAN 2 /* uncorrected errors exist */ -#define TIFFTAG_CONSECUTIVEBADFAXLINES 328 /* max consecutive bad lines */ -#define TIFFTAG_SUBIFD 330 /* subimage descriptors */ -#define TIFFTAG_INKSET 332 /* !inks in separated image */ -#define INKSET_CMYK 1 /* !cyan-magenta-yellow-black color */ -#define INKSET_MULTIINK 2 /* !multi-ink or hi-fi color */ -#define TIFFTAG_INKNAMES 333 /* !ascii names of inks */ -#define TIFFTAG_NUMBEROFINKS 334 /* !number of inks */ -#define TIFFTAG_DOTRANGE 336 /* !0% and 100% dot codes */ -#define TIFFTAG_TARGETPRINTER 337 /* !separation target */ -#define TIFFTAG_EXTRASAMPLES 338 /* !info about extra samples */ -#define EXTRASAMPLE_UNSPECIFIED 0 /* !unspecified data */ -#define EXTRASAMPLE_ASSOCALPHA 1 /* !associated alpha data */ -#define EXTRASAMPLE_UNASSALPHA 2 /* !unassociated alpha data */ -#define TIFFTAG_SAMPLEFORMAT 339 /* !data sample format */ -#define SAMPLEFORMAT_UINT 1 /* !unsigned integer data */ -#define SAMPLEFORMAT_INT 2 /* !signed integer data */ -#define SAMPLEFORMAT_IEEEFP 3 /* !IEEE floating point data */ -#define SAMPLEFORMAT_VOID 4 /* !untyped data */ -#define SAMPLEFORMAT_COMPLEXINT 5 /* !complex signed int */ -#define SAMPLEFORMAT_COMPLEXIEEEFP 6 /* !complex ieee floating */ -#define TIFFTAG_SMINSAMPLEVALUE 340 /* !variable MinSampleValue */ -#define TIFFTAG_SMAXSAMPLEVALUE 341 /* !variable MaxSampleValue */ -#define TIFFTAG_CLIPPATH 343 /* %ClipPath - [Adobe TIFF technote 2] */ -#define TIFFTAG_XCLIPPATHUNITS 344 /* %XClipPathUnits - [Adobe TIFF technote 2] */ -#define TIFFTAG_YCLIPPATHUNITS 345 /* %YClipPathUnits - [Adobe TIFF technote 2] */ -#define TIFFTAG_INDEXED 346 /* %Indexed - [Adobe TIFF Technote 3] */ -#define TIFFTAG_JPEGTABLES 347 /* %JPEG table stream */ -#define TIFFTAG_OPIPROXY 351 /* %OPI Proxy [Adobe TIFF technote] */ -/* Tags 400-435 are from the TIFF/FX spec */ -#define TIFFTAG_GLOBALPARAMETERSIFD 400 /* ! */ -#define TIFFTAG_PROFILETYPE 401 /* ! */ -#define PROFILETYPE_UNSPECIFIED 0 /* ! */ -#define PROFILETYPE_G3_FAX 1 /* ! */ -#define TIFFTAG_FAXPROFILE 402 /* ! */ -#define FAXPROFILE_S 1 /* !TIFF/FX FAX profile S */ -#define FAXPROFILE_F 2 /* !TIFF/FX FAX profile F */ -#define FAXPROFILE_J 3 /* !TIFF/FX FAX profile J */ -#define FAXPROFILE_C 4 /* !TIFF/FX FAX profile C */ -#define FAXPROFILE_L 5 /* !TIFF/FX FAX profile L */ -#define FAXPROFILE_M 6 /* !TIFF/FX FAX profile LM */ -#define TIFFTAG_CODINGMETHODS 403 /* !TIFF/FX coding methods */ -#define CODINGMETHODS_T4_1D (1 << 1) /* !T.4 1D */ -#define CODINGMETHODS_T4_2D (1 << 2) /* !T.4 2D */ -#define CODINGMETHODS_T6 (1 << 3) /* !T.6 */ -#define CODINGMETHODS_T85 (1 << 4) /* !T.85 JBIG */ -#define CODINGMETHODS_T42 (1 << 5) /* !T.42 JPEG */ -#define CODINGMETHODS_T43 (1 << 6) /* !T.43 colour by layered JBIG */ -#define TIFFTAG_VERSIONYEAR 404 /* !TIFF/FX version year */ -#define TIFFTAG_MODENUMBER 405 /* !TIFF/FX mode number */ -#define TIFFTAG_DECODE 433 /* !TIFF/FX decode */ -#define TIFFTAG_IMAGEBASECOLOR 434 /* !TIFF/FX image base colour */ -#define TIFFTAG_T82OPTIONS 435 /* !TIFF/FX T.82 options */ -/* - * Tags 512-521 are obsoleted by Technical Note #2 which specifies a - * revised JPEG-in-TIFF scheme. - */ -#define TIFFTAG_JPEGPROC 512 /* !JPEG processing algorithm */ -#define JPEGPROC_BASELINE 1 /* !baseline sequential */ -#define JPEGPROC_LOSSLESS 14 /* !Huffman coded lossless */ -#define TIFFTAG_JPEGIFOFFSET 513 /* !pointer to SOI marker */ -#define TIFFTAG_JPEGIFBYTECOUNT 514 /* !JFIF stream length */ -#define TIFFTAG_JPEGRESTARTINTERVAL 515 /* !restart interval length */ -#define TIFFTAG_JPEGLOSSLESSPREDICTORS 517 /* !lossless proc predictor */ -#define TIFFTAG_JPEGPOINTTRANSFORM 518 /* !lossless point transform */ -#define TIFFTAG_JPEGQTABLES 519 /* !Q matrice offsets */ -#define TIFFTAG_JPEGDCTABLES 520 /* !DCT table offsets */ -#define TIFFTAG_JPEGACTABLES 521 /* !AC coefficient offsets */ -#define TIFFTAG_YCBCRCOEFFICIENTS 529 /* !RGB -> YCbCr transform */ -#define TIFFTAG_YCBCRSUBSAMPLING 530 /* !YCbCr subsampling factors */ -#define TIFFTAG_YCBCRPOSITIONING 531 /* !subsample positioning */ -#define YCBCRPOSITION_CENTERED 1 /* !as in PostScript Level 2 */ -#define YCBCRPOSITION_COSITED 2 /* !as in CCIR 601-1 */ -#define TIFFTAG_REFERENCEBLACKWHITE 532 /* !colorimetry info */ -#define TIFFTAG_STRIPROWCOUNTS 559 /* !TIFF/FX strip row counts */ -#define TIFFTAG_XMLPACKET 700 /* %XML packet - [Adobe XMP Specification, - January 2004 */ -#define TIFFTAG_OPIIMAGEID 32781 /* %OPI ImageID - [Adobe TIFF technote] */ -/* tags 32952-32956 are private tags registered to Island Graphics */ -#define TIFFTAG_REFPTS 32953 /* image reference points */ -#define TIFFTAG_REGIONTACKPOINT 32954 /* region-xform tack point */ -#define TIFFTAG_REGIONWARPCORNERS 32955 /* warp quadrilateral */ -#define TIFFTAG_REGIONAFFINE 32956 /* affine transformation mat */ -/* tags 32995-32999 are private tags registered to SGI */ -#define TIFFTAG_MATTEING 32995 /* $use ExtraSamples */ -#define TIFFTAG_DATATYPE 32996 /* $use SampleFormat */ -#define TIFFTAG_IMAGEDEPTH 32997 /* z depth of image */ -#define TIFFTAG_TILEDEPTH 32998 /* z depth/data tile */ -/* tags 33300-33309 are private tags registered to Pixar */ -/* - * TIFFTAG_PIXAR_IMAGEFULLWIDTH and TIFFTAG_PIXAR_IMAGEFULLLENGTH - * are set when an image has been cropped out of a larger image. - * They reflect the size of the original uncropped image. - * The TIFFTAG_XPOSITION and TIFFTAG_YPOSITION can be used - * to determine the position of the smaller image in the larger one. - */ -#define TIFFTAG_PIXAR_IMAGEFULLWIDTH 33300 /* full image size in x */ -#define TIFFTAG_PIXAR_IMAGEFULLLENGTH 33301 /* full image size in y */ - /* Tags 33302-33306 are used to identify special image modes and data - * used by Pixar's texture formats. - */ -#define TIFFTAG_PIXAR_TEXTUREFORMAT 33302 /* texture map format */ -#define TIFFTAG_PIXAR_WRAPMODES 33303 /* s & t wrap modes */ -#define TIFFTAG_PIXAR_FOVCOT 33304 /* cotan(fov) for env. maps */ -#define TIFFTAG_PIXAR_MATRIX_WORLDTOSCREEN 33305 -#define TIFFTAG_PIXAR_MATRIX_WORLDTOCAMERA 33306 -/* tag 33405 is a private tag registered to Eastman Kodak */ -#define TIFFTAG_WRITERSERIALNUMBER 33405 /* device serial number */ -#define TIFFTAG_CFAREPEATPATTERNDIM 33421 /* dimensions of CFA pattern */ -#define TIFFTAG_CFAPATTERN 33422 /* color filter array pattern */ -/* tag 33432 is listed in the 6.0 spec w/ unknown ownership */ -#define TIFFTAG_COPYRIGHT 33432 /* copyright string */ -/* IPTC TAG from RichTIFF specifications */ -#define TIFFTAG_RICHTIFFIPTC 33723 -/* 34016-34029 are reserved for ANSI IT8 TIFF/IT <dkelly@apago.com) */ -#define TIFFTAG_IT8SITE 34016 /* site name */ -#define TIFFTAG_IT8COLORSEQUENCE 34017 /* color seq. [RGB,CMYK,etc] */ -#define TIFFTAG_IT8HEADER 34018 /* DDES Header */ -#define TIFFTAG_IT8RASTERPADDING 34019 /* raster scanline padding */ -#define TIFFTAG_IT8BITSPERRUNLENGTH 34020 /* # of bits in short run */ -#define TIFFTAG_IT8BITSPEREXTENDEDRUNLENGTH 34021/* # of bits in long run */ -#define TIFFTAG_IT8COLORTABLE 34022 /* LW colortable */ -#define TIFFTAG_IT8IMAGECOLORINDICATOR 34023 /* BP/BL image color switch */ -#define TIFFTAG_IT8BKGCOLORINDICATOR 34024 /* BP/BL bg color switch */ -#define TIFFTAG_IT8IMAGECOLORVALUE 34025 /* BP/BL image color value */ -#define TIFFTAG_IT8BKGCOLORVALUE 34026 /* BP/BL bg color value */ -#define TIFFTAG_IT8PIXELINTENSITYRANGE 34027 /* MP pixel intensity value */ -#define TIFFTAG_IT8TRANSPARENCYINDICATOR 34028 /* HC transparency switch */ -#define TIFFTAG_IT8COLORCHARACTERIZATION 34029 /* color character. table */ -#define TIFFTAG_IT8HCUSAGE 34030 /* HC usage indicator */ -#define TIFFTAG_IT8TRAPINDICATOR 34031 /* Trapping indicator - (untrapped=0, trapped=1) */ -#define TIFFTAG_IT8CMYKEQUIVALENT 34032 /* CMYK color equivalents */ -/* tags 34232-34236 are private tags registered to Texas Instruments */ -#define TIFFTAG_FRAMECOUNT 34232 /* Sequence Frame Count */ -/* tag 34377 is private tag registered to Adobe for PhotoShop */ -#define TIFFTAG_PHOTOSHOP 34377 -/* tags 34665, 34853 and 40965 are documented in EXIF specification */ -#define TIFFTAG_EXIFIFD 34665 /* Pointer to EXIF private directory */ -/* tag 34750 is a private tag registered to Adobe? */ -#define TIFFTAG_ICCPROFILE 34675 /* ICC profile data */ -#define TIFFTAG_IMAGELAYER 34732 /* !TIFF/FX image layer information */ -/* tag 34750 is a private tag registered to Pixel Magic */ -#define TIFFTAG_JBIGOPTIONS 34750 /* JBIG options */ -#define TIFFTAG_GPSIFD 34853 /* Pointer to GPS private directory */ -/* tags 34908-34914 are private tags registered to SGI */ -#define TIFFTAG_FAXRECVPARAMS 34908 /* encoded Class 2 ses. parms */ -#define TIFFTAG_FAXSUBADDRESS 34909 /* received SubAddr string */ -#define TIFFTAG_FAXRECVTIME 34910 /* receive time (secs) */ -#define TIFFTAG_FAXDCS 34911 /* encoded fax ses. params, Table 2/T.30 */ -/* tags 37439-37443 are registered to SGI <gregl@sgi.com> */ -#define TIFFTAG_STONITS 37439 /* Sample value to Nits */ -/* tag 34929 is a private tag registered to FedEx */ -#define TIFFTAG_FEDEX_EDR 34929 /* unknown use */ -#define TIFFTAG_INTEROPERABILITYIFD 40965 /* Pointer to Interoperability private directory */ -/* Adobe Digital Negative (DNG) format tags */ -#define TIFFTAG_DNGVERSION 50706 /* &DNG version number */ -#define TIFFTAG_DNGBACKWARDVERSION 50707 /* &DNG compatibility version */ -#define TIFFTAG_UNIQUECAMERAMODEL 50708 /* &name for the camera model */ -#define TIFFTAG_LOCALIZEDCAMERAMODEL 50709 /* &localized camera model - name */ -#define TIFFTAG_CFAPLANECOLOR 50710 /* &CFAPattern->LinearRaw space - mapping */ -#define TIFFTAG_CFALAYOUT 50711 /* &spatial layout of the CFA */ -#define TIFFTAG_LINEARIZATIONTABLE 50712 /* &lookup table description */ -#define TIFFTAG_BLACKLEVELREPEATDIM 50713 /* &repeat pattern size for - the BlackLevel tag */ -#define TIFFTAG_BLACKLEVEL 50714 /* &zero light encoding level */ -#define TIFFTAG_BLACKLEVELDELTAH 50715 /* &zero light encoding level - differences (columns) */ -#define TIFFTAG_BLACKLEVELDELTAV 50716 /* &zero light encoding level - differences (rows) */ -#define TIFFTAG_WHITELEVEL 50717 /* &fully saturated encoding - level */ -#define TIFFTAG_DEFAULTSCALE 50718 /* &default scale factors */ -#define TIFFTAG_DEFAULTCROPORIGIN 50719 /* &origin of the final image - area */ -#define TIFFTAG_DEFAULTCROPSIZE 50720 /* &size of the final image - area */ -#define TIFFTAG_COLORMATRIX1 50721 /* &XYZ->reference color space - transformation matrix 1 */ -#define TIFFTAG_COLORMATRIX2 50722 /* &XYZ->reference color space - transformation matrix 2 */ -#define TIFFTAG_CAMERACALIBRATION1 50723 /* &calibration matrix 1 */ -#define TIFFTAG_CAMERACALIBRATION2 50724 /* &calibration matrix 2 */ -#define TIFFTAG_REDUCTIONMATRIX1 50725 /* &dimensionality reduction - matrix 1 */ -#define TIFFTAG_REDUCTIONMATRIX2 50726 /* &dimensionality reduction - matrix 2 */ -#define TIFFTAG_ANALOGBALANCE 50727 /* &gain applied the stored raw - values*/ -#define TIFFTAG_ASSHOTNEUTRAL 50728 /* &selected white balance in - linear reference space */ -#define TIFFTAG_ASSHOTWHITEXY 50729 /* &selected white balance in - x-y chromaticity - coordinates */ -#define TIFFTAG_BASELINEEXPOSURE 50730 /* &how much to move the zero - point */ -#define TIFFTAG_BASELINENOISE 50731 /* &relative noise level */ -#define TIFFTAG_BASELINESHARPNESS 50732 /* &relative amount of - sharpening */ -#define TIFFTAG_BAYERGREENSPLIT 50733 /* &how closely the values of - the green pixels in the - blue/green rows track the - values of the green pixels - in the red/green rows */ -#define TIFFTAG_LINEARRESPONSELIMIT 50734 /* &non-linear encoding range */ -#define TIFFTAG_CAMERASERIALNUMBER 50735 /* &camera's serial number */ -#define TIFFTAG_LENSINFO 50736 /* info about the lens */ -#define TIFFTAG_CHROMABLURRADIUS 50737 /* &chroma blur radius */ -#define TIFFTAG_ANTIALIASSTRENGTH 50738 /* &relative strength of the - camera's anti-alias filter */ -#define TIFFTAG_SHADOWSCALE 50739 /* &used by Adobe Camera Raw */ -#define TIFFTAG_DNGPRIVATEDATA 50740 /* &manufacturer's private data */ -#define TIFFTAG_MAKERNOTESAFETY 50741 /* &whether the EXIF MakerNote - tag is safe to preserve - along with the rest of the - EXIF data */ -#define TIFFTAG_CALIBRATIONILLUMINANT1 50778 /* &illuminant 1 */ -#define TIFFTAG_CALIBRATIONILLUMINANT2 50779 /* &illuminant 2 */ -#define TIFFTAG_BESTQUALITYSCALE 50780 /* &best quality multiplier */ -#define TIFFTAG_RAWDATAUNIQUEID 50781 /* &unique identifier for - the raw image data */ -#define TIFFTAG_ORIGINALRAWFILENAME 50827 /* &file name of the original - raw file */ -#define TIFFTAG_ORIGINALRAWFILEDATA 50828 /* &contents of the original - raw file */ -#define TIFFTAG_ACTIVEAREA 50829 /* &active (non-masked) pixels - of the sensor */ -#define TIFFTAG_MASKEDAREAS 50830 /* &list of coordinates - of fully masked pixels */ -#define TIFFTAG_ASSHOTICCPROFILE 50831 /* &these two tags used to */ -#define TIFFTAG_ASSHOTPREPROFILEMATRIX 50832 /* map cameras's color space - into ICC profile space */ -#define TIFFTAG_CURRENTICCPROFILE 50833 /* & */ -#define TIFFTAG_CURRENTPREPROFILEMATRIX 50834 /* & */ -/* tag 65535 is an undefined tag used by Eastman Kodak */ -#define TIFFTAG_DCSHUESHIFTVALUES 65535 /* hue shift correction data */ - -/* - * The following are ``pseudo tags'' that can be used to control - * codec-specific functionality. These tags are not written to file. - * Note that these values start at 0xffff+1 so that they'll never - * collide with Aldus-assigned tags. - * - * If you want your private pseudo tags ``registered'' (i.e. added to - * this file), please post a bug report via the tracking system at - * http://www.remotesensing.org/libtiff/bugs.html with the appropriate - * C definitions to add. - */ -#define TIFFTAG_FAXMODE 65536 /* Group 3/4 format control */ -#define FAXMODE_CLASSIC 0x0000 /* default, include RTC */ -#define FAXMODE_NORTC 0x0001 /* no RTC at end of data */ -#define FAXMODE_NOEOL 0x0002 /* no EOL code at end of row */ -#define FAXMODE_BYTEALIGN 0x0004 /* byte align row */ -#define FAXMODE_WORDALIGN 0x0008 /* word align row */ -#define FAXMODE_CLASSF FAXMODE_NORTC /* TIFF Class F */ -#define TIFFTAG_JPEGQUALITY 65537 /* Compression quality level */ -/* Note: quality level is on the IJG 0-100 scale. Default value is 75 */ -#define TIFFTAG_JPEGCOLORMODE 65538 /* Auto RGB<=>YCbCr convert? */ -#define JPEGCOLORMODE_RAW 0x0000 /* no conversion (default) */ -#define JPEGCOLORMODE_RGB 0x0001 /* do auto conversion */ -#define TIFFTAG_JPEGTABLESMODE 65539 /* What to put in JPEGTables */ -#define JPEGTABLESMODE_QUANT 0x0001 /* include quantization tbls */ -#define JPEGTABLESMODE_HUFF 0x0002 /* include Huffman tbls */ -/* Note: default is JPEGTABLESMODE_QUANT | JPEGTABLESMODE_HUFF */ -#define TIFFTAG_FAXFILLFUNC 65540 /* G3/G4 fill function */ -#define TIFFTAG_PIXARLOGDATAFMT 65549 /* PixarLogCodec I/O data sz */ -#define PIXARLOGDATAFMT_8BIT 0 /* regular u_char samples */ -#define PIXARLOGDATAFMT_8BITABGR 1 /* ABGR-order u_chars */ -#define PIXARLOGDATAFMT_11BITLOG 2 /* 11-bit log-encoded (raw) */ -#define PIXARLOGDATAFMT_12BITPICIO 3 /* as per PICIO (1.0==2048) */ -#define PIXARLOGDATAFMT_16BIT 4 /* signed short samples */ -#define PIXARLOGDATAFMT_FLOAT 5 /* IEEE float samples */ -/* 65550-65556 are allocated to Oceana Matrix <dev@oceana.com> */ -#define TIFFTAG_DCSIMAGERTYPE 65550 /* imager model & filter */ -#define DCSIMAGERMODEL_M3 0 /* M3 chip (1280 x 1024) */ -#define DCSIMAGERMODEL_M5 1 /* M5 chip (1536 x 1024) */ -#define DCSIMAGERMODEL_M6 2 /* M6 chip (3072 x 2048) */ -#define DCSIMAGERFILTER_IR 0 /* infrared filter */ -#define DCSIMAGERFILTER_MONO 1 /* monochrome filter */ -#define DCSIMAGERFILTER_CFA 2 /* color filter array */ -#define DCSIMAGERFILTER_OTHER 3 /* other filter */ -#define TIFFTAG_DCSINTERPMODE 65551 /* interpolation mode */ -#define DCSINTERPMODE_NORMAL 0x0 /* whole image, default */ -#define DCSINTERPMODE_PREVIEW 0x1 /* preview of image (384x256) */ -#define TIFFTAG_DCSBALANCEARRAY 65552 /* color balance values */ -#define TIFFTAG_DCSCORRECTMATRIX 65553 /* color correction values */ -#define TIFFTAG_DCSGAMMA 65554 /* gamma value */ -#define TIFFTAG_DCSTOESHOULDERPTS 65555 /* toe & shoulder points */ -#define TIFFTAG_DCSCALIBRATIONFD 65556 /* calibration file desc */ -/* Note: quality level is on the ZLIB 1-9 scale. Default value is -1 */ -#define TIFFTAG_ZIPQUALITY 65557 /* compression quality level */ -#define TIFFTAG_PIXARLOGQUALITY 65558 /* PixarLog uses same scale */ -/* 65559 is allocated to Oceana Matrix <dev@oceana.com> */ -#define TIFFTAG_DCSCLIPRECTANGLE 65559 /* area of image to acquire */ -#define TIFFTAG_SGILOGDATAFMT 65560 /* SGILog user data format */ -#define SGILOGDATAFMT_FLOAT 0 /* IEEE float samples */ -#define SGILOGDATAFMT_16BIT 1 /* 16-bit samples */ -#define SGILOGDATAFMT_RAW 2 /* uninterpreted data */ -#define SGILOGDATAFMT_8BIT 3 /* 8-bit RGB monitor values */ -#define TIFFTAG_SGILOGENCODE 65561 /* SGILog data encoding control*/ -#define SGILOGENCODE_NODITHER 0 /* do not dither encoded values*/ -#define SGILOGENCODE_RANDITHER 1 /* randomly dither encd values */ -#define TIFFTAG_LZMAPRESET 65562 /* LZMA2 preset (compression level) */ -#define TIFFTAG_PERSAMPLE 65563 /* interface for per sample tags */ -#define PERSAMPLE_MERGED 0 /* present as a single value */ -#define PERSAMPLE_MULTI 1 /* present as multiple values */ - -/* - * EXIF tags - */ -#define EXIFTAG_EXPOSURETIME 33434 /* Exposure time */ -#define EXIFTAG_FNUMBER 33437 /* F number */ -#define EXIFTAG_EXPOSUREPROGRAM 34850 /* Exposure program */ -#define EXIFTAG_SPECTRALSENSITIVITY 34852 /* Spectral sensitivity */ -#define EXIFTAG_ISOSPEEDRATINGS 34855 /* ISO speed rating */ -#define EXIFTAG_OECF 34856 /* Optoelectric conversion - factor */ -#define EXIFTAG_EXIFVERSION 36864 /* Exif version */ -#define EXIFTAG_DATETIMEORIGINAL 36867 /* Date and time of original - data generation */ -#define EXIFTAG_DATETIMEDIGITIZED 36868 /* Date and time of digital - data generation */ -#define EXIFTAG_COMPONENTSCONFIGURATION 37121 /* Meaning of each component */ -#define EXIFTAG_COMPRESSEDBITSPERPIXEL 37122 /* Image compression mode */ -#define EXIFTAG_SHUTTERSPEEDVALUE 37377 /* Shutter speed */ -#define EXIFTAG_APERTUREVALUE 37378 /* Aperture */ -#define EXIFTAG_BRIGHTNESSVALUE 37379 /* Brightness */ -#define EXIFTAG_EXPOSUREBIASVALUE 37380 /* Exposure bias */ -#define EXIFTAG_MAXAPERTUREVALUE 37381 /* Maximum lens aperture */ -#define EXIFTAG_SUBJECTDISTANCE 37382 /* Subject distance */ -#define EXIFTAG_METERINGMODE 37383 /* Metering mode */ -#define EXIFTAG_LIGHTSOURCE 37384 /* Light source */ -#define EXIFTAG_FLASH 37385 /* Flash */ -#define EXIFTAG_FOCALLENGTH 37386 /* Lens focal length */ -#define EXIFTAG_SUBJECTAREA 37396 /* Subject area */ -#define EXIFTAG_MAKERNOTE 37500 /* Manufacturer notes */ -#define EXIFTAG_USERCOMMENT 37510 /* User comments */ -#define EXIFTAG_SUBSECTIME 37520 /* DateTime subseconds */ -#define EXIFTAG_SUBSECTIMEORIGINAL 37521 /* DateTimeOriginal subseconds */ -#define EXIFTAG_SUBSECTIMEDIGITIZED 37522 /* DateTimeDigitized subseconds */ -#define EXIFTAG_FLASHPIXVERSION 40960 /* Supported Flashpix version */ -#define EXIFTAG_COLORSPACE 40961 /* Color space information */ -#define EXIFTAG_PIXELXDIMENSION 40962 /* Valid image width */ -#define EXIFTAG_PIXELYDIMENSION 40963 /* Valid image height */ -#define EXIFTAG_RELATEDSOUNDFILE 40964 /* Related audio file */ -#define EXIFTAG_FLASHENERGY 41483 /* Flash energy */ -#define EXIFTAG_SPATIALFREQUENCYRESPONSE 41484 /* Spatial frequency response */ -#define EXIFTAG_FOCALPLANEXRESOLUTION 41486 /* Focal plane X resolution */ -#define EXIFTAG_FOCALPLANEYRESOLUTION 41487 /* Focal plane Y resolution */ -#define EXIFTAG_FOCALPLANERESOLUTIONUNIT 41488 /* Focal plane resolution unit */ -#define EXIFTAG_SUBJECTLOCATION 41492 /* Subject location */ -#define EXIFTAG_EXPOSUREINDEX 41493 /* Exposure index */ -#define EXIFTAG_SENSINGMETHOD 41495 /* Sensing method */ -#define EXIFTAG_FILESOURCE 41728 /* File source */ -#define EXIFTAG_SCENETYPE 41729 /* Scene type */ -#define EXIFTAG_CFAPATTERN 41730 /* CFA pattern */ -#define EXIFTAG_CUSTOMRENDERED 41985 /* Custom image processing */ -#define EXIFTAG_EXPOSUREMODE 41986 /* Exposure mode */ -#define EXIFTAG_WHITEBALANCE 41987 /* White balance */ -#define EXIFTAG_DIGITALZOOMRATIO 41988 /* Digital zoom ratio */ -#define EXIFTAG_FOCALLENGTHIN35MMFILM 41989 /* Focal length in 35 mm film */ -#define EXIFTAG_SCENECAPTURETYPE 41990 /* Scene capture type */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_CONTRAST 41992 /* Contrast */ -#define EXIFTAG_SATURATION 41993 /* Saturation */ -#define EXIFTAG_SHARPNESS 41994 /* Sharpness */ -#define EXIFTAG_DEVICESETTINGDESCRIPTION 41995 /* Device settings description */ -#define EXIFTAG_SUBJECTDISTANCERANGE 41996 /* Subject distance range */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_GAINCONTROL 41991 /* Gain control */ -#define EXIFTAG_IMAGEUNIQUEID 42016 /* Unique image ID */ - -#endif /* _TIFF_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/android/armeabi/include/tiff/tiffconf.h b/android/armeabi/include/tiff/tiffconf.h deleted file mode 100644 index 262db339..00000000 --- a/android/armeabi/include/tiff/tiffconf.h +++ /dev/null @@ -1,128 +0,0 @@ -/* libtiff/tiffconf.h. Generated from tiffconf.h.in by configure. */ -/* - Configuration defines for installed libtiff. - This file maintained for backward compatibility. Do not use definitions - from this file in your programs. -*/ - -#ifndef _TIFFCONF_ -#define _TIFFCONF_ - -/* Signed 16-bit type */ -#define TIFF_INT16_T signed short - -/* Signed 32-bit type */ -#define TIFF_INT32_T signed int - -/* Signed 64-bit type */ -#define TIFF_INT64_T signed long long - -/* Signed 8-bit type */ -#define TIFF_INT8_T signed char - -/* Unsigned 16-bit type */ -#define TIFF_UINT16_T unsigned short - -/* Unsigned 32-bit type */ -#define TIFF_UINT32_T unsigned int - -/* Unsigned 64-bit type */ -#define TIFF_UINT64_T unsigned long long - -/* Unsigned 8-bit type */ -#define TIFF_UINT8_T unsigned char - -/* Signed size type */ -#define TIFF_SSIZE_T signed int - -/* Pointer difference type */ -#define TIFF_PTRDIFF_T ptrdiff_t - -/* Define to 1 if the system has the type `int16'. */ -/* #undef HAVE_INT16 */ - -/* Define to 1 if the system has the type `int32'. */ -/* #undef HAVE_INT32 */ - -/* Define to 1 if the system has the type `int8'. */ -/* #undef HAVE_INT8 */ - -/* Compatibility stuff. */ - -/* Define as 0 or 1 according to the floating point format suported by the - machine */ -#define HAVE_IEEEFP 1 - -/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */ -#define HOST_FILLORDER FILLORDER_MSB2LSB - -/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian - (Intel) */ -#define HOST_BIGENDIAN 0 - -/* Support CCITT Group 3 & 4 algorithms */ -#define CCITT_SUPPORT 1 - -/* Support JPEG compression (requires IJG JPEG library) */ -/* #undef JPEG_SUPPORT */ - -/* Support JBIG compression (requires JBIG-KIT library) */ -/* #undef JBIG_SUPPORT */ - -/* Support LogLuv high dynamic range encoding */ -#define LOGLUV_SUPPORT 1 - -/* Support LZW algorithm */ -#define LZW_SUPPORT 1 - -/* Support NeXT 2-bit RLE algorithm */ -#define NEXT_SUPPORT 1 - -/* Support Old JPEG compresson (read contrib/ojpeg/README first! Compilation - fails with unpatched IJG JPEG library) */ -/* #undef OJPEG_SUPPORT */ - -/* Support Macintosh PackBits algorithm */ -#define PACKBITS_SUPPORT 1 - -/* Support Pixar log-format algorithm (requires Zlib) */ -/* #undef PIXARLOG_SUPPORT */ - -/* Support ThunderScan 4-bit RLE algorithm */ -#define THUNDER_SUPPORT 1 - -/* Support Deflate compression */ -/* #undef ZIP_SUPPORT */ - -/* Support strip chopping (whether or not to convert single-strip uncompressed - images to mutiple strips of ~8Kb to reduce memory usage) */ -#define STRIPCHOP_DEFAULT TIFF_STRIPCHOP - -/* Enable SubIFD tag (330) support */ -#define SUBIFD_SUPPORT 1 - -/* Treat extra sample as alpha (default enabled). The RGBA interface will - treat a fourth sample with no EXTRASAMPLE_ value as being ASSOCALPHA. Many - packages produce RGBA files but don't mark the alpha properly. */ -#define DEFAULT_EXTRASAMPLE_AS_ALPHA 1 - -/* Pick up YCbCr subsampling info from the JPEG data stream to support files - lacking the tag (default enabled). */ -#define CHECK_JPEG_YCBCR_SUBSAMPLING 1 - -/* Support MS MDI magic number files as TIFF */ -#define MDI_SUPPORT 1 - -/* - * Feature support definitions. - * XXX: These macros are obsoleted. Don't use them in your apps! - * Macros stays here for backward compatibility and should be always defined. - */ -#define COLORIMETRY_SUPPORT -#define YCBCR_SUPPORT -#define CMYK_SUPPORT -#define ICC_SUPPORT -#define PHOTOSHOP_SUPPORT -#define IPTC_SUPPORT - -#endif /* _TIFFCONF_ */ diff --git a/android/armeabi/include/tiff/tiffio.h b/android/armeabi/include/tiff/tiffio.h deleted file mode 100644 index 038b6701..00000000 --- a/android/armeabi/include/tiff/tiffio.h +++ /dev/null @@ -1,557 +0,0 @@ -/* $Id: tiffio.h,v 1.91 2012-07-29 15:45:29 tgl Exp $ */ - -/* - * Copyright (c) 1988-1997 Sam Leffler - * Copyright (c) 1991-1997 Silicon Graphics, Inc. - * - * Permission to use, copy, modify, distribute, and sell this software and - * its documentation for any purpose is hereby granted without fee, provided - * that (i) the above copyright notices and this permission notice appear in - * all copies of the software and related documentation, and (ii) the names of - * Sam Leffler and Silicon Graphics may not be used in any advertising or - * publicity relating to the software without the specific, prior written - * permission of Sam Leffler and Silicon Graphics. - * - * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, - * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY - * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR - * ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, - * OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, - * WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF - * LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE - * OF THIS SOFTWARE. - */ - -#ifndef _TIFFIO_ -#define _TIFFIO_ - -/* - * TIFF I/O Library Definitions. - */ -#include "tiff.h" -#include "tiffvers.h" - -/* - * TIFF is defined as an incomplete type to hide the - * library's internal data structures from clients. - */ -typedef struct tiff TIFF; - -/* - * The following typedefs define the intrinsic size of - * data types used in the *exported* interfaces. These - * definitions depend on the proper definition of types - * in tiff.h. Note also that the varargs interface used - * to pass tag types and values uses the types defined in - * tiff.h directly. - * - * NB: ttag_t is unsigned int and not unsigned short because - * ANSI C requires that the type before the ellipsis be a - * promoted type (i.e. one of int, unsigned int, pointer, - * or double) and because we defined pseudo-tags that are - * outside the range of legal Aldus-assigned tags. - * NB: tsize_t is int32 and not uint32 because some functions - * return -1. - * NB: toff_t is not off_t for many reasons; TIFFs max out at - * 32-bit file offsets, and BigTIFF maxes out at 64-bit - * offsets being the most important, and to ensure use of - * a consistently unsigned type across architectures. - * Prior to libtiff 4.0, this was an unsigned 32 bit type. - */ -/* - * this is the machine addressing size type, only it's signed, so make it - * int32 on 32bit machines, int64 on 64bit machines - */ -typedef TIFF_SSIZE_T tmsize_t; -typedef uint64 toff_t; /* file offset */ -/* the following are deprecated and should be replaced by their defining - counterparts */ -typedef uint32 ttag_t; /* directory tag */ -typedef uint16 tdir_t; /* directory index */ -typedef uint16 tsample_t; /* sample number */ -typedef uint32 tstrile_t; /* strip or tile number */ -typedef tstrile_t tstrip_t; /* strip number */ -typedef tstrile_t ttile_t; /* tile number */ -typedef tmsize_t tsize_t; /* i/o size in bytes */ -typedef void* tdata_t; /* image data ref */ - -#if !defined(__WIN32__) && (defined(_WIN32) || defined(WIN32)) -#define __WIN32__ -#endif - -/* - * On windows you should define USE_WIN32_FILEIO if you are using tif_win32.c - * or AVOID_WIN32_FILEIO if you are using something else (like tif_unix.c). - * - * By default tif_unix.c is assumed. - */ - -#if defined(_WINDOWS) || defined(__WIN32__) || defined(_Windows) -# if !defined(__CYGWIN) && !defined(AVOID_WIN32_FILEIO) && !defined(USE_WIN32_FILEIO) -# define AVOID_WIN32_FILEIO -# endif -#endif - -#if defined(USE_WIN32_FILEIO) -# define VC_EXTRALEAN -# include <windows.h> -# ifdef __WIN32__ -DECLARE_HANDLE(thandle_t); /* Win32 file handle */ -# else -typedef HFILE thandle_t; /* client data handle */ -# endif /* __WIN32__ */ -#else -typedef void* thandle_t; /* client data handle */ -#endif /* USE_WIN32_FILEIO */ - -/* - * Flags to pass to TIFFPrintDirectory to control - * printing of data structures that are potentially - * very large. Bit-or these flags to enable printing - * multiple items. - */ -#define TIFFPRINT_NONE 0x0 /* no extra info */ -#define TIFFPRINT_STRIPS 0x1 /* strips/tiles info */ -#define TIFFPRINT_CURVES 0x2 /* color/gray response curves */ -#define TIFFPRINT_COLORMAP 0x4 /* colormap */ -#define TIFFPRINT_JPEGQTABLES 0x100 /* JPEG Q matrices */ -#define TIFFPRINT_JPEGACTABLES 0x200 /* JPEG AC tables */ -#define TIFFPRINT_JPEGDCTABLES 0x200 /* JPEG DC tables */ - -/* - * Colour conversion stuff - */ - -/* reference white */ -#define D65_X0 (95.0470F) -#define D65_Y0 (100.0F) -#define D65_Z0 (108.8827F) - -#define D50_X0 (96.4250F) -#define D50_Y0 (100.0F) -#define D50_Z0 (82.4680F) - -/* Structure for holding information about a display device. */ - -typedef unsigned char TIFFRGBValue; /* 8-bit samples */ - -typedef struct { - float d_mat[3][3]; /* XYZ -> luminance matrix */ - float d_YCR; /* Light o/p for reference white */ - float d_YCG; - float d_YCB; - uint32 d_Vrwr; /* Pixel values for ref. white */ - uint32 d_Vrwg; - uint32 d_Vrwb; - float d_Y0R; /* Residual light for black pixel */ - float d_Y0G; - float d_Y0B; - float d_gammaR; /* Gamma values for the three guns */ - float d_gammaG; - float d_gammaB; -} TIFFDisplay; - -typedef struct { /* YCbCr->RGB support */ - TIFFRGBValue* clamptab; /* range clamping table */ - int* Cr_r_tab; - int* Cb_b_tab; - int32* Cr_g_tab; - int32* Cb_g_tab; - int32* Y_tab; -} TIFFYCbCrToRGB; - -typedef struct { /* CIE Lab 1976->RGB support */ - int range; /* Size of conversion table */ -#define CIELABTORGB_TABLE_RANGE 1500 - float rstep, gstep, bstep; - float X0, Y0, Z0; /* Reference white point */ - TIFFDisplay display; - float Yr2r[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yr to r */ - float Yg2g[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yg to g */ - float Yb2b[CIELABTORGB_TABLE_RANGE + 1]; /* Conversion of Yb to b */ -} TIFFCIELabToRGB; - -/* - * RGBA-style image support. - */ -typedef struct _TIFFRGBAImage TIFFRGBAImage; -/* - * The image reading and conversion routines invoke - * ``put routines'' to copy/image/whatever tiles of - * raw image data. A default set of routines are - * provided to convert/copy raw image data to 8-bit - * packed ABGR format rasters. Applications can supply - * alternate routines that unpack the data into a - * different format or, for example, unpack the data - * and draw the unpacked raster on the display. - */ -typedef void (*tileContigRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*); -typedef void (*tileSeparateRoutine) - (TIFFRGBAImage*, uint32*, uint32, uint32, uint32, uint32, int32, int32, - unsigned char*, unsigned char*, unsigned char*, unsigned char*); -/* - * RGBA-reader state. - */ -struct _TIFFRGBAImage { - TIFF* tif; /* image handle */ - int stoponerr; /* stop on read error */ - int isContig; /* data is packed/separate */ - int alpha; /* type of alpha data present */ - uint32 width; /* image width */ - uint32 height; /* image height */ - uint16 bitspersample; /* image bits/sample */ - uint16 samplesperpixel; /* image samples/pixel */ - uint16 orientation; /* image orientation */ - uint16 req_orientation; /* requested orientation */ - uint16 photometric; /* image photometric interp */ - uint16* redcmap; /* colormap pallete */ - uint16* greencmap; - uint16* bluecmap; - /* get image data routine */ - int (*get)(TIFFRGBAImage*, uint32*, uint32, uint32); - /* put decoded strip/tile */ - union { - void (*any)(TIFFRGBAImage*); - tileContigRoutine contig; - tileSeparateRoutine separate; - } put; - TIFFRGBValue* Map; /* sample mapping array */ - uint32** BWmap; /* black&white map */ - uint32** PALmap; /* palette image map */ - TIFFYCbCrToRGB* ycbcr; /* YCbCr conversion state */ - TIFFCIELabToRGB* cielab; /* CIE L*a*b conversion state */ - - uint8* UaToAa; /* Unassociated alpha to associated alpha convertion LUT */ - uint8* Bitdepth16To8; /* LUT for conversion from 16bit to 8bit values */ - - int row_offset; - int col_offset; -}; - -/* - * Macros for extracting components from the - * packed ABGR form returned by TIFFReadRGBAImage. - */ -#define TIFFGetR(abgr) ((abgr) & 0xff) -#define TIFFGetG(abgr) (((abgr) >> 8) & 0xff) -#define TIFFGetB(abgr) (((abgr) >> 16) & 0xff) -#define TIFFGetA(abgr) (((abgr) >> 24) & 0xff) - -/* - * A CODEC is a software package that implements decoding, - * encoding, or decoding+encoding of a compression algorithm. - * The library provides a collection of builtin codecs. - * More codecs may be registered through calls to the library - * and/or the builtin implementations may be overridden. - */ -typedef int (*TIFFInitMethod)(TIFF*, int); -typedef struct { - char* name; - uint16 scheme; - TIFFInitMethod init; -} TIFFCodec; - -#include <stdio.h> -#include <stdarg.h> - -/* share internal LogLuv conversion routines? */ -#ifndef LOGLUV_PUBLIC -#define LOGLUV_PUBLIC 1 -#endif - -#if !defined(__GNUC__) && !defined(__attribute__) -# define __attribute__(x) /*nothing*/ -#endif - -#if defined(c_plusplus) || defined(__cplusplus) -extern "C" { -#endif -typedef void (*TIFFErrorHandler)(const char*, const char*, va_list); -typedef void (*TIFFErrorHandlerExt)(thandle_t, const char*, const char*, va_list); -typedef tmsize_t (*TIFFReadWriteProc)(thandle_t, void*, tmsize_t); -typedef toff_t (*TIFFSeekProc)(thandle_t, toff_t, int); -typedef int (*TIFFCloseProc)(thandle_t); -typedef toff_t (*TIFFSizeProc)(thandle_t); -typedef int (*TIFFMapFileProc)(thandle_t, void** base, toff_t* size); -typedef void (*TIFFUnmapFileProc)(thandle_t, void* base, toff_t size); -typedef void (*TIFFExtendProc)(TIFF*); - -extern const char* TIFFGetVersion(void); - -extern const TIFFCodec* TIFFFindCODEC(uint16); -extern TIFFCodec* TIFFRegisterCODEC(uint16, const char*, TIFFInitMethod); -extern void TIFFUnRegisterCODEC(TIFFCodec*); -extern int TIFFIsCODECConfigured(uint16); -extern TIFFCodec* TIFFGetConfiguredCODECs(void); - -/* - * Auxiliary functions. - */ - -extern void* _TIFFmalloc(tmsize_t s); -extern void* _TIFFrealloc(void* p, tmsize_t s); -extern void _TIFFmemset(void* p, int v, tmsize_t c); -extern void _TIFFmemcpy(void* d, const void* s, tmsize_t c); -extern int _TIFFmemcmp(const void* p1, const void* p2, tmsize_t c); -extern void _TIFFfree(void* p); - -/* -** Stuff, related to tag handling and creating custom tags. -*/ -extern int TIFFGetTagListCount( TIFF * ); -extern uint32 TIFFGetTagListEntry( TIFF *, int tag_index ); - -#define TIFF_ANY TIFF_NOTYPE /* for field descriptor searching */ -#define TIFF_VARIABLE -1 /* marker for variable length tags */ -#define TIFF_SPP -2 /* marker for SamplesPerPixel tags */ -#define TIFF_VARIABLE2 -3 /* marker for uint32 var-length tags */ - -#define FIELD_CUSTOM 65 - -typedef struct _TIFFField TIFFField; -typedef struct _TIFFFieldArray TIFFFieldArray; - -extern const TIFFField* TIFFFindField(TIFF *, uint32, TIFFDataType); -extern const TIFFField* TIFFFieldWithTag(TIFF*, uint32); -extern const TIFFField* TIFFFieldWithName(TIFF*, const char *); - -extern uint32 TIFFFieldTag(const TIFFField*); -extern const char* TIFFFieldName(const TIFFField*); -extern TIFFDataType TIFFFieldDataType(const TIFFField*); -extern int TIFFFieldPassCount(const TIFFField*); -extern int TIFFFieldReadCount(const TIFFField*); -extern int TIFFFieldWriteCount(const TIFFField*); - -typedef int (*TIFFVSetMethod)(TIFF*, uint32, va_list); -typedef int (*TIFFVGetMethod)(TIFF*, uint32, va_list); -typedef void (*TIFFPrintMethod)(TIFF*, FILE*, long); - -typedef struct { - TIFFVSetMethod vsetfield; /* tag set routine */ - TIFFVGetMethod vgetfield; /* tag get routine */ - TIFFPrintMethod printdir; /* directory print routine */ -} TIFFTagMethods; - -extern TIFFTagMethods *TIFFAccessTagMethods(TIFF *); -extern void *TIFFGetClientInfo(TIFF *, const char *); -extern void TIFFSetClientInfo(TIFF *, void *, const char *); - -extern void TIFFCleanup(TIFF* tif); -extern void TIFFClose(TIFF* tif); -extern int TIFFFlush(TIFF* tif); -extern int TIFFFlushData(TIFF* tif); -extern int TIFFGetField(TIFF* tif, uint32 tag, ...); -extern int TIFFVGetField(TIFF* tif, uint32 tag, va_list ap); -extern int TIFFGetFieldDefaulted(TIFF* tif, uint32 tag, ...); -extern int TIFFVGetFieldDefaulted(TIFF* tif, uint32 tag, va_list ap); -extern int TIFFReadDirectory(TIFF* tif); -extern int TIFFReadCustomDirectory(TIFF* tif, toff_t diroff, const TIFFFieldArray* infoarray); -extern int TIFFReadEXIFDirectory(TIFF* tif, toff_t diroff); -extern uint64 TIFFScanlineSize64(TIFF* tif); -extern tmsize_t TIFFScanlineSize(TIFF* tif); -extern uint64 TIFFRasterScanlineSize64(TIFF* tif); -extern tmsize_t TIFFRasterScanlineSize(TIFF* tif); -extern uint64 TIFFStripSize64(TIFF* tif); -extern tmsize_t TIFFStripSize(TIFF* tif); -extern uint64 TIFFRawStripSize64(TIFF* tif, uint32 strip); -extern tmsize_t TIFFRawStripSize(TIFF* tif, uint32 strip); -extern uint64 TIFFVStripSize64(TIFF* tif, uint32 nrows); -extern tmsize_t TIFFVStripSize(TIFF* tif, uint32 nrows); -extern uint64 TIFFTileRowSize64(TIFF* tif); -extern tmsize_t TIFFTileRowSize(TIFF* tif); -extern uint64 TIFFTileSize64(TIFF* tif); -extern tmsize_t TIFFTileSize(TIFF* tif); -extern uint64 TIFFVTileSize64(TIFF* tif, uint32 nrows); -extern tmsize_t TIFFVTileSize(TIFF* tif, uint32 nrows); -extern uint32 TIFFDefaultStripSize(TIFF* tif, uint32 request); -extern void TIFFDefaultTileSize(TIFF*, uint32*, uint32*); -extern int TIFFFileno(TIFF*); -extern int TIFFSetFileno(TIFF*, int); -extern thandle_t TIFFClientdata(TIFF*); -extern thandle_t TIFFSetClientdata(TIFF*, thandle_t); -extern int TIFFGetMode(TIFF*); -extern int TIFFSetMode(TIFF*, int); -extern int TIFFIsTiled(TIFF*); -extern int TIFFIsByteSwapped(TIFF*); -extern int TIFFIsUpSampled(TIFF*); -extern int TIFFIsMSB2LSB(TIFF*); -extern int TIFFIsBigEndian(TIFF*); -extern TIFFReadWriteProc TIFFGetReadProc(TIFF*); -extern TIFFReadWriteProc TIFFGetWriteProc(TIFF*); -extern TIFFSeekProc TIFFGetSeekProc(TIFF*); -extern TIFFCloseProc TIFFGetCloseProc(TIFF*); -extern TIFFSizeProc TIFFGetSizeProc(TIFF*); -extern TIFFMapFileProc TIFFGetMapFileProc(TIFF*); -extern TIFFUnmapFileProc TIFFGetUnmapFileProc(TIFF*); -extern uint32 TIFFCurrentRow(TIFF*); -extern uint16 TIFFCurrentDirectory(TIFF*); -extern uint16 TIFFNumberOfDirectories(TIFF*); -extern uint64 TIFFCurrentDirOffset(TIFF*); -extern uint32 TIFFCurrentStrip(TIFF*); -extern uint32 TIFFCurrentTile(TIFF* tif); -extern int TIFFReadBufferSetup(TIFF* tif, void* bp, tmsize_t size); -extern int TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size); -extern int TIFFSetupStrips(TIFF *); -extern int TIFFWriteCheck(TIFF*, int, const char *); -extern void TIFFFreeDirectory(TIFF*); -extern int TIFFCreateDirectory(TIFF*); -extern int TIFFCreateCustomDirectory(TIFF*,const TIFFFieldArray*); -extern int TIFFCreateEXIFDirectory(TIFF*); -extern int TIFFLastDirectory(TIFF*); -extern int TIFFSetDirectory(TIFF*, uint16); -extern int TIFFSetSubDirectory(TIFF*, uint64); -extern int TIFFUnlinkDirectory(TIFF*, uint16); -extern int TIFFSetField(TIFF*, uint32, ...); -extern int TIFFVSetField(TIFF*, uint32, va_list); -extern int TIFFUnsetField(TIFF*, uint32); -extern int TIFFWriteDirectory(TIFF *); -extern int TIFFWriteCustomDirectory(TIFF *, uint64 *); -extern int TIFFCheckpointDirectory(TIFF *); -extern int TIFFRewriteDirectory(TIFF *); - -#if defined(c_plusplus) || defined(__cplusplus) -extern void TIFFPrintDirectory(TIFF*, FILE*, long = 0); -extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); -extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample = 0); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int = 0); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, - int = ORIENTATION_BOTLEFT, int = 0); -#else -extern void TIFFPrintDirectory(TIFF*, FILE*, long); -extern int TIFFReadScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); -extern int TIFFWriteScanline(TIFF* tif, void* buf, uint32 row, uint16 sample); -extern int TIFFReadRGBAImage(TIFF*, uint32, uint32, uint32*, int); -extern int TIFFReadRGBAImageOriented(TIFF*, uint32, uint32, uint32*, int, int); -#endif - -extern int TIFFReadRGBAStrip(TIFF*, uint32, uint32 * ); -extern int TIFFReadRGBATile(TIFF*, uint32, uint32, uint32 * ); -extern int TIFFRGBAImageOK(TIFF*, char [1024]); -extern int TIFFRGBAImageBegin(TIFFRGBAImage*, TIFF*, int, char [1024]); -extern int TIFFRGBAImageGet(TIFFRGBAImage*, uint32*, uint32, uint32); -extern void TIFFRGBAImageEnd(TIFFRGBAImage*); -extern TIFF* TIFFOpen(const char*, const char*); -# ifdef __WIN32__ -extern TIFF* TIFFOpenW(const wchar_t*, const char*); -# endif /* __WIN32__ */ -extern TIFF* TIFFFdOpen(int, const char*, const char*); -extern TIFF* TIFFClientOpen(const char*, const char*, - thandle_t, - TIFFReadWriteProc, TIFFReadWriteProc, - TIFFSeekProc, TIFFCloseProc, - TIFFSizeProc, - TIFFMapFileProc, TIFFUnmapFileProc); -extern const char* TIFFFileName(TIFF*); -extern const char* TIFFSetFileName(TIFF*, const char *); -extern void TIFFError(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); -extern void TIFFErrorExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); -extern void TIFFWarning(const char*, const char*, ...) __attribute__((__format__ (__printf__,2,3))); -extern void TIFFWarningExt(thandle_t, const char*, const char*, ...) __attribute__((__format__ (__printf__,3,4))); -extern TIFFErrorHandler TIFFSetErrorHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetErrorHandlerExt(TIFFErrorHandlerExt); -extern TIFFErrorHandler TIFFSetWarningHandler(TIFFErrorHandler); -extern TIFFErrorHandlerExt TIFFSetWarningHandlerExt(TIFFErrorHandlerExt); -extern TIFFExtendProc TIFFSetTagExtender(TIFFExtendProc); -extern uint32 TIFFComputeTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); -extern int TIFFCheckTile(TIFF* tif, uint32 x, uint32 y, uint32 z, uint16 s); -extern uint32 TIFFNumberOfTiles(TIFF*); -extern tmsize_t TIFFReadTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); -extern tmsize_t TIFFWriteTile(TIFF* tif, void* buf, uint32 x, uint32 y, uint32 z, uint16 s); -extern uint32 TIFFComputeStrip(TIFF*, uint32, uint16); -extern uint32 TIFFNumberOfStrips(TIFF*); -extern tmsize_t TIFFReadEncodedStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); -extern tmsize_t TIFFReadRawStrip(TIFF* tif, uint32 strip, void* buf, tmsize_t size); -extern tmsize_t TIFFReadEncodedTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); -extern tmsize_t TIFFReadRawTile(TIFF* tif, uint32 tile, void* buf, tmsize_t size); -extern tmsize_t TIFFWriteEncodedStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteRawStrip(TIFF* tif, uint32 strip, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteEncodedTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); -extern tmsize_t TIFFWriteRawTile(TIFF* tif, uint32 tile, void* data, tmsize_t cc); -extern int TIFFDataWidth(TIFFDataType); /* table of tag datatype widths */ -extern void TIFFSetWriteOffset(TIFF* tif, toff_t off); -extern void TIFFSwabShort(uint16*); -extern void TIFFSwabLong(uint32*); -extern void TIFFSwabLong8(uint64*); -extern void TIFFSwabFloat(float*); -extern void TIFFSwabDouble(double*); -extern void TIFFSwabArrayOfShort(uint16* wp, tmsize_t n); -extern void TIFFSwabArrayOfTriples(uint8* tp, tmsize_t n); -extern void TIFFSwabArrayOfLong(uint32* lp, tmsize_t n); -extern void TIFFSwabArrayOfLong8(uint64* lp, tmsize_t n); -extern void TIFFSwabArrayOfFloat(float* fp, tmsize_t n); -extern void TIFFSwabArrayOfDouble(double* dp, tmsize_t n); -extern void TIFFReverseBits(uint8* cp, tmsize_t n); -extern const unsigned char* TIFFGetBitRevTable(int); - -#ifdef LOGLUV_PUBLIC -#define U_NEU 0.210526316 -#define V_NEU 0.473684211 -#define UVSCALE 410. -extern double LogL16toY(int); -extern double LogL10toY(int); -extern void XYZtoRGB24(float*, uint8*); -extern int uv_decode(double*, double*, int); -extern void LogLuv24toXYZ(uint32, float*); -extern void LogLuv32toXYZ(uint32, float*); -#if defined(c_plusplus) || defined(__cplusplus) -extern int LogL16fromY(double, int = SGILOGENCODE_NODITHER); -extern int LogL10fromY(double, int = SGILOGENCODE_NODITHER); -extern int uv_encode(double, double, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv24fromXYZ(float*, int = SGILOGENCODE_NODITHER); -extern uint32 LogLuv32fromXYZ(float*, int = SGILOGENCODE_NODITHER); -#else -extern int LogL16fromY(double, int); -extern int LogL10fromY(double, int); -extern int uv_encode(double, double, int); -extern uint32 LogLuv24fromXYZ(float*, int); -extern uint32 LogLuv32fromXYZ(float*, int); -#endif -#endif /* LOGLUV_PUBLIC */ - -extern int TIFFCIELabToRGBInit(TIFFCIELabToRGB*, const TIFFDisplay *, float*); -extern void TIFFCIELabToXYZ(TIFFCIELabToRGB *, uint32, int32, int32, - float *, float *, float *); -extern void TIFFXYZToRGB(TIFFCIELabToRGB *, float, float, float, - uint32 *, uint32 *, uint32 *); - -extern int TIFFYCbCrToRGBInit(TIFFYCbCrToRGB*, float*, float*); -extern void TIFFYCbCrtoRGB(TIFFYCbCrToRGB *, uint32, int32, int32, - uint32 *, uint32 *, uint32 *); - -/**************************************************************************** - * O B S O L E T E D I N T E R F A C E S - * - * Don't use this stuff in your applications, it may be removed in the future - * libtiff versions. - ****************************************************************************/ -typedef struct { - ttag_t field_tag; /* field's tag */ - short field_readcount; /* read count/TIFF_VARIABLE/TIFF_SPP */ - short field_writecount; /* write count/TIFF_VARIABLE */ - TIFFDataType field_type; /* type of associated data */ - unsigned short field_bit; /* bit in fieldsset bit vector */ - unsigned char field_oktochange; /* if true, can change while writing */ - unsigned char field_passcount; /* if true, pass dir count on set */ - char *field_name; /* ASCII name */ -} TIFFFieldInfo; - -extern int TIFFMergeFieldInfo(TIFF*, const TIFFFieldInfo[], uint32); - -#if defined(c_plusplus) || defined(__cplusplus) -} -#endif - -#endif /* _TIFFIO_ */ - -/* vim: set ts=8 sts=8 sw=8 noet: */ -/* - * Local Variables: - * mode: c - * c-basic-offset: 8 - * fill-column: 78 - * End: - */ diff --git a/android/armeabi/include/tiff/tiffvers.h b/android/armeabi/include/tiff/tiffvers.h deleted file mode 100644 index e965814b..00000000 --- a/android/armeabi/include/tiff/tiffvers.h +++ /dev/null @@ -1,9 +0,0 @@ -#define TIFFLIB_VERSION_STR "LIBTIFF, Version 4.0.6\nCopyright (c) 1988-1996 Sam Leffler\nCopyright (c) 1991-1996 Silicon Graphics, Inc." -/* - * This define can be used in code that requires - * compilation-related definitions specific to a - * version or versions of the library. Runtime - * version checking should be done based on the - * string returned by TIFFGetVersion. - */ -#define TIFFLIB_VERSION 20150912 diff --git a/android/armeabi/include/uv/pthread-barrier.h b/android/armeabi/include/uv/pthread-barrier.h deleted file mode 100644 index 900ebedd..00000000 --- a/android/armeabi/include/uv/pthread-barrier.h +++ /dev/null @@ -1,68 +0,0 @@ -/* -Copyright (c) 2016, Kari Tristan Helgason <kthelgason@gmail.com> - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ - -#ifndef _UV_PTHREAD_BARRIER_ -#define _UV_PTHREAD_BARRIER_ -#include <errno.h> -#include <pthread.h> -#if !defined(__MVS__) -#include <semaphore.h> /* sem_t */ -#endif - -#define PTHREAD_BARRIER_SERIAL_THREAD 0x12345 - -/* - * To maintain ABI compatibility with - * libuv v1.x struct is padded according - * to target platform - */ -#if defined(__ANDROID__) -# define UV_BARRIER_STRUCT_PADDING \ - sizeof(pthread_mutex_t) + \ - sizeof(pthread_cond_t) + \ - sizeof(unsigned int) - \ - sizeof(void *) -#elif defined(__APPLE__) -# define UV_BARRIER_STRUCT_PADDING \ - sizeof(pthread_mutex_t) + \ - 2 * sizeof(sem_t) + \ - 2 * sizeof(unsigned int) - \ - sizeof(void *) -#else -# define UV_BARRIER_STRUCT_PADDING 0 -#endif - -typedef struct { - pthread_mutex_t mutex; - pthread_cond_t cond; - unsigned threshold; - unsigned in; - unsigned out; -} _uv_barrier; - -typedef struct { - _uv_barrier* b; - char _pad[UV_BARRIER_STRUCT_PADDING]; -} pthread_barrier_t; - -int pthread_barrier_init(pthread_barrier_t* barrier, - const void* barrier_attr, - unsigned count); - -int pthread_barrier_wait(pthread_barrier_t* barrier); -int pthread_barrier_destroy(pthread_barrier_t *barrier); - -#endif /* _UV_PTHREAD_BARRIER_ */ diff --git a/android/armeabi/include/uv/stdint-msvc2008.h b/android/armeabi/include/uv/stdint-msvc2008.h deleted file mode 100644 index d02608a5..00000000 --- a/android/armeabi/include/uv/stdint-msvc2008.h +++ /dev/null @@ -1,247 +0,0 @@ -// ISO C9x compliant stdint.h for Microsoft Visual Studio -// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 -// -// Copyright (c) 2006-2008 Alexander Chemeris -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, -// this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. The name of the author may be used to endorse or promote products -// derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED -// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO -// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT 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 _MSC_VER // [ -#error "Use this header only with Microsoft Visual C++ compilers!" -#endif // _MSC_VER ] - -#ifndef _MSC_STDINT_H_ // [ -#define _MSC_STDINT_H_ - -#if _MSC_VER > 1000 -#pragma once -#endif - -#include <limits.h> - -// For Visual Studio 6 in C++ mode and for many Visual Studio versions when -// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}' -// or compiler give many errors like this: -// error C2733: second C linkage of overloaded function 'wmemchr' not allowed -#ifdef __cplusplus -extern "C" { -#endif -# include <wchar.h> -#ifdef __cplusplus -} -#endif - -// Define _W64 macros to mark types changing their size, like intptr_t. -#ifndef _W64 -# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 -# define _W64 __w64 -# else -# define _W64 -# endif -#endif - - -// 7.18.1 Integer types - -// 7.18.1.1 Exact-width integer types - -// Visual Studio 6 and Embedded Visual C++ 4 doesn't -// realize that, e.g. char has the same size as __int8 -// so we give up on __intX for them. -#if (_MSC_VER < 1300) - typedef signed char int8_t; - typedef signed short int16_t; - typedef signed int int32_t; - typedef unsigned char uint8_t; - typedef unsigned short uint16_t; - typedef unsigned int uint32_t; -#else - typedef signed __int8 int8_t; - typedef signed __int16 int16_t; - typedef signed __int32 int32_t; - typedef unsigned __int8 uint8_t; - typedef unsigned __int16 uint16_t; - typedef unsigned __int32 uint32_t; -#endif -typedef signed __int64 int64_t; -typedef unsigned __int64 uint64_t; - - -// 7.18.1.2 Minimum-width integer types -typedef int8_t int_least8_t; -typedef int16_t int_least16_t; -typedef int32_t int_least32_t; -typedef int64_t int_least64_t; -typedef uint8_t uint_least8_t; -typedef uint16_t uint_least16_t; -typedef uint32_t uint_least32_t; -typedef uint64_t uint_least64_t; - -// 7.18.1.3 Fastest minimum-width integer types -typedef int8_t int_fast8_t; -typedef int16_t int_fast16_t; -typedef int32_t int_fast32_t; -typedef int64_t int_fast64_t; -typedef uint8_t uint_fast8_t; -typedef uint16_t uint_fast16_t; -typedef uint32_t uint_fast32_t; -typedef uint64_t uint_fast64_t; - -// 7.18.1.4 Integer types capable of holding object pointers -#ifdef _WIN64 // [ - typedef signed __int64 intptr_t; - typedef unsigned __int64 uintptr_t; -#else // _WIN64 ][ - typedef _W64 signed int intptr_t; - typedef _W64 unsigned int uintptr_t; -#endif // _WIN64 ] - -// 7.18.1.5 Greatest-width integer types -typedef int64_t intmax_t; -typedef uint64_t uintmax_t; - - -// 7.18.2 Limits of specified-width integer types - -#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 - -// 7.18.2.1 Limits of exact-width integer types -#define INT8_MIN ((int8_t)_I8_MIN) -#define INT8_MAX _I8_MAX -#define INT16_MIN ((int16_t)_I16_MIN) -#define INT16_MAX _I16_MAX -#define INT32_MIN ((int32_t)_I32_MIN) -#define INT32_MAX _I32_MAX -#define INT64_MIN ((int64_t)_I64_MIN) -#define INT64_MAX _I64_MAX -#define UINT8_MAX _UI8_MAX -#define UINT16_MAX _UI16_MAX -#define UINT32_MAX _UI32_MAX -#define UINT64_MAX _UI64_MAX - -// 7.18.2.2 Limits of minimum-width integer types -#define INT_LEAST8_MIN INT8_MIN -#define INT_LEAST8_MAX INT8_MAX -#define INT_LEAST16_MIN INT16_MIN -#define INT_LEAST16_MAX INT16_MAX -#define INT_LEAST32_MIN INT32_MIN -#define INT_LEAST32_MAX INT32_MAX -#define INT_LEAST64_MIN INT64_MIN -#define INT_LEAST64_MAX INT64_MAX -#define UINT_LEAST8_MAX UINT8_MAX -#define UINT_LEAST16_MAX UINT16_MAX -#define UINT_LEAST32_MAX UINT32_MAX -#define UINT_LEAST64_MAX UINT64_MAX - -// 7.18.2.3 Limits of fastest minimum-width integer types -#define INT_FAST8_MIN INT8_MIN -#define INT_FAST8_MAX INT8_MAX -#define INT_FAST16_MIN INT16_MIN -#define INT_FAST16_MAX INT16_MAX -#define INT_FAST32_MIN INT32_MIN -#define INT_FAST32_MAX INT32_MAX -#define INT_FAST64_MIN INT64_MIN -#define INT_FAST64_MAX INT64_MAX -#define UINT_FAST8_MAX UINT8_MAX -#define UINT_FAST16_MAX UINT16_MAX -#define UINT_FAST32_MAX UINT32_MAX -#define UINT_FAST64_MAX UINT64_MAX - -// 7.18.2.4 Limits of integer types capable of holding object pointers -#ifdef _WIN64 // [ -# define INTPTR_MIN INT64_MIN -# define INTPTR_MAX INT64_MAX -# define UINTPTR_MAX UINT64_MAX -#else // _WIN64 ][ -# define INTPTR_MIN INT32_MIN -# define INTPTR_MAX INT32_MAX -# define UINTPTR_MAX UINT32_MAX -#endif // _WIN64 ] - -// 7.18.2.5 Limits of greatest-width integer types -#define INTMAX_MIN INT64_MIN -#define INTMAX_MAX INT64_MAX -#define UINTMAX_MAX UINT64_MAX - -// 7.18.3 Limits of other integer types - -#ifdef _WIN64 // [ -# define PTRDIFF_MIN _I64_MIN -# define PTRDIFF_MAX _I64_MAX -#else // _WIN64 ][ -# define PTRDIFF_MIN _I32_MIN -# define PTRDIFF_MAX _I32_MAX -#endif // _WIN64 ] - -#define SIG_ATOMIC_MIN INT_MIN -#define SIG_ATOMIC_MAX INT_MAX - -#ifndef SIZE_MAX // [ -# ifdef _WIN64 // [ -# define SIZE_MAX _UI64_MAX -# else // _WIN64 ][ -# define SIZE_MAX _UI32_MAX -# endif // _WIN64 ] -#endif // SIZE_MAX ] - -// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h> -#ifndef WCHAR_MIN // [ -# define WCHAR_MIN 0 -#endif // WCHAR_MIN ] -#ifndef WCHAR_MAX // [ -# define WCHAR_MAX _UI16_MAX -#endif // WCHAR_MAX ] - -#define WINT_MIN 0 -#define WINT_MAX _UI16_MAX - -#endif // __STDC_LIMIT_MACROS ] - - -// 7.18.4 Limits of other integer types - -#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 - -// 7.18.4.1 Macros for minimum-width integer constants - -#define INT8_C(val) val##i8 -#define INT16_C(val) val##i16 -#define INT32_C(val) val##i32 -#define INT64_C(val) val##i64 - -#define UINT8_C(val) val##ui8 -#define UINT16_C(val) val##ui16 -#define UINT32_C(val) val##ui32 -#define UINT64_C(val) val##ui64 - -// 7.18.4.2 Macros for greatest-width integer constants -#define INTMAX_C INT64_C -#define UINTMAX_C UINT64_C - -#endif // __STDC_CONSTANT_MACROS ] - - -#endif // _MSC_STDINT_H_ ] diff --git a/android/armeabi/include/uv/tree.h b/android/armeabi/include/uv/tree.h deleted file mode 100644 index f936416e..00000000 --- a/android/armeabi/include/uv/tree.h +++ /dev/null @@ -1,768 +0,0 @@ -/*- - * Copyright 2002 Niels Provos <provos@citi.umich.edu> - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 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 UV_TREE_H_ -#define UV_TREE_H_ - -#ifndef UV__UNUSED -# if __GNUC__ -# define UV__UNUSED __attribute__((unused)) -# else -# define UV__UNUSED -# endif -#endif - -/* - * This file defines data structures for different types of trees: - * splay trees and red-black trees. - * - * A splay tree is a self-organizing data structure. Every operation - * on the tree causes a splay to happen. The splay moves the requested - * node to the root of the tree and partly rebalances it. - * - * This has the benefit that request locality causes faster lookups as - * the requested nodes move to the top of the tree. On the other hand, - * every lookup causes memory writes. - * - * The Balance Theorem bounds the total access time for m operations - * and n inserts on an initially empty tree as O((m + n)lg n). The - * amortized cost for a sequence of m accesses to a splay tree is O(lg n); - * - * A red-black tree is a binary search tree with the node color as an - * extra attribute. It fulfills a set of conditions: - * - every search path from the root to a leaf consists of the - * same number of black nodes, - * - each red node (except for the root) has a black parent, - * - each leaf node is black. - * - * Every operation on a red-black tree is bounded as O(lg n). - * The maximum height of a red-black tree is 2lg (n+1). - */ - -#define SPLAY_HEAD(name, type) \ -struct name { \ - struct type *sph_root; /* root of the tree */ \ -} - -#define SPLAY_INITIALIZER(root) \ - { NULL } - -#define SPLAY_INIT(root) do { \ - (root)->sph_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ENTRY(type) \ -struct { \ - struct type *spe_left; /* left element */ \ - struct type *spe_right; /* right element */ \ -} - -#define SPLAY_LEFT(elm, field) (elm)->field.spe_left -#define SPLAY_RIGHT(elm, field) (elm)->field.spe_right -#define SPLAY_ROOT(head) (head)->sph_root -#define SPLAY_EMPTY(head) (SPLAY_ROOT(head) == NULL) - -/* SPLAY_ROTATE_{LEFT,RIGHT} expect that tmp hold SPLAY_{RIGHT,LEFT} */ -#define SPLAY_ROTATE_RIGHT(head, tmp, field) do { \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(tmp, field); \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ROTATE_LEFT(head, tmp, field) do { \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(tmp, field); \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - (head)->sph_root = tmp; \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKLEFT(head, tmp, field) do { \ - SPLAY_LEFT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_LINKRIGHT(head, tmp, field) do { \ - SPLAY_RIGHT(tmp, field) = (head)->sph_root; \ - tmp = (head)->sph_root; \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ -} while (/*CONSTCOND*/ 0) - -#define SPLAY_ASSEMBLE(head, node, left, right, field) do { \ - SPLAY_RIGHT(left, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_LEFT(right, field) = SPLAY_RIGHT((head)->sph_root, field); \ - SPLAY_LEFT((head)->sph_root, field) = SPLAY_RIGHT(node, field); \ - SPLAY_RIGHT((head)->sph_root, field) = SPLAY_LEFT(node, field); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ - -#define SPLAY_PROTOTYPE(name, type, field, cmp) \ -void name##_SPLAY(struct name *, struct type *); \ -void name##_SPLAY_MINMAX(struct name *, int); \ -struct type *name##_SPLAY_INSERT(struct name *, struct type *); \ -struct type *name##_SPLAY_REMOVE(struct name *, struct type *); \ - \ -/* Finds the node with the same key as elm */ \ -static __inline struct type * \ -name##_SPLAY_FIND(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) \ - return(NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) \ - return (head->sph_root); \ - return (NULL); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_NEXT(struct name *head, struct type *elm) \ -{ \ - name##_SPLAY(head, elm); \ - if (SPLAY_RIGHT(elm, field) != NULL) { \ - elm = SPLAY_RIGHT(elm, field); \ - while (SPLAY_LEFT(elm, field) != NULL) { \ - elm = SPLAY_LEFT(elm, field); \ - } \ - } else \ - elm = NULL; \ - return (elm); \ -} \ - \ -static __inline struct type * \ -name##_SPLAY_MIN_MAX(struct name *head, int val) \ -{ \ - name##_SPLAY_MINMAX(head, val); \ - return (SPLAY_ROOT(head)); \ -} - -/* Main splay operation. - * Moves node close to the key of elm to top - */ -#define SPLAY_GENERATE(name, type, field, cmp) \ -struct type * \ -name##_SPLAY_INSERT(struct name *head, struct type *elm) \ -{ \ - if (SPLAY_EMPTY(head)) { \ - SPLAY_LEFT(elm, field) = SPLAY_RIGHT(elm, field) = NULL; \ - } else { \ - int __comp; \ - name##_SPLAY(head, elm); \ - __comp = (cmp)(elm, (head)->sph_root); \ - if(__comp < 0) { \ - SPLAY_LEFT(elm, field) = SPLAY_LEFT((head)->sph_root, field); \ - SPLAY_RIGHT(elm, field) = (head)->sph_root; \ - SPLAY_LEFT((head)->sph_root, field) = NULL; \ - } else if (__comp > 0) { \ - SPLAY_RIGHT(elm, field) = SPLAY_RIGHT((head)->sph_root, field); \ - SPLAY_LEFT(elm, field) = (head)->sph_root; \ - SPLAY_RIGHT((head)->sph_root, field) = NULL; \ - } else \ - return ((head)->sph_root); \ - } \ - (head)->sph_root = (elm); \ - return (NULL); \ -} \ - \ -struct type * \ -name##_SPLAY_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *__tmp; \ - if (SPLAY_EMPTY(head)) \ - return (NULL); \ - name##_SPLAY(head, elm); \ - if ((cmp)(elm, (head)->sph_root) == 0) { \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) { \ - (head)->sph_root = SPLAY_RIGHT((head)->sph_root, field); \ - } else { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - (head)->sph_root = SPLAY_LEFT((head)->sph_root, field); \ - name##_SPLAY(head, elm); \ - SPLAY_RIGHT((head)->sph_root, field) = __tmp; \ - } \ - return (elm); \ - } \ - return (NULL); \ -} \ - \ -void \ -name##_SPLAY(struct name *head, struct type *elm) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - int __comp; \ - \ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ - __left = __right = &__node; \ - \ - while ((__comp = (cmp)(elm, (head)->sph_root)) != 0) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if ((cmp)(elm, __tmp) > 0){ \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} \ - \ -/* Splay with either the minimum or the maximum element \ - * Used to find minimum or maximum element in tree. \ - */ \ -void name##_SPLAY_MINMAX(struct name *head, int __comp) \ -{ \ - struct type __node, *__left, *__right, *__tmp; \ - \ - SPLAY_LEFT(&__node, field) = SPLAY_RIGHT(&__node, field) = NULL; \ - __left = __right = &__node; \ - \ - while (1) { \ - if (__comp < 0) { \ - __tmp = SPLAY_LEFT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp < 0){ \ - SPLAY_ROTATE_RIGHT(head, __tmp, field); \ - if (SPLAY_LEFT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKLEFT(head, __right, field); \ - } else if (__comp > 0) { \ - __tmp = SPLAY_RIGHT((head)->sph_root, field); \ - if (__tmp == NULL) \ - break; \ - if (__comp > 0) { \ - SPLAY_ROTATE_LEFT(head, __tmp, field); \ - if (SPLAY_RIGHT((head)->sph_root, field) == NULL) \ - break; \ - } \ - SPLAY_LINKRIGHT(head, __left, field); \ - } \ - } \ - SPLAY_ASSEMBLE(head, &__node, __left, __right, field); \ -} - -#define SPLAY_NEGINF -1 -#define SPLAY_INF 1 - -#define SPLAY_INSERT(name, x, y) name##_SPLAY_INSERT(x, y) -#define SPLAY_REMOVE(name, x, y) name##_SPLAY_REMOVE(x, y) -#define SPLAY_FIND(name, x, y) name##_SPLAY_FIND(x, y) -#define SPLAY_NEXT(name, x, y) name##_SPLAY_NEXT(x, y) -#define SPLAY_MIN(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_NEGINF)) -#define SPLAY_MAX(name, x) (SPLAY_EMPTY(x) ? NULL \ - : name##_SPLAY_MIN_MAX(x, SPLAY_INF)) - -#define SPLAY_FOREACH(x, name, head) \ - for ((x) = SPLAY_MIN(name, head); \ - (x) != NULL; \ - (x) = SPLAY_NEXT(name, head, x)) - -/* Macros that define a red-black tree */ -#define RB_HEAD(name, type) \ -struct name { \ - struct type *rbh_root; /* root of the tree */ \ -} - -#define RB_INITIALIZER(root) \ - { NULL } - -#define RB_INIT(root) do { \ - (root)->rbh_root = NULL; \ -} while (/*CONSTCOND*/ 0) - -#define RB_BLACK 0 -#define RB_RED 1 -#define RB_ENTRY(type) \ -struct { \ - struct type *rbe_left; /* left element */ \ - struct type *rbe_right; /* right element */ \ - struct type *rbe_parent; /* parent element */ \ - int rbe_color; /* node color */ \ -} - -#define RB_LEFT(elm, field) (elm)->field.rbe_left -#define RB_RIGHT(elm, field) (elm)->field.rbe_right -#define RB_PARENT(elm, field) (elm)->field.rbe_parent -#define RB_COLOR(elm, field) (elm)->field.rbe_color -#define RB_ROOT(head) (head)->rbh_root -#define RB_EMPTY(head) (RB_ROOT(head) == NULL) - -#define RB_SET(elm, parent, field) do { \ - RB_PARENT(elm, field) = parent; \ - RB_LEFT(elm, field) = RB_RIGHT(elm, field) = NULL; \ - RB_COLOR(elm, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#define RB_SET_BLACKRED(black, red, field) do { \ - RB_COLOR(black, field) = RB_BLACK; \ - RB_COLOR(red, field) = RB_RED; \ -} while (/*CONSTCOND*/ 0) - -#ifndef RB_AUGMENT -#define RB_AUGMENT(x) do {} while (0) -#endif - -#define RB_ROTATE_LEFT(head, elm, tmp, field) do { \ - (tmp) = RB_RIGHT(elm, field); \ - if ((RB_RIGHT(elm, field) = RB_LEFT(tmp, field)) != NULL) { \ - RB_PARENT(RB_LEFT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_LEFT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -#define RB_ROTATE_RIGHT(head, elm, tmp, field) do { \ - (tmp) = RB_LEFT(elm, field); \ - if ((RB_LEFT(elm, field) = RB_RIGHT(tmp, field)) != NULL) { \ - RB_PARENT(RB_RIGHT(tmp, field), field) = (elm); \ - } \ - RB_AUGMENT(elm); \ - if ((RB_PARENT(tmp, field) = RB_PARENT(elm, field)) != NULL) { \ - if ((elm) == RB_LEFT(RB_PARENT(elm, field), field)) \ - RB_LEFT(RB_PARENT(elm, field), field) = (tmp); \ - else \ - RB_RIGHT(RB_PARENT(elm, field), field) = (tmp); \ - } else \ - (head)->rbh_root = (tmp); \ - RB_RIGHT(tmp, field) = (elm); \ - RB_PARENT(elm, field) = (tmp); \ - RB_AUGMENT(tmp); \ - if ((RB_PARENT(tmp, field))) \ - RB_AUGMENT(RB_PARENT(tmp, field)); \ -} while (/*CONSTCOND*/ 0) - -/* Generates prototypes and inline functions */ -#define RB_PROTOTYPE(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp,) -#define RB_PROTOTYPE_STATIC(name, type, field, cmp) \ - RB_PROTOTYPE_INTERNAL(name, type, field, cmp, UV__UNUSED static) -#define RB_PROTOTYPE_INTERNAL(name, type, field, cmp, attr) \ -attr void name##_RB_INSERT_COLOR(struct name *, struct type *); \ -attr void name##_RB_REMOVE_COLOR(struct name *, struct type *, struct type *);\ -attr struct type *name##_RB_REMOVE(struct name *, struct type *); \ -attr struct type *name##_RB_INSERT(struct name *, struct type *); \ -attr struct type *name##_RB_FIND(struct name *, struct type *); \ -attr struct type *name##_RB_NFIND(struct name *, struct type *); \ -attr struct type *name##_RB_NEXT(struct type *); \ -attr struct type *name##_RB_PREV(struct type *); \ -attr struct type *name##_RB_MINMAX(struct name *, int); \ - \ - -/* Main rb operation. - * Moves node close to the key of elm to top - */ -#define RB_GENERATE(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp,) -#define RB_GENERATE_STATIC(name, type, field, cmp) \ - RB_GENERATE_INTERNAL(name, type, field, cmp, UV__UNUSED static) -#define RB_GENERATE_INTERNAL(name, type, field, cmp, attr) \ -attr void \ -name##_RB_INSERT_COLOR(struct name *head, struct type *elm) \ -{ \ - struct type *parent, *gparent, *tmp; \ - while ((parent = RB_PARENT(elm, field)) != NULL && \ - RB_COLOR(parent, field) == RB_RED) { \ - gparent = RB_PARENT(parent, field); \ - if (parent == RB_LEFT(gparent, field)) { \ - tmp = RB_RIGHT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field); \ - elm = gparent; \ - continue; \ - } \ - if (RB_RIGHT(parent, field) == elm) { \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_RIGHT(head, gparent, tmp, field); \ - } else { \ - tmp = RB_LEFT(gparent, field); \ - if (tmp && RB_COLOR(tmp, field) == RB_RED) { \ - RB_COLOR(tmp, field) = RB_BLACK; \ - RB_SET_BLACKRED(parent, gparent, field); \ - elm = gparent; \ - continue; \ - } \ - if (RB_LEFT(parent, field) == elm) { \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - tmp = parent; \ - parent = elm; \ - elm = tmp; \ - } \ - RB_SET_BLACKRED(parent, gparent, field); \ - RB_ROTATE_LEFT(head, gparent, tmp, field); \ - } \ - } \ - RB_COLOR(head->rbh_root, field) = RB_BLACK; \ -} \ - \ -attr void \ -name##_RB_REMOVE_COLOR(struct name *head, struct type *parent, \ - struct type *elm) \ -{ \ - struct type *tmp; \ - while ((elm == NULL || RB_COLOR(elm, field) == RB_BLACK) && \ - elm != RB_ROOT(head)) { \ - if (RB_LEFT(parent, field) == elm) { \ - tmp = RB_RIGHT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - tmp = RB_RIGHT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK) { \ - struct type *oleft; \ - if ((oleft = RB_LEFT(tmp, field)) \ - != NULL) \ - RB_COLOR(oleft, field) = RB_BLACK; \ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_RIGHT(head, tmp, oleft, field); \ - tmp = RB_RIGHT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_RIGHT(tmp, field)) \ - RB_COLOR(RB_RIGHT(tmp, field), field) = RB_BLACK; \ - RB_ROTATE_LEFT(head, parent, tmp, field); \ - elm = RB_ROOT(head); \ - break; \ - } \ - } else { \ - tmp = RB_LEFT(parent, field); \ - if (RB_COLOR(tmp, field) == RB_RED) { \ - RB_SET_BLACKRED(tmp, parent, field); \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - tmp = RB_LEFT(parent, field); \ - } \ - if ((RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) && \ - (RB_RIGHT(tmp, field) == NULL || \ - RB_COLOR(RB_RIGHT(tmp, field), field) == RB_BLACK)) { \ - RB_COLOR(tmp, field) = RB_RED; \ - elm = parent; \ - parent = RB_PARENT(elm, field); \ - } else { \ - if (RB_LEFT(tmp, field) == NULL || \ - RB_COLOR(RB_LEFT(tmp, field), field) == RB_BLACK) { \ - struct type *oright; \ - if ((oright = RB_RIGHT(tmp, field)) \ - != NULL) \ - RB_COLOR(oright, field) = RB_BLACK; \ - RB_COLOR(tmp, field) = RB_RED; \ - RB_ROTATE_LEFT(head, tmp, oright, field); \ - tmp = RB_LEFT(parent, field); \ - } \ - RB_COLOR(tmp, field) = RB_COLOR(parent, field); \ - RB_COLOR(parent, field) = RB_BLACK; \ - if (RB_LEFT(tmp, field)) \ - RB_COLOR(RB_LEFT(tmp, field), field) = RB_BLACK; \ - RB_ROTATE_RIGHT(head, parent, tmp, field); \ - elm = RB_ROOT(head); \ - break; \ - } \ - } \ - } \ - if (elm) \ - RB_COLOR(elm, field) = RB_BLACK; \ -} \ - \ -attr struct type * \ -name##_RB_REMOVE(struct name *head, struct type *elm) \ -{ \ - struct type *child, *parent, *old = elm; \ - int color; \ - if (RB_LEFT(elm, field) == NULL) \ - child = RB_RIGHT(elm, field); \ - else if (RB_RIGHT(elm, field) == NULL) \ - child = RB_LEFT(elm, field); \ - else { \ - struct type *left; \ - elm = RB_RIGHT(elm, field); \ - while ((left = RB_LEFT(elm, field)) != NULL) \ - elm = left; \ - child = RB_RIGHT(elm, field); \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ - if (RB_PARENT(elm, field) == old) \ - parent = elm; \ - (elm)->field = (old)->field; \ - if (RB_PARENT(old, field)) { \ - if (RB_LEFT(RB_PARENT(old, field), field) == old) \ - RB_LEFT(RB_PARENT(old, field), field) = elm; \ - else \ - RB_RIGHT(RB_PARENT(old, field), field) = elm; \ - RB_AUGMENT(RB_PARENT(old, field)); \ - } else \ - RB_ROOT(head) = elm; \ - RB_PARENT(RB_LEFT(old, field), field) = elm; \ - if (RB_RIGHT(old, field)) \ - RB_PARENT(RB_RIGHT(old, field), field) = elm; \ - if (parent) { \ - left = parent; \ - do { \ - RB_AUGMENT(left); \ - } while ((left = RB_PARENT(left, field)) != NULL); \ - } \ - goto color; \ - } \ - parent = RB_PARENT(elm, field); \ - color = RB_COLOR(elm, field); \ - if (child) \ - RB_PARENT(child, field) = parent; \ - if (parent) { \ - if (RB_LEFT(parent, field) == elm) \ - RB_LEFT(parent, field) = child; \ - else \ - RB_RIGHT(parent, field) = child; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = child; \ -color: \ - if (color == RB_BLACK) \ - name##_RB_REMOVE_COLOR(head, parent, child); \ - return (old); \ -} \ - \ -/* Inserts a node into the RB tree */ \ -attr struct type * \ -name##_RB_INSERT(struct name *head, struct type *elm) \ -{ \ - struct type *tmp; \ - struct type *parent = NULL; \ - int comp = 0; \ - tmp = RB_ROOT(head); \ - while (tmp) { \ - parent = tmp; \ - comp = (cmp)(elm, parent); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - RB_SET(elm, parent, field); \ - if (parent != NULL) { \ - if (comp < 0) \ - RB_LEFT(parent, field) = elm; \ - else \ - RB_RIGHT(parent, field) = elm; \ - RB_AUGMENT(parent); \ - } else \ - RB_ROOT(head) = elm; \ - name##_RB_INSERT_COLOR(head, elm); \ - return (NULL); \ -} \ - \ -/* Finds the node with the same key as elm */ \ -attr struct type * \ -name##_RB_FIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) \ - tmp = RB_LEFT(tmp, field); \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (NULL); \ -} \ - \ -/* Finds the first node greater than or equal to the search key */ \ -attr struct type * \ -name##_RB_NFIND(struct name *head, struct type *elm) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *res = NULL; \ - int comp; \ - while (tmp) { \ - comp = cmp(elm, tmp); \ - if (comp < 0) { \ - res = tmp; \ - tmp = RB_LEFT(tmp, field); \ - } \ - else if (comp > 0) \ - tmp = RB_RIGHT(tmp, field); \ - else \ - return (tmp); \ - } \ - return (res); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_NEXT(struct type *elm) \ -{ \ - if (RB_RIGHT(elm, field)) { \ - elm = RB_RIGHT(elm, field); \ - while (RB_LEFT(elm, field)) \ - elm = RB_LEFT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -/* ARGSUSED */ \ -attr struct type * \ -name##_RB_PREV(struct type *elm) \ -{ \ - if (RB_LEFT(elm, field)) { \ - elm = RB_LEFT(elm, field); \ - while (RB_RIGHT(elm, field)) \ - elm = RB_RIGHT(elm, field); \ - } else { \ - if (RB_PARENT(elm, field) && \ - (elm == RB_RIGHT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - else { \ - while (RB_PARENT(elm, field) && \ - (elm == RB_LEFT(RB_PARENT(elm, field), field))) \ - elm = RB_PARENT(elm, field); \ - elm = RB_PARENT(elm, field); \ - } \ - } \ - return (elm); \ -} \ - \ -attr struct type * \ -name##_RB_MINMAX(struct name *head, int val) \ -{ \ - struct type *tmp = RB_ROOT(head); \ - struct type *parent = NULL; \ - while (tmp) { \ - parent = tmp; \ - if (val < 0) \ - tmp = RB_LEFT(tmp, field); \ - else \ - tmp = RB_RIGHT(tmp, field); \ - } \ - return (parent); \ -} - -#define RB_NEGINF -1 -#define RB_INF 1 - -#define RB_INSERT(name, x, y) name##_RB_INSERT(x, y) -#define RB_REMOVE(name, x, y) name##_RB_REMOVE(x, y) -#define RB_FIND(name, x, y) name##_RB_FIND(x, y) -#define RB_NFIND(name, x, y) name##_RB_NFIND(x, y) -#define RB_NEXT(name, x, y) name##_RB_NEXT(y) -#define RB_PREV(name, x, y) name##_RB_PREV(y) -#define RB_MIN(name, x) name##_RB_MINMAX(x, RB_NEGINF) -#define RB_MAX(name, x) name##_RB_MINMAX(x, RB_INF) - -#define RB_FOREACH(x, name, head) \ - for ((x) = RB_MIN(name, head); \ - (x) != NULL; \ - (x) = name##_RB_NEXT(x)) - -#define RB_FOREACH_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_SAFE(x, name, head, y) \ - for ((x) = RB_MIN(name, head); \ - ((x) != NULL) && ((y) = name##_RB_NEXT(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE(x, name, head) \ - for ((x) = RB_MAX(name, head); \ - (x) != NULL; \ - (x) = name##_RB_PREV(x)) - -#define RB_FOREACH_REVERSE_FROM(x, name, y) \ - for ((x) = (y); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#define RB_FOREACH_REVERSE_SAFE(x, name, head, y) \ - for ((x) = RB_MAX(name, head); \ - ((x) != NULL) && ((y) = name##_RB_PREV(x), (x) != NULL); \ - (x) = (y)) - -#endif /* UV_TREE_H_ */ diff --git a/android/armeabi/include/uv/uv-aix.h b/android/armeabi/include/uv/uv-aix.h deleted file mode 100644 index 7dc992fa..00000000 --- a/android/armeabi/include/uv/uv-aix.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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 UV_AIX_H -#define UV_AIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - int fs_fd; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char *dir_filename; \ - -#endif /* UV_AIX_H */ diff --git a/android/armeabi/include/uv/uv-bsd.h b/android/armeabi/include/uv/uv-bsd.h deleted file mode 100644 index 2d72b3d7..00000000 --- a/android/armeabi/include/uv/uv-bsd.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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 UV_BSD_H -#define UV_BSD_H - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - -#define UV_IO_PRIVATE_PLATFORM_FIELDS \ - int rcount; \ - int wcount; \ - -#define UV_HAVE_KQUEUE 1 - -#endif /* UV_BSD_H */ diff --git a/android/armeabi/include/uv/uv-darwin.h b/android/armeabi/include/uv/uv-darwin.h deleted file mode 100644 index d2264158..00000000 --- a/android/armeabi/include/uv/uv-darwin.h +++ /dev/null @@ -1,61 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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 UV_DARWIN_H -#define UV_DARWIN_H - -#if defined(__APPLE__) && defined(__MACH__) -# include <mach/mach.h> -# include <mach/task.h> -# include <mach/semaphore.h> -# include <TargetConditionals.h> -# define UV_PLATFORM_SEM_T semaphore_t -#endif - -#define UV_IO_PRIVATE_PLATFORM_FIELDS \ - int rcount; \ - int wcount; \ - -#define UV_PLATFORM_LOOP_FIELDS \ - uv_thread_t cf_thread; \ - void* _cf_reserved; \ - void* cf_state; \ - uv_mutex_t cf_mutex; \ - uv_sem_t cf_sem; \ - void* cf_signals[2]; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - uv__io_t event_watcher; \ - char* realpath; \ - int realpath_len; \ - int cf_flags; \ - uv_async_t* cf_cb; \ - void* cf_events[2]; \ - void* cf_member[2]; \ - int cf_error; \ - uv_mutex_t cf_mutex; \ - -#define UV_STREAM_PRIVATE_PLATFORM_FIELDS \ - void* select; \ - -#define UV_HAVE_KQUEUE 1 - -#endif /* UV_DARWIN_H */ diff --git a/android/armeabi/include/uv/uv-errno.h b/android/armeabi/include/uv/uv-errno.h deleted file mode 100644 index f1371517..00000000 --- a/android/armeabi/include/uv/uv-errno.h +++ /dev/null @@ -1,419 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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 UV_ERRNO_H_ -#define UV_ERRNO_H_ - -#include <errno.h> - -#define UV__EOF (-4095) -#define UV__UNKNOWN (-4094) - -#define UV__EAI_ADDRFAMILY (-3000) -#define UV__EAI_AGAIN (-3001) -#define UV__EAI_BADFLAGS (-3002) -#define UV__EAI_CANCELED (-3003) -#define UV__EAI_FAIL (-3004) -#define UV__EAI_FAMILY (-3005) -#define UV__EAI_MEMORY (-3006) -#define UV__EAI_NODATA (-3007) -#define UV__EAI_NONAME (-3008) -#define UV__EAI_OVERFLOW (-3009) -#define UV__EAI_SERVICE (-3010) -#define UV__EAI_SOCKTYPE (-3011) -#define UV__EAI_BADHINTS (-3013) -#define UV__EAI_PROTOCOL (-3014) - -/* Only map to the system errno on non-Windows platforms. It's apparently - * a fairly common practice for Windows programmers to redefine errno codes. - */ -#if defined(E2BIG) && !defined(_WIN32) -# define UV__E2BIG (-E2BIG) -#else -# define UV__E2BIG (-4093) -#endif - -#if defined(EACCES) && !defined(_WIN32) -# define UV__EACCES (-EACCES) -#else -# define UV__EACCES (-4092) -#endif - -#if defined(EADDRINUSE) && !defined(_WIN32) -# define UV__EADDRINUSE (-EADDRINUSE) -#else -# define UV__EADDRINUSE (-4091) -#endif - -#if defined(EADDRNOTAVAIL) && !defined(_WIN32) -# define UV__EADDRNOTAVAIL (-EADDRNOTAVAIL) -#else -# define UV__EADDRNOTAVAIL (-4090) -#endif - -#if defined(EAFNOSUPPORT) && !defined(_WIN32) -# define UV__EAFNOSUPPORT (-EAFNOSUPPORT) -#else -# define UV__EAFNOSUPPORT (-4089) -#endif - -#if defined(EAGAIN) && !defined(_WIN32) -# define UV__EAGAIN (-EAGAIN) -#else -# define UV__EAGAIN (-4088) -#endif - -#if defined(EALREADY) && !defined(_WIN32) -# define UV__EALREADY (-EALREADY) -#else -# define UV__EALREADY (-4084) -#endif - -#if defined(EBADF) && !defined(_WIN32) -# define UV__EBADF (-EBADF) -#else -# define UV__EBADF (-4083) -#endif - -#if defined(EBUSY) && !defined(_WIN32) -# define UV__EBUSY (-EBUSY) -#else -# define UV__EBUSY (-4082) -#endif - -#if defined(ECANCELED) && !defined(_WIN32) -# define UV__ECANCELED (-ECANCELED) -#else -# define UV__ECANCELED (-4081) -#endif - -#if defined(ECHARSET) && !defined(_WIN32) -# define UV__ECHARSET (-ECHARSET) -#else -# define UV__ECHARSET (-4080) -#endif - -#if defined(ECONNABORTED) && !defined(_WIN32) -# define UV__ECONNABORTED (-ECONNABORTED) -#else -# define UV__ECONNABORTED (-4079) -#endif - -#if defined(ECONNREFUSED) && !defined(_WIN32) -# define UV__ECONNREFUSED (-ECONNREFUSED) -#else -# define UV__ECONNREFUSED (-4078) -#endif - -#if defined(ECONNRESET) && !defined(_WIN32) -# define UV__ECONNRESET (-ECONNRESET) -#else -# define UV__ECONNRESET (-4077) -#endif - -#if defined(EDESTADDRREQ) && !defined(_WIN32) -# define UV__EDESTADDRREQ (-EDESTADDRREQ) -#else -# define UV__EDESTADDRREQ (-4076) -#endif - -#if defined(EEXIST) && !defined(_WIN32) -# define UV__EEXIST (-EEXIST) -#else -# define UV__EEXIST (-4075) -#endif - -#if defined(EFAULT) && !defined(_WIN32) -# define UV__EFAULT (-EFAULT) -#else -# define UV__EFAULT (-4074) -#endif - -#if defined(EHOSTUNREACH) && !defined(_WIN32) -# define UV__EHOSTUNREACH (-EHOSTUNREACH) -#else -# define UV__EHOSTUNREACH (-4073) -#endif - -#if defined(EINTR) && !defined(_WIN32) -# define UV__EINTR (-EINTR) -#else -# define UV__EINTR (-4072) -#endif - -#if defined(EINVAL) && !defined(_WIN32) -# define UV__EINVAL (-EINVAL) -#else -# define UV__EINVAL (-4071) -#endif - -#if defined(EIO) && !defined(_WIN32) -# define UV__EIO (-EIO) -#else -# define UV__EIO (-4070) -#endif - -#if defined(EISCONN) && !defined(_WIN32) -# define UV__EISCONN (-EISCONN) -#else -# define UV__EISCONN (-4069) -#endif - -#if defined(EISDIR) && !defined(_WIN32) -# define UV__EISDIR (-EISDIR) -#else -# define UV__EISDIR (-4068) -#endif - -#if defined(ELOOP) && !defined(_WIN32) -# define UV__ELOOP (-ELOOP) -#else -# define UV__ELOOP (-4067) -#endif - -#if defined(EMFILE) && !defined(_WIN32) -# define UV__EMFILE (-EMFILE) -#else -# define UV__EMFILE (-4066) -#endif - -#if defined(EMSGSIZE) && !defined(_WIN32) -# define UV__EMSGSIZE (-EMSGSIZE) -#else -# define UV__EMSGSIZE (-4065) -#endif - -#if defined(ENAMETOOLONG) && !defined(_WIN32) -# define UV__ENAMETOOLONG (-ENAMETOOLONG) -#else -# define UV__ENAMETOOLONG (-4064) -#endif - -#if defined(ENETDOWN) && !defined(_WIN32) -# define UV__ENETDOWN (-ENETDOWN) -#else -# define UV__ENETDOWN (-4063) -#endif - -#if defined(ENETUNREACH) && !defined(_WIN32) -# define UV__ENETUNREACH (-ENETUNREACH) -#else -# define UV__ENETUNREACH (-4062) -#endif - -#if defined(ENFILE) && !defined(_WIN32) -# define UV__ENFILE (-ENFILE) -#else -# define UV__ENFILE (-4061) -#endif - -#if defined(ENOBUFS) && !defined(_WIN32) -# define UV__ENOBUFS (-ENOBUFS) -#else -# define UV__ENOBUFS (-4060) -#endif - -#if defined(ENODEV) && !defined(_WIN32) -# define UV__ENODEV (-ENODEV) -#else -# define UV__ENODEV (-4059) -#endif - -#if defined(ENOENT) && !defined(_WIN32) -# define UV__ENOENT (-ENOENT) -#else -# define UV__ENOENT (-4058) -#endif - -#if defined(ENOMEM) && !defined(_WIN32) -# define UV__ENOMEM (-ENOMEM) -#else -# define UV__ENOMEM (-4057) -#endif - -#if defined(ENONET) && !defined(_WIN32) -# define UV__ENONET (-ENONET) -#else -# define UV__ENONET (-4056) -#endif - -#if defined(ENOSPC) && !defined(_WIN32) -# define UV__ENOSPC (-ENOSPC) -#else -# define UV__ENOSPC (-4055) -#endif - -#if defined(ENOSYS) && !defined(_WIN32) -# define UV__ENOSYS (-ENOSYS) -#else -# define UV__ENOSYS (-4054) -#endif - -#if defined(ENOTCONN) && !defined(_WIN32) -# define UV__ENOTCONN (-ENOTCONN) -#else -# define UV__ENOTCONN (-4053) -#endif - -#if defined(ENOTDIR) && !defined(_WIN32) -# define UV__ENOTDIR (-ENOTDIR) -#else -# define UV__ENOTDIR (-4052) -#endif - -#if defined(ENOTEMPTY) && !defined(_WIN32) -# define UV__ENOTEMPTY (-ENOTEMPTY) -#else -# define UV__ENOTEMPTY (-4051) -#endif - -#if defined(ENOTSOCK) && !defined(_WIN32) -# define UV__ENOTSOCK (-ENOTSOCK) -#else -# define UV__ENOTSOCK (-4050) -#endif - -#if defined(ENOTSUP) && !defined(_WIN32) -# define UV__ENOTSUP (-ENOTSUP) -#else -# define UV__ENOTSUP (-4049) -#endif - -#if defined(EPERM) && !defined(_WIN32) -# define UV__EPERM (-EPERM) -#else -# define UV__EPERM (-4048) -#endif - -#if defined(EPIPE) && !defined(_WIN32) -# define UV__EPIPE (-EPIPE) -#else -# define UV__EPIPE (-4047) -#endif - -#if defined(EPROTO) && !defined(_WIN32) -# define UV__EPROTO (-EPROTO) -#else -# define UV__EPROTO (-4046) -#endif - -#if defined(EPROTONOSUPPORT) && !defined(_WIN32) -# define UV__EPROTONOSUPPORT (-EPROTONOSUPPORT) -#else -# define UV__EPROTONOSUPPORT (-4045) -#endif - -#if defined(EPROTOTYPE) && !defined(_WIN32) -# define UV__EPROTOTYPE (-EPROTOTYPE) -#else -# define UV__EPROTOTYPE (-4044) -#endif - -#if defined(EROFS) && !defined(_WIN32) -# define UV__EROFS (-EROFS) -#else -# define UV__EROFS (-4043) -#endif - -#if defined(ESHUTDOWN) && !defined(_WIN32) -# define UV__ESHUTDOWN (-ESHUTDOWN) -#else -# define UV__ESHUTDOWN (-4042) -#endif - -#if defined(ESPIPE) && !defined(_WIN32) -# define UV__ESPIPE (-ESPIPE) -#else -# define UV__ESPIPE (-4041) -#endif - -#if defined(ESRCH) && !defined(_WIN32) -# define UV__ESRCH (-ESRCH) -#else -# define UV__ESRCH (-4040) -#endif - -#if defined(ETIMEDOUT) && !defined(_WIN32) -# define UV__ETIMEDOUT (-ETIMEDOUT) -#else -# define UV__ETIMEDOUT (-4039) -#endif - -#if defined(ETXTBSY) && !defined(_WIN32) -# define UV__ETXTBSY (-ETXTBSY) -#else -# define UV__ETXTBSY (-4038) -#endif - -#if defined(EXDEV) && !defined(_WIN32) -# define UV__EXDEV (-EXDEV) -#else -# define UV__EXDEV (-4037) -#endif - -#if defined(EFBIG) && !defined(_WIN32) -# define UV__EFBIG (-EFBIG) -#else -# define UV__EFBIG (-4036) -#endif - -#if defined(ENOPROTOOPT) && !defined(_WIN32) -# define UV__ENOPROTOOPT (-ENOPROTOOPT) -#else -# define UV__ENOPROTOOPT (-4035) -#endif - -#if defined(ERANGE) && !defined(_WIN32) -# define UV__ERANGE (-ERANGE) -#else -# define UV__ERANGE (-4034) -#endif - -#if defined(ENXIO) && !defined(_WIN32) -# define UV__ENXIO (-ENXIO) -#else -# define UV__ENXIO (-4033) -#endif - -#if defined(EMLINK) && !defined(_WIN32) -# define UV__EMLINK (-EMLINK) -#else -# define UV__EMLINK (-4032) -#endif - -/* EHOSTDOWN is not visible on BSD-like systems when _POSIX_C_SOURCE is - * defined. Fortunately, its value is always 64 so it's possible albeit - * icky to hard-code it. - */ -#if defined(EHOSTDOWN) && !defined(_WIN32) -# define UV__EHOSTDOWN (-EHOSTDOWN) -#elif defined(__APPLE__) || \ - defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__NetBSD__) || \ - defined(__OpenBSD__) -# define UV__EHOSTDOWN (-64) -#else -# define UV__EHOSTDOWN (-4031) -#endif - -#endif /* UV_ERRNO_H_ */ diff --git a/android/armeabi/include/uv/uv-linux.h b/android/armeabi/include/uv/uv-linux.h deleted file mode 100644 index 9b38405a..00000000 --- a/android/armeabi/include/uv/uv-linux.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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 UV_LINUX_H -#define UV_LINUX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t inotify_read_watcher; \ - void* inotify_watchers; \ - int inotify_fd; \ - -#define UV_PLATFORM_FS_EVENT_FIELDS \ - void* watchers[2]; \ - int wd; \ - -#endif /* UV_LINUX_H */ diff --git a/android/armeabi/include/uv/uv-os390.h b/android/armeabi/include/uv/uv-os390.h deleted file mode 100644 index 58f92611..00000000 --- a/android/armeabi/include/uv/uv-os390.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * 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 UV_MVS_H -#define UV_MVS_H - -#define UV_PLATFORM_SEM_T int - -#define UV_PLATFORM_LOOP_FIELDS \ - void* ep; \ - -#endif /* UV_MVS_H */ diff --git a/android/armeabi/include/uv/uv-posix.h b/android/armeabi/include/uv/uv-posix.h deleted file mode 100644 index 9a96634d..00000000 --- a/android/armeabi/include/uv/uv-posix.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright libuv project contributors. All rights reserved. - * - * 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 UV_POSIX_H -#define UV_POSIX_H - -#define UV_PLATFORM_LOOP_FIELDS \ - struct pollfd* poll_fds; \ - size_t poll_fds_used; \ - size_t poll_fds_size; \ - unsigned char poll_fds_iterating; \ - -#endif /* UV_POSIX_H */ diff --git a/android/armeabi/include/uv/uv-sunos.h b/android/armeabi/include/uv/uv-sunos.h deleted file mode 100644 index 04216642..00000000 --- a/android/armeabi/include/uv/uv-sunos.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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 UV_SUNOS_H -#define UV_SUNOS_H - -#include <sys/port.h> -#include <port.h> - -/* For the sake of convenience and reduced #ifdef-ery in src/unix/sunos.c, - * add the fs_event fields even when this version of SunOS doesn't support - * file watching. - */ -#define UV_PLATFORM_LOOP_FIELDS \ - uv__io_t fs_event_watcher; \ - int fs_fd; \ - -#if defined(PORT_SOURCE_FILE) - -# define UV_PLATFORM_FS_EVENT_FIELDS \ - file_obj_t fo; \ - int fd; \ - -#endif /* defined(PORT_SOURCE_FILE) */ - -#endif /* UV_SUNOS_H */ diff --git a/android/armeabi/include/uv/uv-threadpool.h b/android/armeabi/include/uv/uv-threadpool.h deleted file mode 100644 index 9708ebdd..00000000 --- a/android/armeabi/include/uv/uv-threadpool.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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. - */ - -/* - * This file is private to libuv. It provides common functionality to both - * Windows and Unix backends. - */ - -#ifndef UV_THREADPOOL_H_ -#define UV_THREADPOOL_H_ - -struct uv__work { - void (*work)(struct uv__work *w); - void (*done)(struct uv__work *w, int status); - struct uv_loop_s* loop; - void* wq[2]; -}; - -#endif /* UV_THREADPOOL_H_ */ diff --git a/android/armeabi/include/uv/uv-unix.h b/android/armeabi/include/uv/uv-unix.h deleted file mode 100644 index d7754509..00000000 --- a/android/armeabi/include/uv/uv-unix.h +++ /dev/null @@ -1,368 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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 UV_UNIX_H -#define UV_UNIX_H - -#include <sys/types.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <dirent.h> - -#include <sys/socket.h> -#include <netinet/in.h> -#include <netinet/tcp.h> -#include <arpa/inet.h> -#include <netdb.h> - -#include <termios.h> -#include <pwd.h> - -#if !defined(__MVS__) -#include <semaphore.h> -#endif -#include <pthread.h> -#include <signal.h> - -#include "uv-threadpool.h" - -#if defined(__linux__) -# include "uv-linux.h" -#elif defined (__MVS__) -# include "uv-os390.h" -#elif defined(_AIX) -# include "uv-aix.h" -#elif defined(__sun) -# include "uv-sunos.h" -#elif defined(__APPLE__) -# include "uv-darwin.h" -#elif defined(__DragonFly__) || \ - defined(__FreeBSD__) || \ - defined(__FreeBSD_kernel__) || \ - defined(__OpenBSD__) || \ - defined(__NetBSD__) -# include "uv-bsd.h" -#elif defined(__CYGWIN__) || defined(__MSYS__) -# include "uv-posix.h" -#endif - -#ifndef PTHREAD_BARRIER_SERIAL_THREAD -# include "pthread-barrier.h" -#endif - -#ifndef NI_MAXHOST -# define NI_MAXHOST 1025 -#endif - -#ifndef NI_MAXSERV -# define NI_MAXSERV 32 -#endif - -#ifndef UV_IO_PRIVATE_PLATFORM_FIELDS -# define UV_IO_PRIVATE_PLATFORM_FIELDS /* empty */ -#endif - -struct uv__io_s; -struct uv_loop_s; - -typedef void (*uv__io_cb)(struct uv_loop_s* loop, - struct uv__io_s* w, - unsigned int events); -typedef struct uv__io_s uv__io_t; - -struct uv__io_s { - uv__io_cb cb; - void* pending_queue[2]; - void* watcher_queue[2]; - unsigned int pevents; /* Pending event mask i.e. mask at next tick. */ - unsigned int events; /* Current event mask. */ - int fd; - UV_IO_PRIVATE_PLATFORM_FIELDS -}; - -#ifndef UV_PLATFORM_SEM_T -# define UV_PLATFORM_SEM_T sem_t -#endif - -#ifndef UV_PLATFORM_LOOP_FIELDS -# define UV_PLATFORM_LOOP_FIELDS /* empty */ -#endif - -#ifndef UV_PLATFORM_FS_EVENT_FIELDS -# define UV_PLATFORM_FS_EVENT_FIELDS /* empty */ -#endif - -#ifndef UV_STREAM_PRIVATE_PLATFORM_FIELDS -# define UV_STREAM_PRIVATE_PLATFORM_FIELDS /* empty */ -#endif - -/* Note: May be cast to struct iovec. See writev(2). */ -typedef struct uv_buf_t { - char* base; - size_t len; -} uv_buf_t; - -typedef int uv_file; -typedef int uv_os_sock_t; -typedef int uv_os_fd_t; - -#define UV_ONCE_INIT PTHREAD_ONCE_INIT - -typedef pthread_once_t uv_once_t; -typedef pthread_t uv_thread_t; -typedef pthread_mutex_t uv_mutex_t; -typedef pthread_rwlock_t uv_rwlock_t; -typedef UV_PLATFORM_SEM_T uv_sem_t; -typedef pthread_cond_t uv_cond_t; -typedef pthread_key_t uv_key_t; -typedef pthread_barrier_t uv_barrier_t; - - -/* Platform-specific definitions for uv_spawn support. */ -typedef gid_t uv_gid_t; -typedef uid_t uv_uid_t; - -typedef struct dirent uv__dirent_t; - -#if defined(DT_UNKNOWN) -# define HAVE_DIRENT_TYPES -# if defined(DT_REG) -# define UV__DT_FILE DT_REG -# else -# define UV__DT_FILE -1 -# endif -# if defined(DT_DIR) -# define UV__DT_DIR DT_DIR -# else -# define UV__DT_DIR -2 -# endif -# if defined(DT_LNK) -# define UV__DT_LINK DT_LNK -# else -# define UV__DT_LINK -3 -# endif -# if defined(DT_FIFO) -# define UV__DT_FIFO DT_FIFO -# else -# define UV__DT_FIFO -4 -# endif -# if defined(DT_SOCK) -# define UV__DT_SOCKET DT_SOCK -# else -# define UV__DT_SOCKET -5 -# endif -# if defined(DT_CHR) -# define UV__DT_CHAR DT_CHR -# else -# define UV__DT_CHAR -6 -# endif -# if defined(DT_BLK) -# define UV__DT_BLOCK DT_BLK -# else -# define UV__DT_BLOCK -7 -# endif -#endif - -/* Platform-specific definitions for uv_dlopen support. */ -#define UV_DYNAMIC /* empty */ - -typedef struct { - void* handle; - char* errmsg; -} uv_lib_t; - -#define UV_LOOP_PRIVATE_FIELDS \ - unsigned long flags; \ - int backend_fd; \ - void* pending_queue[2]; \ - void* watcher_queue[2]; \ - uv__io_t** watchers; \ - unsigned int nwatchers; \ - unsigned int nfds; \ - void* wq[2]; \ - uv_mutex_t wq_mutex; \ - uv_async_t wq_async; \ - uv_rwlock_t cloexec_lock; \ - uv_handle_t* closing_handles; \ - void* process_handles[2]; \ - void* prepare_handles[2]; \ - void* check_handles[2]; \ - void* idle_handles[2]; \ - void* async_handles[2]; \ - void (*async_unused)(void); /* TODO(bnoordhuis) Remove in libuv v2. */ \ - uv__io_t async_io_watcher; \ - int async_wfd; \ - struct { \ - void* min; \ - unsigned int nelts; \ - } timer_heap; \ - uint64_t timer_counter; \ - uint64_t time; \ - int signal_pipefd[2]; \ - uv__io_t signal_io_watcher; \ - uv_signal_t child_watcher; \ - int emfile_fd; \ - UV_PLATFORM_LOOP_FIELDS \ - -#define UV_REQ_TYPE_PRIVATE /* empty */ - -#define UV_REQ_PRIVATE_FIELDS /* empty */ - -#define UV_PRIVATE_REQ_TYPES /* empty */ - -#define UV_WRITE_PRIVATE_FIELDS \ - void* queue[2]; \ - unsigned int write_index; \ - uv_buf_t* bufs; \ - unsigned int nbufs; \ - int error; \ - uv_buf_t bufsml[4]; \ - -#define UV_CONNECT_PRIVATE_FIELDS \ - void* queue[2]; \ - -#define UV_SHUTDOWN_PRIVATE_FIELDS /* empty */ - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - void* queue[2]; \ - struct sockaddr_storage addr; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - ssize_t status; \ - uv_udp_send_cb send_cb; \ - uv_buf_t bufsml[4]; \ - -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* next_closing; \ - unsigned int flags; \ - -#define UV_STREAM_PRIVATE_FIELDS \ - uv_connect_t *connect_req; \ - uv_shutdown_t *shutdown_req; \ - uv__io_t io_watcher; \ - void* write_queue[2]; \ - void* write_completed_queue[2]; \ - uv_connection_cb connection_cb; \ - int delayed_error; \ - int accepted_fd; \ - void* queued_fds; \ - UV_STREAM_PRIVATE_PLATFORM_FIELDS \ - -#define UV_TCP_PRIVATE_FIELDS /* empty */ - -#define UV_UDP_PRIVATE_FIELDS \ - uv_alloc_cb alloc_cb; \ - uv_udp_recv_cb recv_cb; \ - uv__io_t io_watcher; \ - void* write_queue[2]; \ - void* write_completed_queue[2]; \ - -#define UV_PIPE_PRIVATE_FIELDS \ - const char* pipe_fname; /* strdup'ed */ - -#define UV_POLL_PRIVATE_FIELDS \ - uv__io_t io_watcher; - -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_cb prepare_cb; \ - void* queue[2]; \ - -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_cb check_cb; \ - void* queue[2]; \ - -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_cb idle_cb; \ - void* queue[2]; \ - -#define UV_ASYNC_PRIVATE_FIELDS \ - uv_async_cb async_cb; \ - void* queue[2]; \ - int pending; \ - -#define UV_TIMER_PRIVATE_FIELDS \ - uv_timer_cb timer_cb; \ - void* heap_node[3]; \ - uint64_t timeout; \ - uint64_t repeat; \ - uint64_t start_id; - -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getaddrinfo_cb cb; \ - struct addrinfo* hints; \ - char* hostname; \ - char* service; \ - struct addrinfo* addrinfo; \ - int retcode; - -#define UV_GETNAMEINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getnameinfo_cb getnameinfo_cb; \ - struct sockaddr_storage storage; \ - int flags; \ - char host[NI_MAXHOST]; \ - char service[NI_MAXSERV]; \ - int retcode; - -#define UV_PROCESS_PRIVATE_FIELDS \ - void* queue[2]; \ - int status; \ - -#define UV_FS_PRIVATE_FIELDS \ - const char *new_path; \ - uv_file file; \ - int flags; \ - mode_t mode; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - off_t off; \ - uv_uid_t uid; \ - uv_gid_t gid; \ - double atime; \ - double mtime; \ - struct uv__work work_req; \ - uv_buf_t bufsml[4]; \ - -#define UV_WORK_PRIVATE_FIELDS \ - struct uv__work work_req; - -#define UV_TTY_PRIVATE_FIELDS \ - struct termios orig_termios; \ - int mode; - -#define UV_SIGNAL_PRIVATE_FIELDS \ - /* RB_ENTRY(uv_signal_s) tree_entry; */ \ - struct { \ - struct uv_signal_s* rbe_left; \ - struct uv_signal_s* rbe_right; \ - struct uv_signal_s* rbe_parent; \ - int rbe_color; \ - } tree_entry; \ - /* Use two counters here so we don have to fiddle with atomics. */ \ - unsigned int caught_signals; \ - unsigned int dispatched_signals; - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - uv_fs_event_cb cb; \ - UV_PLATFORM_FS_EVENT_FIELDS \ - -#endif /* UV_UNIX_H */ diff --git a/android/armeabi/include/uv/uv-version.h b/android/armeabi/include/uv/uv-version.h deleted file mode 100644 index c80c40ea..00000000 --- a/android/armeabi/include/uv/uv-version.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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 UV_VERSION_H -#define UV_VERSION_H - - /* - * Versions with the same major number are ABI stable. API is allowed to - * evolve between minor releases, but only in a backwards compatible way. - * Make sure you update the -soname directives in configure.ac - * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but - * not UV_VERSION_PATCH.) - */ - -#define UV_VERSION_MAJOR 1 -#define UV_VERSION_MINOR 13 -#define UV_VERSION_PATCH 1 -#define UV_VERSION_IS_RELEASE 1 -#define UV_VERSION_SUFFIX "" - -#define UV_VERSION_HEX ((UV_VERSION_MAJOR << 16) | \ - (UV_VERSION_MINOR << 8) | \ - (UV_VERSION_PATCH)) - -#endif /* UV_VERSION_H */ diff --git a/android/armeabi/include/uv/uv-win.h b/android/armeabi/include/uv/uv-win.h deleted file mode 100644 index 9677ff16..00000000 --- a/android/armeabi/include/uv/uv-win.h +++ /dev/null @@ -1,650 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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 _WIN32_WINNT -# define _WIN32_WINNT 0x0502 -#endif - -#if !defined(_SSIZE_T_) && !defined(_SSIZE_T_DEFINED) -typedef intptr_t ssize_t; -# define _SSIZE_T_ -# define _SSIZE_T_DEFINED -#endif - -#include <winsock2.h> - -#if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR) -typedef struct pollfd { - SOCKET fd; - short events; - short revents; -} WSAPOLLFD, *PWSAPOLLFD, *LPWSAPOLLFD; -#endif - -#ifndef LOCALE_INVARIANT -# define LOCALE_INVARIANT 0x007f -#endif - -#include <mswsock.h> -#include <ws2tcpip.h> -#include <windows.h> - -#include <process.h> -#include <signal.h> -#include <fcntl.h> -#include <sys/stat.h> - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include <stdint.h> -#endif - -#include "tree.h" -#include "uv-threadpool.h" - -#define MAX_PIPENAME_LEN 256 - -#ifndef S_IFLNK -# define S_IFLNK 0xA000 -#endif - -/* Additional signals supported by uv_signal and or uv_kill. The CRT defines - * the following signals already: - * - * #define SIGINT 2 - * #define SIGILL 4 - * #define SIGABRT_COMPAT 6 - * #define SIGFPE 8 - * #define SIGSEGV 11 - * #define SIGTERM 15 - * #define SIGBREAK 21 - * #define SIGABRT 22 - * - * The additional signals have values that are common on other Unix - * variants (Linux and Darwin) - */ -#define SIGHUP 1 -#define SIGKILL 9 -#define SIGWINCH 28 - -/* The CRT defines SIGABRT_COMPAT as 6, which equals SIGABRT on many */ -/* unix-like platforms. However MinGW doesn't define it, so we do. */ -#ifndef SIGABRT_COMPAT -# define SIGABRT_COMPAT 6 -#endif - -/* - * Guids and typedefs for winsock extension functions - * Mingw32 doesn't have these :-( - */ -#ifndef WSAID_ACCEPTEX -# define WSAID_ACCEPTEX \ - {0xb5367df1, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - -# define WSAID_CONNECTEX \ - {0x25a207b9, 0xddf3, 0x4660, \ - {0x8e, 0xe9, 0x76, 0xe5, 0x8c, 0x74, 0x06, 0x3e}} - -# define WSAID_GETACCEPTEXSOCKADDRS \ - {0xb5367df2, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - -# define WSAID_DISCONNECTEX \ - {0x7fda2e11, 0x8630, 0x436f, \ - {0xa0, 0x31, 0xf5, 0x36, 0xa6, 0xee, 0xc1, 0x57}} - -# define WSAID_TRANSMITFILE \ - {0xb5367df0, 0xcbac, 0x11cf, \ - {0x95, 0xca, 0x00, 0x80, 0x5f, 0x48, 0xa1, 0x92}} - - typedef BOOL (PASCAL *LPFN_ACCEPTEX) - (SOCKET sListenSocket, - SOCKET sAcceptSocket, - PVOID lpOutputBuffer, - DWORD dwReceiveDataLength, - DWORD dwLocalAddressLength, - DWORD dwRemoteAddressLength, - LPDWORD lpdwBytesReceived, - LPOVERLAPPED lpOverlapped); - - typedef BOOL (PASCAL *LPFN_CONNECTEX) - (SOCKET s, - const struct sockaddr* name, - int namelen, - PVOID lpSendBuffer, - DWORD dwSendDataLength, - LPDWORD lpdwBytesSent, - LPOVERLAPPED lpOverlapped); - - typedef void (PASCAL *LPFN_GETACCEPTEXSOCKADDRS) - (PVOID lpOutputBuffer, - DWORD dwReceiveDataLength, - DWORD dwLocalAddressLength, - DWORD dwRemoteAddressLength, - LPSOCKADDR* LocalSockaddr, - LPINT LocalSockaddrLength, - LPSOCKADDR* RemoteSockaddr, - LPINT RemoteSockaddrLength); - - typedef BOOL (PASCAL *LPFN_DISCONNECTEX) - (SOCKET hSocket, - LPOVERLAPPED lpOverlapped, - DWORD dwFlags, - DWORD reserved); - - typedef BOOL (PASCAL *LPFN_TRANSMITFILE) - (SOCKET hSocket, - HANDLE hFile, - DWORD nNumberOfBytesToWrite, - DWORD nNumberOfBytesPerSend, - LPOVERLAPPED lpOverlapped, - LPTRANSMIT_FILE_BUFFERS lpTransmitBuffers, - DWORD dwFlags); - - typedef PVOID RTL_SRWLOCK; - typedef RTL_SRWLOCK SRWLOCK, *PSRWLOCK; -#endif - -typedef int (WSAAPI* LPFN_WSARECV) - (SOCKET socket, - LPWSABUF buffers, - DWORD buffer_count, - LPDWORD bytes, - LPDWORD flags, - LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -typedef int (WSAAPI* LPFN_WSARECVFROM) - (SOCKET socket, - LPWSABUF buffers, - DWORD buffer_count, - LPDWORD bytes, - LPDWORD flags, - struct sockaddr* addr, - LPINT addr_len, - LPWSAOVERLAPPED overlapped, - LPWSAOVERLAPPED_COMPLETION_ROUTINE completion_routine); - -#ifndef _NTDEF_ - typedef LONG NTSTATUS; - typedef NTSTATUS *PNTSTATUS; -#endif - -#ifndef RTL_CONDITION_VARIABLE_INIT - typedef PVOID CONDITION_VARIABLE, *PCONDITION_VARIABLE; -#endif - -typedef struct _AFD_POLL_HANDLE_INFO { - HANDLE Handle; - ULONG Events; - NTSTATUS Status; -} AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO; - -typedef struct _AFD_POLL_INFO { - LARGE_INTEGER Timeout; - ULONG NumberOfHandles; - ULONG Exclusive; - AFD_POLL_HANDLE_INFO Handles[1]; -} AFD_POLL_INFO, *PAFD_POLL_INFO; - -#define UV_MSAFD_PROVIDER_COUNT 3 - - -/** - * It should be possible to cast uv_buf_t[] to WSABUF[] - * see http://msdn.microsoft.com/en-us/library/ms741542(v=vs.85).aspx - */ -typedef struct uv_buf_t { - ULONG len; - char* base; -} uv_buf_t; - -typedef int uv_file; -typedef SOCKET uv_os_sock_t; -typedef HANDLE uv_os_fd_t; - -typedef HANDLE uv_thread_t; - -typedef HANDLE uv_sem_t; - -typedef CRITICAL_SECTION uv_mutex_t; - -/* This condition variable implementation is based on the SetEvent solution - * (section 3.2) at http://www.cs.wustl.edu/~schmidt/win32-cv-1.html - * We could not use the SignalObjectAndWait solution (section 3.4) because - * it want the 2nd argument (type uv_mutex_t) of uv_cond_wait() and - * uv_cond_timedwait() to be HANDLEs, but we use CRITICAL_SECTIONs. - */ - -typedef union { - CONDITION_VARIABLE cond_var; - struct { - unsigned int waiters_count; - CRITICAL_SECTION waiters_count_lock; - HANDLE signal_event; - HANDLE broadcast_event; - } fallback; -} uv_cond_t; - -typedef union { - struct { - unsigned int num_readers_; - CRITICAL_SECTION num_readers_lock_; - HANDLE write_semaphore_; - } state_; - /* TODO: remove me in v2.x. */ - struct { - SRWLOCK unused_; - } unused1_; - /* TODO: remove me in v2.x. */ - struct { - uv_mutex_t unused1_; - uv_mutex_t unused2_; - } unused2_; -} uv_rwlock_t; - -typedef struct { - unsigned int n; - unsigned int count; - uv_mutex_t mutex; - uv_sem_t turnstile1; - uv_sem_t turnstile2; -} uv_barrier_t; - -typedef struct { - DWORD tls_index; -} uv_key_t; - -#define UV_ONCE_INIT { 0, NULL } - -typedef struct uv_once_s { - unsigned char ran; - HANDLE event; -} uv_once_t; - -/* Platform-specific definitions for uv_spawn support. */ -typedef unsigned char uv_uid_t; -typedef unsigned char uv_gid_t; - -typedef struct uv__dirent_s { - int d_type; - char d_name[1]; -} uv__dirent_t; - -#define HAVE_DIRENT_TYPES -#define UV__DT_DIR UV_DIRENT_DIR -#define UV__DT_FILE UV_DIRENT_FILE -#define UV__DT_LINK UV_DIRENT_LINK -#define UV__DT_FIFO UV_DIRENT_FIFO -#define UV__DT_SOCKET UV_DIRENT_SOCKET -#define UV__DT_CHAR UV_DIRENT_CHAR -#define UV__DT_BLOCK UV_DIRENT_BLOCK - -/* Platform-specific definitions for uv_dlopen support. */ -#define UV_DYNAMIC FAR WINAPI -typedef struct { - HMODULE handle; - char* errmsg; -} uv_lib_t; - -RB_HEAD(uv_timer_tree_s, uv_timer_s); - -#define UV_LOOP_PRIVATE_FIELDS \ - /* The loop's I/O completion port */ \ - HANDLE iocp; \ - /* The current time according to the event loop. in msecs. */ \ - uint64_t time; \ - /* Tail of a single-linked circular queue of pending reqs. If the queue */ \ - /* is empty, tail_ is NULL. If there is only one item, */ \ - /* tail_->next_req == tail_ */ \ - uv_req_t* pending_reqs_tail; \ - /* Head of a single-linked list of closed handles */ \ - uv_handle_t* endgame_handles; \ - /* The head of the timers tree */ \ - struct uv_timer_tree_s timers; \ - /* Lists of active loop (prepare / check / idle) watchers */ \ - uv_prepare_t* prepare_handles; \ - uv_check_t* check_handles; \ - uv_idle_t* idle_handles; \ - /* This pointer will refer to the prepare/check/idle handle whose */ \ - /* callback is scheduled to be called next. This is needed to allow */ \ - /* safe removal from one of the lists above while that list being */ \ - /* iterated over. */ \ - uv_prepare_t* next_prepare_handle; \ - uv_check_t* next_check_handle; \ - uv_idle_t* next_idle_handle; \ - /* This handle holds the peer sockets for the fast variant of uv_poll_t */ \ - SOCKET poll_peer_sockets[UV_MSAFD_PROVIDER_COUNT]; \ - /* Counter to keep track of active tcp streams */ \ - unsigned int active_tcp_streams; \ - /* Counter to keep track of active udp streams */ \ - unsigned int active_udp_streams; \ - /* Counter to started timer */ \ - uint64_t timer_counter; \ - /* Threadpool */ \ - void* wq[2]; \ - uv_mutex_t wq_mutex; \ - uv_async_t wq_async; - -#define UV_REQ_TYPE_PRIVATE \ - /* TODO: remove the req suffix */ \ - UV_ACCEPT, \ - UV_FS_EVENT_REQ, \ - UV_POLL_REQ, \ - UV_PROCESS_EXIT, \ - UV_READ, \ - UV_UDP_RECV, \ - UV_WAKEUP, \ - UV_SIGNAL_REQ, - -#define UV_REQ_PRIVATE_FIELDS \ - union { \ - /* Used by I/O operations */ \ - struct { \ - OVERLAPPED overlapped; \ - size_t queued_bytes; \ - } io; \ - } u; \ - struct uv_req_s* next_req; - -#define UV_WRITE_PRIVATE_FIELDS \ - int ipc_header; \ - uv_buf_t write_buffer; \ - HANDLE event_handle; \ - HANDLE wait_handle; - -#define UV_CONNECT_PRIVATE_FIELDS \ - /* empty */ - -#define UV_SHUTDOWN_PRIVATE_FIELDS \ - /* empty */ - -#define UV_UDP_SEND_PRIVATE_FIELDS \ - /* empty */ - -#define UV_PRIVATE_REQ_TYPES \ - typedef struct uv_pipe_accept_s { \ - UV_REQ_FIELDS \ - HANDLE pipeHandle; \ - struct uv_pipe_accept_s* next_pending; \ - } uv_pipe_accept_t; \ - \ - typedef struct uv_tcp_accept_s { \ - UV_REQ_FIELDS \ - SOCKET accept_socket; \ - char accept_buffer[sizeof(struct sockaddr_storage) * 2 + 32]; \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - struct uv_tcp_accept_s* next_pending; \ - } uv_tcp_accept_t; \ - \ - typedef struct uv_read_s { \ - UV_REQ_FIELDS \ - HANDLE event_handle; \ - HANDLE wait_handle; \ - } uv_read_t; - -#define uv_stream_connection_fields \ - unsigned int write_reqs_pending; \ - uv_shutdown_t* shutdown_req; - -#define uv_stream_server_fields \ - uv_connection_cb connection_cb; - -#define UV_STREAM_PRIVATE_FIELDS \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_read_t read_req; \ - union { \ - struct { uv_stream_connection_fields } conn; \ - struct { uv_stream_server_fields } serv; \ - } stream; - -#define uv_tcp_server_fields \ - uv_tcp_accept_t* accept_reqs; \ - unsigned int processed_accepts; \ - uv_tcp_accept_t* pending_accepts; \ - LPFN_ACCEPTEX func_acceptex; - -#define uv_tcp_connection_fields \ - uv_buf_t read_buffer; \ - LPFN_CONNECTEX func_connectex; - -#define UV_TCP_PRIVATE_FIELDS \ - SOCKET socket; \ - int delayed_error; \ - union { \ - struct { uv_tcp_server_fields } serv; \ - struct { uv_tcp_connection_fields } conn; \ - } tcp; - -#define UV_UDP_PRIVATE_FIELDS \ - SOCKET socket; \ - unsigned int reqs_pending; \ - int activecnt; \ - uv_req_t recv_req; \ - uv_buf_t recv_buffer; \ - struct sockaddr_storage recv_from; \ - int recv_from_len; \ - uv_udp_recv_cb recv_cb; \ - uv_alloc_cb alloc_cb; \ - LPFN_WSARECV func_wsarecv; \ - LPFN_WSARECVFROM func_wsarecvfrom; - -#define uv_pipe_server_fields \ - int pending_instances; \ - uv_pipe_accept_t* accept_reqs; \ - uv_pipe_accept_t* pending_accepts; - -#define uv_pipe_connection_fields \ - uv_timer_t* eof_timer; \ - uv_write_t ipc_header_write_req; \ - int ipc_pid; \ - uint64_t remaining_ipc_rawdata_bytes; \ - struct { \ - void* queue[2]; \ - int queue_len; \ - } pending_ipc_info; \ - uv_write_t* non_overlapped_writes_tail; \ - uv_mutex_t readfile_mutex; \ - volatile HANDLE readfile_thread; - -#define UV_PIPE_PRIVATE_FIELDS \ - HANDLE handle; \ - WCHAR* name; \ - union { \ - struct { uv_pipe_server_fields } serv; \ - struct { uv_pipe_connection_fields } conn; \ - } pipe; - -/* TODO: put the parser states in an union - TTY handles are always */ -/* half-duplex so read-state can safely overlap write-state. */ -#define UV_TTY_PRIVATE_FIELDS \ - HANDLE handle; \ - union { \ - struct { \ - /* Used for readable TTY handles */ \ - /* TODO: remove me in v2.x. */ \ - HANDLE unused_; \ - uv_buf_t read_line_buffer; \ - HANDLE read_raw_wait; \ - /* Fields used for translating win keystrokes into vt100 characters */ \ - char last_key[8]; \ - unsigned char last_key_offset; \ - unsigned char last_key_len; \ - WCHAR last_utf16_high_surrogate; \ - INPUT_RECORD last_input_record; \ - } rd; \ - struct { \ - /* Used for writable TTY handles */ \ - /* utf8-to-utf16 conversion state */ \ - unsigned int utf8_codepoint; \ - unsigned char utf8_bytes_left; \ - /* eol conversion state */ \ - unsigned char previous_eol; \ - /* ansi parser state */ \ - unsigned char ansi_parser_state; \ - unsigned char ansi_csi_argc; \ - unsigned short ansi_csi_argv[4]; \ - COORD saved_position; \ - WORD saved_attributes; \ - } wr; \ - } tty; - -#define UV_POLL_PRIVATE_FIELDS \ - SOCKET socket; \ - /* Used in fast mode */ \ - SOCKET peer_socket; \ - AFD_POLL_INFO afd_poll_info_1; \ - AFD_POLL_INFO afd_poll_info_2; \ - /* Used in fast and slow mode. */ \ - uv_req_t poll_req_1; \ - uv_req_t poll_req_2; \ - unsigned char submitted_events_1; \ - unsigned char submitted_events_2; \ - unsigned char mask_events_1; \ - unsigned char mask_events_2; \ - unsigned char events; - -#define UV_TIMER_PRIVATE_FIELDS \ - RB_ENTRY(uv_timer_s) tree_entry; \ - uint64_t due; \ - uint64_t repeat; \ - uint64_t start_id; \ - uv_timer_cb timer_cb; - -#define UV_ASYNC_PRIVATE_FIELDS \ - struct uv_req_s async_req; \ - uv_async_cb async_cb; \ - /* char to avoid alignment issues */ \ - char volatile async_sent; - -#define UV_PREPARE_PRIVATE_FIELDS \ - uv_prepare_t* prepare_prev; \ - uv_prepare_t* prepare_next; \ - uv_prepare_cb prepare_cb; - -#define UV_CHECK_PRIVATE_FIELDS \ - uv_check_t* check_prev; \ - uv_check_t* check_next; \ - uv_check_cb check_cb; - -#define UV_IDLE_PRIVATE_FIELDS \ - uv_idle_t* idle_prev; \ - uv_idle_t* idle_next; \ - uv_idle_cb idle_cb; - -#define UV_HANDLE_PRIVATE_FIELDS \ - uv_handle_t* endgame_next; \ - unsigned int flags; - -#define UV_GETADDRINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getaddrinfo_cb getaddrinfo_cb; \ - void* alloc; \ - WCHAR* node; \ - WCHAR* service; \ - /* The addrinfoW field is used to store a pointer to the hints, and */ \ - /* later on to store the result of GetAddrInfoW. The final result will */ \ - /* be converted to struct addrinfo* and stored in the addrinfo field. */ \ - struct addrinfoW* addrinfow; \ - struct addrinfo* addrinfo; \ - int retcode; - -#define UV_GETNAMEINFO_PRIVATE_FIELDS \ - struct uv__work work_req; \ - uv_getnameinfo_cb getnameinfo_cb; \ - struct sockaddr_storage storage; \ - int flags; \ - char host[NI_MAXHOST]; \ - char service[NI_MAXSERV]; \ - int retcode; - -#define UV_PROCESS_PRIVATE_FIELDS \ - struct uv_process_exit_s { \ - UV_REQ_FIELDS \ - } exit_req; \ - BYTE* child_stdio_buffer; \ - int exit_signal; \ - HANDLE wait_handle; \ - HANDLE process_handle; \ - volatile char exit_cb_pending; - -#define UV_FS_PRIVATE_FIELDS \ - struct uv__work work_req; \ - int flags; \ - DWORD sys_errno_; \ - union { \ - /* TODO: remove me in 0.9. */ \ - WCHAR* pathw; \ - int fd; \ - } file; \ - union { \ - struct { \ - int mode; \ - WCHAR* new_pathw; \ - int file_flags; \ - int fd_out; \ - unsigned int nbufs; \ - uv_buf_t* bufs; \ - int64_t offset; \ - uv_buf_t bufsml[4]; \ - } info; \ - struct { \ - double atime; \ - double mtime; \ - } time; \ - } fs; - -#define UV_WORK_PRIVATE_FIELDS \ - struct uv__work work_req; - -#define UV_FS_EVENT_PRIVATE_FIELDS \ - struct uv_fs_event_req_s { \ - UV_REQ_FIELDS \ - } req; \ - HANDLE dir_handle; \ - int req_pending; \ - uv_fs_event_cb cb; \ - WCHAR* filew; \ - WCHAR* short_filew; \ - WCHAR* dirw; \ - char* buffer; - -#define UV_SIGNAL_PRIVATE_FIELDS \ - RB_ENTRY(uv_signal_s) tree_entry; \ - struct uv_req_s signal_req; \ - unsigned long pending_signum; - -#ifndef F_OK -#define F_OK 0 -#endif -#ifndef R_OK -#define R_OK 4 -#endif -#ifndef W_OK -#define W_OK 2 -#endif -#ifndef X_OK -#define X_OK 1 -#endif diff --git a/android/armeabi/include/uv/uv.h b/android/armeabi/include/uv/uv.h deleted file mode 100644 index f076094c..00000000 --- a/android/armeabi/include/uv/uv.h +++ /dev/null @@ -1,1508 +0,0 @@ -/* Copyright Joyent, Inc. and other Node contributors. All rights reserved. - * - * 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. - */ - -/* See https://github.com/libuv/libuv#documentation for documentation. */ - -#ifndef UV_H -#define UV_H -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef _WIN32 - /* Windows - set up dll import/export decorators. */ -# if defined(BUILDING_UV_SHARED) - /* Building shared library. */ -# define UV_EXTERN __declspec(dllexport) -# elif defined(USING_UV_SHARED) - /* Using shared library. */ -# define UV_EXTERN __declspec(dllimport) -# else - /* Building static library. */ -# define UV_EXTERN /* nothing */ -# endif -#elif __GNUC__ >= 4 -# define UV_EXTERN __attribute__((visibility("default"))) -#else -# define UV_EXTERN /* nothing */ -#endif - -#include "uv-errno.h" -#include "uv-version.h" -#include <stddef.h> -#include <stdio.h> - -#if defined(_MSC_VER) && _MSC_VER < 1600 -# include "stdint-msvc2008.h" -#else -# include <stdint.h> -#endif - -#if defined(_WIN32) -# include "uv-win.h" -#else -# include "uv-unix.h" -#endif - -/* Expand this list if necessary. */ -#define UV_ERRNO_MAP(XX) \ - XX(E2BIG, "argument list too long") \ - XX(EACCES, "permission denied") \ - XX(EADDRINUSE, "address already in use") \ - XX(EADDRNOTAVAIL, "address not available") \ - XX(EAFNOSUPPORT, "address family not supported") \ - XX(EAGAIN, "resource temporarily unavailable") \ - XX(EAI_ADDRFAMILY, "address family not supported") \ - XX(EAI_AGAIN, "temporary failure") \ - XX(EAI_BADFLAGS, "bad ai_flags value") \ - XX(EAI_BADHINTS, "invalid value for hints") \ - XX(EAI_CANCELED, "request canceled") \ - XX(EAI_FAIL, "permanent failure") \ - XX(EAI_FAMILY, "ai_family not supported") \ - XX(EAI_MEMORY, "out of memory") \ - XX(EAI_NODATA, "no address") \ - XX(EAI_NONAME, "unknown node or service") \ - XX(EAI_OVERFLOW, "argument buffer overflow") \ - XX(EAI_PROTOCOL, "resolved protocol is unknown") \ - XX(EAI_SERVICE, "service not available for socket type") \ - XX(EAI_SOCKTYPE, "socket type not supported") \ - XX(EALREADY, "connection already in progress") \ - XX(EBADF, "bad file descriptor") \ - XX(EBUSY, "resource busy or locked") \ - XX(ECANCELED, "operation canceled") \ - XX(ECHARSET, "invalid Unicode character") \ - XX(ECONNABORTED, "software caused connection abort") \ - XX(ECONNREFUSED, "connection refused") \ - XX(ECONNRESET, "connection reset by peer") \ - XX(EDESTADDRREQ, "destination address required") \ - XX(EEXIST, "file already exists") \ - XX(EFAULT, "bad address in system call argument") \ - XX(EFBIG, "file too large") \ - XX(EHOSTUNREACH, "host is unreachable") \ - XX(EINTR, "interrupted system call") \ - XX(EINVAL, "invalid argument") \ - XX(EIO, "i/o error") \ - XX(EISCONN, "socket is already connected") \ - XX(EISDIR, "illegal operation on a directory") \ - XX(ELOOP, "too many symbolic links encountered") \ - XX(EMFILE, "too many open files") \ - XX(EMSGSIZE, "message too long") \ - XX(ENAMETOOLONG, "name too long") \ - XX(ENETDOWN, "network is down") \ - XX(ENETUNREACH, "network is unreachable") \ - XX(ENFILE, "file table overflow") \ - XX(ENOBUFS, "no buffer space available") \ - XX(ENODEV, "no such device") \ - XX(ENOENT, "no such file or directory") \ - XX(ENOMEM, "not enough memory") \ - XX(ENONET, "machine is not on the network") \ - XX(ENOPROTOOPT, "protocol not available") \ - XX(ENOSPC, "no space left on device") \ - XX(ENOSYS, "function not implemented") \ - XX(ENOTCONN, "socket is not connected") \ - XX(ENOTDIR, "not a directory") \ - XX(ENOTEMPTY, "directory not empty") \ - XX(ENOTSOCK, "socket operation on non-socket") \ - XX(ENOTSUP, "operation not supported on socket") \ - XX(EPERM, "operation not permitted") \ - XX(EPIPE, "broken pipe") \ - XX(EPROTO, "protocol error") \ - XX(EPROTONOSUPPORT, "protocol not supported") \ - XX(EPROTOTYPE, "protocol wrong type for socket") \ - XX(ERANGE, "result too large") \ - XX(EROFS, "read-only file system") \ - XX(ESHUTDOWN, "cannot send after transport endpoint shutdown") \ - XX(ESPIPE, "invalid seek") \ - XX(ESRCH, "no such process") \ - XX(ETIMEDOUT, "connection timed out") \ - XX(ETXTBSY, "text file is busy") \ - XX(EXDEV, "cross-device link not permitted") \ - XX(UNKNOWN, "unknown error") \ - XX(EOF, "end of file") \ - XX(ENXIO, "no such device or address") \ - XX(EMLINK, "too many links") \ - XX(EHOSTDOWN, "host is down") \ - -#define UV_HANDLE_TYPE_MAP(XX) \ - XX(ASYNC, async) \ - XX(CHECK, check) \ - XX(FS_EVENT, fs_event) \ - XX(FS_POLL, fs_poll) \ - XX(HANDLE, handle) \ - XX(IDLE, idle) \ - XX(NAMED_PIPE, pipe) \ - XX(POLL, poll) \ - XX(PREPARE, prepare) \ - XX(PROCESS, process) \ - XX(STREAM, stream) \ - XX(TCP, tcp) \ - XX(TIMER, timer) \ - XX(TTY, tty) \ - XX(UDP, udp) \ - XX(SIGNAL, signal) \ - -#define UV_REQ_TYPE_MAP(XX) \ - XX(REQ, req) \ - XX(CONNECT, connect) \ - XX(WRITE, write) \ - XX(SHUTDOWN, shutdown) \ - XX(UDP_SEND, udp_send) \ - XX(FS, fs) \ - XX(WORK, work) \ - XX(GETADDRINFO, getaddrinfo) \ - XX(GETNAMEINFO, getnameinfo) \ - -typedef enum { -#define XX(code, _) UV_ ## code = UV__ ## code, - UV_ERRNO_MAP(XX) -#undef XX - UV_ERRNO_MAX = UV__EOF - 1 -} uv_errno_t; - -typedef enum { - UV_UNKNOWN_HANDLE = 0, -#define XX(uc, lc) UV_##uc, - UV_HANDLE_TYPE_MAP(XX) -#undef XX - UV_FILE, - UV_HANDLE_TYPE_MAX -} uv_handle_type; - -typedef enum { - UV_UNKNOWN_REQ = 0, -#define XX(uc, lc) UV_##uc, - UV_REQ_TYPE_MAP(XX) -#undef XX - UV_REQ_TYPE_PRIVATE - UV_REQ_TYPE_MAX -} uv_req_type; - - -/* Handle types. */ -typedef struct uv_loop_s uv_loop_t; -typedef struct uv_handle_s uv_handle_t; -typedef struct uv_stream_s uv_stream_t; -typedef struct uv_tcp_s uv_tcp_t; -typedef struct uv_udp_s uv_udp_t; -typedef struct uv_pipe_s uv_pipe_t; -typedef struct uv_tty_s uv_tty_t; -typedef struct uv_poll_s uv_poll_t; -typedef struct uv_timer_s uv_timer_t; -typedef struct uv_prepare_s uv_prepare_t; -typedef struct uv_check_s uv_check_t; -typedef struct uv_idle_s uv_idle_t; -typedef struct uv_async_s uv_async_t; -typedef struct uv_process_s uv_process_t; -typedef struct uv_fs_event_s uv_fs_event_t; -typedef struct uv_fs_poll_s uv_fs_poll_t; -typedef struct uv_signal_s uv_signal_t; - -/* Request types. */ -typedef struct uv_req_s uv_req_t; -typedef struct uv_getaddrinfo_s uv_getaddrinfo_t; -typedef struct uv_getnameinfo_s uv_getnameinfo_t; -typedef struct uv_shutdown_s uv_shutdown_t; -typedef struct uv_write_s uv_write_t; -typedef struct uv_connect_s uv_connect_t; -typedef struct uv_udp_send_s uv_udp_send_t; -typedef struct uv_fs_s uv_fs_t; -typedef struct uv_work_s uv_work_t; - -/* None of the above. */ -typedef struct uv_cpu_info_s uv_cpu_info_t; -typedef struct uv_interface_address_s uv_interface_address_t; -typedef struct uv_dirent_s uv_dirent_t; -typedef struct uv_passwd_s uv_passwd_t; - -typedef enum { - UV_LOOP_BLOCK_SIGNAL -} uv_loop_option; - -typedef enum { - UV_RUN_DEFAULT = 0, - UV_RUN_ONCE, - UV_RUN_NOWAIT -} uv_run_mode; - - -UV_EXTERN unsigned int uv_version(void); -UV_EXTERN const char* uv_version_string(void); - -typedef void* (*uv_malloc_func)(size_t size); -typedef void* (*uv_realloc_func)(void* ptr, size_t size); -typedef void* (*uv_calloc_func)(size_t count, size_t size); -typedef void (*uv_free_func)(void* ptr); - -UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func, - uv_realloc_func realloc_func, - uv_calloc_func calloc_func, - uv_free_func free_func); - -UV_EXTERN uv_loop_t* uv_default_loop(void); -UV_EXTERN int uv_loop_init(uv_loop_t* loop); -UV_EXTERN int uv_loop_close(uv_loop_t* loop); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12), users should - * allocate the loop manually and use uv_loop_init instead. - */ -UV_EXTERN uv_loop_t* uv_loop_new(void); -/* - * NOTE: - * This function is DEPRECATED (to be removed after 0.12). Users should use - * uv_loop_close and free the memory manually instead. - */ -UV_EXTERN void uv_loop_delete(uv_loop_t*); -UV_EXTERN size_t uv_loop_size(void); -UV_EXTERN int uv_loop_alive(const uv_loop_t* loop); -UV_EXTERN int uv_loop_configure(uv_loop_t* loop, uv_loop_option option, ...); -UV_EXTERN int uv_loop_fork(uv_loop_t* loop); - -UV_EXTERN int uv_run(uv_loop_t*, uv_run_mode mode); -UV_EXTERN void uv_stop(uv_loop_t*); - -UV_EXTERN void uv_ref(uv_handle_t*); -UV_EXTERN void uv_unref(uv_handle_t*); -UV_EXTERN int uv_has_ref(const uv_handle_t*); - -UV_EXTERN void uv_update_time(uv_loop_t*); -UV_EXTERN uint64_t uv_now(const uv_loop_t*); - -UV_EXTERN int uv_backend_fd(const uv_loop_t*); -UV_EXTERN int uv_backend_timeout(const uv_loop_t*); - -typedef void (*uv_alloc_cb)(uv_handle_t* handle, - size_t suggested_size, - uv_buf_t* buf); -typedef void (*uv_read_cb)(uv_stream_t* stream, - ssize_t nread, - const uv_buf_t* buf); -typedef void (*uv_write_cb)(uv_write_t* req, int status); -typedef void (*uv_connect_cb)(uv_connect_t* req, int status); -typedef void (*uv_shutdown_cb)(uv_shutdown_t* req, int status); -typedef void (*uv_connection_cb)(uv_stream_t* server, int status); -typedef void (*uv_close_cb)(uv_handle_t* handle); -typedef void (*uv_poll_cb)(uv_poll_t* handle, int status, int events); -typedef void (*uv_timer_cb)(uv_timer_t* handle); -typedef void (*uv_async_cb)(uv_async_t* handle); -typedef void (*uv_prepare_cb)(uv_prepare_t* handle); -typedef void (*uv_check_cb)(uv_check_t* handle); -typedef void (*uv_idle_cb)(uv_idle_t* handle); -typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); -typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); -typedef void (*uv_fs_cb)(uv_fs_t* req); -typedef void (*uv_work_cb)(uv_work_t* req); -typedef void (*uv_after_work_cb)(uv_work_t* req, int status); -typedef void (*uv_getaddrinfo_cb)(uv_getaddrinfo_t* req, - int status, - struct addrinfo* res); -typedef void (*uv_getnameinfo_cb)(uv_getnameinfo_t* req, - int status, - const char* hostname, - const char* service); - -typedef struct { - long tv_sec; - long tv_nsec; -} uv_timespec_t; - - -typedef struct { - uint64_t st_dev; - uint64_t st_mode; - uint64_t st_nlink; - uint64_t st_uid; - uint64_t st_gid; - uint64_t st_rdev; - uint64_t st_ino; - uint64_t st_size; - uint64_t st_blksize; - uint64_t st_blocks; - uint64_t st_flags; - uint64_t st_gen; - uv_timespec_t st_atim; - uv_timespec_t st_mtim; - uv_timespec_t st_ctim; - uv_timespec_t st_birthtim; -} uv_stat_t; - - -typedef void (*uv_fs_event_cb)(uv_fs_event_t* handle, - const char* filename, - int events, - int status); - -typedef void (*uv_fs_poll_cb)(uv_fs_poll_t* handle, - int status, - const uv_stat_t* prev, - const uv_stat_t* curr); - -typedef void (*uv_signal_cb)(uv_signal_t* handle, int signum); - - -typedef enum { - UV_LEAVE_GROUP = 0, - UV_JOIN_GROUP -} uv_membership; - - -UV_EXTERN int uv_translate_sys_error(int sys_errno); - -UV_EXTERN const char* uv_strerror(int err); -UV_EXTERN const char* uv_err_name(int err); - - -#define UV_REQ_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_req_type type; \ - /* private */ \ - void* active_queue[2]; \ - void* reserved[4]; \ - UV_REQ_PRIVATE_FIELDS \ - -/* Abstract base class of all requests. */ -struct uv_req_s { - UV_REQ_FIELDS -}; - - -/* Platform-specific request types. */ -UV_PRIVATE_REQ_TYPES - - -UV_EXTERN int uv_shutdown(uv_shutdown_t* req, - uv_stream_t* handle, - uv_shutdown_cb cb); - -struct uv_shutdown_s { - UV_REQ_FIELDS - uv_stream_t* handle; - uv_shutdown_cb cb; - UV_SHUTDOWN_PRIVATE_FIELDS -}; - - -#define UV_HANDLE_FIELDS \ - /* public */ \ - void* data; \ - /* read-only */ \ - uv_loop_t* loop; \ - uv_handle_type type; \ - /* private */ \ - uv_close_cb close_cb; \ - void* handle_queue[2]; \ - union { \ - int fd; \ - void* reserved[4]; \ - } u; \ - UV_HANDLE_PRIVATE_FIELDS \ - -/* The abstract base class of all handles. */ -struct uv_handle_s { - UV_HANDLE_FIELDS -}; - -UV_EXTERN size_t uv_handle_size(uv_handle_type type); -UV_EXTERN size_t uv_req_size(uv_req_type type); - -UV_EXTERN int uv_is_active(const uv_handle_t* handle); - -UV_EXTERN void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg); - -/* Helpers for ad hoc debugging, no API/ABI stability guaranteed. */ -UV_EXTERN void uv_print_all_handles(uv_loop_t* loop, FILE* stream); -UV_EXTERN void uv_print_active_handles(uv_loop_t* loop, FILE* stream); - -UV_EXTERN void uv_close(uv_handle_t* handle, uv_close_cb close_cb); - -UV_EXTERN int uv_send_buffer_size(uv_handle_t* handle, int* value); -UV_EXTERN int uv_recv_buffer_size(uv_handle_t* handle, int* value); - -UV_EXTERN int uv_fileno(const uv_handle_t* handle, uv_os_fd_t* fd); - -UV_EXTERN uv_buf_t uv_buf_init(char* base, unsigned int len); - - -#define UV_STREAM_FIELDS \ - /* number of bytes queued for writing */ \ - size_t write_queue_size; \ - uv_alloc_cb alloc_cb; \ - uv_read_cb read_cb; \ - /* private */ \ - UV_STREAM_PRIVATE_FIELDS - -/* - * uv_stream_t is a subclass of uv_handle_t. - * - * uv_stream is an abstract class. - * - * uv_stream_t is the parent class of uv_tcp_t, uv_pipe_t and uv_tty_t. - */ -struct uv_stream_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS -}; - -UV_EXTERN int uv_listen(uv_stream_t* stream, int backlog, uv_connection_cb cb); -UV_EXTERN int uv_accept(uv_stream_t* server, uv_stream_t* client); - -UV_EXTERN int uv_read_start(uv_stream_t*, - uv_alloc_cb alloc_cb, - uv_read_cb read_cb); -UV_EXTERN int uv_read_stop(uv_stream_t*); - -UV_EXTERN int uv_write(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_write_cb cb); -UV_EXTERN int uv_write2(uv_write_t* req, - uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - uv_stream_t* send_handle, - uv_write_cb cb); -UV_EXTERN int uv_try_write(uv_stream_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs); - -/* uv_write_t is a subclass of uv_req_t. */ -struct uv_write_s { - UV_REQ_FIELDS - uv_write_cb cb; - uv_stream_t* send_handle; - uv_stream_t* handle; - UV_WRITE_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_is_readable(const uv_stream_t* handle); -UV_EXTERN int uv_is_writable(const uv_stream_t* handle); - -UV_EXTERN int uv_stream_set_blocking(uv_stream_t* handle, int blocking); - -UV_EXTERN int uv_is_closing(const uv_handle_t* handle); - - -/* - * uv_tcp_t is a subclass of uv_stream_t. - * - * Represents a TCP stream or TCP server. - */ -struct uv_tcp_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TCP_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_tcp_init(uv_loop_t*, uv_tcp_t* handle); -UV_EXTERN int uv_tcp_init_ex(uv_loop_t*, uv_tcp_t* handle, unsigned int flags); -UV_EXTERN int uv_tcp_open(uv_tcp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_tcp_nodelay(uv_tcp_t* handle, int enable); -UV_EXTERN int uv_tcp_keepalive(uv_tcp_t* handle, - int enable, - unsigned int delay); -UV_EXTERN int uv_tcp_simultaneous_accepts(uv_tcp_t* handle, int enable); - -enum uv_tcp_flags { - /* Used with uv_tcp_bind, when an IPv6 address is used. */ - UV_TCP_IPV6ONLY = 1 -}; - -UV_EXTERN int uv_tcp_bind(uv_tcp_t* handle, - const struct sockaddr* addr, - unsigned int flags); -UV_EXTERN int uv_tcp_getsockname(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_getpeername(const uv_tcp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_tcp_connect(uv_connect_t* req, - uv_tcp_t* handle, - const struct sockaddr* addr, - uv_connect_cb cb); - -/* uv_connect_t is a subclass of uv_req_t. */ -struct uv_connect_s { - UV_REQ_FIELDS - uv_connect_cb cb; - uv_stream_t* handle; - UV_CONNECT_PRIVATE_FIELDS -}; - - -/* - * UDP support. - */ - -enum uv_udp_flags { - /* Disables dual stack mode. */ - UV_UDP_IPV6ONLY = 1, - /* - * Indicates message was truncated because read buffer was too small. The - * remainder was discarded by the OS. Used in uv_udp_recv_cb. - */ - UV_UDP_PARTIAL = 2, - /* - * Indicates if SO_REUSEADDR will be set when binding the handle. - * This sets the SO_REUSEPORT socket flag on the BSDs and OS X. On other - * Unix platforms, it sets the SO_REUSEADDR flag. What that means is that - * multiple threads or processes can bind to the same address without error - * (provided they all set the flag) but only the last one to bind will receive - * any traffic, in effect "stealing" the port from the previous listener. - */ - UV_UDP_REUSEADDR = 4 -}; - -typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status); -typedef void (*uv_udp_recv_cb)(uv_udp_t* handle, - ssize_t nread, - const uv_buf_t* buf, - const struct sockaddr* addr, - unsigned flags); - -/* uv_udp_t is a subclass of uv_handle_t. */ -struct uv_udp_s { - UV_HANDLE_FIELDS - /* read-only */ - /* - * Number of bytes queued for sending. This field strictly shows how much - * information is currently queued. - */ - size_t send_queue_size; - /* - * Number of send requests currently in the queue awaiting to be processed. - */ - size_t send_queue_count; - UV_UDP_PRIVATE_FIELDS -}; - -/* uv_udp_send_t is a subclass of uv_req_t. */ -struct uv_udp_send_s { - UV_REQ_FIELDS - uv_udp_t* handle; - uv_udp_send_cb cb; - UV_UDP_SEND_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_udp_init(uv_loop_t*, uv_udp_t* handle); -UV_EXTERN int uv_udp_init_ex(uv_loop_t*, uv_udp_t* handle, unsigned int flags); -UV_EXTERN int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock); -UV_EXTERN int uv_udp_bind(uv_udp_t* handle, - const struct sockaddr* addr, - unsigned int flags); - -UV_EXTERN int uv_udp_getsockname(const uv_udp_t* handle, - struct sockaddr* name, - int* namelen); -UV_EXTERN int uv_udp_set_membership(uv_udp_t* handle, - const char* multicast_addr, - const char* interface_addr, - uv_membership membership); -UV_EXTERN int uv_udp_set_multicast_loop(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_multicast_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_set_multicast_interface(uv_udp_t* handle, - const char* interface_addr); -UV_EXTERN int uv_udp_set_broadcast(uv_udp_t* handle, int on); -UV_EXTERN int uv_udp_set_ttl(uv_udp_t* handle, int ttl); -UV_EXTERN int uv_udp_send(uv_udp_send_t* req, - uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr, - uv_udp_send_cb send_cb); -UV_EXTERN int uv_udp_try_send(uv_udp_t* handle, - const uv_buf_t bufs[], - unsigned int nbufs, - const struct sockaddr* addr); -UV_EXTERN int uv_udp_recv_start(uv_udp_t* handle, - uv_alloc_cb alloc_cb, - uv_udp_recv_cb recv_cb); -UV_EXTERN int uv_udp_recv_stop(uv_udp_t* handle); - - -/* - * uv_tty_t is a subclass of uv_stream_t. - * - * Representing a stream for the console. - */ -struct uv_tty_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - UV_TTY_PRIVATE_FIELDS -}; - -typedef enum { - /* Initial/normal terminal mode */ - UV_TTY_MODE_NORMAL, - /* Raw input mode (On Windows, ENABLE_WINDOW_INPUT is also enabled) */ - UV_TTY_MODE_RAW, - /* Binary-safe I/O mode for IPC (Unix-only) */ - UV_TTY_MODE_IO -} uv_tty_mode_t; - -UV_EXTERN int uv_tty_init(uv_loop_t*, uv_tty_t*, uv_file fd, int readable); -UV_EXTERN int uv_tty_set_mode(uv_tty_t*, uv_tty_mode_t mode); -UV_EXTERN int uv_tty_reset_mode(void); -UV_EXTERN int uv_tty_get_winsize(uv_tty_t*, int* width, int* height); - -#ifdef __cplusplus -extern "C++" { - -inline int uv_tty_set_mode(uv_tty_t* handle, int mode) { - return uv_tty_set_mode(handle, static_cast<uv_tty_mode_t>(mode)); -} - -} -#endif - -UV_EXTERN uv_handle_type uv_guess_handle(uv_file file); - -/* - * uv_pipe_t is a subclass of uv_stream_t. - * - * Representing a pipe stream or pipe server. On Windows this is a Named - * Pipe. On Unix this is a Unix domain socket. - */ -struct uv_pipe_s { - UV_HANDLE_FIELDS - UV_STREAM_FIELDS - int ipc; /* non-zero if this pipe is used for passing handles */ - UV_PIPE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_pipe_init(uv_loop_t*, uv_pipe_t* handle, int ipc); -UV_EXTERN int uv_pipe_open(uv_pipe_t*, uv_file file); -UV_EXTERN int uv_pipe_bind(uv_pipe_t* handle, const char* name); -UV_EXTERN void uv_pipe_connect(uv_connect_t* req, - uv_pipe_t* handle, - const char* name, - uv_connect_cb cb); -UV_EXTERN int uv_pipe_getsockname(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN int uv_pipe_getpeername(const uv_pipe_t* handle, - char* buffer, - size_t* size); -UV_EXTERN void uv_pipe_pending_instances(uv_pipe_t* handle, int count); -UV_EXTERN int uv_pipe_pending_count(uv_pipe_t* handle); -UV_EXTERN uv_handle_type uv_pipe_pending_type(uv_pipe_t* handle); - - -struct uv_poll_s { - UV_HANDLE_FIELDS - uv_poll_cb poll_cb; - UV_POLL_PRIVATE_FIELDS -}; - -enum uv_poll_event { - UV_READABLE = 1, - UV_WRITABLE = 2, - UV_DISCONNECT = 4 -}; - -UV_EXTERN int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd); -UV_EXTERN int uv_poll_init_socket(uv_loop_t* loop, - uv_poll_t* handle, - uv_os_sock_t socket); -UV_EXTERN int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb); -UV_EXTERN int uv_poll_stop(uv_poll_t* handle); - - -struct uv_prepare_s { - UV_HANDLE_FIELDS - UV_PREPARE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_prepare_init(uv_loop_t*, uv_prepare_t* prepare); -UV_EXTERN int uv_prepare_start(uv_prepare_t* prepare, uv_prepare_cb cb); -UV_EXTERN int uv_prepare_stop(uv_prepare_t* prepare); - - -struct uv_check_s { - UV_HANDLE_FIELDS - UV_CHECK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_check_init(uv_loop_t*, uv_check_t* check); -UV_EXTERN int uv_check_start(uv_check_t* check, uv_check_cb cb); -UV_EXTERN int uv_check_stop(uv_check_t* check); - - -struct uv_idle_s { - UV_HANDLE_FIELDS - UV_IDLE_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_idle_init(uv_loop_t*, uv_idle_t* idle); -UV_EXTERN int uv_idle_start(uv_idle_t* idle, uv_idle_cb cb); -UV_EXTERN int uv_idle_stop(uv_idle_t* idle); - - -struct uv_async_s { - UV_HANDLE_FIELDS - UV_ASYNC_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_async_init(uv_loop_t*, - uv_async_t* async, - uv_async_cb async_cb); -UV_EXTERN int uv_async_send(uv_async_t* async); - - -/* - * uv_timer_t is a subclass of uv_handle_t. - * - * Used to get woken up at a specified time in the future. - */ -struct uv_timer_s { - UV_HANDLE_FIELDS - UV_TIMER_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_timer_init(uv_loop_t*, uv_timer_t* handle); -UV_EXTERN int uv_timer_start(uv_timer_t* handle, - uv_timer_cb cb, - uint64_t timeout, - uint64_t repeat); -UV_EXTERN int uv_timer_stop(uv_timer_t* handle); -UV_EXTERN int uv_timer_again(uv_timer_t* handle); -UV_EXTERN void uv_timer_set_repeat(uv_timer_t* handle, uint64_t repeat); -UV_EXTERN uint64_t uv_timer_get_repeat(const uv_timer_t* handle); - - -/* - * uv_getaddrinfo_t is a subclass of uv_req_t. - * - * Request object for uv_getaddrinfo. - */ -struct uv_getaddrinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* struct addrinfo* addrinfo is marked as private, but it really isn't. */ - UV_GETADDRINFO_PRIVATE_FIELDS -}; - - -UV_EXTERN int uv_getaddrinfo(uv_loop_t* loop, - uv_getaddrinfo_t* req, - uv_getaddrinfo_cb getaddrinfo_cb, - const char* node, - const char* service, - const struct addrinfo* hints); -UV_EXTERN void uv_freeaddrinfo(struct addrinfo* ai); - - -/* -* uv_getnameinfo_t is a subclass of uv_req_t. -* -* Request object for uv_getnameinfo. -*/ -struct uv_getnameinfo_s { - UV_REQ_FIELDS - /* read-only */ - uv_loop_t* loop; - /* host and service are marked as private, but they really aren't. */ - UV_GETNAMEINFO_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_getnameinfo(uv_loop_t* loop, - uv_getnameinfo_t* req, - uv_getnameinfo_cb getnameinfo_cb, - const struct sockaddr* addr, - int flags); - - -/* uv_spawn() options. */ -typedef enum { - UV_IGNORE = 0x00, - UV_CREATE_PIPE = 0x01, - UV_INHERIT_FD = 0x02, - UV_INHERIT_STREAM = 0x04, - - /* - * When UV_CREATE_PIPE is specified, UV_READABLE_PIPE and UV_WRITABLE_PIPE - * determine the direction of flow, from the child process' perspective. Both - * flags may be specified to create a duplex data stream. - */ - UV_READABLE_PIPE = 0x10, - UV_WRITABLE_PIPE = 0x20 -} uv_stdio_flags; - -typedef struct uv_stdio_container_s { - uv_stdio_flags flags; - - union { - uv_stream_t* stream; - int fd; - } data; -} uv_stdio_container_t; - -typedef struct uv_process_options_s { - uv_exit_cb exit_cb; /* Called after the process exits. */ - const char* file; /* Path to program to execute. */ - /* - * Command line arguments. args[0] should be the path to the program. On - * Windows this uses CreateProcess which concatenates the arguments into a - * string this can cause some strange errors. See the note at - * windows_verbatim_arguments. - */ - char** args; - /* - * This will be set as the environ variable in the subprocess. If this is - * NULL then the parents environ will be used. - */ - char** env; - /* - * If non-null this represents a directory the subprocess should execute - * in. Stands for current working directory. - */ - const char* cwd; - /* - * Various flags that control how uv_spawn() behaves. See the definition of - * `enum uv_process_flags` below. - */ - unsigned int flags; - /* - * The `stdio` field points to an array of uv_stdio_container_t structs that - * describe the file descriptors that will be made available to the child - * process. The convention is that stdio[0] points to stdin, fd 1 is used for - * stdout, and fd 2 is stderr. - * - * Note that on windows file descriptors greater than 2 are available to the - * child process only if the child processes uses the MSVCRT runtime. - */ - int stdio_count; - uv_stdio_container_t* stdio; - /* - * Libuv can change the child process' user/group id. This happens only when - * the appropriate bits are set in the flags fields. This is not supported on - * windows; uv_spawn() will fail and set the error to UV_ENOTSUP. - */ - uv_uid_t uid; - uv_gid_t gid; -} uv_process_options_t; - -/* - * These are the flags that can be used for the uv_process_options.flags field. - */ -enum uv_process_flags { - /* - * Set the child process' user id. The user id is supplied in the `uid` field - * of the options struct. This does not work on windows; setting this flag - * will cause uv_spawn() to fail. - */ - UV_PROCESS_SETUID = (1 << 0), - /* - * Set the child process' group id. The user id is supplied in the `gid` - * field of the options struct. This does not work on windows; setting this - * flag will cause uv_spawn() to fail. - */ - UV_PROCESS_SETGID = (1 << 1), - /* - * Do not wrap any arguments in quotes, or perform any other escaping, when - * converting the argument list into a command line string. This option is - * only meaningful on Windows systems. On Unix it is silently ignored. - */ - UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS = (1 << 2), - /* - * Spawn the child process in a detached state - this will make it a process - * group leader, and will effectively enable the child to keep running after - * the parent exits. Note that the child process will still keep the - * parent's event loop alive unless the parent process calls uv_unref() on - * the child's process handle. - */ - UV_PROCESS_DETACHED = (1 << 3), - /* - * Hide the subprocess console window that would normally be created. This - * option is only meaningful on Windows systems. On Unix it is silently - * ignored. - */ - UV_PROCESS_WINDOWS_HIDE = (1 << 4) -}; - -/* - * uv_process_t is a subclass of uv_handle_t. - */ -struct uv_process_s { - UV_HANDLE_FIELDS - uv_exit_cb exit_cb; - int pid; - UV_PROCESS_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_spawn(uv_loop_t* loop, - uv_process_t* handle, - const uv_process_options_t* options); -UV_EXTERN int uv_process_kill(uv_process_t*, int signum); -UV_EXTERN int uv_kill(int pid, int signum); - - -/* - * uv_work_t is a subclass of uv_req_t. - */ -struct uv_work_s { - UV_REQ_FIELDS - uv_loop_t* loop; - uv_work_cb work_cb; - uv_after_work_cb after_work_cb; - UV_WORK_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_queue_work(uv_loop_t* loop, - uv_work_t* req, - uv_work_cb work_cb, - uv_after_work_cb after_work_cb); - -UV_EXTERN int uv_cancel(uv_req_t* req); - - -struct uv_cpu_info_s { - char* model; - int speed; - struct uv_cpu_times_s { - uint64_t user; - uint64_t nice; - uint64_t sys; - uint64_t idle; - uint64_t irq; - } cpu_times; -}; - -struct uv_interface_address_s { - char* name; - char phys_addr[6]; - int is_internal; - union { - struct sockaddr_in address4; - struct sockaddr_in6 address6; - } address; - union { - struct sockaddr_in netmask4; - struct sockaddr_in6 netmask6; - } netmask; -}; - -struct uv_passwd_s { - char* username; - long uid; - long gid; - char* shell; - char* homedir; -}; - -typedef enum { - UV_DIRENT_UNKNOWN, - UV_DIRENT_FILE, - UV_DIRENT_DIR, - UV_DIRENT_LINK, - UV_DIRENT_FIFO, - UV_DIRENT_SOCKET, - UV_DIRENT_CHAR, - UV_DIRENT_BLOCK -} uv_dirent_type_t; - -struct uv_dirent_s { - const char* name; - uv_dirent_type_t type; -}; - -UV_EXTERN char** uv_setup_args(int argc, char** argv); -UV_EXTERN int uv_get_process_title(char* buffer, size_t size); -UV_EXTERN int uv_set_process_title(const char* title); -UV_EXTERN int uv_resident_set_memory(size_t* rss); -UV_EXTERN int uv_uptime(double* uptime); -UV_EXTERN uv_os_fd_t uv_get_osfhandle(int fd); - -typedef struct { - long tv_sec; - long tv_usec; -} uv_timeval_t; - -typedef struct { - uv_timeval_t ru_utime; /* user CPU time used */ - uv_timeval_t ru_stime; /* system CPU time used */ - uint64_t ru_maxrss; /* maximum resident set size */ - uint64_t ru_ixrss; /* integral shared memory size */ - uint64_t ru_idrss; /* integral unshared data size */ - uint64_t ru_isrss; /* integral unshared stack size */ - uint64_t ru_minflt; /* page reclaims (soft page faults) */ - uint64_t ru_majflt; /* page faults (hard page faults) */ - uint64_t ru_nswap; /* swaps */ - uint64_t ru_inblock; /* block input operations */ - uint64_t ru_oublock; /* block output operations */ - uint64_t ru_msgsnd; /* IPC messages sent */ - uint64_t ru_msgrcv; /* IPC messages received */ - uint64_t ru_nsignals; /* signals received */ - uint64_t ru_nvcsw; /* voluntary context switches */ - uint64_t ru_nivcsw; /* involuntary context switches */ -} uv_rusage_t; - -UV_EXTERN int uv_getrusage(uv_rusage_t* rusage); - -UV_EXTERN int uv_os_homedir(char* buffer, size_t* size); -UV_EXTERN int uv_os_tmpdir(char* buffer, size_t* size); -UV_EXTERN int uv_os_get_passwd(uv_passwd_t* pwd); -UV_EXTERN void uv_os_free_passwd(uv_passwd_t* pwd); - -UV_EXTERN int uv_cpu_info(uv_cpu_info_t** cpu_infos, int* count); -UV_EXTERN void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count); - -UV_EXTERN int uv_interface_addresses(uv_interface_address_t** addresses, - int* count); -UV_EXTERN void uv_free_interface_addresses(uv_interface_address_t* addresses, - int count); - -UV_EXTERN int uv_os_getenv(const char* name, char* buffer, size_t* size); -UV_EXTERN int uv_os_setenv(const char* name, const char* value); -UV_EXTERN int uv_os_unsetenv(const char* name); - -UV_EXTERN int uv_os_gethostname(char* buffer, size_t* size); - - -typedef enum { - UV_FS_UNKNOWN = -1, - UV_FS_CUSTOM, - UV_FS_OPEN, - UV_FS_CLOSE, - UV_FS_READ, - UV_FS_WRITE, - UV_FS_SENDFILE, - UV_FS_STAT, - UV_FS_LSTAT, - UV_FS_FSTAT, - UV_FS_FTRUNCATE, - UV_FS_UTIME, - UV_FS_FUTIME, - UV_FS_ACCESS, - UV_FS_CHMOD, - UV_FS_FCHMOD, - UV_FS_FSYNC, - UV_FS_FDATASYNC, - UV_FS_UNLINK, - UV_FS_RMDIR, - UV_FS_MKDIR, - UV_FS_MKDTEMP, - UV_FS_RENAME, - UV_FS_SCANDIR, - UV_FS_LINK, - UV_FS_SYMLINK, - UV_FS_READLINK, - UV_FS_CHOWN, - UV_FS_FCHOWN, - UV_FS_REALPATH -} uv_fs_type; - -/* uv_fs_t is a subclass of uv_req_t. */ -struct uv_fs_s { - UV_REQ_FIELDS - uv_fs_type fs_type; - uv_loop_t* loop; - uv_fs_cb cb; - ssize_t result; - void* ptr; - const char* path; - uv_stat_t statbuf; /* Stores the result of uv_fs_stat() and uv_fs_fstat(). */ - UV_FS_PRIVATE_FIELDS -}; - -UV_EXTERN void uv_fs_req_cleanup(uv_fs_t* req); -UV_EXTERN int uv_fs_close(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_open(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_read(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_unlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_write(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - const uv_buf_t bufs[], - unsigned int nbufs, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_mkdtemp(uv_loop_t* loop, - uv_fs_t* req, - const char* tpl, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rmdir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_scandir_next(uv_fs_t* req, - uv_dirent_t* ent); -UV_EXTERN int uv_fs_stat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fstat(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_rename(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fsync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fdatasync(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_fs_cb cb); -UV_EXTERN int uv_fs_ftruncate(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int64_t offset, - uv_fs_cb cb); -UV_EXTERN int uv_fs_sendfile(uv_loop_t* loop, - uv_fs_t* req, - uv_file out_fd, - uv_file in_fd, - int64_t in_offset, - size_t length, - uv_fs_cb cb); -UV_EXTERN int uv_fs_access(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chmod(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_utime(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_futime(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - double atime, - double mtime, - uv_fs_cb cb); -UV_EXTERN int uv_fs_lstat(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_link(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - uv_fs_cb cb); - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * path argument points to a directory. - */ -#define UV_FS_SYMLINK_DIR 0x0001 - -/* - * This flag can be used with uv_fs_symlink() on Windows to specify whether - * the symlink is to be created using junction points. - */ -#define UV_FS_SYMLINK_JUNCTION 0x0002 - -UV_EXTERN int uv_fs_symlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - const char* new_path, - int flags, - uv_fs_cb cb); -UV_EXTERN int uv_fs_readlink(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_realpath(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchmod(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - int mode, - uv_fs_cb cb); -UV_EXTERN int uv_fs_chown(uv_loop_t* loop, - uv_fs_t* req, - const char* path, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); -UV_EXTERN int uv_fs_fchown(uv_loop_t* loop, - uv_fs_t* req, - uv_file file, - uv_uid_t uid, - uv_gid_t gid, - uv_fs_cb cb); - - -enum uv_fs_event { - UV_RENAME = 1, - UV_CHANGE = 2 -}; - - -struct uv_fs_event_s { - UV_HANDLE_FIELDS - /* private */ - char* path; - UV_FS_EVENT_PRIVATE_FIELDS -}; - - -/* - * uv_fs_stat() based polling file watcher. - */ -struct uv_fs_poll_s { - UV_HANDLE_FIELDS - /* Private, don't touch. */ - void* poll_ctx; -}; - -UV_EXTERN int uv_fs_poll_init(uv_loop_t* loop, uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_start(uv_fs_poll_t* handle, - uv_fs_poll_cb poll_cb, - const char* path, - unsigned int interval); -UV_EXTERN int uv_fs_poll_stop(uv_fs_poll_t* handle); -UV_EXTERN int uv_fs_poll_getpath(uv_fs_poll_t* handle, - char* buffer, - size_t* size); - - -struct uv_signal_s { - UV_HANDLE_FIELDS - uv_signal_cb signal_cb; - int signum; - UV_SIGNAL_PRIVATE_FIELDS -}; - -UV_EXTERN int uv_signal_init(uv_loop_t* loop, uv_signal_t* handle); -UV_EXTERN int uv_signal_start(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_start_oneshot(uv_signal_t* handle, - uv_signal_cb signal_cb, - int signum); -UV_EXTERN int uv_signal_stop(uv_signal_t* handle); - -UV_EXTERN void uv_loadavg(double avg[3]); - - -/* - * Flags to be passed to uv_fs_event_start(). - */ -enum uv_fs_event_flags { - /* - * By default, if the fs event watcher is given a directory name, we will - * watch for all events in that directory. This flags overrides this behavior - * and makes fs_event report only changes to the directory entry itself. This - * flag does not affect individual files watched. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_WATCH_ENTRY = 1, - - /* - * By default uv_fs_event will try to use a kernel interface such as inotify - * or kqueue to detect events. This may not work on remote filesystems such - * as NFS mounts. This flag makes fs_event fall back to calling stat() on a - * regular interval. - * This flag is currently not implemented yet on any backend. - */ - UV_FS_EVENT_STAT = 2, - - /* - * By default, event watcher, when watching directory, is not registering - * (is ignoring) changes in it's subdirectories. - * This flag will override this behaviour on platforms that support it. - */ - UV_FS_EVENT_RECURSIVE = 4 -}; - - -UV_EXTERN int uv_fs_event_init(uv_loop_t* loop, uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_start(uv_fs_event_t* handle, - uv_fs_event_cb cb, - const char* path, - unsigned int flags); -UV_EXTERN int uv_fs_event_stop(uv_fs_event_t* handle); -UV_EXTERN int uv_fs_event_getpath(uv_fs_event_t* handle, - char* buffer, - size_t* size); - -UV_EXTERN int uv_ip4_addr(const char* ip, int port, struct sockaddr_in* addr); -UV_EXTERN int uv_ip6_addr(const char* ip, int port, struct sockaddr_in6* addr); - -UV_EXTERN int uv_ip4_name(const struct sockaddr_in* src, char* dst, size_t size); -UV_EXTERN int uv_ip6_name(const struct sockaddr_in6* src, char* dst, size_t size); - -UV_EXTERN int uv_inet_ntop(int af, const void* src, char* dst, size_t size); -UV_EXTERN int uv_inet_pton(int af, const char* src, void* dst); - -UV_EXTERN int uv_exepath(char* buffer, size_t* size); - -UV_EXTERN int uv_cwd(char* buffer, size_t* size); - -UV_EXTERN int uv_chdir(const char* dir); - -UV_EXTERN uint64_t uv_get_free_memory(void); -UV_EXTERN uint64_t uv_get_total_memory(void); - -UV_EXTERN uint64_t uv_hrtime(void); - -UV_EXTERN void uv_disable_stdio_inheritance(void); - -UV_EXTERN int uv_dlopen(const char* filename, uv_lib_t* lib); -UV_EXTERN void uv_dlclose(uv_lib_t* lib); -UV_EXTERN int uv_dlsym(uv_lib_t* lib, const char* name, void** ptr); -UV_EXTERN const char* uv_dlerror(const uv_lib_t* lib); - -UV_EXTERN int uv_mutex_init(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_destroy(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_lock(uv_mutex_t* handle); -UV_EXTERN int uv_mutex_trylock(uv_mutex_t* handle); -UV_EXTERN void uv_mutex_unlock(uv_mutex_t* handle); - -UV_EXTERN int uv_rwlock_init(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_destroy(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_tryrdlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_rdunlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrlock(uv_rwlock_t* rwlock); -UV_EXTERN int uv_rwlock_trywrlock(uv_rwlock_t* rwlock); -UV_EXTERN void uv_rwlock_wrunlock(uv_rwlock_t* rwlock); - -UV_EXTERN int uv_sem_init(uv_sem_t* sem, unsigned int value); -UV_EXTERN void uv_sem_destroy(uv_sem_t* sem); -UV_EXTERN void uv_sem_post(uv_sem_t* sem); -UV_EXTERN void uv_sem_wait(uv_sem_t* sem); -UV_EXTERN int uv_sem_trywait(uv_sem_t* sem); - -UV_EXTERN int uv_cond_init(uv_cond_t* cond); -UV_EXTERN void uv_cond_destroy(uv_cond_t* cond); -UV_EXTERN void uv_cond_signal(uv_cond_t* cond); -UV_EXTERN void uv_cond_broadcast(uv_cond_t* cond); - -UV_EXTERN int uv_barrier_init(uv_barrier_t* barrier, unsigned int count); -UV_EXTERN void uv_barrier_destroy(uv_barrier_t* barrier); -UV_EXTERN int uv_barrier_wait(uv_barrier_t* barrier); - -UV_EXTERN void uv_cond_wait(uv_cond_t* cond, uv_mutex_t* mutex); -UV_EXTERN int uv_cond_timedwait(uv_cond_t* cond, - uv_mutex_t* mutex, - uint64_t timeout); - -UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); - -UV_EXTERN int uv_key_create(uv_key_t* key); -UV_EXTERN void uv_key_delete(uv_key_t* key); -UV_EXTERN void* uv_key_get(uv_key_t* key); -UV_EXTERN void uv_key_set(uv_key_t* key, void* value); - -typedef void (*uv_thread_cb)(void* arg); - -UV_EXTERN int uv_thread_create(uv_thread_t* tid, uv_thread_cb entry, void* arg); -UV_EXTERN uv_thread_t uv_thread_self(void); -UV_EXTERN int uv_thread_join(uv_thread_t *tid); -UV_EXTERN int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2); - -/* The presence of these unions force similar struct layout. */ -#define XX(_, name) uv_ ## name ## _t name; -union uv_any_handle { - UV_HANDLE_TYPE_MAP(XX) -}; - -union uv_any_req { - UV_REQ_TYPE_MAP(XX) -}; -#undef XX - - -struct uv_loop_s { - /* User data - use this for whatever. */ - void* data; - /* Loop reference counting. */ - unsigned int active_handles; - void* handle_queue[2]; - void* active_reqs[2]; - /* Internal flag to signal loop stop. */ - unsigned int stop_flag; - UV_LOOP_PRIVATE_FIELDS -}; - - -/* Don't export the private CPP symbols. */ -#undef UV_HANDLE_TYPE_PRIVATE -#undef UV_REQ_TYPE_PRIVATE -#undef UV_REQ_PRIVATE_FIELDS -#undef UV_STREAM_PRIVATE_FIELDS -#undef UV_TCP_PRIVATE_FIELDS -#undef UV_PREPARE_PRIVATE_FIELDS -#undef UV_CHECK_PRIVATE_FIELDS -#undef UV_IDLE_PRIVATE_FIELDS -#undef UV_ASYNC_PRIVATE_FIELDS -#undef UV_TIMER_PRIVATE_FIELDS -#undef UV_GETADDRINFO_PRIVATE_FIELDS -#undef UV_GETNAMEINFO_PRIVATE_FIELDS -#undef UV_FS_REQ_PRIVATE_FIELDS -#undef UV_WORK_PRIVATE_FIELDS -#undef UV_FS_EVENT_PRIVATE_FIELDS -#undef UV_SIGNAL_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_FIELDS -#undef UV_LOOP_PRIVATE_PLATFORM_FIELDS - -#ifdef __cplusplus -} -#endif -#endif /* UV_H */ diff --git a/android/armeabi/include/v8/libplatform/libplatform-export.h b/android/armeabi/include/v8/libplatform/libplatform-export.h deleted file mode 100644 index 15618434..00000000 --- a/android/armeabi/include/v8/libplatform/libplatform-export.h +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_ -#define V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_ - -#if defined(_WIN32) - -#ifdef BUILDING_V8_PLATFORM_SHARED -#define V8_PLATFORM_EXPORT __declspec(dllexport) -#elif USING_V8_PLATFORM_SHARED -#define V8_PLATFORM_EXPORT __declspec(dllimport) -#else -#define V8_PLATFORM_EXPORT -#endif // BUILDING_V8_PLATFORM_SHARED - -#else // defined(_WIN32) - -// Setup for Linux shared library export. -#ifdef BUILDING_V8_PLATFORM_SHARED -#define V8_PLATFORM_EXPORT __attribute__((visibility("default"))) -#else -#define V8_PLATFORM_EXPORT -#endif - -#endif // defined(_WIN32) - -#endif // V8_LIBPLATFORM_LIBPLATFORM_EXPORT_H_ diff --git a/android/armeabi/include/v8/libplatform/libplatform.h b/android/armeabi/include/v8/libplatform/libplatform.h deleted file mode 100644 index e9450456..00000000 --- a/android/armeabi/include/v8/libplatform/libplatform.h +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_LIBPLATFORM_LIBPLATFORM_H_ -#define V8_LIBPLATFORM_LIBPLATFORM_H_ - -#include "libplatform/libplatform-export.h" -#include "libplatform/v8-tracing.h" -#include "v8-platform.h" // NOLINT(build/include) - -namespace v8 { -namespace platform { - -enum class IdleTaskSupport { kDisabled, kEnabled }; -enum class InProcessStackDumping { kDisabled, kEnabled }; - -enum class MessageLoopBehavior : bool { - kDoNotWait = false, - kWaitForWork = true -}; - -/** - * Returns a new instance of the default v8::Platform implementation. - * - * The caller will take ownership of the returned pointer. |thread_pool_size| - * is the number of worker threads to allocate for background jobs. If a value - * of zero is passed, a suitable default based on the current number of - * processors online will be chosen. - * If |idle_task_support| is enabled then the platform will accept idle - * tasks (IdleTasksEnabled will return true) and will rely on the embedder - * calling v8::platform::RunIdleTasks to process the idle tasks. - */ -V8_PLATFORM_EXPORT v8::Platform* CreateDefaultPlatform( - int thread_pool_size = 0, - IdleTaskSupport idle_task_support = IdleTaskSupport::kDisabled, - InProcessStackDumping in_process_stack_dumping = - InProcessStackDumping::kEnabled); - -/** - * Pumps the message loop for the given isolate. - * - * The caller has to make sure that this is called from the right thread. - * Returns true if a task was executed, and false otherwise. Unless requested - * through the |behavior| parameter, this call does not block if no task is - * pending. The |platform| has to be created using |CreateDefaultPlatform|. - */ -V8_PLATFORM_EXPORT bool PumpMessageLoop( - v8::Platform* platform, v8::Isolate* isolate, - MessageLoopBehavior behavior = MessageLoopBehavior::kDoNotWait); - -V8_PLATFORM_EXPORT void EnsureEventLoopInitialized(v8::Platform* platform, - v8::Isolate* isolate); - -/** - * Runs pending idle tasks for at most |idle_time_in_seconds| seconds. - * - * The caller has to make sure that this is called from the right thread. - * This call does not block if no task is pending. The |platform| has to be - * created using |CreateDefaultPlatform|. - */ -V8_PLATFORM_EXPORT void RunIdleTasks(v8::Platform* platform, - v8::Isolate* isolate, - double idle_time_in_seconds); - -/** - * Attempts to set the tracing controller for the given platform. - * - * The |platform| has to be created using |CreateDefaultPlatform|. - */ -V8_PLATFORM_EXPORT void SetTracingController( - v8::Platform* platform, - v8::platform::tracing::TracingController* tracing_controller); - -} // namespace platform -} // namespace v8 - -#endif // V8_LIBPLATFORM_LIBPLATFORM_H_ diff --git a/android/armeabi/include/v8/libplatform/v8-tracing.h b/android/armeabi/include/v8/libplatform/v8-tracing.h deleted file mode 100644 index 902f8ea9..00000000 --- a/android/armeabi/include/v8/libplatform/v8-tracing.h +++ /dev/null @@ -1,270 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_LIBPLATFORM_V8_TRACING_H_ -#define V8_LIBPLATFORM_V8_TRACING_H_ - -#include <fstream> -#include <memory> -#include <unordered_set> -#include <vector> - -#include "libplatform/libplatform-export.h" -#include "v8-platform.h" // NOLINT(build/include) - -namespace v8 { - -namespace base { -class Mutex; -} // namespace base - -namespace platform { -namespace tracing { - -const int kTraceMaxNumArgs = 2; - -class V8_PLATFORM_EXPORT TraceObject { - public: - union ArgValue { - bool as_bool; - uint64_t as_uint; - int64_t as_int; - double as_double; - const void* as_pointer; - const char* as_string; - }; - - TraceObject() {} - ~TraceObject(); - void Initialize( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables, - unsigned int flags); - void UpdateDuration(); - void InitializeForTesting( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables, - unsigned int flags, int pid, int tid, int64_t ts, int64_t tts, - uint64_t duration, uint64_t cpu_duration); - - int pid() const { return pid_; } - int tid() const { return tid_; } - char phase() const { return phase_; } - const uint8_t* category_enabled_flag() const { - return category_enabled_flag_; - } - const char* name() const { return name_; } - const char* scope() const { return scope_; } - uint64_t id() const { return id_; } - uint64_t bind_id() const { return bind_id_; } - int num_args() const { return num_args_; } - const char** arg_names() { return arg_names_; } - uint8_t* arg_types() { return arg_types_; } - ArgValue* arg_values() { return arg_values_; } - std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables() { - return arg_convertables_; - } - unsigned int flags() const { return flags_; } - int64_t ts() { return ts_; } - int64_t tts() { return tts_; } - uint64_t duration() { return duration_; } - uint64_t cpu_duration() { return cpu_duration_; } - - private: - int pid_; - int tid_; - char phase_; - const char* name_; - const char* scope_; - const uint8_t* category_enabled_flag_; - uint64_t id_; - uint64_t bind_id_; - int num_args_ = 0; - const char* arg_names_[kTraceMaxNumArgs]; - uint8_t arg_types_[kTraceMaxNumArgs]; - ArgValue arg_values_[kTraceMaxNumArgs]; - std::unique_ptr<v8::ConvertableToTraceFormat> - arg_convertables_[kTraceMaxNumArgs]; - char* parameter_copy_storage_ = nullptr; - unsigned int flags_; - int64_t ts_; - int64_t tts_; - uint64_t duration_; - uint64_t cpu_duration_; - - // Disallow copy and assign - TraceObject(const TraceObject&) = delete; - void operator=(const TraceObject&) = delete; -}; - -class V8_PLATFORM_EXPORT TraceWriter { - public: - TraceWriter() {} - virtual ~TraceWriter() {} - virtual void AppendTraceEvent(TraceObject* trace_event) = 0; - virtual void Flush() = 0; - - static TraceWriter* CreateJSONTraceWriter(std::ostream& stream); - - private: - // Disallow copy and assign - TraceWriter(const TraceWriter&) = delete; - void operator=(const TraceWriter&) = delete; -}; - -class V8_PLATFORM_EXPORT TraceBufferChunk { - public: - explicit TraceBufferChunk(uint32_t seq); - - void Reset(uint32_t new_seq); - bool IsFull() const { return next_free_ == kChunkSize; } - TraceObject* AddTraceEvent(size_t* event_index); - TraceObject* GetEventAt(size_t index) { return &chunk_[index]; } - - uint32_t seq() const { return seq_; } - size_t size() const { return next_free_; } - - static const size_t kChunkSize = 64; - - private: - size_t next_free_ = 0; - TraceObject chunk_[kChunkSize]; - uint32_t seq_; - - // Disallow copy and assign - TraceBufferChunk(const TraceBufferChunk&) = delete; - void operator=(const TraceBufferChunk&) = delete; -}; - -class V8_PLATFORM_EXPORT TraceBuffer { - public: - TraceBuffer() {} - virtual ~TraceBuffer() {} - - virtual TraceObject* AddTraceEvent(uint64_t* handle) = 0; - virtual TraceObject* GetEventByHandle(uint64_t handle) = 0; - virtual bool Flush() = 0; - - static const size_t kRingBufferChunks = 1024; - - static TraceBuffer* CreateTraceBufferRingBuffer(size_t max_chunks, - TraceWriter* trace_writer); - - private: - // Disallow copy and assign - TraceBuffer(const TraceBuffer&) = delete; - void operator=(const TraceBuffer&) = delete; -}; - -// Options determines how the trace buffer stores data. -enum TraceRecordMode { - // Record until the trace buffer is full. - RECORD_UNTIL_FULL, - - // Record until the user ends the trace. The trace buffer is a fixed size - // and we use it as a ring buffer during recording. - RECORD_CONTINUOUSLY, - - // Record until the trace buffer is full, but with a huge buffer size. - RECORD_AS_MUCH_AS_POSSIBLE, - - // Echo to console. Events are discarded. - ECHO_TO_CONSOLE, -}; - -class V8_PLATFORM_EXPORT TraceConfig { - public: - typedef std::vector<std::string> StringList; - - static TraceConfig* CreateDefaultTraceConfig(); - - TraceConfig() : enable_systrace_(false), enable_argument_filter_(false) {} - TraceRecordMode GetTraceRecordMode() const { return record_mode_; } - bool IsSystraceEnabled() const { return enable_systrace_; } - bool IsArgumentFilterEnabled() const { return enable_argument_filter_; } - - void SetTraceRecordMode(TraceRecordMode mode) { record_mode_ = mode; } - void EnableSystrace() { enable_systrace_ = true; } - void EnableArgumentFilter() { enable_argument_filter_ = true; } - - void AddIncludedCategory(const char* included_category); - - bool IsCategoryGroupEnabled(const char* category_group) const; - - private: - TraceRecordMode record_mode_; - bool enable_systrace_ : 1; - bool enable_argument_filter_ : 1; - StringList included_categories_; - - // Disallow copy and assign - TraceConfig(const TraceConfig&) = delete; - void operator=(const TraceConfig&) = delete; -}; - -class V8_PLATFORM_EXPORT TracingController { - public: - enum Mode { DISABLED = 0, RECORDING_MODE }; - - // The pointer returned from GetCategoryGroupEnabledInternal() points to a - // value with zero or more of the following bits. Used in this class only. - // The TRACE_EVENT macros should only use the value as a bool. - // These values must be in sync with macro values in TraceEvent.h in Blink. - enum CategoryGroupEnabledFlags { - // Category group enabled for the recording mode. - ENABLED_FOR_RECORDING = 1 << 0, - // Category group enabled by SetEventCallbackEnabled(). - ENABLED_FOR_EVENT_CALLBACK = 1 << 2, - // Category group enabled to export events to ETW. - ENABLED_FOR_ETW_EXPORT = 1 << 3 - }; - - TracingController(); - ~TracingController(); - void Initialize(TraceBuffer* trace_buffer); - const uint8_t* GetCategoryGroupEnabled(const char* category_group); - static const char* GetCategoryGroupName(const uint8_t* category_enabled_flag); - uint64_t AddTraceEvent( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr<v8::ConvertableToTraceFormat>* arg_convertables, - unsigned int flags); - void UpdateTraceEventDuration(const uint8_t* category_enabled_flag, - const char* name, uint64_t handle); - - void StartTracing(TraceConfig* trace_config); - void StopTracing(); - - void AddTraceStateObserver(Platform::TraceStateObserver* observer); - void RemoveTraceStateObserver(Platform::TraceStateObserver* observer); - - private: - const uint8_t* GetCategoryGroupEnabledInternal(const char* category_group); - void UpdateCategoryGroupEnabledFlag(size_t category_index); - void UpdateCategoryGroupEnabledFlags(); - - std::unique_ptr<TraceBuffer> trace_buffer_; - std::unique_ptr<TraceConfig> trace_config_; - std::unique_ptr<base::Mutex> mutex_; - std::unordered_set<Platform::TraceStateObserver*> observers_; - Mode mode_ = DISABLED; - - // Disallow copy and assign - TracingController(const TracingController&) = delete; - void operator=(const TracingController&) = delete; -}; - -} // namespace tracing -} // namespace platform -} // namespace v8 - -#endif // V8_LIBPLATFORM_V8_TRACING_H_ diff --git a/android/armeabi/include/v8/v8-debug.h b/android/armeabi/include/v8/v8-debug.h deleted file mode 100644 index 54c0f216..00000000 --- a/android/armeabi/include/v8/v8-debug.h +++ /dev/null @@ -1,255 +0,0 @@ -// Copyright 2008 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_V8_DEBUG_H_ -#define V8_V8_DEBUG_H_ - -#include "v8.h" // NOLINT(build/include) - -/** - * ATTENTION: The debugger API exposed by this file is deprecated and will be - * removed by the end of 2017. Please use the V8 inspector declared - * in include/v8-inspector.h instead. - */ -namespace v8 { - -// Debug events which can occur in the V8 JavaScript engine. -enum DebugEvent { - Break = 1, - Exception = 2, - AfterCompile = 3, - CompileError = 4, - AsyncTaskEvent = 5, -}; - -class V8_EXPORT Debug { - public: - /** - * A client object passed to the v8 debugger whose ownership will be taken by - * it. v8 is always responsible for deleting the object. - */ - class ClientData { - public: - virtual ~ClientData() {} - }; - - - /** - * A message object passed to the debug message handler. - */ - class Message { - public: - /** - * Check type of message. - */ - virtual bool IsEvent() const = 0; - virtual bool IsResponse() const = 0; - virtual DebugEvent GetEvent() const = 0; - - /** - * Indicate whether this is a response to a continue command which will - * start the VM running after this is processed. - */ - virtual bool WillStartRunning() const = 0; - - /** - * Access to execution state and event data. Don't store these cross - * callbacks as their content becomes invalid. These objects are from the - * debugger event that started the debug message loop. - */ - virtual Local<Object> GetExecutionState() const = 0; - virtual Local<Object> GetEventData() const = 0; - - /** - * Get the debugger protocol JSON. - */ - virtual Local<String> GetJSON() const = 0; - - /** - * Get the context active when the debug event happened. Note this is not - * the current active context as the JavaScript part of the debugger is - * running in its own context which is entered at this point. - */ - virtual Local<Context> GetEventContext() const = 0; - - /** - * Client data passed with the corresponding request if any. This is the - * client_data data value passed into Debug::SendCommand along with the - * request that led to the message or NULL if the message is an event. The - * debugger takes ownership of the data and will delete it even if there is - * no message handler. - */ - virtual ClientData* GetClientData() const = 0; - - virtual Isolate* GetIsolate() const = 0; - - virtual ~Message() {} - }; - - /** - * An event details object passed to the debug event listener. - */ - class EventDetails { - public: - /** - * Event type. - */ - virtual DebugEvent GetEvent() const = 0; - - /** - * Access to execution state and event data of the debug event. Don't store - * these cross callbacks as their content becomes invalid. - */ - virtual Local<Object> GetExecutionState() const = 0; - virtual Local<Object> GetEventData() const = 0; - - /** - * Get the context active when the debug event happened. Note this is not - * the current active context as the JavaScript part of the debugger is - * running in its own context which is entered at this point. - */ - virtual Local<Context> GetEventContext() const = 0; - - /** - * Client data passed with the corresponding callback when it was - * registered. - */ - virtual Local<Value> GetCallbackData() const = 0; - - /** - * This is now a dummy that returns nullptr. - */ - virtual ClientData* GetClientData() const = 0; - - virtual Isolate* GetIsolate() const = 0; - - virtual ~EventDetails() {} - }; - - /** - * Debug event callback function. - * - * \param event_details object providing information about the debug event - * - * A EventCallback does not take possession of the event data, - * and must not rely on the data persisting after the handler returns. - */ - typedef void (*EventCallback)(const EventDetails& event_details); - - /** - * This is now a no-op. - */ - typedef void (*MessageHandler)(const Message& message); - - V8_DEPRECATED("No longer supported", static bool SetDebugEventListener( - Isolate* isolate, EventCallback that, - Local<Value> data = Local<Value>())); - - // Schedule a debugger break to happen when JavaScript code is run - // in the given isolate. - V8_DEPRECATED("No longer supported", - static void DebugBreak(Isolate* isolate)); - - // Remove scheduled debugger break in given isolate if it has not - // happened yet. - V8_DEPRECATED("No longer supported", - static void CancelDebugBreak(Isolate* isolate)); - - // Check if a debugger break is scheduled in the given isolate. - V8_DEPRECATED("No longer supported", - static bool CheckDebugBreak(Isolate* isolate)); - - // This is now a no-op. - V8_DEPRECATED("No longer supported", - static void SetMessageHandler(Isolate* isolate, - MessageHandler handler)); - - // This is now a no-op. - V8_DEPRECATED("No longer supported", - static void SendCommand(Isolate* isolate, - const uint16_t* command, int length, - ClientData* client_data = NULL)); - - /** - * Run a JavaScript function in the debugger. - * \param fun the function to call - * \param data passed as second argument to the function - * With this call the debugger is entered and the function specified is called - * with the execution state as the first argument. This makes it possible to - * get access to information otherwise not available during normal JavaScript - * execution e.g. details on stack frames. Receiver of the function call will - * be the debugger context global object, however this is a subject to change. - * The following example shows a JavaScript function which when passed to - * v8::Debug::Call will return the current line of JavaScript execution. - * - * \code - * function frame_source_line(exec_state) { - * return exec_state.frame(0).sourceLine(); - * } - * \endcode - */ - V8_DEPRECATED("No longer supported", - static MaybeLocal<Value> Call( - Local<Context> context, v8::Local<v8::Function> fun, - Local<Value> data = Local<Value>())); - - // This is now a no-op. - V8_DEPRECATED("No longer supported", - static void ProcessDebugMessages(Isolate* isolate)); - - /** - * Debugger is running in its own context which is entered while debugger - * messages are being dispatched. This is an explicit getter for this - * debugger context. Note that the content of the debugger context is subject - * to change. The Context exists only when the debugger is active, i.e. at - * least one DebugEventListener or MessageHandler is set. - */ - V8_DEPRECATED("Use v8-inspector", - static Local<Context> GetDebugContext(Isolate* isolate)); - - /** - * While in the debug context, this method returns the top-most non-debug - * context, if it exists. - */ - V8_DEPRECATED( - "No longer supported", - static MaybeLocal<Context> GetDebuggedContext(Isolate* isolate)); - - /** - * Enable/disable LiveEdit functionality for the given Isolate - * (default Isolate if not provided). V8 will abort if LiveEdit is - * unexpectedly used. LiveEdit is enabled by default. - */ - V8_DEPRECATED("No longer supported", - static void SetLiveEditEnabled(Isolate* isolate, bool enable)); - - /** - * Returns array of internal properties specific to the value type. Result has - * the following format: [<name>, <value>,...,<name>, <value>]. Result array - * will be allocated in the current context. - */ - V8_DEPRECATED("No longer supported", - static MaybeLocal<Array> GetInternalProperties( - Isolate* isolate, Local<Value> value)); - - /** - * Defines if the ES2015 tail call elimination feature is enabled or not. - * The change of this flag triggers deoptimization of all functions that - * contain calls at tail position. - */ - V8_DEPRECATED("No longer supported", - static bool IsTailCallEliminationEnabled(Isolate* isolate)); - V8_DEPRECATED("No longer supported", - static void SetTailCallEliminationEnabled(Isolate* isolate, - bool enabled)); -}; - - -} // namespace v8 - - -#undef EXPORT - - -#endif // V8_V8_DEBUG_H_ diff --git a/android/armeabi/include/v8/v8-inspector-protocol.h b/android/armeabi/include/v8/v8-inspector-protocol.h deleted file mode 100644 index 612a2ebc..00000000 --- a/android/armeabi/include/v8/v8-inspector-protocol.h +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_V8_INSPECTOR_PROTOCOL_H_ -#define V8_V8_INSPECTOR_PROTOCOL_H_ - -#include "inspector/Debugger.h" // NOLINT(build/include) -#include "inspector/Runtime.h" // NOLINT(build/include) -#include "inspector/Schema.h" // NOLINT(build/include) -#include "v8-inspector.h" // NOLINT(build/include) - -#endif // V8_V8_INSPECTOR_PROTOCOL_H_ diff --git a/android/armeabi/include/v8/v8-inspector.h b/android/armeabi/include/v8/v8-inspector.h deleted file mode 100644 index 43bf3b4f..00000000 --- a/android/armeabi/include/v8/v8-inspector.h +++ /dev/null @@ -1,267 +0,0 @@ -// Copyright 2016 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_V8_INSPECTOR_H_ -#define V8_V8_INSPECTOR_H_ - -#include <stdint.h> -#include <cctype> - -#include <memory> - -#include "v8.h" // NOLINT(build/include) - -namespace v8_inspector { - -namespace protocol { -namespace Debugger { -namespace API { -class SearchMatch; -} -} -namespace Runtime { -namespace API { -class RemoteObject; -class StackTrace; -} -} -namespace Schema { -namespace API { -class Domain; -} -} -} // namespace protocol - -class V8_EXPORT StringView { - public: - StringView() : m_is8Bit(true), m_length(0), m_characters8(nullptr) {} - - StringView(const uint8_t* characters, size_t length) - : m_is8Bit(true), m_length(length), m_characters8(characters) {} - - StringView(const uint16_t* characters, size_t length) - : m_is8Bit(false), m_length(length), m_characters16(characters) {} - - bool is8Bit() const { return m_is8Bit; } - size_t length() const { return m_length; } - - // TODO(dgozman): add DCHECK(m_is8Bit) to accessors once platform can be used - // here. - const uint8_t* characters8() const { return m_characters8; } - const uint16_t* characters16() const { return m_characters16; } - - private: - bool m_is8Bit; - size_t m_length; - union { - const uint8_t* m_characters8; - const uint16_t* m_characters16; - }; -}; - -class V8_EXPORT StringBuffer { - public: - virtual ~StringBuffer() {} - virtual const StringView& string() = 0; - // This method copies contents. - static std::unique_ptr<StringBuffer> create(const StringView&); -}; - -class V8_EXPORT V8ContextInfo { - public: - V8ContextInfo(v8::Local<v8::Context> context, int contextGroupId, - const StringView& humanReadableName) - : context(context), - contextGroupId(contextGroupId), - humanReadableName(humanReadableName), - hasMemoryOnConsole(false) {} - - v8::Local<v8::Context> context; - // Each v8::Context is a part of a group. The group id must be non-zero. - int contextGroupId; - StringView humanReadableName; - StringView origin; - StringView auxData; - bool hasMemoryOnConsole; - - static int executionContextId(v8::Local<v8::Context> context); - - private: - // Disallow copying and allocating this one. - enum NotNullTagEnum { NotNullLiteral }; - void* operator new(size_t) = delete; - void* operator new(size_t, NotNullTagEnum, void*) = delete; - void* operator new(size_t, void*) = delete; - V8ContextInfo(const V8ContextInfo&) = delete; - V8ContextInfo& operator=(const V8ContextInfo&) = delete; -}; - -class V8_EXPORT V8StackTrace { - public: - virtual bool isEmpty() const = 0; - virtual StringView topSourceURL() const = 0; - virtual int topLineNumber() const = 0; - virtual int topColumnNumber() const = 0; - virtual StringView topScriptId() const = 0; - virtual StringView topFunctionName() const = 0; - - virtual ~V8StackTrace() {} - virtual std::unique_ptr<protocol::Runtime::API::StackTrace> - buildInspectorObject() const = 0; - virtual std::unique_ptr<StringBuffer> toString() const = 0; - - // Safe to pass between threads, drops async chain. - virtual std::unique_ptr<V8StackTrace> clone() = 0; -}; - -class V8_EXPORT V8InspectorSession { - public: - virtual ~V8InspectorSession() {} - - // Cross-context inspectable values (DOM nodes in different worlds, etc.). - class V8_EXPORT Inspectable { - public: - virtual v8::Local<v8::Value> get(v8::Local<v8::Context>) = 0; - virtual ~Inspectable() {} - }; - virtual void addInspectedObject(std::unique_ptr<Inspectable>) = 0; - - // Dispatching protocol messages. - static bool canDispatchMethod(const StringView& method); - virtual void dispatchProtocolMessage(const StringView& message) = 0; - virtual std::unique_ptr<StringBuffer> stateJSON() = 0; - virtual std::vector<std::unique_ptr<protocol::Schema::API::Domain>> - supportedDomains() = 0; - - // Debugger actions. - virtual void schedulePauseOnNextStatement(const StringView& breakReason, - const StringView& breakDetails) = 0; - virtual void cancelPauseOnNextStatement() = 0; - virtual void breakProgram(const StringView& breakReason, - const StringView& breakDetails) = 0; - virtual void setSkipAllPauses(bool) = 0; - virtual void resume() = 0; - virtual void stepOver() = 0; - virtual std::vector<std::unique_ptr<protocol::Debugger::API::SearchMatch>> - searchInTextByLines(const StringView& text, const StringView& query, - bool caseSensitive, bool isRegex) = 0; - - // Remote objects. - virtual std::unique_ptr<protocol::Runtime::API::RemoteObject> wrapObject( - v8::Local<v8::Context>, v8::Local<v8::Value>, - const StringView& groupName) = 0; - virtual bool unwrapObject(std::unique_ptr<StringBuffer>* error, - const StringView& objectId, v8::Local<v8::Value>*, - v8::Local<v8::Context>*, - std::unique_ptr<StringBuffer>* objectGroup) = 0; - virtual void releaseObjectGroup(const StringView&) = 0; -}; - -class V8_EXPORT V8InspectorClient { - public: - virtual ~V8InspectorClient() {} - - virtual void runMessageLoopOnPause(int contextGroupId) {} - virtual void quitMessageLoopOnPause() {} - virtual void runIfWaitingForDebugger(int contextGroupId) {} - - virtual void muteMetrics(int contextGroupId) {} - virtual void unmuteMetrics(int contextGroupId) {} - - virtual void beginUserGesture() {} - virtual void endUserGesture() {} - - virtual std::unique_ptr<StringBuffer> valueSubtype(v8::Local<v8::Value>) { - return nullptr; - } - virtual bool formatAccessorsAsProperties(v8::Local<v8::Value>) { - return false; - } - virtual bool isInspectableHeapObject(v8::Local<v8::Object>) { return true; } - - virtual v8::Local<v8::Context> ensureDefaultContextInGroup( - int contextGroupId) { - return v8::Local<v8::Context>(); - } - virtual void beginEnsureAllContextsInGroup(int contextGroupId) {} - virtual void endEnsureAllContextsInGroup(int contextGroupId) {} - - virtual void installAdditionalCommandLineAPI(v8::Local<v8::Context>, - v8::Local<v8::Object>) {} - virtual void consoleAPIMessage(int contextGroupId, - v8::Isolate::MessageErrorLevel level, - const StringView& message, - const StringView& url, unsigned lineNumber, - unsigned columnNumber, V8StackTrace*) {} - virtual v8::MaybeLocal<v8::Value> memoryInfo(v8::Isolate*, - v8::Local<v8::Context>) { - return v8::MaybeLocal<v8::Value>(); - } - - virtual void consoleTime(const StringView& title) {} - virtual void consoleTimeEnd(const StringView& title) {} - virtual void consoleTimeStamp(const StringView& title) {} - virtual void consoleClear(int contextGroupId) {} - virtual double currentTimeMS() { return 0; } - typedef void (*TimerCallback)(void*); - virtual void startRepeatingTimer(double, TimerCallback, void* data) {} - virtual void cancelTimer(void* data) {} - - // TODO(dgozman): this was added to support service worker shadow page. We - // should not connect at all. - virtual bool canExecuteScripts(int contextGroupId) { return true; } -}; - -class V8_EXPORT V8Inspector { - public: - static std::unique_ptr<V8Inspector> create(v8::Isolate*, V8InspectorClient*); - virtual ~V8Inspector() {} - - // Contexts instrumentation. - virtual void contextCreated(const V8ContextInfo&) = 0; - virtual void contextDestroyed(v8::Local<v8::Context>) = 0; - virtual void resetContextGroup(int contextGroupId) = 0; - - // Various instrumentation. - virtual void idleStarted() = 0; - virtual void idleFinished() = 0; - - // Async stack traces instrumentation. - virtual void asyncTaskScheduled(const StringView& taskName, void* task, - bool recurring) = 0; - virtual void asyncTaskCanceled(void* task) = 0; - virtual void asyncTaskStarted(void* task) = 0; - virtual void asyncTaskFinished(void* task) = 0; - virtual void allAsyncTasksCanceled() = 0; - - // Exceptions instrumentation. - virtual unsigned exceptionThrown( - v8::Local<v8::Context>, const StringView& message, - v8::Local<v8::Value> exception, const StringView& detailedMessage, - const StringView& url, unsigned lineNumber, unsigned columnNumber, - std::unique_ptr<V8StackTrace>, int scriptId) = 0; - virtual void exceptionRevoked(v8::Local<v8::Context>, unsigned exceptionId, - const StringView& message) = 0; - - // Connection. - class V8_EXPORT Channel { - public: - virtual ~Channel() {} - virtual void sendResponse(int callId, - std::unique_ptr<StringBuffer> message) = 0; - virtual void sendNotification(std::unique_ptr<StringBuffer> message) = 0; - virtual void flushProtocolNotifications() = 0; - }; - virtual std::unique_ptr<V8InspectorSession> connect( - int contextGroupId, Channel*, const StringView& state) = 0; - - // API methods. - virtual std::unique_ptr<V8StackTrace> createStackTrace( - v8::Local<v8::StackTrace>) = 0; - virtual std::unique_ptr<V8StackTrace> captureStackTrace(bool fullStack) = 0; -}; - -} // namespace v8_inspector - -#endif // V8_V8_INSPECTOR_H_ diff --git a/android/armeabi/include/v8/v8-platform.h b/android/armeabi/include/v8/v8-platform.h deleted file mode 100644 index 8f6d8042..00000000 --- a/android/armeabi/include/v8/v8-platform.h +++ /dev/null @@ -1,227 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_V8_PLATFORM_H_ -#define V8_V8_PLATFORM_H_ - -#include <stddef.h> -#include <stdint.h> -#include <memory> -#include <string> - -namespace v8 { - -class Isolate; - -/** - * A Task represents a unit of work. - */ -class Task { - public: - virtual ~Task() = default; - - virtual void Run() = 0; -}; - -/** - * An IdleTask represents a unit of work to be performed in idle time. - * The Run method is invoked with an argument that specifies the deadline in - * seconds returned by MonotonicallyIncreasingTime(). - * The idle task is expected to complete by this deadline. - */ -class IdleTask { - public: - virtual ~IdleTask() = default; - virtual void Run(double deadline_in_seconds) = 0; -}; - -/** - * The interface represents complex arguments to trace events. - */ -class ConvertableToTraceFormat { - public: - virtual ~ConvertableToTraceFormat() = default; - - /** - * Append the class info to the provided |out| string. The appended - * data must be a valid JSON object. Strings must be properly quoted, and - * escaped. There is no processing applied to the content after it is - * appended. - */ - virtual void AppendAsTraceFormat(std::string* out) const = 0; -}; - -/** - * V8 Platform abstraction layer. - * - * The embedder has to provide an implementation of this interface before - * initializing the rest of V8. - */ -class Platform { - public: - /** - * This enum is used to indicate whether a task is potentially long running, - * or causes a long wait. The embedder might want to use this hint to decide - * whether to execute the task on a dedicated thread. - */ - enum ExpectedRuntime { - kShortRunningTask, - kLongRunningTask - }; - - virtual ~Platform() = default; - - /** - * Gets the number of threads that are used to execute background tasks. Is - * used to estimate the number of tasks a work package should be split into. - * A return value of 0 means that there are no background threads available. - * Note that a value of 0 won't prohibit V8 from posting tasks using - * |CallOnBackgroundThread|. - */ - virtual size_t NumberOfAvailableBackgroundThreads() { return 0; } - - /** - * Schedules a task to be invoked on a background thread. |expected_runtime| - * indicates that the task will run a long time. The Platform implementation - * takes ownership of |task|. There is no guarantee about order of execution - * of tasks wrt order of scheduling, nor is there a guarantee about the - * thread the task will be run on. - */ - virtual void CallOnBackgroundThread(Task* task, - ExpectedRuntime expected_runtime) = 0; - - /** - * Schedules a task to be invoked on a foreground thread wrt a specific - * |isolate|. Tasks posted for the same isolate should be execute in order of - * scheduling. The definition of "foreground" is opaque to V8. - */ - virtual void CallOnForegroundThread(Isolate* isolate, Task* task) = 0; - - /** - * Schedules a task to be invoked on a foreground thread wrt a specific - * |isolate| after the given number of seconds |delay_in_seconds|. - * Tasks posted for the same isolate should be execute in order of - * scheduling. The definition of "foreground" is opaque to V8. - */ - virtual void CallDelayedOnForegroundThread(Isolate* isolate, Task* task, - double delay_in_seconds) = 0; - - /** - * Schedules a task to be invoked on a foreground thread wrt a specific - * |isolate| when the embedder is idle. - * Requires that SupportsIdleTasks(isolate) is true. - * Idle tasks may be reordered relative to other task types and may be - * starved for an arbitrarily long time if no idle time is available. - * The definition of "foreground" is opaque to V8. - */ - virtual void CallIdleOnForegroundThread(Isolate* isolate, IdleTask* task) { - // TODO(ulan): Make this function abstract after V8 roll in Chromium. - } - - /** - * Returns true if idle tasks are enabled for the given |isolate|. - */ - virtual bool IdleTasksEnabled(Isolate* isolate) { - // TODO(ulan): Make this function abstract after V8 roll in Chromium. - return false; - } - - /** - * Monotonically increasing time in seconds from an arbitrary fixed point in - * the past. This function is expected to return at least - * millisecond-precision values. For this reason, - * it is recommended that the fixed point be no further in the past than - * the epoch. - **/ - virtual double MonotonicallyIncreasingTime() = 0; - - /** - * Called by TRACE_EVENT* macros, don't call this directly. - * The name parameter is a category group for example: - * TRACE_EVENT0("v8,parse", "V8.Parse") - * The pointer returned points to a value with zero or more of the bits - * defined in CategoryGroupEnabledFlags. - **/ - virtual const uint8_t* GetCategoryGroupEnabled(const char* name) { - static uint8_t no = 0; - return &no; - } - - /** - * Gets the category group name of the given category_enabled_flag pointer. - * Usually used while serliazing TRACE_EVENTs. - **/ - virtual const char* GetCategoryGroupName( - const uint8_t* category_enabled_flag) { - static const char dummy[] = "dummy"; - return dummy; - } - - /** - * Adds a trace event to the platform tracing system. This function call is - * usually the result of a TRACE_* macro from trace_event_common.h when - * tracing and the category of the particular trace are enabled. It is not - * advisable to call this function on its own; it is really only meant to be - * used by the trace macros. The returned handle can be used by - * UpdateTraceEventDuration to update the duration of COMPLETE events. - */ - virtual uint64_t AddTraceEvent( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, unsigned int flags) { - return 0; - } - - /** - * Adds a trace event to the platform tracing system. This function call is - * usually the result of a TRACE_* macro from trace_event_common.h when - * tracing and the category of the particular trace are enabled. It is not - * advisable to call this function on its own; it is really only meant to be - * used by the trace macros. The returned handle can be used by - * UpdateTraceEventDuration to update the duration of COMPLETE events. - */ - virtual uint64_t AddTraceEvent( - char phase, const uint8_t* category_enabled_flag, const char* name, - const char* scope, uint64_t id, uint64_t bind_id, int32_t num_args, - const char** arg_names, const uint8_t* arg_types, - const uint64_t* arg_values, - std::unique_ptr<ConvertableToTraceFormat>* arg_convertables, - unsigned int flags) { - return AddTraceEvent(phase, category_enabled_flag, name, scope, id, bind_id, - num_args, arg_names, arg_types, arg_values, flags); - } - - /** - * Sets the duration field of a COMPLETE trace event. It must be called with - * the handle returned from AddTraceEvent(). - **/ - virtual void UpdateTraceEventDuration(const uint8_t* category_enabled_flag, - const char* name, uint64_t handle) {} - - class TraceStateObserver { - public: - virtual ~TraceStateObserver() = default; - virtual void OnTraceEnabled() = 0; - virtual void OnTraceDisabled() = 0; - }; - - /** Adds tracing state change observer. */ - virtual void AddTraceStateObserver(TraceStateObserver*) {} - - /** Removes tracing state change observer. */ - virtual void RemoveTraceStateObserver(TraceStateObserver*) {} - - typedef void (*StackTracePrinter)(); - - /** - * Returns a function pointer that print a stack trace of the current stack - * on invocation. Disables printing of the stack trace if nullptr. - */ - virtual StackTracePrinter GetStackTracePrinter() { return nullptr; } -}; - -} // namespace v8 - -#endif // V8_V8_PLATFORM_H_ diff --git a/android/armeabi/include/v8/v8-profiler.h b/android/armeabi/include/v8/v8-profiler.h deleted file mode 100644 index b60d137f..00000000 --- a/android/armeabi/include/v8/v8-profiler.h +++ /dev/null @@ -1,912 +0,0 @@ -// Copyright 2010 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_V8_PROFILER_H_ -#define V8_V8_PROFILER_H_ - -#include <unordered_set> -#include <vector> -#include "v8.h" // NOLINT(build/include) - -/** - * Profiler support for the V8 JavaScript engine. - */ -namespace v8 { - -class HeapGraphNode; -struct HeapStatsUpdate; - -typedef uint32_t SnapshotObjectId; - - -struct CpuProfileDeoptFrame { - int script_id; - size_t position; -}; - -} // namespace v8 - -#ifdef V8_OS_WIN -template class V8_EXPORT std::vector<v8::CpuProfileDeoptFrame>; -#endif - -namespace v8 { - -struct V8_EXPORT CpuProfileDeoptInfo { - /** A pointer to a static string owned by v8. */ - const char* deopt_reason; - std::vector<CpuProfileDeoptFrame> stack; -}; - -} // namespace v8 - -#ifdef V8_OS_WIN -template class V8_EXPORT std::vector<v8::CpuProfileDeoptInfo>; -#endif - -namespace v8 { - -/** - * TracingCpuProfiler monitors tracing being enabled/disabled - * and emits CpuProfile trace events once v8.cpu_profiler tracing category - * is enabled. It has no overhead unless the category is enabled. - */ -class V8_EXPORT TracingCpuProfiler { - public: - static std::unique_ptr<TracingCpuProfiler> Create(Isolate*); - virtual ~TracingCpuProfiler() = default; - - protected: - TracingCpuProfiler() = default; -}; - -// TickSample captures the information collected for each sample. -struct TickSample { - // Internal profiling (with --prof + tools/$OS-tick-processor) wants to - // include the runtime function we're calling. Externally exposed tick - // samples don't care. - enum RecordCEntryFrame { kIncludeCEntryFrame, kSkipCEntryFrame }; - - TickSample() - : state(OTHER), - pc(nullptr), - external_callback_entry(nullptr), - frames_count(0), - has_external_callback(false), - update_stats(true) {} - - /** - * Initialize a tick sample from the isolate. - * \param isolate The isolate. - * \param state Execution state. - * \param record_c_entry_frame Include or skip the runtime function. - * \param update_stats Whether update the sample to the aggregated stats. - * \param use_simulator_reg_state When set to true and V8 is running under a - * simulator, the method will use the simulator - * register state rather than the one provided - * with |state| argument. Otherwise the method - * will use provided register |state| as is. - */ - void Init(Isolate* isolate, const v8::RegisterState& state, - RecordCEntryFrame record_c_entry_frame, bool update_stats, - bool use_simulator_reg_state = true); - /** - * Get a call stack sample from the isolate. - * \param isolate The isolate. - * \param state Register state. - * \param record_c_entry_frame Include or skip the runtime function. - * \param frames Caller allocated buffer to store stack frames. - * \param frames_limit Maximum number of frames to capture. The buffer must - * be large enough to hold the number of frames. - * \param sample_info The sample info is filled up by the function - * provides number of actual captured stack frames and - * the current VM state. - * \param use_simulator_reg_state When set to true and V8 is running under a - * simulator, the method will use the simulator - * register state rather than the one provided - * with |state| argument. Otherwise the method - * will use provided register |state| as is. - * \note GetStackSample is thread and signal safe and should only be called - * when the JS thread is paused or interrupted. - * Otherwise the behavior is undefined. - */ - static bool GetStackSample(Isolate* isolate, v8::RegisterState* state, - RecordCEntryFrame record_c_entry_frame, - void** frames, size_t frames_limit, - v8::SampleInfo* sample_info, - bool use_simulator_reg_state = true); - StateTag state; // The state of the VM. - void* pc; // Instruction pointer. - union { - void* tos; // Top stack value (*sp). - void* external_callback_entry; - }; - static const unsigned kMaxFramesCountLog2 = 8; - static const unsigned kMaxFramesCount = (1 << kMaxFramesCountLog2) - 1; - void* stack[kMaxFramesCount]; // Call stack. - unsigned frames_count : kMaxFramesCountLog2; // Number of captured frames. - bool has_external_callback : 1; - bool update_stats : 1; // Whether the sample should update aggregated stats. -}; - -/** - * CpuProfileNode represents a node in a call graph. - */ -class V8_EXPORT CpuProfileNode { - public: - struct LineTick { - /** The 1-based number of the source line where the function originates. */ - int line; - - /** The count of samples associated with the source line. */ - unsigned int hit_count; - }; - - /** Returns function name (empty string for anonymous functions.) */ - Local<String> GetFunctionName() const; - - /** - * Returns function name (empty string for anonymous functions.) - * The string ownership is *not* passed to the caller. It stays valid until - * profile is deleted. The function is thread safe. - */ - const char* GetFunctionNameStr() const; - - /** Returns id of the script where function is located. */ - int GetScriptId() const; - - /** Returns resource name for script from where the function originates. */ - Local<String> GetScriptResourceName() const; - - /** - * Returns resource name for script from where the function originates. - * The string ownership is *not* passed to the caller. It stays valid until - * profile is deleted. The function is thread safe. - */ - const char* GetScriptResourceNameStr() const; - - /** - * Returns the number, 1-based, of the line where the function originates. - * kNoLineNumberInfo if no line number information is available. - */ - int GetLineNumber() const; - - /** - * Returns 1-based number of the column where the function originates. - * kNoColumnNumberInfo if no column number information is available. - */ - int GetColumnNumber() const; - - /** - * Returns the number of the function's source lines that collect the samples. - */ - unsigned int GetHitLineCount() const; - - /** Returns the set of source lines that collect the samples. - * The caller allocates buffer and responsible for releasing it. - * True if all available entries are copied, otherwise false. - * The function copies nothing if buffer is not large enough. - */ - bool GetLineTicks(LineTick* entries, unsigned int length) const; - - /** Returns bailout reason for the function - * if the optimization was disabled for it. - */ - const char* GetBailoutReason() const; - - /** - * Returns the count of samples where the function was currently executing. - */ - unsigned GetHitCount() const; - - /** Returns function entry UID. */ - V8_DEPRECATE_SOON( - "Use GetScriptId, GetLineNumber, and GetColumnNumber instead.", - unsigned GetCallUid() const); - - /** Returns id of the node. The id is unique within the tree */ - unsigned GetNodeId() const; - - /** Returns child nodes count of the node. */ - int GetChildrenCount() const; - - /** Retrieves a child node by index. */ - const CpuProfileNode* GetChild(int index) const; - - /** Retrieves deopt infos for the node. */ - const std::vector<CpuProfileDeoptInfo>& GetDeoptInfos() const; - - static const int kNoLineNumberInfo = Message::kNoLineNumberInfo; - static const int kNoColumnNumberInfo = Message::kNoColumnInfo; -}; - - -/** - * CpuProfile contains a CPU profile in a form of top-down call tree - * (from main() down to functions that do all the work). - */ -class V8_EXPORT CpuProfile { - public: - /** Returns CPU profile title. */ - Local<String> GetTitle() const; - - /** Returns the root node of the top down call tree. */ - const CpuProfileNode* GetTopDownRoot() const; - - /** - * Returns number of samples recorded. The samples are not recorded unless - * |record_samples| parameter of CpuProfiler::StartCpuProfiling is true. - */ - int GetSamplesCount() const; - - /** - * Returns profile node corresponding to the top frame the sample at - * the given index. - */ - const CpuProfileNode* GetSample(int index) const; - - /** - * Returns the timestamp of the sample. The timestamp is the number of - * microseconds since some unspecified starting point. - * The point is equal to the starting point used by GetStartTime. - */ - int64_t GetSampleTimestamp(int index) const; - - /** - * Returns time when the profile recording was started (in microseconds) - * since some unspecified starting point. - */ - int64_t GetStartTime() const; - - /** - * Returns time when the profile recording was stopped (in microseconds) - * since some unspecified starting point. - * The point is equal to the starting point used by GetStartTime. - */ - int64_t GetEndTime() const; - - /** - * Deletes the profile and removes it from CpuProfiler's list. - * All pointers to nodes previously returned become invalid. - */ - void Delete(); -}; - -/** - * Interface for controlling CPU profiling. Instance of the - * profiler can be created using v8::CpuProfiler::New method. - */ -class V8_EXPORT CpuProfiler { - public: - /** - * Creates a new CPU profiler for the |isolate|. The isolate must be - * initialized. The profiler object must be disposed after use by calling - * |Dispose| method. - */ - static CpuProfiler* New(Isolate* isolate); - - /** - * Disposes the CPU profiler object. - */ - void Dispose(); - - /** - * Changes default CPU profiler sampling interval to the specified number - * of microseconds. Default interval is 1000us. This method must be called - * when there are no profiles being recorded. - */ - void SetSamplingInterval(int us); - - /** - * Starts collecting CPU profile. Title may be an empty string. It - * is allowed to have several profiles being collected at - * once. Attempts to start collecting several profiles with the same - * title are silently ignored. While collecting a profile, functions - * from all security contexts are included in it. The token-based - * filtering is only performed when querying for a profile. - * - * |record_samples| parameter controls whether individual samples should - * be recorded in addition to the aggregated tree. - */ - void StartProfiling(Local<String> title, bool record_samples = false); - - /** - * Stops collecting CPU profile with a given title and returns it. - * If the title given is empty, finishes the last profile started. - */ - CpuProfile* StopProfiling(Local<String> title); - - /** - * Force collection of a sample. Must be called on the VM thread. - * Recording the forced sample does not contribute to the aggregated - * profile statistics. - */ - void CollectSample(); - - /** - * Tells the profiler whether the embedder is idle. - */ - void SetIdle(bool is_idle); - - private: - CpuProfiler(); - ~CpuProfiler(); - CpuProfiler(const CpuProfiler&); - CpuProfiler& operator=(const CpuProfiler&); -}; - - -/** - * HeapSnapshotEdge represents a directed connection between heap - * graph nodes: from retainers to retained nodes. - */ -class V8_EXPORT HeapGraphEdge { - public: - enum Type { - kContextVariable = 0, // A variable from a function context. - kElement = 1, // An element of an array. - kProperty = 2, // A named object property. - kInternal = 3, // A link that can't be accessed from JS, - // thus, its name isn't a real property name - // (e.g. parts of a ConsString). - kHidden = 4, // A link that is needed for proper sizes - // calculation, but may be hidden from user. - kShortcut = 5, // A link that must not be followed during - // sizes calculation. - kWeak = 6 // A weak reference (ignored by the GC). - }; - - /** Returns edge type (see HeapGraphEdge::Type). */ - Type GetType() const; - - /** - * Returns edge name. This can be a variable name, an element index, or - * a property name. - */ - Local<Value> GetName() const; - - /** Returns origin node. */ - const HeapGraphNode* GetFromNode() const; - - /** Returns destination node. */ - const HeapGraphNode* GetToNode() const; -}; - - -/** - * HeapGraphNode represents a node in a heap graph. - */ -class V8_EXPORT HeapGraphNode { - public: - enum Type { - kHidden = 0, // Hidden node, may be filtered when shown to user. - kArray = 1, // An array of elements. - kString = 2, // A string. - kObject = 3, // A JS object (except for arrays and strings). - kCode = 4, // Compiled code. - kClosure = 5, // Function closure. - kRegExp = 6, // RegExp. - kHeapNumber = 7, // Number stored in the heap. - kNative = 8, // Native object (not from V8 heap). - kSynthetic = 9, // Synthetic object, usualy used for grouping - // snapshot items together. - kConsString = 10, // Concatenated string. A pair of pointers to strings. - kSlicedString = 11, // Sliced string. A fragment of another string. - kSymbol = 12 // A Symbol (ES6). - }; - - /** Returns node type (see HeapGraphNode::Type). */ - Type GetType() const; - - /** - * Returns node name. Depending on node's type this can be the name - * of the constructor (for objects), the name of the function (for - * closures), string value, or an empty string (for compiled code). - */ - Local<String> GetName() const; - - /** - * Returns node id. For the same heap object, the id remains the same - * across all snapshots. - */ - SnapshotObjectId GetId() const; - - /** Returns node's own size, in bytes. */ - size_t GetShallowSize() const; - - /** Returns child nodes count of the node. */ - int GetChildrenCount() const; - - /** Retrieves a child by index. */ - const HeapGraphEdge* GetChild(int index) const; -}; - - -/** - * An interface for exporting data from V8, using "push" model. - */ -class V8_EXPORT OutputStream { // NOLINT - public: - enum WriteResult { - kContinue = 0, - kAbort = 1 - }; - virtual ~OutputStream() {} - /** Notify about the end of stream. */ - virtual void EndOfStream() = 0; - /** Get preferred output chunk size. Called only once. */ - virtual int GetChunkSize() { return 1024; } - /** - * Writes the next chunk of snapshot data into the stream. Writing - * can be stopped by returning kAbort as function result. EndOfStream - * will not be called in case writing was aborted. - */ - virtual WriteResult WriteAsciiChunk(char* data, int size) = 0; - /** - * Writes the next chunk of heap stats data into the stream. Writing - * can be stopped by returning kAbort as function result. EndOfStream - * will not be called in case writing was aborted. - */ - virtual WriteResult WriteHeapStatsChunk(HeapStatsUpdate* data, int count) { - return kAbort; - } -}; - - -/** - * HeapSnapshots record the state of the JS heap at some moment. - */ -class V8_EXPORT HeapSnapshot { - public: - enum SerializationFormat { - kJSON = 0 // See format description near 'Serialize' method. - }; - - /** Returns the root node of the heap graph. */ - const HeapGraphNode* GetRoot() const; - - /** Returns a node by its id. */ - const HeapGraphNode* GetNodeById(SnapshotObjectId id) const; - - /** Returns total nodes count in the snapshot. */ - int GetNodesCount() const; - - /** Returns a node by index. */ - const HeapGraphNode* GetNode(int index) const; - - /** Returns a max seen JS object Id. */ - SnapshotObjectId GetMaxSnapshotJSObjectId() const; - - /** - * Deletes the snapshot and removes it from HeapProfiler's list. - * All pointers to nodes, edges and paths previously returned become - * invalid. - */ - void Delete(); - - /** - * Prepare a serialized representation of the snapshot. The result - * is written into the stream provided in chunks of specified size. - * The total length of the serialized snapshot is unknown in - * advance, it can be roughly equal to JS heap size (that means, - * it can be really big - tens of megabytes). - * - * For the JSON format, heap contents are represented as an object - * with the following structure: - * - * { - * snapshot: { - * title: "...", - * uid: nnn, - * meta: { meta-info }, - * node_count: nnn, - * edge_count: nnn - * }, - * nodes: [nodes array], - * edges: [edges array], - * strings: [strings array] - * } - * - * Nodes reference strings, other nodes, and edges by their indexes - * in corresponding arrays. - */ - void Serialize(OutputStream* stream, - SerializationFormat format = kJSON) const; -}; - - -/** - * An interface for reporting progress and controlling long-running - * activities. - */ -class V8_EXPORT ActivityControl { // NOLINT - public: - enum ControlOption { - kContinue = 0, - kAbort = 1 - }; - virtual ~ActivityControl() {} - /** - * Notify about current progress. The activity can be stopped by - * returning kAbort as the callback result. - */ - virtual ControlOption ReportProgressValue(int done, int total) = 0; -}; - - -/** - * AllocationProfile is a sampled profile of allocations done by the program. - * This is structured as a call-graph. - */ -class V8_EXPORT AllocationProfile { - public: - struct Allocation { - /** - * Size of the sampled allocation object. - */ - size_t size; - - /** - * The number of objects of such size that were sampled. - */ - unsigned int count; - }; - - /** - * Represents a node in the call-graph. - */ - struct Node { - /** - * Name of the function. May be empty for anonymous functions or if the - * script corresponding to this function has been unloaded. - */ - Local<String> name; - - /** - * Name of the script containing the function. May be empty if the script - * name is not available, or if the script has been unloaded. - */ - Local<String> script_name; - - /** - * id of the script where the function is located. May be equal to - * v8::UnboundScript::kNoScriptId in cases where the script doesn't exist. - */ - int script_id; - - /** - * Start position of the function in the script. - */ - int start_position; - - /** - * 1-indexed line number where the function starts. May be - * kNoLineNumberInfo if no line number information is available. - */ - int line_number; - - /** - * 1-indexed column number where the function starts. May be - * kNoColumnNumberInfo if no line number information is available. - */ - int column_number; - - /** - * List of callees called from this node for which we have sampled - * allocations. The lifetime of the children is scoped to the containing - * AllocationProfile. - */ - std::vector<Node*> children; - - /** - * List of self allocations done by this node in the call-graph. - */ - std::vector<Allocation> allocations; - }; - - /** - * Returns the root node of the call-graph. The root node corresponds to an - * empty JS call-stack. The lifetime of the returned Node* is scoped to the - * containing AllocationProfile. - */ - virtual Node* GetRootNode() = 0; - - virtual ~AllocationProfile() {} - - static const int kNoLineNumberInfo = Message::kNoLineNumberInfo; - static const int kNoColumnNumberInfo = Message::kNoColumnInfo; -}; - - -/** - * Interface for controlling heap profiling. Instance of the - * profiler can be retrieved using v8::Isolate::GetHeapProfiler. - */ -class V8_EXPORT HeapProfiler { - public: - enum SamplingFlags { - kSamplingNoFlags = 0, - kSamplingForceGC = 1 << 0, - }; - - typedef std::unordered_set<const v8::PersistentBase<v8::Value>*> - RetainerChildren; - typedef std::vector<std::pair<v8::RetainedObjectInfo*, RetainerChildren>> - RetainerGroups; - typedef std::vector<std::pair<const v8::PersistentBase<v8::Value>*, - const v8::PersistentBase<v8::Value>*>> - RetainerEdges; - - struct RetainerInfos { - RetainerGroups groups; - RetainerEdges edges; - }; - - /** - * Callback function invoked to retrieve all RetainerInfos from the embedder. - */ - typedef RetainerInfos (*GetRetainerInfosCallback)(v8::Isolate* isolate); - - /** - * Callback function invoked for obtaining RetainedObjectInfo for - * the given JavaScript wrapper object. It is prohibited to enter V8 - * while the callback is running: only getters on the handle and - * GetPointerFromInternalField on the objects are allowed. - */ - typedef RetainedObjectInfo* (*WrapperInfoCallback)(uint16_t class_id, - Local<Value> wrapper); - - /** Returns the number of snapshots taken. */ - int GetSnapshotCount(); - - /** Returns a snapshot by index. */ - const HeapSnapshot* GetHeapSnapshot(int index); - - /** - * Returns SnapshotObjectId for a heap object referenced by |value| if - * it has been seen by the heap profiler, kUnknownObjectId otherwise. - */ - SnapshotObjectId GetObjectId(Local<Value> value); - - /** - * Returns heap object with given SnapshotObjectId if the object is alive, - * otherwise empty handle is returned. - */ - Local<Value> FindObjectById(SnapshotObjectId id); - - /** - * Clears internal map from SnapshotObjectId to heap object. The new objects - * will not be added into it unless a heap snapshot is taken or heap object - * tracking is kicked off. - */ - void ClearObjectIds(); - - /** - * A constant for invalid SnapshotObjectId. GetSnapshotObjectId will return - * it in case heap profiler cannot find id for the object passed as - * parameter. HeapSnapshot::GetNodeById will always return NULL for such id. - */ - static const SnapshotObjectId kUnknownObjectId = 0; - - /** - * Callback interface for retrieving user friendly names of global objects. - */ - class ObjectNameResolver { - public: - /** - * Returns name to be used in the heap snapshot for given node. Returned - * string must stay alive until snapshot collection is completed. - */ - virtual const char* GetName(Local<Object> object) = 0; - - protected: - virtual ~ObjectNameResolver() {} - }; - - /** - * Takes a heap snapshot and returns it. - */ - const HeapSnapshot* TakeHeapSnapshot( - ActivityControl* control = NULL, - ObjectNameResolver* global_object_name_resolver = NULL); - - /** - * Starts tracking of heap objects population statistics. After calling - * this method, all heap objects relocations done by the garbage collector - * are being registered. - * - * |track_allocations| parameter controls whether stack trace of each - * allocation in the heap will be recorded and reported as part of - * HeapSnapshot. - */ - void StartTrackingHeapObjects(bool track_allocations = false); - - /** - * Adds a new time interval entry to the aggregated statistics array. The - * time interval entry contains information on the current heap objects - * population size. The method also updates aggregated statistics and - * reports updates for all previous time intervals via the OutputStream - * object. Updates on each time interval are provided as a stream of the - * HeapStatsUpdate structure instances. - * If |timestamp_us| is supplied, timestamp of the new entry will be written - * into it. The return value of the function is the last seen heap object Id. - * - * StartTrackingHeapObjects must be called before the first call to this - * method. - */ - SnapshotObjectId GetHeapStats(OutputStream* stream, - int64_t* timestamp_us = NULL); - - /** - * Stops tracking of heap objects population statistics, cleans up all - * collected data. StartHeapObjectsTracking must be called again prior to - * calling GetHeapStats next time. - */ - void StopTrackingHeapObjects(); - - /** - * Starts gathering a sampling heap profile. A sampling heap profile is - * similar to tcmalloc's heap profiler and Go's mprof. It samples object - * allocations and builds an online 'sampling' heap profile. At any point in - * time, this profile is expected to be a representative sample of objects - * currently live in the system. Each sampled allocation includes the stack - * trace at the time of allocation, which makes this really useful for memory - * leak detection. - * - * This mechanism is intended to be cheap enough that it can be used in - * production with minimal performance overhead. - * - * Allocations are sampled using a randomized Poisson process. On average, one - * allocation will be sampled every |sample_interval| bytes allocated. The - * |stack_depth| parameter controls the maximum number of stack frames to be - * captured on each allocation. - * - * NOTE: This is a proof-of-concept at this point. Right now we only sample - * newspace allocations. Support for paged space allocation (e.g. pre-tenured - * objects, large objects, code objects, etc.) and native allocations - * doesn't exist yet, but is anticipated in the future. - * - * Objects allocated before the sampling is started will not be included in - * the profile. - * - * Returns false if a sampling heap profiler is already running. - */ - bool StartSamplingHeapProfiler(uint64_t sample_interval = 512 * 1024, - int stack_depth = 16, - SamplingFlags flags = kSamplingNoFlags); - - /** - * Stops the sampling heap profile and discards the current profile. - */ - void StopSamplingHeapProfiler(); - - /** - * Returns the sampled profile of allocations allocated (and still live) since - * StartSamplingHeapProfiler was called. The ownership of the pointer is - * transfered to the caller. Returns nullptr if sampling heap profiler is not - * active. - */ - AllocationProfile* GetAllocationProfile(); - - /** - * Deletes all snapshots taken. All previously returned pointers to - * snapshots and their contents become invalid after this call. - */ - void DeleteAllHeapSnapshots(); - - /** Binds a callback to embedder's class ID. */ - void SetWrapperClassInfoProvider( - uint16_t class_id, - WrapperInfoCallback callback); - - void SetGetRetainerInfosCallback(GetRetainerInfosCallback callback); - - /** - * Default value of persistent handle class ID. Must not be used to - * define a class. Can be used to reset a class of a persistent - * handle. - */ - static const uint16_t kPersistentHandleNoClassId = 0; - - /** Returns memory used for profiler internal data and snapshots. */ - size_t GetProfilerMemorySize(); - - private: - HeapProfiler(); - ~HeapProfiler(); - HeapProfiler(const HeapProfiler&); - HeapProfiler& operator=(const HeapProfiler&); -}; - -/** - * Interface for providing information about embedder's objects - * held by global handles. This information is reported in two ways: - * - * 1. When calling AddObjectGroup, an embedder may pass - * RetainedObjectInfo instance describing the group. To collect - * this information while taking a heap snapshot, V8 calls GC - * prologue and epilogue callbacks. - * - * 2. When a heap snapshot is collected, V8 additionally - * requests RetainedObjectInfos for persistent handles that - * were not previously reported via AddObjectGroup. - * - * Thus, if an embedder wants to provide information about native - * objects for heap snapshots, it can do it in a GC prologue - * handler, and / or by assigning wrapper class ids in the following way: - * - * 1. Bind a callback to class id by calling SetWrapperClassInfoProvider. - * 2. Call SetWrapperClassId on certain persistent handles. - * - * V8 takes ownership of RetainedObjectInfo instances passed to it and - * keeps them alive only during snapshot collection. Afterwards, they - * are freed by calling the Dispose class function. - */ -class V8_EXPORT RetainedObjectInfo { // NOLINT - public: - /** Called by V8 when it no longer needs an instance. */ - virtual void Dispose() = 0; - - /** Returns whether two instances are equivalent. */ - virtual bool IsEquivalent(RetainedObjectInfo* other) = 0; - - /** - * Returns hash value for the instance. Equivalent instances - * must have the same hash value. - */ - virtual intptr_t GetHash() = 0; - - /** - * Returns human-readable label. It must be a null-terminated UTF-8 - * encoded string. V8 copies its contents during a call to GetLabel. - */ - virtual const char* GetLabel() = 0; - - /** - * Returns human-readable group label. It must be a null-terminated UTF-8 - * encoded string. V8 copies its contents during a call to GetGroupLabel. - * Heap snapshot generator will collect all the group names, create - * top level entries with these names and attach the objects to the - * corresponding top level group objects. There is a default - * implementation which is required because embedders don't have their - * own implementation yet. - */ - virtual const char* GetGroupLabel() { return GetLabel(); } - - /** - * Returns element count in case if a global handle retains - * a subgraph by holding one of its nodes. - */ - virtual intptr_t GetElementCount() { return -1; } - - /** Returns embedder's object size in bytes. */ - virtual intptr_t GetSizeInBytes() { return -1; } - - protected: - RetainedObjectInfo() {} - virtual ~RetainedObjectInfo() {} - - private: - RetainedObjectInfo(const RetainedObjectInfo&); - RetainedObjectInfo& operator=(const RetainedObjectInfo&); -}; - - -/** - * A struct for exporting HeapStats data from V8, using "push" model. - * See HeapProfiler::GetHeapStats. - */ -struct HeapStatsUpdate { - HeapStatsUpdate(uint32_t index, uint32_t count, uint32_t size) - : index(index), count(count), size(size) { } - uint32_t index; // Index of the time interval that was changed. - uint32_t count; // New value of count field for the interval with this index. - uint32_t size; // New value of size field for the interval with this index. -}; - - -} // namespace v8 - - -#endif // V8_V8_PROFILER_H_ diff --git a/android/armeabi/include/v8/v8-testing.h b/android/armeabi/include/v8/v8-testing.h deleted file mode 100644 index f67bf253..00000000 --- a/android/armeabi/include/v8/v8-testing.h +++ /dev/null @@ -1,48 +0,0 @@ -// Copyright 2010 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_V8_TEST_H_ -#define V8_V8_TEST_H_ - -#include "v8.h" // NOLINT(build/include) - -/** - * Testing support for the V8 JavaScript engine. - */ -namespace v8 { - -class V8_EXPORT Testing { - public: - enum StressType { - kStressTypeOpt, - kStressTypeDeopt - }; - - /** - * Set the type of stressing to do. The default if not set is kStressTypeOpt. - */ - static void SetStressRunType(StressType type); - - /** - * Get the number of runs of a given test that is required to get the full - * stress coverage. - */ - static int GetStressRuns(); - - /** - * Indicate the number of the run which is about to start. The value of run - * should be between 0 and one less than the result from GetStressRuns() - */ - static void PrepareStressRun(int run); - - /** - * Force deoptimization of all functions. - */ - static void DeoptimizeAll(Isolate* isolate); -}; - - -} // namespace v8 - -#endif // V8_V8_TEST_H_ diff --git a/android/armeabi/include/v8/v8-util.h b/android/armeabi/include/v8/v8-util.h deleted file mode 100644 index a04a5e84..00000000 --- a/android/armeabi/include/v8/v8-util.h +++ /dev/null @@ -1,655 +0,0 @@ -// Copyright 2014 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_UTIL_H_ -#define V8_UTIL_H_ - -#include "v8.h" // NOLINT(build/include) -#include <assert.h> -#include <map> -#include <vector> - -/** - * Support for Persistent containers. - * - * C++11 embedders can use STL containers with Global values, - * but pre-C++11 does not support the required move semantic and hence - * may want these container classes. - */ -namespace v8 { - -typedef uintptr_t PersistentContainerValue; -static const uintptr_t kPersistentContainerNotFound = 0; -enum PersistentContainerCallbackType { - kNotWeak, - // These correspond to v8::WeakCallbackType - kWeakWithParameter, - kWeakWithInternalFields, - kWeak = kWeakWithParameter // For backwards compatibility. Deprecate. -}; - - -/** - * A default trait implemenation for PersistentValueMap which uses std::map - * as a backing map. - * - * Users will have to implement their own weak callbacks & dispose traits. - */ -template<typename K, typename V> -class StdMapTraits { - public: - // STL map & related: - typedef std::map<K, PersistentContainerValue> Impl; - typedef typename Impl::iterator Iterator; - - static bool Empty(Impl* impl) { return impl->empty(); } - static size_t Size(Impl* impl) { return impl->size(); } - static void Swap(Impl& a, Impl& b) { std::swap(a, b); } // NOLINT - static Iterator Begin(Impl* impl) { return impl->begin(); } - static Iterator End(Impl* impl) { return impl->end(); } - static K Key(Iterator it) { return it->first; } - static PersistentContainerValue Value(Iterator it) { return it->second; } - static PersistentContainerValue Set(Impl* impl, K key, - PersistentContainerValue value) { - std::pair<Iterator, bool> res = impl->insert(std::make_pair(key, value)); - PersistentContainerValue old_value = kPersistentContainerNotFound; - if (!res.second) { - old_value = res.first->second; - res.first->second = value; - } - return old_value; - } - static PersistentContainerValue Get(Impl* impl, K key) { - Iterator it = impl->find(key); - if (it == impl->end()) return kPersistentContainerNotFound; - return it->second; - } - static PersistentContainerValue Remove(Impl* impl, K key) { - Iterator it = impl->find(key); - if (it == impl->end()) return kPersistentContainerNotFound; - PersistentContainerValue value = it->second; - impl->erase(it); - return value; - } -}; - - -/** - * A default trait implementation for PersistentValueMap, which inherits - * a std:map backing map from StdMapTraits and holds non-weak persistent - * objects and has no special Dispose handling. - * - * You should not derive from this class, since MapType depends on the - * surrounding class, and hence a subclass cannot simply inherit the methods. - */ -template<typename K, typename V> -class DefaultPersistentValueMapTraits : public StdMapTraits<K, V> { - public: - // Weak callback & friends: - static const PersistentContainerCallbackType kCallbackType = kNotWeak; - typedef PersistentValueMap<K, V, DefaultPersistentValueMapTraits<K, V> > - MapType; - typedef void WeakCallbackDataType; - - static WeakCallbackDataType* WeakCallbackParameter( - MapType* map, const K& key, Local<V> value) { - return NULL; - } - static MapType* MapFromWeakCallbackInfo( - const WeakCallbackInfo<WeakCallbackDataType>& data) { - return NULL; - } - static K KeyFromWeakCallbackInfo( - const WeakCallbackInfo<WeakCallbackDataType>& data) { - return K(); - } - static void DisposeCallbackData(WeakCallbackDataType* data) { } - static void Dispose(Isolate* isolate, Global<V> value, K key) {} -}; - - -template <typename K, typename V> -class DefaultGlobalMapTraits : public StdMapTraits<K, V> { - private: - template <typename T> - struct RemovePointer; - - public: - // Weak callback & friends: - static const PersistentContainerCallbackType kCallbackType = kNotWeak; - typedef GlobalValueMap<K, V, DefaultGlobalMapTraits<K, V> > MapType; - typedef void WeakCallbackDataType; - - static WeakCallbackDataType* WeakCallbackParameter(MapType* map, const K& key, - Local<V> value) { - return nullptr; - } - static MapType* MapFromWeakCallbackInfo( - const WeakCallbackInfo<WeakCallbackDataType>& data) { - return nullptr; - } - static K KeyFromWeakCallbackInfo( - const WeakCallbackInfo<WeakCallbackDataType>& data) { - return K(); - } - static void DisposeCallbackData(WeakCallbackDataType* data) {} - static void OnWeakCallback( - const WeakCallbackInfo<WeakCallbackDataType>& data) {} - static void Dispose(Isolate* isolate, Global<V> value, K key) {} - // This is a second pass callback, so SetSecondPassCallback cannot be called. - static void DisposeWeak(const WeakCallbackInfo<WeakCallbackDataType>& data) {} - - private: - template <typename T> - struct RemovePointer<T*> { - typedef T Type; - }; -}; - - -/** - * A map wrapper that allows using Global as a mapped value. - * C++11 embedders don't need this class, as they can use Global - * directly in std containers. - * - * The map relies on a backing map, whose type and accessors are described - * by the Traits class. The backing map will handle values of type - * PersistentContainerValue, with all conversion into and out of V8 - * handles being transparently handled by this class. - */ -template <typename K, typename V, typename Traits> -class PersistentValueMapBase { - public: - Isolate* GetIsolate() { return isolate_; } - - /** - * Return size of the map. - */ - size_t Size() { return Traits::Size(&impl_); } - - /** - * Return whether the map holds weak persistents. - */ - bool IsWeak() { return Traits::kCallbackType != kNotWeak; } - - /** - * Get value stored in map. - */ - Local<V> Get(const K& key) { - return Local<V>::New(isolate_, FromVal(Traits::Get(&impl_, key))); - } - - /** - * Check whether a value is contained in the map. - */ - bool Contains(const K& key) { - return Traits::Get(&impl_, key) != kPersistentContainerNotFound; - } - - /** - * Get value stored in map and set it in returnValue. - * Return true if a value was found. - */ - bool SetReturnValue(const K& key, - ReturnValue<Value> returnValue) { - return SetReturnValueFromVal(&returnValue, Traits::Get(&impl_, key)); - } - - /** - * Call Isolate::SetReference with the given parent and the map value. - */ - void SetReference(const K& key, - const Persistent<Object>& parent) { - GetIsolate()->SetReference( - reinterpret_cast<internal::Object**>(parent.val_), - reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key)))); - } - - /** - * Call V8::RegisterExternallyReferencedObject with the map value for given - * key. - */ - void RegisterExternallyReferencedObject(K& key) { - assert(Contains(key)); - V8::RegisterExternallyReferencedObject( - reinterpret_cast<internal::Object**>(FromVal(Traits::Get(&impl_, key))), - reinterpret_cast<internal::Isolate*>(GetIsolate())); - } - - /** - * Return value for key and remove it from the map. - */ - Global<V> Remove(const K& key) { - return Release(Traits::Remove(&impl_, key)).Pass(); - } - - /** - * Traverses the map repeatedly, - * in case side effects of disposal cause insertions. - **/ - void Clear() { - typedef typename Traits::Iterator It; - HandleScope handle_scope(isolate_); - // TODO(dcarney): figure out if this swap and loop is necessary. - while (!Traits::Empty(&impl_)) { - typename Traits::Impl impl; - Traits::Swap(impl_, impl); - for (It i = Traits::Begin(&impl); i != Traits::End(&impl); ++i) { - Traits::Dispose(isolate_, Release(Traits::Value(i)).Pass(), - Traits::Key(i)); - } - } - } - - /** - * Helper class for GetReference/SetWithReference. Do not use outside - * that context. - */ - class PersistentValueReference { - public: - PersistentValueReference() : value_(kPersistentContainerNotFound) { } - PersistentValueReference(const PersistentValueReference& other) - : value_(other.value_) { } - - Local<V> NewLocal(Isolate* isolate) const { - return Local<V>::New(isolate, FromVal(value_)); - } - bool IsEmpty() const { - return value_ == kPersistentContainerNotFound; - } - template<typename T> - bool SetReturnValue(ReturnValue<T> returnValue) { - return SetReturnValueFromVal(&returnValue, value_); - } - void Reset() { - value_ = kPersistentContainerNotFound; - } - void operator=(const PersistentValueReference& other) { - value_ = other.value_; - } - - private: - friend class PersistentValueMapBase; - friend class PersistentValueMap<K, V, Traits>; - friend class GlobalValueMap<K, V, Traits>; - - explicit PersistentValueReference(PersistentContainerValue value) - : value_(value) { } - - void operator=(PersistentContainerValue value) { - value_ = value; - } - - PersistentContainerValue value_; - }; - - /** - * Get a reference to a map value. This enables fast, repeated access - * to a value stored in the map while the map remains unchanged. - * - * Careful: This is potentially unsafe, so please use with care. - * The value will become invalid if the value for this key changes - * in the underlying map, as a result of Set or Remove for the same - * key; as a result of the weak callback for the same key; or as a - * result of calling Clear() or destruction of the map. - */ - PersistentValueReference GetReference(const K& key) { - return PersistentValueReference(Traits::Get(&impl_, key)); - } - - protected: - explicit PersistentValueMapBase(Isolate* isolate) : isolate_(isolate) {} - - ~PersistentValueMapBase() { Clear(); } - - Isolate* isolate() { return isolate_; } - typename Traits::Impl* impl() { return &impl_; } - - static V* FromVal(PersistentContainerValue v) { - return reinterpret_cast<V*>(v); - } - - static PersistentContainerValue ClearAndLeak(Global<V>* persistent) { - V* v = persistent->val_; - persistent->val_ = 0; - return reinterpret_cast<PersistentContainerValue>(v); - } - - static PersistentContainerValue Leak(Global<V>* persistent) { - return reinterpret_cast<PersistentContainerValue>(persistent->val_); - } - - /** - * Return a container value as Global and make sure the weak - * callback is properly disposed of. All remove functionality should go - * through this. - */ - static Global<V> Release(PersistentContainerValue v) { - Global<V> p; - p.val_ = FromVal(v); - if (Traits::kCallbackType != kNotWeak && p.IsWeak()) { - Traits::DisposeCallbackData( - p.template ClearWeak<typename Traits::WeakCallbackDataType>()); - } - return p.Pass(); - } - - void RemoveWeak(const K& key) { - Global<V> p; - p.val_ = FromVal(Traits::Remove(&impl_, key)); - p.Reset(); - } - - private: - PersistentValueMapBase(PersistentValueMapBase&); - void operator=(PersistentValueMapBase&); - - static bool SetReturnValueFromVal(ReturnValue<Value>* returnValue, - PersistentContainerValue value) { - bool hasValue = value != kPersistentContainerNotFound; - if (hasValue) { - returnValue->SetInternal( - *reinterpret_cast<internal::Object**>(FromVal(value))); - } - return hasValue; - } - - Isolate* isolate_; - typename Traits::Impl impl_; -}; - - -template <typename K, typename V, typename Traits> -class PersistentValueMap : public PersistentValueMapBase<K, V, Traits> { - public: - explicit PersistentValueMap(Isolate* isolate) - : PersistentValueMapBase<K, V, Traits>(isolate) {} - - typedef - typename PersistentValueMapBase<K, V, Traits>::PersistentValueReference - PersistentValueReference; - - /** - * Put value into map. Depending on Traits::kIsWeak, the value will be held - * by the map strongly or weakly. - * Returns old value as Global. - */ - Global<V> Set(const K& key, Local<V> value) { - Global<V> persistent(this->isolate(), value); - return SetUnique(key, &persistent); - } - - /** - * Put value into map, like Set(const K&, Local<V>). - */ - Global<V> Set(const K& key, Global<V> value) { - return SetUnique(key, &value); - } - - /** - * Put the value into the map, and set the 'weak' callback when demanded - * by the Traits class. - */ - Global<V> SetUnique(const K& key, Global<V>* persistent) { - if (Traits::kCallbackType != kNotWeak) { - Local<V> value(Local<V>::New(this->isolate(), *persistent)); - persistent->template SetWeak<typename Traits::WeakCallbackDataType>( - Traits::WeakCallbackParameter(this, key, value), WeakCallback); - } - PersistentContainerValue old_value = - Traits::Set(this->impl(), key, this->ClearAndLeak(persistent)); - return this->Release(old_value).Pass(); - } - - /** - * Put a value into the map and update the reference. - * Restrictions of GetReference apply here as well. - */ - Global<V> Set(const K& key, Global<V> value, - PersistentValueReference* reference) { - *reference = this->Leak(&value); - return SetUnique(key, &value); - } - - private: - static void WeakCallback( - const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) { - if (Traits::kCallbackType != kNotWeak) { - PersistentValueMap<K, V, Traits>* persistentValueMap = - Traits::MapFromWeakCallbackInfo(data); - K key = Traits::KeyFromWeakCallbackInfo(data); - Traits::Dispose(data.GetIsolate(), - persistentValueMap->Remove(key).Pass(), key); - Traits::DisposeCallbackData(data.GetParameter()); - } - } -}; - - -template <typename K, typename V, typename Traits> -class GlobalValueMap : public PersistentValueMapBase<K, V, Traits> { - public: - explicit GlobalValueMap(Isolate* isolate) - : PersistentValueMapBase<K, V, Traits>(isolate) {} - - typedef - typename PersistentValueMapBase<K, V, Traits>::PersistentValueReference - PersistentValueReference; - - /** - * Put value into map. Depending on Traits::kIsWeak, the value will be held - * by the map strongly or weakly. - * Returns old value as Global. - */ - Global<V> Set(const K& key, Local<V> value) { - Global<V> persistent(this->isolate(), value); - return SetUnique(key, &persistent); - } - - /** - * Put value into map, like Set(const K&, Local<V>). - */ - Global<V> Set(const K& key, Global<V> value) { - return SetUnique(key, &value); - } - - /** - * Put the value into the map, and set the 'weak' callback when demanded - * by the Traits class. - */ - Global<V> SetUnique(const K& key, Global<V>* persistent) { - if (Traits::kCallbackType != kNotWeak) { - WeakCallbackType callback_type = - Traits::kCallbackType == kWeakWithInternalFields - ? WeakCallbackType::kInternalFields - : WeakCallbackType::kParameter; - Local<V> value(Local<V>::New(this->isolate(), *persistent)); - persistent->template SetWeak<typename Traits::WeakCallbackDataType>( - Traits::WeakCallbackParameter(this, key, value), OnWeakCallback, - callback_type); - } - PersistentContainerValue old_value = - Traits::Set(this->impl(), key, this->ClearAndLeak(persistent)); - return this->Release(old_value).Pass(); - } - - /** - * Put a value into the map and update the reference. - * Restrictions of GetReference apply here as well. - */ - Global<V> Set(const K& key, Global<V> value, - PersistentValueReference* reference) { - *reference = this->Leak(&value); - return SetUnique(key, &value); - } - - private: - static void OnWeakCallback( - const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) { - if (Traits::kCallbackType != kNotWeak) { - auto map = Traits::MapFromWeakCallbackInfo(data); - K key = Traits::KeyFromWeakCallbackInfo(data); - map->RemoveWeak(key); - Traits::OnWeakCallback(data); - data.SetSecondPassCallback(SecondWeakCallback); - } - } - - static void SecondWeakCallback( - const WeakCallbackInfo<typename Traits::WeakCallbackDataType>& data) { - Traits::DisposeWeak(data); - } -}; - - -/** - * A map that uses Global as value and std::map as the backing - * implementation. Persistents are held non-weak. - * - * C++11 embedders don't need this class, as they can use - * Global directly in std containers. - */ -template<typename K, typename V, - typename Traits = DefaultPersistentValueMapTraits<K, V> > -class StdPersistentValueMap : public PersistentValueMap<K, V, Traits> { - public: - explicit StdPersistentValueMap(Isolate* isolate) - : PersistentValueMap<K, V, Traits>(isolate) {} -}; - - -/** - * A map that uses Global as value and std::map as the backing - * implementation. Globals are held non-weak. - * - * C++11 embedders don't need this class, as they can use - * Global directly in std containers. - */ -template <typename K, typename V, - typename Traits = DefaultGlobalMapTraits<K, V> > -class StdGlobalValueMap : public GlobalValueMap<K, V, Traits> { - public: - explicit StdGlobalValueMap(Isolate* isolate) - : GlobalValueMap<K, V, Traits>(isolate) {} -}; - - -class DefaultPersistentValueVectorTraits { - public: - typedef std::vector<PersistentContainerValue> Impl; - - static void Append(Impl* impl, PersistentContainerValue value) { - impl->push_back(value); - } - static bool IsEmpty(const Impl* impl) { - return impl->empty(); - } - static size_t Size(const Impl* impl) { - return impl->size(); - } - static PersistentContainerValue Get(const Impl* impl, size_t i) { - return (i < impl->size()) ? impl->at(i) : kPersistentContainerNotFound; - } - static void ReserveCapacity(Impl* impl, size_t capacity) { - impl->reserve(capacity); - } - static void Clear(Impl* impl) { - impl->clear(); - } -}; - - -/** - * A vector wrapper that safely stores Global values. - * C++11 embedders don't need this class, as they can use Global - * directly in std containers. - * - * This class relies on a backing vector implementation, whose type and methods - * are described by the Traits class. The backing map will handle values of type - * PersistentContainerValue, with all conversion into and out of V8 - * handles being transparently handled by this class. - */ -template<typename V, typename Traits = DefaultPersistentValueVectorTraits> -class PersistentValueVector { - public: - explicit PersistentValueVector(Isolate* isolate) : isolate_(isolate) { } - - ~PersistentValueVector() { - Clear(); - } - - /** - * Append a value to the vector. - */ - void Append(Local<V> value) { - Global<V> persistent(isolate_, value); - Traits::Append(&impl_, ClearAndLeak(&persistent)); - } - - /** - * Append a persistent's value to the vector. - */ - void Append(Global<V> persistent) { - Traits::Append(&impl_, ClearAndLeak(&persistent)); - } - - /** - * Are there any values in the vector? - */ - bool IsEmpty() const { - return Traits::IsEmpty(&impl_); - } - - /** - * How many elements are in the vector? - */ - size_t Size() const { - return Traits::Size(&impl_); - } - - /** - * Retrieve the i-th value in the vector. - */ - Local<V> Get(size_t index) const { - return Local<V>::New(isolate_, FromVal(Traits::Get(&impl_, index))); - } - - /** - * Remove all elements from the vector. - */ - void Clear() { - size_t length = Traits::Size(&impl_); - for (size_t i = 0; i < length; i++) { - Global<V> p; - p.val_ = FromVal(Traits::Get(&impl_, i)); - } - Traits::Clear(&impl_); - } - - /** - * Reserve capacity in the vector. - * (Efficiency gains depend on the backing implementation.) - */ - void ReserveCapacity(size_t capacity) { - Traits::ReserveCapacity(&impl_, capacity); - } - - private: - static PersistentContainerValue ClearAndLeak(Global<V>* persistent) { - V* v = persistent->val_; - persistent->val_ = 0; - return reinterpret_cast<PersistentContainerValue>(v); - } - - static V* FromVal(PersistentContainerValue v) { - return reinterpret_cast<V*>(v); - } - - Isolate* isolate_; - typename Traits::Impl impl_; -}; - -} // namespace v8 - -#endif // V8_UTIL_H diff --git a/android/armeabi/include/v8/v8-value-serializer-version.h b/android/armeabi/include/v8/v8-value-serializer-version.h deleted file mode 100644 index c72911c6..00000000 --- a/android/armeabi/include/v8/v8-value-serializer-version.h +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** - * Compile-time constants. - * - * This header provides access to information about the value serializer at - * compile time, without declaring or defining any symbols that require linking - * to V8. - */ - -#ifndef INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_ -#define INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_ - -#include <stdint.h> - -namespace v8 { - -constexpr uint32_t CurrentValueSerializerFormatVersion() { return 13; } - -} // namespace v8 - -#endif // INCLUDE_V8_VALUE_SERIALIZER_VERSION_H_ diff --git a/android/armeabi/include/v8/v8-version-string.h b/android/armeabi/include/v8/v8-version-string.h deleted file mode 100644 index 075282de..00000000 --- a/android/armeabi/include/v8/v8-version-string.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright 2017 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_VERSION_STRING_H_ -#define V8_VERSION_STRING_H_ - -#include "v8-version.h" // NOLINT(build/include) - -// This is here rather than v8-version.h to keep that file simple and -// machine-processable. - -#if V8_IS_CANDIDATE_VERSION -#define V8_CANDIDATE_STRING " (candidate)" -#else -#define V8_CANDIDATE_STRING "" -#endif - -#define V8_SX(x) #x -#define V8_S(x) V8_SX(x) - -#if V8_PATCH_LEVEL > 0 -#define V8_VERSION_STRING \ - V8_S(V8_MAJOR_VERSION) \ - "." V8_S(V8_MINOR_VERSION) "." V8_S(V8_BUILD_NUMBER) "." V8_S( \ - V8_PATCH_LEVEL) V8_CANDIDATE_STRING -#else -#define V8_VERSION_STRING \ - V8_S(V8_MAJOR_VERSION) \ - "." V8_S(V8_MINOR_VERSION) "." V8_S(V8_BUILD_NUMBER) V8_CANDIDATE_STRING -#endif - -#endif // V8_VERSION_STRING_H_ diff --git a/android/armeabi/include/v8/v8-version.h b/android/armeabi/include/v8/v8-version.h deleted file mode 100644 index 0889459c..00000000 --- a/android/armeabi/include/v8/v8-version.h +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2015 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8_INCLUDE_VERSION_H_ // V8_VERSION_H_ conflicts with src/version.h -#define V8_INCLUDE_VERSION_H_ - -// These macros define the version number for the current version. -// NOTE these macros are used by some of the tool scripts and the build -// system so their names cannot be changed without changing the scripts. -#define V8_MAJOR_VERSION 6 -#define V8_MINOR_VERSION 0 -#define V8_BUILD_NUMBER 286 -#define V8_PATCH_LEVEL 52 - -// Use 1 for candidates and 0 otherwise. -// (Boolean macro values are not supported by all preprocessors.) -#define V8_IS_CANDIDATE_VERSION 0 - -#endif // V8_INCLUDE_VERSION_H_ diff --git a/android/armeabi/include/v8/v8.h b/android/armeabi/include/v8/v8.h deleted file mode 100644 index da3cdfdc..00000000 --- a/android/armeabi/include/v8/v8.h +++ /dev/null @@ -1,10155 +0,0 @@ -// Copyright 2012 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -/** \mainpage V8 API Reference Guide - * - * V8 is Google's open source JavaScript engine. - * - * This set of documents provides reference material generated from the - * V8 header file, include/v8.h. - * - * For other documentation see http://code.google.com/apis/v8/ - */ - -#ifndef INCLUDE_V8_H_ -#define INCLUDE_V8_H_ - -#include <stddef.h> -#include <stdint.h> -#include <stdio.h> -#include <memory> -#include <utility> -#include <vector> - -#include "v8-version.h" // NOLINT(build/include) -#include "v8config.h" // NOLINT(build/include) - -// We reserve the V8_* prefix for macros defined in V8 public API and -// assume there are no name conflicts with the embedder's code. - -#ifdef V8_OS_WIN - -// Setup for Windows DLL export/import. When building the V8 DLL the -// BUILDING_V8_SHARED needs to be defined. When building a program which uses -// the V8 DLL USING_V8_SHARED needs to be defined. When either building the V8 -// static library or building a program which uses the V8 static library neither -// BUILDING_V8_SHARED nor USING_V8_SHARED should be defined. -#ifdef BUILDING_V8_SHARED -# define V8_EXPORT __declspec(dllexport) -#elif USING_V8_SHARED -# define V8_EXPORT __declspec(dllimport) -#else -# define V8_EXPORT -#endif // BUILDING_V8_SHARED - -#else // V8_OS_WIN - -// Setup for Linux shared library export. -#if V8_HAS_ATTRIBUTE_VISIBILITY -# ifdef BUILDING_V8_SHARED -# define V8_EXPORT __attribute__ ((visibility("default"))) -# else -# define V8_EXPORT -# endif -#else -# define V8_EXPORT -#endif - -#endif // V8_OS_WIN - -/** - * The v8 JavaScript engine. - */ -namespace v8 { - -class AccessorSignature; -class Array; -class ArrayBuffer; -class Boolean; -class BooleanObject; -class Context; -class CpuProfiler; -class Data; -class Date; -class External; -class Function; -class FunctionTemplate; -class HeapProfiler; -class ImplementationUtilities; -class Int32; -class Integer; -class Isolate; -template <class T> -class Maybe; -class Name; -class Number; -class NumberObject; -class Object; -class ObjectOperationDescriptor; -class ObjectTemplate; -class Platform; -class Primitive; -class Promise; -class PropertyDescriptor; -class Proxy; -class RawOperationDescriptor; -class Script; -class SharedArrayBuffer; -class Signature; -class StartupData; -class StackFrame; -class StackTrace; -class String; -class StringObject; -class Symbol; -class SymbolObject; -class Private; -class Uint32; -class Utils; -class Value; -class WasmCompiledModule; -template <class T> class Local; -template <class T> -class MaybeLocal; -template <class T> class Eternal; -template<class T> class NonCopyablePersistentTraits; -template<class T> class PersistentBase; -template <class T, class M = NonCopyablePersistentTraits<T> > -class Persistent; -template <class T> -class Global; -template<class K, class V, class T> class PersistentValueMap; -template <class K, class V, class T> -class PersistentValueMapBase; -template <class K, class V, class T> -class GlobalValueMap; -template<class V, class T> class PersistentValueVector; -template<class T, class P> class WeakCallbackObject; -class FunctionTemplate; -class ObjectTemplate; -template<typename T> class FunctionCallbackInfo; -template<typename T> class PropertyCallbackInfo; -class StackTrace; -class StackFrame; -class Isolate; -class CallHandlerHelper; -class EscapableHandleScope; -template<typename T> class ReturnValue; - -namespace internal { -class Arguments; -class Heap; -class HeapObject; -class Isolate; -class Object; -struct StreamedSource; -template<typename T> class CustomArguments; -class PropertyCallbackArguments; -class FunctionCallbackArguments; -class GlobalHandles; -} // namespace internal - -namespace debug { -class ConsoleCallArguments; -} // namespace debug - -// --- Handles --- - -#define TYPE_CHECK(T, S) \ - while (false) { \ - *(static_cast<T* volatile*>(0)) = static_cast<S*>(0); \ - } - -/** - * An object reference managed by the v8 garbage collector. - * - * All objects returned from v8 have to be tracked by the garbage - * collector so that it knows that the objects are still alive. Also, - * because the garbage collector may move objects, it is unsafe to - * point directly to an object. Instead, all objects are stored in - * handles which are known by the garbage collector and updated - * whenever an object moves. Handles should always be passed by value - * (except in cases like out-parameters) and they should never be - * allocated on the heap. - * - * There are two types of handles: local and persistent handles. - * - * Local handles are light-weight and transient and typically used in - * local operations. They are managed by HandleScopes. That means that a - * HandleScope must exist on the stack when they are created and that they are - * only valid inside of the HandleScope active during their creation. - * For passing a local handle to an outer HandleScope, an EscapableHandleScope - * and its Escape() method must be used. - * - * Persistent handles can be used when storing objects across several - * independent operations and have to be explicitly deallocated when they're no - * longer used. - * - * It is safe to extract the object stored in the handle by - * dereferencing the handle (for instance, to extract the Object* from - * a Local<Object>); the value will still be governed by a handle - * behind the scenes and the same rules apply to these values as to - * their handles. - */ -template <class T> -class Local { - public: - V8_INLINE Local() : val_(0) {} - template <class S> - V8_INLINE Local(Local<S> that) - : val_(reinterpret_cast<T*>(*that)) { - /** - * This check fails when trying to convert between incompatible - * handles. For example, converting from a Local<String> to a - * Local<Number>. - */ - TYPE_CHECK(T, S); - } - - /** - * Returns true if the handle is empty. - */ - V8_INLINE bool IsEmpty() const { return val_ == 0; } - - /** - * Sets the handle to be empty. IsEmpty() will then return true. - */ - V8_INLINE void Clear() { val_ = 0; } - - V8_INLINE T* operator->() const { return val_; } - - V8_INLINE T* operator*() const { return val_; } - - /** - * Checks whether two handles are the same. - * Returns true if both are empty, or if the objects - * to which they refer are identical. - * The handles' references are not checked. - */ - template <class S> - V8_INLINE bool operator==(const Local<S>& that) const { - internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); - internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); - if (a == 0) return b == 0; - if (b == 0) return false; - return *a == *b; - } - - template <class S> V8_INLINE bool operator==( - const PersistentBase<S>& that) const { - internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); - internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); - if (a == 0) return b == 0; - if (b == 0) return false; - return *a == *b; - } - - /** - * Checks whether two handles are different. - * Returns true if only one of the handles is empty, or if - * the objects to which they refer are different. - * The handles' references are not checked. - */ - template <class S> - V8_INLINE bool operator!=(const Local<S>& that) const { - return !operator==(that); - } - - template <class S> V8_INLINE bool operator!=( - const Persistent<S>& that) const { - return !operator==(that); - } - - /** - * Cast a handle to a subclass, e.g. Local<Value> to Local<Object>. - * This is only valid if the handle actually refers to a value of the - * target type. - */ - template <class S> V8_INLINE static Local<T> Cast(Local<S> that) { -#ifdef V8_ENABLE_CHECKS - // If we're going to perform the type check then we have to check - // that the handle isn't empty before doing the checked cast. - if (that.IsEmpty()) return Local<T>(); -#endif - return Local<T>(T::Cast(*that)); - } - - /** - * Calling this is equivalent to Local<S>::Cast(). - * In particular, this is only valid if the handle actually refers to a value - * of the target type. - */ - template <class S> - V8_INLINE Local<S> As() const { - return Local<S>::Cast(*this); - } - - /** - * Create a local handle for the content of another handle. - * The referee is kept alive by the local handle even when - * the original handle is destroyed/disposed. - */ - V8_INLINE static Local<T> New(Isolate* isolate, Local<T> that); - V8_INLINE static Local<T> New(Isolate* isolate, - const PersistentBase<T>& that); - - private: - friend class Utils; - template<class F> friend class Eternal; - template<class F> friend class PersistentBase; - template<class F, class M> friend class Persistent; - template<class F> friend class Local; - template <class F> - friend class MaybeLocal; - template<class F> friend class FunctionCallbackInfo; - template<class F> friend class PropertyCallbackInfo; - friend class String; - friend class Object; - friend class Context; - friend class Private; - template<class F> friend class internal::CustomArguments; - friend Local<Primitive> Undefined(Isolate* isolate); - friend Local<Primitive> Null(Isolate* isolate); - friend Local<Boolean> True(Isolate* isolate); - friend Local<Boolean> False(Isolate* isolate); - friend class HandleScope; - friend class EscapableHandleScope; - template <class F1, class F2, class F3> - friend class PersistentValueMapBase; - template<class F1, class F2> friend class PersistentValueVector; - template <class F> - friend class ReturnValue; - - explicit V8_INLINE Local(T* that) : val_(that) {} - V8_INLINE static Local<T> New(Isolate* isolate, T* that); - T* val_; -}; - - -#if !defined(V8_IMMINENT_DEPRECATION_WARNINGS) -// Handle is an alias for Local for historical reasons. -template <class T> -using Handle = Local<T>; -#endif - - -/** - * A MaybeLocal<> is a wrapper around Local<> that enforces a check whether - * the Local<> is empty before it can be used. - * - * If an API method returns a MaybeLocal<>, the API method can potentially fail - * either because an exception is thrown, or because an exception is pending, - * e.g. because a previous API call threw an exception that hasn't been caught - * yet, or because a TerminateExecution exception was thrown. In that case, an - * empty MaybeLocal is returned. - */ -template <class T> -class MaybeLocal { - public: - V8_INLINE MaybeLocal() : val_(nullptr) {} - template <class S> - V8_INLINE MaybeLocal(Local<S> that) - : val_(reinterpret_cast<T*>(*that)) { - TYPE_CHECK(T, S); - } - - V8_INLINE bool IsEmpty() const { return val_ == nullptr; } - - /** - * Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty, - * |false| is returned and |out| is left untouched. - */ - template <class S> - V8_WARN_UNUSED_RESULT V8_INLINE bool ToLocal(Local<S>* out) const { - out->val_ = IsEmpty() ? nullptr : this->val_; - return !IsEmpty(); - } - - /** - * Converts this MaybeLocal<> to a Local<>. If this MaybeLocal<> is empty, - * V8 will crash the process. - */ - V8_INLINE Local<T> ToLocalChecked(); - - /** - * Converts this MaybeLocal<> to a Local<>, using a default value if this - * MaybeLocal<> is empty. - */ - template <class S> - V8_INLINE Local<S> FromMaybe(Local<S> default_value) const { - return IsEmpty() ? default_value : Local<S>(val_); - } - - private: - T* val_; -}; - -/** - * Eternal handles are set-once handles that live for the lifetime of the - * isolate. - */ -template <class T> class Eternal { - public: - V8_INLINE Eternal() : val_(nullptr) {} - template <class S> - V8_INLINE Eternal(Isolate* isolate, Local<S> handle) : val_(nullptr) { - Set(isolate, handle); - } - // Can only be safely called if already set. - V8_INLINE Local<T> Get(Isolate* isolate) const; - V8_INLINE bool IsEmpty() const { return val_ == nullptr; } - template<class S> V8_INLINE void Set(Isolate* isolate, Local<S> handle); - - private: - T* val_; -}; - - -static const int kInternalFieldsInWeakCallback = 2; -static const int kEmbedderFieldsInWeakCallback = 2; - -template <typename T> -class WeakCallbackInfo { - public: - typedef void (*Callback)(const WeakCallbackInfo<T>& data); - - WeakCallbackInfo(Isolate* isolate, T* parameter, - void* embedder_fields[kEmbedderFieldsInWeakCallback], - Callback* callback) - : isolate_(isolate), parameter_(parameter), callback_(callback) { - for (int i = 0; i < kEmbedderFieldsInWeakCallback; ++i) { - embedder_fields_[i] = embedder_fields[i]; - } - } - - V8_INLINE Isolate* GetIsolate() const { return isolate_; } - V8_INLINE T* GetParameter() const { return parameter_; } - V8_INLINE void* GetInternalField(int index) const; - - V8_INLINE V8_DEPRECATED("use indexed version", - void* GetInternalField1() const) { - return embedder_fields_[0]; - } - V8_INLINE V8_DEPRECATED("use indexed version", - void* GetInternalField2() const) { - return embedder_fields_[1]; - } - - V8_DEPRECATED("Not realiable once SetSecondPassCallback() was used.", - bool IsFirstPass() const) { - return callback_ != nullptr; - } - - // When first called, the embedder MUST Reset() the Global which triggered the - // callback. The Global itself is unusable for anything else. No v8 other api - // calls may be called in the first callback. Should additional work be - // required, the embedder must set a second pass callback, which will be - // called after all the initial callbacks are processed. - // Calling SetSecondPassCallback on the second pass will immediately crash. - void SetSecondPassCallback(Callback callback) const { *callback_ = callback; } - - private: - Isolate* isolate_; - T* parameter_; - Callback* callback_; - void* embedder_fields_[kEmbedderFieldsInWeakCallback]; -}; - - -// kParameter will pass a void* parameter back to the callback, kInternalFields -// will pass the first two internal fields back to the callback, kFinalizer -// will pass a void* parameter back, but is invoked before the object is -// actually collected, so it can be resurrected. In the last case, it is not -// possible to request a second pass callback. -enum class WeakCallbackType { kParameter, kInternalFields, kFinalizer }; - -/** - * An object reference that is independent of any handle scope. Where - * a Local handle only lives as long as the HandleScope in which it was - * allocated, a PersistentBase handle remains valid until it is explicitly - * disposed using Reset(). - * - * A persistent handle contains a reference to a storage cell within - * the V8 engine which holds an object value and which is updated by - * the garbage collector whenever the object is moved. A new storage - * cell can be created using the constructor or PersistentBase::Reset and - * existing handles can be disposed using PersistentBase::Reset. - * - */ -template <class T> class PersistentBase { - public: - /** - * If non-empty, destroy the underlying storage cell - * IsEmpty() will return true after this call. - */ - V8_INLINE void Reset(); - /** - * If non-empty, destroy the underlying storage cell - * and create a new one with the contents of other if other is non empty - */ - template <class S> - V8_INLINE void Reset(Isolate* isolate, const Local<S>& other); - - /** - * If non-empty, destroy the underlying storage cell - * and create a new one with the contents of other if other is non empty - */ - template <class S> - V8_INLINE void Reset(Isolate* isolate, const PersistentBase<S>& other); - - V8_INLINE bool IsEmpty() const { return val_ == NULL; } - V8_INLINE void Empty() { val_ = 0; } - - V8_INLINE Local<T> Get(Isolate* isolate) const { - return Local<T>::New(isolate, *this); - } - - template <class S> - V8_INLINE bool operator==(const PersistentBase<S>& that) const { - internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); - internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); - if (a == NULL) return b == NULL; - if (b == NULL) return false; - return *a == *b; - } - - template <class S> - V8_INLINE bool operator==(const Local<S>& that) const { - internal::Object** a = reinterpret_cast<internal::Object**>(this->val_); - internal::Object** b = reinterpret_cast<internal::Object**>(that.val_); - if (a == NULL) return b == NULL; - if (b == NULL) return false; - return *a == *b; - } - - template <class S> - V8_INLINE bool operator!=(const PersistentBase<S>& that) const { - return !operator==(that); - } - - template <class S> - V8_INLINE bool operator!=(const Local<S>& that) const { - return !operator==(that); - } - - /** - * Install a finalization callback on this object. - * NOTE: There is no guarantee as to *when* or even *if* the callback is - * invoked. The invocation is performed solely on a best effort basis. - * As always, GC-based finalization should *not* be relied upon for any - * critical form of resource management! - */ - template <typename P> - V8_INLINE void SetWeak(P* parameter, - typename WeakCallbackInfo<P>::Callback callback, - WeakCallbackType type); - - /** - * Turns this handle into a weak phantom handle without finalization callback. - * The handle will be reset automatically when the garbage collector detects - * that the object is no longer reachable. - * A related function Isolate::NumberOfPhantomHandleResetsSinceLastCall - * returns how many phantom handles were reset by the garbage collector. - */ - V8_INLINE void SetWeak(); - - template<typename P> - V8_INLINE P* ClearWeak(); - - // TODO(dcarney): remove this. - V8_INLINE void ClearWeak() { ClearWeak<void>(); } - - /** - * Allows the embedder to tell the v8 garbage collector that a certain object - * is alive. Only allowed when the embedder is asked to trace its heap by - * EmbedderHeapTracer. - */ - V8_INLINE void RegisterExternalReference(Isolate* isolate) const; - - /** - * Marks the reference to this object independent. Garbage collector is free - * to ignore any object groups containing this object. Weak callback for an - * independent handle should not assume that it will be preceded by a global - * GC prologue callback or followed by a global GC epilogue callback. - */ - V8_INLINE void MarkIndependent(); - - /** - * Marks the reference to this object as active. The scavenge garbage - * collection should not reclaim the objects marked as active. - * This bit is cleared after the each garbage collection pass. - */ - V8_INLINE void MarkActive(); - - V8_INLINE bool IsIndependent() const; - - /** Checks if the handle holds the only reference to an object. */ - V8_INLINE bool IsNearDeath() const; - - /** Returns true if the handle's reference is weak. */ - V8_INLINE bool IsWeak() const; - - /** - * Assigns a wrapper class ID to the handle. See RetainedObjectInfo interface - * description in v8-profiler.h for details. - */ - V8_INLINE void SetWrapperClassId(uint16_t class_id); - - /** - * Returns the class ID previously assigned to this handle or 0 if no class ID - * was previously assigned. - */ - V8_INLINE uint16_t WrapperClassId() const; - - PersistentBase(const PersistentBase& other) = delete; // NOLINT - void operator=(const PersistentBase&) = delete; - - private: - friend class Isolate; - friend class Utils; - template<class F> friend class Local; - template<class F1, class F2> friend class Persistent; - template <class F> - friend class Global; - template<class F> friend class PersistentBase; - template<class F> friend class ReturnValue; - template <class F1, class F2, class F3> - friend class PersistentValueMapBase; - template<class F1, class F2> friend class PersistentValueVector; - friend class Object; - - explicit V8_INLINE PersistentBase(T* val) : val_(val) {} - V8_INLINE static T* New(Isolate* isolate, T* that); - - T* val_; -}; - - -/** - * Default traits for Persistent. This class does not allow - * use of the copy constructor or assignment operator. - * At present kResetInDestructor is not set, but that will change in a future - * version. - */ -template<class T> -class NonCopyablePersistentTraits { - public: - typedef Persistent<T, NonCopyablePersistentTraits<T> > NonCopyablePersistent; - static const bool kResetInDestructor = false; - template<class S, class M> - V8_INLINE static void Copy(const Persistent<S, M>& source, - NonCopyablePersistent* dest) { - Uncompilable<Object>(); - } - // TODO(dcarney): come up with a good compile error here. - template<class O> V8_INLINE static void Uncompilable() { - TYPE_CHECK(O, Primitive); - } -}; - - -/** - * Helper class traits to allow copying and assignment of Persistent. - * This will clone the contents of storage cell, but not any of the flags, etc. - */ -template<class T> -struct CopyablePersistentTraits { - typedef Persistent<T, CopyablePersistentTraits<T> > CopyablePersistent; - static const bool kResetInDestructor = true; - template<class S, class M> - static V8_INLINE void Copy(const Persistent<S, M>& source, - CopyablePersistent* dest) { - // do nothing, just allow copy - } -}; - - -/** - * A PersistentBase which allows copy and assignment. - * - * Copy, assignment and destructor behavior is controlled by the traits - * class M. - * - * Note: Persistent class hierarchy is subject to future changes. - */ -template <class T, class M> class Persistent : public PersistentBase<T> { - public: - /** - * A Persistent with no storage cell. - */ - V8_INLINE Persistent() : PersistentBase<T>(0) { } - /** - * Construct a Persistent from a Local. - * When the Local is non-empty, a new storage cell is created - * pointing to the same object, and no flags are set. - */ - template <class S> - V8_INLINE Persistent(Isolate* isolate, Local<S> that) - : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) { - TYPE_CHECK(T, S); - } - /** - * Construct a Persistent from a Persistent. - * When the Persistent is non-empty, a new storage cell is created - * pointing to the same object, and no flags are set. - */ - template <class S, class M2> - V8_INLINE Persistent(Isolate* isolate, const Persistent<S, M2>& that) - : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) { - TYPE_CHECK(T, S); - } - /** - * The copy constructors and assignment operator create a Persistent - * exactly as the Persistent constructor, but the Copy function from the - * traits class is called, allowing the setting of flags based on the - * copied Persistent. - */ - V8_INLINE Persistent(const Persistent& that) : PersistentBase<T>(0) { - Copy(that); - } - template <class S, class M2> - V8_INLINE Persistent(const Persistent<S, M2>& that) : PersistentBase<T>(0) { - Copy(that); - } - V8_INLINE Persistent& operator=(const Persistent& that) { // NOLINT - Copy(that); - return *this; - } - template <class S, class M2> - V8_INLINE Persistent& operator=(const Persistent<S, M2>& that) { // NOLINT - Copy(that); - return *this; - } - /** - * The destructor will dispose the Persistent based on the - * kResetInDestructor flags in the traits class. Since not calling dispose - * can result in a memory leak, it is recommended to always set this flag. - */ - V8_INLINE ~Persistent() { - if (M::kResetInDestructor) this->Reset(); - } - - // TODO(dcarney): this is pretty useless, fix or remove - template <class S> - V8_INLINE static Persistent<T>& Cast(const Persistent<S>& that) { // NOLINT -#ifdef V8_ENABLE_CHECKS - // If we're going to perform the type check then we have to check - // that the handle isn't empty before doing the checked cast. - if (!that.IsEmpty()) T::Cast(*that); -#endif - return reinterpret_cast<Persistent<T>&>(const_cast<Persistent<S>&>(that)); - } - - // TODO(dcarney): this is pretty useless, fix or remove - template <class S> - V8_INLINE Persistent<S>& As() const { // NOLINT - return Persistent<S>::Cast(*this); - } - - private: - friend class Isolate; - friend class Utils; - template<class F> friend class Local; - template<class F1, class F2> friend class Persistent; - template<class F> friend class ReturnValue; - - explicit V8_INLINE Persistent(T* that) : PersistentBase<T>(that) {} - V8_INLINE T* operator*() const { return this->val_; } - template<class S, class M2> - V8_INLINE void Copy(const Persistent<S, M2>& that); -}; - - -/** - * A PersistentBase which has move semantics. - * - * Note: Persistent class hierarchy is subject to future changes. - */ -template <class T> -class Global : public PersistentBase<T> { - public: - /** - * A Global with no storage cell. - */ - V8_INLINE Global() : PersistentBase<T>(nullptr) {} - /** - * Construct a Global from a Local. - * When the Local is non-empty, a new storage cell is created - * pointing to the same object, and no flags are set. - */ - template <class S> - V8_INLINE Global(Isolate* isolate, Local<S> that) - : PersistentBase<T>(PersistentBase<T>::New(isolate, *that)) { - TYPE_CHECK(T, S); - } - /** - * Construct a Global from a PersistentBase. - * When the Persistent is non-empty, a new storage cell is created - * pointing to the same object, and no flags are set. - */ - template <class S> - V8_INLINE Global(Isolate* isolate, const PersistentBase<S>& that) - : PersistentBase<T>(PersistentBase<T>::New(isolate, that.val_)) { - TYPE_CHECK(T, S); - } - /** - * Move constructor. - */ - V8_INLINE Global(Global&& other) : PersistentBase<T>(other.val_) { // NOLINT - other.val_ = nullptr; - } - V8_INLINE ~Global() { this->Reset(); } - /** - * Move via assignment. - */ - template <class S> - V8_INLINE Global& operator=(Global<S>&& rhs) { // NOLINT - TYPE_CHECK(T, S); - if (this != &rhs) { - this->Reset(); - this->val_ = rhs.val_; - rhs.val_ = nullptr; - } - return *this; - } - /** - * Pass allows returning uniques from functions, etc. - */ - Global Pass() { return static_cast<Global&&>(*this); } // NOLINT - - /* - * For compatibility with Chromium's base::Bind (base::Passed). - */ - typedef void MoveOnlyTypeForCPP03; - - Global(const Global&) = delete; - void operator=(const Global&) = delete; - - private: - template <class F> - friend class ReturnValue; - V8_INLINE T* operator*() const { return this->val_; } -}; - - -// UniquePersistent is an alias for Global for historical reason. -template <class T> -using UniquePersistent = Global<T>; - - - /** - * A stack-allocated class that governs a number of local handles. - * After a handle scope has been created, all local handles will be - * allocated within that handle scope until either the handle scope is - * deleted or another handle scope is created. If there is already a - * handle scope and a new one is created, all allocations will take - * place in the new handle scope until it is deleted. After that, - * new handles will again be allocated in the original handle scope. - * - * After the handle scope of a local handle has been deleted the - * garbage collector will no longer track the object stored in the - * handle and may deallocate it. The behavior of accessing a handle - * for which the handle scope has been deleted is undefined. - */ -class V8_EXPORT HandleScope { - public: - explicit HandleScope(Isolate* isolate); - - ~HandleScope(); - - /** - * Counts the number of allocated handles. - */ - static int NumberOfHandles(Isolate* isolate); - - V8_INLINE Isolate* GetIsolate() const { - return reinterpret_cast<Isolate*>(isolate_); - } - - HandleScope(const HandleScope&) = delete; - void operator=(const HandleScope&) = delete; - void* operator new(size_t size); - void operator delete(void*, size_t); - - protected: - V8_INLINE HandleScope() {} - - void Initialize(Isolate* isolate); - - static internal::Object** CreateHandle(internal::Isolate* isolate, - internal::Object* value); - - private: - // Uses heap_object to obtain the current Isolate. - static internal::Object** CreateHandle(internal::HeapObject* heap_object, - internal::Object* value); - - internal::Isolate* isolate_; - internal::Object** prev_next_; - internal::Object** prev_limit_; - - // Local::New uses CreateHandle with an Isolate* parameter. - template<class F> friend class Local; - - // Object::GetInternalField and Context::GetEmbedderData use CreateHandle with - // a HeapObject* in their shortcuts. - friend class Object; - friend class Context; -}; - - -/** - * A HandleScope which first allocates a handle in the current scope - * which will be later filled with the escape value. - */ -class V8_EXPORT EscapableHandleScope : public HandleScope { - public: - explicit EscapableHandleScope(Isolate* isolate); - V8_INLINE ~EscapableHandleScope() {} - - /** - * Pushes the value into the previous scope and returns a handle to it. - * Cannot be called twice. - */ - template <class T> - V8_INLINE Local<T> Escape(Local<T> value) { - internal::Object** slot = - Escape(reinterpret_cast<internal::Object**>(*value)); - return Local<T>(reinterpret_cast<T*>(slot)); - } - - EscapableHandleScope(const EscapableHandleScope&) = delete; - void operator=(const EscapableHandleScope&) = delete; - void* operator new(size_t size); - void operator delete(void*, size_t); - - private: - internal::Object** Escape(internal::Object** escape_value); - internal::Object** escape_slot_; -}; - -/** - * A SealHandleScope acts like a handle scope in which no handle allocations - * are allowed. It can be useful for debugging handle leaks. - * Handles can be allocated within inner normal HandleScopes. - */ -class V8_EXPORT SealHandleScope { - public: - SealHandleScope(Isolate* isolate); - ~SealHandleScope(); - - SealHandleScope(const SealHandleScope&) = delete; - void operator=(const SealHandleScope&) = delete; - void* operator new(size_t size); - void operator delete(void*, size_t); - - private: - internal::Isolate* const isolate_; - internal::Object** prev_limit_; - int prev_sealed_level_; -}; - - -// --- Special objects --- - - -/** - * The superclass of values and API object templates. - */ -class V8_EXPORT Data { - private: - Data(); -}; - - -/** - * The optional attributes of ScriptOrigin. - */ -class ScriptOriginOptions { - public: - V8_INLINE ScriptOriginOptions(bool is_shared_cross_origin = false, - bool is_opaque = false, bool is_wasm = false, - bool is_module = false) - : flags_((is_shared_cross_origin ? kIsSharedCrossOrigin : 0) | - (is_wasm ? kIsWasm : 0) | (is_opaque ? kIsOpaque : 0) | - (is_module ? kIsModule : 0)) {} - V8_INLINE ScriptOriginOptions(int flags) - : flags_(flags & - (kIsSharedCrossOrigin | kIsOpaque | kIsWasm | kIsModule)) {} - - bool IsSharedCrossOrigin() const { - return (flags_ & kIsSharedCrossOrigin) != 0; - } - bool IsOpaque() const { return (flags_ & kIsOpaque) != 0; } - bool IsWasm() const { return (flags_ & kIsWasm) != 0; } - bool IsModule() const { return (flags_ & kIsModule) != 0; } - - int Flags() const { return flags_; } - - private: - enum { - kIsSharedCrossOrigin = 1, - kIsOpaque = 1 << 1, - kIsWasm = 1 << 2, - kIsModule = 1 << 3 - }; - const int flags_; -}; - -/** - * The origin, within a file, of a script. - */ -class ScriptOrigin { - public: - V8_INLINE ScriptOrigin( - Local<Value> resource_name, - Local<Integer> resource_line_offset = Local<Integer>(), - Local<Integer> resource_column_offset = Local<Integer>(), - Local<Boolean> resource_is_shared_cross_origin = Local<Boolean>(), - Local<Integer> script_id = Local<Integer>(), - Local<Value> source_map_url = Local<Value>(), - Local<Boolean> resource_is_opaque = Local<Boolean>(), - Local<Boolean> is_wasm = Local<Boolean>(), - Local<Boolean> is_module = Local<Boolean>()); - - V8_INLINE Local<Value> ResourceName() const; - V8_INLINE Local<Integer> ResourceLineOffset() const; - V8_INLINE Local<Integer> ResourceColumnOffset() const; - /** - * Returns true for embedder's debugger scripts - */ - V8_INLINE Local<Integer> ScriptID() const; - V8_INLINE Local<Value> SourceMapUrl() const; - V8_INLINE ScriptOriginOptions Options() const { return options_; } - - private: - Local<Value> resource_name_; - Local<Integer> resource_line_offset_; - Local<Integer> resource_column_offset_; - ScriptOriginOptions options_; - Local<Integer> script_id_; - Local<Value> source_map_url_; -}; - - -/** - * A compiled JavaScript script, not yet tied to a Context. - */ -class V8_EXPORT UnboundScript { - public: - /** - * Binds the script to the currently entered context. - */ - Local<Script> BindToCurrentContext(); - - int GetId(); - Local<Value> GetScriptName(); - - /** - * Data read from magic sourceURL comments. - */ - Local<Value> GetSourceURL(); - /** - * Data read from magic sourceMappingURL comments. - */ - Local<Value> GetSourceMappingURL(); - - /** - * Returns zero based line number of the code_pos location in the script. - * -1 will be returned if no information available. - */ - int GetLineNumber(int code_pos); - - static const int kNoScriptId = 0; -}; - -/** - * This is an unfinished experimental feature, and is only exposed - * here for internal testing purposes. DO NOT USE. - * - * A compiled JavaScript module. - */ -class V8_EXPORT Module { - public: - /** - * Returns the number of modules requested by this module. - */ - int GetModuleRequestsLength() const; - - /** - * Returns the ith module specifier in this module. - * i must be < GetModuleRequestsLength() and >= 0. - */ - Local<String> GetModuleRequest(int i) const; - - /** - * Returns the identity hash for this object. - */ - int GetIdentityHash() const; - - typedef MaybeLocal<Module> (*ResolveCallback)(Local<Context> context, - Local<String> specifier, - Local<Module> referrer); - - /** - * ModuleDeclarationInstantiation - * - * Returns false if an exception occurred during instantiation. (In the case - * where the callback throws an exception, that exception is propagated.) - */ - V8_WARN_UNUSED_RESULT bool Instantiate(Local<Context> context, - ResolveCallback callback); - - /** - * ModuleEvaluation - * - * Returns the completion value. - */ - V8_WARN_UNUSED_RESULT MaybeLocal<Value> Evaluate(Local<Context> context); -}; - -/** - * This is an unfinished experimental feature, and is only exposed - * here for internal testing purposes. DO NOT USE. - * - * A compiled JavaScript module. - */ -class V8_EXPORT DynamicImportResult { - public: - /** - * Resolves the promise with the namespace object of the given - * module. - */ - V8_WARN_UNUSED_RESULT bool FinishDynamicImportSuccess(Local<Context> context, - Local<Module> module); - - /** - * Rejects the promise with the given exception. - */ - V8_WARN_UNUSED_RESULT bool FinishDynamicImportFailure(Local<Context> context, - Local<Value> exception); -}; - -/** - * A compiled JavaScript script, tied to a Context which was active when the - * script was compiled. - */ -class V8_EXPORT Script { - public: - /** - * A shorthand for ScriptCompiler::Compile(). - */ - static V8_DEPRECATE_SOON( - "Use maybe version", - Local<Script> Compile(Local<String> source, - ScriptOrigin* origin = nullptr)); - static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile( - Local<Context> context, Local<String> source, - ScriptOrigin* origin = nullptr); - - static Local<Script> V8_DEPRECATE_SOON("Use maybe version", - Compile(Local<String> source, - Local<String> file_name)); - - /** - * Runs the script returning the resulting value. It will be run in the - * context in which it was created (ScriptCompiler::CompileBound or - * UnboundScript::BindToCurrentContext()). - */ - V8_DEPRECATE_SOON("Use maybe version", Local<Value> Run()); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> Run(Local<Context> context); - - /** - * Returns the corresponding context-unbound script. - */ - Local<UnboundScript> GetUnboundScript(); -}; - - -/** - * For compiling scripts. - */ -class V8_EXPORT ScriptCompiler { - public: - /** - * Compilation data that the embedder can cache and pass back to speed up - * future compilations. The data is produced if the CompilerOptions passed to - * the compilation functions in ScriptCompiler contains produce_data_to_cache - * = true. The data to cache can then can be retrieved from - * UnboundScript. - */ - struct V8_EXPORT CachedData { - enum BufferPolicy { - BufferNotOwned, - BufferOwned - }; - - CachedData() - : data(NULL), - length(0), - rejected(false), - buffer_policy(BufferNotOwned) {} - - // If buffer_policy is BufferNotOwned, the caller keeps the ownership of - // data and guarantees that it stays alive until the CachedData object is - // destroyed. If the policy is BufferOwned, the given data will be deleted - // (with delete[]) when the CachedData object is destroyed. - CachedData(const uint8_t* data, int length, - BufferPolicy buffer_policy = BufferNotOwned); - ~CachedData(); - // TODO(marja): Async compilation; add constructors which take a callback - // which will be called when V8 no longer needs the data. - const uint8_t* data; - int length; - bool rejected; - BufferPolicy buffer_policy; - - // Prevent copying. - CachedData(const CachedData&) = delete; - CachedData& operator=(const CachedData&) = delete; - }; - - /** - * Source code which can be then compiled to a UnboundScript or Script. - */ - class Source { - public: - // Source takes ownership of CachedData. - V8_INLINE Source(Local<String> source_string, const ScriptOrigin& origin, - CachedData* cached_data = NULL); - V8_INLINE Source(Local<String> source_string, - CachedData* cached_data = NULL); - V8_INLINE ~Source(); - - // Ownership of the CachedData or its buffers is *not* transferred to the - // caller. The CachedData object is alive as long as the Source object is - // alive. - V8_INLINE const CachedData* GetCachedData() const; - - V8_INLINE const ScriptOriginOptions& GetResourceOptions() const; - - // Prevent copying. - Source(const Source&) = delete; - Source& operator=(const Source&) = delete; - - private: - friend class ScriptCompiler; - - Local<String> source_string; - - // Origin information - Local<Value> resource_name; - Local<Integer> resource_line_offset; - Local<Integer> resource_column_offset; - ScriptOriginOptions resource_options; - Local<Value> source_map_url; - - // Cached data from previous compilation (if a kConsume*Cache flag is - // set), or hold newly generated cache data (kProduce*Cache flags) are - // set when calling a compile method. - CachedData* cached_data; - }; - - /** - * For streaming incomplete script data to V8. The embedder should implement a - * subclass of this class. - */ - class V8_EXPORT ExternalSourceStream { - public: - virtual ~ExternalSourceStream() {} - - /** - * V8 calls this to request the next chunk of data from the embedder. This - * function will be called on a background thread, so it's OK to block and - * wait for the data, if the embedder doesn't have data yet. Returns the - * length of the data returned. When the data ends, GetMoreData should - * return 0. Caller takes ownership of the data. - * - * When streaming UTF-8 data, V8 handles multi-byte characters split between - * two data chunks, but doesn't handle multi-byte characters split between - * more than two data chunks. The embedder can avoid this problem by always - * returning at least 2 bytes of data. - * - * If the embedder wants to cancel the streaming, they should make the next - * GetMoreData call return 0. V8 will interpret it as end of data (and most - * probably, parsing will fail). The streaming task will return as soon as - * V8 has parsed the data it received so far. - */ - virtual size_t GetMoreData(const uint8_t** src) = 0; - - /** - * V8 calls this method to set a 'bookmark' at the current position in - * the source stream, for the purpose of (maybe) later calling - * ResetToBookmark. If ResetToBookmark is called later, then subsequent - * calls to GetMoreData should return the same data as they did when - * SetBookmark was called earlier. - * - * The embedder may return 'false' to indicate it cannot provide this - * functionality. - */ - virtual bool SetBookmark(); - - /** - * V8 calls this to return to a previously set bookmark. - */ - virtual void ResetToBookmark(); - }; - - - /** - * Source code which can be streamed into V8 in pieces. It will be parsed - * while streaming. It can be compiled after the streaming is complete. - * StreamedSource must be kept alive while the streaming task is ran (see - * ScriptStreamingTask below). - */ - class V8_EXPORT StreamedSource { - public: - enum Encoding { ONE_BYTE, TWO_BYTE, UTF8 }; - - StreamedSource(ExternalSourceStream* source_stream, Encoding encoding); - ~StreamedSource(); - - // Ownership of the CachedData or its buffers is *not* transferred to the - // caller. The CachedData object is alive as long as the StreamedSource - // object is alive. - const CachedData* GetCachedData() const; - - internal::StreamedSource* impl() const { return impl_; } - - // Prevent copying. - StreamedSource(const StreamedSource&) = delete; - StreamedSource& operator=(const StreamedSource&) = delete; - - private: - internal::StreamedSource* impl_; - }; - - /** - * A streaming task which the embedder must run on a background thread to - * stream scripts into V8. Returned by ScriptCompiler::StartStreamingScript. - */ - class ScriptStreamingTask { - public: - virtual ~ScriptStreamingTask() {} - virtual void Run() = 0; - }; - - enum CompileOptions { - kNoCompileOptions = 0, - kProduceParserCache, - kConsumeParserCache, - kProduceCodeCache, - kConsumeCodeCache - }; - - /** - * Compiles the specified script (context-independent). - * Cached data as part of the source object can be optionally produced to be - * consumed later to speed up compilation of identical source scripts. - * - * Note that when producing cached data, the source must point to NULL for - * cached data. When consuming cached data, the cached data must have been - * produced by the same version of V8. - * - * \param source Script source code. - * \return Compiled script object (context independent; for running it must be - * bound to a context). - */ - static V8_DEPRECATED("Use maybe version", - Local<UnboundScript> CompileUnbound( - Isolate* isolate, Source* source, - CompileOptions options = kNoCompileOptions)); - static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundScript( - Isolate* isolate, Source* source, - CompileOptions options = kNoCompileOptions); - - /** - * Compiles the specified script (bound to current context). - * - * \param source Script source code. - * \param pre_data Pre-parsing data, as obtained by ScriptData::PreCompile() - * using pre_data speeds compilation if it's done multiple times. - * Owned by caller, no references are kept when this function returns. - * \return Compiled script object, bound to the context that was active - * when this function was called. When run it will always use this - * context. - */ - static V8_DEPRECATED( - "Use maybe version", - Local<Script> Compile(Isolate* isolate, Source* source, - CompileOptions options = kNoCompileOptions)); - static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile( - Local<Context> context, Source* source, - CompileOptions options = kNoCompileOptions); - - /** - * Returns a task which streams script data into V8, or NULL if the script - * cannot be streamed. The user is responsible for running the task on a - * background thread and deleting it. When ran, the task starts parsing the - * script, and it will request data from the StreamedSource as needed. When - * ScriptStreamingTask::Run exits, all data has been streamed and the script - * can be compiled (see Compile below). - * - * This API allows to start the streaming with as little data as possible, and - * the remaining data (for example, the ScriptOrigin) is passed to Compile. - */ - static ScriptStreamingTask* StartStreamingScript( - Isolate* isolate, StreamedSource* source, - CompileOptions options = kNoCompileOptions); - - /** - * Compiles a streamed script (bound to current context). - * - * This can only be called after the streaming has finished - * (ScriptStreamingTask has been run). V8 doesn't construct the source string - * during streaming, so the embedder needs to pass the full source here. - */ - static V8_DEPRECATED("Use maybe version", - Local<Script> Compile(Isolate* isolate, - StreamedSource* source, - Local<String> full_source_string, - const ScriptOrigin& origin)); - static V8_WARN_UNUSED_RESULT MaybeLocal<Script> Compile( - Local<Context> context, StreamedSource* source, - Local<String> full_source_string, const ScriptOrigin& origin); - - /** - * Return a version tag for CachedData for the current V8 version & flags. - * - * This value is meant only for determining whether a previously generated - * CachedData instance is still valid; the tag has no other meaing. - * - * Background: The data carried by CachedData may depend on the exact - * V8 version number or current compiler flags. This means that when - * persisting CachedData, the embedder must take care to not pass in - * data from another V8 version, or the same version with different - * features enabled. - * - * The easiest way to do so is to clear the embedder's cache on any - * such change. - * - * Alternatively, this tag can be stored alongside the cached data and - * compared when it is being used. - */ - static uint32_t CachedDataVersionTag(); - - /** - * This is an unfinished experimental feature, and is only exposed - * here for internal testing purposes. DO NOT USE. - * - * Compile an ES module, returning a Module that encapsulates - * the compiled code. - * - * Corresponds to the ParseModule abstract operation in the - * ECMAScript specification. - */ - static V8_WARN_UNUSED_RESULT MaybeLocal<Module> CompileModule( - Isolate* isolate, Source* source); - - /** - * Compile a function for a given context. This is equivalent to running - * - * with (obj) { - * return function(args) { ... } - * } - * - * It is possible to specify multiple context extensions (obj in the above - * example). - */ - static V8_DEPRECATE_SOON("Use maybe version", - Local<Function> CompileFunctionInContext( - Isolate* isolate, Source* source, - Local<Context> context, size_t arguments_count, - Local<String> arguments[], - size_t context_extension_count, - Local<Object> context_extensions[])); - static V8_WARN_UNUSED_RESULT MaybeLocal<Function> CompileFunctionInContext( - Local<Context> context, Source* source, size_t arguments_count, - Local<String> arguments[], size_t context_extension_count, - Local<Object> context_extensions[]); - - private: - static V8_WARN_UNUSED_RESULT MaybeLocal<UnboundScript> CompileUnboundInternal( - Isolate* isolate, Source* source, CompileOptions options); -}; - - -/** - * An error message. - */ -class V8_EXPORT Message { - public: - Local<String> Get() const; - - V8_DEPRECATE_SOON("Use maybe version", Local<String> GetSourceLine() const); - V8_WARN_UNUSED_RESULT MaybeLocal<String> GetSourceLine( - Local<Context> context) const; - - /** - * Returns the origin for the script from where the function causing the - * error originates. - */ - ScriptOrigin GetScriptOrigin() const; - - /** - * Returns the resource name for the script from where the function causing - * the error originates. - */ - Local<Value> GetScriptResourceName() const; - - /** - * Exception stack trace. By default stack traces are not captured for - * uncaught exceptions. SetCaptureStackTraceForUncaughtExceptions allows - * to change this option. - */ - Local<StackTrace> GetStackTrace() const; - - /** - * Returns the number, 1-based, of the line where the error occurred. - */ - V8_DEPRECATE_SOON("Use maybe version", int GetLineNumber() const); - V8_WARN_UNUSED_RESULT Maybe<int> GetLineNumber(Local<Context> context) const; - - /** - * Returns the index within the script of the first character where - * the error occurred. - */ - int GetStartPosition() const; - - /** - * Returns the index within the script of the last character where - * the error occurred. - */ - int GetEndPosition() const; - - /** - * Returns the error level of the message. - */ - int ErrorLevel() const; - - /** - * Returns the index within the line of the first character where - * the error occurred. - */ - V8_DEPRECATE_SOON("Use maybe version", int GetStartColumn() const); - V8_WARN_UNUSED_RESULT Maybe<int> GetStartColumn(Local<Context> context) const; - - /** - * Returns the index within the line of the last character where - * the error occurred. - */ - V8_DEPRECATED("Use maybe version", int GetEndColumn() const); - V8_WARN_UNUSED_RESULT Maybe<int> GetEndColumn(Local<Context> context) const; - - /** - * Passes on the value set by the embedder when it fed the script from which - * this Message was generated to V8. - */ - bool IsSharedCrossOrigin() const; - bool IsOpaque() const; - - // TODO(1245381): Print to a string instead of on a FILE. - static void PrintCurrentStackTrace(Isolate* isolate, FILE* out); - - static const int kNoLineNumberInfo = 0; - static const int kNoColumnInfo = 0; - static const int kNoScriptIdInfo = 0; -}; - - -/** - * Representation of a JavaScript stack trace. The information collected is a - * snapshot of the execution stack and the information remains valid after - * execution continues. - */ -class V8_EXPORT StackTrace { - public: - /** - * Flags that determine what information is placed captured for each - * StackFrame when grabbing the current stack trace. - * Note: these options are deprecated and we always collect all available - * information (kDetailed). - */ - enum StackTraceOptions { - kLineNumber = 1, - kColumnOffset = 1 << 1 | kLineNumber, - kScriptName = 1 << 2, - kFunctionName = 1 << 3, - kIsEval = 1 << 4, - kIsConstructor = 1 << 5, - kScriptNameOrSourceURL = 1 << 6, - kScriptId = 1 << 7, - kExposeFramesAcrossSecurityOrigins = 1 << 8, - kOverview = kLineNumber | kColumnOffset | kScriptName | kFunctionName, - kDetailed = kOverview | kIsEval | kIsConstructor | kScriptNameOrSourceURL - }; - - /** - * Returns a StackFrame at a particular index. - */ - Local<StackFrame> GetFrame(uint32_t index) const; - - /** - * Returns the number of StackFrames. - */ - int GetFrameCount() const; - - /** - * Returns StackTrace as a v8::Array that contains StackFrame objects. - */ - V8_DEPRECATED("Use native API instead", Local<Array> AsArray()); - - /** - * Grab a snapshot of the current JavaScript execution stack. - * - * \param frame_limit The maximum number of stack frames we want to capture. - * \param options Enumerates the set of things we will capture for each - * StackFrame. - */ - static Local<StackTrace> CurrentStackTrace( - Isolate* isolate, int frame_limit, StackTraceOptions options = kDetailed); -}; - - -/** - * A single JavaScript stack frame. - */ -class V8_EXPORT StackFrame { - public: - /** - * Returns the number, 1-based, of the line for the associate function call. - * This method will return Message::kNoLineNumberInfo if it is unable to - * retrieve the line number, or if kLineNumber was not passed as an option - * when capturing the StackTrace. - */ - int GetLineNumber() const; - - /** - * Returns the 1-based column offset on the line for the associated function - * call. - * This method will return Message::kNoColumnInfo if it is unable to retrieve - * the column number, or if kColumnOffset was not passed as an option when - * capturing the StackTrace. - */ - int GetColumn() const; - - /** - * Returns the id of the script for the function for this StackFrame. - * This method will return Message::kNoScriptIdInfo if it is unable to - * retrieve the script id, or if kScriptId was not passed as an option when - * capturing the StackTrace. - */ - int GetScriptId() const; - - /** - * Returns the name of the resource that contains the script for the - * function for this StackFrame. - */ - Local<String> GetScriptName() const; - - /** - * Returns the name of the resource that contains the script for the - * function for this StackFrame or sourceURL value if the script name - * is undefined and its source ends with //# sourceURL=... string or - * deprecated //@ sourceURL=... string. - */ - Local<String> GetScriptNameOrSourceURL() const; - - /** - * Returns the name of the function associated with this stack frame. - */ - Local<String> GetFunctionName() const; - - /** - * Returns whether or not the associated function is compiled via a call to - * eval(). - */ - bool IsEval() const; - - /** - * Returns whether or not the associated function is called as a - * constructor via "new". - */ - bool IsConstructor() const; - - /** - * Returns whether or not the associated functions is defined in wasm. - */ - bool IsWasm() const; -}; - - -// A StateTag represents a possible state of the VM. -enum StateTag { JS, GC, COMPILER, OTHER, EXTERNAL, IDLE }; - -// A RegisterState represents the current state of registers used -// by the sampling profiler API. -struct RegisterState { - RegisterState() : pc(nullptr), sp(nullptr), fp(nullptr) {} - void* pc; // Instruction pointer. - void* sp; // Stack pointer. - void* fp; // Frame pointer. -}; - -// The output structure filled up by GetStackSample API function. -struct SampleInfo { - size_t frames_count; // Number of frames collected. - StateTag vm_state; // Current VM state. - void* external_callback_entry; // External callback address if VM is - // executing an external callback. -}; - -/** - * A JSON Parser and Stringifier. - */ -class V8_EXPORT JSON { - public: - /** - * Tries to parse the string |json_string| and returns it as value if - * successful. - * - * \param json_string The string to parse. - * \return The corresponding value if successfully parsed. - */ - static V8_DEPRECATED("Use the maybe version taking context", - Local<Value> Parse(Local<String> json_string)); - static V8_DEPRECATE_SOON("Use the maybe version taking context", - MaybeLocal<Value> Parse(Isolate* isolate, - Local<String> json_string)); - static V8_WARN_UNUSED_RESULT MaybeLocal<Value> Parse( - Local<Context> context, Local<String> json_string); - - /** - * Tries to stringify the JSON-serializable object |json_object| and returns - * it as string if successful. - * - * \param json_object The JSON-serializable object to stringify. - * \return The corresponding string if successfully stringified. - */ - static V8_WARN_UNUSED_RESULT MaybeLocal<String> Stringify( - Local<Context> context, Local<Object> json_object, - Local<String> gap = Local<String>()); -}; - -/** - * Value serialization compatible with the HTML structured clone algorithm. - * The format is backward-compatible (i.e. safe to store to disk). - * - * WARNING: This API is under development, and changes (including incompatible - * changes to the API or wire format) may occur without notice until this - * warning is removed. - */ -class V8_EXPORT ValueSerializer { - public: - class V8_EXPORT Delegate { - public: - virtual ~Delegate() {} - - /** - * Handles the case where a DataCloneError would be thrown in the structured - * clone spec. Other V8 embedders may throw some other appropriate exception - * type. - */ - virtual void ThrowDataCloneError(Local<String> message) = 0; - - /** - * The embedder overrides this method to write some kind of host object, if - * possible. If not, a suitable exception should be thrown and - * Nothing<bool>() returned. - */ - virtual Maybe<bool> WriteHostObject(Isolate* isolate, Local<Object> object); - - /** - * Called when the ValueSerializer is going to serialize a - * SharedArrayBuffer object. The embedder must return an ID for the - * object, using the same ID if this SharedArrayBuffer has already been - * serialized in this buffer. When deserializing, this ID will be passed to - * ValueDeserializer::TransferSharedArrayBuffer as |transfer_id|. - * - * If the object cannot be serialized, an - * exception should be thrown and Nothing<uint32_t>() returned. - */ - virtual Maybe<uint32_t> GetSharedArrayBufferId( - Isolate* isolate, Local<SharedArrayBuffer> shared_array_buffer); - - virtual Maybe<uint32_t> GetWasmModuleTransferId( - Isolate* isolate, Local<WasmCompiledModule> module); - /** - * Allocates memory for the buffer of at least the size provided. The actual - * size (which may be greater or equal) is written to |actual_size|. If no - * buffer has been allocated yet, nullptr will be provided. - * - * If the memory cannot be allocated, nullptr should be returned. - * |actual_size| will be ignored. It is assumed that |old_buffer| is still - * valid in this case and has not been modified. - */ - virtual void* ReallocateBufferMemory(void* old_buffer, size_t size, - size_t* actual_size); - - /** - * Frees a buffer allocated with |ReallocateBufferMemory|. - */ - virtual void FreeBufferMemory(void* buffer); - }; - - explicit ValueSerializer(Isolate* isolate); - ValueSerializer(Isolate* isolate, Delegate* delegate); - ~ValueSerializer(); - - /** - * Writes out a header, which includes the format version. - */ - void WriteHeader(); - - /** - * Serializes a JavaScript value into the buffer. - */ - V8_WARN_UNUSED_RESULT Maybe<bool> WriteValue(Local<Context> context, - Local<Value> value); - - /** - * Returns the stored data. This serializer should not be used once the buffer - * is released. The contents are undefined if a previous write has failed. - */ - V8_DEPRECATE_SOON("Use Release()", std::vector<uint8_t> ReleaseBuffer()); - - /** - * Returns the stored data (allocated using the delegate's - * AllocateBufferMemory) and its size. This serializer should not be used once - * the buffer is released. The contents are undefined if a previous write has - * failed. - */ - V8_WARN_UNUSED_RESULT std::pair<uint8_t*, size_t> Release(); - - /** - * Marks an ArrayBuffer as havings its contents transferred out of band. - * Pass the corresponding ArrayBuffer in the deserializing context to - * ValueDeserializer::TransferArrayBuffer. - */ - void TransferArrayBuffer(uint32_t transfer_id, - Local<ArrayBuffer> array_buffer); - - /** - * Similar to TransferArrayBuffer, but for SharedArrayBuffer. - */ - V8_DEPRECATE_SOON("Use Delegate::GetSharedArrayBufferId", - void TransferSharedArrayBuffer( - uint32_t transfer_id, - Local<SharedArrayBuffer> shared_array_buffer)); - - /** - * Indicate whether to treat ArrayBufferView objects as host objects, - * i.e. pass them to Delegate::WriteHostObject. This should not be - * called when no Delegate was passed. - * - * The default is not to treat ArrayBufferViews as host objects. - */ - void SetTreatArrayBufferViewsAsHostObjects(bool mode); - - /** - * Write raw data in various common formats to the buffer. - * Note that integer types are written in base-128 varint format, not with a - * binary copy. For use during an override of Delegate::WriteHostObject. - */ - void WriteUint32(uint32_t value); - void WriteUint64(uint64_t value); - void WriteDouble(double value); - void WriteRawBytes(const void* source, size_t length); - - private: - ValueSerializer(const ValueSerializer&) = delete; - void operator=(const ValueSerializer&) = delete; - - struct PrivateData; - PrivateData* private_; -}; - -/** - * Deserializes values from data written with ValueSerializer, or a compatible - * implementation. - * - * WARNING: This API is under development, and changes (including incompatible - * changes to the API or wire format) may occur without notice until this - * warning is removed. - */ -class V8_EXPORT ValueDeserializer { - public: - class V8_EXPORT Delegate { - public: - virtual ~Delegate() {} - - /** - * The embedder overrides this method to read some kind of host object, if - * possible. If not, a suitable exception should be thrown and - * MaybeLocal<Object>() returned. - */ - virtual MaybeLocal<Object> ReadHostObject(Isolate* isolate); - - /** - * Get a WasmCompiledModule given a transfer_id previously provided - * by ValueSerializer::GetWasmModuleTransferId - */ - virtual MaybeLocal<WasmCompiledModule> GetWasmModuleFromId( - Isolate* isolate, uint32_t transfer_id); - }; - - ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size); - ValueDeserializer(Isolate* isolate, const uint8_t* data, size_t size, - Delegate* delegate); - ~ValueDeserializer(); - - /** - * Reads and validates a header (including the format version). - * May, for example, reject an invalid or unsupported wire format. - */ - V8_WARN_UNUSED_RESULT Maybe<bool> ReadHeader(Local<Context> context); - - /** - * Deserializes a JavaScript value from the buffer. - */ - V8_WARN_UNUSED_RESULT MaybeLocal<Value> ReadValue(Local<Context> context); - - /** - * Accepts the array buffer corresponding to the one passed previously to - * ValueSerializer::TransferArrayBuffer. - */ - void TransferArrayBuffer(uint32_t transfer_id, - Local<ArrayBuffer> array_buffer); - - /** - * Similar to TransferArrayBuffer, but for SharedArrayBuffer. - * The id is not necessarily in the same namespace as unshared ArrayBuffer - * objects. - */ - void TransferSharedArrayBuffer(uint32_t id, - Local<SharedArrayBuffer> shared_array_buffer); - - /** - * Must be called before ReadHeader to enable support for reading the legacy - * wire format (i.e., which predates this being shipped). - * - * Don't use this unless you need to read data written by previous versions of - * blink::ScriptValueSerializer. - */ - void SetSupportsLegacyWireFormat(bool supports_legacy_wire_format); - - /** - * Expect inline wasm in the data stream (rather than in-memory transfer) - */ - void SetExpectInlineWasm(bool allow_inline_wasm); - - /** - * Reads the underlying wire format version. Likely mostly to be useful to - * legacy code reading old wire format versions. Must be called after - * ReadHeader. - */ - uint32_t GetWireFormatVersion() const; - - /** - * Reads raw data in various common formats to the buffer. - * Note that integer types are read in base-128 varint format, not with a - * binary copy. For use during an override of Delegate::ReadHostObject. - */ - V8_WARN_UNUSED_RESULT bool ReadUint32(uint32_t* value); - V8_WARN_UNUSED_RESULT bool ReadUint64(uint64_t* value); - V8_WARN_UNUSED_RESULT bool ReadDouble(double* value); - V8_WARN_UNUSED_RESULT bool ReadRawBytes(size_t length, const void** data); - - private: - ValueDeserializer(const ValueDeserializer&) = delete; - void operator=(const ValueDeserializer&) = delete; - - struct PrivateData; - PrivateData* private_; -}; - -/** - * A map whose keys are referenced weakly. It is similar to JavaScript WeakMap - * but can be created without entering a v8::Context and hence shouldn't - * escape to JavaScript. - */ -class V8_EXPORT NativeWeakMap : public Data { - public: - static Local<NativeWeakMap> New(Isolate* isolate); - void Set(Local<Value> key, Local<Value> value); - Local<Value> Get(Local<Value> key) const; - bool Has(Local<Value> key); - bool Delete(Local<Value> key); -}; - - -// --- Value --- - - -/** - * The superclass of all JavaScript values and objects. - */ -class V8_EXPORT Value : public Data { - public: - /** - * Returns true if this value is the undefined value. See ECMA-262 - * 4.3.10. - */ - V8_INLINE bool IsUndefined() const; - - /** - * Returns true if this value is the null value. See ECMA-262 - * 4.3.11. - */ - V8_INLINE bool IsNull() const; - - /** - * Returns true if this value is either the null or the undefined value. - * See ECMA-262 - * 4.3.11. and 4.3.12 - */ - V8_INLINE bool IsNullOrUndefined() const; - - /** - * Returns true if this value is true. - */ - bool IsTrue() const; - - /** - * Returns true if this value is false. - */ - bool IsFalse() const; - - /** - * Returns true if this value is a symbol or a string. - */ - bool IsName() const; - - /** - * Returns true if this value is an instance of the String type. - * See ECMA-262 8.4. - */ - V8_INLINE bool IsString() const; - - /** - * Returns true if this value is a symbol. - */ - bool IsSymbol() const; - - /** - * Returns true if this value is a function. - */ - bool IsFunction() const; - - /** - * Returns true if this value is an array. Note that it will return false for - * an Proxy for an array. - */ - bool IsArray() const; - - /** - * Returns true if this value is an object. - */ - bool IsObject() const; - - /** - * Returns true if this value is boolean. - */ - bool IsBoolean() const; - - /** - * Returns true if this value is a number. - */ - bool IsNumber() const; - - /** - * Returns true if this value is external. - */ - bool IsExternal() const; - - /** - * Returns true if this value is a 32-bit signed integer. - */ - bool IsInt32() const; - - /** - * Returns true if this value is a 32-bit unsigned integer. - */ - bool IsUint32() const; - - /** - * Returns true if this value is a Date. - */ - bool IsDate() const; - - /** - * Returns true if this value is an Arguments object. - */ - bool IsArgumentsObject() const; - - /** - * Returns true if this value is a Boolean object. - */ - bool IsBooleanObject() const; - - /** - * Returns true if this value is a Number object. - */ - bool IsNumberObject() const; - - /** - * Returns true if this value is a String object. - */ - bool IsStringObject() const; - - /** - * Returns true if this value is a Symbol object. - */ - bool IsSymbolObject() const; - - /** - * Returns true if this value is a NativeError. - */ - bool IsNativeError() const; - - /** - * Returns true if this value is a RegExp. - */ - bool IsRegExp() const; - - /** - * Returns true if this value is an async function. - */ - bool IsAsyncFunction() const; - - /** - * Returns true if this value is a Generator function. - */ - bool IsGeneratorFunction() const; - - /** - * Returns true if this value is a Generator object (iterator). - */ - bool IsGeneratorObject() const; - - /** - * Returns true if this value is a Promise. - */ - bool IsPromise() const; - - /** - * Returns true if this value is a Map. - */ - bool IsMap() const; - - /** - * Returns true if this value is a Set. - */ - bool IsSet() const; - - /** - * Returns true if this value is a Map Iterator. - */ - bool IsMapIterator() const; - - /** - * Returns true if this value is a Set Iterator. - */ - bool IsSetIterator() const; - - /** - * Returns true if this value is a WeakMap. - */ - bool IsWeakMap() const; - - /** - * Returns true if this value is a WeakSet. - */ - bool IsWeakSet() const; - - /** - * Returns true if this value is an ArrayBuffer. - */ - bool IsArrayBuffer() const; - - /** - * Returns true if this value is an ArrayBufferView. - */ - bool IsArrayBufferView() const; - - /** - * Returns true if this value is one of TypedArrays. - */ - bool IsTypedArray() const; - - /** - * Returns true if this value is an Uint8Array. - */ - bool IsUint8Array() const; - - /** - * Returns true if this value is an Uint8ClampedArray. - */ - bool IsUint8ClampedArray() const; - - /** - * Returns true if this value is an Int8Array. - */ - bool IsInt8Array() const; - - /** - * Returns true if this value is an Uint16Array. - */ - bool IsUint16Array() const; - - /** - * Returns true if this value is an Int16Array. - */ - bool IsInt16Array() const; - - /** - * Returns true if this value is an Uint32Array. - */ - bool IsUint32Array() const; - - /** - * Returns true if this value is an Int32Array. - */ - bool IsInt32Array() const; - - /** - * Returns true if this value is a Float32Array. - */ - bool IsFloat32Array() const; - - /** - * Returns true if this value is a Float64Array. - */ - bool IsFloat64Array() const; - - /** - * Returns true if this value is a DataView. - */ - bool IsDataView() const; - - /** - * Returns true if this value is a SharedArrayBuffer. - * This is an experimental feature. - */ - bool IsSharedArrayBuffer() const; - - /** - * Returns true if this value is a JavaScript Proxy. - */ - bool IsProxy() const; - - bool IsWebAssemblyCompiledModule() const; - - V8_WARN_UNUSED_RESULT MaybeLocal<Boolean> ToBoolean( - Local<Context> context) const; - V8_WARN_UNUSED_RESULT MaybeLocal<Number> ToNumber( - Local<Context> context) const; - V8_WARN_UNUSED_RESULT MaybeLocal<String> ToString( - Local<Context> context) const; - V8_WARN_UNUSED_RESULT MaybeLocal<String> ToDetailString( - Local<Context> context) const; - V8_WARN_UNUSED_RESULT MaybeLocal<Object> ToObject( - Local<Context> context) const; - V8_WARN_UNUSED_RESULT MaybeLocal<Integer> ToInteger( - Local<Context> context) const; - V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToUint32( - Local<Context> context) const; - V8_WARN_UNUSED_RESULT MaybeLocal<Int32> ToInt32(Local<Context> context) const; - - V8_DEPRECATE_SOON("Use maybe version", - Local<Boolean> ToBoolean(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local<Number> ToNumber(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local<String> ToString(Isolate* isolate) const); - V8_DEPRECATED("Use maybe version", - Local<String> ToDetailString(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local<Object> ToObject(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local<Integer> ToInteger(Isolate* isolate) const); - V8_DEPRECATED("Use maybe version", - Local<Uint32> ToUint32(Isolate* isolate) const); - V8_DEPRECATE_SOON("Use maybe version", - Local<Int32> ToInt32(Isolate* isolate) const); - - inline V8_DEPRECATE_SOON("Use maybe version", - Local<Boolean> ToBoolean() const); - inline V8_DEPRECATED("Use maybe version", Local<Number> ToNumber() const); - inline V8_DEPRECATE_SOON("Use maybe version", Local<String> ToString() const); - inline V8_DEPRECATED("Use maybe version", - Local<String> ToDetailString() const); - inline V8_DEPRECATE_SOON("Use maybe version", Local<Object> ToObject() const); - inline V8_DEPRECATE_SOON("Use maybe version", - Local<Integer> ToInteger() const); - inline V8_DEPRECATED("Use maybe version", Local<Uint32> ToUint32() const); - inline V8_DEPRECATED("Use maybe version", Local<Int32> ToInt32() const); - - /** - * Attempts to convert a string to an array index. - * Returns an empty handle if the conversion fails. - */ - V8_DEPRECATED("Use maybe version", Local<Uint32> ToArrayIndex() const); - V8_WARN_UNUSED_RESULT MaybeLocal<Uint32> ToArrayIndex( - Local<Context> context) const; - - V8_WARN_UNUSED_RESULT Maybe<bool> BooleanValue(Local<Context> context) const; - V8_WARN_UNUSED_RESULT Maybe<double> NumberValue(Local<Context> context) const; - V8_WARN_UNUSED_RESULT Maybe<int64_t> IntegerValue( - Local<Context> context) const; - V8_WARN_UNUSED_RESULT Maybe<uint32_t> Uint32Value( - Local<Context> context) const; - V8_WARN_UNUSED_RESULT Maybe<int32_t> Int32Value(Local<Context> context) const; - - V8_DEPRECATE_SOON("Use maybe version", bool BooleanValue() const); - V8_DEPRECATE_SOON("Use maybe version", double NumberValue() const); - V8_DEPRECATE_SOON("Use maybe version", int64_t IntegerValue() const); - V8_DEPRECATE_SOON("Use maybe version", uint32_t Uint32Value() const); - V8_DEPRECATE_SOON("Use maybe version", int32_t Int32Value() const); - - /** JS == */ - V8_DEPRECATE_SOON("Use maybe version", bool Equals(Local<Value> that) const); - V8_WARN_UNUSED_RESULT Maybe<bool> Equals(Local<Context> context, - Local<Value> that) const; - bool StrictEquals(Local<Value> that) const; - bool SameValue(Local<Value> that) const; - - template <class T> V8_INLINE static Value* Cast(T* value); - - Local<String> TypeOf(Isolate*); - - Maybe<bool> InstanceOf(Local<Context> context, Local<Object> object); - - private: - V8_INLINE bool QuickIsUndefined() const; - V8_INLINE bool QuickIsNull() const; - V8_INLINE bool QuickIsNullOrUndefined() const; - V8_INLINE bool QuickIsString() const; - bool FullIsUndefined() const; - bool FullIsNull() const; - bool FullIsString() const; -}; - - -/** - * The superclass of primitive values. See ECMA-262 4.3.2. - */ -class V8_EXPORT Primitive : public Value { }; - - -/** - * A primitive boolean value (ECMA-262, 4.3.14). Either the true - * or false value. - */ -class V8_EXPORT Boolean : public Primitive { - public: - bool Value() const; - V8_INLINE static Boolean* Cast(v8::Value* obj); - V8_INLINE static Local<Boolean> New(Isolate* isolate, bool value); - - private: - static void CheckCast(v8::Value* obj); -}; - - -/** - * A superclass for symbols and strings. - */ -class V8_EXPORT Name : public Primitive { - public: - /** - * Returns the identity hash for this object. The current implementation - * uses an inline property on the object to store the identity hash. - * - * The return value will never be 0. Also, it is not guaranteed to be - * unique. - */ - int GetIdentityHash(); - - V8_INLINE static Name* Cast(Value* obj); - - private: - static void CheckCast(Value* obj); -}; - -/** - * A flag describing different modes of string creation. - * - * Aside from performance implications there are no differences between the two - * creation modes. - */ -enum class NewStringType { - /** - * Create a new string, always allocating new storage memory. - */ - kNormal, - - /** - * Acts as a hint that the string should be created in the - * old generation heap space and be deduplicated if an identical string - * already exists. - */ - kInternalized -}; - -/** - * A JavaScript string value (ECMA-262, 4.3.17). - */ -class V8_EXPORT String : public Name { - public: - static const int kMaxLength = (1 << 28) - 16; - - enum Encoding { - UNKNOWN_ENCODING = 0x1, - TWO_BYTE_ENCODING = 0x0, - ONE_BYTE_ENCODING = 0x8 - }; - /** - * Returns the number of characters (UTF-16 code units) in this string. - */ - int Length() const; - - /** - * Returns the number of bytes in the UTF-8 encoded - * representation of this string. - */ - int Utf8Length() const; - - /** - * Returns whether this string is known to contain only one byte data, - * i.e. ISO-8859-1 code points. - * Does not read the string. - * False negatives are possible. - */ - bool IsOneByte() const; - - /** - * Returns whether this string contain only one byte data, - * i.e. ISO-8859-1 code points. - * Will read the entire string in some cases. - */ - bool ContainsOnlyOneByte() const; - - /** - * Write the contents of the string to an external buffer. - * If no arguments are given, expects the buffer to be large - * enough to hold the entire string and NULL terminator. Copies - * the contents of the string and the NULL terminator into the - * buffer. - * - * WriteUtf8 will not write partial UTF-8 sequences, preferring to stop - * before the end of the buffer. - * - * Copies up to length characters into the output buffer. - * Only null-terminates if there is enough space in the buffer. - * - * \param buffer The buffer into which the string will be copied. - * \param start The starting position within the string at which - * copying begins. - * \param length The number of characters to copy from the string. For - * WriteUtf8 the number of bytes in the buffer. - * \param nchars_ref The number of characters written, can be NULL. - * \param options Various options that might affect performance of this or - * subsequent operations. - * \return The number of characters copied to the buffer excluding the null - * terminator. For WriteUtf8: The number of bytes copied to the buffer - * including the null terminator (if written). - */ - enum WriteOptions { - NO_OPTIONS = 0, - HINT_MANY_WRITES_EXPECTED = 1, - NO_NULL_TERMINATION = 2, - PRESERVE_ONE_BYTE_NULL = 4, - // Used by WriteUtf8 to replace orphan surrogate code units with the - // unicode replacement character. Needs to be set to guarantee valid UTF-8 - // output. - REPLACE_INVALID_UTF8 = 8 - }; - - // 16-bit character codes. - int Write(uint16_t* buffer, - int start = 0, - int length = -1, - int options = NO_OPTIONS) const; - // One byte characters. - int WriteOneByte(uint8_t* buffer, - int start = 0, - int length = -1, - int options = NO_OPTIONS) const; - // UTF-8 encoded characters. - int WriteUtf8(char* buffer, - int length = -1, - int* nchars_ref = NULL, - int options = NO_OPTIONS) const; - - /** - * A zero length string. - */ - V8_INLINE static Local<String> Empty(Isolate* isolate); - - /** - * Returns true if the string is external - */ - bool IsExternal() const; - - /** - * Returns true if the string is both external and one-byte. - */ - bool IsExternalOneByte() const; - - class V8_EXPORT ExternalStringResourceBase { // NOLINT - public: - virtual ~ExternalStringResourceBase() {} - - virtual bool IsCompressible() const { return false; } - - protected: - ExternalStringResourceBase() {} - - /** - * Internally V8 will call this Dispose method when the external string - * resource is no longer needed. The default implementation will use the - * delete operator. This method can be overridden in subclasses to - * control how allocated external string resources are disposed. - */ - virtual void Dispose() { delete this; } - - // Disallow copying and assigning. - ExternalStringResourceBase(const ExternalStringResourceBase&) = delete; - void operator=(const ExternalStringResourceBase&) = delete; - - private: - friend class internal::Heap; - friend class v8::String; - }; - - /** - * An ExternalStringResource is a wrapper around a two-byte string - * buffer that resides outside V8's heap. Implement an - * ExternalStringResource to manage the life cycle of the underlying - * buffer. Note that the string data must be immutable. - */ - class V8_EXPORT ExternalStringResource - : public ExternalStringResourceBase { - public: - /** - * Override the destructor to manage the life cycle of the underlying - * buffer. - */ - virtual ~ExternalStringResource() {} - - /** - * The string data from the underlying buffer. - */ - virtual const uint16_t* data() const = 0; - - /** - * The length of the string. That is, the number of two-byte characters. - */ - virtual size_t length() const = 0; - - protected: - ExternalStringResource() {} - }; - - /** - * An ExternalOneByteStringResource is a wrapper around an one-byte - * string buffer that resides outside V8's heap. Implement an - * ExternalOneByteStringResource to manage the life cycle of the - * underlying buffer. Note that the string data must be immutable - * and that the data must be Latin-1 and not UTF-8, which would require - * special treatment internally in the engine and do not allow efficient - * indexing. Use String::New or convert to 16 bit data for non-Latin1. - */ - - class V8_EXPORT ExternalOneByteStringResource - : public ExternalStringResourceBase { - public: - /** - * Override the destructor to manage the life cycle of the underlying - * buffer. - */ - virtual ~ExternalOneByteStringResource() {} - /** The string data from the underlying buffer.*/ - virtual const char* data() const = 0; - /** The number of Latin-1 characters in the string.*/ - virtual size_t length() const = 0; - protected: - ExternalOneByteStringResource() {} - }; - - /** - * If the string is an external string, return the ExternalStringResourceBase - * regardless of the encoding, otherwise return NULL. The encoding of the - * string is returned in encoding_out. - */ - V8_INLINE ExternalStringResourceBase* GetExternalStringResourceBase( - Encoding* encoding_out) const; - - /** - * Get the ExternalStringResource for an external string. Returns - * NULL if IsExternal() doesn't return true. - */ - V8_INLINE ExternalStringResource* GetExternalStringResource() const; - - /** - * Get the ExternalOneByteStringResource for an external one-byte string. - * Returns NULL if IsExternalOneByte() doesn't return true. - */ - const ExternalOneByteStringResource* GetExternalOneByteStringResource() const; - - V8_INLINE static String* Cast(v8::Value* obj); - - // TODO(dcarney): remove with deprecation of New functions. - enum NewStringType { - kNormalString = static_cast<int>(v8::NewStringType::kNormal), - kInternalizedString = static_cast<int>(v8::NewStringType::kInternalized) - }; - - /** Allocates a new string from UTF-8 data.*/ - static V8_DEPRECATE_SOON( - "Use maybe version", - Local<String> NewFromUtf8(Isolate* isolate, const char* data, - NewStringType type = kNormalString, - int length = -1)); - - /** Allocates a new string from UTF-8 data. Only returns an empty value when - * length > kMaxLength. **/ - static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromUtf8( - Isolate* isolate, const char* data, v8::NewStringType type, - int length = -1); - - /** Allocates a new string from Latin-1 data.*/ - static V8_DEPRECATED( - "Use maybe version", - Local<String> NewFromOneByte(Isolate* isolate, const uint8_t* data, - NewStringType type = kNormalString, - int length = -1)); - - /** Allocates a new string from Latin-1 data. Only returns an empty value - * when length > kMaxLength. **/ - static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromOneByte( - Isolate* isolate, const uint8_t* data, v8::NewStringType type, - int length = -1); - - /** Allocates a new string from UTF-16 data.*/ - static V8_DEPRECATE_SOON( - "Use maybe version", - Local<String> NewFromTwoByte(Isolate* isolate, const uint16_t* data, - NewStringType type = kNormalString, - int length = -1)); - - /** Allocates a new string from UTF-16 data. Only returns an empty value when - * length > kMaxLength. **/ - static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewFromTwoByte( - Isolate* isolate, const uint16_t* data, v8::NewStringType type, - int length = -1); - - /** - * Creates a new string by concatenating the left and the right strings - * passed in as parameters. - */ - static Local<String> Concat(Local<String> left, Local<String> right); - - /** - * Creates a new external string using the data defined in the given - * resource. When the external string is no longer live on V8's heap the - * resource will be disposed by calling its Dispose method. The caller of - * this function should not otherwise delete or modify the resource. Neither - * should the underlying buffer be deallocated or modified except through the - * destructor of the external string resource. - */ - static V8_DEPRECATED("Use maybe version", - Local<String> NewExternal( - Isolate* isolate, ExternalStringResource* resource)); - static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalTwoByte( - Isolate* isolate, ExternalStringResource* resource); - - /** - * Associate an external string resource with this string by transforming it - * in place so that existing references to this string in the JavaScript heap - * will use the external string resource. The external string resource's - * character contents need to be equivalent to this string. - * Returns true if the string has been changed to be an external string. - * The string is not modified if the operation fails. See NewExternal for - * information on the lifetime of the resource. - */ - bool MakeExternal(ExternalStringResource* resource); - - /** - * Creates a new external string using the one-byte data defined in the given - * resource. When the external string is no longer live on V8's heap the - * resource will be disposed by calling its Dispose method. The caller of - * this function should not otherwise delete or modify the resource. Neither - * should the underlying buffer be deallocated or modified except through the - * destructor of the external string resource. - */ - static V8_DEPRECATE_SOON( - "Use maybe version", - Local<String> NewExternal(Isolate* isolate, - ExternalOneByteStringResource* resource)); - static V8_WARN_UNUSED_RESULT MaybeLocal<String> NewExternalOneByte( - Isolate* isolate, ExternalOneByteStringResource* resource); - - /** - * Associate an external string resource with this string by transforming it - * in place so that existing references to this string in the JavaScript heap - * will use the external string resource. The external string resource's - * character contents need to be equivalent to this string. - * Returns true if the string has been changed to be an external string. - * The string is not modified if the operation fails. See NewExternal for - * information on the lifetime of the resource. - */ - bool MakeExternal(ExternalOneByteStringResource* resource); - - /** - * Returns true if this string can be made external. - */ - bool CanMakeExternal(); - - /** - * Converts an object to a UTF-8-encoded character array. Useful if - * you want to print the object. If conversion to a string fails - * (e.g. due to an exception in the toString() method of the object) - * then the length() method returns 0 and the * operator returns - * NULL. - */ - class V8_EXPORT Utf8Value { - public: - explicit Utf8Value(Local<v8::Value> obj); - ~Utf8Value(); - char* operator*() { return str_; } - const char* operator*() const { return str_; } - int length() const { return length_; } - - // Disallow copying and assigning. - Utf8Value(const Utf8Value&) = delete; - void operator=(const Utf8Value&) = delete; - - private: - char* str_; - int length_; - }; - - /** - * Converts an object to a two-byte (UTF-16-encoded) string. - * If conversion to a string fails (eg. due to an exception in the toString() - * method of the object) then the length() method returns 0 and the * operator - * returns NULL. - */ - class V8_EXPORT Value { - public: - explicit Value(Local<v8::Value> obj); - ~Value(); - uint16_t* operator*() { return str_; } - const uint16_t* operator*() const { return str_; } - int length() const { return length_; } - - // Disallow copying and assigning. - Value(const Value&) = delete; - void operator=(const Value&) = delete; - - private: - uint16_t* str_; - int length_; - }; - - private: - void VerifyExternalStringResourceBase(ExternalStringResourceBase* v, - Encoding encoding) const; - void VerifyExternalStringResource(ExternalStringResource* val) const; - static void CheckCast(v8::Value* obj); -}; - - -/** - * A JavaScript symbol (ECMA-262 edition 6) - */ -class V8_EXPORT Symbol : public Name { - public: - /** - * Returns the print name string of the symbol, or undefined if none. - */ - Local<Value> Name() const; - - /** - * Create a symbol. If name is not empty, it will be used as the description. - */ - static Local<Symbol> New(Isolate* isolate, - Local<String> name = Local<String>()); - - /** - * Access global symbol registry. - * Note that symbols created this way are never collected, so - * they should only be used for statically fixed properties. - * Also, there is only one global name space for the names used as keys. - * To minimize the potential for clashes, use qualified names as keys. - */ - static Local<Symbol> For(Isolate *isolate, Local<String> name); - - /** - * Retrieve a global symbol. Similar to |For|, but using a separate - * registry that is not accessible by (and cannot clash with) JavaScript code. - */ - static Local<Symbol> ForApi(Isolate *isolate, Local<String> name); - - // Well-known symbols - static Local<Symbol> GetHasInstance(Isolate* isolate); - static Local<Symbol> GetIsConcatSpreadable(Isolate* isolate); - static Local<Symbol> GetIterator(Isolate* isolate); - static Local<Symbol> GetMatch(Isolate* isolate); - static Local<Symbol> GetReplace(Isolate* isolate); - static Local<Symbol> GetSearch(Isolate* isolate); - static Local<Symbol> GetSplit(Isolate* isolate); - static Local<Symbol> GetToPrimitive(Isolate* isolate); - static Local<Symbol> GetToStringTag(Isolate* isolate); - static Local<Symbol> GetUnscopables(Isolate* isolate); - - V8_INLINE static Symbol* Cast(Value* obj); - - private: - Symbol(); - static void CheckCast(Value* obj); -}; - - -/** - * A private symbol - * - * This is an experimental feature. Use at your own risk. - */ -class V8_EXPORT Private : public Data { - public: - /** - * Returns the print name string of the private symbol, or undefined if none. - */ - Local<Value> Name() const; - - /** - * Create a private symbol. If name is not empty, it will be the description. - */ - static Local<Private> New(Isolate* isolate, - Local<String> name = Local<String>()); - - /** - * Retrieve a global private symbol. If a symbol with this name has not - * been retrieved in the same isolate before, it is created. - * Note that private symbols created this way are never collected, so - * they should only be used for statically fixed properties. - * Also, there is only one global name space for the names used as keys. - * To minimize the potential for clashes, use qualified names as keys, - * e.g., "Class#property". - */ - static Local<Private> ForApi(Isolate* isolate, Local<String> name); - - private: - Private(); -}; - - -/** - * A JavaScript number value (ECMA-262, 4.3.20) - */ -class V8_EXPORT Number : public Primitive { - public: - double Value() const; - static Local<Number> New(Isolate* isolate, double value); - V8_INLINE static Number* Cast(v8::Value* obj); - private: - Number(); - static void CheckCast(v8::Value* obj); -}; - - -/** - * A JavaScript value representing a signed integer. - */ -class V8_EXPORT Integer : public Number { - public: - static Local<Integer> New(Isolate* isolate, int32_t value); - static Local<Integer> NewFromUnsigned(Isolate* isolate, uint32_t value); - int64_t Value() const; - V8_INLINE static Integer* Cast(v8::Value* obj); - private: - Integer(); - static void CheckCast(v8::Value* obj); -}; - - -/** - * A JavaScript value representing a 32-bit signed integer. - */ -class V8_EXPORT Int32 : public Integer { - public: - int32_t Value() const; - V8_INLINE static Int32* Cast(v8::Value* obj); - - private: - Int32(); - static void CheckCast(v8::Value* obj); -}; - - -/** - * A JavaScript value representing a 32-bit unsigned integer. - */ -class V8_EXPORT Uint32 : public Integer { - public: - uint32_t Value() const; - V8_INLINE static Uint32* Cast(v8::Value* obj); - - private: - Uint32(); - static void CheckCast(v8::Value* obj); -}; - -/** - * PropertyAttribute. - */ -enum PropertyAttribute { - /** None. **/ - None = 0, - /** ReadOnly, i.e., not writable. **/ - ReadOnly = 1 << 0, - /** DontEnum, i.e., not enumerable. **/ - DontEnum = 1 << 1, - /** DontDelete, i.e., not configurable. **/ - DontDelete = 1 << 2 -}; - -/** - * Accessor[Getter|Setter] are used as callback functions when - * setting|getting a particular property. See Object and ObjectTemplate's - * method SetAccessor. - */ -typedef void (*AccessorGetterCallback)( - Local<String> property, - const PropertyCallbackInfo<Value>& info); -typedef void (*AccessorNameGetterCallback)( - Local<Name> property, - const PropertyCallbackInfo<Value>& info); - - -typedef void (*AccessorSetterCallback)( - Local<String> property, - Local<Value> value, - const PropertyCallbackInfo<void>& info); -typedef void (*AccessorNameSetterCallback)( - Local<Name> property, - Local<Value> value, - const PropertyCallbackInfo<void>& info); - - -/** - * Access control specifications. - * - * Some accessors should be accessible across contexts. These - * accessors have an explicit access control parameter which specifies - * the kind of cross-context access that should be allowed. - * - * TODO(dcarney): Remove PROHIBITS_OVERWRITING as it is now unused. - */ -enum AccessControl { - DEFAULT = 0, - ALL_CAN_READ = 1, - ALL_CAN_WRITE = 1 << 1, - PROHIBITS_OVERWRITING = 1 << 2 -}; - -/** - * Property filter bits. They can be or'ed to build a composite filter. - */ -enum PropertyFilter { - ALL_PROPERTIES = 0, - ONLY_WRITABLE = 1, - ONLY_ENUMERABLE = 2, - ONLY_CONFIGURABLE = 4, - SKIP_STRINGS = 8, - SKIP_SYMBOLS = 16 -}; - -/** - * Keys/Properties filter enums: - * - * KeyCollectionMode limits the range of collected properties. kOwnOnly limits - * the collected properties to the given Object only. kIncludesPrototypes will - * include all keys of the objects's prototype chain as well. - */ -enum class KeyCollectionMode { kOwnOnly, kIncludePrototypes }; - -/** - * kIncludesIndices allows for integer indices to be collected, while - * kSkipIndices will exclude integer indicies from being collected. - */ -enum class IndexFilter { kIncludeIndices, kSkipIndices }; - -/** - * Integrity level for objects. - */ -enum class IntegrityLevel { kFrozen, kSealed }; - -/** - * A JavaScript object (ECMA-262, 4.3.3) - */ -class V8_EXPORT Object : public Value { - public: - V8_DEPRECATE_SOON("Use maybe version", - bool Set(Local<Value> key, Local<Value> value)); - V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, - Local<Value> key, Local<Value> value); - - V8_DEPRECATE_SOON("Use maybe version", - bool Set(uint32_t index, Local<Value> value)); - V8_WARN_UNUSED_RESULT Maybe<bool> Set(Local<Context> context, uint32_t index, - Local<Value> value); - - // Implements CreateDataProperty (ECMA-262, 7.3.4). - // - // Defines a configurable, writable, enumerable property with the given value - // on the object unless the property already exists and is not configurable - // or the object is not extensible. - // - // Returns true on success. - V8_WARN_UNUSED_RESULT Maybe<bool> CreateDataProperty(Local<Context> context, - Local<Name> key, - Local<Value> value); - V8_WARN_UNUSED_RESULT Maybe<bool> CreateDataProperty(Local<Context> context, - uint32_t index, - Local<Value> value); - - // Implements DefineOwnProperty. - // - // In general, CreateDataProperty will be faster, however, does not allow - // for specifying attributes. - // - // Returns true on success. - V8_WARN_UNUSED_RESULT Maybe<bool> DefineOwnProperty( - Local<Context> context, Local<Name> key, Local<Value> value, - PropertyAttribute attributes = None); - - // Implements Object.DefineProperty(O, P, Attributes), see Ecma-262 19.1.2.4. - // - // The defineProperty function is used to add an own property or - // update the attributes of an existing own property of an object. - // - // Both data and accessor descriptors can be used. - // - // In general, CreateDataProperty is faster, however, does not allow - // for specifying attributes or an accessor descriptor. - // - // The PropertyDescriptor can change when redefining a property. - // - // Returns true on success. - V8_WARN_UNUSED_RESULT Maybe<bool> DefineProperty( - Local<Context> context, Local<Name> key, PropertyDescriptor& descriptor); - - // Sets an own property on this object bypassing interceptors and - // overriding accessors or read-only properties. - // - // Note that if the object has an interceptor the property will be set - // locally, but since the interceptor takes precedence the local property - // will only be returned if the interceptor doesn't return a value. - // - // Note also that this only works for named properties. - V8_DEPRECATED("Use CreateDataProperty / DefineOwnProperty", - bool ForceSet(Local<Value> key, Local<Value> value, - PropertyAttribute attribs = None)); - V8_DEPRECATE_SOON("Use CreateDataProperty / DefineOwnProperty", - Maybe<bool> ForceSet(Local<Context> context, - Local<Value> key, Local<Value> value, - PropertyAttribute attribs = None)); - - V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(Local<Value> key)); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context, - Local<Value> key); - - V8_DEPRECATE_SOON("Use maybe version", Local<Value> Get(uint32_t index)); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context, - uint32_t index); - - /** - * Gets the property attributes of a property which can be None or - * any combination of ReadOnly, DontEnum and DontDelete. Returns - * None when the property doesn't exist. - */ - V8_DEPRECATED("Use maybe version", - PropertyAttribute GetPropertyAttributes(Local<Value> key)); - V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetPropertyAttributes( - Local<Context> context, Local<Value> key); - - /** - * Returns Object.getOwnPropertyDescriptor as per ES2016 section 19.1.2.6. - */ - V8_DEPRECATED("Use maybe version", - Local<Value> GetOwnPropertyDescriptor(Local<Name> key)); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetOwnPropertyDescriptor( - Local<Context> context, Local<Name> key); - - V8_DEPRECATE_SOON("Use maybe version", bool Has(Local<Value> key)); - /** - * Object::Has() calls the abstract operation HasProperty(O, P) described - * in ECMA-262, 7.3.10. Has() returns - * true, if the object has the property, either own or on the prototype chain. - * Interceptors, i.e., PropertyQueryCallbacks, are called if present. - * - * Has() has the same side effects as JavaScript's `variable in object`. - * For example, calling Has() on a revoked proxy will throw an exception. - * - * \note Has() converts the key to a name, which possibly calls back into - * JavaScript. - * - * See also v8::Object::HasOwnProperty() and - * v8::Object::HasRealNamedProperty(). - */ - V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, - Local<Value> key); - - V8_DEPRECATE_SOON("Use maybe version", bool Delete(Local<Value> key)); - V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context, - Local<Value> key); - - V8_DEPRECATED("Use maybe version", bool Has(uint32_t index)); - V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, - uint32_t index); - - V8_DEPRECATED("Use maybe version", bool Delete(uint32_t index)); - V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context, - uint32_t index); - - V8_DEPRECATED("Use maybe version", - bool SetAccessor(Local<String> name, - AccessorGetterCallback getter, - AccessorSetterCallback setter = 0, - Local<Value> data = Local<Value>(), - AccessControl settings = DEFAULT, - PropertyAttribute attribute = None)); - V8_DEPRECATED("Use maybe version", - bool SetAccessor(Local<Name> name, - AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter = 0, - Local<Value> data = Local<Value>(), - AccessControl settings = DEFAULT, - PropertyAttribute attribute = None)); - V8_WARN_UNUSED_RESULT Maybe<bool> SetAccessor(Local<Context> context, - Local<Name> name, - AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter = 0, - MaybeLocal<Value> data = MaybeLocal<Value>(), - AccessControl settings = DEFAULT, - PropertyAttribute attribute = None); - - void SetAccessorProperty(Local<Name> name, Local<Function> getter, - Local<Function> setter = Local<Function>(), - PropertyAttribute attribute = None, - AccessControl settings = DEFAULT); - - /** - * Sets a native data property like Template::SetNativeDataProperty, but - * this method sets on this object directly. - */ - V8_WARN_UNUSED_RESULT Maybe<bool> SetNativeDataProperty( - Local<Context> context, Local<Name> name, - AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter = nullptr, - Local<Value> data = Local<Value>(), PropertyAttribute attributes = None); - - /** - * Functionality for private properties. - * This is an experimental feature, use at your own risk. - * Note: Private properties are not inherited. Do not rely on this, since it - * may change. - */ - Maybe<bool> HasPrivate(Local<Context> context, Local<Private> key); - Maybe<bool> SetPrivate(Local<Context> context, Local<Private> key, - Local<Value> value); - Maybe<bool> DeletePrivate(Local<Context> context, Local<Private> key); - MaybeLocal<Value> GetPrivate(Local<Context> context, Local<Private> key); - - /** - * Returns an array containing the names of the enumerable properties - * of this object, including properties from prototype objects. The - * array returned by this method contains the same values as would - * be enumerated by a for-in statement over this object. - */ - V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetPropertyNames()); - V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames( - Local<Context> context); - V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetPropertyNames( - Local<Context> context, KeyCollectionMode mode, - PropertyFilter property_filter, IndexFilter index_filter); - - /** - * This function has the same functionality as GetPropertyNames but - * the returned array doesn't contain the names of properties from - * prototype objects. - */ - V8_DEPRECATE_SOON("Use maybe version", Local<Array> GetOwnPropertyNames()); - V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames( - Local<Context> context); - - /** - * Returns an array containing the names of the filtered properties - * of this object, including properties from prototype objects. The - * array returned by this method contains the same values as would - * be enumerated by a for-in statement over this object. - */ - V8_WARN_UNUSED_RESULT MaybeLocal<Array> GetOwnPropertyNames( - Local<Context> context, PropertyFilter filter); - - /** - * Get the prototype object. This does not skip objects marked to - * be skipped by __proto__ and it does not consult the security - * handler. - */ - Local<Value> GetPrototype(); - - /** - * Set the prototype object. This does not skip objects marked to - * be skipped by __proto__ and it does not consult the security - * handler. - */ - V8_DEPRECATED("Use maybe version", bool SetPrototype(Local<Value> prototype)); - V8_WARN_UNUSED_RESULT Maybe<bool> SetPrototype(Local<Context> context, - Local<Value> prototype); - - /** - * Finds an instance of the given function template in the prototype - * chain. - */ - Local<Object> FindInstanceInPrototypeChain(Local<FunctionTemplate> tmpl); - - /** - * Call builtin Object.prototype.toString on this object. - * This is different from Value::ToString() that may call - * user-defined toString function. This one does not. - */ - V8_DEPRECATED("Use maybe version", Local<String> ObjectProtoToString()); - V8_WARN_UNUSED_RESULT MaybeLocal<String> ObjectProtoToString( - Local<Context> context); - - /** - * Returns the name of the function invoked as a constructor for this object. - */ - Local<String> GetConstructorName(); - - /** - * Sets the integrity level of the object. - */ - Maybe<bool> SetIntegrityLevel(Local<Context> context, IntegrityLevel level); - - /** Gets the number of internal fields for this Object. */ - int InternalFieldCount(); - - /** Same as above, but works for Persistents */ - V8_INLINE static int InternalFieldCount( - const PersistentBase<Object>& object) { - return object.val_->InternalFieldCount(); - } - - /** Gets the value from an internal field. */ - V8_INLINE Local<Value> GetInternalField(int index); - - /** Sets the value in an internal field. */ - void SetInternalField(int index, Local<Value> value); - - /** - * Gets a 2-byte-aligned native pointer from an internal field. This field - * must have been set by SetAlignedPointerInInternalField, everything else - * leads to undefined behavior. - */ - V8_INLINE void* GetAlignedPointerFromInternalField(int index); - - /** Same as above, but works for Persistents */ - V8_INLINE static void* GetAlignedPointerFromInternalField( - const PersistentBase<Object>& object, int index) { - return object.val_->GetAlignedPointerFromInternalField(index); - } - - /** - * Sets a 2-byte-aligned native pointer in an internal field. To retrieve such - * a field, GetAlignedPointerFromInternalField must be used, everything else - * leads to undefined behavior. - */ - void SetAlignedPointerInInternalField(int index, void* value); - void SetAlignedPointerInInternalFields(int argc, int indices[], - void* values[]); - - // Testers for local properties. - V8_DEPRECATED("Use maybe version", bool HasOwnProperty(Local<String> key)); - - /** - * HasOwnProperty() is like JavaScript's Object.prototype.hasOwnProperty(). - * - * See also v8::Object::Has() and v8::Object::HasRealNamedProperty(). - */ - V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context, - Local<Name> key); - V8_WARN_UNUSED_RESULT Maybe<bool> HasOwnProperty(Local<Context> context, - uint32_t index); - V8_DEPRECATE_SOON("Use maybe version", - bool HasRealNamedProperty(Local<String> key)); - /** - * Use HasRealNamedProperty() if you want to check if an object has an own - * property without causing side effects, i.e., without calling interceptors. - * - * This function is similar to v8::Object::HasOwnProperty(), but it does not - * call interceptors. - * - * \note Consider using non-masking interceptors, i.e., the interceptors are - * not called if the receiver has the real named property. See - * `v8::PropertyHandlerFlags::kNonMasking`. - * - * See also v8::Object::Has(). - */ - V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedProperty(Local<Context> context, - Local<Name> key); - V8_DEPRECATE_SOON("Use maybe version", - bool HasRealIndexedProperty(uint32_t index)); - V8_WARN_UNUSED_RESULT Maybe<bool> HasRealIndexedProperty( - Local<Context> context, uint32_t index); - V8_DEPRECATE_SOON("Use maybe version", - bool HasRealNamedCallbackProperty(Local<String> key)); - V8_WARN_UNUSED_RESULT Maybe<bool> HasRealNamedCallbackProperty( - Local<Context> context, Local<Name> key); - - /** - * If result.IsEmpty() no real property was located in the prototype chain. - * This means interceptors in the prototype chain are not called. - */ - V8_DEPRECATED( - "Use maybe version", - Local<Value> GetRealNamedPropertyInPrototypeChain(Local<String> key)); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedPropertyInPrototypeChain( - Local<Context> context, Local<Name> key); - - /** - * Gets the property attributes of a real property in the prototype chain, - * which can be None or any combination of ReadOnly, DontEnum and DontDelete. - * Interceptors in the prototype chain are not called. - */ - V8_DEPRECATED( - "Use maybe version", - Maybe<PropertyAttribute> GetRealNamedPropertyAttributesInPrototypeChain( - Local<String> key)); - V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> - GetRealNamedPropertyAttributesInPrototypeChain(Local<Context> context, - Local<Name> key); - - /** - * If result.IsEmpty() no real property was located on the object or - * in the prototype chain. - * This means interceptors in the prototype chain are not called. - */ - V8_DEPRECATED("Use maybe version", - Local<Value> GetRealNamedProperty(Local<String> key)); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> GetRealNamedProperty( - Local<Context> context, Local<Name> key); - - /** - * Gets the property attributes of a real property which can be - * None or any combination of ReadOnly, DontEnum and DontDelete. - * Interceptors in the prototype chain are not called. - */ - V8_DEPRECATED("Use maybe version", - Maybe<PropertyAttribute> GetRealNamedPropertyAttributes( - Local<String> key)); - V8_WARN_UNUSED_RESULT Maybe<PropertyAttribute> GetRealNamedPropertyAttributes( - Local<Context> context, Local<Name> key); - - /** Tests for a named lookup interceptor.*/ - bool HasNamedLookupInterceptor(); - - /** Tests for an index lookup interceptor.*/ - bool HasIndexedLookupInterceptor(); - - /** - * Returns the identity hash for this object. The current implementation - * uses a hidden property on the object to store the identity hash. - * - * The return value will never be 0. Also, it is not guaranteed to be - * unique. - */ - int GetIdentityHash(); - - /** - * Clone this object with a fast but shallow copy. Values will point - * to the same values as the original object. - */ - // TODO(dcarney): take an isolate and optionally bail out? - Local<Object> Clone(); - - /** - * Returns the context in which the object was created. - */ - Local<Context> CreationContext(); - - /** Same as above, but works for Persistents */ - V8_INLINE static Local<Context> CreationContext( - const PersistentBase<Object>& object) { - return object.val_->CreationContext(); - } - - /** - * Checks whether a callback is set by the - * ObjectTemplate::SetCallAsFunctionHandler method. - * When an Object is callable this method returns true. - */ - bool IsCallable(); - - /** - * True if this object is a constructor. - */ - bool IsConstructor(); - - /** - * Call an Object as a function if a callback is set by the - * ObjectTemplate::SetCallAsFunctionHandler method. - */ - V8_DEPRECATED("Use maybe version", - Local<Value> CallAsFunction(Local<Value> recv, int argc, - Local<Value> argv[])); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsFunction(Local<Context> context, - Local<Value> recv, - int argc, - Local<Value> argv[]); - - /** - * Call an Object as a constructor if a callback is set by the - * ObjectTemplate::SetCallAsFunctionHandler method. - * Note: This method behaves like the Function::NewInstance method. - */ - V8_DEPRECATED("Use maybe version", - Local<Value> CallAsConstructor(int argc, Local<Value> argv[])); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> CallAsConstructor( - Local<Context> context, int argc, Local<Value> argv[]); - - /** - * Return the isolate to which the Object belongs to. - */ - V8_DEPRECATE_SOON("Keep track of isolate correctly", Isolate* GetIsolate()); - - static Local<Object> New(Isolate* isolate); - - V8_INLINE static Object* Cast(Value* obj); - - private: - Object(); - static void CheckCast(Value* obj); - Local<Value> SlowGetInternalField(int index); - void* SlowGetAlignedPointerFromInternalField(int index); -}; - - -/** - * An instance of the built-in array constructor (ECMA-262, 15.4.2). - */ -class V8_EXPORT Array : public Object { - public: - uint32_t Length() const; - - /** - * Clones an element at index |index|. Returns an empty - * handle if cloning fails (for any reason). - */ - V8_DEPRECATED("Cloning is not supported.", - Local<Object> CloneElementAt(uint32_t index)); - V8_DEPRECATED("Cloning is not supported.", - MaybeLocal<Object> CloneElementAt(Local<Context> context, - uint32_t index)); - - /** - * Creates a JavaScript array with the given length. If the length - * is negative the returned array will have length 0. - */ - static Local<Array> New(Isolate* isolate, int length = 0); - - V8_INLINE static Array* Cast(Value* obj); - private: - Array(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of the built-in Map constructor (ECMA-262, 6th Edition, 23.1.1). - */ -class V8_EXPORT Map : public Object { - public: - size_t Size() const; - void Clear(); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> Get(Local<Context> context, - Local<Value> key); - V8_WARN_UNUSED_RESULT MaybeLocal<Map> Set(Local<Context> context, - Local<Value> key, - Local<Value> value); - V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, - Local<Value> key); - V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context, - Local<Value> key); - - /** - * Returns an array of length Size() * 2, where index N is the Nth key and - * index N + 1 is the Nth value. - */ - Local<Array> AsArray() const; - - /** - * Creates a new empty Map. - */ - static Local<Map> New(Isolate* isolate); - - V8_INLINE static Map* Cast(Value* obj); - - private: - Map(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of the built-in Set constructor (ECMA-262, 6th Edition, 23.2.1). - */ -class V8_EXPORT Set : public Object { - public: - size_t Size() const; - void Clear(); - V8_WARN_UNUSED_RESULT MaybeLocal<Set> Add(Local<Context> context, - Local<Value> key); - V8_WARN_UNUSED_RESULT Maybe<bool> Has(Local<Context> context, - Local<Value> key); - V8_WARN_UNUSED_RESULT Maybe<bool> Delete(Local<Context> context, - Local<Value> key); - - /** - * Returns an array of the keys in this Set. - */ - Local<Array> AsArray() const; - - /** - * Creates a new empty Set. - */ - static Local<Set> New(Isolate* isolate); - - V8_INLINE static Set* Cast(Value* obj); - - private: - Set(); - static void CheckCast(Value* obj); -}; - - -template<typename T> -class ReturnValue { - public: - template <class S> V8_INLINE ReturnValue(const ReturnValue<S>& that) - : value_(that.value_) { - TYPE_CHECK(T, S); - } - // Local setters - template <typename S> - V8_INLINE V8_DEPRECATE_SOON("Use Global<> instead", - void Set(const Persistent<S>& handle)); - template <typename S> - V8_INLINE void Set(const Global<S>& handle); - template <typename S> - V8_INLINE void Set(const Local<S> handle); - // Fast primitive setters - V8_INLINE void Set(bool value); - V8_INLINE void Set(double i); - V8_INLINE void Set(int32_t i); - V8_INLINE void Set(uint32_t i); - // Fast JS primitive setters - V8_INLINE void SetNull(); - V8_INLINE void SetUndefined(); - V8_INLINE void SetEmptyString(); - // Convenience getter for Isolate - V8_INLINE Isolate* GetIsolate() const; - - // Pointer setter: Uncompilable to prevent inadvertent misuse. - template <typename S> - V8_INLINE void Set(S* whatever); - - // Getter. Creates a new Local<> so it comes with a certain performance - // hit. If the ReturnValue was not yet set, this will return the undefined - // value. - V8_INLINE Local<Value> Get() const; - - private: - template<class F> friend class ReturnValue; - template<class F> friend class FunctionCallbackInfo; - template<class F> friend class PropertyCallbackInfo; - template <class F, class G, class H> - friend class PersistentValueMapBase; - V8_INLINE void SetInternal(internal::Object* value) { *value_ = value; } - V8_INLINE internal::Object* GetDefaultValue(); - V8_INLINE explicit ReturnValue(internal::Object** slot); - internal::Object** value_; -}; - - -/** - * The argument information given to function call callbacks. This - * class provides access to information about the context of the call, - * including the receiver, the number and values of arguments, and - * the holder of the function. - */ -template<typename T> -class FunctionCallbackInfo { - public: - /** The number of available arguments. */ - V8_INLINE int Length() const; - /** Accessor for the available arguments. */ - V8_INLINE Local<Value> operator[](int i) const; - V8_INLINE V8_DEPRECATED("Use Data() to explicitly pass Callee instead", - Local<Function> Callee() const); - /** Returns the receiver. This corresponds to the "this" value. */ - V8_INLINE Local<Object> This() const; - /** - * If the callback was created without a Signature, this is the same - * value as This(). If there is a signature, and the signature didn't match - * This() but one of its hidden prototypes, this will be the respective - * hidden prototype. - * - * Note that this is not the prototype of This() on which the accessor - * referencing this callback was found (which in V8 internally is often - * referred to as holder [sic]). - */ - V8_INLINE Local<Object> Holder() const; - /** For construct calls, this returns the "new.target" value. */ - V8_INLINE Local<Value> NewTarget() const; - /** Indicates whether this is a regular call or a construct call. */ - V8_INLINE bool IsConstructCall() const; - /** The data argument specified when creating the callback. */ - V8_INLINE Local<Value> Data() const; - /** The current Isolate. */ - V8_INLINE Isolate* GetIsolate() const; - /** The ReturnValue for the call. */ - V8_INLINE ReturnValue<T> GetReturnValue() const; - // This shouldn't be public, but the arm compiler needs it. - static const int kArgsLength = 8; - - protected: - friend class internal::FunctionCallbackArguments; - friend class internal::CustomArguments<FunctionCallbackInfo>; - friend class debug::ConsoleCallArguments; - static const int kHolderIndex = 0; - static const int kIsolateIndex = 1; - static const int kReturnValueDefaultValueIndex = 2; - static const int kReturnValueIndex = 3; - static const int kDataIndex = 4; - static const int kCalleeIndex = 5; - static const int kContextSaveIndex = 6; - static const int kNewTargetIndex = 7; - - V8_INLINE FunctionCallbackInfo(internal::Object** implicit_args, - internal::Object** values, int length); - internal::Object** implicit_args_; - internal::Object** values_; - int length_; -}; - - -/** - * The information passed to a property callback about the context - * of the property access. - */ -template<typename T> -class PropertyCallbackInfo { - public: - /** - * \return The isolate of the property access. - */ - V8_INLINE Isolate* GetIsolate() const; - - /** - * \return The data set in the configuration, i.e., in - * `NamedPropertyHandlerConfiguration` or - * `IndexedPropertyHandlerConfiguration.` - */ - V8_INLINE Local<Value> Data() const; - - /** - * \return The receiver. In many cases, this is the object on which the - * property access was intercepted. When using - * `Reflect.get`, `Function.prototype.call`, or similar functions, it is the - * object passed in as receiver or thisArg. - * - * \code - * void GetterCallback(Local<Name> name, - * const v8::PropertyCallbackInfo<v8::Value>& info) { - * auto context = info.GetIsolate()->GetCurrentContext(); - * - * v8::Local<v8::Value> a_this = - * info.This() - * ->GetRealNamedProperty(context, v8_str("a")) - * .ToLocalChecked(); - * v8::Local<v8::Value> a_holder = - * info.Holder() - * ->GetRealNamedProperty(context, v8_str("a")) - * .ToLocalChecked(); - * - * CHECK(v8_str("r")->Equals(context, a_this).FromJust()); - * CHECK(v8_str("obj")->Equals(context, a_holder).FromJust()); - * - * info.GetReturnValue().Set(name); - * } - * - * v8::Local<v8::FunctionTemplate> templ = - * v8::FunctionTemplate::New(isolate); - * templ->InstanceTemplate()->SetHandler( - * v8::NamedPropertyHandlerConfiguration(GetterCallback)); - * LocalContext env; - * env->Global() - * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - * .ToLocalChecked() - * ->NewInstance(env.local()) - * .ToLocalChecked()) - * .FromJust(); - * - * CompileRun("obj.a = 'obj'; var r = {a: 'r'}; Reflect.get(obj, 'x', r)"); - * \endcode - */ - V8_INLINE Local<Object> This() const; - - /** - * \return The object in the prototype chain of the receiver that has the - * interceptor. Suppose you have `x` and its prototype is `y`, and `y` - * has an interceptor. Then `info.This()` is `x` and `info.Holder()` is `y`. - * The Holder() could be a hidden object (the global object, rather - * than the global proxy). - * - * \note For security reasons, do not pass the object back into the runtime. - */ - V8_INLINE Local<Object> Holder() const; - - /** - * \return The return value of the callback. - * Can be changed by calling Set(). - * \code - * info.GetReturnValue().Set(...) - * \endcode - * - */ - V8_INLINE ReturnValue<T> GetReturnValue() const; - - /** - * \return True if the intercepted function should throw if an error occurs. - * Usually, `true` corresponds to `'use strict'`. - * - * \note Always `false` when intercepting `Reflect.set()` - * independent of the language mode. - */ - V8_INLINE bool ShouldThrowOnError() const; - - // This shouldn't be public, but the arm compiler needs it. - static const int kArgsLength = 7; - - protected: - friend class MacroAssembler; - friend class internal::PropertyCallbackArguments; - friend class internal::CustomArguments<PropertyCallbackInfo>; - static const int kShouldThrowOnErrorIndex = 0; - static const int kHolderIndex = 1; - static const int kIsolateIndex = 2; - static const int kReturnValueDefaultValueIndex = 3; - static const int kReturnValueIndex = 4; - static const int kDataIndex = 5; - static const int kThisIndex = 6; - - V8_INLINE PropertyCallbackInfo(internal::Object** args) : args_(args) {} - internal::Object** args_; -}; - - -typedef void (*FunctionCallback)(const FunctionCallbackInfo<Value>& info); - -enum class ConstructorBehavior { kThrow, kAllow }; - -/** - * A JavaScript function object (ECMA-262, 15.3). - */ -class V8_EXPORT Function : public Object { - public: - /** - * Create a function in the current execution context - * for a given FunctionCallback. - */ - static MaybeLocal<Function> New( - Local<Context> context, FunctionCallback callback, - Local<Value> data = Local<Value>(), int length = 0, - ConstructorBehavior behavior = ConstructorBehavior::kAllow); - static V8_DEPRECATE_SOON( - "Use maybe version", - Local<Function> New(Isolate* isolate, FunctionCallback callback, - Local<Value> data = Local<Value>(), int length = 0)); - - V8_DEPRECATED("Use maybe version", - Local<Object> NewInstance(int argc, Local<Value> argv[]) const); - V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance( - Local<Context> context, int argc, Local<Value> argv[]) const; - - V8_DEPRECATED("Use maybe version", Local<Object> NewInstance() const); - V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance( - Local<Context> context) const { - return NewInstance(context, 0, nullptr); - } - - V8_DEPRECATE_SOON("Use maybe version", - Local<Value> Call(Local<Value> recv, int argc, - Local<Value> argv[])); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> Call(Local<Context> context, - Local<Value> recv, int argc, - Local<Value> argv[]); - - void SetName(Local<String> name); - Local<Value> GetName() const; - - /** - * Name inferred from variable or property assignment of this function. - * Used to facilitate debugging and profiling of JavaScript code written - * in an OO style, where many functions are anonymous but are assigned - * to object properties. - */ - Local<Value> GetInferredName() const; - - /** - * displayName if it is set, otherwise name if it is configured, otherwise - * function name, otherwise inferred name. - */ - Local<Value> GetDebugName() const; - - /** - * User-defined name assigned to the "displayName" property of this function. - * Used to facilitate debugging and profiling of JavaScript code. - */ - Local<Value> GetDisplayName() const; - - /** - * Returns zero based line number of function body and - * kLineOffsetNotFound if no information available. - */ - int GetScriptLineNumber() const; - /** - * Returns zero based column number of function body and - * kLineOffsetNotFound if no information available. - */ - int GetScriptColumnNumber() const; - - /** - * Tells whether this function is builtin. - */ - V8_DEPRECATED("this should no longer be used.", bool IsBuiltin() const); - - /** - * Returns scriptId. - */ - int ScriptId() const; - - /** - * Returns the original function if this function is bound, else returns - * v8::Undefined. - */ - Local<Value> GetBoundFunction() const; - - ScriptOrigin GetScriptOrigin() const; - V8_INLINE static Function* Cast(Value* obj); - static const int kLineOffsetNotFound; - - private: - Function(); - static void CheckCast(Value* obj); -}; - -#ifndef V8_PROMISE_INTERNAL_FIELD_COUNT -// The number of required internal fields can be defined by embedder. -#define V8_PROMISE_INTERNAL_FIELD_COUNT 0 -#endif - -/** - * An instance of the built-in Promise constructor (ES6 draft). - */ -class V8_EXPORT Promise : public Object { - public: - /** - * State of the promise. Each value corresponds to one of the possible values - * of the [[PromiseState]] field. - */ - enum PromiseState { kPending, kFulfilled, kRejected }; - - class V8_EXPORT Resolver : public Object { - public: - /** - * Create a new resolver, along with an associated promise in pending state. - */ - static V8_DEPRECATE_SOON("Use maybe version", - Local<Resolver> New(Isolate* isolate)); - static V8_WARN_UNUSED_RESULT MaybeLocal<Resolver> New( - Local<Context> context); - - /** - * Extract the associated promise. - */ - Local<Promise> GetPromise(); - - /** - * Resolve/reject the associated promise with a given value. - * Ignored if the promise is no longer pending. - */ - V8_DEPRECATE_SOON("Use maybe version", void Resolve(Local<Value> value)); - V8_WARN_UNUSED_RESULT Maybe<bool> Resolve(Local<Context> context, - Local<Value> value); - - V8_DEPRECATE_SOON("Use maybe version", void Reject(Local<Value> value)); - V8_WARN_UNUSED_RESULT Maybe<bool> Reject(Local<Context> context, - Local<Value> value); - - V8_INLINE static Resolver* Cast(Value* obj); - - private: - Resolver(); - static void CheckCast(Value* obj); - }; - - /** - * Register a resolution/rejection handler with a promise. - * The handler is given the respective resolution/rejection value as - * an argument. If the promise is already resolved/rejected, the handler is - * invoked at the end of turn. - */ - V8_DEPRECATED("Use maybe version", - Local<Promise> Catch(Local<Function> handler)); - V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Catch(Local<Context> context, - Local<Function> handler); - - V8_DEPRECATED("Use maybe version", - Local<Promise> Then(Local<Function> handler)); - V8_WARN_UNUSED_RESULT MaybeLocal<Promise> Then(Local<Context> context, - Local<Function> handler); - - /** - * Returns true if the promise has at least one derived promise, and - * therefore resolve/reject handlers (including default handler). - */ - bool HasHandler(); - - /** - * Returns the content of the [[PromiseResult]] field. The Promise must not - * be pending. - */ - Local<Value> Result(); - - /** - * Returns the value of the [[PromiseState]] field. - */ - PromiseState State(); - - V8_INLINE static Promise* Cast(Value* obj); - - static const int kEmbedderFieldCount = V8_PROMISE_INTERNAL_FIELD_COUNT; - - private: - Promise(); - static void CheckCast(Value* obj); -}; - -/** - * An instance of a Property Descriptor, see Ecma-262 6.2.4. - * - * Properties in a descriptor are present or absent. If you do not set - * `enumerable`, `configurable`, and `writable`, they are absent. If `value`, - * `get`, or `set` are absent, but you must specify them in the constructor, use - * empty handles. - * - * Accessors `get` and `set` must be callable or undefined if they are present. - * - * \note Only query properties if they are present, i.e., call `x()` only if - * `has_x()` returns true. - * - * \code - * // var desc = {writable: false} - * v8::PropertyDescriptor d(Local<Value>()), false); - * d.value(); // error, value not set - * if (d.has_writable()) { - * d.writable(); // false - * } - * - * // var desc = {value: undefined} - * v8::PropertyDescriptor d(v8::Undefined(isolate)); - * - * // var desc = {get: undefined} - * v8::PropertyDescriptor d(v8::Undefined(isolate), Local<Value>())); - * \endcode - */ -class V8_EXPORT PropertyDescriptor { - public: - // GenericDescriptor - PropertyDescriptor(); - - // DataDescriptor - PropertyDescriptor(Local<Value> value); - - // DataDescriptor with writable property - PropertyDescriptor(Local<Value> value, bool writable); - - // AccessorDescriptor - PropertyDescriptor(Local<Value> get, Local<Value> set); - - ~PropertyDescriptor(); - - Local<Value> value() const; - bool has_value() const; - - Local<Value> get() const; - bool has_get() const; - Local<Value> set() const; - bool has_set() const; - - void set_enumerable(bool enumerable); - bool enumerable() const; - bool has_enumerable() const; - - void set_configurable(bool configurable); - bool configurable() const; - bool has_configurable() const; - - bool writable() const; - bool has_writable() const; - - struct PrivateData; - PrivateData* get_private() const { return private_; } - - PropertyDescriptor(const PropertyDescriptor&) = delete; - void operator=(const PropertyDescriptor&) = delete; - - private: - PrivateData* private_; -}; - -/** - * An instance of the built-in Proxy constructor (ECMA-262, 6th Edition, - * 26.2.1). - */ -class V8_EXPORT Proxy : public Object { - public: - Local<Object> GetTarget(); - Local<Value> GetHandler(); - bool IsRevoked(); - void Revoke(); - - /** - * Creates a new Proxy for the target object. - */ - static MaybeLocal<Proxy> New(Local<Context> context, - Local<Object> local_target, - Local<Object> local_handler); - - V8_INLINE static Proxy* Cast(Value* obj); - - private: - Proxy(); - static void CheckCast(Value* obj); -}; - -// TODO(mtrofin): rename WasmCompiledModule to WasmModuleObject, for -// consistency with internal APIs. -class V8_EXPORT WasmCompiledModule : public Object { - public: - typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> SerializedModule; - // A buffer that is owned by the caller. - typedef std::pair<const uint8_t*, size_t> CallerOwnedBuffer; - - // An opaque, native heap object for transferring wasm modules. It - // supports move semantics, and does not support copy semantics. - class TransferrableModule final { - public: - TransferrableModule(TransferrableModule&& src) = default; - TransferrableModule(const TransferrableModule& src) = delete; - - TransferrableModule& operator=(TransferrableModule&& src) = default; - TransferrableModule& operator=(const TransferrableModule& src) = delete; - - private: - typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> OwnedBuffer; - friend class WasmCompiledModule; - TransferrableModule(OwnedBuffer&& code, OwnedBuffer&& bytes) - : compiled_code(std::move(code)), wire_bytes(std::move(bytes)) {} - - OwnedBuffer compiled_code = {nullptr, 0}; - OwnedBuffer wire_bytes = {nullptr, 0}; - }; - - // Get an in-memory, non-persistable, and context-independent (meaning, - // suitable for transfer to another Isolate and Context) representation - // of this wasm compiled module. - TransferrableModule GetTransferrableModule(); - - // Efficiently re-create a WasmCompiledModule, without recompiling, from - // a TransferrableModule. - static MaybeLocal<WasmCompiledModule> FromTransferrableModule( - Isolate* isolate, const TransferrableModule&); - - // Get the wasm-encoded bytes that were used to compile this module. - Local<String> GetWasmWireBytes(); - - // Serialize the compiled module. The serialized data does not include the - // uncompiled bytes. - SerializedModule Serialize(); - - // If possible, deserialize the module, otherwise compile it from the provided - // uncompiled bytes. - static MaybeLocal<WasmCompiledModule> DeserializeOrCompile( - Isolate* isolate, const CallerOwnedBuffer& serialized_module, - const CallerOwnedBuffer& wire_bytes); - V8_INLINE static WasmCompiledModule* Cast(Value* obj); - - private: - // TODO(ahaas): please remove the friend once streamed compilation is - // implemented - friend class WasmModuleObjectBuilder; - - static MaybeLocal<WasmCompiledModule> Deserialize( - Isolate* isolate, const CallerOwnedBuffer& serialized_module, - const CallerOwnedBuffer& wire_bytes); - static MaybeLocal<WasmCompiledModule> Compile(Isolate* isolate, - const uint8_t* start, - size_t length); - static CallerOwnedBuffer AsCallerOwned( - const TransferrableModule::OwnedBuffer& buff) { - return {buff.first.get(), buff.second}; - } - - WasmCompiledModule(); - static void CheckCast(Value* obj); -}; - -class V8_EXPORT WasmModuleObjectBuilder final { - public: - WasmModuleObjectBuilder(Isolate* isolate) : isolate_(isolate) {} - // The buffer passed into OnBytesReceived is owned by the caller. - void OnBytesReceived(const uint8_t*, size_t size); - MaybeLocal<WasmCompiledModule> Finish(); - - private: - Isolate* isolate_ = nullptr; - // TODO(ahaas): We probably need none of this below here once streamed - // compilation is implemented. - typedef std::pair<std::unique_ptr<const uint8_t[]>, size_t> Buffer; - - // Disable copy semantics *in this implementation*. We can choose to - // relax this, albeit it's not clear why. - WasmModuleObjectBuilder(const WasmModuleObjectBuilder&) = delete; - WasmModuleObjectBuilder(WasmModuleObjectBuilder&&) = default; - WasmModuleObjectBuilder& operator=(const WasmModuleObjectBuilder&) = delete; - WasmModuleObjectBuilder& operator=(WasmModuleObjectBuilder&&) = default; - - std::vector<Buffer> received_buffers_; - size_t total_size_ = 0; -}; - -#ifndef V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT -// The number of required internal fields can be defined by embedder. -#define V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT 2 -#endif - - -enum class ArrayBufferCreationMode { kInternalized, kExternalized }; - - -/** - * An instance of the built-in ArrayBuffer constructor (ES6 draft 15.13.5). - */ -class V8_EXPORT ArrayBuffer : public Object { - public: - /** - * A thread-safe allocator that V8 uses to allocate |ArrayBuffer|'s memory. - * The allocator is a global V8 setting. It has to be set via - * Isolate::CreateParams. - * - * Memory allocated through this allocator by V8 is accounted for as external - * memory by V8. Note that V8 keeps track of the memory for all internalized - * |ArrayBuffer|s. Responsibility for tracking external memory (using - * Isolate::AdjustAmountOfExternalAllocatedMemory) is handed over to the - * embedder upon externalization and taken over upon internalization (creating - * an internalized buffer from an existing buffer). - * - * Note that it is unsafe to call back into V8 from any of the allocator - * functions. - */ - class V8_EXPORT Allocator { // NOLINT - public: - virtual ~Allocator() {} - - /** - * Allocate |length| bytes. Return NULL if allocation is not successful. - * Memory should be initialized to zeroes. - */ - virtual void* Allocate(size_t length) = 0; - - /** - * Allocate |length| bytes. Return NULL if allocation is not successful. - * Memory does not have to be initialized. - */ - virtual void* AllocateUninitialized(size_t length) = 0; - - /** - * Reserved |length| bytes, but do not commit the memory. Must call - * |SetProtection| to make memory accessible. - */ - // TODO(eholk): make this pure virtual once blink implements this. - virtual void* Reserve(size_t length); - - /** - * Free the memory block of size |length|, pointed to by |data|. - * That memory is guaranteed to be previously allocated by |Allocate|. - */ - virtual void Free(void* data, size_t length) = 0; - - enum class AllocationMode { kNormal, kReservation }; - - /** - * Free the memory block of size |length|, pointed to by |data|. - * That memory is guaranteed to be previously allocated by |Allocate| or - * |Reserve|, depending on |mode|. - */ - // TODO(eholk): make this pure virtual once blink implements this. - virtual void Free(void* data, size_t length, AllocationMode mode); - - enum class Protection { kNoAccess, kReadWrite }; - - /** - * Change the protection on a region of memory. - * - * On platforms that make a distinction between reserving and committing - * memory, changing the protection to kReadWrite must also ensure the memory - * is committed. - */ - // TODO(eholk): make this pure virtual once blink implements this. - virtual void SetProtection(void* data, size_t length, - Protection protection); - - /** - * malloc/free based convenience allocator. - * - * Caller takes ownership, i.e. the returned object needs to be freed using - * |delete allocator| once it is no longer in use. - */ - static Allocator* NewDefaultAllocator(); - }; - - /** - * The contents of an |ArrayBuffer|. Externalization of |ArrayBuffer| - * returns an instance of this class, populated, with a pointer to data - * and byte length. - * - * The Data pointer of ArrayBuffer::Contents is always allocated with - * Allocator::Allocate that is set via Isolate::CreateParams. - */ - class V8_EXPORT Contents { // NOLINT - public: - Contents() : data_(NULL), byte_length_(0) {} - - void* Data() const { return data_; } - size_t ByteLength() const { return byte_length_; } - - private: - void* data_; - size_t byte_length_; - - friend class ArrayBuffer; - }; - - - /** - * Data length in bytes. - */ - size_t ByteLength() const; - - /** - * Create a new ArrayBuffer. Allocate |byte_length| bytes. - * Allocated memory will be owned by a created ArrayBuffer and - * will be deallocated when it is garbage-collected, - * unless the object is externalized. - */ - static Local<ArrayBuffer> New(Isolate* isolate, size_t byte_length); - - /** - * Create a new ArrayBuffer over an existing memory block. - * The created array buffer is by default immediately in externalized state. - * In externalized state, the memory block will not be reclaimed when a - * created ArrayBuffer is garbage-collected. - * In internalized state, the memory block will be released using - * |Allocator::Free| once all ArrayBuffers referencing it are collected by - * the garbage collector. - */ - static Local<ArrayBuffer> New( - Isolate* isolate, void* data, size_t byte_length, - ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); - - /** - * Returns true if ArrayBuffer is externalized, that is, does not - * own its memory block. - */ - bool IsExternal() const; - - /** - * Returns true if this ArrayBuffer may be neutered. - */ - bool IsNeuterable() const; - - /** - * Neuters this ArrayBuffer and all its views (typed arrays). - * Neutering sets the byte length of the buffer and all typed arrays to zero, - * preventing JavaScript from ever accessing underlying backing store. - * ArrayBuffer should have been externalized and must be neuterable. - */ - void Neuter(); - - /** - * Make this ArrayBuffer external. The pointer to underlying memory block - * and byte length are returned as |Contents| structure. After ArrayBuffer - * had been externalized, it does no longer own the memory block. The caller - * should take steps to free memory when it is no longer needed. - * - * The memory block is guaranteed to be allocated with |Allocator::Allocate| - * that has been set via Isolate::CreateParams. - */ - Contents Externalize(); - - /** - * Get a pointer to the ArrayBuffer's underlying memory block without - * externalizing it. If the ArrayBuffer is not externalized, this pointer - * will become invalid as soon as the ArrayBuffer gets garbage collected. - * - * The embedder should make sure to hold a strong reference to the - * ArrayBuffer while accessing this pointer. - * - * The memory block is guaranteed to be allocated with |Allocator::Allocate|. - */ - Contents GetContents(); - - V8_INLINE static ArrayBuffer* Cast(Value* obj); - - static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; - static const int kEmbedderFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; - - private: - ArrayBuffer(); - static void CheckCast(Value* obj); -}; - - -#ifndef V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT -// The number of required internal fields can be defined by embedder. -#define V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT 2 -#endif - - -/** - * A base class for an instance of one of "views" over ArrayBuffer, - * including TypedArrays and DataView (ES6 draft 15.13). - */ -class V8_EXPORT ArrayBufferView : public Object { - public: - /** - * Returns underlying ArrayBuffer. - */ - Local<ArrayBuffer> Buffer(); - /** - * Byte offset in |Buffer|. - */ - size_t ByteOffset(); - /** - * Size of a view in bytes. - */ - size_t ByteLength(); - - /** - * Copy the contents of the ArrayBufferView's buffer to an embedder defined - * memory without additional overhead that calling ArrayBufferView::Buffer - * might incur. - * - * Will write at most min(|byte_length|, ByteLength) bytes starting at - * ByteOffset of the underlying buffer to the memory starting at |dest|. - * Returns the number of bytes actually written. - */ - size_t CopyContents(void* dest, size_t byte_length); - - /** - * Returns true if ArrayBufferView's backing ArrayBuffer has already been - * allocated. - */ - bool HasBuffer() const; - - V8_INLINE static ArrayBufferView* Cast(Value* obj); - - static const int kInternalFieldCount = - V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; - static const int kEmbedderFieldCount = - V8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT; - - private: - ArrayBufferView(); - static void CheckCast(Value* obj); -}; - - -/** - * A base class for an instance of TypedArray series of constructors - * (ES6 draft 15.13.6). - */ -class V8_EXPORT TypedArray : public ArrayBufferView { - public: - /** - * Number of elements in this typed array - * (e.g. for Int16Array, |ByteLength|/2). - */ - size_t Length(); - - V8_INLINE static TypedArray* Cast(Value* obj); - - private: - TypedArray(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of Uint8Array constructor (ES6 draft 15.13.6). - */ -class V8_EXPORT Uint8Array : public TypedArray { - public: - static Local<Uint8Array> New(Local<ArrayBuffer> array_buffer, - size_t byte_offset, size_t length); - static Local<Uint8Array> New(Local<SharedArrayBuffer> shared_array_buffer, - size_t byte_offset, size_t length); - V8_INLINE static Uint8Array* Cast(Value* obj); - - private: - Uint8Array(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of Uint8ClampedArray constructor (ES6 draft 15.13.6). - */ -class V8_EXPORT Uint8ClampedArray : public TypedArray { - public: - static Local<Uint8ClampedArray> New(Local<ArrayBuffer> array_buffer, - size_t byte_offset, size_t length); - static Local<Uint8ClampedArray> New( - Local<SharedArrayBuffer> shared_array_buffer, size_t byte_offset, - size_t length); - V8_INLINE static Uint8ClampedArray* Cast(Value* obj); - - private: - Uint8ClampedArray(); - static void CheckCast(Value* obj); -}; - -/** - * An instance of Int8Array constructor (ES6 draft 15.13.6). - */ -class V8_EXPORT Int8Array : public TypedArray { - public: - static Local<Int8Array> New(Local<ArrayBuffer> array_buffer, - size_t byte_offset, size_t length); - static Local<Int8Array> New(Local<SharedArrayBuffer> shared_array_buffer, - size_t byte_offset, size_t length); - V8_INLINE static Int8Array* Cast(Value* obj); - - private: - Int8Array(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of Uint16Array constructor (ES6 draft 15.13.6). - */ -class V8_EXPORT Uint16Array : public TypedArray { - public: - static Local<Uint16Array> New(Local<ArrayBuffer> array_buffer, - size_t byte_offset, size_t length); - static Local<Uint16Array> New(Local<SharedArrayBuffer> shared_array_buffer, - size_t byte_offset, size_t length); - V8_INLINE static Uint16Array* Cast(Value* obj); - - private: - Uint16Array(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of Int16Array constructor (ES6 draft 15.13.6). - */ -class V8_EXPORT Int16Array : public TypedArray { - public: - static Local<Int16Array> New(Local<ArrayBuffer> array_buffer, - size_t byte_offset, size_t length); - static Local<Int16Array> New(Local<SharedArrayBuffer> shared_array_buffer, - size_t byte_offset, size_t length); - V8_INLINE static Int16Array* Cast(Value* obj); - - private: - Int16Array(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of Uint32Array constructor (ES6 draft 15.13.6). - */ -class V8_EXPORT Uint32Array : public TypedArray { - public: - static Local<Uint32Array> New(Local<ArrayBuffer> array_buffer, - size_t byte_offset, size_t length); - static Local<Uint32Array> New(Local<SharedArrayBuffer> shared_array_buffer, - size_t byte_offset, size_t length); - V8_INLINE static Uint32Array* Cast(Value* obj); - - private: - Uint32Array(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of Int32Array constructor (ES6 draft 15.13.6). - */ -class V8_EXPORT Int32Array : public TypedArray { - public: - static Local<Int32Array> New(Local<ArrayBuffer> array_buffer, - size_t byte_offset, size_t length); - static Local<Int32Array> New(Local<SharedArrayBuffer> shared_array_buffer, - size_t byte_offset, size_t length); - V8_INLINE static Int32Array* Cast(Value* obj); - - private: - Int32Array(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of Float32Array constructor (ES6 draft 15.13.6). - */ -class V8_EXPORT Float32Array : public TypedArray { - public: - static Local<Float32Array> New(Local<ArrayBuffer> array_buffer, - size_t byte_offset, size_t length); - static Local<Float32Array> New(Local<SharedArrayBuffer> shared_array_buffer, - size_t byte_offset, size_t length); - V8_INLINE static Float32Array* Cast(Value* obj); - - private: - Float32Array(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of Float64Array constructor (ES6 draft 15.13.6). - */ -class V8_EXPORT Float64Array : public TypedArray { - public: - static Local<Float64Array> New(Local<ArrayBuffer> array_buffer, - size_t byte_offset, size_t length); - static Local<Float64Array> New(Local<SharedArrayBuffer> shared_array_buffer, - size_t byte_offset, size_t length); - V8_INLINE static Float64Array* Cast(Value* obj); - - private: - Float64Array(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of DataView constructor (ES6 draft 15.13.7). - */ -class V8_EXPORT DataView : public ArrayBufferView { - public: - static Local<DataView> New(Local<ArrayBuffer> array_buffer, - size_t byte_offset, size_t length); - static Local<DataView> New(Local<SharedArrayBuffer> shared_array_buffer, - size_t byte_offset, size_t length); - V8_INLINE static DataView* Cast(Value* obj); - - private: - DataView(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of the built-in SharedArrayBuffer constructor. - * This API is experimental and may change significantly. - */ -class V8_EXPORT SharedArrayBuffer : public Object { - public: - /** - * The contents of an |SharedArrayBuffer|. Externalization of - * |SharedArrayBuffer| returns an instance of this class, populated, with a - * pointer to data and byte length. - * - * The Data pointer of SharedArrayBuffer::Contents is always allocated with - * |ArrayBuffer::Allocator::Allocate| by the allocator specified in - * v8::Isolate::CreateParams::array_buffer_allocator. - * - * This API is experimental and may change significantly. - */ - class V8_EXPORT Contents { // NOLINT - public: - Contents() : data_(NULL), byte_length_(0) {} - - void* Data() const { return data_; } - size_t ByteLength() const { return byte_length_; } - - private: - void* data_; - size_t byte_length_; - - friend class SharedArrayBuffer; - }; - - - /** - * Data length in bytes. - */ - size_t ByteLength() const; - - /** - * Create a new SharedArrayBuffer. Allocate |byte_length| bytes. - * Allocated memory will be owned by a created SharedArrayBuffer and - * will be deallocated when it is garbage-collected, - * unless the object is externalized. - */ - static Local<SharedArrayBuffer> New(Isolate* isolate, size_t byte_length); - - /** - * Create a new SharedArrayBuffer over an existing memory block. The created - * array buffer is immediately in externalized state unless otherwise - * specified. The memory block will not be reclaimed when a created - * SharedArrayBuffer is garbage-collected. - */ - static Local<SharedArrayBuffer> New( - Isolate* isolate, void* data, size_t byte_length, - ArrayBufferCreationMode mode = ArrayBufferCreationMode::kExternalized); - - /** - * Returns true if SharedArrayBuffer is externalized, that is, does not - * own its memory block. - */ - bool IsExternal() const; - - /** - * Make this SharedArrayBuffer external. The pointer to underlying memory - * block and byte length are returned as |Contents| structure. After - * SharedArrayBuffer had been externalized, it does no longer own the memory - * block. The caller should take steps to free memory when it is no longer - * needed. - * - * The memory block is guaranteed to be allocated with |Allocator::Allocate| - * by the allocator specified in - * v8::Isolate::CreateParams::array_buffer_allocator. - * - */ - Contents Externalize(); - - /** - * Get a pointer to the ArrayBuffer's underlying memory block without - * externalizing it. If the ArrayBuffer is not externalized, this pointer - * will become invalid as soon as the ArrayBuffer became garbage collected. - * - * The embedder should make sure to hold a strong reference to the - * ArrayBuffer while accessing this pointer. - * - * The memory block is guaranteed to be allocated with |Allocator::Allocate| - * by the allocator specified in - * v8::Isolate::CreateParams::array_buffer_allocator. - */ - Contents GetContents(); - - V8_INLINE static SharedArrayBuffer* Cast(Value* obj); - - static const int kInternalFieldCount = V8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT; - - private: - SharedArrayBuffer(); - static void CheckCast(Value* obj); -}; - - -/** - * An instance of the built-in Date constructor (ECMA-262, 15.9). - */ -class V8_EXPORT Date : public Object { - public: - static V8_DEPRECATE_SOON("Use maybe version.", - Local<Value> New(Isolate* isolate, double time)); - static V8_WARN_UNUSED_RESULT MaybeLocal<Value> New(Local<Context> context, - double time); - - /** - * A specialization of Value::NumberValue that is more efficient - * because we know the structure of this object. - */ - double ValueOf() const; - - V8_INLINE static Date* Cast(Value* obj); - - /** - * Notification that the embedder has changed the time zone, - * daylight savings time, or other date / time configuration - * parameters. V8 keeps a cache of various values used for - * date / time computation. This notification will reset - * those cached values for the current context so that date / - * time configuration changes would be reflected in the Date - * object. - * - * This API should not be called more than needed as it will - * negatively impact the performance of date operations. - */ - static void DateTimeConfigurationChangeNotification(Isolate* isolate); - - private: - static void CheckCast(Value* obj); -}; - - -/** - * A Number object (ECMA-262, 4.3.21). - */ -class V8_EXPORT NumberObject : public Object { - public: - static Local<Value> New(Isolate* isolate, double value); - - double ValueOf() const; - - V8_INLINE static NumberObject* Cast(Value* obj); - - private: - static void CheckCast(Value* obj); -}; - - -/** - * A Boolean object (ECMA-262, 4.3.15). - */ -class V8_EXPORT BooleanObject : public Object { - public: - static Local<Value> New(Isolate* isolate, bool value); - V8_DEPRECATED("Pass an isolate", static Local<Value> New(bool value)); - - bool ValueOf() const; - - V8_INLINE static BooleanObject* Cast(Value* obj); - - private: - static void CheckCast(Value* obj); -}; - - -/** - * A String object (ECMA-262, 4.3.18). - */ -class V8_EXPORT StringObject : public Object { - public: - static Local<Value> New(Local<String> value); - - Local<String> ValueOf() const; - - V8_INLINE static StringObject* Cast(Value* obj); - - private: - static void CheckCast(Value* obj); -}; - - -/** - * A Symbol object (ECMA-262 edition 6). - */ -class V8_EXPORT SymbolObject : public Object { - public: - static Local<Value> New(Isolate* isolate, Local<Symbol> value); - - Local<Symbol> ValueOf() const; - - V8_INLINE static SymbolObject* Cast(Value* obj); - - private: - static void CheckCast(Value* obj); -}; - - -/** - * An instance of the built-in RegExp constructor (ECMA-262, 15.10). - */ -class V8_EXPORT RegExp : public Object { - public: - /** - * Regular expression flag bits. They can be or'ed to enable a set - * of flags. - */ - enum Flags { - kNone = 0, - kGlobal = 1 << 0, - kIgnoreCase = 1 << 1, - kMultiline = 1 << 2, - kSticky = 1 << 3, - kUnicode = 1 << 4, - kDotAll = 1 << 5, - }; - - /** - * Creates a regular expression from the given pattern string and - * the flags bit field. May throw a JavaScript exception as - * described in ECMA-262, 15.10.4.1. - * - * For example, - * RegExp::New(v8::String::New("foo"), - * static_cast<RegExp::Flags>(kGlobal | kMultiline)) - * is equivalent to evaluating "/foo/gm". - */ - static V8_DEPRECATE_SOON("Use maybe version", - Local<RegExp> New(Local<String> pattern, - Flags flags)); - static V8_WARN_UNUSED_RESULT MaybeLocal<RegExp> New(Local<Context> context, - Local<String> pattern, - Flags flags); - - /** - * Returns the value of the source property: a string representing - * the regular expression. - */ - Local<String> GetSource() const; - - /** - * Returns the flags bit field. - */ - Flags GetFlags() const; - - V8_INLINE static RegExp* Cast(Value* obj); - - private: - static void CheckCast(Value* obj); -}; - - -/** - * A JavaScript value that wraps a C++ void*. This type of value is mainly used - * to associate C++ data structures with JavaScript objects. - */ -class V8_EXPORT External : public Value { - public: - static Local<External> New(Isolate* isolate, void* value); - V8_INLINE static External* Cast(Value* obj); - void* Value() const; - private: - static void CheckCast(v8::Value* obj); -}; - -#define V8_INTRINSICS_LIST(F) \ - F(ArrayProto_entries, array_entries_iterator) \ - F(ArrayProto_forEach, array_for_each_iterator) \ - F(ArrayProto_keys, array_keys_iterator) \ - F(ArrayProto_values, array_values_iterator) \ - F(IteratorPrototype, initial_iterator_prototype) - -enum Intrinsic { -#define V8_DECL_INTRINSIC(name, iname) k##name, - V8_INTRINSICS_LIST(V8_DECL_INTRINSIC) -#undef V8_DECL_INTRINSIC -}; - - -// --- Templates --- - - -/** - * The superclass of object and function templates. - */ -class V8_EXPORT Template : public Data { - public: - /** - * Adds a property to each instance created by this template. - * - * The property must be defined either as a primitive value, or a template. - */ - void Set(Local<Name> name, Local<Data> value, - PropertyAttribute attributes = None); - void SetPrivate(Local<Private> name, Local<Data> value, - PropertyAttribute attributes = None); - V8_INLINE void Set(Isolate* isolate, const char* name, Local<Data> value); - - void SetAccessorProperty( - Local<Name> name, - Local<FunctionTemplate> getter = Local<FunctionTemplate>(), - Local<FunctionTemplate> setter = Local<FunctionTemplate>(), - PropertyAttribute attribute = None, - AccessControl settings = DEFAULT); - - /** - * Whenever the property with the given name is accessed on objects - * created from this Template the getter and setter callbacks - * are called instead of getting and setting the property directly - * on the JavaScript object. - * - * \param name The name of the property for which an accessor is added. - * \param getter The callback to invoke when getting the property. - * \param setter The callback to invoke when setting the property. - * \param data A piece of data that will be passed to the getter and setter - * callbacks whenever they are invoked. - * \param settings Access control settings for the accessor. This is a bit - * field consisting of one of more of - * DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2. - * The default is to not allow cross-context access. - * ALL_CAN_READ means that all cross-context reads are allowed. - * ALL_CAN_WRITE means that all cross-context writes are allowed. - * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all - * cross-context access. - * \param attribute The attributes of the property for which an accessor - * is added. - * \param signature The signature describes valid receivers for the accessor - * and is used to perform implicit instance checks against them. If the - * receiver is incompatible (i.e. is not an instance of the constructor as - * defined by FunctionTemplate::HasInstance()), an implicit TypeError is - * thrown and no callback is invoked. - */ - void SetNativeDataProperty( - Local<String> name, AccessorGetterCallback getter, - AccessorSetterCallback setter = 0, - // TODO(dcarney): gcc can't handle Local below - Local<Value> data = Local<Value>(), PropertyAttribute attribute = None, - Local<AccessorSignature> signature = Local<AccessorSignature>(), - AccessControl settings = DEFAULT); - void SetNativeDataProperty( - Local<Name> name, AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter = 0, - // TODO(dcarney): gcc can't handle Local below - Local<Value> data = Local<Value>(), PropertyAttribute attribute = None, - Local<AccessorSignature> signature = Local<AccessorSignature>(), - AccessControl settings = DEFAULT); - - /** - * Like SetNativeDataProperty, but V8 will replace the native data property - * with a real data property on first access. - */ - void SetLazyDataProperty(Local<Name> name, AccessorNameGetterCallback getter, - Local<Value> data = Local<Value>(), - PropertyAttribute attribute = None); - - /** - * During template instantiation, sets the value with the intrinsic property - * from the correct context. - */ - void SetIntrinsicDataProperty(Local<Name> name, Intrinsic intrinsic, - PropertyAttribute attribute = None); - - private: - Template(); - - friend class ObjectTemplate; - friend class FunctionTemplate; -}; - - -/** - * NamedProperty[Getter|Setter] are used as interceptors on object. - * See ObjectTemplate::SetNamedPropertyHandler. - */ -typedef void (*NamedPropertyGetterCallback)( - Local<String> property, - const PropertyCallbackInfo<Value>& info); - - -/** - * Returns the value if the setter intercepts the request. - * Otherwise, returns an empty handle. - */ -typedef void (*NamedPropertySetterCallback)( - Local<String> property, - Local<Value> value, - const PropertyCallbackInfo<Value>& info); - - -/** - * Returns a non-empty handle if the interceptor intercepts the request. - * The result is an integer encoding property attributes (like v8::None, - * v8::DontEnum, etc.) - */ -typedef void (*NamedPropertyQueryCallback)( - Local<String> property, - const PropertyCallbackInfo<Integer>& info); - - -/** - * Returns a non-empty handle if the deleter intercepts the request. - * The return value is true if the property could be deleted and false - * otherwise. - */ -typedef void (*NamedPropertyDeleterCallback)( - Local<String> property, - const PropertyCallbackInfo<Boolean>& info); - - -/** - * Returns an array containing the names of the properties the named - * property getter intercepts. - */ -typedef void (*NamedPropertyEnumeratorCallback)( - const PropertyCallbackInfo<Array>& info); - - -// TODO(dcarney): Deprecate and remove previous typedefs, and replace -// GenericNamedPropertyFooCallback with just NamedPropertyFooCallback. - -/** - * Interceptor for get requests on an object. - * - * Use `info.GetReturnValue().Set()` to set the return value of the - * intercepted get request. - * - * \param property The name of the property for which the request was - * intercepted. - * \param info Information about the intercepted request, such as - * isolate, receiver, return value, or whether running in `'use strict`' mode. - * See `PropertyCallbackInfo`. - * - * \code - * void GetterCallback( - * Local<Name> name, - * const v8::PropertyCallbackInfo<v8::Value>& info) { - * info.GetReturnValue().Set(v8_num(42)); - * } - * - * v8::Local<v8::FunctionTemplate> templ = - * v8::FunctionTemplate::New(isolate); - * templ->InstanceTemplate()->SetHandler( - * v8::NamedPropertyHandlerConfiguration(GetterCallback)); - * LocalContext env; - * env->Global() - * ->Set(env.local(), v8_str("obj"), templ->GetFunction(env.local()) - * .ToLocalChecked() - * ->NewInstance(env.local()) - * .ToLocalChecked()) - * .FromJust(); - * v8::Local<v8::Value> result = CompileRun("obj.a = 17; obj.a"); - * CHECK(v8_num(42)->Equals(env.local(), result).FromJust()); - * \endcode - * - * See also `ObjectTemplate::SetHandler`. - */ -typedef void (*GenericNamedPropertyGetterCallback)( - Local<Name> property, const PropertyCallbackInfo<Value>& info); - -/** - * Interceptor for set requests on an object. - * - * Use `info.GetReturnValue()` to indicate whether the request was intercepted - * or not. If the setter successfully intercepts the request, i.e., if the - * request should not be further executed, call - * `info.GetReturnValue().Set(value)`. If the setter - * did not intercept the request, i.e., if the request should be handled as - * if no interceptor is present, do not not call `Set()`. - * - * \param property The name of the property for which the request was - * intercepted. - * \param value The value which the property will have if the request - * is not intercepted. - * \param info Information about the intercepted request, such as - * isolate, receiver, return value, or whether running in `'use strict'` mode. - * See `PropertyCallbackInfo`. - * - * See also - * `ObjectTemplate::SetHandler.` - */ -typedef void (*GenericNamedPropertySetterCallback)( - Local<Name> property, Local<Value> value, - const PropertyCallbackInfo<Value>& info); - -/** - * Intercepts all requests that query the attributes of the - * property, e.g., getOwnPropertyDescriptor(), propertyIsEnumerable(), and - * defineProperty(). - * - * Use `info.GetReturnValue().Set(value)` to set the property attributes. The - * value is an interger encoding a `v8::PropertyAttribute`. - * - * \param property The name of the property for which the request was - * intercepted. - * \param info Information about the intercepted request, such as - * isolate, receiver, return value, or whether running in `'use strict'` mode. - * See `PropertyCallbackInfo`. - * - * \note Some functions query the property attributes internally, even though - * they do not return the attributes. For example, `hasOwnProperty()` can - * trigger this interceptor depending on the state of the object. - * - * See also - * `ObjectTemplate::SetHandler.` - */ -typedef void (*GenericNamedPropertyQueryCallback)( - Local<Name> property, const PropertyCallbackInfo<Integer>& info); - -/** - * Interceptor for delete requests on an object. - * - * Use `info.GetReturnValue()` to indicate whether the request was intercepted - * or not. If the deleter successfully intercepts the request, i.e., if the - * request should not be further executed, call - * `info.GetReturnValue().Set(value)` with a boolean `value`. The `value` is - * used as the return value of `delete`. - * - * \param property The name of the property for which the request was - * intercepted. - * \param info Information about the intercepted request, such as - * isolate, receiver, return value, or whether running in `'use strict'` mode. - * See `PropertyCallbackInfo`. - * - * \note If you need to mimic the behavior of `delete`, i.e., throw in strict - * mode instead of returning false, use `info.ShouldThrowOnError()` to determine - * if you are in strict mode. - * - * See also `ObjectTemplate::SetHandler.` - */ -typedef void (*GenericNamedPropertyDeleterCallback)( - Local<Name> property, const PropertyCallbackInfo<Boolean>& info); - - -/** - * Returns an array containing the names of the properties the named - * property getter intercepts. - */ -typedef void (*GenericNamedPropertyEnumeratorCallback)( - const PropertyCallbackInfo<Array>& info); - -/** - * Interceptor for defineProperty requests on an object. - * - * Use `info.GetReturnValue()` to indicate whether the request was intercepted - * or not. If the definer successfully intercepts the request, i.e., if the - * request should not be further executed, call - * `info.GetReturnValue().Set(value)`. If the definer - * did not intercept the request, i.e., if the request should be handled as - * if no interceptor is present, do not not call `Set()`. - * - * \param property The name of the property for which the request was - * intercepted. - * \param desc The property descriptor which is used to define the - * property if the request is not intercepted. - * \param info Information about the intercepted request, such as - * isolate, receiver, return value, or whether running in `'use strict'` mode. - * See `PropertyCallbackInfo`. - * - * See also `ObjectTemplate::SetHandler`. - */ -typedef void (*GenericNamedPropertyDefinerCallback)( - Local<Name> property, const PropertyDescriptor& desc, - const PropertyCallbackInfo<Value>& info); - -/** - * Interceptor for getOwnPropertyDescriptor requests on an object. - * - * Use `info.GetReturnValue().Set()` to set the return value of the - * intercepted request. The return value must be an object that - * can be converted to a PropertyDescriptor, e.g., a `v8::value` returned from - * `v8::Object::getOwnPropertyDescriptor`. - * - * \param property The name of the property for which the request was - * intercepted. - * \info Information about the intercepted request, such as - * isolate, receiver, return value, or whether running in `'use strict'` mode. - * See `PropertyCallbackInfo`. - * - * \note If GetOwnPropertyDescriptor is intercepted, it will - * always return true, i.e., indicate that the property was found. - * - * See also `ObjectTemplate::SetHandler`. - */ -typedef void (*GenericNamedPropertyDescriptorCallback)( - Local<Name> property, const PropertyCallbackInfo<Value>& info); - -/** - * See `v8::GenericNamedPropertyGetterCallback`. - */ -typedef void (*IndexedPropertyGetterCallback)( - uint32_t index, - const PropertyCallbackInfo<Value>& info); - -/** - * See `v8::GenericNamedPropertySetterCallback`. - */ -typedef void (*IndexedPropertySetterCallback)( - uint32_t index, - Local<Value> value, - const PropertyCallbackInfo<Value>& info); - -/** - * See `v8::GenericNamedPropertyQueryCallback`. - */ -typedef void (*IndexedPropertyQueryCallback)( - uint32_t index, - const PropertyCallbackInfo<Integer>& info); - -/** - * See `v8::GenericNamedPropertyDeleterCallback`. - */ -typedef void (*IndexedPropertyDeleterCallback)( - uint32_t index, - const PropertyCallbackInfo<Boolean>& info); - -/** - * See `v8::GenericNamedPropertyEnumeratorCallback`. - */ -typedef void (*IndexedPropertyEnumeratorCallback)( - const PropertyCallbackInfo<Array>& info); - -/** - * See `v8::GenericNamedPropertyDefinerCallback`. - */ -typedef void (*IndexedPropertyDefinerCallback)( - uint32_t index, const PropertyDescriptor& desc, - const PropertyCallbackInfo<Value>& info); - -/** - * See `v8::GenericNamedPropertyDescriptorCallback`. - */ -typedef void (*IndexedPropertyDescriptorCallback)( - uint32_t index, const PropertyCallbackInfo<Value>& info); - -/** - * Access type specification. - */ -enum AccessType { - ACCESS_GET, - ACCESS_SET, - ACCESS_HAS, - ACCESS_DELETE, - ACCESS_KEYS -}; - - -/** - * Returns true if the given context should be allowed to access the given - * object. - */ -typedef bool (*AccessCheckCallback)(Local<Context> accessing_context, - Local<Object> accessed_object, - Local<Value> data); - -/** - * A FunctionTemplate is used to create functions at runtime. There - * can only be one function created from a FunctionTemplate in a - * context. The lifetime of the created function is equal to the - * lifetime of the context. So in case the embedder needs to create - * temporary functions that can be collected using Scripts is - * preferred. - * - * Any modification of a FunctionTemplate after first instantiation will trigger - * a crash. - * - * A FunctionTemplate can have properties, these properties are added to the - * function object when it is created. - * - * A FunctionTemplate has a corresponding instance template which is - * used to create object instances when the function is used as a - * constructor. Properties added to the instance template are added to - * each object instance. - * - * A FunctionTemplate can have a prototype template. The prototype template - * is used to create the prototype object of the function. - * - * The following example shows how to use a FunctionTemplate: - * - * \code - * v8::Local<v8::FunctionTemplate> t = v8::FunctionTemplate::New(isolate); - * t->Set(isolate, "func_property", v8::Number::New(isolate, 1)); - * - * v8::Local<v8::Template> proto_t = t->PrototypeTemplate(); - * proto_t->Set(isolate, - * "proto_method", - * v8::FunctionTemplate::New(isolate, InvokeCallback)); - * proto_t->Set(isolate, "proto_const", v8::Number::New(isolate, 2)); - * - * v8::Local<v8::ObjectTemplate> instance_t = t->InstanceTemplate(); - * instance_t->SetAccessor(String::NewFromUtf8(isolate, "instance_accessor"), - * InstanceAccessorCallback); - * instance_t->SetNamedPropertyHandler(PropertyHandlerCallback); - * instance_t->Set(String::NewFromUtf8(isolate, "instance_property"), - * Number::New(isolate, 3)); - * - * v8::Local<v8::Function> function = t->GetFunction(); - * v8::Local<v8::Object> instance = function->NewInstance(); - * \endcode - * - * Let's use "function" as the JS variable name of the function object - * and "instance" for the instance object created above. The function - * and the instance will have the following properties: - * - * \code - * func_property in function == true; - * function.func_property == 1; - * - * function.prototype.proto_method() invokes 'InvokeCallback' - * function.prototype.proto_const == 2; - * - * instance instanceof function == true; - * instance.instance_accessor calls 'InstanceAccessorCallback' - * instance.instance_property == 3; - * \endcode - * - * A FunctionTemplate can inherit from another one by calling the - * FunctionTemplate::Inherit method. The following graph illustrates - * the semantics of inheritance: - * - * \code - * FunctionTemplate Parent -> Parent() . prototype -> { } - * ^ ^ - * | Inherit(Parent) | .__proto__ - * | | - * FunctionTemplate Child -> Child() . prototype -> { } - * \endcode - * - * A FunctionTemplate 'Child' inherits from 'Parent', the prototype - * object of the Child() function has __proto__ pointing to the - * Parent() function's prototype object. An instance of the Child - * function has all properties on Parent's instance templates. - * - * Let Parent be the FunctionTemplate initialized in the previous - * section and create a Child FunctionTemplate by: - * - * \code - * Local<FunctionTemplate> parent = t; - * Local<FunctionTemplate> child = FunctionTemplate::New(); - * child->Inherit(parent); - * - * Local<Function> child_function = child->GetFunction(); - * Local<Object> child_instance = child_function->NewInstance(); - * \endcode - * - * The Child function and Child instance will have the following - * properties: - * - * \code - * child_func.prototype.__proto__ == function.prototype; - * child_instance.instance_accessor calls 'InstanceAccessorCallback' - * child_instance.instance_property == 3; - * \endcode - */ -class V8_EXPORT FunctionTemplate : public Template { - public: - /** Creates a function template.*/ - static Local<FunctionTemplate> New( - Isolate* isolate, FunctionCallback callback = 0, - Local<Value> data = Local<Value>(), - Local<Signature> signature = Local<Signature>(), int length = 0, - ConstructorBehavior behavior = ConstructorBehavior::kAllow); - - /** Get a template included in the snapshot by index. */ - static MaybeLocal<FunctionTemplate> FromSnapshot(Isolate* isolate, - size_t index); - - /** - * Creates a function template backed/cached by a private property. - */ - static Local<FunctionTemplate> NewWithCache( - Isolate* isolate, FunctionCallback callback, - Local<Private> cache_property, Local<Value> data = Local<Value>(), - Local<Signature> signature = Local<Signature>(), int length = 0); - - /** Returns the unique function instance in the current execution context.*/ - V8_DEPRECATE_SOON("Use maybe version", Local<Function> GetFunction()); - V8_WARN_UNUSED_RESULT MaybeLocal<Function> GetFunction( - Local<Context> context); - - /** - * Similar to Context::NewRemoteContext, this creates an instance that - * isn't backed by an actual object. - * - * The InstanceTemplate of this FunctionTemplate must have access checks with - * handlers installed. - */ - V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewRemoteInstance(); - - /** - * Set the call-handler callback for a FunctionTemplate. This - * callback is called whenever the function created from this - * FunctionTemplate is called. - */ - void SetCallHandler(FunctionCallback callback, - Local<Value> data = Local<Value>()); - - /** Set the predefined length property for the FunctionTemplate. */ - void SetLength(int length); - - /** Get the InstanceTemplate. */ - Local<ObjectTemplate> InstanceTemplate(); - - /** - * Causes the function template to inherit from a parent function template. - * This means the the function's prototype.__proto__ is set to the parent - * function's prototype. - **/ - void Inherit(Local<FunctionTemplate> parent); - - /** - * A PrototypeTemplate is the template used to create the prototype object - * of the function created by this template. - */ - Local<ObjectTemplate> PrototypeTemplate(); - - /** - * A PrototypeProviderTemplate is another function template whose prototype - * property is used for this template. This is mutually exclusive with setting - * a prototype template indirectly by calling PrototypeTemplate() or using - * Inherit(). - **/ - void SetPrototypeProviderTemplate(Local<FunctionTemplate> prototype_provider); - - /** - * Set the class name of the FunctionTemplate. This is used for - * printing objects created with the function created from the - * FunctionTemplate as its constructor. - */ - void SetClassName(Local<String> name); - - - /** - * When set to true, no access check will be performed on the receiver of a - * function call. Currently defaults to true, but this is subject to change. - */ - void SetAcceptAnyReceiver(bool value); - - /** - * Determines whether the __proto__ accessor ignores instances of - * the function template. If instances of the function template are - * ignored, __proto__ skips all instances and instead returns the - * next object in the prototype chain. - * - * Call with a value of true to make the __proto__ accessor ignore - * instances of the function template. Call with a value of false - * to make the __proto__ accessor not ignore instances of the - * function template. By default, instances of a function template - * are not ignored. - */ - void SetHiddenPrototype(bool value); - - /** - * Sets the ReadOnly flag in the attributes of the 'prototype' property - * of functions created from this FunctionTemplate to true. - */ - void ReadOnlyPrototype(); - - /** - * Removes the prototype property from functions created from this - * FunctionTemplate. - */ - void RemovePrototype(); - - /** - * Returns true if the given object is an instance of this function - * template. - */ - bool HasInstance(Local<Value> object); - - private: - FunctionTemplate(); - friend class Context; - friend class ObjectTemplate; -}; - -/** - * Configuration flags for v8::NamedPropertyHandlerConfiguration or - * v8::IndexedPropertyHandlerConfiguration. - */ -enum class PropertyHandlerFlags { - /** - * None. - */ - kNone = 0, - - /** - * See ALL_CAN_READ above. - */ - kAllCanRead = 1, - - /** Will not call into interceptor for properties on the receiver or prototype - * chain, i.e., only call into interceptor for properties that do not exist. - * Currently only valid for named interceptors. - */ - kNonMasking = 1 << 1, - - /** - * Will not call into interceptor for symbol lookup. Only meaningful for - * named interceptors. - */ - kOnlyInterceptStrings = 1 << 2, -}; - -struct NamedPropertyHandlerConfiguration { - NamedPropertyHandlerConfiguration( - /** Note: getter is required */ - GenericNamedPropertyGetterCallback getter = 0, - GenericNamedPropertySetterCallback setter = 0, - GenericNamedPropertyQueryCallback query = 0, - GenericNamedPropertyDeleterCallback deleter = 0, - GenericNamedPropertyEnumeratorCallback enumerator = 0, - Local<Value> data = Local<Value>(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(getter), - setter(setter), - query(query), - deleter(deleter), - enumerator(enumerator), - definer(0), - descriptor(0), - data(data), - flags(flags) {} - - NamedPropertyHandlerConfiguration( - GenericNamedPropertyGetterCallback getter, - GenericNamedPropertySetterCallback setter, - GenericNamedPropertyDescriptorCallback descriptor, - GenericNamedPropertyDeleterCallback deleter, - GenericNamedPropertyEnumeratorCallback enumerator, - GenericNamedPropertyDefinerCallback definer, - Local<Value> data = Local<Value>(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(getter), - setter(setter), - query(0), - deleter(deleter), - enumerator(enumerator), - definer(definer), - descriptor(descriptor), - data(data), - flags(flags) {} - - GenericNamedPropertyGetterCallback getter; - GenericNamedPropertySetterCallback setter; - GenericNamedPropertyQueryCallback query; - GenericNamedPropertyDeleterCallback deleter; - GenericNamedPropertyEnumeratorCallback enumerator; - GenericNamedPropertyDefinerCallback definer; - GenericNamedPropertyDescriptorCallback descriptor; - Local<Value> data; - PropertyHandlerFlags flags; -}; - - -struct IndexedPropertyHandlerConfiguration { - IndexedPropertyHandlerConfiguration( - /** Note: getter is required */ - IndexedPropertyGetterCallback getter = 0, - IndexedPropertySetterCallback setter = 0, - IndexedPropertyQueryCallback query = 0, - IndexedPropertyDeleterCallback deleter = 0, - IndexedPropertyEnumeratorCallback enumerator = 0, - Local<Value> data = Local<Value>(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(getter), - setter(setter), - query(query), - deleter(deleter), - enumerator(enumerator), - definer(0), - descriptor(0), - data(data), - flags(flags) {} - - IndexedPropertyHandlerConfiguration( - IndexedPropertyGetterCallback getter, - IndexedPropertySetterCallback setter, - IndexedPropertyDescriptorCallback descriptor, - IndexedPropertyDeleterCallback deleter, - IndexedPropertyEnumeratorCallback enumerator, - IndexedPropertyDefinerCallback definer, - Local<Value> data = Local<Value>(), - PropertyHandlerFlags flags = PropertyHandlerFlags::kNone) - : getter(getter), - setter(setter), - query(0), - deleter(deleter), - enumerator(enumerator), - definer(definer), - descriptor(descriptor), - data(data), - flags(flags) {} - - IndexedPropertyGetterCallback getter; - IndexedPropertySetterCallback setter; - IndexedPropertyQueryCallback query; - IndexedPropertyDeleterCallback deleter; - IndexedPropertyEnumeratorCallback enumerator; - IndexedPropertyDefinerCallback definer; - IndexedPropertyDescriptorCallback descriptor; - Local<Value> data; - PropertyHandlerFlags flags; -}; - - -/** - * An ObjectTemplate is used to create objects at runtime. - * - * Properties added to an ObjectTemplate are added to each object - * created from the ObjectTemplate. - */ -class V8_EXPORT ObjectTemplate : public Template { - public: - /** Creates an ObjectTemplate. */ - static Local<ObjectTemplate> New( - Isolate* isolate, - Local<FunctionTemplate> constructor = Local<FunctionTemplate>()); - static V8_DEPRECATED("Use isolate version", Local<ObjectTemplate> New()); - - /** Get a template included in the snapshot by index. */ - static MaybeLocal<ObjectTemplate> FromSnapshot(Isolate* isolate, - size_t index); - - /** Creates a new instance of this template.*/ - V8_DEPRECATE_SOON("Use maybe version", Local<Object> NewInstance()); - V8_WARN_UNUSED_RESULT MaybeLocal<Object> NewInstance(Local<Context> context); - - /** - * Sets an accessor on the object template. - * - * Whenever the property with the given name is accessed on objects - * created from this ObjectTemplate the getter and setter callbacks - * are called instead of getting and setting the property directly - * on the JavaScript object. - * - * \param name The name of the property for which an accessor is added. - * \param getter The callback to invoke when getting the property. - * \param setter The callback to invoke when setting the property. - * \param data A piece of data that will be passed to the getter and setter - * callbacks whenever they are invoked. - * \param settings Access control settings for the accessor. This is a bit - * field consisting of one of more of - * DEFAULT = 0, ALL_CAN_READ = 1, or ALL_CAN_WRITE = 2. - * The default is to not allow cross-context access. - * ALL_CAN_READ means that all cross-context reads are allowed. - * ALL_CAN_WRITE means that all cross-context writes are allowed. - * The combination ALL_CAN_READ | ALL_CAN_WRITE can be used to allow all - * cross-context access. - * \param attribute The attributes of the property for which an accessor - * is added. - * \param signature The signature describes valid receivers for the accessor - * and is used to perform implicit instance checks against them. If the - * receiver is incompatible (i.e. is not an instance of the constructor as - * defined by FunctionTemplate::HasInstance()), an implicit TypeError is - * thrown and no callback is invoked. - */ - void SetAccessor( - Local<String> name, AccessorGetterCallback getter, - AccessorSetterCallback setter = 0, Local<Value> data = Local<Value>(), - AccessControl settings = DEFAULT, PropertyAttribute attribute = None, - Local<AccessorSignature> signature = Local<AccessorSignature>()); - void SetAccessor( - Local<Name> name, AccessorNameGetterCallback getter, - AccessorNameSetterCallback setter = 0, Local<Value> data = Local<Value>(), - AccessControl settings = DEFAULT, PropertyAttribute attribute = None, - Local<AccessorSignature> signature = Local<AccessorSignature>()); - - /** - * Sets a named property handler on the object template. - * - * Whenever a property whose name is a string is accessed on objects created - * from this object template, the provided callback is invoked instead of - * accessing the property directly on the JavaScript object. - * - * SetNamedPropertyHandler() is different from SetHandler(), in - * that the latter can intercept symbol-named properties as well as - * string-named properties when called with a - * NamedPropertyHandlerConfiguration. New code should use SetHandler(). - * - * \param getter The callback to invoke when getting a property. - * \param setter The callback to invoke when setting a property. - * \param query The callback to invoke to check if a property is present, - * and if present, get its attributes. - * \param deleter The callback to invoke when deleting a property. - * \param enumerator The callback to invoke to enumerate all the named - * properties of an object. - * \param data A piece of data that will be passed to the callbacks - * whenever they are invoked. - */ - // TODO(dcarney): deprecate - void SetNamedPropertyHandler(NamedPropertyGetterCallback getter, - NamedPropertySetterCallback setter = 0, - NamedPropertyQueryCallback query = 0, - NamedPropertyDeleterCallback deleter = 0, - NamedPropertyEnumeratorCallback enumerator = 0, - Local<Value> data = Local<Value>()); - - /** - * Sets a named property handler on the object template. - * - * Whenever a property whose name is a string or a symbol is accessed on - * objects created from this object template, the provided callback is - * invoked instead of accessing the property directly on the JavaScript - * object. - * - * @param configuration The NamedPropertyHandlerConfiguration that defines the - * callbacks to invoke when accessing a property. - */ - void SetHandler(const NamedPropertyHandlerConfiguration& configuration); - - /** - * Sets an indexed property handler on the object template. - * - * Whenever an indexed property is accessed on objects created from - * this object template, the provided callback is invoked instead of - * accessing the property directly on the JavaScript object. - * - * \param getter The callback to invoke when getting a property. - * \param setter The callback to invoke when setting a property. - * \param query The callback to invoke to check if an object has a property. - * \param deleter The callback to invoke when deleting a property. - * \param enumerator The callback to invoke to enumerate all the indexed - * properties of an object. - * \param data A piece of data that will be passed to the callbacks - * whenever they are invoked. - */ - // TODO(dcarney): deprecate - void SetIndexedPropertyHandler( - IndexedPropertyGetterCallback getter, - IndexedPropertySetterCallback setter = 0, - IndexedPropertyQueryCallback query = 0, - IndexedPropertyDeleterCallback deleter = 0, - IndexedPropertyEnumeratorCallback enumerator = 0, - Local<Value> data = Local<Value>()) { - SetHandler(IndexedPropertyHandlerConfiguration(getter, setter, query, - deleter, enumerator, data)); - } - - /** - * Sets an indexed property handler on the object template. - * - * Whenever an indexed property is accessed on objects created from - * this object template, the provided callback is invoked instead of - * accessing the property directly on the JavaScript object. - * - * @param configuration The IndexedPropertyHandlerConfiguration that defines - * the callbacks to invoke when accessing a property. - */ - void SetHandler(const IndexedPropertyHandlerConfiguration& configuration); - - /** - * Sets the callback to be used when calling instances created from - * this template as a function. If no callback is set, instances - * behave like normal JavaScript objects that cannot be called as a - * function. - */ - void SetCallAsFunctionHandler(FunctionCallback callback, - Local<Value> data = Local<Value>()); - - /** - * Mark object instances of the template as undetectable. - * - * In many ways, undetectable objects behave as though they are not - * there. They behave like 'undefined' in conditionals and when - * printed. However, properties can be accessed and called as on - * normal objects. - */ - void MarkAsUndetectable(); - - /** - * Sets access check callback on the object template and enables access - * checks. - * - * When accessing properties on instances of this object template, - * the access check callback will be called to determine whether or - * not to allow cross-context access to the properties. - */ - void SetAccessCheckCallback(AccessCheckCallback callback, - Local<Value> data = Local<Value>()); - - /** - * Like SetAccessCheckCallback but invokes an interceptor on failed access - * checks instead of looking up all-can-read properties. You can only use - * either this method or SetAccessCheckCallback, but not both at the same - * time. - */ - void SetAccessCheckCallbackAndHandler( - AccessCheckCallback callback, - const NamedPropertyHandlerConfiguration& named_handler, - const IndexedPropertyHandlerConfiguration& indexed_handler, - Local<Value> data = Local<Value>()); - - /** - * Gets the number of internal fields for objects generated from - * this template. - */ - int InternalFieldCount(); - - /** - * Sets the number of internal fields for objects generated from - * this template. - */ - void SetInternalFieldCount(int value); - - /** - * Returns true if the object will be an immutable prototype exotic object. - */ - bool IsImmutableProto(); - - /** - * Makes the ObjectTempate for an immutable prototype exotic object, with an - * immutable __proto__. - */ - void SetImmutableProto(); - - private: - ObjectTemplate(); - static Local<ObjectTemplate> New(internal::Isolate* isolate, - Local<FunctionTemplate> constructor); - friend class FunctionTemplate; -}; - -/** - * A Signature specifies which receiver is valid for a function. - * - * A receiver matches a given signature if the receiver (or any of its - * hidden prototypes) was created from the signature's FunctionTemplate, or - * from a FunctionTemplate that inherits directly or indirectly from the - * signature's FunctionTemplate. - */ -class V8_EXPORT Signature : public Data { - public: - static Local<Signature> New( - Isolate* isolate, - Local<FunctionTemplate> receiver = Local<FunctionTemplate>()); - - private: - Signature(); -}; - - -/** - * An AccessorSignature specifies which receivers are valid parameters - * to an accessor callback. - */ -class V8_EXPORT AccessorSignature : public Data { - public: - static Local<AccessorSignature> New( - Isolate* isolate, - Local<FunctionTemplate> receiver = Local<FunctionTemplate>()); - - private: - AccessorSignature(); -}; - - -// --- Extensions --- - -class V8_EXPORT ExternalOneByteStringResourceImpl - : public String::ExternalOneByteStringResource { - public: - ExternalOneByteStringResourceImpl() : data_(0), length_(0) {} - ExternalOneByteStringResourceImpl(const char* data, size_t length) - : data_(data), length_(length) {} - const char* data() const { return data_; } - size_t length() const { return length_; } - - private: - const char* data_; - size_t length_; -}; - -/** - * Ignore - */ -class V8_EXPORT Extension { // NOLINT - public: - // Note that the strings passed into this constructor must live as long - // as the Extension itself. - Extension(const char* name, - const char* source = 0, - int dep_count = 0, - const char** deps = 0, - int source_length = -1); - virtual ~Extension() { } - virtual Local<FunctionTemplate> GetNativeFunctionTemplate( - Isolate* isolate, Local<String> name) { - return Local<FunctionTemplate>(); - } - - const char* name() const { return name_; } - size_t source_length() const { return source_length_; } - const String::ExternalOneByteStringResource* source() const { - return &source_; } - int dependency_count() { return dep_count_; } - const char** dependencies() { return deps_; } - void set_auto_enable(bool value) { auto_enable_ = value; } - bool auto_enable() { return auto_enable_; } - - // Disallow copying and assigning. - Extension(const Extension&) = delete; - void operator=(const Extension&) = delete; - - private: - const char* name_; - size_t source_length_; // expected to initialize before source_ - ExternalOneByteStringResourceImpl source_; - int dep_count_; - const char** deps_; - bool auto_enable_; -}; - - -void V8_EXPORT RegisterExtension(Extension* extension); - - -// --- Statics --- - -V8_INLINE Local<Primitive> Undefined(Isolate* isolate); -V8_INLINE Local<Primitive> Null(Isolate* isolate); -V8_INLINE Local<Boolean> True(Isolate* isolate); -V8_INLINE Local<Boolean> False(Isolate* isolate); - -/** - * A set of constraints that specifies the limits of the runtime's memory use. - * You must set the heap size before initializing the VM - the size cannot be - * adjusted after the VM is initialized. - * - * If you are using threads then you should hold the V8::Locker lock while - * setting the stack limit and you must set a non-default stack limit separately - * for each thread. - * - * The arguments for set_max_semi_space_size, set_max_old_space_size, - * set_max_executable_size, set_code_range_size specify limits in MB. - */ -class V8_EXPORT ResourceConstraints { - public: - ResourceConstraints(); - - /** - * Configures the constraints with reasonable default values based on the - * capabilities of the current device the VM is running on. - * - * \param physical_memory The total amount of physical memory on the current - * device, in bytes. - * \param virtual_memory_limit The amount of virtual memory on the current - * device, in bytes, or zero, if there is no limit. - */ - void ConfigureDefaults(uint64_t physical_memory, - uint64_t virtual_memory_limit); - - int max_semi_space_size() const { return max_semi_space_size_; } - void set_max_semi_space_size(int limit_in_mb) { - max_semi_space_size_ = limit_in_mb; - } - int max_old_space_size() const { return max_old_space_size_; } - void set_max_old_space_size(int limit_in_mb) { - max_old_space_size_ = limit_in_mb; - } - V8_DEPRECATE_SOON("max_executable_size_ is subsumed by max_old_space_size_", - int max_executable_size() const) { - return max_executable_size_; - } - V8_DEPRECATE_SOON("max_executable_size_ is subsumed by max_old_space_size_", - void set_max_executable_size(int limit_in_mb)) { - max_executable_size_ = limit_in_mb; - } - uint32_t* stack_limit() const { return stack_limit_; } - // Sets an address beyond which the VM's stack may not grow. - void set_stack_limit(uint32_t* value) { stack_limit_ = value; } - size_t code_range_size() const { return code_range_size_; } - void set_code_range_size(size_t limit_in_mb) { - code_range_size_ = limit_in_mb; - } - size_t max_zone_pool_size() const { return max_zone_pool_size_; } - void set_max_zone_pool_size(const size_t bytes) { - max_zone_pool_size_ = bytes; - } - - private: - int max_semi_space_size_; - int max_old_space_size_; - int max_executable_size_; - uint32_t* stack_limit_; - size_t code_range_size_; - size_t max_zone_pool_size_; -}; - - -// --- Exceptions --- - - -typedef void (*FatalErrorCallback)(const char* location, const char* message); - -typedef void (*OOMErrorCallback)(const char* location, bool is_heap_oom); - -typedef void (*MessageCallback)(Local<Message> message, Local<Value> data); - -// --- Tracing --- - -typedef void (*LogEventCallback)(const char* name, int event); - -/** - * Create new error objects by calling the corresponding error object - * constructor with the message. - */ -class V8_EXPORT Exception { - public: - static Local<Value> RangeError(Local<String> message); - static Local<Value> ReferenceError(Local<String> message); - static Local<Value> SyntaxError(Local<String> message); - static Local<Value> TypeError(Local<String> message); - static Local<Value> Error(Local<String> message); - - /** - * Creates an error message for the given exception. - * Will try to reconstruct the original stack trace from the exception value, - * or capture the current stack trace if not available. - */ - static Local<Message> CreateMessage(Isolate* isolate, Local<Value> exception); - V8_DEPRECATED("Use version with an Isolate*", - static Local<Message> CreateMessage(Local<Value> exception)); - - /** - * Returns the original stack trace that was captured at the creation time - * of a given exception, or an empty handle if not available. - */ - static Local<StackTrace> GetStackTrace(Local<Value> exception); -}; - - -// --- Counters Callbacks --- - -typedef int* (*CounterLookupCallback)(const char* name); - -typedef void* (*CreateHistogramCallback)(const char* name, - int min, - int max, - size_t buckets); - -typedef void (*AddHistogramSampleCallback)(void* histogram, int sample); - -// --- Memory Allocation Callback --- -enum ObjectSpace { - kObjectSpaceNewSpace = 1 << 0, - kObjectSpaceOldSpace = 1 << 1, - kObjectSpaceCodeSpace = 1 << 2, - kObjectSpaceMapSpace = 1 << 3, - kObjectSpaceLoSpace = 1 << 4, - kObjectSpaceAll = kObjectSpaceNewSpace | kObjectSpaceOldSpace | - kObjectSpaceCodeSpace | kObjectSpaceMapSpace | - kObjectSpaceLoSpace -}; - - enum AllocationAction { - kAllocationActionAllocate = 1 << 0, - kAllocationActionFree = 1 << 1, - kAllocationActionAll = kAllocationActionAllocate | kAllocationActionFree - }; - -// --- Enter/Leave Script Callback --- -typedef void (*BeforeCallEnteredCallback)(Isolate*); -typedef void (*CallCompletedCallback)(Isolate*); -typedef void (*DeprecatedCallCompletedCallback)(); - -/** - * HostImportDynamicallyCallback is called when we require the - * embedder to load a module. This is used as part of the dynamic - * import syntax. The behavior of this callback is not specified in - * EcmaScript. - * - * The referrer is the name of the file which calls the dynamic - * import. The referrer can be used to resolve the module location. - * - * The specifier is the name of the module that should be imported. - * - * The DynamicImportResult object is used to signal success or failure - * by calling it's respective methods. - * - */ -typedef void (*HostImportModuleDynamicallyCallback)( - Isolate* isolate, Local<String> referrer, Local<String> specifier, - Local<DynamicImportResult> result); - -/** - * PromiseHook with type kInit is called when a new promise is - * created. When a new promise is created as part of the chain in the - * case of Promise.then or in the intermediate promises created by - * Promise.{race, all}/AsyncFunctionAwait, we pass the parent promise - * otherwise we pass undefined. - * - * PromiseHook with type kResolve is called at the beginning of - * resolve or reject function defined by CreateResolvingFunctions. - * - * PromiseHook with type kBefore is called at the beginning of the - * PromiseReactionJob. - * - * PromiseHook with type kAfter is called right at the end of the - * PromiseReactionJob. - */ -enum class PromiseHookType { kInit, kResolve, kBefore, kAfter }; - -typedef void (*PromiseHook)(PromiseHookType type, Local<Promise> promise, - Local<Value> parent); - -// --- Promise Reject Callback --- -enum PromiseRejectEvent { - kPromiseRejectWithNoHandler = 0, - kPromiseHandlerAddedAfterReject = 1 -}; - -class PromiseRejectMessage { - public: - PromiseRejectMessage(Local<Promise> promise, PromiseRejectEvent event, - Local<Value> value, Local<StackTrace> stack_trace) - : promise_(promise), - event_(event), - value_(value), - stack_trace_(stack_trace) {} - - V8_INLINE Local<Promise> GetPromise() const { return promise_; } - V8_INLINE PromiseRejectEvent GetEvent() const { return event_; } - V8_INLINE Local<Value> GetValue() const { return value_; } - - V8_DEPRECATED("Use v8::Exception::CreateMessage(GetValue())->GetStackTrace()", - V8_INLINE Local<StackTrace> GetStackTrace() const) { - return stack_trace_; - } - - private: - Local<Promise> promise_; - PromiseRejectEvent event_; - Local<Value> value_; - Local<StackTrace> stack_trace_; -}; - -typedef void (*PromiseRejectCallback)(PromiseRejectMessage message); - -// --- Microtasks Callbacks --- -typedef void (*MicrotasksCompletedCallback)(Isolate*); -typedef void (*MicrotaskCallback)(void* data); - - -/** - * Policy for running microtasks: - * - explicit: microtasks are invoked with Isolate::RunMicrotasks() method; - * - scoped: microtasks invocation is controlled by MicrotasksScope objects; - * - auto: microtasks are invoked when the script call depth decrements - * to zero. - */ -enum class MicrotasksPolicy { kExplicit, kScoped, kAuto }; - - -/** - * This scope is used to control microtasks when kScopeMicrotasksInvocation - * is used on Isolate. In this mode every non-primitive call to V8 should be - * done inside some MicrotasksScope. - * Microtasks are executed when topmost MicrotasksScope marked as kRunMicrotasks - * exits. - * kDoNotRunMicrotasks should be used to annotate calls not intended to trigger - * microtasks. - */ -class V8_EXPORT MicrotasksScope { - public: - enum Type { kRunMicrotasks, kDoNotRunMicrotasks }; - - MicrotasksScope(Isolate* isolate, Type type); - ~MicrotasksScope(); - - /** - * Runs microtasks if no kRunMicrotasks scope is currently active. - */ - static void PerformCheckpoint(Isolate* isolate); - - /** - * Returns current depth of nested kRunMicrotasks scopes. - */ - static int GetCurrentDepth(Isolate* isolate); - - /** - * Returns true while microtasks are being executed. - */ - static bool IsRunningMicrotasks(Isolate* isolate); - - // Prevent copying. - MicrotasksScope(const MicrotasksScope&) = delete; - MicrotasksScope& operator=(const MicrotasksScope&) = delete; - - private: - internal::Isolate* const isolate_; - bool run_; -}; - - -// --- Failed Access Check Callback --- -typedef void (*FailedAccessCheckCallback)(Local<Object> target, - AccessType type, - Local<Value> data); - -// --- AllowCodeGenerationFromStrings callbacks --- - -/** - * Callback to check if code generation from strings is allowed. See - * Context::AllowCodeGenerationFromStrings. - */ -typedef bool (*AllowCodeGenerationFromStringsCallback)(Local<Context> context); - -// --- WASM compilation callbacks --- -typedef bool (*ExtensionCallback)(const FunctionCallbackInfo<Value>&); - -// --- Garbage Collection Callbacks --- - -/** - * Applications can register callback functions which will be called before and - * after certain garbage collection operations. Allocations are not allowed in - * the callback functions, you therefore cannot manipulate objects (set or - * delete properties for example) since it is possible such operations will - * result in the allocation of objects. - */ -enum GCType { - kGCTypeScavenge = 1 << 0, - kGCTypeMarkSweepCompact = 1 << 1, - kGCTypeIncrementalMarking = 1 << 2, - kGCTypeProcessWeakCallbacks = 1 << 3, - kGCTypeAll = kGCTypeScavenge | kGCTypeMarkSweepCompact | - kGCTypeIncrementalMarking | kGCTypeProcessWeakCallbacks -}; - -/** - * GCCallbackFlags is used to notify additional information about the GC - * callback. - * - kGCCallbackFlagConstructRetainedObjectInfos: The GC callback is for - * constructing retained object infos. - * - kGCCallbackFlagForced: The GC callback is for a forced GC for testing. - * - kGCCallbackFlagSynchronousPhantomCallbackProcessing: The GC callback - * is called synchronously without getting posted to an idle task. - * - kGCCallbackFlagCollectAllAvailableGarbage: The GC callback is called - * in a phase where V8 is trying to collect all available garbage - * (e.g., handling a low memory notification). - * - kGCCallbackScheduleIdleGarbageCollection: The GC callback is called to - * trigger an idle garbage collection. - */ -enum GCCallbackFlags { - kNoGCCallbackFlags = 0, - kGCCallbackFlagConstructRetainedObjectInfos = 1 << 1, - kGCCallbackFlagForced = 1 << 2, - kGCCallbackFlagSynchronousPhantomCallbackProcessing = 1 << 3, - kGCCallbackFlagCollectAllAvailableGarbage = 1 << 4, - kGCCallbackFlagCollectAllExternalMemory = 1 << 5, - kGCCallbackScheduleIdleGarbageCollection = 1 << 6, -}; - -typedef void (*GCCallback)(GCType type, GCCallbackFlags flags); - -typedef void (*InterruptCallback)(Isolate* isolate, void* data); - - -/** - * Collection of V8 heap information. - * - * Instances of this class can be passed to v8::V8::HeapStatistics to - * get heap statistics from V8. - */ -class V8_EXPORT HeapStatistics { - public: - HeapStatistics(); - size_t total_heap_size() { return total_heap_size_; } - size_t total_heap_size_executable() { return total_heap_size_executable_; } - size_t total_physical_size() { return total_physical_size_; } - size_t total_available_size() { return total_available_size_; } - size_t used_heap_size() { return used_heap_size_; } - size_t heap_size_limit() { return heap_size_limit_; } - size_t malloced_memory() { return malloced_memory_; } - size_t peak_malloced_memory() { return peak_malloced_memory_; } - - /** - * Returns a 0/1 boolean, which signifies whether the V8 overwrite heap - * garbage with a bit pattern. - */ - size_t does_zap_garbage() { return does_zap_garbage_; } - - private: - size_t total_heap_size_; - size_t total_heap_size_executable_; - size_t total_physical_size_; - size_t total_available_size_; - size_t used_heap_size_; - size_t heap_size_limit_; - size_t malloced_memory_; - size_t peak_malloced_memory_; - bool does_zap_garbage_; - - friend class V8; - friend class Isolate; -}; - - -class V8_EXPORT HeapSpaceStatistics { - public: - HeapSpaceStatistics(); - const char* space_name() { return space_name_; } - size_t space_size() { return space_size_; } - size_t space_used_size() { return space_used_size_; } - size_t space_available_size() { return space_available_size_; } - size_t physical_space_size() { return physical_space_size_; } - - private: - const char* space_name_; - size_t space_size_; - size_t space_used_size_; - size_t space_available_size_; - size_t physical_space_size_; - - friend class Isolate; -}; - - -class V8_EXPORT HeapObjectStatistics { - public: - HeapObjectStatistics(); - const char* object_type() { return object_type_; } - const char* object_sub_type() { return object_sub_type_; } - size_t object_count() { return object_count_; } - size_t object_size() { return object_size_; } - - private: - const char* object_type_; - const char* object_sub_type_; - size_t object_count_; - size_t object_size_; - - friend class Isolate; -}; - -class V8_EXPORT HeapCodeStatistics { - public: - HeapCodeStatistics(); - size_t code_and_metadata_size() { return code_and_metadata_size_; } - size_t bytecode_and_metadata_size() { return bytecode_and_metadata_size_; } - - private: - size_t code_and_metadata_size_; - size_t bytecode_and_metadata_size_; - - friend class Isolate; -}; - -class RetainedObjectInfo; - - -/** - * FunctionEntryHook is the type of the profile entry hook called at entry to - * any generated function when function-level profiling is enabled. - * - * \param function the address of the function that's being entered. - * \param return_addr_location points to a location on stack where the machine - * return address resides. This can be used to identify the caller of - * \p function, and/or modified to divert execution when \p function exits. - * - * \note the entry hook must not cause garbage collection. - */ -typedef void (*FunctionEntryHook)(uintptr_t function, - uintptr_t return_addr_location); - -/** - * A JIT code event is issued each time code is added, moved or removed. - * - * \note removal events are not currently issued. - */ -struct JitCodeEvent { - enum EventType { - CODE_ADDED, - CODE_MOVED, - CODE_REMOVED, - CODE_ADD_LINE_POS_INFO, - CODE_START_LINE_INFO_RECORDING, - CODE_END_LINE_INFO_RECORDING - }; - // Definition of the code position type. The "POSITION" type means the place - // in the source code which are of interest when making stack traces to - // pin-point the source location of a stack frame as close as possible. - // The "STATEMENT_POSITION" means the place at the beginning of each - // statement, and is used to indicate possible break locations. - enum PositionType { POSITION, STATEMENT_POSITION }; - - // Type of event. - EventType type; - // Start of the instructions. - void* code_start; - // Size of the instructions. - size_t code_len; - // Script info for CODE_ADDED event. - Local<UnboundScript> script; - // User-defined data for *_LINE_INFO_* event. It's used to hold the source - // code line information which is returned from the - // CODE_START_LINE_INFO_RECORDING event. And it's passed to subsequent - // CODE_ADD_LINE_POS_INFO and CODE_END_LINE_INFO_RECORDING events. - void* user_data; - - struct name_t { - // Name of the object associated with the code, note that the string is not - // zero-terminated. - const char* str; - // Number of chars in str. - size_t len; - }; - - struct line_info_t { - // PC offset - size_t offset; - // Code postion - size_t pos; - // The position type. - PositionType position_type; - }; - - union { - // Only valid for CODE_ADDED. - struct name_t name; - - // Only valid for CODE_ADD_LINE_POS_INFO - struct line_info_t line_info; - - // New location of instructions. Only valid for CODE_MOVED. - void* new_code_start; - }; -}; - -/** - * Option flags passed to the SetRAILMode function. - * See documentation https://developers.google.com/web/tools/chrome-devtools/ - * profile/evaluate-performance/rail - */ -enum RAILMode { - // Response performance mode: In this mode very low virtual machine latency - // is provided. V8 will try to avoid JavaScript execution interruptions. - // Throughput may be throttled. - PERFORMANCE_RESPONSE, - // Animation performance mode: In this mode low virtual machine latency is - // provided. V8 will try to avoid as many JavaScript execution interruptions - // as possible. Throughput may be throttled. This is the default mode. - PERFORMANCE_ANIMATION, - // Idle performance mode: The embedder is idle. V8 can complete deferred work - // in this mode. - PERFORMANCE_IDLE, - // Load performance mode: In this mode high throughput is provided. V8 may - // turn off latency optimizations. - PERFORMANCE_LOAD -}; - -/** - * Option flags passed to the SetJitCodeEventHandler function. - */ -enum JitCodeEventOptions { - kJitCodeEventDefault = 0, - // Generate callbacks for already existent code. - kJitCodeEventEnumExisting = 1 -}; - - -/** - * Callback function passed to SetJitCodeEventHandler. - * - * \param event code add, move or removal event. - */ -typedef void (*JitCodeEventHandler)(const JitCodeEvent* event); - - -/** - * Interface for iterating through all external resources in the heap. - */ -class V8_EXPORT ExternalResourceVisitor { // NOLINT - public: - virtual ~ExternalResourceVisitor() {} - virtual void VisitExternalString(Local<String> string) {} -}; - - -/** - * Interface for iterating through all the persistent handles in the heap. - */ -class V8_EXPORT PersistentHandleVisitor { // NOLINT - public: - virtual ~PersistentHandleVisitor() {} - virtual void VisitPersistentHandle(Persistent<Value>* value, - uint16_t class_id) {} -}; - -/** - * Memory pressure level for the MemoryPressureNotification. - * kNone hints V8 that there is no memory pressure. - * kModerate hints V8 to speed up incremental garbage collection at the cost of - * of higher latency due to garbage collection pauses. - * kCritical hints V8 to free memory as soon as possible. Garbage collection - * pauses at this level will be large. - */ -enum class MemoryPressureLevel { kNone, kModerate, kCritical }; - -/** - * Interface for tracing through the embedder heap. During a v8 garbage - * collection, v8 collects hidden fields of all potential wrappers, and at the - * end of its marking phase iterates the collection and asks the embedder to - * trace through its heap and use reporter to report each JavaScript object - * reachable from any of the given wrappers. - * - * Before the first call to the TraceWrappersFrom function TracePrologue will be - * called. When the garbage collection cycle is finished, TraceEpilogue will be - * called. - */ -class V8_EXPORT EmbedderHeapTracer { - public: - enum ForceCompletionAction { FORCE_COMPLETION, DO_NOT_FORCE_COMPLETION }; - - struct AdvanceTracingActions { - explicit AdvanceTracingActions(ForceCompletionAction force_completion_) - : force_completion(force_completion_) {} - - ForceCompletionAction force_completion; - }; - - /** - * Called by v8 to register internal fields of found wrappers. - * - * The embedder is expected to store them somewhere and trace reachable - * wrappers from them when called through |AdvanceTracing|. - */ - virtual void RegisterV8References( - const std::vector<std::pair<void*, void*> >& embedder_fields) = 0; - - /** - * Called at the beginning of a GC cycle. - */ - virtual void TracePrologue() = 0; - - /** - * Called to to make a tracing step in the embedder. - * - * The embedder is expected to trace its heap starting from wrappers reported - * by RegisterV8References method, and report back all reachable wrappers. - * Furthermore, the embedder is expected to stop tracing by the given - * deadline. - * - * Returns true if there is still work to do. - */ - virtual bool AdvanceTracing(double deadline_in_ms, - AdvanceTracingActions actions) = 0; - - /** - * Called at the end of a GC cycle. - * - * Note that allocation is *not* allowed within |TraceEpilogue|. - */ - virtual void TraceEpilogue() = 0; - - /** - * Called upon entering the final marking pause. No more incremental marking - * steps will follow this call. - */ - virtual void EnterFinalPause() = 0; - - /** - * Called when tracing is aborted. - * - * The embedder is expected to throw away all intermediate data and reset to - * the initial state. - */ - virtual void AbortTracing() = 0; - - /** - * Returns the number of wrappers that are still to be traced by the embedder. - */ - virtual size_t NumberOfWrappersToTrace() { return 0; } - - protected: - virtual ~EmbedderHeapTracer() = default; -}; - -/** - * Callback and supporting data used in SnapshotCreator to implement embedder - * logic to serialize internal fields. - */ -struct SerializeInternalFieldsCallback { - typedef StartupData (*CallbackFunction)(Local<Object> holder, int index, - void* data); - SerializeInternalFieldsCallback(CallbackFunction function = nullptr, - void* data_arg = nullptr) - : callback(function), data(data_arg) {} - CallbackFunction callback; - void* data; -}; -// Note that these fields are called "internal fields" in the API and called -// "embedder fields" within V8. -typedef SerializeInternalFieldsCallback SerializeEmbedderFieldsCallback; - -/** - * Callback and supporting data used to implement embedder logic to deserialize - * internal fields. - */ -struct DeserializeInternalFieldsCallback { - typedef void (*CallbackFunction)(Local<Object> holder, int index, - StartupData payload, void* data); - DeserializeInternalFieldsCallback(CallbackFunction function = nullptr, - void* data_arg = nullptr) - : callback(function), data(data_arg) {} - void (*callback)(Local<Object> holder, int index, StartupData payload, - void* data); - void* data; -}; -typedef DeserializeInternalFieldsCallback DeserializeEmbedderFieldsCallback; - -/** - * Isolate represents an isolated instance of the V8 engine. V8 isolates have - * completely separate states. Objects from one isolate must not be used in - * other isolates. The embedder can create multiple isolates and use them in - * parallel in multiple threads. An isolate can be entered by at most one - * thread at any given time. The Locker/Unlocker API must be used to - * synchronize. - */ -class V8_EXPORT Isolate { - public: - /** - * Initial configuration parameters for a new Isolate. - */ - struct CreateParams { - CreateParams() - : entry_hook(nullptr), - code_event_handler(nullptr), - snapshot_blob(nullptr), - counter_lookup_callback(nullptr), - create_histogram_callback(nullptr), - add_histogram_sample_callback(nullptr), - array_buffer_allocator(nullptr), - external_references(nullptr), - allow_atomics_wait(true), - host_import_module_dynamically_callback_(nullptr) {} - - /** - * The optional entry_hook allows the host application to provide the - * address of a function that's invoked on entry to every V8-generated - * function. Note that entry_hook is invoked at the very start of each - * generated function. - * An entry_hook can only be provided in no-snapshot builds; in snapshot - * builds it must be nullptr. - */ - FunctionEntryHook entry_hook; - - /** - * Allows the host application to provide the address of a function that is - * notified each time code is added, moved or removed. - */ - JitCodeEventHandler code_event_handler; - - /** - * ResourceConstraints to use for the new Isolate. - */ - ResourceConstraints constraints; - - /** - * Explicitly specify a startup snapshot blob. The embedder owns the blob. - */ - StartupData* snapshot_blob; - - - /** - * Enables the host application to provide a mechanism for recording - * statistics counters. - */ - CounterLookupCallback counter_lookup_callback; - - /** - * Enables the host application to provide a mechanism for recording - * histograms. The CreateHistogram function returns a - * histogram which will later be passed to the AddHistogramSample - * function. - */ - CreateHistogramCallback create_histogram_callback; - AddHistogramSampleCallback add_histogram_sample_callback; - - /** - * The ArrayBuffer::Allocator to use for allocating and freeing the backing - * store of ArrayBuffers. - */ - ArrayBuffer::Allocator* array_buffer_allocator; - - /** - * Specifies an optional nullptr-terminated array of raw addresses in the - * embedder that V8 can match against during serialization and use for - * deserialization. This array and its content must stay valid for the - * entire lifetime of the isolate. - */ - intptr_t* external_references; - - /** - * Whether calling Atomics.wait (a function that may block) is allowed in - * this isolate. This can also be configured via SetAllowAtomicsWait. - */ - bool allow_atomics_wait; - - /** - * This is an unfinished experimental feature, and is only exposed - * here for internal testing purposes. DO NOT USE. - * - * This specifies the callback called by the upcoming dynamic - * import() language feature to load modules. - */ - HostImportModuleDynamicallyCallback - host_import_module_dynamically_callback_; - }; - - - /** - * Stack-allocated class which sets the isolate for all operations - * executed within a local scope. - */ - class V8_EXPORT Scope { - public: - explicit Scope(Isolate* isolate) : isolate_(isolate) { - isolate->Enter(); - } - - ~Scope() { isolate_->Exit(); } - - // Prevent copying of Scope objects. - Scope(const Scope&) = delete; - Scope& operator=(const Scope&) = delete; - - private: - Isolate* const isolate_; - }; - - - /** - * Assert that no Javascript code is invoked. - */ - class V8_EXPORT DisallowJavascriptExecutionScope { - public: - enum OnFailure { CRASH_ON_FAILURE, THROW_ON_FAILURE }; - - DisallowJavascriptExecutionScope(Isolate* isolate, OnFailure on_failure); - ~DisallowJavascriptExecutionScope(); - - // Prevent copying of Scope objects. - DisallowJavascriptExecutionScope(const DisallowJavascriptExecutionScope&) = - delete; - DisallowJavascriptExecutionScope& operator=( - const DisallowJavascriptExecutionScope&) = delete; - - private: - bool on_failure_; - void* internal_; - }; - - - /** - * Introduce exception to DisallowJavascriptExecutionScope. - */ - class V8_EXPORT AllowJavascriptExecutionScope { - public: - explicit AllowJavascriptExecutionScope(Isolate* isolate); - ~AllowJavascriptExecutionScope(); - - // Prevent copying of Scope objects. - AllowJavascriptExecutionScope(const AllowJavascriptExecutionScope&) = - delete; - AllowJavascriptExecutionScope& operator=( - const AllowJavascriptExecutionScope&) = delete; - - private: - void* internal_throws_; - void* internal_assert_; - }; - - /** - * Do not run microtasks while this scope is active, even if microtasks are - * automatically executed otherwise. - */ - class V8_EXPORT SuppressMicrotaskExecutionScope { - public: - explicit SuppressMicrotaskExecutionScope(Isolate* isolate); - ~SuppressMicrotaskExecutionScope(); - - // Prevent copying of Scope objects. - SuppressMicrotaskExecutionScope(const SuppressMicrotaskExecutionScope&) = - delete; - SuppressMicrotaskExecutionScope& operator=( - const SuppressMicrotaskExecutionScope&) = delete; - - private: - internal::Isolate* const isolate_; - }; - - /** - * Types of garbage collections that can be requested via - * RequestGarbageCollectionForTesting. - */ - enum GarbageCollectionType { - kFullGarbageCollection, - kMinorGarbageCollection - }; - - /** - * Features reported via the SetUseCounterCallback callback. Do not change - * assigned numbers of existing items; add new features to the end of this - * list. - */ - enum UseCounterFeature { - kUseAsm = 0, - kBreakIterator = 1, - kLegacyConst = 2, - kMarkDequeOverflow = 3, - kStoreBufferOverflow = 4, - kSlotsBufferOverflow = 5, - kObjectObserve = 6, - kForcedGC = 7, - kSloppyMode = 8, - kStrictMode = 9, - kStrongMode = 10, - kRegExpPrototypeStickyGetter = 11, - kRegExpPrototypeToString = 12, - kRegExpPrototypeUnicodeGetter = 13, - kIntlV8Parse = 14, - kIntlPattern = 15, - kIntlResolved = 16, - kPromiseChain = 17, - kPromiseAccept = 18, - kPromiseDefer = 19, - kHtmlCommentInExternalScript = 20, - kHtmlComment = 21, - kSloppyModeBlockScopedFunctionRedefinition = 22, - kForInInitializer = 23, - kArrayProtectorDirtied = 24, - kArraySpeciesModified = 25, - kArrayPrototypeConstructorModified = 26, - kArrayInstanceProtoModified = 27, - kArrayInstanceConstructorModified = 28, - kLegacyFunctionDeclaration = 29, - kRegExpPrototypeSourceGetter = 30, - kRegExpPrototypeOldFlagGetter = 31, - kDecimalWithLeadingZeroInStrictMode = 32, - kLegacyDateParser = 33, - kDefineGetterOrSetterWouldThrow = 34, - kFunctionConstructorReturnedUndefined = 35, - kAssigmentExpressionLHSIsCallInSloppy = 36, - kAssigmentExpressionLHSIsCallInStrict = 37, - kPromiseConstructorReturnedUndefined = 38, - - // If you add new values here, you'll also need to update Chromium's: - // UseCounter.h, V8PerIsolateData.cpp, histograms.xml - kUseCounterFeatureCount // This enum value must be last. - }; - - enum MessageErrorLevel { - kMessageLog = (1 << 0), - kMessageDebug = (1 << 1), - kMessageInfo = (1 << 2), - kMessageError = (1 << 3), - kMessageWarning = (1 << 4), - kMessageAll = kMessageLog | kMessageDebug | kMessageInfo | kMessageError | - kMessageWarning, - }; - - typedef void (*UseCounterCallback)(Isolate* isolate, - UseCounterFeature feature); - - - /** - * Creates a new isolate. Does not change the currently entered - * isolate. - * - * When an isolate is no longer used its resources should be freed - * by calling Dispose(). Using the delete operator is not allowed. - * - * V8::Initialize() must have run prior to this. - */ - static Isolate* New(const CreateParams& params); - - /** - * Returns the entered isolate for the current thread or NULL in - * case there is no current isolate. - * - * This method must not be invoked before V8::Initialize() was invoked. - */ - static Isolate* GetCurrent(); - - /** - * Custom callback used by embedders to help V8 determine if it should abort - * when it throws and no internal handler is predicted to catch the - * exception. If --abort-on-uncaught-exception is used on the command line, - * then V8 will abort if either: - * - no custom callback is set. - * - the custom callback set returns true. - * Otherwise, the custom callback will not be called and V8 will not abort. - */ - typedef bool (*AbortOnUncaughtExceptionCallback)(Isolate*); - void SetAbortOnUncaughtExceptionCallback( - AbortOnUncaughtExceptionCallback callback); - - /** - * Optional notification that the system is running low on memory. - * V8 uses these notifications to guide heuristics. - * It is allowed to call this function from another thread while - * the isolate is executing long running JavaScript code. - */ - void MemoryPressureNotification(MemoryPressureLevel level); - - /** - * Methods below this point require holding a lock (using Locker) in - * a multi-threaded environment. - */ - - /** - * Sets this isolate as the entered one for the current thread. - * Saves the previously entered one (if any), so that it can be - * restored when exiting. Re-entering an isolate is allowed. - */ - void Enter(); - - /** - * Exits this isolate by restoring the previously entered one in the - * current thread. The isolate may still stay the same, if it was - * entered more than once. - * - * Requires: this == Isolate::GetCurrent(). - */ - void Exit(); - - /** - * Disposes the isolate. The isolate must not be entered by any - * thread to be disposable. - */ - void Dispose(); - - /** - * Dumps activated low-level V8 internal stats. This can be used instead - * of performing a full isolate disposal. - */ - void DumpAndResetStats(); - - /** - * Discards all V8 thread-specific data for the Isolate. Should be used - * if a thread is terminating and it has used an Isolate that will outlive - * the thread -- all thread-specific data for an Isolate is discarded when - * an Isolate is disposed so this call is pointless if an Isolate is about - * to be Disposed. - */ - void DiscardThreadSpecificMetadata(); - - /** - * Associate embedder-specific data with the isolate. |slot| has to be - * between 0 and GetNumberOfDataSlots() - 1. - */ - V8_INLINE void SetData(uint32_t slot, void* data); - - /** - * Retrieve embedder-specific data from the isolate. - * Returns NULL if SetData has never been called for the given |slot|. - */ - V8_INLINE void* GetData(uint32_t slot); - - /** - * Returns the maximum number of available embedder data slots. Valid slots - * are in the range of 0 - GetNumberOfDataSlots() - 1. - */ - V8_INLINE static uint32_t GetNumberOfDataSlots(); - - /** - * Get statistics about the heap memory usage. - */ - void GetHeapStatistics(HeapStatistics* heap_statistics); - - /** - * Returns the number of spaces in the heap. - */ - size_t NumberOfHeapSpaces(); - - /** - * Get the memory usage of a space in the heap. - * - * \param space_statistics The HeapSpaceStatistics object to fill in - * statistics. - * \param index The index of the space to get statistics from, which ranges - * from 0 to NumberOfHeapSpaces() - 1. - * \returns true on success. - */ - bool GetHeapSpaceStatistics(HeapSpaceStatistics* space_statistics, - size_t index); - - /** - * Returns the number of types of objects tracked in the heap at GC. - */ - size_t NumberOfTrackedHeapObjectTypes(); - - /** - * Get statistics about objects in the heap. - * - * \param object_statistics The HeapObjectStatistics object to fill in - * statistics of objects of given type, which were live in the previous GC. - * \param type_index The index of the type of object to fill details about, - * which ranges from 0 to NumberOfTrackedHeapObjectTypes() - 1. - * \returns true on success. - */ - bool GetHeapObjectStatisticsAtLastGC(HeapObjectStatistics* object_statistics, - size_t type_index); - - /** - * Get statistics about code and its metadata in the heap. - * - * \param object_statistics The HeapCodeStatistics object to fill in - * statistics of code, bytecode and their metadata. - * \returns true on success. - */ - bool GetHeapCodeAndMetadataStatistics(HeapCodeStatistics* object_statistics); - - /** - * Get a call stack sample from the isolate. - * \param state Execution state. - * \param frames Caller allocated buffer to store stack frames. - * \param frames_limit Maximum number of frames to capture. The buffer must - * be large enough to hold the number of frames. - * \param sample_info The sample info is filled up by the function - * provides number of actual captured stack frames and - * the current VM state. - * \note GetStackSample should only be called when the JS thread is paused or - * interrupted. Otherwise the behavior is undefined. - */ - void GetStackSample(const RegisterState& state, void** frames, - size_t frames_limit, SampleInfo* sample_info); - - /** - * Adjusts the amount of registered external memory. Used to give V8 an - * indication of the amount of externally allocated memory that is kept alive - * by JavaScript objects. V8 uses this to decide when to perform global - * garbage collections. Registering externally allocated memory will trigger - * global garbage collections more often than it would otherwise in an attempt - * to garbage collect the JavaScript objects that keep the externally - * allocated memory alive. - * - * \param change_in_bytes the change in externally allocated memory that is - * kept alive by JavaScript objects. - * \returns the adjusted value. - */ - V8_INLINE int64_t - AdjustAmountOfExternalAllocatedMemory(int64_t change_in_bytes); - - /** - * Returns the number of phantom handles without callbacks that were reset - * by the garbage collector since the last call to this function. - */ - size_t NumberOfPhantomHandleResetsSinceLastCall(); - - /** - * Returns heap profiler for this isolate. Will return NULL until the isolate - * is initialized. - */ - HeapProfiler* GetHeapProfiler(); - - /** - * Returns CPU profiler for this isolate. Will return NULL unless the isolate - * is initialized. It is the embedder's responsibility to stop all CPU - * profiling activities if it has started any. - */ - V8_DEPRECATE_SOON("CpuProfiler should be created with CpuProfiler::New call.", - CpuProfiler* GetCpuProfiler()); - - /** Returns true if this isolate has a current context. */ - bool InContext(); - - /** - * Returns the context of the currently running JavaScript, or the context - * on the top of the stack if no JavaScript is running. - */ - Local<Context> GetCurrentContext(); - - /** - * Returns the context of the calling JavaScript code. That is the - * context of the top-most JavaScript frame. If there are no - * JavaScript frames an empty handle is returned. - */ - V8_DEPRECATE_SOON( - "Calling context concept is not compatible with tail calls, and will be " - "removed.", - Local<Context> GetCallingContext()); - - /** Returns the last context entered through V8's C++ API. */ - Local<Context> GetEnteredContext(); - - /** - * Returns either the last context entered through V8's C++ API, or the - * context of the currently running microtask while processing microtasks. - * If a context is entered while executing a microtask, that context is - * returned. - */ - Local<Context> GetEnteredOrMicrotaskContext(); - - /** - * Schedules an exception to be thrown when returning to JavaScript. When an - * exception has been scheduled it is illegal to invoke any JavaScript - * operation; the caller must return immediately and only after the exception - * has been handled does it become legal to invoke JavaScript operations. - */ - Local<Value> ThrowException(Local<Value> exception); - - typedef void (*GCCallback)(Isolate* isolate, GCType type, - GCCallbackFlags flags); - - /** - * Enables the host application to receive a notification before a - * garbage collection. Allocations are allowed in the callback function, - * but the callback is not re-entrant: if the allocation inside it will - * trigger the garbage collection, the callback won't be called again. - * It is possible to specify the GCType filter for your callback. But it is - * not possible to register the same callback function two times with - * different GCType filters. - */ - void AddGCPrologueCallback(GCCallback callback, - GCType gc_type_filter = kGCTypeAll); - - /** - * This function removes callback which was installed by - * AddGCPrologueCallback function. - */ - void RemoveGCPrologueCallback(GCCallback callback); - - /** - * Sets the embedder heap tracer for the isolate. - */ - void SetEmbedderHeapTracer(EmbedderHeapTracer* tracer); - - /** - * Enables the host application to receive a notification after a - * garbage collection. Allocations are allowed in the callback function, - * but the callback is not re-entrant: if the allocation inside it will - * trigger the garbage collection, the callback won't be called again. - * It is possible to specify the GCType filter for your callback. But it is - * not possible to register the same callback function two times with - * different GCType filters. - */ - void AddGCEpilogueCallback(GCCallback callback, - GCType gc_type_filter = kGCTypeAll); - - /** - * This function removes callback which was installed by - * AddGCEpilogueCallback function. - */ - void RemoveGCEpilogueCallback(GCCallback callback); - - /** - * Forcefully terminate the current thread of JavaScript execution - * in the given isolate. - * - * This method can be used by any thread even if that thread has not - * acquired the V8 lock with a Locker object. - */ - void TerminateExecution(); - - /** - * Is V8 terminating JavaScript execution. - * - * Returns true if JavaScript execution is currently terminating - * because of a call to TerminateExecution. In that case there are - * still JavaScript frames on the stack and the termination - * exception is still active. - */ - bool IsExecutionTerminating(); - - /** - * Resume execution capability in the given isolate, whose execution - * was previously forcefully terminated using TerminateExecution(). - * - * When execution is forcefully terminated using TerminateExecution(), - * the isolate can not resume execution until all JavaScript frames - * have propagated the uncatchable exception which is generated. This - * method allows the program embedding the engine to handle the - * termination event and resume execution capability, even if - * JavaScript frames remain on the stack. - * - * This method can be used by any thread even if that thread has not - * acquired the V8 lock with a Locker object. - */ - void CancelTerminateExecution(); - - /** - * Request V8 to interrupt long running JavaScript code and invoke - * the given |callback| passing the given |data| to it. After |callback| - * returns control will be returned to the JavaScript code. - * There may be a number of interrupt requests in flight. - * Can be called from another thread without acquiring a |Locker|. - * Registered |callback| must not reenter interrupted Isolate. - */ - void RequestInterrupt(InterruptCallback callback, void* data); - - /** - * Request garbage collection in this Isolate. It is only valid to call this - * function if --expose_gc was specified. - * - * This should only be used for testing purposes and not to enforce a garbage - * collection schedule. It has strong negative impact on the garbage - * collection performance. Use IdleNotificationDeadline() or - * LowMemoryNotification() instead to influence the garbage collection - * schedule. - */ - void RequestGarbageCollectionForTesting(GarbageCollectionType type); - - /** - * Set the callback to invoke for logging event. - */ - void SetEventLogger(LogEventCallback that); - - /** - * Adds a callback to notify the host application right before a script - * is about to run. If a script re-enters the runtime during executing, the - * BeforeCallEnteredCallback is invoked for each re-entrance. - * Executing scripts inside the callback will re-trigger the callback. - */ - void AddBeforeCallEnteredCallback(BeforeCallEnteredCallback callback); - - /** - * Removes callback that was installed by AddBeforeCallEnteredCallback. - */ - void RemoveBeforeCallEnteredCallback(BeforeCallEnteredCallback callback); - - /** - * Adds a callback to notify the host application when a script finished - * running. If a script re-enters the runtime during executing, the - * CallCompletedCallback is only invoked when the outer-most script - * execution ends. Executing scripts inside the callback do not trigger - * further callbacks. - */ - void AddCallCompletedCallback(CallCompletedCallback callback); - V8_DEPRECATE_SOON( - "Use callback with parameter", - void AddCallCompletedCallback(DeprecatedCallCompletedCallback callback)); - - /** - * Removes callback that was installed by AddCallCompletedCallback. - */ - void RemoveCallCompletedCallback(CallCompletedCallback callback); - V8_DEPRECATE_SOON( - "Use callback with parameter", - void RemoveCallCompletedCallback( - DeprecatedCallCompletedCallback callback)); - - /** - * Experimental: Set the PromiseHook callback for various promise - * lifecycle events. - */ - void SetPromiseHook(PromiseHook hook); - - /** - * Set callback to notify about promise reject with no handler, or - * revocation of such a previous notification once the handler is added. - */ - void SetPromiseRejectCallback(PromiseRejectCallback callback); - - /** - * Experimental: Runs the Microtask Work Queue until empty - * Any exceptions thrown by microtask callbacks are swallowed. - */ - void RunMicrotasks(); - - /** - * Experimental: Enqueues the callback to the Microtask Work Queue - */ - void EnqueueMicrotask(Local<Function> microtask); - - /** - * Experimental: Enqueues the callback to the Microtask Work Queue - */ - void EnqueueMicrotask(MicrotaskCallback microtask, void* data = NULL); - - /** - * Experimental: Controls how Microtasks are invoked. See MicrotasksPolicy - * for details. - */ - void SetMicrotasksPolicy(MicrotasksPolicy policy); - V8_DEPRECATE_SOON("Use SetMicrotasksPolicy", - void SetAutorunMicrotasks(bool autorun)); - - /** - * Experimental: Returns the policy controlling how Microtasks are invoked. - */ - MicrotasksPolicy GetMicrotasksPolicy() const; - V8_DEPRECATE_SOON("Use GetMicrotasksPolicy", - bool WillAutorunMicrotasks() const); - - /** - * Experimental: adds a callback to notify the host application after - * microtasks were run. The callback is triggered by explicit RunMicrotasks - * call or automatic microtasks execution (see SetAutorunMicrotasks). - * - * Callback will trigger even if microtasks were attempted to run, - * but the microtasks queue was empty and no single microtask was actually - * executed. - * - * Executing scriptsinside the callback will not re-trigger microtasks and - * the callback. - */ - void AddMicrotasksCompletedCallback(MicrotasksCompletedCallback callback); - - /** - * Removes callback that was installed by AddMicrotasksCompletedCallback. - */ - void RemoveMicrotasksCompletedCallback(MicrotasksCompletedCallback callback); - - /** - * Sets a callback for counting the number of times a feature of V8 is used. - */ - void SetUseCounterCallback(UseCounterCallback callback); - - /** - * Enables the host application to provide a mechanism for recording - * statistics counters. - */ - void SetCounterFunction(CounterLookupCallback); - - /** - * Enables the host application to provide a mechanism for recording - * histograms. The CreateHistogram function returns a - * histogram which will later be passed to the AddHistogramSample - * function. - */ - void SetCreateHistogramFunction(CreateHistogramCallback); - void SetAddHistogramSampleFunction(AddHistogramSampleCallback); - - /** - * Optional notification that the embedder is idle. - * V8 uses the notification to perform garbage collection. - * This call can be used repeatedly if the embedder remains idle. - * Returns true if the embedder should stop calling IdleNotificationDeadline - * until real work has been done. This indicates that V8 has done - * as much cleanup as it will be able to do. - * - * The deadline_in_seconds argument specifies the deadline V8 has to finish - * garbage collection work. deadline_in_seconds is compared with - * MonotonicallyIncreasingTime() and should be based on the same timebase as - * that function. There is no guarantee that the actual work will be done - * within the time limit. - */ - bool IdleNotificationDeadline(double deadline_in_seconds); - - V8_DEPRECATED("use IdleNotificationDeadline()", - bool IdleNotification(int idle_time_in_ms)); - - /** - * Optional notification that the system is running low on memory. - * V8 uses these notifications to attempt to free memory. - */ - void LowMemoryNotification(); - - /** - * Optional notification that a context has been disposed. V8 uses - * these notifications to guide the GC heuristic. Returns the number - * of context disposals - including this one - since the last time - * V8 had a chance to clean up. - * - * The optional parameter |dependant_context| specifies whether the disposed - * context was depending on state from other contexts or not. - */ - int ContextDisposedNotification(bool dependant_context = true); - - /** - * Optional notification that the isolate switched to the foreground. - * V8 uses these notifications to guide heuristics. - */ - void IsolateInForegroundNotification(); - - /** - * Optional notification that the isolate switched to the background. - * V8 uses these notifications to guide heuristics. - */ - void IsolateInBackgroundNotification(); - - /** - * Optional notification to tell V8 the current performance requirements - * of the embedder based on RAIL. - * V8 uses these notifications to guide heuristics. - * This is an unfinished experimental feature. Semantics and implementation - * may change frequently. - */ - void SetRAILMode(RAILMode rail_mode); - - /** - * Optional notification to tell V8 the current isolate is used for debugging - * and requires higher heap limit. - */ - void IncreaseHeapLimitForDebugging(); - - /** - * Restores the original heap limit after IncreaseHeapLimitForDebugging(). - */ - void RestoreOriginalHeapLimit(); - - /** - * Returns true if the heap limit was increased for debugging and the - * original heap limit was not restored yet. - */ - bool IsHeapLimitIncreasedForDebugging(); - - /** - * Allows the host application to provide the address of a function that is - * notified each time code is added, moved or removed. - * - * \param options options for the JIT code event handler. - * \param event_handler the JIT code event handler, which will be invoked - * each time code is added, moved or removed. - * \note \p event_handler won't get notified of existent code. - * \note since code removal notifications are not currently issued, the - * \p event_handler may get notifications of code that overlaps earlier - * code notifications. This happens when code areas are reused, and the - * earlier overlapping code areas should therefore be discarded. - * \note the events passed to \p event_handler and the strings they point to - * are not guaranteed to live past each call. The \p event_handler must - * copy strings and other parameters it needs to keep around. - * \note the set of events declared in JitCodeEvent::EventType is expected to - * grow over time, and the JitCodeEvent structure is expected to accrue - * new members. The \p event_handler function must ignore event codes - * it does not recognize to maintain future compatibility. - * \note Use Isolate::CreateParams to get events for code executed during - * Isolate setup. - */ - void SetJitCodeEventHandler(JitCodeEventOptions options, - JitCodeEventHandler event_handler); - - /** - * Modifies the stack limit for this Isolate. - * - * \param stack_limit An address beyond which the Vm's stack may not grow. - * - * \note If you are using threads then you should hold the V8::Locker lock - * while setting the stack limit and you must set a non-default stack - * limit separately for each thread. - */ - void SetStackLimit(uintptr_t stack_limit); - - /** - * Returns a memory range that can potentially contain jitted code. - * - * On Win64, embedders are advised to install function table callbacks for - * these ranges, as default SEH won't be able to unwind through jitted code. - * - * The first page of the code range is reserved for the embedder and is - * committed, writable, and executable. - * - * Might be empty on other platforms. - * - * https://code.google.com/p/v8/issues/detail?id=3598 - */ - void GetCodeRange(void** start, size_t* length_in_bytes); - - /** Set the callback to invoke in case of fatal errors. */ - void SetFatalErrorHandler(FatalErrorCallback that); - - /** Set the callback to invoke in case of OOM errors. */ - void SetOOMErrorHandler(OOMErrorCallback that); - - /** - * Set the callback to invoke to check if code generation from - * strings should be allowed. - */ - void SetAllowCodeGenerationFromStringsCallback( - AllowCodeGenerationFromStringsCallback callback); - - /** - * Embedder over{ride|load} injection points for wasm APIs. - */ - void SetWasmModuleCallback(ExtensionCallback callback); - void SetWasmCompileCallback(ExtensionCallback callback); - void SetWasmInstanceCallback(ExtensionCallback callback); - void SetWasmInstantiateCallback(ExtensionCallback callback); - - /** - * Check if V8 is dead and therefore unusable. This is the case after - * fatal errors such as out-of-memory situations. - */ - bool IsDead(); - - /** - * Adds a message listener (errors only). - * - * The same message listener can be added more than once and in that - * case it will be called more than once for each message. - * - * If data is specified, it will be passed to the callback when it is called. - * Otherwise, the exception object will be passed to the callback instead. - */ - bool AddMessageListener(MessageCallback that, - Local<Value> data = Local<Value>()); - - /** - * Adds a message listener. - * - * The same message listener can be added more than once and in that - * case it will be called more than once for each message. - * - * If data is specified, it will be passed to the callback when it is called. - * Otherwise, the exception object will be passed to the callback instead. - * - * A listener can listen for particular error levels by providing a mask. - */ - bool AddMessageListenerWithErrorLevel(MessageCallback that, - int message_levels, - Local<Value> data = Local<Value>()); - - /** - * Remove all message listeners from the specified callback function. - */ - void RemoveMessageListeners(MessageCallback that); - - /** Callback function for reporting failed access checks.*/ - void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback); - - /** - * Tells V8 to capture current stack trace when uncaught exception occurs - * and report it to the message listeners. The option is off by default. - */ - void SetCaptureStackTraceForUncaughtExceptions( - bool capture, int frame_limit = 10, - StackTrace::StackTraceOptions options = StackTrace::kOverview); - - /** - * Iterates through all external resources referenced from current isolate - * heap. GC is not invoked prior to iterating, therefore there is no - * guarantee that visited objects are still alive. - */ - void VisitExternalResources(ExternalResourceVisitor* visitor); - - /** - * Iterates through all the persistent handles in the current isolate's heap - * that have class_ids. - */ - void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor); - - /** - * Iterates through all the persistent handles in the current isolate's heap - * that have class_ids and are candidates to be marked as partially dependent - * handles. This will visit handles to young objects created since the last - * garbage collection but is free to visit an arbitrary superset of these - * objects. - */ - void VisitHandlesForPartialDependence(PersistentHandleVisitor* visitor); - - /** - * Iterates through all the persistent handles in the current isolate's heap - * that have class_ids and are weak to be marked as inactive if there is no - * pending activity for the handle. - */ - void VisitWeakHandles(PersistentHandleVisitor* visitor); - - /** - * Check if this isolate is in use. - * True if at least one thread Enter'ed this isolate. - */ - bool IsInUse(); - - /** - * Set whether calling Atomics.wait (a function that may block) is allowed in - * this isolate. This can also be configured via - * CreateParams::allow_atomics_wait. - */ - void SetAllowAtomicsWait(bool allow); - - Isolate() = delete; - ~Isolate() = delete; - Isolate(const Isolate&) = delete; - Isolate& operator=(const Isolate&) = delete; - void* operator new(size_t size) = delete; - void operator delete(void*, size_t) = delete; - - private: - template <class K, class V, class Traits> - friend class PersistentValueMapBase; - - void ReportExternalAllocationLimitReached(); -}; - -class V8_EXPORT StartupData { - public: - const char* data; - int raw_size; -}; - - -/** - * EntropySource is used as a callback function when v8 needs a source - * of entropy. - */ -typedef bool (*EntropySource)(unsigned char* buffer, size_t length); - -/** - * ReturnAddressLocationResolver is used as a callback function when v8 is - * resolving the location of a return address on the stack. Profilers that - * change the return address on the stack can use this to resolve the stack - * location to whereever the profiler stashed the original return address. - * - * \param return_addr_location A location on stack where a machine - * return address resides. - * \returns Either return_addr_location, or else a pointer to the profiler's - * copy of the original return address. - * - * \note The resolver function must not cause garbage collection. - */ -typedef uintptr_t (*ReturnAddressLocationResolver)( - uintptr_t return_addr_location); - - -/** - * Container class for static utility functions. - */ -class V8_EXPORT V8 { - public: - /** Set the callback to invoke in case of fatal errors. */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void SetFatalErrorHandler(FatalErrorCallback that)); - - /** - * Set the callback to invoke to check if code generation from - * strings should be allowed. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", void SetAllowCodeGenerationFromStringsCallback( - AllowCodeGenerationFromStringsCallback that)); - - /** - * Check if V8 is dead and therefore unusable. This is the case after - * fatal errors such as out-of-memory situations. - */ - V8_INLINE static V8_DEPRECATED("Use isolate version", bool IsDead()); - - /** - * Hand startup data to V8, in case the embedder has chosen to build - * V8 with external startup data. - * - * Note: - * - By default the startup data is linked into the V8 library, in which - * case this function is not meaningful. - * - If this needs to be called, it needs to be called before V8 - * tries to make use of its built-ins. - * - To avoid unnecessary copies of data, V8 will point directly into the - * given data blob, so pretty please keep it around until V8 exit. - * - Compression of the startup blob might be useful, but needs to - * handled entirely on the embedders' side. - * - The call will abort if the data is invalid. - */ - static void SetNativesDataBlob(StartupData* startup_blob); - static void SetSnapshotDataBlob(StartupData* startup_blob); - - /** - * Bootstrap an isolate and a context from scratch to create a startup - * snapshot. Include the side-effects of running the optional script. - * Returns { NULL, 0 } on failure. - * The caller acquires ownership of the data array in the return value. - */ - static StartupData CreateSnapshotDataBlob(const char* embedded_source = NULL); - - /** - * Bootstrap an isolate and a context from the cold startup blob, run the - * warm-up script to trigger code compilation. The side effects are then - * discarded. The resulting startup snapshot will include compiled code. - * Returns { NULL, 0 } on failure. - * The caller acquires ownership of the data array in the return value. - * The argument startup blob is untouched. - */ - static StartupData WarmUpSnapshotDataBlob(StartupData cold_startup_blob, - const char* warmup_source); - - /** - * Adds a message listener. - * - * The same message listener can be added more than once and in that - * case it will be called more than once for each message. - * - * If data is specified, it will be passed to the callback when it is called. - * Otherwise, the exception object will be passed to the callback instead. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - bool AddMessageListener(MessageCallback that, - Local<Value> data = Local<Value>())); - - /** - * Remove all message listeners from the specified callback function. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", void RemoveMessageListeners(MessageCallback that)); - - /** - * Tells V8 to capture current stack trace when uncaught exception occurs - * and report it to the message listeners. The option is off by default. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void SetCaptureStackTraceForUncaughtExceptions( - bool capture, int frame_limit = 10, - StackTrace::StackTraceOptions options = StackTrace::kOverview)); - - /** - * Sets V8 flags from a string. - */ - static void SetFlagsFromString(const char* str, int length); - - /** - * Sets V8 flags from the command line. - */ - static void SetFlagsFromCommandLine(int* argc, - char** argv, - bool remove_flags); - - /** Get the version string. */ - static const char* GetVersion(); - - /** Callback function for reporting failed access checks.*/ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void SetFailedAccessCheckCallbackFunction(FailedAccessCheckCallback)); - - /** - * Enables the host application to receive a notification before a - * garbage collection. Allocations are not allowed in the - * callback function, you therefore cannot manipulate objects (set - * or delete properties for example) since it is possible such - * operations will result in the allocation of objects. It is possible - * to specify the GCType filter for your callback. But it is not possible to - * register the same callback function two times with different - * GCType filters. - */ - static V8_DEPRECATED( - "Use isolate version", - void AddGCPrologueCallback(GCCallback callback, - GCType gc_type_filter = kGCTypeAll)); - - /** - * This function removes callback which was installed by - * AddGCPrologueCallback function. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void RemoveGCPrologueCallback(GCCallback callback)); - - /** - * Enables the host application to receive a notification after a - * garbage collection. Allocations are not allowed in the - * callback function, you therefore cannot manipulate objects (set - * or delete properties for example) since it is possible such - * operations will result in the allocation of objects. It is possible - * to specify the GCType filter for your callback. But it is not possible to - * register the same callback function two times with different - * GCType filters. - */ - static V8_DEPRECATED( - "Use isolate version", - void AddGCEpilogueCallback(GCCallback callback, - GCType gc_type_filter = kGCTypeAll)); - - /** - * This function removes callback which was installed by - * AddGCEpilogueCallback function. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void RemoveGCEpilogueCallback(GCCallback callback)); - - /** - * Initializes V8. This function needs to be called before the first Isolate - * is created. It always returns true. - */ - static bool Initialize(); - - /** - * Allows the host application to provide a callback which can be used - * as a source of entropy for random number generators. - */ - static void SetEntropySource(EntropySource source); - - /** - * Allows the host application to provide a callback that allows v8 to - * cooperate with a profiler that rewrites return addresses on stack. - */ - static void SetReturnAddressLocationResolver( - ReturnAddressLocationResolver return_address_resolver); - - /** - * Forcefully terminate the current thread of JavaScript execution - * in the given isolate. - * - * This method can be used by any thread even if that thread has not - * acquired the V8 lock with a Locker object. - * - * \param isolate The isolate in which to terminate the current JS execution. - */ - V8_INLINE static V8_DEPRECATED("Use isolate version", - void TerminateExecution(Isolate* isolate)); - - /** - * Is V8 terminating JavaScript execution. - * - * Returns true if JavaScript execution is currently terminating - * because of a call to TerminateExecution. In that case there are - * still JavaScript frames on the stack and the termination - * exception is still active. - * - * \param isolate The isolate in which to check. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - bool IsExecutionTerminating(Isolate* isolate = NULL)); - - /** - * Resume execution capability in the given isolate, whose execution - * was previously forcefully terminated using TerminateExecution(). - * - * When execution is forcefully terminated using TerminateExecution(), - * the isolate can not resume execution until all JavaScript frames - * have propagated the uncatchable exception which is generated. This - * method allows the program embedding the engine to handle the - * termination event and resume execution capability, even if - * JavaScript frames remain on the stack. - * - * This method can be used by any thread even if that thread has not - * acquired the V8 lock with a Locker object. - * - * \param isolate The isolate in which to resume execution capability. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", void CancelTerminateExecution(Isolate* isolate)); - - /** - * Releases any resources used by v8 and stops any utility threads - * that may be running. Note that disposing v8 is permanent, it - * cannot be reinitialized. - * - * It should generally not be necessary to dispose v8 before exiting - * a process, this should happen automatically. It is only necessary - * to use if the process needs the resources taken up by v8. - */ - static bool Dispose(); - - /** - * Iterates through all external resources referenced from current isolate - * heap. GC is not invoked prior to iterating, therefore there is no - * guarantee that visited objects are still alive. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void VisitExternalResources(ExternalResourceVisitor* visitor)); - - /** - * Iterates through all the persistent handles in the current isolate's heap - * that have class_ids. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void VisitHandlesWithClassIds(PersistentHandleVisitor* visitor)); - - /** - * Iterates through all the persistent handles in isolate's heap that have - * class_ids. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void VisitHandlesWithClassIds(Isolate* isolate, - PersistentHandleVisitor* visitor)); - - /** - * Iterates through all the persistent handles in the current isolate's heap - * that have class_ids and are candidates to be marked as partially dependent - * handles. This will visit handles to young objects created since the last - * garbage collection but is free to visit an arbitrary superset of these - * objects. - */ - V8_INLINE static V8_DEPRECATED( - "Use isolate version", - void VisitHandlesForPartialDependence(Isolate* isolate, - PersistentHandleVisitor* visitor)); - - /** - * Initialize the ICU library bundled with V8. The embedder should only - * invoke this method when using the bundled ICU. Returns true on success. - * - * If V8 was compiled with the ICU data in an external file, the location - * of the data file has to be provided. - */ - V8_DEPRECATE_SOON( - "Use version with default location.", - static bool InitializeICU(const char* icu_data_file = nullptr)); - - /** - * Initialize the ICU library bundled with V8. The embedder should only - * invoke this method when using the bundled ICU. If V8 was compiled with - * the ICU data in an external file and when the default location of that - * file should be used, a path to the executable must be provided. - * Returns true on success. - * - * The default is a file called icudtl.dat side-by-side with the executable. - * - * Optionally, the location of the data file can be provided to override the - * default. - */ - static bool InitializeICUDefaultLocation(const char* exec_path, - const char* icu_data_file = nullptr); - - /** - * Initialize the external startup data. The embedder only needs to - * invoke this method when external startup data was enabled in a build. - * - * If V8 was compiled with the startup data in an external file, then - * V8 needs to be given those external files during startup. There are - * three ways to do this: - * - InitializeExternalStartupData(const char*) - * This will look in the given directory for files "natives_blob.bin" - * and "snapshot_blob.bin" - which is what the default build calls them. - * - InitializeExternalStartupData(const char*, const char*) - * As above, but will directly use the two given file names. - * - Call SetNativesDataBlob, SetNativesDataBlob. - * This will read the blobs from the given data structures and will - * not perform any file IO. - */ - static void InitializeExternalStartupData(const char* directory_path); - static void InitializeExternalStartupData(const char* natives_blob, - const char* snapshot_blob); - /** - * Sets the v8::Platform to use. This should be invoked before V8 is - * initialized. - */ - static void InitializePlatform(Platform* platform); - - /** - * Clears all references to the v8::Platform. This should be invoked after - * V8 was disposed. - */ - static void ShutdownPlatform(); - -#if V8_OS_LINUX && V8_TARGET_ARCH_X64 && !V8_OS_ANDROID - /** - * Give the V8 signal handler a chance to handle a fault. - * - * This function determines whether a memory access violation can be recovered - * by V8. If so, it will return true and modify context to return to a code - * fragment that can recover from the fault. Otherwise, TryHandleSignal will - * return false. - * - * The parameters to this function correspond to those passed to a Linux - * signal handler. - * - * \param signal_number The signal number. - * - * \param info A pointer to the siginfo_t structure provided to the signal - * handler. - * - * \param context The third argument passed to the Linux signal handler, which - * points to a ucontext_t structure. - */ - static bool TryHandleSignal(int signal_number, void* info, void* context); -#endif // V8_OS_LINUX - - /** - * Enable the default signal handler rather than using one provided by the - * embedder. - */ - static bool RegisterDefaultSignalHandler(); - - private: - V8(); - - static internal::Object** GlobalizeReference(internal::Isolate* isolate, - internal::Object** handle); - static internal::Object** CopyPersistent(internal::Object** handle); - static void DisposeGlobal(internal::Object** global_handle); - static void MakeWeak(internal::Object** location, void* data, - WeakCallbackInfo<void>::Callback weak_callback, - WeakCallbackType type); - static void MakeWeak(internal::Object** location, void* data, - // Must be 0 or -1. - int internal_field_index1, - // Must be 1 or -1. - int internal_field_index2, - WeakCallbackInfo<void>::Callback weak_callback); - static void MakeWeak(internal::Object*** location_addr); - static void* ClearWeak(internal::Object** location); - static Value* Eternalize(Isolate* isolate, Value* handle); - - static void RegisterExternallyReferencedObject(internal::Object** object, - internal::Isolate* isolate); - - template <class K, class V, class T> - friend class PersistentValueMapBase; - - static void FromJustIsNothing(); - static void ToLocalEmpty(); - static void InternalFieldOutOfBounds(int index); - template <class T> friend class Local; - template <class T> - friend class MaybeLocal; - template <class T> - friend class Maybe; - template <class T> - friend class WeakCallbackInfo; - template <class T> friend class Eternal; - template <class T> friend class PersistentBase; - template <class T, class M> friend class Persistent; - friend class Context; -}; - -/** - * Helper class to create a snapshot data blob. - */ -class V8_EXPORT SnapshotCreator { - public: - enum class FunctionCodeHandling { kClear, kKeep }; - - /** - * Create and enter an isolate, and set it up for serialization. - * The isolate is either created from scratch or from an existing snapshot. - * The caller keeps ownership of the argument snapshot. - * \param existing_blob existing snapshot from which to create this one. - * \param external_references a null-terminated array of external references - * that must be equivalent to CreateParams::external_references. - */ - SnapshotCreator(intptr_t* external_references = nullptr, - StartupData* existing_blob = nullptr); - - ~SnapshotCreator(); - - /** - * \returns the isolate prepared by the snapshot creator. - */ - Isolate* GetIsolate(); - - /** - * Set the default context to be included in the snapshot blob. - * The snapshot will not contain the global proxy, and we expect one or a - * global object template to create one, to be provided upon deserialization. - */ - void SetDefaultContext(Local<Context> context); - - /** - * Add additional context to be included in the snapshot blob. - * The snapshot will include the global proxy. - * - * \param callback optional callback to serialize internal fields. - * - * \returns the index of the context in the snapshot blob. - */ - size_t AddContext(Local<Context> context, - SerializeInternalFieldsCallback callback = - SerializeInternalFieldsCallback()); - - /** - * Add a template to be included in the snapshot blob. - * \returns the index of the template in the snapshot blob. - */ - size_t AddTemplate(Local<Template> template_obj); - - /** - * Created a snapshot data blob. - * This must not be called from within a handle scope. - * \param function_code_handling whether to include compiled function code - * in the snapshot. - * \returns { nullptr, 0 } on failure, and a startup snapshot on success. The - * caller acquires ownership of the data array in the return value. - */ - StartupData CreateBlob(FunctionCodeHandling function_code_handling); - - // Disallow copying and assigning. - SnapshotCreator(const SnapshotCreator&) = delete; - void operator=(const SnapshotCreator&) = delete; - - private: - void* data_; -}; - -/** - * A simple Maybe type, representing an object which may or may not have a - * value, see https://hackage.haskell.org/package/base/docs/Data-Maybe.html. - * - * If an API method returns a Maybe<>, the API method can potentially fail - * either because an exception is thrown, or because an exception is pending, - * e.g. because a previous API call threw an exception that hasn't been caught - * yet, or because a TerminateExecution exception was thrown. In that case, a - * "Nothing" value is returned. - */ -template <class T> -class Maybe { - public: - V8_INLINE bool IsNothing() const { return !has_value_; } - V8_INLINE bool IsJust() const { return has_value_; } - - /** - * An alias for |FromJust|. Will crash if the Maybe<> is nothing. - */ - V8_INLINE T ToChecked() const { return FromJust(); } - - /** - * Converts this Maybe<> to a value of type T. If this Maybe<> is - * nothing (empty), |false| is returned and |out| is left untouched. - */ - V8_WARN_UNUSED_RESULT V8_INLINE bool To(T* out) const { - if (V8_LIKELY(IsJust())) *out = value_; - return IsJust(); - } - - /** - * Converts this Maybe<> to a value of type T. If this Maybe<> is - * nothing (empty), V8 will crash the process. - */ - V8_INLINE T FromJust() const { - if (V8_UNLIKELY(!IsJust())) V8::FromJustIsNothing(); - return value_; - } - - /** - * Converts this Maybe<> to a value of type T, using a default value if this - * Maybe<> is nothing (empty). - */ - V8_INLINE T FromMaybe(const T& default_value) const { - return has_value_ ? value_ : default_value; - } - - V8_INLINE bool operator==(const Maybe& other) const { - return (IsJust() == other.IsJust()) && - (!IsJust() || FromJust() == other.FromJust()); - } - - V8_INLINE bool operator!=(const Maybe& other) const { - return !operator==(other); - } - - private: - Maybe() : has_value_(false) {} - explicit Maybe(const T& t) : has_value_(true), value_(t) {} - - bool has_value_; - T value_; - - template <class U> - friend Maybe<U> Nothing(); - template <class U> - friend Maybe<U> Just(const U& u); -}; - - -template <class T> -inline Maybe<T> Nothing() { - return Maybe<T>(); -} - - -template <class T> -inline Maybe<T> Just(const T& t) { - return Maybe<T>(t); -} - - -/** - * An external exception handler. - */ -class V8_EXPORT TryCatch { - public: - /** - * Creates a new try/catch block and registers it with v8. Note that - * all TryCatch blocks should be stack allocated because the memory - * location itself is compared against JavaScript try/catch blocks. - */ - V8_DEPRECATED("Use isolate version", TryCatch()); - - /** - * Creates a new try/catch block and registers it with v8. Note that - * all TryCatch blocks should be stack allocated because the memory - * location itself is compared against JavaScript try/catch blocks. - */ - TryCatch(Isolate* isolate); - - /** - * Unregisters and deletes this try/catch block. - */ - ~TryCatch(); - - /** - * Returns true if an exception has been caught by this try/catch block. - */ - bool HasCaught() const; - - /** - * For certain types of exceptions, it makes no sense to continue execution. - * - * If CanContinue returns false, the correct action is to perform any C++ - * cleanup needed and then return. If CanContinue returns false and - * HasTerminated returns true, it is possible to call - * CancelTerminateExecution in order to continue calling into the engine. - */ - bool CanContinue() const; - - /** - * Returns true if an exception has been caught due to script execution - * being terminated. - * - * There is no JavaScript representation of an execution termination - * exception. Such exceptions are thrown when the TerminateExecution - * methods are called to terminate a long-running script. - * - * If such an exception has been thrown, HasTerminated will return true, - * indicating that it is possible to call CancelTerminateExecution in order - * to continue calling into the engine. - */ - bool HasTerminated() const; - - /** - * Throws the exception caught by this TryCatch in a way that avoids - * it being caught again by this same TryCatch. As with ThrowException - * it is illegal to execute any JavaScript operations after calling - * ReThrow; the caller must return immediately to where the exception - * is caught. - */ - Local<Value> ReThrow(); - - /** - * Returns the exception caught by this try/catch block. If no exception has - * been caught an empty handle is returned. - * - * The returned handle is valid until this TryCatch block has been destroyed. - */ - Local<Value> Exception() const; - - /** - * Returns the .stack property of the thrown object. If no .stack - * property is present an empty handle is returned. - */ - V8_DEPRECATE_SOON("Use maybe version.", Local<Value> StackTrace() const); - V8_WARN_UNUSED_RESULT MaybeLocal<Value> StackTrace( - Local<Context> context) const; - - /** - * Returns the message associated with this exception. If there is - * no message associated an empty handle is returned. - * - * The returned handle is valid until this TryCatch block has been - * destroyed. - */ - Local<v8::Message> Message() const; - - /** - * Clears any exceptions that may have been caught by this try/catch block. - * After this method has been called, HasCaught() will return false. Cancels - * the scheduled exception if it is caught and ReThrow() is not called before. - * - * It is not necessary to clear a try/catch block before using it again; if - * another exception is thrown the previously caught exception will just be - * overwritten. However, it is often a good idea since it makes it easier - * to determine which operation threw a given exception. - */ - void Reset(); - - /** - * Set verbosity of the external exception handler. - * - * By default, exceptions that are caught by an external exception - * handler are not reported. Call SetVerbose with true on an - * external exception handler to have exceptions caught by the - * handler reported as if they were not caught. - */ - void SetVerbose(bool value); - - /** - * Returns true if verbosity is enabled. - */ - bool IsVerbose() const; - - /** - * Set whether or not this TryCatch should capture a Message object - * which holds source information about where the exception - * occurred. True by default. - */ - void SetCaptureMessage(bool value); - - /** - * There are cases when the raw address of C++ TryCatch object cannot be - * used for comparisons with addresses into the JS stack. The cases are: - * 1) ARM, ARM64 and MIPS simulators which have separate JS stack. - * 2) Address sanitizer allocates local C++ object in the heap when - * UseAfterReturn mode is enabled. - * This method returns address that can be used for comparisons with - * addresses into the JS stack. When neither simulator nor ASAN's - * UseAfterReturn is enabled, then the address returned will be the address - * of the C++ try catch handler itself. - */ - static void* JSStackComparableAddress(TryCatch* handler) { - if (handler == NULL) return NULL; - return handler->js_stack_comparable_address_; - } - - TryCatch(const TryCatch&) = delete; - void operator=(const TryCatch&) = delete; - void* operator new(size_t size); - void operator delete(void*, size_t); - - private: - void ResetInternal(); - - internal::Isolate* isolate_; - TryCatch* next_; - void* exception_; - void* message_obj_; - void* js_stack_comparable_address_; - bool is_verbose_ : 1; - bool can_continue_ : 1; - bool capture_message_ : 1; - bool rethrow_ : 1; - bool has_terminated_ : 1; - - friend class internal::Isolate; -}; - - -// --- Context --- - - -/** - * A container for extension names. - */ -class V8_EXPORT ExtensionConfiguration { - public: - ExtensionConfiguration() : name_count_(0), names_(NULL) { } - ExtensionConfiguration(int name_count, const char* names[]) - : name_count_(name_count), names_(names) { } - - const char** begin() const { return &names_[0]; } - const char** end() const { return &names_[name_count_]; } - - private: - const int name_count_; - const char** names_; -}; - -/** - * A sandboxed execution context with its own set of built-in objects - * and functions. - */ -class V8_EXPORT Context { - public: - /** - * Returns the global proxy object. - * - * Global proxy object is a thin wrapper whose prototype points to actual - * context's global object with the properties like Object, etc. This is done - * that way for security reasons (for more details see - * https://wiki.mozilla.org/Gecko:SplitWindow). - * - * Please note that changes to global proxy object prototype most probably - * would break VM---v8 expects only global object as a prototype of global - * proxy object. - */ - Local<Object> Global(); - - /** - * Detaches the global object from its context before - * the global object can be reused to create a new context. - */ - void DetachGlobal(); - - /** - * Creates a new context and returns a handle to the newly allocated - * context. - * - * \param isolate The isolate in which to create the context. - * - * \param extensions An optional extension configuration containing - * the extensions to be installed in the newly created context. - * - * \param global_template An optional object template from which the - * global object for the newly created context will be created. - * - * \param global_object An optional global object to be reused for - * the newly created context. This global object must have been - * created by a previous call to Context::New with the same global - * template. The state of the global object will be completely reset - * and only object identify will remain. - */ - static Local<Context> New( - Isolate* isolate, ExtensionConfiguration* extensions = NULL, - MaybeLocal<ObjectTemplate> global_template = MaybeLocal<ObjectTemplate>(), - MaybeLocal<Value> global_object = MaybeLocal<Value>()); - - /** - * Create a new context from a (non-default) context snapshot. There - * is no way to provide a global object template since we do not create - * a new global object from template, but we can reuse a global object. - * - * \param isolate See v8::Context::New. - * - * \param context_snapshot_index The index of the context snapshot to - * deserialize from. Use v8::Context::New for the default snapshot. - * - * \param embedder_fields_deserializer Optional callback to deserialize - * internal fields. It should match the SerializeInternalFieldCallback used - * to serialize. - * - * \param extensions See v8::Context::New. - * - * \param global_object See v8::Context::New. - */ - - static MaybeLocal<Context> FromSnapshot( - Isolate* isolate, size_t context_snapshot_index, - DeserializeInternalFieldsCallback embedder_fields_deserializer = - DeserializeInternalFieldsCallback(), - ExtensionConfiguration* extensions = nullptr, - MaybeLocal<Value> global_object = MaybeLocal<Value>()); - - /** - * Returns an global object that isn't backed by an actual context. - * - * The global template needs to have access checks with handlers installed. - * If an existing global object is passed in, the global object is detached - * from its context. - * - * Note that this is different from a detached context where all accesses to - * the global proxy will fail. Instead, the access check handlers are invoked. - * - * It is also not possible to detach an object returned by this method. - * Instead, the access check handlers need to return nothing to achieve the - * same effect. - * - * It is possible, however, to create a new context from the global object - * returned by this method. - */ - static MaybeLocal<Object> NewRemoteContext( - Isolate* isolate, Local<ObjectTemplate> global_template, - MaybeLocal<Value> global_object = MaybeLocal<Value>()); - - /** - * Sets the security token for the context. To access an object in - * another context, the security tokens must match. - */ - void SetSecurityToken(Local<Value> token); - - /** Restores the security token to the default value. */ - void UseDefaultSecurityToken(); - - /** Returns the security token of this context.*/ - Local<Value> GetSecurityToken(); - - /** - * Enter this context. After entering a context, all code compiled - * and run is compiled and run in this context. If another context - * is already entered, this old context is saved so it can be - * restored when the new context is exited. - */ - void Enter(); - - /** - * Exit this context. Exiting the current context restores the - * context that was in place when entering the current context. - */ - void Exit(); - - /** Returns an isolate associated with a current context. */ - Isolate* GetIsolate(); - - /** - * The field at kDebugIdIndex used to be reserved for the inspector. - * It now serves no purpose. - */ - enum EmbedderDataFields { kDebugIdIndex = 0 }; - - /** - * Gets the embedder data with the given index, which must have been set by a - * previous call to SetEmbedderData with the same index. - */ - V8_INLINE Local<Value> GetEmbedderData(int index); - - /** - * Gets the binding object used by V8 extras. Extra natives get a reference - * to this object and can use it to "export" functionality by adding - * properties. Extra natives can also "import" functionality by accessing - * properties added by the embedder using the V8 API. - */ - Local<Object> GetExtrasBindingObject(); - - /** - * Sets the embedder data with the given index, growing the data as - * needed. Note that index 0 currently has a special meaning for Chrome's - * debugger. - */ - void SetEmbedderData(int index, Local<Value> value); - - /** - * Gets a 2-byte-aligned native pointer from the embedder data with the given - * index, which must have been set by a previous call to - * SetAlignedPointerInEmbedderData with the same index. Note that index 0 - * currently has a special meaning for Chrome's debugger. - */ - V8_INLINE void* GetAlignedPointerFromEmbedderData(int index); - - /** - * Sets a 2-byte-aligned native pointer in the embedder data with the given - * index, growing the data as needed. Note that index 0 currently has a - * special meaning for Chrome's debugger. - */ - void SetAlignedPointerInEmbedderData(int index, void* value); - - /** - * Control whether code generation from strings is allowed. Calling - * this method with false will disable 'eval' and the 'Function' - * constructor for code running in this context. If 'eval' or the - * 'Function' constructor are used an exception will be thrown. - * - * If code generation from strings is not allowed the - * V8::AllowCodeGenerationFromStrings callback will be invoked if - * set before blocking the call to 'eval' or the 'Function' - * constructor. If that callback returns true, the call will be - * allowed, otherwise an exception will be thrown. If no callback is - * set an exception will be thrown. - */ - void AllowCodeGenerationFromStrings(bool allow); - - /** - * Returns true if code generation from strings is allowed for the context. - * For more details see AllowCodeGenerationFromStrings(bool) documentation. - */ - bool IsCodeGenerationFromStringsAllowed(); - - /** - * Sets the error description for the exception that is thrown when - * code generation from strings is not allowed and 'eval' or the 'Function' - * constructor are called. - */ - void SetErrorMessageForCodeGenerationFromStrings(Local<String> message); - - /** - * Estimate the memory in bytes retained by this context. - */ - V8_DEPRECATED("no longer supported", size_t EstimatedSize()); - - /** - * Stack-allocated class which sets the execution context for all - * operations executed within a local scope. - */ - class Scope { - public: - explicit V8_INLINE Scope(Local<Context> context) : context_(context) { - context_->Enter(); - } - V8_INLINE ~Scope() { context_->Exit(); } - - private: - Local<Context> context_; - }; - - private: - friend class Value; - friend class Script; - friend class Object; - friend class Function; - - Local<Value> SlowGetEmbedderData(int index); - void* SlowGetAlignedPointerFromEmbedderData(int index); -}; - - -/** - * Multiple threads in V8 are allowed, but only one thread at a time is allowed - * to use any given V8 isolate, see the comments in the Isolate class. The - * definition of 'using a V8 isolate' includes accessing handles or holding onto - * object pointers obtained from V8 handles while in the particular V8 isolate. - * It is up to the user of V8 to ensure, perhaps with locking, that this - * constraint is not violated. In addition to any other synchronization - * mechanism that may be used, the v8::Locker and v8::Unlocker classes must be - * used to signal thread switches to V8. - * - * v8::Locker is a scoped lock object. While it's active, i.e. between its - * construction and destruction, the current thread is allowed to use the locked - * isolate. V8 guarantees that an isolate can be locked by at most one thread at - * any time. In other words, the scope of a v8::Locker is a critical section. - * - * Sample usage: -* \code - * ... - * { - * v8::Locker locker(isolate); - * v8::Isolate::Scope isolate_scope(isolate); - * ... - * // Code using V8 and isolate goes here. - * ... - * } // Destructor called here - * \endcode - * - * If you wish to stop using V8 in a thread A you can do this either by - * destroying the v8::Locker object as above or by constructing a v8::Unlocker - * object: - * - * \code - * { - * isolate->Exit(); - * v8::Unlocker unlocker(isolate); - * ... - * // Code not using V8 goes here while V8 can run in another thread. - * ... - * } // Destructor called here. - * isolate->Enter(); - * \endcode - * - * The Unlocker object is intended for use in a long-running callback from V8, - * where you want to release the V8 lock for other threads to use. - * - * The v8::Locker is a recursive lock, i.e. you can lock more than once in a - * given thread. This can be useful if you have code that can be called either - * from code that holds the lock or from code that does not. The Unlocker is - * not recursive so you can not have several Unlockers on the stack at once, and - * you can not use an Unlocker in a thread that is not inside a Locker's scope. - * - * An unlocker will unlock several lockers if it has to and reinstate the - * correct depth of locking on its destruction, e.g.: - * - * \code - * // V8 not locked. - * { - * v8::Locker locker(isolate); - * Isolate::Scope isolate_scope(isolate); - * // V8 locked. - * { - * v8::Locker another_locker(isolate); - * // V8 still locked (2 levels). - * { - * isolate->Exit(); - * v8::Unlocker unlocker(isolate); - * // V8 not locked. - * } - * isolate->Enter(); - * // V8 locked again (2 levels). - * } - * // V8 still locked (1 level). - * } - * // V8 Now no longer locked. - * \endcode - */ -class V8_EXPORT Unlocker { - public: - /** - * Initialize Unlocker for a given Isolate. - */ - V8_INLINE explicit Unlocker(Isolate* isolate) { Initialize(isolate); } - - ~Unlocker(); - private: - void Initialize(Isolate* isolate); - - internal::Isolate* isolate_; -}; - - -class V8_EXPORT Locker { - public: - /** - * Initialize Locker for a given Isolate. - */ - V8_INLINE explicit Locker(Isolate* isolate) { Initialize(isolate); } - - ~Locker(); - - /** - * Returns whether or not the locker for a given isolate, is locked by the - * current thread. - */ - static bool IsLocked(Isolate* isolate); - - /** - * Returns whether v8::Locker is being used by this V8 instance. - */ - static bool IsActive(); - - // Disallow copying and assigning. - Locker(const Locker&) = delete; - void operator=(const Locker&) = delete; - - private: - void Initialize(Isolate* isolate); - - bool has_lock_; - bool top_level_; - internal::Isolate* isolate_; -}; - - -// --- Implementation --- - - -namespace internal { - -const int kApiPointerSize = sizeof(void*); // NOLINT -const int kApiIntSize = sizeof(int); // NOLINT -const int kApiInt64Size = sizeof(int64_t); // NOLINT - -// Tag information for HeapObject. -const int kHeapObjectTag = 1; -const int kHeapObjectTagSize = 2; -const intptr_t kHeapObjectTagMask = (1 << kHeapObjectTagSize) - 1; - -// Tag information for Smi. -const int kSmiTag = 0; -const int kSmiTagSize = 1; -const intptr_t kSmiTagMask = (1 << kSmiTagSize) - 1; - -template <size_t ptr_size> struct SmiTagging; - -template<int kSmiShiftSize> -V8_INLINE internal::Object* IntToSmi(int value) { - int smi_shift_bits = kSmiTagSize + kSmiShiftSize; - uintptr_t tagged_value = - (static_cast<uintptr_t>(value) << smi_shift_bits) | kSmiTag; - return reinterpret_cast<internal::Object*>(tagged_value); -} - -// Smi constants for 32-bit systems. -template <> struct SmiTagging<4> { - enum { kSmiShiftSize = 0, kSmiValueSize = 31 }; - static int SmiShiftSize() { return kSmiShiftSize; } - static int SmiValueSize() { return kSmiValueSize; } - V8_INLINE static int SmiToInt(const internal::Object* value) { - int shift_bits = kSmiTagSize + kSmiShiftSize; - // Throw away top 32 bits and shift down (requires >> to be sign extending). - return static_cast<int>(reinterpret_cast<intptr_t>(value)) >> shift_bits; - } - V8_INLINE static internal::Object* IntToSmi(int value) { - return internal::IntToSmi<kSmiShiftSize>(value); - } - V8_INLINE static bool IsValidSmi(intptr_t value) { - // To be representable as an tagged small integer, the two - // most-significant bits of 'value' must be either 00 or 11 due to - // sign-extension. To check this we add 01 to the two - // most-significant bits, and check if the most-significant bit is 0 - // - // CAUTION: The original code below: - // bool result = ((value + 0x40000000) & 0x80000000) == 0; - // may lead to incorrect results according to the C language spec, and - // in fact doesn't work correctly with gcc4.1.1 in some cases: The - // compiler may produce undefined results in case of signed integer - // overflow. The computation must be done w/ unsigned ints. - return static_cast<uintptr_t>(value + 0x40000000U) < 0x80000000U; - } -}; - -// Smi constants for 64-bit systems. -template <> struct SmiTagging<8> { - enum { kSmiShiftSize = 31, kSmiValueSize = 32 }; - static int SmiShiftSize() { return kSmiShiftSize; } - static int SmiValueSize() { return kSmiValueSize; } - V8_INLINE static int SmiToInt(const internal::Object* value) { - int shift_bits = kSmiTagSize + kSmiShiftSize; - // Shift down and throw away top 32 bits. - return static_cast<int>(reinterpret_cast<intptr_t>(value) >> shift_bits); - } - V8_INLINE static internal::Object* IntToSmi(int value) { - return internal::IntToSmi<kSmiShiftSize>(value); - } - V8_INLINE static bool IsValidSmi(intptr_t value) { - // To be representable as a long smi, the value must be a 32-bit integer. - return (value == static_cast<int32_t>(value)); - } -}; - -typedef SmiTagging<kApiPointerSize> PlatformSmiTagging; -const int kSmiShiftSize = PlatformSmiTagging::kSmiShiftSize; -const int kSmiValueSize = PlatformSmiTagging::kSmiValueSize; -V8_INLINE static bool SmiValuesAre31Bits() { return kSmiValueSize == 31; } -V8_INLINE static bool SmiValuesAre32Bits() { return kSmiValueSize == 32; } - -/** - * This class exports constants and functionality from within v8 that - * is necessary to implement inline functions in the v8 api. Don't - * depend on functions and constants defined here. - */ -class Internals { - public: - // These values match non-compiler-dependent values defined within - // the implementation of v8. - static const int kHeapObjectMapOffset = 0; - static const int kMapInstanceTypeAndBitFieldOffset = - 1 * kApiPointerSize + kApiIntSize; - static const int kStringResourceOffset = 3 * kApiPointerSize; - - static const int kOddballKindOffset = 4 * kApiPointerSize + sizeof(double); - static const int kForeignAddressOffset = kApiPointerSize; - static const int kJSObjectHeaderSize = 3 * kApiPointerSize; - static const int kFixedArrayHeaderSize = 2 * kApiPointerSize; - static const int kContextHeaderSize = 2 * kApiPointerSize; - static const int kContextEmbedderDataIndex = 5; - static const int kFullStringRepresentationMask = 0x0f; - static const int kStringEncodingMask = 0x8; - static const int kExternalTwoByteRepresentationTag = 0x02; - static const int kExternalOneByteRepresentationTag = 0x0a; - - static const int kIsolateEmbedderDataOffset = 0 * kApiPointerSize; - static const int kExternalMemoryOffset = 4 * kApiPointerSize; - static const int kExternalMemoryLimitOffset = - kExternalMemoryOffset + kApiInt64Size; - static const int kIsolateRootsOffset = kExternalMemoryLimitOffset + - kApiInt64Size + kApiInt64Size + - kApiPointerSize + kApiPointerSize; - static const int kUndefinedValueRootIndex = 4; - static const int kTheHoleValueRootIndex = 5; - static const int kNullValueRootIndex = 6; - static const int kTrueValueRootIndex = 7; - static const int kFalseValueRootIndex = 8; - static const int kEmptyStringRootIndex = 9; - - static const int kNodeClassIdOffset = 1 * kApiPointerSize; - static const int kNodeFlagsOffset = 1 * kApiPointerSize + 3; - static const int kNodeStateMask = 0x7; - static const int kNodeStateIsWeakValue = 2; - static const int kNodeStateIsPendingValue = 3; - static const int kNodeStateIsNearDeathValue = 4; - static const int kNodeIsIndependentShift = 3; - static const int kNodeIsActiveShift = 4; - - static const int kJSApiObjectType = 0xbb; - static const int kJSObjectType = 0xbc; - static const int kFirstNonstringType = 0x80; - static const int kOddballType = 0x82; - static const int kForeignType = 0x86; - - static const int kUndefinedOddballKind = 5; - static const int kNullOddballKind = 3; - - static const uint32_t kNumIsolateDataSlots = 4; - - V8_EXPORT static void CheckInitializedImpl(v8::Isolate* isolate); - V8_INLINE static void CheckInitialized(v8::Isolate* isolate) { -#ifdef V8_ENABLE_CHECKS - CheckInitializedImpl(isolate); -#endif - } - - V8_INLINE static bool HasHeapObjectTag(const internal::Object* value) { - return ((reinterpret_cast<intptr_t>(value) & kHeapObjectTagMask) == - kHeapObjectTag); - } - - V8_INLINE static int SmiValue(const internal::Object* value) { - return PlatformSmiTagging::SmiToInt(value); - } - - V8_INLINE static internal::Object* IntToSmi(int value) { - return PlatformSmiTagging::IntToSmi(value); - } - - V8_INLINE static bool IsValidSmi(intptr_t value) { - return PlatformSmiTagging::IsValidSmi(value); - } - - V8_INLINE static int GetInstanceType(const internal::Object* obj) { - typedef internal::Object O; - O* map = ReadField<O*>(obj, kHeapObjectMapOffset); - // Map::InstanceType is defined so that it will always be loaded into - // the LS 8 bits of one 16-bit word, regardless of endianess. - return ReadField<uint16_t>(map, kMapInstanceTypeAndBitFieldOffset) & 0xff; - } - - V8_INLINE static int GetOddballKind(const internal::Object* obj) { - typedef internal::Object O; - return SmiValue(ReadField<O*>(obj, kOddballKindOffset)); - } - - V8_INLINE static bool IsExternalTwoByteString(int instance_type) { - int representation = (instance_type & kFullStringRepresentationMask); - return representation == kExternalTwoByteRepresentationTag; - } - - V8_INLINE static uint8_t GetNodeFlag(internal::Object** obj, int shift) { - uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; - return *addr & static_cast<uint8_t>(1U << shift); - } - - V8_INLINE static void UpdateNodeFlag(internal::Object** obj, - bool value, int shift) { - uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; - uint8_t mask = static_cast<uint8_t>(1U << shift); - *addr = static_cast<uint8_t>((*addr & ~mask) | (value << shift)); - } - - V8_INLINE static uint8_t GetNodeState(internal::Object** obj) { - uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; - return *addr & kNodeStateMask; - } - - V8_INLINE static void UpdateNodeState(internal::Object** obj, - uint8_t value) { - uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + kNodeFlagsOffset; - *addr = static_cast<uint8_t>((*addr & ~kNodeStateMask) | value); - } - - V8_INLINE static void SetEmbedderData(v8::Isolate* isolate, - uint32_t slot, - void* data) { - uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + - kIsolateEmbedderDataOffset + slot * kApiPointerSize; - *reinterpret_cast<void**>(addr) = data; - } - - V8_INLINE static void* GetEmbedderData(const v8::Isolate* isolate, - uint32_t slot) { - const uint8_t* addr = reinterpret_cast<const uint8_t*>(isolate) + - kIsolateEmbedderDataOffset + slot * kApiPointerSize; - return *reinterpret_cast<void* const*>(addr); - } - - V8_INLINE static internal::Object** GetRoot(v8::Isolate* isolate, - int index) { - uint8_t* addr = reinterpret_cast<uint8_t*>(isolate) + kIsolateRootsOffset; - return reinterpret_cast<internal::Object**>(addr + index * kApiPointerSize); - } - - template <typename T> - V8_INLINE static T ReadField(const internal::Object* ptr, int offset) { - const uint8_t* addr = - reinterpret_cast<const uint8_t*>(ptr) + offset - kHeapObjectTag; - return *reinterpret_cast<const T*>(addr); - } - - template <typename T> - V8_INLINE static T ReadEmbedderData(const v8::Context* context, int index) { - typedef internal::Object O; - typedef internal::Internals I; - O* ctx = *reinterpret_cast<O* const*>(context); - int embedder_data_offset = I::kContextHeaderSize + - (internal::kApiPointerSize * I::kContextEmbedderDataIndex); - O* embedder_data = I::ReadField<O*>(ctx, embedder_data_offset); - int value_offset = - I::kFixedArrayHeaderSize + (internal::kApiPointerSize * index); - return I::ReadField<T>(embedder_data, value_offset); - } -}; - -} // namespace internal - - -template <class T> -Local<T> Local<T>::New(Isolate* isolate, Local<T> that) { - return New(isolate, that.val_); -} - -template <class T> -Local<T> Local<T>::New(Isolate* isolate, const PersistentBase<T>& that) { - return New(isolate, that.val_); -} - - -template <class T> -Local<T> Local<T>::New(Isolate* isolate, T* that) { - if (that == NULL) return Local<T>(); - T* that_ptr = that; - internal::Object** p = reinterpret_cast<internal::Object**>(that_ptr); - return Local<T>(reinterpret_cast<T*>(HandleScope::CreateHandle( - reinterpret_cast<internal::Isolate*>(isolate), *p))); -} - - -template<class T> -template<class S> -void Eternal<T>::Set(Isolate* isolate, Local<S> handle) { - TYPE_CHECK(T, S); - val_ = reinterpret_cast<T*>( - V8::Eternalize(isolate, reinterpret_cast<Value*>(*handle))); -} - -template <class T> -Local<T> Eternal<T>::Get(Isolate* isolate) const { - // The eternal handle will never go away, so as with the roots, we don't even - // need to open a handle. - return Local<T>(val_); -} - - -template <class T> -Local<T> MaybeLocal<T>::ToLocalChecked() { - if (V8_UNLIKELY(val_ == nullptr)) V8::ToLocalEmpty(); - return Local<T>(val_); -} - - -template <class T> -void* WeakCallbackInfo<T>::GetInternalField(int index) const { -#ifdef V8_ENABLE_CHECKS - if (index < 0 || index >= kEmbedderFieldsInWeakCallback) { - V8::InternalFieldOutOfBounds(index); - } -#endif - return embedder_fields_[index]; -} - - -template <class T> -T* PersistentBase<T>::New(Isolate* isolate, T* that) { - if (that == NULL) return NULL; - internal::Object** p = reinterpret_cast<internal::Object**>(that); - return reinterpret_cast<T*>( - V8::GlobalizeReference(reinterpret_cast<internal::Isolate*>(isolate), - p)); -} - - -template <class T, class M> -template <class S, class M2> -void Persistent<T, M>::Copy(const Persistent<S, M2>& that) { - TYPE_CHECK(T, S); - this->Reset(); - if (that.IsEmpty()) return; - internal::Object** p = reinterpret_cast<internal::Object**>(that.val_); - this->val_ = reinterpret_cast<T*>(V8::CopyPersistent(p)); - M::Copy(that, this); -} - - -template <class T> -bool PersistentBase<T>::IsIndependent() const { - typedef internal::Internals I; - if (this->IsEmpty()) return false; - return I::GetNodeFlag(reinterpret_cast<internal::Object**>(this->val_), - I::kNodeIsIndependentShift); -} - - -template <class T> -bool PersistentBase<T>::IsNearDeath() const { - typedef internal::Internals I; - if (this->IsEmpty()) return false; - uint8_t node_state = - I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)); - return node_state == I::kNodeStateIsNearDeathValue || - node_state == I::kNodeStateIsPendingValue; -} - - -template <class T> -bool PersistentBase<T>::IsWeak() const { - typedef internal::Internals I; - if (this->IsEmpty()) return false; - return I::GetNodeState(reinterpret_cast<internal::Object**>(this->val_)) == - I::kNodeStateIsWeakValue; -} - - -template <class T> -void PersistentBase<T>::Reset() { - if (this->IsEmpty()) return; - V8::DisposeGlobal(reinterpret_cast<internal::Object**>(this->val_)); - val_ = 0; -} - - -template <class T> -template <class S> -void PersistentBase<T>::Reset(Isolate* isolate, const Local<S>& other) { - TYPE_CHECK(T, S); - Reset(); - if (other.IsEmpty()) return; - this->val_ = New(isolate, other.val_); -} - - -template <class T> -template <class S> -void PersistentBase<T>::Reset(Isolate* isolate, - const PersistentBase<S>& other) { - TYPE_CHECK(T, S); - Reset(); - if (other.IsEmpty()) return; - this->val_ = New(isolate, other.val_); -} - - -template <class T> -template <typename P> -V8_INLINE void PersistentBase<T>::SetWeak( - P* parameter, typename WeakCallbackInfo<P>::Callback callback, - WeakCallbackType type) { - typedef typename WeakCallbackInfo<void>::Callback Callback; - V8::MakeWeak(reinterpret_cast<internal::Object**>(this->val_), parameter, - reinterpret_cast<Callback>(callback), type); -} - -template <class T> -void PersistentBase<T>::SetWeak() { - V8::MakeWeak(reinterpret_cast<internal::Object***>(&this->val_)); -} - -template <class T> -template <typename P> -P* PersistentBase<T>::ClearWeak() { - return reinterpret_cast<P*>( - V8::ClearWeak(reinterpret_cast<internal::Object**>(this->val_))); -} - -template <class T> -void PersistentBase<T>::RegisterExternalReference(Isolate* isolate) const { - if (IsEmpty()) return; - V8::RegisterExternallyReferencedObject( - reinterpret_cast<internal::Object**>(this->val_), - reinterpret_cast<internal::Isolate*>(isolate)); -} - -template <class T> -void PersistentBase<T>::MarkIndependent() { - typedef internal::Internals I; - if (this->IsEmpty()) return; - I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), - true, - I::kNodeIsIndependentShift); -} - -template <class T> -void PersistentBase<T>::MarkActive() { - typedef internal::Internals I; - if (this->IsEmpty()) return; - I::UpdateNodeFlag(reinterpret_cast<internal::Object**>(this->val_), true, - I::kNodeIsActiveShift); -} - - -template <class T> -void PersistentBase<T>::SetWrapperClassId(uint16_t class_id) { - typedef internal::Internals I; - if (this->IsEmpty()) return; - internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); - uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; - *reinterpret_cast<uint16_t*>(addr) = class_id; -} - - -template <class T> -uint16_t PersistentBase<T>::WrapperClassId() const { - typedef internal::Internals I; - if (this->IsEmpty()) return 0; - internal::Object** obj = reinterpret_cast<internal::Object**>(this->val_); - uint8_t* addr = reinterpret_cast<uint8_t*>(obj) + I::kNodeClassIdOffset; - return *reinterpret_cast<uint16_t*>(addr); -} - - -template<typename T> -ReturnValue<T>::ReturnValue(internal::Object** slot) : value_(slot) {} - -template<typename T> -template<typename S> -void ReturnValue<T>::Set(const Persistent<S>& handle) { - TYPE_CHECK(T, S); - if (V8_UNLIKELY(handle.IsEmpty())) { - *value_ = GetDefaultValue(); - } else { - *value_ = *reinterpret_cast<internal::Object**>(*handle); - } -} - -template <typename T> -template <typename S> -void ReturnValue<T>::Set(const Global<S>& handle) { - TYPE_CHECK(T, S); - if (V8_UNLIKELY(handle.IsEmpty())) { - *value_ = GetDefaultValue(); - } else { - *value_ = *reinterpret_cast<internal::Object**>(*handle); - } -} - -template <typename T> -template <typename S> -void ReturnValue<T>::Set(const Local<S> handle) { - TYPE_CHECK(T, S); - if (V8_UNLIKELY(handle.IsEmpty())) { - *value_ = GetDefaultValue(); - } else { - *value_ = *reinterpret_cast<internal::Object**>(*handle); - } -} - -template<typename T> -void ReturnValue<T>::Set(double i) { - TYPE_CHECK(T, Number); - Set(Number::New(GetIsolate(), i)); -} - -template<typename T> -void ReturnValue<T>::Set(int32_t i) { - TYPE_CHECK(T, Integer); - typedef internal::Internals I; - if (V8_LIKELY(I::IsValidSmi(i))) { - *value_ = I::IntToSmi(i); - return; - } - Set(Integer::New(GetIsolate(), i)); -} - -template<typename T> -void ReturnValue<T>::Set(uint32_t i) { - TYPE_CHECK(T, Integer); - // Can't simply use INT32_MAX here for whatever reason. - bool fits_into_int32_t = (i & (1U << 31)) == 0; - if (V8_LIKELY(fits_into_int32_t)) { - Set(static_cast<int32_t>(i)); - return; - } - Set(Integer::NewFromUnsigned(GetIsolate(), i)); -} - -template<typename T> -void ReturnValue<T>::Set(bool value) { - TYPE_CHECK(T, Boolean); - typedef internal::Internals I; - int root_index; - if (value) { - root_index = I::kTrueValueRootIndex; - } else { - root_index = I::kFalseValueRootIndex; - } - *value_ = *I::GetRoot(GetIsolate(), root_index); -} - -template<typename T> -void ReturnValue<T>::SetNull() { - TYPE_CHECK(T, Primitive); - typedef internal::Internals I; - *value_ = *I::GetRoot(GetIsolate(), I::kNullValueRootIndex); -} - -template<typename T> -void ReturnValue<T>::SetUndefined() { - TYPE_CHECK(T, Primitive); - typedef internal::Internals I; - *value_ = *I::GetRoot(GetIsolate(), I::kUndefinedValueRootIndex); -} - -template<typename T> -void ReturnValue<T>::SetEmptyString() { - TYPE_CHECK(T, String); - typedef internal::Internals I; - *value_ = *I::GetRoot(GetIsolate(), I::kEmptyStringRootIndex); -} - -template <typename T> -Isolate* ReturnValue<T>::GetIsolate() const { - // Isolate is always the pointer below the default value on the stack. - return *reinterpret_cast<Isolate**>(&value_[-2]); -} - -template <typename T> -Local<Value> ReturnValue<T>::Get() const { - typedef internal::Internals I; - if (*value_ == *I::GetRoot(GetIsolate(), I::kTheHoleValueRootIndex)) - return Local<Value>(*Undefined(GetIsolate())); - return Local<Value>::New(GetIsolate(), reinterpret_cast<Value*>(value_)); -} - -template <typename T> -template <typename S> -void ReturnValue<T>::Set(S* whatever) { - // Uncompilable to prevent inadvertent misuse. - TYPE_CHECK(S*, Primitive); -} - -template<typename T> -internal::Object* ReturnValue<T>::GetDefaultValue() { - // Default value is always the pointer below value_ on the stack. - return value_[-1]; -} - -template <typename T> -FunctionCallbackInfo<T>::FunctionCallbackInfo(internal::Object** implicit_args, - internal::Object** values, - int length) - : implicit_args_(implicit_args), values_(values), length_(length) {} - -template<typename T> -Local<Value> FunctionCallbackInfo<T>::operator[](int i) const { - if (i < 0 || length_ <= i) return Local<Value>(*Undefined(GetIsolate())); - return Local<Value>(reinterpret_cast<Value*>(values_ - i)); -} - - -template<typename T> -Local<Function> FunctionCallbackInfo<T>::Callee() const { - return Local<Function>(reinterpret_cast<Function*>( - &implicit_args_[kCalleeIndex])); -} - - -template<typename T> -Local<Object> FunctionCallbackInfo<T>::This() const { - return Local<Object>(reinterpret_cast<Object*>(values_ + 1)); -} - - -template<typename T> -Local<Object> FunctionCallbackInfo<T>::Holder() const { - return Local<Object>(reinterpret_cast<Object*>( - &implicit_args_[kHolderIndex])); -} - -template <typename T> -Local<Value> FunctionCallbackInfo<T>::NewTarget() const { - return Local<Value>( - reinterpret_cast<Value*>(&implicit_args_[kNewTargetIndex])); -} - -template <typename T> -Local<Value> FunctionCallbackInfo<T>::Data() const { - return Local<Value>(reinterpret_cast<Value*>(&implicit_args_[kDataIndex])); -} - - -template<typename T> -Isolate* FunctionCallbackInfo<T>::GetIsolate() const { - return *reinterpret_cast<Isolate**>(&implicit_args_[kIsolateIndex]); -} - - -template<typename T> -ReturnValue<T> FunctionCallbackInfo<T>::GetReturnValue() const { - return ReturnValue<T>(&implicit_args_[kReturnValueIndex]); -} - - -template<typename T> -bool FunctionCallbackInfo<T>::IsConstructCall() const { - return !NewTarget()->IsUndefined(); -} - - -template<typename T> -int FunctionCallbackInfo<T>::Length() const { - return length_; -} - -ScriptOrigin::ScriptOrigin(Local<Value> resource_name, - Local<Integer> resource_line_offset, - Local<Integer> resource_column_offset, - Local<Boolean> resource_is_shared_cross_origin, - Local<Integer> script_id, - Local<Value> source_map_url, - Local<Boolean> resource_is_opaque, - Local<Boolean> is_wasm, Local<Boolean> is_module) - : resource_name_(resource_name), - resource_line_offset_(resource_line_offset), - resource_column_offset_(resource_column_offset), - options_(!resource_is_shared_cross_origin.IsEmpty() && - resource_is_shared_cross_origin->IsTrue(), - !resource_is_opaque.IsEmpty() && resource_is_opaque->IsTrue(), - !is_wasm.IsEmpty() && is_wasm->IsTrue(), - !is_module.IsEmpty() && is_module->IsTrue()), - script_id_(script_id), - source_map_url_(source_map_url) {} - -Local<Value> ScriptOrigin::ResourceName() const { return resource_name_; } - - -Local<Integer> ScriptOrigin::ResourceLineOffset() const { - return resource_line_offset_; -} - - -Local<Integer> ScriptOrigin::ResourceColumnOffset() const { - return resource_column_offset_; -} - - -Local<Integer> ScriptOrigin::ScriptID() const { return script_id_; } - - -Local<Value> ScriptOrigin::SourceMapUrl() const { return source_map_url_; } - - -ScriptCompiler::Source::Source(Local<String> string, const ScriptOrigin& origin, - CachedData* data) - : source_string(string), - resource_name(origin.ResourceName()), - resource_line_offset(origin.ResourceLineOffset()), - resource_column_offset(origin.ResourceColumnOffset()), - resource_options(origin.Options()), - source_map_url(origin.SourceMapUrl()), - cached_data(data) {} - - -ScriptCompiler::Source::Source(Local<String> string, - CachedData* data) - : source_string(string), cached_data(data) {} - - -ScriptCompiler::Source::~Source() { - delete cached_data; -} - - -const ScriptCompiler::CachedData* ScriptCompiler::Source::GetCachedData() - const { - return cached_data; -} - -const ScriptOriginOptions& ScriptCompiler::Source::GetResourceOptions() const { - return resource_options; -} - -Local<Boolean> Boolean::New(Isolate* isolate, bool value) { - return value ? True(isolate) : False(isolate); -} - -void Template::Set(Isolate* isolate, const char* name, Local<Data> value) { - Set(String::NewFromUtf8(isolate, name, NewStringType::kInternalized) - .ToLocalChecked(), - value); -} - - -Local<Value> Object::GetInternalField(int index) { -#ifndef V8_ENABLE_CHECKS - typedef internal::Object O; - typedef internal::HeapObject HO; - typedef internal::Internals I; - O* obj = *reinterpret_cast<O**>(this); - // Fast path: If the object is a plain JSObject, which is the common case, we - // know where to find the internal fields and can return the value directly. - auto instance_type = I::GetInstanceType(obj); - if (instance_type == I::kJSObjectType || - instance_type == I::kJSApiObjectType) { - int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); - O* value = I::ReadField<O*>(obj, offset); - O** result = HandleScope::CreateHandle(reinterpret_cast<HO*>(obj), value); - return Local<Value>(reinterpret_cast<Value*>(result)); - } -#endif - return SlowGetInternalField(index); -} - - -void* Object::GetAlignedPointerFromInternalField(int index) { -#ifndef V8_ENABLE_CHECKS - typedef internal::Object O; - typedef internal::Internals I; - O* obj = *reinterpret_cast<O**>(this); - // Fast path: If the object is a plain JSObject, which is the common case, we - // know where to find the internal fields and can return the value directly. - auto instance_type = I::GetInstanceType(obj); - if (V8_LIKELY(instance_type == I::kJSObjectType || - instance_type == I::kJSApiObjectType)) { - int offset = I::kJSObjectHeaderSize + (internal::kApiPointerSize * index); - return I::ReadField<void*>(obj, offset); - } -#endif - return SlowGetAlignedPointerFromInternalField(index); -} - -String* String::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<String*>(value); -} - - -Local<String> String::Empty(Isolate* isolate) { - typedef internal::Object* S; - typedef internal::Internals I; - I::CheckInitialized(isolate); - S* slot = I::GetRoot(isolate, I::kEmptyStringRootIndex); - return Local<String>(reinterpret_cast<String*>(slot)); -} - - -String::ExternalStringResource* String::GetExternalStringResource() const { - typedef internal::Object O; - typedef internal::Internals I; - O* obj = *reinterpret_cast<O* const*>(this); - String::ExternalStringResource* result; - if (I::IsExternalTwoByteString(I::GetInstanceType(obj))) { - void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); - result = reinterpret_cast<String::ExternalStringResource*>(value); - } else { - result = NULL; - } -#ifdef V8_ENABLE_CHECKS - VerifyExternalStringResource(result); -#endif - return result; -} - - -String::ExternalStringResourceBase* String::GetExternalStringResourceBase( - String::Encoding* encoding_out) const { - typedef internal::Object O; - typedef internal::Internals I; - O* obj = *reinterpret_cast<O* const*>(this); - int type = I::GetInstanceType(obj) & I::kFullStringRepresentationMask; - *encoding_out = static_cast<Encoding>(type & I::kStringEncodingMask); - ExternalStringResourceBase* resource = NULL; - if (type == I::kExternalOneByteRepresentationTag || - type == I::kExternalTwoByteRepresentationTag) { - void* value = I::ReadField<void*>(obj, I::kStringResourceOffset); - resource = static_cast<ExternalStringResourceBase*>(value); - } -#ifdef V8_ENABLE_CHECKS - VerifyExternalStringResourceBase(resource, *encoding_out); -#endif - return resource; -} - - -bool Value::IsUndefined() const { -#ifdef V8_ENABLE_CHECKS - return FullIsUndefined(); -#else - return QuickIsUndefined(); -#endif -} - -bool Value::QuickIsUndefined() const { - typedef internal::Object O; - typedef internal::Internals I; - O* obj = *reinterpret_cast<O* const*>(this); - if (!I::HasHeapObjectTag(obj)) return false; - if (I::GetInstanceType(obj) != I::kOddballType) return false; - return (I::GetOddballKind(obj) == I::kUndefinedOddballKind); -} - - -bool Value::IsNull() const { -#ifdef V8_ENABLE_CHECKS - return FullIsNull(); -#else - return QuickIsNull(); -#endif -} - -bool Value::QuickIsNull() const { - typedef internal::Object O; - typedef internal::Internals I; - O* obj = *reinterpret_cast<O* const*>(this); - if (!I::HasHeapObjectTag(obj)) return false; - if (I::GetInstanceType(obj) != I::kOddballType) return false; - return (I::GetOddballKind(obj) == I::kNullOddballKind); -} - -bool Value::IsNullOrUndefined() const { -#ifdef V8_ENABLE_CHECKS - return FullIsNull() || FullIsUndefined(); -#else - return QuickIsNullOrUndefined(); -#endif -} - -bool Value::QuickIsNullOrUndefined() const { - typedef internal::Object O; - typedef internal::Internals I; - O* obj = *reinterpret_cast<O* const*>(this); - if (!I::HasHeapObjectTag(obj)) return false; - if (I::GetInstanceType(obj) != I::kOddballType) return false; - int kind = I::GetOddballKind(obj); - return kind == I::kNullOddballKind || kind == I::kUndefinedOddballKind; -} - -bool Value::IsString() const { -#ifdef V8_ENABLE_CHECKS - return FullIsString(); -#else - return QuickIsString(); -#endif -} - -bool Value::QuickIsString() const { - typedef internal::Object O; - typedef internal::Internals I; - O* obj = *reinterpret_cast<O* const*>(this); - if (!I::HasHeapObjectTag(obj)) return false; - return (I::GetInstanceType(obj) < I::kFirstNonstringType); -} - - -template <class T> Value* Value::Cast(T* value) { - return static_cast<Value*>(value); -} - - -Local<Boolean> Value::ToBoolean() const { - return ToBoolean(Isolate::GetCurrent()->GetCurrentContext()) - .FromMaybe(Local<Boolean>()); -} - - -Local<Number> Value::ToNumber() const { - return ToNumber(Isolate::GetCurrent()->GetCurrentContext()) - .FromMaybe(Local<Number>()); -} - - -Local<String> Value::ToString() const { - return ToString(Isolate::GetCurrent()->GetCurrentContext()) - .FromMaybe(Local<String>()); -} - - -Local<String> Value::ToDetailString() const { - return ToDetailString(Isolate::GetCurrent()->GetCurrentContext()) - .FromMaybe(Local<String>()); -} - - -Local<Object> Value::ToObject() const { - return ToObject(Isolate::GetCurrent()->GetCurrentContext()) - .FromMaybe(Local<Object>()); -} - - -Local<Integer> Value::ToInteger() const { - return ToInteger(Isolate::GetCurrent()->GetCurrentContext()) - .FromMaybe(Local<Integer>()); -} - - -Local<Uint32> Value::ToUint32() const { - return ToUint32(Isolate::GetCurrent()->GetCurrentContext()) - .FromMaybe(Local<Uint32>()); -} - - -Local<Int32> Value::ToInt32() const { - return ToInt32(Isolate::GetCurrent()->GetCurrentContext()) - .FromMaybe(Local<Int32>()); -} - - -Boolean* Boolean::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Boolean*>(value); -} - - -Name* Name::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Name*>(value); -} - - -Symbol* Symbol::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Symbol*>(value); -} - - -Number* Number::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Number*>(value); -} - - -Integer* Integer::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Integer*>(value); -} - - -Int32* Int32::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Int32*>(value); -} - - -Uint32* Uint32::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Uint32*>(value); -} - - -Date* Date::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Date*>(value); -} - - -StringObject* StringObject::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<StringObject*>(value); -} - - -SymbolObject* SymbolObject::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<SymbolObject*>(value); -} - - -NumberObject* NumberObject::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<NumberObject*>(value); -} - - -BooleanObject* BooleanObject::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<BooleanObject*>(value); -} - - -RegExp* RegExp::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<RegExp*>(value); -} - - -Object* Object::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Object*>(value); -} - - -Array* Array::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Array*>(value); -} - - -Map* Map::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Map*>(value); -} - - -Set* Set::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Set*>(value); -} - - -Promise* Promise::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Promise*>(value); -} - - -Proxy* Proxy::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Proxy*>(value); -} - -WasmCompiledModule* WasmCompiledModule::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<WasmCompiledModule*>(value); -} - -Promise::Resolver* Promise::Resolver::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Promise::Resolver*>(value); -} - - -ArrayBuffer* ArrayBuffer::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<ArrayBuffer*>(value); -} - - -ArrayBufferView* ArrayBufferView::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<ArrayBufferView*>(value); -} - - -TypedArray* TypedArray::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<TypedArray*>(value); -} - - -Uint8Array* Uint8Array::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Uint8Array*>(value); -} - - -Int8Array* Int8Array::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Int8Array*>(value); -} - - -Uint16Array* Uint16Array::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Uint16Array*>(value); -} - - -Int16Array* Int16Array::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Int16Array*>(value); -} - - -Uint32Array* Uint32Array::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Uint32Array*>(value); -} - - -Int32Array* Int32Array::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Int32Array*>(value); -} - - -Float32Array* Float32Array::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Float32Array*>(value); -} - - -Float64Array* Float64Array::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Float64Array*>(value); -} - - -Uint8ClampedArray* Uint8ClampedArray::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Uint8ClampedArray*>(value); -} - - -DataView* DataView::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<DataView*>(value); -} - - -SharedArrayBuffer* SharedArrayBuffer::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<SharedArrayBuffer*>(value); -} - - -Function* Function::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<Function*>(value); -} - - -External* External::Cast(v8::Value* value) { -#ifdef V8_ENABLE_CHECKS - CheckCast(value); -#endif - return static_cast<External*>(value); -} - - -template<typename T> -Isolate* PropertyCallbackInfo<T>::GetIsolate() const { - return *reinterpret_cast<Isolate**>(&args_[kIsolateIndex]); -} - - -template<typename T> -Local<Value> PropertyCallbackInfo<T>::Data() const { - return Local<Value>(reinterpret_cast<Value*>(&args_[kDataIndex])); -} - - -template<typename T> -Local<Object> PropertyCallbackInfo<T>::This() const { - return Local<Object>(reinterpret_cast<Object*>(&args_[kThisIndex])); -} - - -template<typename T> -Local<Object> PropertyCallbackInfo<T>::Holder() const { - return Local<Object>(reinterpret_cast<Object*>(&args_[kHolderIndex])); -} - - -template<typename T> -ReturnValue<T> PropertyCallbackInfo<T>::GetReturnValue() const { - return ReturnValue<T>(&args_[kReturnValueIndex]); -} - -template <typename T> -bool PropertyCallbackInfo<T>::ShouldThrowOnError() const { - typedef internal::Internals I; - return args_[kShouldThrowOnErrorIndex] != I::IntToSmi(0); -} - - -Local<Primitive> Undefined(Isolate* isolate) { - typedef internal::Object* S; - typedef internal::Internals I; - I::CheckInitialized(isolate); - S* slot = I::GetRoot(isolate, I::kUndefinedValueRootIndex); - return Local<Primitive>(reinterpret_cast<Primitive*>(slot)); -} - - -Local<Primitive> Null(Isolate* isolate) { - typedef internal::Object* S; - typedef internal::Internals I; - I::CheckInitialized(isolate); - S* slot = I::GetRoot(isolate, I::kNullValueRootIndex); - return Local<Primitive>(reinterpret_cast<Primitive*>(slot)); -} - - -Local<Boolean> True(Isolate* isolate) { - typedef internal::Object* S; - typedef internal::Internals I; - I::CheckInitialized(isolate); - S* slot = I::GetRoot(isolate, I::kTrueValueRootIndex); - return Local<Boolean>(reinterpret_cast<Boolean*>(slot)); -} - - -Local<Boolean> False(Isolate* isolate) { - typedef internal::Object* S; - typedef internal::Internals I; - I::CheckInitialized(isolate); - S* slot = I::GetRoot(isolate, I::kFalseValueRootIndex); - return Local<Boolean>(reinterpret_cast<Boolean*>(slot)); -} - - -void Isolate::SetData(uint32_t slot, void* data) { - typedef internal::Internals I; - I::SetEmbedderData(this, slot, data); -} - - -void* Isolate::GetData(uint32_t slot) { - typedef internal::Internals I; - return I::GetEmbedderData(this, slot); -} - - -uint32_t Isolate::GetNumberOfDataSlots() { - typedef internal::Internals I; - return I::kNumIsolateDataSlots; -} - - -int64_t Isolate::AdjustAmountOfExternalAllocatedMemory( - int64_t change_in_bytes) { - typedef internal::Internals I; - int64_t* external_memory = reinterpret_cast<int64_t*>( - reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryOffset); - const int64_t external_memory_limit = *reinterpret_cast<int64_t*>( - reinterpret_cast<uint8_t*>(this) + I::kExternalMemoryLimitOffset); - const int64_t amount = *external_memory + change_in_bytes; - *external_memory = amount; - if (change_in_bytes > 0 && amount > external_memory_limit) { - ReportExternalAllocationLimitReached(); - } - return *external_memory; -} - -Local<Value> Context::GetEmbedderData(int index) { -#ifndef V8_ENABLE_CHECKS - typedef internal::Object O; - typedef internal::HeapObject HO; - typedef internal::Internals I; - HO* context = *reinterpret_cast<HO**>(this); - O** result = - HandleScope::CreateHandle(context, I::ReadEmbedderData<O*>(this, index)); - return Local<Value>(reinterpret_cast<Value*>(result)); -#else - return SlowGetEmbedderData(index); -#endif -} - - -void* Context::GetAlignedPointerFromEmbedderData(int index) { -#ifndef V8_ENABLE_CHECKS - typedef internal::Internals I; - return I::ReadEmbedderData<void*>(this, index); -#else - return SlowGetAlignedPointerFromEmbedderData(index); -#endif -} - - -void V8::SetAllowCodeGenerationFromStringsCallback( - AllowCodeGenerationFromStringsCallback callback) { - Isolate* isolate = Isolate::GetCurrent(); - isolate->SetAllowCodeGenerationFromStringsCallback(callback); -} - - -bool V8::IsDead() { - Isolate* isolate = Isolate::GetCurrent(); - return isolate->IsDead(); -} - - -bool V8::AddMessageListener(MessageCallback that, Local<Value> data) { - Isolate* isolate = Isolate::GetCurrent(); - return isolate->AddMessageListener(that, data); -} - - -void V8::RemoveMessageListeners(MessageCallback that) { - Isolate* isolate = Isolate::GetCurrent(); - isolate->RemoveMessageListeners(that); -} - - -void V8::SetFailedAccessCheckCallbackFunction( - FailedAccessCheckCallback callback) { - Isolate* isolate = Isolate::GetCurrent(); - isolate->SetFailedAccessCheckCallbackFunction(callback); -} - - -void V8::SetCaptureStackTraceForUncaughtExceptions( - bool capture, int frame_limit, StackTrace::StackTraceOptions options) { - Isolate* isolate = Isolate::GetCurrent(); - isolate->SetCaptureStackTraceForUncaughtExceptions(capture, frame_limit, - options); -} - - -void V8::SetFatalErrorHandler(FatalErrorCallback callback) { - Isolate* isolate = Isolate::GetCurrent(); - isolate->SetFatalErrorHandler(callback); -} - -void V8::RemoveGCPrologueCallback(GCCallback callback) { - Isolate* isolate = Isolate::GetCurrent(); - isolate->RemoveGCPrologueCallback( - reinterpret_cast<Isolate::GCCallback>(callback)); -} - - -void V8::RemoveGCEpilogueCallback(GCCallback callback) { - Isolate* isolate = Isolate::GetCurrent(); - isolate->RemoveGCEpilogueCallback( - reinterpret_cast<Isolate::GCCallback>(callback)); -} - -void V8::TerminateExecution(Isolate* isolate) { isolate->TerminateExecution(); } - - -bool V8::IsExecutionTerminating(Isolate* isolate) { - if (isolate == NULL) { - isolate = Isolate::GetCurrent(); - } - return isolate->IsExecutionTerminating(); -} - - -void V8::CancelTerminateExecution(Isolate* isolate) { - isolate->CancelTerminateExecution(); -} - - -void V8::VisitExternalResources(ExternalResourceVisitor* visitor) { - Isolate* isolate = Isolate::GetCurrent(); - isolate->VisitExternalResources(visitor); -} - - -void V8::VisitHandlesWithClassIds(PersistentHandleVisitor* visitor) { - Isolate* isolate = Isolate::GetCurrent(); - isolate->VisitHandlesWithClassIds(visitor); -} - - -void V8::VisitHandlesWithClassIds(Isolate* isolate, - PersistentHandleVisitor* visitor) { - isolate->VisitHandlesWithClassIds(visitor); -} - - -void V8::VisitHandlesForPartialDependence(Isolate* isolate, - PersistentHandleVisitor* visitor) { - isolate->VisitHandlesForPartialDependence(visitor); -} - -/** - * \example shell.cc - * A simple shell that takes a list of expressions on the - * command-line and executes them. - */ - - -/** - * \example process.cc - */ - - -} // namespace v8 - - -#undef TYPE_CHECK - - -#endif // INCLUDE_V8_H_ diff --git a/android/armeabi/include/v8/v8config.h b/android/armeabi/include/v8/v8config.h deleted file mode 100644 index 964949c2..00000000 --- a/android/armeabi/include/v8/v8config.h +++ /dev/null @@ -1,428 +0,0 @@ -// Copyright 2013 the V8 project authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -#ifndef V8CONFIG_H_ -#define V8CONFIG_H_ - -// clang-format off - -// Platform headers for feature detection below. -#if defined(__ANDROID__) -# include <sys/cdefs.h> -#elif defined(__APPLE__) -# include <TargetConditionals.h> -#elif defined(__linux__) -# include <features.h> -#endif - - -// This macro allows to test for the version of the GNU C library (or -// a compatible C library that masquerades as glibc). It evaluates to -// 0 if libc is not GNU libc or compatible. -// Use like: -// #if V8_GLIBC_PREREQ(2, 3) -// ... -// #endif -#if defined(__GLIBC__) && defined(__GLIBC_MINOR__) -# define V8_GLIBC_PREREQ(major, minor) \ - ((__GLIBC__ * 100 + __GLIBC_MINOR__) >= ((major) * 100 + (minor))) -#else -# define V8_GLIBC_PREREQ(major, minor) 0 -#endif - - -// This macro allows to test for the version of the GNU C++ compiler. -// Note that this also applies to compilers that masquerade as GCC, -// for example clang and the Intel C++ compiler for Linux. -// Use like: -// #if V8_GNUC_PREREQ(4, 3, 1) -// ... -// #endif -#if defined(__GNUC__) && defined(__GNUC_MINOR__) && defined(__GNUC_PATCHLEVEL__) -# define V8_GNUC_PREREQ(major, minor, patchlevel) \ - ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= \ - ((major) * 10000 + (minor) * 100 + (patchlevel))) -#elif defined(__GNUC__) && defined(__GNUC_MINOR__) -# define V8_GNUC_PREREQ(major, minor, patchlevel) \ - ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= \ - ((major) * 10000 + (minor) * 100 + (patchlevel))) -#else -# define V8_GNUC_PREREQ(major, minor, patchlevel) 0 -#endif - - - -// ----------------------------------------------------------------------------- -// Operating system detection -// -// V8_OS_ANDROID - Android -// V8_OS_BSD - BSDish (Mac OS X, Net/Free/Open/DragonFlyBSD) -// V8_OS_CYGWIN - Cygwin -// V8_OS_DRAGONFLYBSD - DragonFlyBSD -// V8_OS_FREEBSD - FreeBSD -// V8_OS_LINUX - Linux -// V8_OS_MACOSX - Mac OS X -// V8_OS_NETBSD - NetBSD -// V8_OS_OPENBSD - OpenBSD -// V8_OS_POSIX - POSIX compatible (mostly everything except Windows) -// V8_OS_QNX - QNX Neutrino -// V8_OS_SOLARIS - Sun Solaris and OpenSolaris -// V8_OS_AIX - AIX -// V8_OS_WIN - Microsoft Windows - -#if defined(__ANDROID__) -# define V8_OS_ANDROID 1 -# define V8_OS_LINUX 1 -# define V8_OS_POSIX 1 -#elif defined(__APPLE__) -# define V8_OS_BSD 1 -# define V8_OS_MACOSX 1 -# define V8_OS_POSIX 1 -#elif defined(__CYGWIN__) -# define V8_OS_CYGWIN 1 -# define V8_OS_POSIX 1 -#elif defined(__linux__) -# define V8_OS_LINUX 1 -# define V8_OS_POSIX 1 -#elif defined(__sun) -# define V8_OS_POSIX 1 -# define V8_OS_SOLARIS 1 -#elif defined(_AIX) -#define V8_OS_POSIX 1 -#define V8_OS_AIX 1 -#elif defined(__FreeBSD__) -# define V8_OS_BSD 1 -# define V8_OS_FREEBSD 1 -# define V8_OS_POSIX 1 -#elif defined(__DragonFly__) -# define V8_OS_BSD 1 -# define V8_OS_DRAGONFLYBSD 1 -# define V8_OS_POSIX 1 -#elif defined(__NetBSD__) -# define V8_OS_BSD 1 -# define V8_OS_NETBSD 1 -# define V8_OS_POSIX 1 -#elif defined(__OpenBSD__) -# define V8_OS_BSD 1 -# define V8_OS_OPENBSD 1 -# define V8_OS_POSIX 1 -#elif defined(__QNXNTO__) -# define V8_OS_POSIX 1 -# define V8_OS_QNX 1 -#elif defined(_WIN32) -# define V8_OS_WIN 1 -#endif - - -// ----------------------------------------------------------------------------- -// C library detection -// -// V8_LIBC_MSVCRT - MSVC libc -// V8_LIBC_BIONIC - Bionic libc -// V8_LIBC_BSD - BSD libc derivate -// V8_LIBC_GLIBC - GNU C library -// V8_LIBC_UCLIBC - uClibc -// -// Note that testing for libc must be done using #if not #ifdef. For example, -// to test for the GNU C library, use: -// #if V8_LIBC_GLIBC -// ... -// #endif - -#if defined (_MSC_VER) -# define V8_LIBC_MSVCRT 1 -#elif defined(__BIONIC__) -# define V8_LIBC_BIONIC 1 -# define V8_LIBC_BSD 1 -#elif defined(__UCLIBC__) -// Must test for UCLIBC before GLIBC, as UCLIBC pretends to be GLIBC. -# define V8_LIBC_UCLIBC 1 -#elif defined(__GLIBC__) || defined(__GNU_LIBRARY__) -# define V8_LIBC_GLIBC 1 -#else -# define V8_LIBC_BSD V8_OS_BSD -#endif - - -// ----------------------------------------------------------------------------- -// Compiler detection -// -// V8_CC_GNU - GCC, or clang in gcc mode -// V8_CC_INTEL - Intel C++ -// V8_CC_MINGW - Minimalist GNU for Windows -// V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32) -// V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64) -// V8_CC_MSVC - Microsoft Visual C/C++, or clang in cl.exe mode -// -// C++11 feature detection -// -// V8_HAS_CXX11_ALIGNAS - alignas specifier supported -// V8_HAS_CXX11_ALIGNOF - alignof(type) operator supported -// -// Compiler-specific feature detection -// -// V8_HAS___ALIGNOF - __alignof(type) operator supported -// V8_HAS___ALIGNOF__ - __alignof__(type) operator supported -// V8_HAS_ATTRIBUTE_ALIGNED - __attribute__((aligned(n))) supported -// V8_HAS_ATTRIBUTE_ALWAYS_INLINE - __attribute__((always_inline)) -// supported -// V8_HAS_ATTRIBUTE_DEPRECATED - __attribute__((deprecated)) supported -// V8_HAS_ATTRIBUTE_NOINLINE - __attribute__((noinline)) supported -// V8_HAS_ATTRIBUTE_NORETURN - __attribute__((noreturn)) supported -// V8_HAS_ATTRIBUTE_UNUSED - __attribute__((unused)) supported -// V8_HAS_ATTRIBUTE_VISIBILITY - __attribute__((visibility)) supported -// V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT - __attribute__((warn_unused_result)) -// supported -// V8_HAS_BUILTIN_CLZ - __builtin_clz() supported -// V8_HAS_BUILTIN_CTZ - __builtin_ctz() supported -// V8_HAS_BUILTIN_EXPECT - __builtin_expect() supported -// V8_HAS_BUILTIN_FRAME_ADDRESS - __builtin_frame_address() supported -// V8_HAS_BUILTIN_POPCOUNT - __builtin_popcount() supported -// V8_HAS_BUILTIN_SADD_OVERFLOW - __builtin_sadd_overflow() supported -// V8_HAS_BUILTIN_SSUB_OVERFLOW - __builtin_ssub_overflow() supported -// V8_HAS_BUILTIN_UADD_OVERFLOW - __builtin_uadd_overflow() supported -// V8_HAS_DECLSPEC_ALIGN - __declspec(align(n)) supported -// V8_HAS_DECLSPEC_DEPRECATED - __declspec(deprecated) supported -// V8_HAS_DECLSPEC_NOINLINE - __declspec(noinline) supported -// V8_HAS_DECLSPEC_SELECTANY - __declspec(selectany) supported -// V8_HAS_DECLSPEC_NORETURN - __declspec(noreturn) supported -// V8_HAS___FORCEINLINE - __forceinline supported -// -// Note that testing for compilers and/or features must be done using #if -// not #ifdef. For example, to test for Intel C++ Compiler, use: -// #if V8_CC_INTEL -// ... -// #endif - -#if defined(__clang__) - -#if defined(__GNUC__) // Clang in gcc mode. -# define V8_CC_GNU 1 -#endif - -// Clang defines __alignof__ as alias for __alignof -# define V8_HAS___ALIGNOF 1 -# define V8_HAS___ALIGNOF__ V8_HAS___ALIGNOF - -# define V8_HAS_ATTRIBUTE_ALIGNED (__has_attribute(aligned)) -# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (__has_attribute(always_inline)) -# define V8_HAS_ATTRIBUTE_DEPRECATED (__has_attribute(deprecated)) -# define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline)) -# define V8_HAS_ATTRIBUTE_NORETURN (__has_attribute(noreturn)) -# define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused)) -# define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility)) -# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ - (__has_attribute(warn_unused_result)) - -# define V8_HAS_BUILTIN_CLZ (__has_builtin(__builtin_clz)) -# define V8_HAS_BUILTIN_CTZ (__has_builtin(__builtin_ctz)) -# define V8_HAS_BUILTIN_EXPECT (__has_builtin(__builtin_expect)) -# define V8_HAS_BUILTIN_FRAME_ADDRESS (__has_builtin(__builtin_frame_address)) -# define V8_HAS_BUILTIN_POPCOUNT (__has_builtin(__builtin_popcount)) -# define V8_HAS_BUILTIN_SADD_OVERFLOW (__has_builtin(__builtin_sadd_overflow)) -# define V8_HAS_BUILTIN_SSUB_OVERFLOW (__has_builtin(__builtin_ssub_overflow)) -# define V8_HAS_BUILTIN_UADD_OVERFLOW (__has_builtin(__builtin_uadd_overflow)) - -# define V8_HAS_CXX11_ALIGNAS (__has_feature(cxx_alignas)) - -#elif defined(__GNUC__) - -# define V8_CC_GNU 1 -# if defined(__INTEL_COMPILER) // Intel C++ also masquerades as GCC 3.2.0 -# define V8_CC_INTEL 1 -# endif -# if defined(__MINGW32__) -# define V8_CC_MINGW32 1 -# endif -# if defined(__MINGW64__) -# define V8_CC_MINGW64 1 -# endif -# define V8_CC_MINGW (V8_CC_MINGW32 || V8_CC_MINGW64) - -# define V8_HAS___ALIGNOF__ (V8_GNUC_PREREQ(4, 3, 0)) - -# define V8_HAS_ATTRIBUTE_ALIGNED (V8_GNUC_PREREQ(2, 95, 0)) -// always_inline is available in gcc 4.0 but not very reliable until 4.4. -// Works around "sorry, unimplemented: inlining failed" build errors with -// older compilers. -# define V8_HAS_ATTRIBUTE_ALWAYS_INLINE (V8_GNUC_PREREQ(4, 4, 0)) -# define V8_HAS_ATTRIBUTE_DEPRECATED (V8_GNUC_PREREQ(3, 4, 0)) -# define V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE (V8_GNUC_PREREQ(4, 5, 0)) -# define V8_HAS_ATTRIBUTE_NOINLINE (V8_GNUC_PREREQ(3, 4, 0)) -# define V8_HAS_ATTRIBUTE_NORETURN (V8_GNUC_PREREQ(2, 5, 0)) -# define V8_HAS_ATTRIBUTE_UNUSED (V8_GNUC_PREREQ(2, 95, 0)) -# define V8_HAS_ATTRIBUTE_VISIBILITY (V8_GNUC_PREREQ(4, 3, 0)) -# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \ - (!V8_CC_INTEL && V8_GNUC_PREREQ(4, 1, 0)) - -# define V8_HAS_BUILTIN_CLZ (V8_GNUC_PREREQ(3, 4, 0)) -# define V8_HAS_BUILTIN_CTZ (V8_GNUC_PREREQ(3, 4, 0)) -# define V8_HAS_BUILTIN_EXPECT (V8_GNUC_PREREQ(2, 96, 0)) -# define V8_HAS_BUILTIN_FRAME_ADDRESS (V8_GNUC_PREREQ(2, 96, 0)) -# define V8_HAS_BUILTIN_POPCOUNT (V8_GNUC_PREREQ(3, 4, 0)) - -# if __cplusplus >= 201103L -# define V8_HAS_CXX11_ALIGNAS (V8_GNUC_PREREQ(4, 8, 0)) -# define V8_HAS_CXX11_ALIGNOF (V8_GNUC_PREREQ(4, 8, 0)) -# endif -#endif - -#if defined(_MSC_VER) -# define V8_CC_MSVC 1 -# define V8_HAS___ALIGNOF 1 - -# define V8_HAS_DECLSPEC_ALIGN 1 -# define V8_HAS_DECLSPEC_DEPRECATED 1 -# define V8_HAS_DECLSPEC_NOINLINE 1 -# define V8_HAS_DECLSPEC_SELECTANY 1 -# define V8_HAS_DECLSPEC_NORETURN 1 - -# define V8_HAS___FORCEINLINE 1 - -#endif - - -// ----------------------------------------------------------------------------- -// Helper macros - -// A macro used to make better inlining. Don't bother for debug builds. -// Use like: -// V8_INLINE int GetZero() { return 0; } -#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_ALWAYS_INLINE -# define V8_INLINE inline __attribute__((always_inline)) -#elif !defined(DEBUG) && V8_HAS___FORCEINLINE -# define V8_INLINE __forceinline -#else -# define V8_INLINE inline -#endif - - -// A macro used to tell the compiler to never inline a particular function. -// Don't bother for debug builds. -// Use like: -// V8_NOINLINE int GetMinusOne() { return -1; } -#if !defined(DEBUG) && V8_HAS_ATTRIBUTE_NOINLINE -# define V8_NOINLINE __attribute__((noinline)) -#elif !defined(DEBUG) && V8_HAS_DECLSPEC_NOINLINE -# define V8_NOINLINE __declspec(noinline) -#else -# define V8_NOINLINE /* NOT SUPPORTED */ -#endif - - -// A macro used to tell the compiler that a particular function never returns. -// Use like: -// V8_NORETURN void MyAbort() { abort(); } -#if V8_HAS_ATTRIBUTE_NORETURN -# define V8_NORETURN __attribute__((noreturn)) -#elif V8_HAS_DECLSPEC_NORETURN -# define V8_NORETURN __declspec(noreturn) -#else -# define V8_NORETURN /* NOT SUPPORTED */ -#endif - - -// A macro (V8_DEPRECATED) to mark classes or functions as deprecated. -#if defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE -#define V8_DEPRECATED(message, declarator) \ - declarator __attribute__((deprecated(message))) -#elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED -#define V8_DEPRECATED(message, declarator) \ - declarator __attribute__((deprecated)) -#elif defined(V8_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED -#define V8_DEPRECATED(message, declarator) __declspec(deprecated) declarator -#else -#define V8_DEPRECATED(message, declarator) declarator -#endif - - -// A macro (V8_DEPRECATE_SOON) to make it easier to see what will be deprecated. -#if defined(V8_IMMINENT_DEPRECATION_WARNINGS) && \ - V8_HAS_ATTRIBUTE_DEPRECATED_MESSAGE -#define V8_DEPRECATE_SOON(message, declarator) \ - declarator __attribute__((deprecated(message))) -#elif defined(V8_IMMINENT_DEPRECATION_WARNINGS) && V8_HAS_ATTRIBUTE_DEPRECATED -#define V8_DEPRECATE_SOON(message, declarator) \ - declarator __attribute__((deprecated)) -#elif defined(V8_IMMINENT_DEPRECATION_WARNINGS) && V8_HAS_DECLSPEC_DEPRECATED -#define V8_DEPRECATE_SOON(message, declarator) __declspec(deprecated) declarator -#else -#define V8_DEPRECATE_SOON(message, declarator) declarator -#endif - - -// A macro to provide the compiler with branch prediction information. -#if V8_HAS_BUILTIN_EXPECT -# define V8_UNLIKELY(condition) (__builtin_expect(!!(condition), 0)) -# define V8_LIKELY(condition) (__builtin_expect(!!(condition), 1)) -#else -# define V8_UNLIKELY(condition) (condition) -# define V8_LIKELY(condition) (condition) -#endif - - -// This macro allows to specify memory alignment for structs, classes, etc. -// Use like: -// class V8_ALIGNED(16) MyClass { ... }; -// V8_ALIGNED(32) int array[42]; -#if V8_HAS_CXX11_ALIGNAS -# define V8_ALIGNED(n) alignas(n) -#elif V8_HAS_ATTRIBUTE_ALIGNED -# define V8_ALIGNED(n) __attribute__((aligned(n))) -#elif V8_HAS_DECLSPEC_ALIGN -# define V8_ALIGNED(n) __declspec(align(n)) -#else -# define V8_ALIGNED(n) /* NOT SUPPORTED */ -#endif - - -// This macro is similar to V8_ALIGNED(), but takes a type instead of size -// in bytes. If the compiler does not supports using the alignment of the -// |type|, it will align according to the |alignment| instead. For example, -// Visual Studio C++ cannot combine __declspec(align) and __alignof. The -// |alignment| must be a literal that is used as a kind of worst-case fallback -// alignment. -// Use like: -// struct V8_ALIGNAS(AnotherClass, 16) NewClass { ... }; -// V8_ALIGNAS(double, 8) int array[100]; -#if V8_HAS_CXX11_ALIGNAS -# define V8_ALIGNAS(type, alignment) alignas(type) -#elif V8_HAS___ALIGNOF__ && V8_HAS_ATTRIBUTE_ALIGNED -# define V8_ALIGNAS(type, alignment) __attribute__((aligned(__alignof__(type)))) -#else -# define V8_ALIGNAS(type, alignment) V8_ALIGNED(alignment) -#endif - - -// This macro returns alignment in bytes (an integer power of two) required for -// any instance of the given type, which is either complete type, an array type, -// or a reference type. -// Use like: -// size_t alignment = V8_ALIGNOF(double); -#if V8_HAS_CXX11_ALIGNOF -# define V8_ALIGNOF(type) alignof(type) -#elif V8_HAS___ALIGNOF -# define V8_ALIGNOF(type) __alignof(type) -#elif V8_HAS___ALIGNOF__ -# define V8_ALIGNOF(type) __alignof__(type) -#else -// Note that alignment of a type within a struct can be less than the -// alignment of the type stand-alone (because of ancient ABIs), so this -// should only be used as a last resort. -namespace v8 { template <typename T> class AlignOfHelper { char c; T t; }; } -# define V8_ALIGNOF(type) (sizeof(::v8::AlignOfHelper<type>) - sizeof(type)) -#endif - -// Annotate a function indicating the caller must examine the return value. -// Use like: -// int foo() WARN_UNUSED_RESULT; -#if V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT -#define V8_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#else -#define V8_WARN_UNUSED_RESULT /* NOT SUPPORTED */ -#endif - -// clang-format on - -#endif // V8CONFIG_H_ diff --git a/android/armeabi/include/webp/decode.h b/android/armeabi/include/webp/decode.h deleted file mode 100644 index 143e4fbe..00000000 --- a/android/armeabi/include/webp/decode.h +++ /dev/null @@ -1,488 +0,0 @@ -// Copyright 2010 Google Inc. All Rights Reserved. -// -// Use of this source code is governed by a BSD-style license -// that can be found in the COPYING file in the root of the source -// tree. An additional intellectual property rights grant can be found -// in the file PATENTS. All contributing project authors may -// be found in the AUTHORS file in the root of the source tree. -// ----------------------------------------------------------------------------- -// -// Main decoding functions for WebP images. -// -// Author: Skal (pascal.massimino@gmail.com) - -#ifndef WEBP_WEBP_DECODE_H_ -#define WEBP_WEBP_DECODE_H_ - -#include "./types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define WEBP_DECODER_ABI_VERSION 0x0208 // MAJOR(8b) + MINOR(8b) - -// Note: forward declaring enumerations is not allowed in (strict) C and C++, -// the types are left here for reference. -// typedef enum VP8StatusCode VP8StatusCode; -// typedef enum WEBP_CSP_MODE WEBP_CSP_MODE; -typedef struct WebPRGBABuffer WebPRGBABuffer; -typedef struct WebPYUVABuffer WebPYUVABuffer; -typedef struct WebPDecBuffer WebPDecBuffer; -typedef struct WebPIDecoder WebPIDecoder; -typedef struct WebPBitstreamFeatures WebPBitstreamFeatures; -typedef struct WebPDecoderOptions WebPDecoderOptions; -typedef struct WebPDecoderConfig WebPDecoderConfig; - -// Return the decoder's version number, packed in hexadecimal using 8bits for -// each of major/minor/revision. E.g: v2.5.7 is 0x020507. -WEBP_EXTERN(int) WebPGetDecoderVersion(void); - -// Retrieve basic header information: width, height. -// This function will also validate the header and return 0 in -// case of formatting error. -// Pointers 'width' and 'height' can be passed NULL if deemed irrelevant. -WEBP_EXTERN(int) WebPGetInfo(const uint8_t* data, size_t data_size, - int* width, int* height); - -// Decodes WebP images pointed to by 'data' and returns RGBA samples, along -// with the dimensions in *width and *height. The ordering of samples in -// memory is R, G, B, A, R, G, B, A... in scan order (endian-independent). -// The returned pointer should be deleted calling WebPFree(). -// Returns NULL in case of error. -WEBP_EXTERN(uint8_t*) WebPDecodeRGBA(const uint8_t* data, size_t data_size, - int* width, int* height); - -// Same as WebPDecodeRGBA, but returning A, R, G, B, A, R, G, B... ordered data. -WEBP_EXTERN(uint8_t*) WebPDecodeARGB(const uint8_t* data, size_t data_size, - int* width, int* height); - -// Same as WebPDecodeRGBA, but returning B, G, R, A, B, G, R, A... ordered data. -WEBP_EXTERN(uint8_t*) WebPDecodeBGRA(const uint8_t* data, size_t data_size, - int* width, int* height); - -// Same as WebPDecodeRGBA, but returning R, G, B, R, G, B... ordered data. -// If the bitstream contains transparency, it is ignored. -WEBP_EXTERN(uint8_t*) WebPDecodeRGB(const uint8_t* data, size_t data_size, - int* width, int* height); - -// Same as WebPDecodeRGB, but returning B, G, R, B, G, R... ordered data. -WEBP_EXTERN(uint8_t*) WebPDecodeBGR(const uint8_t* data, size_t data_size, - int* width, int* height); - - -// Decode WebP images pointed to by 'data' to Y'UV format(*). The pointer -// returned is the Y samples buffer. Upon return, *u and *v will point to -// the U and V chroma data. These U and V buffers need NOT be passed to -// WebPFree(), unlike the returned Y luma one. The dimension of the U and V -// planes are both (*width + 1) / 2 and (*height + 1)/ 2. -// Upon return, the Y buffer has a stride returned as '*stride', while U and V -// have a common stride returned as '*uv_stride'. -// Return NULL in case of error. -// (*) Also named Y'CbCr. See: http://en.wikipedia.org/wiki/YCbCr -WEBP_EXTERN(uint8_t*) WebPDecodeYUV(const uint8_t* data, size_t data_size, - int* width, int* height, - uint8_t** u, uint8_t** v, - int* stride, int* uv_stride); - -// Releases memory returned by the WebPDecode*() functions above. -WEBP_EXTERN(void) WebPFree(void* ptr); - -// These five functions are variants of the above ones, that decode the image -// directly into a pre-allocated buffer 'output_buffer'. The maximum storage -// available in this buffer is indicated by 'output_buffer_size'. If this -// storage is not sufficient (or an error occurred), NULL is returned. -// Otherwise, output_buffer is returned, for convenience. -// The parameter 'output_stride' specifies the distance (in bytes) -// between scanlines. Hence, output_buffer_size is expected to be at least -// output_stride x picture-height. -WEBP_EXTERN(uint8_t*) WebPDecodeRGBAInto( - const uint8_t* data, size_t data_size, - uint8_t* output_buffer, size_t output_buffer_size, int output_stride); -WEBP_EXTERN(uint8_t*) WebPDecodeARGBInto( - const uint8_t* data, size_t data_size, - uint8_t* output_buffer, size_t output_buffer_size, int output_stride); -WEBP_EXTERN(uint8_t*) WebPDecodeBGRAInto( - const uint8_t* data, size_t data_size, - uint8_t* output_buffer, size_t output_buffer_size, int output_stride); - -// RGB and BGR variants. Here too the transparency information, if present, -// will be dropped and ignored. -WEBP_EXTERN(uint8_t*) WebPDecodeRGBInto( - const uint8_t* data, size_t data_size, - uint8_t* output_buffer, size_t output_buffer_size, int output_stride); -WEBP_EXTERN(uint8_t*) WebPDecodeBGRInto( - const uint8_t* data, size_t data_size, - uint8_t* output_buffer, size_t output_buffer_size, int output_stride); - -// WebPDecodeYUVInto() is a variant of WebPDecodeYUV() that operates directly -// into pre-allocated luma/chroma plane buffers. This function requires the -// strides to be passed: one for the luma plane and one for each of the -// chroma ones. The size of each plane buffer is passed as 'luma_size', -// 'u_size' and 'v_size' respectively. -// Pointer to the luma plane ('*luma') is returned or NULL if an error occurred -// during decoding (or because some buffers were found to be too small). -WEBP_EXTERN(uint8_t*) WebPDecodeYUVInto( - const uint8_t* data, size_t data_size, - uint8_t* luma, size_t luma_size, int luma_stride, - uint8_t* u, size_t u_size, int u_stride, - uint8_t* v, size_t v_size, int v_stride); - -//------------------------------------------------------------------------------ -// Output colorspaces and buffer - -// Colorspaces -// Note: the naming describes the byte-ordering of packed samples in memory. -// For instance, MODE_BGRA relates to samples ordered as B,G,R,A,B,G,R,A,... -// Non-capital names (e.g.:MODE_Argb) relates to pre-multiplied RGB channels. -// RGBA-4444 and RGB-565 colorspaces are represented by following byte-order: -// RGBA-4444: [r3 r2 r1 r0 g3 g2 g1 g0], [b3 b2 b1 b0 a3 a2 a1 a0], ... -// RGB-565: [r4 r3 r2 r1 r0 g5 g4 g3], [g2 g1 g0 b4 b3 b2 b1 b0], ... -// In the case WEBP_SWAP_16BITS_CSP is defined, the bytes are swapped for -// these two modes: -// RGBA-4444: [b3 b2 b1 b0 a3 a2 a1 a0], [r3 r2 r1 r0 g3 g2 g1 g0], ... -// RGB-565: [g2 g1 g0 b4 b3 b2 b1 b0], [r4 r3 r2 r1 r0 g5 g4 g3], ... - -typedef enum WEBP_CSP_MODE { - MODE_RGB = 0, MODE_RGBA = 1, - MODE_BGR = 2, MODE_BGRA = 3, - MODE_ARGB = 4, MODE_RGBA_4444 = 5, - MODE_RGB_565 = 6, - // RGB-premultiplied transparent modes (alpha value is preserved) - MODE_rgbA = 7, - MODE_bgrA = 8, - MODE_Argb = 9, - MODE_rgbA_4444 = 10, - // YUV modes must come after RGB ones. - MODE_YUV = 11, MODE_YUVA = 12, // yuv 4:2:0 - MODE_LAST = 13 -} WEBP_CSP_MODE; - -// Some useful macros: -static WEBP_INLINE int WebPIsPremultipliedMode(WEBP_CSP_MODE mode) { - return (mode == MODE_rgbA || mode == MODE_bgrA || mode == MODE_Argb || - mode == MODE_rgbA_4444); -} - -static WEBP_INLINE int WebPIsAlphaMode(WEBP_CSP_MODE mode) { - return (mode == MODE_RGBA || mode == MODE_BGRA || mode == MODE_ARGB || - mode == MODE_RGBA_4444 || mode == MODE_YUVA || - WebPIsPremultipliedMode(mode)); -} - -static WEBP_INLINE int WebPIsRGBMode(WEBP_CSP_MODE mode) { - return (mode < MODE_YUV); -} - -//------------------------------------------------------------------------------ -// WebPDecBuffer: Generic structure for describing the output sample buffer. - -struct WebPRGBABuffer { // view as RGBA - uint8_t* rgba; // pointer to RGBA samples - int stride; // stride in bytes from one scanline to the next. - size_t size; // total size of the *rgba buffer. -}; - -struct WebPYUVABuffer { // view as YUVA - uint8_t* y, *u, *v, *a; // pointer to luma, chroma U/V, alpha samples - int y_stride; // luma stride - int u_stride, v_stride; // chroma strides - int a_stride; // alpha stride - size_t y_size; // luma plane size - size_t u_size, v_size; // chroma planes size - size_t a_size; // alpha-plane size -}; - -// Output buffer -struct WebPDecBuffer { - WEBP_CSP_MODE colorspace; // Colorspace. - int width, height; // Dimensions. - int is_external_memory; // If true, 'internal_memory' pointer is not used. - union { - WebPRGBABuffer RGBA; - WebPYUVABuffer YUVA; - } u; // Nameless union of buffer parameters. - uint32_t pad[4]; // padding for later use - - uint8_t* private_memory; // Internally allocated memory (only when - // is_external_memory is false). Should not be used - // externally, but accessed via the buffer union. -}; - -// Internal, version-checked, entry point -WEBP_EXTERN(int) WebPInitDecBufferInternal(WebPDecBuffer*, int); - -// Initialize the structure as empty. Must be called before any other use. -// Returns false in case of version mismatch -static WEBP_INLINE int WebPInitDecBuffer(WebPDecBuffer* buffer) { - return WebPInitDecBufferInternal(buffer, WEBP_DECODER_ABI_VERSION); -} - -// Free any memory associated with the buffer. Must always be called last. -// Note: doesn't free the 'buffer' structure itself. -WEBP_EXTERN(void) WebPFreeDecBuffer(WebPDecBuffer* buffer); - -//------------------------------------------------------------------------------ -// Enumeration of the status codes - -typedef enum VP8StatusCode { - VP8_STATUS_OK = 0, - VP8_STATUS_OUT_OF_MEMORY, - VP8_STATUS_INVALID_PARAM, - VP8_STATUS_BITSTREAM_ERROR, - VP8_STATUS_UNSUPPORTED_FEATURE, - VP8_STATUS_SUSPENDED, - VP8_STATUS_USER_ABORT, - VP8_STATUS_NOT_ENOUGH_DATA -} VP8StatusCode; - -//------------------------------------------------------------------------------ -// Incremental decoding -// -// This API allows streamlined decoding of partial data. -// Picture can be incrementally decoded as data become available thanks to the -// WebPIDecoder object. This object can be left in a SUSPENDED state if the -// picture is only partially decoded, pending additional input. -// Code example: -// -// WebPInitDecBuffer(&buffer); -// buffer.colorspace = mode; -// ... -// WebPIDecoder* idec = WebPINewDecoder(&buffer); -// while (has_more_data) { -// // ... (get additional data) -// status = WebPIAppend(idec, new_data, new_data_size); -// if (status != VP8_STATUS_SUSPENDED || -// break; -// } -// -// // The above call decodes the current available buffer. -// // Part of the image can now be refreshed by calling to -// // WebPIDecGetRGB()/WebPIDecGetYUVA() etc. -// } -// WebPIDelete(idec); - -// Creates a new incremental decoder with the supplied buffer parameter. -// This output_buffer can be passed NULL, in which case a default output buffer -// is used (with MODE_RGB). Otherwise, an internal reference to 'output_buffer' -// is kept, which means that the lifespan of 'output_buffer' must be larger than -// that of the returned WebPIDecoder object. -// The supplied 'output_buffer' content MUST NOT be changed between calls to -// WebPIAppend() or WebPIUpdate() unless 'output_buffer.is_external_memory' is -// set to 1. In such a case, it is allowed to modify the pointers, size and -// stride of output_buffer.u.RGBA or output_buffer.u.YUVA, provided they remain -// within valid bounds. -// All other fields of WebPDecBuffer MUST remain constant between calls. -// Returns NULL if the allocation failed. -WEBP_EXTERN(WebPIDecoder*) WebPINewDecoder(WebPDecBuffer* output_buffer); - -// This function allocates and initializes an incremental-decoder object, which -// will output the RGB/A samples specified by 'csp' into a preallocated -// buffer 'output_buffer'. The size of this buffer is at least -// 'output_buffer_size' and the stride (distance in bytes between two scanlines) -// is specified by 'output_stride'. -// Additionally, output_buffer can be passed NULL in which case the output -// buffer will be allocated automatically when the decoding starts. The -// colorspace 'csp' is taken into account for allocating this buffer. All other -// parameters are ignored. -// Returns NULL if the allocation failed, or if some parameters are invalid. -WEBP_EXTERN(WebPIDecoder*) WebPINewRGB( - WEBP_CSP_MODE csp, - uint8_t* output_buffer, size_t output_buffer_size, int output_stride); - -// This function allocates and initializes an incremental-decoder object, which -// will output the raw luma/chroma samples into a preallocated planes if -// supplied. The luma plane is specified by its pointer 'luma', its size -// 'luma_size' and its stride 'luma_stride'. Similarly, the chroma-u plane -// is specified by the 'u', 'u_size' and 'u_stride' parameters, and the chroma-v -// plane by 'v' and 'v_size'. And same for the alpha-plane. The 'a' pointer -// can be pass NULL in case one is not interested in the transparency plane. -// Conversely, 'luma' can be passed NULL if no preallocated planes are supplied. -// In this case, the output buffer will be automatically allocated (using -// MODE_YUVA) when decoding starts. All parameters are then ignored. -// Returns NULL if the allocation failed or if a parameter is invalid. -WEBP_EXTERN(WebPIDecoder*) WebPINewYUVA( - uint8_t* luma, size_t luma_size, int luma_stride, - uint8_t* u, size_t u_size, int u_stride, - uint8_t* v, size_t v_size, int v_stride, - uint8_t* a, size_t a_size, int a_stride); - -// Deprecated version of the above, without the alpha plane. -// Kept for backward compatibility. -WEBP_EXTERN(WebPIDecoder*) WebPINewYUV( - uint8_t* luma, size_t luma_size, int luma_stride, - uint8_t* u, size_t u_size, int u_stride, - uint8_t* v, size_t v_size, int v_stride); - -// Deletes the WebPIDecoder object and associated memory. Must always be called -// if WebPINewDecoder, WebPINewRGB or WebPINewYUV succeeded. -WEBP_EXTERN(void) WebPIDelete(WebPIDecoder* idec); - -// Copies and decodes the next available data. Returns VP8_STATUS_OK when -// the image is successfully decoded. Returns VP8_STATUS_SUSPENDED when more -// data is expected. Returns error in other cases. -WEBP_EXTERN(VP8StatusCode) WebPIAppend( - WebPIDecoder* idec, const uint8_t* data, size_t data_size); - -// A variant of the above function to be used when data buffer contains -// partial data from the beginning. In this case data buffer is not copied -// to the internal memory. -// Note that the value of the 'data' pointer can change between calls to -// WebPIUpdate, for instance when the data buffer is resized to fit larger data. -WEBP_EXTERN(VP8StatusCode) WebPIUpdate( - WebPIDecoder* idec, const uint8_t* data, size_t data_size); - -// Returns the RGB/A image decoded so far. Returns NULL if output params -// are not initialized yet. The RGB/A output type corresponds to the colorspace -// specified during call to WebPINewDecoder() or WebPINewRGB(). -// *last_y is the index of last decoded row in raster scan order. Some pointers -// (*last_y, *width etc.) can be NULL if corresponding information is not -// needed. -WEBP_EXTERN(uint8_t*) WebPIDecGetRGB( - const WebPIDecoder* idec, int* last_y, - int* width, int* height, int* stride); - -// Same as above function to get a YUVA image. Returns pointer to the luma -// plane or NULL in case of error. If there is no alpha information -// the alpha pointer '*a' will be returned NULL. -WEBP_EXTERN(uint8_t*) WebPIDecGetYUVA( - const WebPIDecoder* idec, int* last_y, - uint8_t** u, uint8_t** v, uint8_t** a, - int* width, int* height, int* stride, int* uv_stride, int* a_stride); - -// Deprecated alpha-less version of WebPIDecGetYUVA(): it will ignore the -// alpha information (if present). Kept for backward compatibility. -static WEBP_INLINE uint8_t* WebPIDecGetYUV( - const WebPIDecoder* idec, int* last_y, uint8_t** u, uint8_t** v, - int* width, int* height, int* stride, int* uv_stride) { - return WebPIDecGetYUVA(idec, last_y, u, v, NULL, width, height, - stride, uv_stride, NULL); -} - -// Generic call to retrieve information about the displayable area. -// If non NULL, the left/right/width/height pointers are filled with the visible -// rectangular area so far. -// Returns NULL in case the incremental decoder object is in an invalid state. -// Otherwise returns the pointer to the internal representation. This structure -// is read-only, tied to WebPIDecoder's lifespan and should not be modified. -WEBP_EXTERN(const WebPDecBuffer*) WebPIDecodedArea( - const WebPIDecoder* idec, int* left, int* top, int* width, int* height); - -//------------------------------------------------------------------------------ -// Advanced decoding parametrization -// -// Code sample for using the advanced decoding API -/* - // A) Init a configuration object - WebPDecoderConfig config; - CHECK(WebPInitDecoderConfig(&config)); - - // B) optional: retrieve the bitstream's features. - CHECK(WebPGetFeatures(data, data_size, &config.input) == VP8_STATUS_OK); - - // C) Adjust 'config', if needed - config.no_fancy_upsampling = 1; - config.output.colorspace = MODE_BGRA; - // etc. - - // Note that you can also make config.output point to an externally - // supplied memory buffer, provided it's big enough to store the decoded - // picture. Otherwise, config.output will just be used to allocate memory - // and store the decoded picture. - - // D) Decode! - CHECK(WebPDecode(data, data_size, &config) == VP8_STATUS_OK); - - // E) Decoded image is now in config.output (and config.output.u.RGBA) - - // F) Reclaim memory allocated in config's object. It's safe to call - // this function even if the memory is external and wasn't allocated - // by WebPDecode(). - WebPFreeDecBuffer(&config.output); -*/ - -// Features gathered from the bitstream -struct WebPBitstreamFeatures { - int width; // Width in pixels, as read from the bitstream. - int height; // Height in pixels, as read from the bitstream. - int has_alpha; // True if the bitstream contains an alpha channel. - int has_animation; // True if the bitstream is an animation. - int format; // 0 = undefined (/mixed), 1 = lossy, 2 = lossless - - uint32_t pad[5]; // padding for later use -}; - -// Internal, version-checked, entry point -WEBP_EXTERN(VP8StatusCode) WebPGetFeaturesInternal( - const uint8_t*, size_t, WebPBitstreamFeatures*, int); - -// Retrieve features from the bitstream. The *features structure is filled -// with information gathered from the bitstream. -// Returns VP8_STATUS_OK when the features are successfully retrieved. Returns -// VP8_STATUS_NOT_ENOUGH_DATA when more data is needed to retrieve the -// features from headers. Returns error in other cases. -static WEBP_INLINE VP8StatusCode WebPGetFeatures( - const uint8_t* data, size_t data_size, - WebPBitstreamFeatures* features) { - return WebPGetFeaturesInternal(data, data_size, features, - WEBP_DECODER_ABI_VERSION); -} - -// Decoding options -struct WebPDecoderOptions { - int bypass_filtering; // if true, skip the in-loop filtering - int no_fancy_upsampling; // if true, use faster pointwise upsampler - int use_cropping; // if true, cropping is applied _first_ - int crop_left, crop_top; // top-left position for cropping. - // Will be snapped to even values. - int crop_width, crop_height; // dimension of the cropping area - int use_scaling; // if true, scaling is applied _afterward_ - int scaled_width, scaled_height; // final resolution - int use_threads; // if true, use multi-threaded decoding - int dithering_strength; // dithering strength (0=Off, 100=full) - int flip; // flip output vertically - int alpha_dithering_strength; // alpha dithering strength in [0..100] - - uint32_t pad[5]; // padding for later use -}; - -// Main object storing the configuration for advanced decoding. -struct WebPDecoderConfig { - WebPBitstreamFeatures input; // Immutable bitstream features (optional) - WebPDecBuffer output; // Output buffer (can point to external mem) - WebPDecoderOptions options; // Decoding options -}; - -// Internal, version-checked, entry point -WEBP_EXTERN(int) WebPInitDecoderConfigInternal(WebPDecoderConfig*, int); - -// Initialize the configuration as empty. This function must always be -// called first, unless WebPGetFeatures() is to be called. -// Returns false in case of mismatched version. -static WEBP_INLINE int WebPInitDecoderConfig(WebPDecoderConfig* config) { - return WebPInitDecoderConfigInternal(config, WEBP_DECODER_ABI_VERSION); -} - -// Instantiate a new incremental decoder object with the requested -// configuration. The bitstream can be passed using 'data' and 'data_size' -// parameter, in which case the features will be parsed and stored into -// config->input. Otherwise, 'data' can be NULL and no parsing will occur. -// Note that 'config' can be NULL too, in which case a default configuration -// is used. -// The return WebPIDecoder object must always be deleted calling WebPIDelete(). -// Returns NULL in case of error (and config->status will then reflect -// the error condition). -WEBP_EXTERN(WebPIDecoder*) WebPIDecode(const uint8_t* data, size_t data_size, - WebPDecoderConfig* config); - -// Non-incremental version. This version decodes the full data at once, taking -// 'config' into account. Returns decoding status (which should be VP8_STATUS_OK -// if the decoding was successful). -WEBP_EXTERN(VP8StatusCode) WebPDecode(const uint8_t* data, size_t data_size, - WebPDecoderConfig* config); - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* WEBP_WEBP_DECODE_H_ */ diff --git a/android/armeabi/include/webp/encode.h b/android/armeabi/include/webp/encode.h deleted file mode 100644 index c382ea76..00000000 --- a/android/armeabi/include/webp/encode.h +++ /dev/null @@ -1,527 +0,0 @@ -// Copyright 2011 Google Inc. All Rights Reserved. -// -// Use of this source code is governed by a BSD-style license -// that can be found in the COPYING file in the root of the source -// tree. An additional intellectual property rights grant can be found -// in the file PATENTS. All contributing project authors may -// be found in the AUTHORS file in the root of the source tree. -// ----------------------------------------------------------------------------- -// -// WebP encoder: main interface -// -// Author: Skal (pascal.massimino@gmail.com) - -#ifndef WEBP_WEBP_ENCODE_H_ -#define WEBP_WEBP_ENCODE_H_ - -#include "./types.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define WEBP_ENCODER_ABI_VERSION 0x0209 // MAJOR(8b) + MINOR(8b) - -// Note: forward declaring enumerations is not allowed in (strict) C and C++, -// the types are left here for reference. -// typedef enum WebPImageHint WebPImageHint; -// typedef enum WebPEncCSP WebPEncCSP; -// typedef enum WebPPreset WebPPreset; -// typedef enum WebPEncodingError WebPEncodingError; -typedef struct WebPConfig WebPConfig; -typedef struct WebPPicture WebPPicture; // main structure for I/O -typedef struct WebPAuxStats WebPAuxStats; -typedef struct WebPMemoryWriter WebPMemoryWriter; - -// Return the encoder's version number, packed in hexadecimal using 8bits for -// each of major/minor/revision. E.g: v2.5.7 is 0x020507. -WEBP_EXTERN(int) WebPGetEncoderVersion(void); - -//------------------------------------------------------------------------------ -// One-stop-shop call! No questions asked: - -// Returns the size of the compressed data (pointed to by *output), or 0 if -// an error occurred. The compressed data must be released by the caller -// using the call 'WebPFree(*output)'. -// These functions compress using the lossy format, and the quality_factor -// can go from 0 (smaller output, lower quality) to 100 (best quality, -// larger output). -WEBP_EXTERN(size_t) WebPEncodeRGB(const uint8_t* rgb, - int width, int height, int stride, - float quality_factor, uint8_t** output); -WEBP_EXTERN(size_t) WebPEncodeBGR(const uint8_t* bgr, - int width, int height, int stride, - float quality_factor, uint8_t** output); -WEBP_EXTERN(size_t) WebPEncodeRGBA(const uint8_t* rgba, - int width, int height, int stride, - float quality_factor, uint8_t** output); -WEBP_EXTERN(size_t) WebPEncodeBGRA(const uint8_t* bgra, - int width, int height, int stride, - float quality_factor, uint8_t** output); - -// These functions are the equivalent of the above, but compressing in a -// lossless manner. Files are usually larger than lossy format, but will -// not suffer any compression loss. -WEBP_EXTERN(size_t) WebPEncodeLosslessRGB(const uint8_t* rgb, - int width, int height, int stride, - uint8_t** output); -WEBP_EXTERN(size_t) WebPEncodeLosslessBGR(const uint8_t* bgr, - int width, int height, int stride, - uint8_t** output); -WEBP_EXTERN(size_t) WebPEncodeLosslessRGBA(const uint8_t* rgba, - int width, int height, int stride, - uint8_t** output); -WEBP_EXTERN(size_t) WebPEncodeLosslessBGRA(const uint8_t* bgra, - int width, int height, int stride, - uint8_t** output); - -// Releases memory returned by the WebPEncode*() functions above. -WEBP_EXTERN(void) WebPFree(void* ptr); - -//------------------------------------------------------------------------------ -// Coding parameters - -// Image characteristics hint for the underlying encoder. -typedef enum WebPImageHint { - WEBP_HINT_DEFAULT = 0, // default preset. - WEBP_HINT_PICTURE, // digital picture, like portrait, inner shot - WEBP_HINT_PHOTO, // outdoor photograph, with natural lighting - WEBP_HINT_GRAPH, // Discrete tone image (graph, map-tile etc). - WEBP_HINT_LAST -} WebPImageHint; - -// Compression parameters. -struct WebPConfig { - int lossless; // Lossless encoding (0=lossy(default), 1=lossless). - float quality; // between 0 (smallest file) and 100 (biggest) - int method; // quality/speed trade-off (0=fast, 6=slower-better) - - WebPImageHint image_hint; // Hint for image type (lossless only for now). - - // Parameters related to lossy compression only: - int target_size; // if non-zero, set the desired target size in bytes. - // Takes precedence over the 'compression' parameter. - float target_PSNR; // if non-zero, specifies the minimal distortion to - // try to achieve. Takes precedence over target_size. - int segments; // maximum number of segments to use, in [1..4] - int sns_strength; // Spatial Noise Shaping. 0=off, 100=maximum. - int filter_strength; // range: [0 = off .. 100 = strongest] - int filter_sharpness; // range: [0 = off .. 7 = least sharp] - int filter_type; // filtering type: 0 = simple, 1 = strong (only used - // if filter_strength > 0 or autofilter > 0) - int autofilter; // Auto adjust filter's strength [0 = off, 1 = on] - int alpha_compression; // Algorithm for encoding the alpha plane (0 = none, - // 1 = compressed with WebP lossless). Default is 1. - int alpha_filtering; // Predictive filtering method for alpha plane. - // 0: none, 1: fast, 2: best. Default if 1. - int alpha_quality; // Between 0 (smallest size) and 100 (lossless). - // Default is 100. - int pass; // number of entropy-analysis passes (in [1..10]). - - int show_compressed; // if true, export the compressed picture back. - // In-loop filtering is not applied. - int preprocessing; // preprocessing filter: - // 0=none, 1=segment-smooth, 2=pseudo-random dithering - int partitions; // log2(number of token partitions) in [0..3]. Default - // is set to 0 for easier progressive decoding. - int partition_limit; // quality degradation allowed to fit the 512k limit - // on prediction modes coding (0: no degradation, - // 100: maximum possible degradation). - int emulate_jpeg_size; // If true, compression parameters will be remapped - // to better match the expected output size from - // JPEG compression. Generally, the output size will - // be similar but the degradation will be lower. - int thread_level; // If non-zero, try and use multi-threaded encoding. - int low_memory; // If set, reduce memory usage (but increase CPU use). - - int near_lossless; // Near lossless encoding [0 = off(default) .. 100]. - // This feature is experimental. - int exact; // if non-zero, preserve the exact RGB values under - // transparent area. Otherwise, discard this invisible - // RGB information for better compression. The default - // value is 0. - -#ifdef WEBP_EXPERIMENTAL_FEATURES - int delta_palettization; - uint32_t pad[2]; // padding for later use -#else - uint32_t pad[3]; // padding for later use -#endif // WEBP_EXPERIMENTAL_FEATURES -}; - -// Enumerate some predefined settings for WebPConfig, depending on the type -// of source picture. These presets are used when calling WebPConfigPreset(). -typedef enum WebPPreset { - WEBP_PRESET_DEFAULT = 0, // default preset. - WEBP_PRESET_PICTURE, // digital picture, like portrait, inner shot - WEBP_PRESET_PHOTO, // outdoor photograph, with natural lighting - WEBP_PRESET_DRAWING, // hand or line drawing, with high-contrast details - WEBP_PRESET_ICON, // small-sized colorful images - WEBP_PRESET_TEXT // text-like -} WebPPreset; - -// Internal, version-checked, entry point -WEBP_EXTERN(int) WebPConfigInitInternal(WebPConfig*, WebPPreset, float, int); - -// Should always be called, to initialize a fresh WebPConfig structure before -// modification. Returns false in case of version mismatch. WebPConfigInit() -// must have succeeded before using the 'config' object. -// Note that the default values are lossless=0 and quality=75. -static WEBP_INLINE int WebPConfigInit(WebPConfig* config) { - return WebPConfigInitInternal(config, WEBP_PRESET_DEFAULT, 75.f, - WEBP_ENCODER_ABI_VERSION); -} - -// This function will initialize the configuration according to a predefined -// set of parameters (referred to by 'preset') and a given quality factor. -// This function can be called as a replacement to WebPConfigInit(). Will -// return false in case of error. -static WEBP_INLINE int WebPConfigPreset(WebPConfig* config, - WebPPreset preset, float quality) { - return WebPConfigInitInternal(config, preset, quality, - WEBP_ENCODER_ABI_VERSION); -} - -// Activate the lossless compression mode with the desired efficiency level -// between 0 (fastest, lowest compression) and 9 (slower, best compression). -// A good default level is '6', providing a fair tradeoff between compression -// speed and final compressed size. -// This function will overwrite several fields from config: 'method', 'quality' -// and 'lossless'. Returns false in case of parameter error. -WEBP_EXTERN(int) WebPConfigLosslessPreset(WebPConfig* config, int level); - -// Returns true if 'config' is non-NULL and all configuration parameters are -// within their valid ranges. -WEBP_EXTERN(int) WebPValidateConfig(const WebPConfig* config); - -//------------------------------------------------------------------------------ -// Input / Output -// Structure for storing auxiliary statistics (mostly for lossy encoding). - -struct WebPAuxStats { - int coded_size; // final size - - float PSNR[5]; // peak-signal-to-noise ratio for Y/U/V/All/Alpha - int block_count[3]; // number of intra4/intra16/skipped macroblocks - int header_bytes[2]; // approximate number of bytes spent for header - // and mode-partition #0 - int residual_bytes[3][4]; // approximate number of bytes spent for - // DC/AC/uv coefficients for each (0..3) segments. - int segment_size[4]; // number of macroblocks in each segments - int segment_quant[4]; // quantizer values for each segments - int segment_level[4]; // filtering strength for each segments [0..63] - - int alpha_data_size; // size of the transparency data - int layer_data_size; // size of the enhancement layer data - - // lossless encoder statistics - uint32_t lossless_features; // bit0:predictor bit1:cross-color transform - // bit2:subtract-green bit3:color indexing - int histogram_bits; // number of precision bits of histogram - int transform_bits; // precision bits for transform - int cache_bits; // number of bits for color cache lookup - int palette_size; // number of color in palette, if used - int lossless_size; // final lossless size - int lossless_hdr_size; // lossless header (transform, huffman etc) size - int lossless_data_size; // lossless image data size - - uint32_t pad[2]; // padding for later use -}; - -// Signature for output function. Should return true if writing was successful. -// data/data_size is the segment of data to write, and 'picture' is for -// reference (and so one can make use of picture->custom_ptr). -typedef int (*WebPWriterFunction)(const uint8_t* data, size_t data_size, - const WebPPicture* picture); - -// WebPMemoryWrite: a special WebPWriterFunction that writes to memory using -// the following WebPMemoryWriter object (to be set as a custom_ptr). -struct WebPMemoryWriter { - uint8_t* mem; // final buffer (of size 'max_size', larger than 'size'). - size_t size; // final size - size_t max_size; // total capacity - uint32_t pad[1]; // padding for later use -}; - -// The following must be called first before any use. -WEBP_EXTERN(void) WebPMemoryWriterInit(WebPMemoryWriter* writer); - -// The following must be called to deallocate writer->mem memory. The 'writer' -// object itself is not deallocated. -WEBP_EXTERN(void) WebPMemoryWriterClear(WebPMemoryWriter* writer); -// The custom writer to be used with WebPMemoryWriter as custom_ptr. Upon -// completion, writer.mem and writer.size will hold the coded data. -// writer.mem must be freed by calling WebPMemoryWriterClear. -WEBP_EXTERN(int) WebPMemoryWrite(const uint8_t* data, size_t data_size, - const WebPPicture* picture); - -// Progress hook, called from time to time to report progress. It can return -// false to request an abort of the encoding process, or true otherwise if -// everything is OK. -typedef int (*WebPProgressHook)(int percent, const WebPPicture* picture); - -// Color spaces. -typedef enum WebPEncCSP { - // chroma sampling - WEBP_YUV420 = 0, // 4:2:0 - WEBP_YUV420A = 4, // alpha channel variant - WEBP_CSP_UV_MASK = 3, // bit-mask to get the UV sampling factors - WEBP_CSP_ALPHA_BIT = 4 // bit that is set if alpha is present -} WebPEncCSP; - -// Encoding error conditions. -typedef enum WebPEncodingError { - VP8_ENC_OK = 0, - VP8_ENC_ERROR_OUT_OF_MEMORY, // memory error allocating objects - VP8_ENC_ERROR_BITSTREAM_OUT_OF_MEMORY, // memory error while flushing bits - VP8_ENC_ERROR_NULL_PARAMETER, // a pointer parameter is NULL - VP8_ENC_ERROR_INVALID_CONFIGURATION, // configuration is invalid - VP8_ENC_ERROR_BAD_DIMENSION, // picture has invalid width/height - VP8_ENC_ERROR_PARTITION0_OVERFLOW, // partition is bigger than 512k - VP8_ENC_ERROR_PARTITION_OVERFLOW, // partition is bigger than 16M - VP8_ENC_ERROR_BAD_WRITE, // error while flushing bytes - VP8_ENC_ERROR_FILE_TOO_BIG, // file is bigger than 4G - VP8_ENC_ERROR_USER_ABORT, // abort request by user - VP8_ENC_ERROR_LAST // list terminator. always last. -} WebPEncodingError; - -// maximum width/height allowed (inclusive), in pixels -#define WEBP_MAX_DIMENSION 16383 - -// Main exchange structure (input samples, output bytes, statistics) -struct WebPPicture { - // INPUT - ////////////// - // Main flag for encoder selecting between ARGB or YUV input. - // It is recommended to use ARGB input (*argb, argb_stride) for lossless - // compression, and YUV input (*y, *u, *v, etc.) for lossy compression - // since these are the respective native colorspace for these formats. - int use_argb; - - // YUV input (mostly used for input to lossy compression) - WebPEncCSP colorspace; // colorspace: should be YUV420 for now (=Y'CbCr). - int width, height; // dimensions (less or equal to WEBP_MAX_DIMENSION) - uint8_t *y, *u, *v; // pointers to luma/chroma planes. - int y_stride, uv_stride; // luma/chroma strides. - uint8_t* a; // pointer to the alpha plane - int a_stride; // stride of the alpha plane - uint32_t pad1[2]; // padding for later use - - // ARGB input (mostly used for input to lossless compression) - uint32_t* argb; // Pointer to argb (32 bit) plane. - int argb_stride; // This is stride in pixels units, not bytes. - uint32_t pad2[3]; // padding for later use - - // OUTPUT - /////////////// - // Byte-emission hook, to store compressed bytes as they are ready. - WebPWriterFunction writer; // can be NULL - void* custom_ptr; // can be used by the writer. - - // map for extra information (only for lossy compression mode) - int extra_info_type; // 1: intra type, 2: segment, 3: quant - // 4: intra-16 prediction mode, - // 5: chroma prediction mode, - // 6: bit cost, 7: distortion - uint8_t* extra_info; // if not NULL, points to an array of size - // ((width + 15) / 16) * ((height + 15) / 16) that - // will be filled with a macroblock map, depending - // on extra_info_type. - - // STATS AND REPORTS - /////////////////////////// - // Pointer to side statistics (updated only if not NULL) - WebPAuxStats* stats; - - // Error code for the latest error encountered during encoding - WebPEncodingError error_code; - - // If not NULL, report progress during encoding. - WebPProgressHook progress_hook; - - void* user_data; // this field is free to be set to any value and - // used during callbacks (like progress-report e.g.). - - uint32_t pad3[3]; // padding for later use - - // Unused for now - uint8_t *pad4, *pad5; - uint32_t pad6[8]; // padding for later use - - // PRIVATE FIELDS - //////////////////// - void* memory_; // row chunk of memory for yuva planes - void* memory_argb_; // and for argb too. - void* pad7[2]; // padding for later use -}; - -// Internal, version-checked, entry point -WEBP_EXTERN(int) WebPPictureInitInternal(WebPPicture*, int); - -// Should always be called, to initialize the structure. Returns false in case -// of version mismatch. WebPPictureInit() must have succeeded before using the -// 'picture' object. -// Note that, by default, use_argb is false and colorspace is WEBP_YUV420. -static WEBP_INLINE int WebPPictureInit(WebPPicture* picture) { - return WebPPictureInitInternal(picture, WEBP_ENCODER_ABI_VERSION); -} - -//------------------------------------------------------------------------------ -// WebPPicture utils - -// Convenience allocation / deallocation based on picture->width/height: -// Allocate y/u/v buffers as per colorspace/width/height specification. -// Note! This function will free the previous buffer if needed. -// Returns false in case of memory error. -WEBP_EXTERN(int) WebPPictureAlloc(WebPPicture* picture); - -// Release the memory allocated by WebPPictureAlloc() or WebPPictureImport*(). -// Note that this function does _not_ free the memory used by the 'picture' -// object itself. -// Besides memory (which is reclaimed) all other fields of 'picture' are -// preserved. -WEBP_EXTERN(void) WebPPictureFree(WebPPicture* picture); - -// Copy the pixels of *src into *dst, using WebPPictureAlloc. Upon return, *dst -// will fully own the copied pixels (this is not a view). The 'dst' picture need -// not be initialized as its content is overwritten. -// Returns false in case of memory allocation error. -WEBP_EXTERN(int) WebPPictureCopy(const WebPPicture* src, WebPPicture* dst); - -// Compute PSNR, SSIM or LSIM distortion metric between two pictures. Results -// are in dB, stored in result[] in the Y/U/V/Alpha/All or B/G/R/A/All order. -// Returns false in case of error (src and ref don't have same dimension, ...) -// Warning: this function is rather CPU-intensive. -WEBP_EXTERN(int) WebPPictureDistortion( - const WebPPicture* src, const WebPPicture* ref, - int metric_type, // 0 = PSNR, 1 = SSIM, 2 = LSIM - float result[5]); - -// self-crops a picture to the rectangle defined by top/left/width/height. -// Returns false in case of memory allocation error, or if the rectangle is -// outside of the source picture. -// The rectangle for the view is defined by the top-left corner pixel -// coordinates (left, top) as well as its width and height. This rectangle -// must be fully be comprised inside the 'src' source picture. If the source -// picture uses the YUV420 colorspace, the top and left coordinates will be -// snapped to even values. -WEBP_EXTERN(int) WebPPictureCrop(WebPPicture* picture, - int left, int top, int width, int height); - -// Extracts a view from 'src' picture into 'dst'. The rectangle for the view -// is defined by the top-left corner pixel coordinates (left, top) as well -// as its width and height. This rectangle must be fully be comprised inside -// the 'src' source picture. If the source picture uses the YUV420 colorspace, -// the top and left coordinates will be snapped to even values. -// Picture 'src' must out-live 'dst' picture. Self-extraction of view is allowed -// ('src' equal to 'dst') as a mean of fast-cropping (but note that doing so, -// the original dimension will be lost). Picture 'dst' need not be initialized -// with WebPPictureInit() if it is different from 'src', since its content will -// be overwritten. -// Returns false in case of memory allocation error or invalid parameters. -WEBP_EXTERN(int) WebPPictureView(const WebPPicture* src, - int left, int top, int width, int height, - WebPPicture* dst); - -// Returns true if the 'picture' is actually a view and therefore does -// not own the memory for pixels. -WEBP_EXTERN(int) WebPPictureIsView(const WebPPicture* picture); - -// Rescale a picture to new dimension width x height. -// If either 'width' or 'height' (but not both) is 0 the corresponding -// dimension will be calculated preserving the aspect ratio. -// No gamma correction is applied. -// Returns false in case of error (invalid parameter or insufficient memory). -WEBP_EXTERN(int) WebPPictureRescale(WebPPicture* pic, int width, int height); - -// Colorspace conversion function to import RGB samples. -// Previous buffer will be free'd, if any. -// *rgb buffer should have a size of at least height * rgb_stride. -// Returns false in case of memory error. -WEBP_EXTERN(int) WebPPictureImportRGB( - WebPPicture* picture, const uint8_t* rgb, int rgb_stride); -// Same, but for RGBA buffer. -WEBP_EXTERN(int) WebPPictureImportRGBA( - WebPPicture* picture, const uint8_t* rgba, int rgba_stride); -// Same, but for RGBA buffer. Imports the RGB direct from the 32-bit format -// input buffer ignoring the alpha channel. Avoids needing to copy the data -// to a temporary 24-bit RGB buffer to import the RGB only. -WEBP_EXTERN(int) WebPPictureImportRGBX( - WebPPicture* picture, const uint8_t* rgbx, int rgbx_stride); - -// Variants of the above, but taking BGR(A|X) input. -WEBP_EXTERN(int) WebPPictureImportBGR( - WebPPicture* picture, const uint8_t* bgr, int bgr_stride); -WEBP_EXTERN(int) WebPPictureImportBGRA( - WebPPicture* picture, const uint8_t* bgra, int bgra_stride); -WEBP_EXTERN(int) WebPPictureImportBGRX( - WebPPicture* picture, const uint8_t* bgrx, int bgrx_stride); - -// Converts picture->argb data to the YUV420A format. The 'colorspace' -// parameter is deprecated and should be equal to WEBP_YUV420. -// Upon return, picture->use_argb is set to false. The presence of real -// non-opaque transparent values is detected, and 'colorspace' will be -// adjusted accordingly. Note that this method is lossy. -// Returns false in case of error. -WEBP_EXTERN(int) WebPPictureARGBToYUVA(WebPPicture* picture, - WebPEncCSP /*colorspace = WEBP_YUV420*/); - -// Same as WebPPictureARGBToYUVA(), but the conversion is done using -// pseudo-random dithering with a strength 'dithering' between -// 0.0 (no dithering) and 1.0 (maximum dithering). This is useful -// for photographic picture. -WEBP_EXTERN(int) WebPPictureARGBToYUVADithered( - WebPPicture* picture, WebPEncCSP colorspace, float dithering); - -// Performs 'smart' RGBA->YUVA420 downsampling and colorspace conversion. -// Downsampling is handled with extra care in case of color clipping. This -// method is roughly 2x slower than WebPPictureARGBToYUVA() but produces better -// YUV representation. -// Returns false in case of error. -WEBP_EXTERN(int) WebPPictureSmartARGBToYUVA(WebPPicture* picture); - -// Converts picture->yuv to picture->argb and sets picture->use_argb to true. -// The input format must be YUV_420 or YUV_420A. -// Note that the use of this method is discouraged if one has access to the -// raw ARGB samples, since using YUV420 is comparatively lossy. Also, the -// conversion from YUV420 to ARGB incurs a small loss too. -// Returns false in case of error. -WEBP_EXTERN(int) WebPPictureYUVAToARGB(WebPPicture* picture); - -// Helper function: given a width x height plane of RGBA or YUV(A) samples -// clean-up the YUV or RGB samples under fully transparent area, to help -// compressibility (no guarantee, though). -WEBP_EXTERN(void) WebPCleanupTransparentArea(WebPPicture* picture); - -// Scan the picture 'picture' for the presence of non fully opaque alpha values. -// Returns true in such case. Otherwise returns false (indicating that the -// alpha plane can be ignored altogether e.g.). -WEBP_EXTERN(int) WebPPictureHasTransparency(const WebPPicture* picture); - -// Remove the transparency information (if present) by blending the color with -// the background color 'background_rgb' (specified as 24bit RGB triplet). -// After this call, all alpha values are reset to 0xff. -WEBP_EXTERN(void) WebPBlendAlpha(WebPPicture* pic, uint32_t background_rgb); - -//------------------------------------------------------------------------------ -// Main call - -// Main encoding call, after config and picture have been initialized. -// 'picture' must be less than 16384x16384 in dimension (cf WEBP_MAX_DIMENSION), -// and the 'config' object must be a valid one. -// Returns false in case of error, true otherwise. -// In case of error, picture->error_code is updated accordingly. -// 'picture' can hold the source samples in both YUV(A) or ARGB input, depending -// on the value of 'picture->use_argb'. It is highly recommended to use -// the former for lossy encoding, and the latter for lossless encoding -// (when config.lossless is true). Automatic conversion from one format to -// another is provided but they both incur some loss. -WEBP_EXTERN(int) WebPEncode(const WebPConfig* config, WebPPicture* picture); - -//------------------------------------------------------------------------------ - -#ifdef __cplusplus -} // extern "C" -#endif - -#endif /* WEBP_WEBP_ENCODE_H_ */ diff --git a/android/armeabi/include/webp/types.h b/android/armeabi/include/webp/types.h deleted file mode 100644 index 98fff35a..00000000 --- a/android/armeabi/include/webp/types.h +++ /dev/null @@ -1,52 +0,0 @@ -// Copyright 2010 Google Inc. All Rights Reserved. -// -// Use of this source code is governed by a BSD-style license -// that can be found in the COPYING file in the root of the source -// tree. An additional intellectual property rights grant can be found -// in the file PATENTS. All contributing project authors may -// be found in the AUTHORS file in the root of the source tree. -// ----------------------------------------------------------------------------- -// -// Common types -// -// Author: Skal (pascal.massimino@gmail.com) - -#ifndef WEBP_WEBP_TYPES_H_ -#define WEBP_WEBP_TYPES_H_ - -#include <stddef.h> // for size_t - -#ifndef _MSC_VER -#include <inttypes.h> -#if defined(__cplusplus) || !defined(__STRICT_ANSI__) || \ - (defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) -#define WEBP_INLINE inline -#else -#define WEBP_INLINE -#endif -#else -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef unsigned long long int uint64_t; -typedef long long int int64_t; -#define WEBP_INLINE __forceinline -#endif /* _MSC_VER */ - -#ifndef WEBP_EXTERN -// This explicitly marks library functions and allows for changing the -// signature for e.g., Windows DLL builds. -# if defined(__GNUC__) && __GNUC__ >= 4 -# define WEBP_EXTERN(type) extern __attribute__ ((visibility ("default"))) type -# else -# define WEBP_EXTERN(type) extern type -# endif /* __GNUC__ >= 4 */ -#endif /* WEBP_EXTERN */ - -// Macro to check ABI compatibility (same major revision number) -#define WEBP_ABI_IS_INCOMPATIBLE(a, b) (((a) >> 8) != ((b) >> 8)) - -#endif /* WEBP_WEBP_TYPES_H_ */ diff --git a/android/armeabi/include/websockets/libwebsockets.h b/android/armeabi/include/websockets/libwebsockets.h deleted file mode 100644 index 7efeba1f..00000000 --- a/android/armeabi/include/websockets/libwebsockets.h +++ /dev/null @@ -1,4196 +0,0 @@ -/* - * libwebsockets - small server side websockets and web server implementation - * - * Copyright (C) 2010-2016 Andy Green <andy@warmcat.com> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation: - * version 2.1 of the License. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, - * MA 02110-1301 USA - */ - -/** @file */ - -#ifndef LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C -#define LIBWEBSOCKET_H_3060898B846849FF9F88F5DB59B5950C - -#ifdef __cplusplus -#include <cstddef> -#include <cstdarg> -#ifdef MBED_OPERATORS -#include "mbed-drivers/mbed.h" -#include "sal-iface-eth/EthernetInterface.h" -#include "sockets/TCPListener.h" -#include "sal-stack-lwip/lwipv4_init.h" - -namespace { -} -using namespace mbed::Sockets::v0; - - -struct sockaddr_in; -struct lws; - -class lws_conn { - public: - lws_conn(): - ts(NULL), - wsi(NULL), - writeable(1), - awaiting_on_writeable(0) - { - } - -public: - void set_wsi(struct lws *_wsi) { wsi = _wsi; } - int actual_onRX(Socket *s); - void onRX(Socket *s); - void onError(Socket *s, socket_error_t err); - void onDisconnect(TCPStream *s); - void onSent(Socket *s, uint16_t len); - void serialized_writeable(struct lws *wsi); - -public: - TCPStream *ts; - -public: - struct lws *wsi; - char writeable; - char awaiting_on_writeable; -}; - -class lws_conn_listener : lws_conn { -public: - lws_conn_listener(): - srv(SOCKET_STACK_LWIP_IPV4) - { - srv.setOnError(TCPStream::ErrorHandler_t(this, - &lws_conn_listener::onError)); - } - - void start(const uint16_t port); /**< start listening */ - -protected: - void onRX(Socket *s); /**< incoming data ready */ - void onError(Socket *s, socket_error_t err); /**< if error occurs */ - void onIncoming(TCPListener *s, void *impl); /**< new connection */ - void onDisconnect(TCPStream *s); /**< disconnection */ - -public: - TCPListener srv; -}; - -#endif - -extern "C" { -#else -#include <stdarg.h> -#endif - -#if defined(MBED_OPERATORS) || defined(LWS_WITH_ESP8266) -struct sockaddr_in; -#define LWS_POSIX 0 -#else -#define LWS_POSIX 1 -#endif - -#include "lws_config.h" - -#if defined(WIN32) || defined(_WIN32) -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN -#endif - -#include <winsock2.h> -#include <ws2tcpip.h> -#include <stddef.h> -#include <basetsd.h> -#ifndef _WIN32_WCE -#include <fcntl.h> -#else -#define _O_RDONLY 0x0000 -#define O_RDONLY _O_RDONLY -#endif - -// Visual studio older than 2015 and WIN_CE has only _stricmp -#if (defined(_MSC_VER) && _MSC_VER < 1900) || defined(_WIN32_WCE) -#define strcasecmp _stricmp -#else -#define strcasecmp stricmp -#endif -#define getdtablesize() 30000 - -#define LWS_INLINE __inline -#define LWS_VISIBLE -#define LWS_WARN_UNUSED_RESULT -#define LWS_WARN_DEPRECATED - -#ifdef LWS_DLL -#ifdef LWS_INTERNAL -#define LWS_EXTERN extern __declspec(dllexport) -#else -#define LWS_EXTERN extern __declspec(dllimport) -#endif -#else -#define LWS_EXTERN -#endif - -#define LWS_INVALID_FILE INVALID_HANDLE_VALUE -#define LWS_O_RDONLY _O_RDONLY - -#if !defined(_MSC_VER) || _MSC_VER < 1900 /* Visual Studio 2015 already defines this in <stdio.h> */ -#define lws_snprintf _snprintf -#endif - -#ifndef __func__ -#define __func__ __FUNCTION__ -#endif - -#else /* NOT WIN32 */ -#include <unistd.h> - -#if defined(__NetBSD__) || defined(__FreeBSD__) -#include <netinet/in.h> -#endif - -#define LWS_INLINE inline -#define LWS_O_RDONLY O_RDONLY - -#if !defined(MBED_OPERATORS) && !defined(LWS_WITH_ESP8266) -#include <poll.h> -#include <netdb.h> -#define LWS_INVALID_FILE -1 -#else -#define getdtablesize() (20) -#define LWS_INVALID_FILE NULL -#endif - -#if defined(__GNUC__) - -/* warn_unused_result attribute only supported by GCC 3.4 or later */ -#if __GNUC__ >= 4 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -#define LWS_WARN_UNUSED_RESULT __attribute__((warn_unused_result)) -#else -#define LWS_WARN_UNUSED_RESULT -#endif - -#define LWS_VISIBLE __attribute__((visibility("default"))) -#define LWS_WARN_DEPRECATED __attribute__ ((deprecated)) -#else -#define LWS_VISIBLE -#define LWS_WARN_UNUSED_RESULT -#define LWS_WARN_DEPRECATED -#endif - -#if defined(__ANDROID__) -#include <unistd.h> -#define getdtablesize() sysconf(_SC_OPEN_MAX) -#endif - -#endif - -#ifdef LWS_USE_LIBEV -#include <ev.h> -#endif /* LWS_USE_LIBEV */ -#ifdef LWS_USE_LIBUV -#include <uv.h> -#ifdef LWS_HAVE_UV_VERSION_H -#include <uv-version.h> -#endif -#endif /* LWS_USE_LIBUV */ - -#ifndef LWS_EXTERN -#define LWS_EXTERN extern -#endif - -#ifdef _WIN32 -#define random rand -#else -#include <sys/time.h> -#include <unistd.h> -#endif - -#ifdef LWS_OPENSSL_SUPPORT - -#ifdef USE_WOLFSSL -#ifdef USE_OLD_CYASSL -#include <cyassl/openssl/ssl.h> -#include <cyassl/error-ssl.h> -#else -#include <wolfssl/openssl/ssl.h> -#include <wolfssl/error-ssl.h> -#endif /* not USE_OLD_CYASSL */ -#else -#if defined(LWS_USE_POLARSSL) -#include <polarssl/ssl.h> -struct lws_polarssl_context { - x509_crt ca; /**< ca */ - x509_crt certificate; /**< cert */ - rsa_context key; /**< key */ -}; -typedef struct lws_polarssl_context SSL_CTX; -typedef ssl_context SSL; -#else -#if defined(LWS_USE_MBEDTLS) -#include <mbedtls/ssl.h> -#else -#include <openssl/ssl.h> -#include <openssl/err.h> -#endif /* not USE_MBEDTLS */ -#endif /* not USE_POLARSSL */ -#endif /* not USE_WOLFSSL */ -#endif - - -#define CONTEXT_PORT_NO_LISTEN -1 - -/** \defgroup log Logging - * - * ##Logging - * - * Lws provides flexible and filterable logging facilities, which can be - * used inside lws and in user code. - * - * Log categories may be individually filtered bitwise, and directed to built-in - * sinks for syslog-compatible logging, or a user-defined function. - */ -///@{ - -enum lws_log_levels { - LLL_ERR = 1 << 0, - LLL_WARN = 1 << 1, - LLL_NOTICE = 1 << 2, - LLL_INFO = 1 << 3, - LLL_DEBUG = 1 << 4, - LLL_PARSER = 1 << 5, - LLL_HEADER = 1 << 6, - LLL_EXT = 1 << 7, - LLL_CLIENT = 1 << 8, - LLL_LATENCY = 1 << 9, - - LLL_COUNT = 10 /* set to count of valid flags */ -}; - -LWS_VISIBLE LWS_EXTERN void _lws_log(int filter, const char *format, ...); -LWS_VISIBLE LWS_EXTERN void _lws_logv(int filter, const char *format, va_list vl); -/** - * lwsl_timestamp: generate logging timestamp string - * - * \param level: logging level - * \param p: char * buffer to take timestamp - * \param len: length of p - * - * returns length written in p - */ -LWS_VISIBLE LWS_EXTERN int -lwsl_timestamp(int level, char *p, int len); - -#define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__) - -#if !defined(LWS_WITH_NO_LOGS) -/* notice, warn and log are always compiled in */ -#define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__) -#define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__) -#endif -/* - * weaker logging can be deselected at configure time using --disable-debug - * that gets rid of the overhead of checking while keeping _warn and _err - * active - */ - -#if defined(LWS_WITH_ESP8266) -#undef _DEBUG -#endif - -#ifdef _DEBUG -#if defined(LWS_WITH_NO_LOGS) -/* notice, warn and log are always compiled in */ -//#define lwsl_err(...) _lws_log(LLL_ERR, __VA_ARGS__) -#define lwsl_warn(...) _lws_log(LLL_WARN, __VA_ARGS__) -#define lwsl_notice(...) _lws_log(LLL_NOTICE, __VA_ARGS__) -#endif -#define lwsl_info(...) _lws_log(LLL_INFO, __VA_ARGS__) -#define lwsl_debug(...) _lws_log(LLL_DEBUG, __VA_ARGS__) -#define lwsl_parser(...) _lws_log(LLL_PARSER, __VA_ARGS__) -#define lwsl_header(...) _lws_log(LLL_HEADER, __VA_ARGS__) -#define lwsl_ext(...) _lws_log(LLL_EXT, __VA_ARGS__) -#define lwsl_client(...) _lws_log(LLL_CLIENT, __VA_ARGS__) -#define lwsl_latency(...) _lws_log(LLL_LATENCY, __VA_ARGS__) -/** - * lwsl_hexdump() - helper to hexdump a buffer (DEBUG builds only) - * - * \param buf: buffer start to dump - * \param len: length of buffer to dump - */ -LWS_VISIBLE LWS_EXTERN void lwsl_hexdump(void *buf, size_t len); - -#else /* no debug */ -#if defined(LWS_WITH_NO_LOGS) -//#define lwsl_err(...) do {} while(0) -#define lwsl_warn(...) do {} while(0) -#define lwsl_notice(...) do {} while(0) -#endif -#define lwsl_info(...) do {} while(0) -#define lwsl_debug(...) do {} while(0) -#define lwsl_parser(...) do {} while(0) -#define lwsl_header(...) do {} while(0) -#define lwsl_ext(...) do {} while(0) -#define lwsl_client(...) do {} while(0) -#define lwsl_latency(...) do {} while(0) -#define lwsl_hexdump(a, b) - -#endif - -/** - * lws_set_log_level() - Set the logging bitfield - * \param level: OR together the LLL_ debug contexts you want output from - * \param log_emit_function: NULL to leave it as it is, or a user-supplied - * function to perform log string emission instead of - * the default stderr one. - * - * log level defaults to "err", "warn" and "notice" contexts enabled and - * emission on stderr. - */ -LWS_VISIBLE LWS_EXTERN void -lws_set_log_level(int level, - void (*log_emit_function)(int level, const char *line)); - -/** - * lwsl_emit_syslog() - helper log emit function writes to system log - * - * \param level: one of LLL_ log level indexes - * \param line: log string - * - * You use this by passing the function pointer to lws_set_log_level(), to set - * it as the log emit function, it is not called directly. - */ -LWS_VISIBLE LWS_EXTERN void -lwsl_emit_syslog(int level, const char *line); - -///@} - - -#include <stddef.h> - -#ifndef lws_container_of -#define lws_container_of(P,T,M) ((T *)((char *)(P) - offsetof(T, M))) -#endif - - -struct lws; -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) -#endif - -/* api change list for user code to test against */ - -#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_ARG - -/* the struct lws_protocols has the id field present */ -#define LWS_FEATURE_PROTOCOLS_HAS_ID_FIELD - -/* you can call lws_get_peer_write_allowance */ -#define LWS_FEATURE_PROTOCOLS_HAS_PEER_WRITE_ALLOWANCE - -/* extra parameter introduced in 917f43ab821 */ -#define LWS_FEATURE_SERVE_HTTP_FILE_HAS_OTHER_HEADERS_LEN - -/* File operations stuff exists */ -#define LWS_FEATURE_FOPS - - -#if defined(_WIN32) -typedef SOCKET lws_sockfd_type; -typedef HANDLE lws_filefd_type; -#define lws_sockfd_valid(sfd) (!!sfd) -struct lws_pollfd { - lws_sockfd_type fd; /**< file descriptor */ - SHORT events; /**< which events to respond to */ - SHORT revents; /**< which events happened */ -}; -#define LWS_POLLHUP (FD_CLOSE) -#define LWS_POLLIN (FD_READ | FD_ACCEPT) -#define LWS_POLLOUT (FD_WRITE) -#else - -#if defined(MBED_OPERATORS) -/* it's a class lws_conn * */ -typedef void * lws_sockfd_type; -typedef void * lws_filefd_type; -#define lws_sockfd_valid(sfd) (!!sfd) -struct pollfd { - lws_sockfd_type fd; /**< fd related to */ - short events; /**< which POLL... events to respond to */ - short revents; /**< which POLL... events occurred */ -}; -#define POLLIN 0x0001 -#define POLLPRI 0x0002 -#define POLLOUT 0x0004 -#define POLLERR 0x0008 -#define POLLHUP 0x0010 -#define POLLNVAL 0x0020 - -struct lws; - -void * mbed3_create_tcp_stream_socket(void); -void mbed3_delete_tcp_stream_socket(void *sockfd); -void mbed3_tcp_stream_bind(void *sock, int port, struct lws *); -void mbed3_tcp_stream_accept(void *sock, struct lws *); -#else -#if defined(LWS_WITH_ESP8266) - -#include <user_interface.h> -#include <espconn.h> - -typedef struct espconn * lws_sockfd_type; -typedef void * lws_filefd_type; -#define lws_sockfd_valid(sfd) (!!sfd) -struct pollfd { - lws_sockfd_type fd; /**< fd related to */ - short events; /**< which POLL... events to respond to */ - short revents; /**< which POLL... events occurred */ -}; -#define POLLIN 0x0001 -#define POLLPRI 0x0002 -#define POLLOUT 0x0004 -#define POLLERR 0x0008 -#define POLLHUP 0x0010 -#define POLLNVAL 0x0020 - -struct lws_vhost; - -lws_sockfd_type esp8266_create_tcp_listen_socket(struct lws_vhost *vh); -void esp8266_tcp_stream_accept(lws_sockfd_type fd, struct lws *wsi); - -#include <os_type.h> -#include <osapi.h> -#include "ets_sys.h" - -int ets_snprintf(char *str, size_t size, const char *format, ...); -#define snprintf ets_snprintf - -typedef os_timer_t uv_timer_t; -typedef void uv_cb_t(uv_timer_t *); - -void os_timer_disarm(void *); -void os_timer_setfn(os_timer_t *, os_timer_func_t *, void *); - -void ets_timer_arm_new(os_timer_t *, int, int, int); - -//void os_timer_arm(os_timer_t *, int, int); - -#define UV_VERSION_MAJOR 1 - -#define lws_uv_getloop(a, b) (NULL) - -static inline void uv_timer_init(void *l, uv_timer_t *t) -{ - (void)l; - memset(t, 0, sizeof(*t)); - os_timer_disarm(t); -} - -static inline void uv_timer_start(uv_timer_t *t, uv_cb_t *cb, int first, int rep) -{ - os_timer_setfn(t, (os_timer_func_t *)cb, t); - /* ms, repeat */ - os_timer_arm(t, first, !!rep); -} - -static inline void uv_timer_stop(uv_timer_t *t) -{ - os_timer_disarm(t); -} - -#else -typedef int lws_sockfd_type; -typedef int lws_filefd_type; -#define lws_sockfd_valid(sfd) (sfd >= 0) -#endif -#endif - -#define lws_pollfd pollfd -#define LWS_POLLHUP (POLLHUP|POLLERR) -#define LWS_POLLIN (POLLIN) -#define LWS_POLLOUT (POLLOUT) -#endif - -/** struct lws_pollargs - argument structure for all external poll related calls - * passed in via 'in' */ -struct lws_pollargs { - lws_sockfd_type fd; /**< applicable socket descriptor */ - int events; /**< the new event mask */ - int prev_events; /**< the previous event mask */ -}; - -struct lws_tokens; -struct lws_token_limits; - -/*! \defgroup wsclose Websocket Close - * - * ##Websocket close frame control - * - * When we close a ws connection, we can send a reason code and a short - * UTF-8 description back with the close packet. - */ -///@{ - -/* - * NOTE: These public enums are part of the abi. If you want to add one, - * add it at where specified so existing users are unaffected. - */ -/** enum lws_close_status - RFC6455 close status codes */ -enum lws_close_status { - LWS_CLOSE_STATUS_NOSTATUS = 0, - LWS_CLOSE_STATUS_NORMAL = 1000, - /**< 1000 indicates a normal closure, meaning that the purpose for - which the connection was established has been fulfilled. */ - LWS_CLOSE_STATUS_GOINGAWAY = 1001, - /**< 1001 indicates that an endpoint is "going away", such as a server - going down or a browser having navigated away from a page. */ - LWS_CLOSE_STATUS_PROTOCOL_ERR = 1002, - /**< 1002 indicates that an endpoint is terminating the connection due - to a protocol error. */ - LWS_CLOSE_STATUS_UNACCEPTABLE_OPCODE = 1003, - /**< 1003 indicates that an endpoint is terminating the connection - because it has received a type of data it cannot accept (e.g., an - endpoint that understands only text data MAY send this if it - receives a binary message). */ - LWS_CLOSE_STATUS_RESERVED = 1004, - /**< Reserved. The specific meaning might be defined in the future. */ - LWS_CLOSE_STATUS_NO_STATUS = 1005, - /**< 1005 is a reserved value and MUST NOT be set as a status code in a - Close control frame by an endpoint. It is designated for use in - applications expecting a status code to indicate that no status - code was actually present. */ - LWS_CLOSE_STATUS_ABNORMAL_CLOSE = 1006, - /**< 1006 is a reserved value and MUST NOT be set as a status code in a - Close control frame by an endpoint. It is designated for use in - applications expecting a status code to indicate that the - connection was closed abnormally, e.g., without sending or - receiving a Close control frame. */ - LWS_CLOSE_STATUS_INVALID_PAYLOAD = 1007, - /**< 1007 indicates that an endpoint is terminating the connection - because it has received data within a message that was not - consistent with the type of the message (e.g., non-UTF-8 [RFC3629] - data within a text message). */ - LWS_CLOSE_STATUS_POLICY_VIOLATION = 1008, - /**< 1008 indicates that an endpoint is terminating the connection - because it has received a message that violates its policy. This - is a generic status code that can be returned when there is no - other more suitable status code (e.g., 1003 or 1009) or if there - is a need to hide specific details about the policy. */ - LWS_CLOSE_STATUS_MESSAGE_TOO_LARGE = 1009, - /**< 1009 indicates that an endpoint is terminating the connection - because it has received a message that is too big for it to - process. */ - LWS_CLOSE_STATUS_EXTENSION_REQUIRED = 1010, - /**< 1010 indicates that an endpoint (client) is terminating the - connection because it has expected the server to negotiate one or - more extension, but the server didn't return them in the response - message of the WebSocket handshake. The list of extensions that - are needed SHOULD appear in the /reason/ part of the Close frame. - Note that this status code is not used by the server, because it - can fail the WebSocket handshake instead */ - LWS_CLOSE_STATUS_UNEXPECTED_CONDITION = 1011, - /**< 1011 indicates that a server is terminating the connection because - it encountered an unexpected condition that prevented it from - fulfilling the request. */ - LWS_CLOSE_STATUS_TLS_FAILURE = 1015, - /**< 1015 is a reserved value and MUST NOT be set as a status code in a - Close control frame by an endpoint. It is designated for use in - applications expecting a status code to indicate that the - connection was closed due to a failure to perform a TLS handshake - (e.g., the server certificate can't be verified). */ - - /****** add new things just above ---^ ******/ - - LWS_CLOSE_STATUS_NOSTATUS_CONTEXT_DESTROY = 9999, -}; - -/** - * lws_close_reason - Set reason and aux data to send with Close packet - * If you are going to return nonzero from the callback - * requesting the connection to close, you can optionally - * call this to set the reason the peer will be told if - * possible. - * - * \param wsi: The websocket connection to set the close reason on - * \param status: A valid close status from websocket standard - * \param buf: NULL or buffer containing up to 124 bytes of auxiliary data - * \param len: Length of data in \param buf to send - */ -LWS_VISIBLE LWS_EXTERN void -lws_close_reason(struct lws *wsi, enum lws_close_status status, - unsigned char *buf, size_t len); - -///@} - -struct lws; -struct lws_context; -/* needed even with extensions disabled for create context */ -struct lws_extension; - -/*! \defgroup usercb User Callback - * - * ##User protocol callback - * - * The protocol callback is the primary way lws interacts with - * user code. For one of a list of a few dozen reasons the callback gets - * called at some event to be handled. - * - * All of the events can be ignored, returning 0 is taken as "OK" and returning - * nonzero in most cases indicates that the connection should be closed. - */ -///@{ - - -/* - * NOTE: These public enums are part of the abi. If you want to add one, - * add it at where specified so existing users are unaffected. - */ -/** enum lws_callback_reasons - reason you're getting a protocol callback */ -enum lws_callback_reasons { - LWS_CALLBACK_ESTABLISHED = 0, - /**< (VH) after the server completes a handshake with an incoming - * client. If you built the library with ssl support, in is a - * pointer to the ssl struct associated with the connection or NULL.*/ - LWS_CALLBACK_CLIENT_CONNECTION_ERROR = 1, - /**< the request client connection has been unable to complete a - * handshake with the remote server. If in is non-NULL, you can - * find an error string of length len where it points to - * - * Diagnostic strings that may be returned include - * - * "getaddrinfo (ipv6) failed" - * "unknown address family" - * "getaddrinfo (ipv4) failed" - * "set socket opts failed" - * "insert wsi failed" - * "lws_ssl_client_connect1 failed" - * "lws_ssl_client_connect2 failed" - * "Peer hung up" - * "read failed" - * "HS: URI missing" - * "HS: Redirect code but no Location" - * "HS: URI did not parse" - * "HS: Redirect failed" - * "HS: Server did not return 200" - * "HS: OOM" - * "HS: disallowed by client filter" - * "HS: disallowed at ESTABLISHED" - * "HS: ACCEPT missing" - * "HS: ws upgrade response not 101" - * "HS: UPGRADE missing" - * "HS: Upgrade to something other than websocket" - * "HS: CONNECTION missing" - * "HS: UPGRADE malformed" - * "HS: PROTOCOL malformed" - * "HS: Cannot match protocol" - * "HS: EXT: list too big" - * "HS: EXT: failed setting defaults" - * "HS: EXT: failed parsing defaults" - * "HS: EXT: failed parsing options" - * "HS: EXT: Rejects server options" - * "HS: EXT: unknown ext" - * "HS: Accept hash wrong" - * "HS: Rejected by filter cb" - * "HS: OOM" - * "HS: SO_SNDBUF failed" - * "HS: Rejected at CLIENT_ESTABLISHED" - */ - LWS_CALLBACK_CLIENT_FILTER_PRE_ESTABLISH = 2, - /**< this is the last chance for the client user code to examine the - * http headers and decide to reject the connection. If the - * content in the headers is interesting to the - * client (url, etc) it needs to copy it out at - * this point since it will be destroyed before - * the CLIENT_ESTABLISHED call */ - LWS_CALLBACK_CLIENT_ESTABLISHED = 3, - /**< after your client connection completed - * a handshake with the remote server */ - LWS_CALLBACK_CLOSED = 4, - /**< when the websocket session ends */ - LWS_CALLBACK_CLOSED_HTTP = 5, - /**< when a HTTP (non-websocket) session ends */ - LWS_CALLBACK_RECEIVE = 6, - /**< data has appeared for this server endpoint from a - * remote client, it can be found at *in and is - * len bytes long */ - LWS_CALLBACK_RECEIVE_PONG = 7, - /**< servers receive PONG packets with this callback reason */ - LWS_CALLBACK_CLIENT_RECEIVE = 8, - /**< data has appeared from the server for the client connection, it - * can be found at *in and is len bytes long */ - LWS_CALLBACK_CLIENT_RECEIVE_PONG = 9, - /**< clients receive PONG packets with this callback reason */ - LWS_CALLBACK_CLIENT_WRITEABLE = 10, - /**< If you call lws_callback_on_writable() on a connection, you will - * get one of these callbacks coming when the connection socket - * is able to accept another write packet without blocking. - * If it already was able to take another packet without blocking, - * you'll get this callback at the next call to the service loop - * function. Notice that CLIENTs get LWS_CALLBACK_CLIENT_WRITEABLE - * and servers get LWS_CALLBACK_SERVER_WRITEABLE. */ - LWS_CALLBACK_SERVER_WRITEABLE = 11, - /**< See LWS_CALLBACK_CLIENT_WRITEABLE */ - LWS_CALLBACK_HTTP = 12, - /**< an http request has come from a client that is not - * asking to upgrade the connection to a websocket - * one. This is a chance to serve http content, - * for example, to send a script to the client - * which will then open the websockets connection. - * in points to the URI path requested and - * lws_serve_http_file() makes it very - * simple to send back a file to the client. - * Normally after sending the file you are done - * with the http connection, since the rest of the - * activity will come by websockets from the script - * that was delivered by http, so you will want to - * return 1; to close and free up the connection. */ - LWS_CALLBACK_HTTP_BODY = 13, - /**< the next len bytes data from the http - * request body HTTP connection is now available in in. */ - LWS_CALLBACK_HTTP_BODY_COMPLETION = 14, - /**< the expected amount of http request body has been delivered */ - LWS_CALLBACK_HTTP_FILE_COMPLETION = 15, - /**< a file requested to be sent down http link has completed. */ - LWS_CALLBACK_HTTP_WRITEABLE = 16, - /**< you can write more down the http protocol link now. */ - LWS_CALLBACK_FILTER_NETWORK_CONNECTION = 17, - /**< called when a client connects to - * the server at network level; the connection is accepted but then - * passed to this callback to decide whether to hang up immediately - * or not, based on the client IP. in contains the connection - * socket's descriptor. Since the client connection information is - * not available yet, wsi still pointing to the main server socket. - * Return non-zero to terminate the connection before sending or - * receiving anything. Because this happens immediately after the - * network connection from the client, there's no websocket protocol - * selected yet so this callback is issued only to protocol 0. */ - LWS_CALLBACK_FILTER_HTTP_CONNECTION = 18, - /**< called when the request has - * been received and parsed from the client, but the response is - * not sent yet. Return non-zero to disallow the connection. - * user is a pointer to the connection user space allocation, - * in is the URI, eg, "/" - * In your handler you can use the public APIs - * lws_hdr_total_length() / lws_hdr_copy() to access all of the - * headers using the header enums lws_token_indexes from - * libwebsockets.h to check for and read the supported header - * presence and content before deciding to allow the http - * connection to proceed or to kill the connection. */ - LWS_CALLBACK_SERVER_NEW_CLIENT_INSTANTIATED = 19, - /**< A new client just had - * been connected, accepted, and instantiated into the pool. This - * callback allows setting any relevant property to it. Because this - * happens immediately after the instantiation of a new client, - * there's no websocket protocol selected yet so this callback is - * issued only to protocol 0. Only wsi is defined, pointing to the - * new client, and the return value is ignored. */ - LWS_CALLBACK_FILTER_PROTOCOL_CONNECTION = 20, - /**< called when the handshake has - * been received and parsed from the client, but the response is - * not sent yet. Return non-zero to disallow the connection. - * user is a pointer to the connection user space allocation, - * in is the requested protocol name - * In your handler you can use the public APIs - * lws_hdr_total_length() / lws_hdr_copy() to access all of the - * headers using the header enums lws_token_indexes from - * libwebsockets.h to check for and read the supported header - * presence and content before deciding to allow the handshake - * to proceed or to kill the connection. */ - LWS_CALLBACK_OPENSSL_LOAD_EXTRA_CLIENT_VERIFY_CERTS = 21, - /**< if configured for - * including OpenSSL support, this callback allows your user code - * to perform extra SSL_CTX_load_verify_locations() or similar - * calls to direct OpenSSL where to find certificates the client - * can use to confirm the remote server identity. user is the - * OpenSSL SSL_CTX* */ - LWS_CALLBACK_OPENSSL_LOAD_EXTRA_SERVER_VERIFY_CERTS = 22, - /**< if configured for - * including OpenSSL support, this callback allows your user code - * to load extra certifcates into the server which allow it to - * verify the validity of certificates returned by clients. user - * is the server's OpenSSL SSL_CTX* */ - LWS_CALLBACK_OPENSSL_PERFORM_CLIENT_CERT_VERIFICATION = 23, - /**< if the libwebsockets vhost was created with the option - * LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT, then this - * callback is generated during OpenSSL verification of the cert - * sent from the client. It is sent to protocol[0] callback as - * no protocol has been negotiated on the connection yet. - * Notice that the libwebsockets context and wsi are both NULL - * during this callback. See - * http://www.openssl.org/docs/ssl/SSL_CTX_set_verify.html - * to understand more detail about the OpenSSL callback that - * generates this libwebsockets callback and the meanings of the - * arguments passed. In this callback, user is the x509_ctx, - * in is the ssl pointer and len is preverify_ok - * Notice that this callback maintains libwebsocket return - * conventions, return 0 to mean the cert is OK or 1 to fail it. - * This also means that if you don't handle this callback then - * the default callback action of returning 0 allows the client - * certificates. */ - LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER = 24, - /**< this callback happens - * when a client handshake is being compiled. user is NULL, - * in is a char **, it's pointing to a char * which holds the - * next location in the header buffer where you can add - * headers, and len is the remaining space in the header buffer, - * which is typically some hundreds of bytes. So, to add a canned - * cookie, your handler code might look similar to: - * - * char **p = (char **)in; - * - * if (len < 100) - * return 1; - * - * *p += sprintf(*p, "Cookie: a=b\x0d\x0a"); - * - * return 0; - * - * Notice if you add anything, you just have to take care about - * the CRLF on the line you added. Obviously this callback is - * optional, if you don't handle it everything is fine. - * - * Notice the callback is coming to protocols[0] all the time, - * because there is no specific protocol negotiated yet. */ - LWS_CALLBACK_CONFIRM_EXTENSION_OKAY = 25, - /**< When the server handshake code - * sees that it does support a requested extension, before - * accepting the extension by additing to the list sent back to - * the client it gives this callback just to check that it's okay - * to use that extension. It calls back to the requested protocol - * and with in being the extension name, len is 0 and user is - * valid. Note though at this time the ESTABLISHED callback hasn't - * happened yet so if you initialize user content there, user - * content during this callback might not be useful for anything. - * Notice this callback comes to protocols[0]. */ - LWS_CALLBACK_CLIENT_CONFIRM_EXTENSION_SUPPORTED = 26, - /**< When a client - * connection is being prepared to start a handshake to a server, - * each supported extension is checked with protocols[0] callback - * with this reason, giving the user code a chance to suppress the - * claim to support that extension by returning non-zero. If - * unhandled, by default 0 will be returned and the extension - * support included in the header to the server. Notice this - * callback comes to protocols[0]. */ - LWS_CALLBACK_PROTOCOL_INIT = 27, - /**< One-time call per protocol, per-vhost using it, so it can - * do initial setup / allocations etc */ - LWS_CALLBACK_PROTOCOL_DESTROY = 28, - /**< One-time call per protocol, per-vhost using it, indicating - * this protocol won't get used at all after this callback, the - * vhost is getting destroyed. Take the opportunity to - * deallocate everything that was allocated by the protocol. */ - LWS_CALLBACK_WSI_CREATE = 29, - /**< outermost (earliest) wsi create notification to protocols[0] */ - LWS_CALLBACK_WSI_DESTROY = 30, - /**< outermost (latest) wsi destroy notification to protocols[0] */ - LWS_CALLBACK_GET_THREAD_ID = 31, - /**< lws can accept callback when writable requests from other - * threads, if you implement this callback and return an opaque - * current thread ID integer. */ - - /* external poll() management support */ - LWS_CALLBACK_ADD_POLL_FD = 32, - /**< lws normally deals with its poll() or other event loop - * internally, but in the case you are integrating with another - * server you will need to have lws sockets share a - * polling array with the other server. This and the other - * POLL_FD related callbacks let you put your specialized - * poll array interface code in the callback for protocol 0, the - * first protocol you support, usually the HTTP protocol in the - * serving case. - * This callback happens when a socket needs to be - * added to the polling loop: in points to a struct - * lws_pollargs; the fd member of the struct is the file - * descriptor, and events contains the active events - * - * If you are using the internal lws polling / event loop - * you can just ignore these callbacks. */ - LWS_CALLBACK_DEL_POLL_FD = 33, - /**< This callback happens when a socket descriptor - * needs to be removed from an external polling array. in is - * again the struct lws_pollargs containing the fd member - * to be removed. If you are using the internal polling - * loop, you can just ignore it. */ - LWS_CALLBACK_CHANGE_MODE_POLL_FD = 34, - /**< This callback happens when lws wants to modify the events for - * a connection. - * in is the struct lws_pollargs with the fd to change. - * The new event mask is in events member and the old mask is in - * the prev_events member. - * If you are using the internal polling loop, you can just ignore - * it. */ - LWS_CALLBACK_LOCK_POLL = 35, - /**< These allow the external poll changes driven - * by lws to participate in an external thread locking - * scheme around the changes, so the whole thing is threadsafe. - * These are called around three activities in the library, - * - inserting a new wsi in the wsi / fd table (len=1) - * - deleting a wsi from the wsi / fd table (len=1) - * - changing a wsi's POLLIN/OUT state (len=0) - * Locking and unlocking external synchronization objects when - * len == 1 allows external threads to be synchronized against - * wsi lifecycle changes if it acquires the same lock for the - * duration of wsi dereference from the other thread context. */ - LWS_CALLBACK_UNLOCK_POLL = 36, - /**< See LWS_CALLBACK_LOCK_POLL, ignore if using lws internal poll */ - - LWS_CALLBACK_OPENSSL_CONTEXT_REQUIRES_PRIVATE_KEY = 37, - /**< if configured for including OpenSSL support but no private key - * file has been specified (ssl_private_key_filepath is NULL), this is - * called to allow the user to set the private key directly via - * libopenssl and perform further operations if required; this might be - * useful in situations where the private key is not directly accessible - * by the OS, for example if it is stored on a smartcard. - * user is the server's OpenSSL SSL_CTX* */ - LWS_CALLBACK_WS_PEER_INITIATED_CLOSE = 38, - /**< The peer has sent an unsolicited Close WS packet. in and - * len are the optional close code (first 2 bytes, network - * order) and the optional additional information which is not - * defined in the standard, and may be a string or non-human- readable data. - * If you return 0 lws will echo the close and then close the - * connection. If you return nonzero lws will just close the - * connection. */ - - LWS_CALLBACK_WS_EXT_DEFAULTS = 39, - /**< */ - - LWS_CALLBACK_CGI = 40, - /**< */ - LWS_CALLBACK_CGI_TERMINATED = 41, - /**< */ - LWS_CALLBACK_CGI_STDIN_DATA = 42, - /**< */ - LWS_CALLBACK_CGI_STDIN_COMPLETED = 43, - /**< */ - LWS_CALLBACK_ESTABLISHED_CLIENT_HTTP = 44, - /**< */ - LWS_CALLBACK_CLOSED_CLIENT_HTTP = 45, - /**< */ - LWS_CALLBACK_RECEIVE_CLIENT_HTTP = 46, - /**< */ - LWS_CALLBACK_COMPLETED_CLIENT_HTTP = 47, - /**< */ - LWS_CALLBACK_RECEIVE_CLIENT_HTTP_READ = 48, - /**< */ - LWS_CALLBACK_HTTP_BIND_PROTOCOL = 49, - /**< */ - LWS_CALLBACK_HTTP_DROP_PROTOCOL = 50, - /**< */ - LWS_CALLBACK_CHECK_ACCESS_RIGHTS = 51, - /**< */ - LWS_CALLBACK_PROCESS_HTML = 52, - /**< */ - LWS_CALLBACK_ADD_HEADERS = 53, - /**< */ - LWS_CALLBACK_SESSION_INFO = 54, - /**< */ - - LWS_CALLBACK_GS_EVENT = 55, - /**< */ - LWS_CALLBACK_HTTP_PMO = 56, - /**< per-mount options for this connection, called before - * the normal LWS_CALLBACK_HTTP when the mount has per-mount - * options - */ - LWS_CALLBACK_CLIENT_HTTP_WRITEABLE = 57, - /**< when doing an HTTP type client connection, you can call - * lws_client_http_body_pending(wsi, 1) from - * LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER to get these callbacks - * sending the HTTP headers. - * - * From this callback, when you have sent everything, you should let - * lws know by calling lws_client_http_body_pending(wsi, 0) - */ - - /****** add new things just above ---^ ******/ - - LWS_CALLBACK_USER = 1000, - /**< user code can use any including / above without fear of clashes */ -}; - - - -/** - * typedef lws_callback_function() - User server actions - * \param wsi: Opaque websocket instance pointer - * \param reason: The reason for the call - * \param user: Pointer to per-session user data allocated by library - * \param in: Pointer used for some callback reasons - * \param len: Length set for some callback reasons - * - * This callback is the way the user controls what is served. All the - * protocol detail is hidden and handled by the library. - * - * For each connection / session there is user data allocated that is - * pointed to by "user". You set the size of this user data area when - * the library is initialized with lws_create_server. - */ -typedef int -lws_callback_function(struct lws *wsi, enum lws_callback_reasons reason, - void *user, void *in, size_t len); -///@} - -/*! \defgroup extensions - * - * ##Extension releated functions - * - * Ws defines optional extensions, lws provides the ability to implement these - * in user code if so desired. - * - * We provide one extensions permessage-deflate. - */ -///@{ - -/* - * NOTE: These public enums are part of the abi. If you want to add one, - * add it at where specified so existing users are unaffected. - */ -enum lws_extension_callback_reasons { - LWS_EXT_CB_SERVER_CONTEXT_CONSTRUCT = 0, - LWS_EXT_CB_CLIENT_CONTEXT_CONSTRUCT = 1, - LWS_EXT_CB_SERVER_CONTEXT_DESTRUCT = 2, - LWS_EXT_CB_CLIENT_CONTEXT_DESTRUCT = 3, - LWS_EXT_CB_CONSTRUCT = 4, - LWS_EXT_CB_CLIENT_CONSTRUCT = 5, - LWS_EXT_CB_CHECK_OK_TO_REALLY_CLOSE = 6, - LWS_EXT_CB_CHECK_OK_TO_PROPOSE_EXTENSION = 7, - LWS_EXT_CB_DESTROY = 8, - LWS_EXT_CB_DESTROY_ANY_WSI_CLOSING = 9, - LWS_EXT_CB_ANY_WSI_ESTABLISHED = 10, - LWS_EXT_CB_PACKET_RX_PREPARSE = 11, - LWS_EXT_CB_PACKET_TX_PRESEND = 12, - LWS_EXT_CB_PACKET_TX_DO_SEND = 13, - LWS_EXT_CB_HANDSHAKE_REPLY_TX = 14, - LWS_EXT_CB_FLUSH_PENDING_TX = 15, - LWS_EXT_CB_EXTENDED_PAYLOAD_RX = 16, - LWS_EXT_CB_CAN_PROXY_CLIENT_CONNECTION = 17, - LWS_EXT_CB_1HZ = 18, - LWS_EXT_CB_REQUEST_ON_WRITEABLE = 19, - LWS_EXT_CB_IS_WRITEABLE = 20, - LWS_EXT_CB_PAYLOAD_TX = 21, - LWS_EXT_CB_PAYLOAD_RX = 22, - LWS_EXT_CB_OPTION_DEFAULT = 23, - LWS_EXT_CB_OPTION_SET = 24, - LWS_EXT_CB_OPTION_CONFIRM = 25, - LWS_EXT_CB_NAMED_OPTION_SET = 26, - - /****** add new things just above ---^ ******/ -}; - -/** enum lws_ext_options_types */ -enum lws_ext_options_types { - EXTARG_NONE, /**< does not take an argument */ - EXTARG_DEC, /**< requires a decimal argument */ - EXTARG_OPT_DEC /**< may have an optional decimal argument */ - - /* Add new things just above here ---^ - * This is part of the ABI, don't needlessly break compatibility */ -}; - -/** struct lws_ext_options - Option arguments to the extension. These are - * used in the negotiation at ws upgrade time. - * The helper function lws_ext_parse_options() - * uses these to generate callbacks */ -struct lws_ext_options { - const char *name; /**< Option name, eg, "server_no_context_takeover" */ - enum lws_ext_options_types type; /**< What kind of args the option can take */ - - /* Add new things just above here ---^ - * This is part of the ABI, don't needlessly break compatibility */ -}; - -/** struct lws_ext_option_arg */ -struct lws_ext_option_arg { - const char *option_name; /**< may be NULL, option_index used then */ - int option_index; /**< argument ordinal to use if option_name missing */ - const char *start; /**< value */ - int len; /**< length of value */ -}; - -/** - * typedef lws_extension_callback_function() - Hooks to allow extensions to operate - * \param context: Websockets context - * \param ext: This extension - * \param wsi: Opaque websocket instance pointer - * \param reason: The reason for the call - * \param user: Pointer to ptr to per-session user data allocated by library - * \param in: Pointer used for some callback reasons - * \param len: Length set for some callback reasons - * - * Each extension that is active on a particular connection receives - * callbacks during the connection lifetime to allow the extension to - * operate on websocket data and manage itself. - * - * Libwebsockets takes care of allocating and freeing "user" memory for - * each active extension on each connection. That is what is pointed to - * by the user parameter. - * - * LWS_EXT_CB_CONSTRUCT: called when the server has decided to - * select this extension from the list provided by the client, - * just before the server will send back the handshake accepting - * the connection with this extension active. This gives the - * extension a chance to initialize its connection context found - * in user. - * - * LWS_EXT_CB_CLIENT_CONSTRUCT: same as LWS_EXT_CB_CONSTRUCT - * but called when client is instantiating this extension. Some - * extensions will work the same on client and server side and then - * you can just merge handlers for both CONSTRUCTS. - * - * LWS_EXT_CB_DESTROY: called when the connection the extension was - * being used on is about to be closed and deallocated. It's the - * last chance for the extension to deallocate anything it has - * allocated in the user data (pointed to by user) before the - * user data is deleted. This same callback is used whether you - * are in client or server instantiation context. - * - * LWS_EXT_CB_PACKET_RX_PREPARSE: when this extension was active on - * a connection, and a packet of data arrived at the connection, - * it is passed to this callback to give the extension a chance to - * change the data, eg, decompress it. user is pointing to the - * extension's private connection context data, in is pointing - * to an lws_tokens struct, it consists of a char * pointer called - * token, and an int called token_len. At entry, these are - * set to point to the received buffer and set to the content - * length. If the extension will grow the content, it should use - * a new buffer allocated in its private user context data and - * set the pointed-to lws_tokens members to point to its buffer. - * - * LWS_EXT_CB_PACKET_TX_PRESEND: this works the same way as - * LWS_EXT_CB_PACKET_RX_PREPARSE above, except it gives the - * extension a chance to change websocket data just before it will - * be sent out. Using the same lws_token pointer scheme in in, - * the extension can change the buffer and the length to be - * transmitted how it likes. Again if it wants to grow the - * buffer safely, it should copy the data into its own buffer and - * set the lws_tokens token pointer to it. - * - * LWS_EXT_CB_ARGS_VALIDATE: - */ -typedef int -lws_extension_callback_function(struct lws_context *context, - const struct lws_extension *ext, struct lws *wsi, - enum lws_extension_callback_reasons reason, - void *user, void *in, size_t len); - -/** struct lws_extension - An extension we support */ -struct lws_extension { - const char *name; /**< Formal extension name, eg, "permessage-deflate" */ - lws_extension_callback_function *callback; /**< Service callback */ - const char *client_offer; /**< String containing exts and options client offers */ - - /* Add new things just above here ---^ - * This is part of the ABI, don't needlessly break compatibility */ -}; - -/** - * lws_set_extension_option(): set extension option if possible - * - * \param wsi: websocket connection - * \param ext_name: name of ext, like "permessage-deflate" - * \param opt_name: name of option, like "rx_buf_size" - * \param opt_val: value to set option to - */ -LWS_VISIBLE LWS_EXTERN int -lws_set_extension_option(struct lws *wsi, const char *ext_name, - const char *opt_name, const char *opt_val); - -#ifndef LWS_NO_EXTENSIONS -/* lws_get_internal_extensions() - DEPRECATED - * - * \Deprecated There is no longer a set internal extensions table. The table is provided - * by user code along with application-specific settings. See the test - * client and server for how to do. - */ -static LWS_INLINE LWS_WARN_DEPRECATED const struct lws_extension * -lws_get_internal_extensions() { return NULL; } - -/** - * lws_ext_parse_options() - deal with parsing negotiated extension options - * - * \param ext: related extension struct - * \param wsi: websocket connection - * \param ext_user: per-connection extension private data - * \param opts: list of supported options - * \param o: option string to parse - * \param len: length - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_ext_parse_options(const struct lws_extension *ext, struct lws *wsi, - void *ext_user, const struct lws_ext_options *opts, - const char *o, int len); -#endif - -/** lws_extension_callback_pm_deflate() - extension for RFC7692 - * - * \param context: lws context - * \param ext: related lws_extension struct - * \param wsi: websocket connection - * \param reason: incoming callback reason - * \param user: per-connection extension private data - * \param in: pointer parameter - * \param len: length parameter - * - * Built-in callback implementing RFC7692 permessage-deflate - */ -LWS_EXTERN -int lws_extension_callback_pm_deflate( - struct lws_context *context, const struct lws_extension *ext, - struct lws *wsi, enum lws_extension_callback_reasons reason, - void *user, void *in, size_t len); - -/* - * The internal exts are part of the public abi - * If we add more extensions, publish the callback here ------v - */ -///@} - -/*! \defgroup Protocols-and-Plugins Protocols and Plugins - * \ingroup lwsapi - * - * ##Protocol and protocol plugin -related apis - * - * Protocols bind ws protocol names to a custom callback specific to that - * protocol implementaion. - * - * A list of protocols can be passed in at context creation time, but it is - * also legal to leave that NULL and add the protocols and their callback code - * using plugins. - * - * Plugins are much preferable compared to cut and pasting code into an - * application each time, since they can be used standalone. - */ -///@{ -/** struct lws_protocols - List of protocols and handlers client or server - * supports. */ - -struct lws_protocols { - const char *name; - /**< Protocol name that must match the one given in the client - * Javascript new WebSocket(url, 'protocol') name. */ - lws_callback_function *callback; - /**< The service callback used for this protocol. It allows the - * service action for an entire protocol to be encapsulated in - * the protocol-specific callback */ - size_t per_session_data_size; - /**< Each new connection using this protocol gets - * this much memory allocated on connection establishment and - * freed on connection takedown. A pointer to this per-connection - * allocation is passed into the callback in the 'user' parameter */ - size_t rx_buffer_size; - /**< lws allocates this much space for rx data and informs callback - * when something came. Due to rx flow control, the callback may not - * be able to consume it all without having to return to the event - * loop. That is supported in lws. - * - * This also controls how much may be sent at once at the moment, - * although this is likely to change. - */ - unsigned int id; - /**< ignored by lws, but useful to contain user information bound - * to the selected protocol. For example if this protocol was - * called "myprotocol-v2", you might set id to 2, and the user - * code that acts differently according to the version can do so by - * switch (wsi->protocol->id), user code might use some bits as - * capability flags based on selected protocol version, etc. */ - void *user; /**< ignored by lws, but user code can pass a pointer - here it can later access from the protocol callback */ - - /* Add new things just above here ---^ - * This is part of the ABI, don't needlessly break compatibility */ -}; - -struct lws_vhost; - -/** - * lws_vhost_name_to_protocol() - get vhost's protocol object from its name - * - * \param vh: vhost to search - * \param name: protocol name - * - * Returns NULL or a pointer to the vhost's protocol of the requested name - */ -LWS_VISIBLE LWS_EXTERN const struct lws_protocols * -lws_vhost_name_to_protocol(struct lws_vhost *vh, const char *name); - -/** - * lws_get_protocol() - Returns a protocol pointer from a websocket - * connection. - * \param wsi: pointer to struct websocket you want to know the protocol of - * - * - * Some apis can act on all live connections of a given protocol, - * this is how you can get a pointer to the active protocol if needed. - */ -LWS_VISIBLE LWS_EXTERN const struct lws_protocols * -lws_get_protocol(struct lws *wsi); - -/** lws_protocol_get() - deprecated: use lws_get_protocol */ -LWS_VISIBLE LWS_EXTERN const struct lws_protocols * -lws_protocol_get(struct lws *wsi) LWS_WARN_DEPRECATED; - -/** - * lws_protocol_vh_priv_zalloc() - Allocate and zero down a protocol's per-vhost - * storage - * \param vhost: vhost the instance is related to - * \param prot: protocol the instance is related to - * \param size: bytes to allocate - * - * Protocols often find it useful to allocate a per-vhost struct, this is a - * helper to be called in the per-vhost init LWS_CALLBACK_PROTOCOL_INIT - */ -LWS_VISIBLE LWS_EXTERN void * -lws_protocol_vh_priv_zalloc(struct lws_vhost *vhost, const struct lws_protocols *prot, - int size); - -/** - * lws_protocol_vh_priv_get() - retreive a protocol's per-vhost storage - * - * \param vhost: vhost the instance is related to - * \param prot: protocol the instance is related to - * - * Recover a pointer to the allocated per-vhost storage for the protocol created - * by lws_protocol_vh_priv_zalloc() earlier - */ -LWS_VISIBLE LWS_EXTERN void * -lws_protocol_vh_priv_get(struct lws_vhost *vhost, const struct lws_protocols *prot); - -/** - * lws_finalize_startup() - drop initial process privileges - * - * \param context: lws context - * - * This is called after the end of the vhost protocol initializations, but - * you may choose to call it earlier - */ -LWS_VISIBLE LWS_EXTERN int -lws_finalize_startup(struct lws_context *context); - -#ifdef LWS_WITH_PLUGINS - -/* PLUGINS implies LIBUV */ - -#define LWS_PLUGIN_API_MAGIC 180 - -/** struct lws_plugin_capability - how a plugin introduces itself to lws */ -struct lws_plugin_capability { - unsigned int api_magic; /**< caller fills this in, plugin fills rest */ - const struct lws_protocols *protocols; /**< array of supported protocols provided by plugin */ - int count_protocols; /**< how many protocols */ - const struct lws_extension *extensions; /**< array of extensions provided by plugin */ - int count_extensions; /**< how many extensions */ -}; - -typedef int (*lws_plugin_init_func)(struct lws_context *, - struct lws_plugin_capability *); -typedef int (*lws_plugin_destroy_func)(struct lws_context *); - -/** struct lws_plugin */ -struct lws_plugin { - struct lws_plugin *list; /**< linked list */ -#if (UV_VERSION_MAJOR > 0) - uv_lib_t lib; /**< shared library pointer */ -#else - void *l; /**< so we can compile on ancient libuv */ -#endif - char name[64]; /**< name of the plugin */ - struct lws_plugin_capability caps; /**< plugin capabilities */ -}; - -#endif - -///@} - - -/*! \defgroup generic-sessions plugin: generic-sessions - * \ingroup Protocols-and-Plugins - * - * ##Plugin Generic-sessions related - * - * generic-sessions plugin provides a reusable, generic session and login / - * register / forgot password framework including email verification. - */ -///@{ - -#define LWSGS_EMAIL_CONTENT_SIZE 16384 -/**< Maximum size of email we might send */ - -/* SHA-1 binary and hexified versions */ -/** typedef struct lwsgw_hash_bin */ -typedef struct { unsigned char bin[20]; /**< binary representation of hash */} lwsgw_hash_bin; -/** typedef struct lwsgw_hash */ -typedef struct { char id[41]; /**< ascii hex representation of hash */ } lwsgw_hash; - -/** enum lwsgs_auth_bits */ -enum lwsgs_auth_bits { - LWSGS_AUTH_LOGGED_IN = 1, /**< user is logged in as somebody */ - LWSGS_AUTH_ADMIN = 2, /**< logged in as the admin user */ - LWSGS_AUTH_VERIFIED = 4, /**< user has verified his email */ - LWSGS_AUTH_FORGOT_FLOW = 8, /**< he just completed "forgot password" flow */ -}; - -/** struct lws_session_info - information about user session status */ -struct lws_session_info { - char username[32]; /**< username logged in as, or empty string */ - char email[100]; /**< email address associated with login, or empty string */ - char ip[72]; /**< ip address session was started from */ - unsigned int mask; /**< access rights mask associated with session - * see enum lwsgs_auth_bits */ - char session[42]; /**< session id string, usable as opaque uid when not logged in */ -}; - -/** enum lws_gs_event */ -enum lws_gs_event { - LWSGSE_CREATED, /**< a new user was created */ - LWSGSE_DELETED /**< an existing user was deleted */ -}; - -/** struct lws_gs_event_args */ -struct lws_gs_event_args { - enum lws_gs_event event; /**< which event happened */ - const char *username; /**< which username the event happened to */ - const char *email; /**< the email address of that user */ -}; - -///@} - - -/*! \defgroup context-and-vhost - * \ingroup lwsapi - * - * ##Context and Vhost releated functions - * - * LWS requires that there is one context, in which you may define multiple - * vhosts. Each vhost is a virtual host, with either its own listen port - * or sharing an existing one. Each vhost has its own SSL context that can - * be set up individually or left disabled. - * - * If you don't care about multiple "site" support, you can ignore it and - * lws will create a single default vhost at context creation time. - */ -///@{ - -/* - * NOTE: These public enums are part of the abi. If you want to add one, - * add it at where specified so existing users are unaffected. - */ - -/** enum lws_context_options - context and vhost options */ -enum lws_context_options { - LWS_SERVER_OPTION_REQUIRE_VALID_OPENSSL_CLIENT_CERT = (1 << 1) | - (1 << 12), - /**< (VH) Don't allow the connection unless the client has a - * client cert that we recognize; provides - * LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT */ - LWS_SERVER_OPTION_SKIP_SERVER_CANONICAL_NAME = (1 << 2), - /**< (CTX) Don't try to get the server's hostname */ - LWS_SERVER_OPTION_ALLOW_NON_SSL_ON_SSL_PORT = (1 << 3) | - (1 << 12), - /**< (VH) Allow non-SSL (plaintext) connections on the same - * port as SSL is listening... undermines the security of SSL; - * provides LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT */ - LWS_SERVER_OPTION_LIBEV = (1 << 4), - /**< (CTX) Use libev event loop */ - LWS_SERVER_OPTION_DISABLE_IPV6 = (1 << 5), - /**< (VH) Disable IPV6 support */ - LWS_SERVER_OPTION_DISABLE_OS_CA_CERTS = (1 << 6), - /**< (VH) Don't load OS CA certs, you will need to load your - * own CA cert(s) */ - LWS_SERVER_OPTION_PEER_CERT_NOT_REQUIRED = (1 << 7), - /**< (VH) Accept connections with no valid Cert (eg, selfsigned) */ - LWS_SERVER_OPTION_VALIDATE_UTF8 = (1 << 8), - /**< (VH) Check UT-8 correctness */ - LWS_SERVER_OPTION_SSL_ECDH = (1 << 9) | - (1 << 12), - /**< (VH) initialize ECDH ciphers */ - LWS_SERVER_OPTION_LIBUV = (1 << 10), - /**< (CTX) Use libuv event loop */ - LWS_SERVER_OPTION_REDIRECT_HTTP_TO_HTTPS = (1 << 11) | - (1 << 12), - /**< (VH) Use http redirect to force http to https - * (deprecated: use mount redirection) */ - LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT = (1 << 12), - /**< (CTX) Initialize the SSL library at all */ - LWS_SERVER_OPTION_EXPLICIT_VHOSTS = (1 << 13), - /**< (CTX) Only create the context when calling context - * create api, implies user code will create its own vhosts */ - LWS_SERVER_OPTION_UNIX_SOCK = (1 << 14), - /**< (VH) Use Unix socket */ - LWS_SERVER_OPTION_STS = (1 << 15), - /**< (VH) Send Strict Transport Security header, making - * clients subsequently go to https even if user asked for http */ - LWS_SERVER_OPTION_IPV6_V6ONLY_MODIFY = (1 << 16), - /**< (VH) Enable LWS_SERVER_OPTION_IPV6_V6ONLY_VALUE to take effect */ - LWS_SERVER_OPTION_IPV6_V6ONLY_VALUE = (1 << 17), - /**< (VH) if set, only ipv6 allowed on the vhost */ - LWS_SERVER_OPTION_UV_NO_SIGSEGV_SIGFPE_SPIN = (1 << 18), - /**< (CTX) Libuv only: Do not spin on SIGSEGV / SIGFPE. A segfault - * normally makes the lib spin so you can attach a debugger to it - * even if it happened without a debugger in place. You can disable - * that by giving this option. - */ - - /****** add new things just above ---^ ******/ -}; - -#define lws_check_opt(c, f) (((c) & (f)) == (f)) - -/** struct lws_context_creation_info - parameters to create context and /or vhost with - * - * This is also used to create vhosts.... if LWS_SERVER_OPTION_EXPLICIT_VHOSTS - * is not given, then for backwards compatibility one vhost is created at - * context-creation time using the info from this struct. - * - * If LWS_SERVER_OPTION_EXPLICIT_VHOSTS is given, then no vhosts are created - * at the same time as the context, they are expected to be created afterwards. - */ -struct lws_context_creation_info { - int port; - /**< VHOST: Port to listen on... you can use CONTEXT_PORT_NO_LISTEN to - * suppress listening on any port, that's what you want if you are - * not running a websocket server at all but just using it as a - * client */ - const char *iface; - /**< VHOST: NULL to bind the listen socket to all interfaces, or the - * interface name, eg, "eth2" - * If options specifies LWS_SERVER_OPTION_UNIX_SOCK, this member is - * the pathname of a UNIX domain socket. you can use the UNIX domain - * sockets in abstract namespace, by prepending an at symbol to the - * socket name. */ - const struct lws_protocols *protocols; - /**< VHOST: Array of structures listing supported protocols and a protocol- - * specific callback for each one. The list is ended with an - * entry that has a NULL callback pointer. */ - const struct lws_extension *extensions; - /**< VHOST: NULL or array of lws_extension structs listing the - * extensions this context supports. */ - const struct lws_token_limits *token_limits; - /**< CONTEXT: NULL or struct lws_token_limits pointer which is initialized - * with a token length limit for each possible WSI_TOKEN_ */ - const char *ssl_private_key_password; - /**< VHOST: NULL or the passphrase needed for the private key */ - const char *ssl_cert_filepath; - /**< VHOST: If libwebsockets was compiled to use ssl, and you want - * to listen using SSL, set to the filepath to fetch the - * server cert from, otherwise NULL for unencrypted */ - const char *ssl_private_key_filepath; - /**< VHOST: filepath to private key if wanting SSL mode; - * if this is set to NULL but sll_cert_filepath is set, the - * OPENSSL_CONTEXT_REQUIRES_PRIVATE_KEY callback is called - * to allow setting of the private key directly via openSSL - * library calls */ - const char *ssl_ca_filepath; - /**< VHOST: CA certificate filepath or NULL */ - const char *ssl_cipher_list; - /**< VHOST: List of valid ciphers to use (eg, - * "RC4-MD5:RC4-SHA:AES128-SHA:AES256-SHA:HIGH:!DSS:!aNULL" - * or you can leave it as NULL to get "DEFAULT" */ - const char *http_proxy_address; - /**< VHOST: If non-NULL, attempts to proxy via the given address. - * If proxy auth is required, use format "username:password\@server:port" */ - unsigned int http_proxy_port; - /**< VHOST: If http_proxy_address was non-NULL, uses this port */ - int gid; - /**< CONTEXT: group id to change to after setting listen socket, or -1. */ - int uid; - /**< CONTEXT: user id to change to after setting listen socket, or -1. */ - unsigned int options; - /**< VHOST + CONTEXT: 0, or LWS_SERVER_OPTION_... bitfields */ - void *user; - /**< CONTEXT: optional user pointer that can be recovered via the context - * pointer using lws_context_user */ - int ka_time; - /**< CONTEXT: 0 for no TCP keepalive, otherwise apply this keepalive - * timeout to all libwebsocket sockets, client or server */ - int ka_probes; - /**< CONTEXT: if ka_time was nonzero, after the timeout expires how many - * times to try to get a response from the peer before giving up - * and killing the connection */ - int ka_interval; - /**< CONTEXT: if ka_time was nonzero, how long to wait before each ka_probes - * attempt */ -#ifdef LWS_OPENSSL_SUPPORT - SSL_CTX *provided_client_ssl_ctx; - /**< CONTEXT: If non-null, swap out libwebsockets ssl - * implementation for the one provided by provided_ssl_ctx. - * Libwebsockets no longer is responsible for freeing the context - * if this option is selected. */ -#else /* maintain structure layout either way */ - void *provided_client_ssl_ctx; /**< dummy if ssl disabled */ -#endif - - short max_http_header_data; - /**< CONTEXT: The max amount of header payload that can be handled - * in an http request (unrecognized header payload is dropped) */ - short max_http_header_pool; - /**< CONTEXT: The max number of connections with http headers that - * can be processed simultaneously (the corresponding memory is - * allocated for the lifetime of the context). If the pool is - * busy new incoming connections must wait for accept until one - * becomes free. */ - - unsigned int count_threads; - /**< CONTEXT: how many contexts to create in an array, 0 = 1 */ - unsigned int fd_limit_per_thread; - /**< CONTEXT: nonzero means restrict each service thread to this - * many fds, 0 means the default which is divide the process fd - * limit by the number of threads. */ - unsigned int timeout_secs; - /**< VHOST: various processes involving network roundtrips in the - * library are protected from hanging forever by timeouts. If - * nonzero, this member lets you set the timeout used in seconds. - * Otherwise a default timeout is used. */ - const char *ecdh_curve; - /**< VHOST: if NULL, defaults to initializing server with "prime256v1" */ - const char *vhost_name; - /**< VHOST: name of vhost, must match external DNS name used to - * access the site, like "warmcat.com" as it's used to match - * Host: header and / or SNI name for SSL. */ - const char * const *plugin_dirs; - /**< CONTEXT: NULL, or NULL-terminated array of directories to - * scan for lws protocol plugins at context creation time */ - const struct lws_protocol_vhost_options *pvo; - /**< VHOST: pointer to optional linked list of per-vhost - * options made accessible to protocols */ - int keepalive_timeout; - /**< VHOST: (default = 0 = 60s) seconds to allow remote - * client to hold on to an idle HTTP/1.1 connection */ - const char *log_filepath; - /**< VHOST: filepath to append logs to... this is opened before - * any dropping of initial privileges */ - const struct lws_http_mount *mounts; - /**< VHOST: optional linked list of mounts for this vhost */ - const char *server_string; - /**< CONTEXT: string used in HTTP headers to identify server - * software, if NULL, "libwebsockets". */ - unsigned int pt_serv_buf_size; - /**< CONTEXT: 0 = default of 4096. This buffer is used by - * various service related features including file serving, it - * defines the max chunk of file that can be sent at once. - * At the risk of lws having to buffer failed large sends, it - * can be increased to, eg, 128KiB to improve throughput. */ - unsigned int max_http_header_data2; - /**< CONTEXT: if max_http_header_data is 0 and this - * is nonzero, this will be used in place of the default. It's - * like this for compatibility with the original short version, - * this is unsigned int length. */ - long ssl_options_set; - /**< VHOST: Any bits set here will be set as SSL options */ - long ssl_options_clear; - /**< VHOST: Any bits set here will be cleared as SSL options */ - unsigned short ws_ping_pong_interval; - /**< CONTEXT: 0 for none, else interval in seconds between sending - * PINGs on idle websocket connections. When the PING is sent, - * the PONG must come within the normal timeout_secs timeout period - * or the connection will be dropped. - * Any RX or TX traffic on the connection restarts the interval timer, - * so a connection which always sends or receives something at intervals - * less than the interval given here will never send PINGs / expect - * PONGs. Conversely as soon as the ws connection is established, an - * idle connection will do the PING / PONG roundtrip as soon as - * ws_ping_pong_interval seconds has passed without traffic - */ - const struct lws_protocol_vhost_options *headers; - /**< VHOST: pointer to optional linked list of per-vhost - * canned headers that are added to server responses */ - - /* Add new things just above here ---^ - * This is part of the ABI, don't needlessly break compatibility - * - * The below is to ensure later library versions with new - * members added above will see 0 (default) even if the app - * was not built against the newer headers. - */ - - void *_unused[8]; /**< dummy */ -}; - -/** - * lws_create_context() - Create the websocket handler - * \param info: pointer to struct with parameters - * - * This function creates the listening socket (if serving) and takes care - * of all initialization in one step. - * - * If option LWS_SERVER_OPTION_EXPLICIT_VHOSTS is given, no vhost is - * created; you're expected to create your own vhosts afterwards using - * lws_create_vhost(). Otherwise a vhost named "default" is also created - * using the information in the vhost-related members, for compatibility. - * - * After initialization, it returns a struct lws_context * that - * represents this server. After calling, user code needs to take care - * of calling lws_service() with the context pointer to get the - * server's sockets serviced. This must be done in the same process - * context as the initialization call. - * - * The protocol callback functions are called for a handful of events - * including http requests coming in, websocket connections becoming - * established, and data arriving; it's also called periodically to allow - * async transmission. - * - * HTTP requests are sent always to the FIRST protocol in protocol, since - * at that time websocket protocol has not been negotiated. Other - * protocols after the first one never see any HTTP callack activity. - * - * The server created is a simple http server by default; part of the - * websocket standard is upgrading this http connection to a websocket one. - * - * This allows the same server to provide files like scripts and favicon / - * images or whatever over http and dynamic data over websockets all in - * one place; they're all handled in the user callback. - */ -LWS_VISIBLE LWS_EXTERN struct lws_context * -lws_create_context(struct lws_context_creation_info *info); - -/** - * lws_context_destroy() - Destroy the websocket context - * \param context: Websocket context - * - * This function closes any active connections and then frees the - * context. After calling this, any further use of the context is - * undefined. - */ -LWS_VISIBLE LWS_EXTERN void -lws_context_destroy(struct lws_context *context); - -/** - * lws_set_proxy() - Setups proxy to lws_context. - * \param vhost: pointer to struct lws_vhost you want set proxy for - * \param proxy: pointer to c string containing proxy in format address:port - * - * Returns 0 if proxy string was parsed and proxy was setup. - * Returns -1 if proxy is NULL or has incorrect format. - * - * This is only required if your OS does not provide the http_proxy - * environment variable (eg, OSX) - * - * IMPORTANT! You should call this function right after creation of the - * lws_context and before call to connect. If you call this - * function after connect behavior is undefined. - * This function will override proxy settings made on lws_context - * creation with genenv() call. - */ -LWS_VISIBLE LWS_EXTERN int -lws_set_proxy(struct lws_vhost *vhost, const char *proxy); - - -struct lws_vhost; - -/** - * lws_create_vhost() - Create a vhost (virtual server context) - * \param context: pointer to result of lws_create_context() - * \param info: pointer to struct with parameters - * - * This function creates a virtual server (vhost) using the vhost-related - * members of the info struct. You can create many vhosts inside one context - * if you created the context with the option LWS_SERVER_OPTION_EXPLICIT_VHOSTS - */ -LWS_EXTERN LWS_VISIBLE struct lws_vhost * -lws_create_vhost(struct lws_context *context, - struct lws_context_creation_info *info); - -/** - * lwsws_get_config_globals() - Parse a JSON server config file - * \param info: pointer to struct with parameters - * \param d: filepath of the config file - * \param config_strings: storage for the config strings extracted from JSON, - * the pointer is incremented as strings are stored - * \param len: pointer to the remaining length left in config_strings - * the value is decremented as strings are stored - * - * This function prepares a n lws_context_creation_info struct with global - * settings from a file d. - * - * Requires CMake option LWS_WITH_LEJP_CONF to have been enabled - */ -LWS_VISIBLE LWS_EXTERN int -lwsws_get_config_globals(struct lws_context_creation_info *info, const char *d, - char **config_strings, int *len); - -/** - * lwsws_get_config_vhosts() - Create vhosts from a JSON server config file - * \param context: pointer to result of lws_create_context() - * \param info: pointer to struct with parameters - * \param d: filepath of the config file - * \param config_strings: storage for the config strings extracted from JSON, - * the pointer is incremented as strings are stored - * \param len: pointer to the remaining length left in config_strings - * the value is decremented as strings are stored - * - * This function creates vhosts into a context according to the settings in - *JSON files found in directory d. - * - * Requires CMake option LWS_WITH_LEJP_CONF to have been enabled - */ -LWS_VISIBLE LWS_EXTERN int -lwsws_get_config_vhosts(struct lws_context *context, - struct lws_context_creation_info *info, const char *d, - char **config_strings, int *len); - -/** lws_vhost_get() - \deprecated deprecated: use lws_get_vhost() */ -LWS_VISIBLE LWS_EXTERN struct lws_vhost * -lws_vhost_get(struct lws *wsi) LWS_WARN_DEPRECATED; - -/** - * lws_get_vhost() - return the vhost a wsi belongs to - * - * \param wsi: which connection - */ -LWS_VISIBLE LWS_EXTERN struct lws_vhost * -lws_get_vhost(struct lws *wsi); - -/** - * lws_json_dump_vhost() - describe vhost state and stats in JSON - * - * \param vh: the vhost - * \param buf: buffer to fill with JSON - * \param len: max length of buf - */ -LWS_VISIBLE LWS_EXTERN int -lws_json_dump_vhost(const struct lws_vhost *vh, char *buf, int len); - -/** - * lws_json_dump_context() - describe context state and stats in JSON - * - * \param context: the context - * \param buf: buffer to fill with JSON - * \param len: max length of buf - */ -LWS_VISIBLE LWS_EXTERN int -lws_json_dump_context(const struct lws_context *context, char *buf, int len); - -/** - * lws_context_user() - get the user data associated with the context - * \param context: Websocket context - * - * This returns the optional user allocation that can be attached to - * the context the sockets live in at context_create time. It's a way - * to let all sockets serviced in the same context share data without - * using globals statics in the user code. - */ -LWS_VISIBLE LWS_EXTERN void * -lws_context_user(struct lws_context *context); - -/*! \defgroup vhost-mounts Vhost mounts and options - * \ingroup context-and-vhost-creation - * - * ##Vhost mounts and options - */ -///@{ -/** struct lws_protocol_vhost_options - linked list of per-vhost protocol - * name=value options - * - * This provides a general way to attach a linked-list of name=value pairs, - * which can also have an optional child link-list using the options member. - */ -struct lws_protocol_vhost_options { - const struct lws_protocol_vhost_options *next; /**< linked list */ - const struct lws_protocol_vhost_options *options; /**< child linked-list of more options for this node */ - const char *name; /**< name of name=value pair */ - const char *value; /**< value of name=value pair */ -}; - -/** enum lws_mount_protocols - * This specifies the mount protocol for a mountpoint, whether it is to be - * served from a filesystem, or it is a cgi etc. - */ -enum lws_mount_protocols { - LWSMPRO_HTTP = 0, /**< not supported yet */ - LWSMPRO_HTTPS = 1, /**< not supported yet */ - LWSMPRO_FILE = 2, /**< serve from filesystem directory */ - LWSMPRO_CGI = 3, /**< pass to CGI to handle */ - LWSMPRO_REDIR_HTTP = 4, /**< redirect to http:// url */ - LWSMPRO_REDIR_HTTPS = 5, /**< redirect to https:// url */ - LWSMPRO_CALLBACK = 6, /**< hand by named protocol's callback */ -}; - -/** struct lws_http_mount - * - * arguments for mounting something in a vhost's url namespace - */ -struct lws_http_mount { - const struct lws_http_mount *mount_next; - /**< pointer to next struct lws_http_mount */ - const char *mountpoint; - /**< mountpoint in http pathspace, eg, "/" */ - const char *origin; - /**< path to be mounted, eg, "/var/www/warmcat.com" */ - const char *def; - /**< default target, eg, "index.html" */ - const char *protocol; - /**<"protocol-name" to handle mount */ - - const struct lws_protocol_vhost_options *cgienv; - /**< optional linked-list of cgi options. These are created - * as environment variables for the cgi process - */ - const struct lws_protocol_vhost_options *extra_mimetypes; - /**< optional linked-list of mimetype mappings */ - const struct lws_protocol_vhost_options *interpret; - /**< optional linked-list of files to be interpreted */ - - int cgi_timeout; - /**< seconds cgi is allowed to live, if cgi://mount type */ - int cache_max_age; - /**< max-age for reuse of client cache of files, seconds */ - unsigned int auth_mask; - /**< bits set here must be set for authorized client session */ - - unsigned int cache_reusable:1; /**< set if client cache may reuse this */ - unsigned int cache_revalidate:1; /**< set if client cache should revalidate on use */ - unsigned int cache_intermediaries:1; /**< set if intermediaries are allowed to cache */ - - unsigned char origin_protocol; /**< one of enum lws_mount_protocols */ - unsigned char mountpoint_len; /**< length of mountpoint string */ -}; -///@} -///@} - -/*! \defgroup client - * \ingroup lwsapi - * - * ##Client releated functions - * */ -///@{ - -/** enum lws_client_connect_ssl_connection_flags - flags that may be used - * with struct lws_client_connect_info ssl_connection member to control if - * and how SSL checks apply to the client connection being created - */ - -enum lws_client_connect_ssl_connection_flags { - LCCSCF_USE_SSL = (1 << 0), - LCCSCF_ALLOW_SELFSIGNED = (1 << 1), - LCCSCF_SKIP_SERVER_CERT_HOSTNAME_CHECK = (1 << 2) -}; - -/** struct lws_client_connect_info - parameters to connect with when using - * lws_client_connect_via_info() */ - -struct lws_client_connect_info { - struct lws_context *context; - /**< lws context to create connection in */ - const char *address; - /**< remote address to connect to */ - int port; - /**< remote port to connect to */ - int ssl_connection; - /**< nonzero for ssl */ - const char *path; - /**< uri path */ - const char *host; - /**< content of host header */ - const char *origin; - /**< content of origin header */ - const char *protocol; - /**< list of ws protocols we could accept */ - int ietf_version_or_minus_one; - /**< deprecated: currently leave at 0 or -1 */ - void *userdata; - /**< if non-NULL, use this as wsi user_data instead of malloc it */ - const struct lws_extension *client_exts; - /**< array of extensions that may be used on connection */ - const char *method; - /**< if non-NULL, do this http method instead of ws[s] upgrade. - * use "GET" to be a simple http client connection */ - struct lws *parent_wsi; - /**< if another wsi is responsible for this connection, give it here. - * this is used to make sure if the parent closes so do any - * child connections first. */ - const char *uri_replace_from; - /**< if non-NULL, when this string is found in URIs in - * text/html content-encoding, it's replaced with uri_replace_to */ - const char *uri_replace_to; - /**< see uri_replace_from */ - struct lws_vhost *vhost; - /**< vhost to bind to (used to determine related SSL_CTX) */ - struct lws **pwsi; - /**< if not NULL, store the new wsi here early in the connection - * process. Although we return the new wsi, the call to create the - * client connection does progress the connection somewhat and may - * meet an error that will result in the connection being scrubbed and - * NULL returned. While the wsi exists though, he may process a - * callback like CLIENT_CONNECTION_ERROR with his wsi: this gives the - * user callback a way to identify which wsi it is that faced the error - * even before the new wsi is returned and even if ultimately no wsi - * is returned. - */ - - /* Add new things just above here ---^ - * This is part of the ABI, don't needlessly break compatibility - * - * The below is to ensure later library versions with new - * members added above will see 0 (default) even if the app - * was not built against the newer headers. - */ - - void *_unused[4]; /**< dummy */ -}; - -/** - * lws_client_connect_via_info() - Connect to another websocket server - * \param ccinfo: pointer to lws_client_connect_info struct - * - * This function creates a connection to a remote server using the - * information provided in ccinfo. - */ -LWS_VISIBLE LWS_EXTERN struct lws * -lws_client_connect_via_info(struct lws_client_connect_info * ccinfo); - -/** - * lws_client_connect() - Connect to another websocket server - * \deprecated DEPRECATED use lws_client_connect_via_info - * \param clients: Websocket context - * \param address: Remote server address, eg, "myserver.com" - * \param port: Port to connect to on the remote server, eg, 80 - * \param ssl_connection: 0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self - * signed certs - * \param path: Websocket path on server - * \param host: Hostname on server - * \param origin: Socket origin name - * \param protocol: Comma-separated list of protocols being asked for from - * the server, or just one. The server will pick the one it - * likes best. If you don't want to specify a protocol, which is - * legal, use NULL here. - * \param ietf_version_or_minus_one: -1 to ask to connect using the default, latest - * protocol supported, or the specific protocol ordinal - * - * This function creates a connection to a remote server - */ -/* deprecated, use lws_client_connect_via_info() */ -LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT -lws_client_connect(struct lws_context *clients, const char *address, - int port, int ssl_connection, const char *path, - const char *host, const char *origin, const char *protocol, - int ietf_version_or_minus_one) LWS_WARN_DEPRECATED; -/* deprecated, use lws_client_connect_via_info() */ -/** - * lws_client_connect_extended() - Connect to another websocket server - * \deprecated DEPRECATED use lws_client_connect_via_info - * \param clients: Websocket context - * \param address: Remote server address, eg, "myserver.com" - * \param port: Port to connect to on the remote server, eg, 80 - * \param ssl_connection: 0 = ws://, 1 = wss:// encrypted, 2 = wss:// allow self - * signed certs - * \param path: Websocket path on server - * \param host: Hostname on server - * \param origin: Socket origin name - * \param protocol: Comma-separated list of protocols being asked for from - * the server, or just one. The server will pick the one it - * likes best. - * \param ietf_version_or_minus_one: -1 to ask to connect using the default, latest - * protocol supported, or the specific protocol ordinal - * \param userdata: Pre-allocated user data - * - * This function creates a connection to a remote server - */ -LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT -lws_client_connect_extended(struct lws_context *clients, const char *address, - int port, int ssl_connection, const char *path, - const char *host, const char *origin, - const char *protocol, int ietf_version_or_minus_one, - void *userdata) LWS_WARN_DEPRECATED; - -/** - * lws_init_vhost_client_ssl() - also enable client SSL on an existing vhost - * - * \param info: client ssl related info - * \param vhost: which vhost to initialize client ssl operations on - * - * You only need to call this if you plan on using SSL client connections on - * the vhost. For non-SSL client connections, it's not necessary to call this. - * - * The following members of info are used during the call - * - * - options must have LWS_SERVER_OPTION_DO_SSL_GLOBAL_INIT set, - * otherwise the call does nothing - * - provided_client_ssl_ctx must be NULL to get a generated client - * ssl context, otherwise you can pass a prepared one in by setting it - * - ssl_cipher_list may be NULL or set to the client valid cipher list - * - ssl_ca_filepath may be NULL or client cert filepath - * - ssl_cert_filepath may be NULL or client cert filepath - * - ssl_private_key_filepath may be NULL or client cert private key - * - * You must create your vhost explicitly if you want to use this, so you have - * a pointer to the vhost. Create the context first with the option flag - * LWS_SERVER_OPTION_EXPLICIT_VHOSTS and then call lws_create_vhost() with - * the same info struct. - */ -LWS_VISIBLE LWS_EXTERN int -lws_init_vhost_client_ssl(const struct lws_context_creation_info *info, - struct lws_vhost *vhost); - -LWS_VISIBLE LWS_EXTERN int -lws_http_client_read(struct lws *wsi, char **buf, int *len); - -LWS_VISIBLE LWS_EXTERN void -lws_client_http_body_pending(struct lws *wsi, int something_left_to_send); - -/** - * lws_client_http_body_pending() - control if client connection neeeds to send body - * - * \param wsi: client connection - * \param something_left_to_send: nonzero if need to send more body, 0 (default) - * if nothing more to send - * - * If you will send payload data with your HTTP client connection, eg, for POST, - * when you set the related http headers in - * LWS_CALLBACK_CLIENT_APPEND_HANDSHAKE_HEADER callback you should also call - * this API with something_left_to_send nonzero, and call - * lws_callback_on_writable(wsi); - * - * After sending the headers, lws will call your callback with - * LWS_CALLBACK_CLIENT_HTTP_WRITEABLE reason when writable. You can send the - * next part of the http body payload, calling lws_callback_on_writable(wsi); - * if there is more to come, or lws_client_http_body_pending(wsi, 0); to - * let lws know the last part is sent and the connection can move on. - */ - -///@} - -/** \defgroup service Built-in service loop entry - * - * ##Built-in service loop entry - * - * If you're not using libev / libuv, these apis are needed to enter the poll() - * wait in lws and service any connections with pending events. - */ -///@{ - -/** - * lws_service() - Service any pending websocket activity - * \param context: Websocket context - * \param timeout_ms: Timeout for poll; 0 means return immediately if nothing needed - * service otherwise block and service immediately, returning - * after the timeout if nothing needed service. - * - * This function deals with any pending websocket traffic, for three - * kinds of event. It handles these events on both server and client - * types of connection the same. - * - * 1) Accept new connections to our context's server - * - * 2) Call the receive callback for incoming frame data received by - * server or client connections. - * - * You need to call this service function periodically to all the above - * functions to happen; if your application is single-threaded you can - * just call it in your main event loop. - * - * Alternatively you can fork a new process that asynchronously handles - * calling this service in a loop. In that case you are happy if this - * call blocks your thread until it needs to take care of something and - * would call it with a large nonzero timeout. Your loop then takes no - * CPU while there is nothing happening. - * - * If you are calling it in a single-threaded app, you don't want it to - * wait around blocking other things in your loop from happening, so you - * would call it with a timeout_ms of 0, so it returns immediately if - * nothing is pending, or as soon as it services whatever was pending. - */ -LWS_VISIBLE LWS_EXTERN int -lws_service(struct lws_context *context, int timeout_ms); - -/** - * lws_service() - Service any pending websocket activity - * - * \param context: Websocket context - * \param timeout_ms: Timeout for poll; 0 means return immediately if nothing needed - * service otherwise block and service immediately, returning - * after the timeout if nothing needed service. - * - * Same as lws_service(), but for a specific thread service index. Only needed - * if you are spawning multiple service threads. - */ -LWS_VISIBLE LWS_EXTERN int -lws_service_tsi(struct lws_context *context, int timeout_ms, int tsi); - -/** - * lws_cancel_service_pt() - Cancel servicing of pending socket activity - * on one thread - * \param wsi: Cancel service on the thread this wsi is serviced by - * - * This function lets a call to lws_service() waiting for a timeout - * immediately return. - * - * It works by creating a phony event and then swallowing it silently. - * - * The reason it may be needed is when waiting in poll(), changes to - * the event masks are ignored by the OS until poll() is reentered. This - * lets you halt the poll() wait and make the reentry happen immediately - * instead of having the wait out the rest of the poll timeout. - */ -LWS_VISIBLE LWS_EXTERN void -lws_cancel_service_pt(struct lws *wsi); - -/** - * lws_cancel_service() - Cancel wait for new pending socket activity - * \param context: Websocket context - * - * This function let a call to lws_service() waiting for a timeout - * immediately return. - * - * What it basically does is provide a fake event that will be swallowed, - * so the wait in poll() is ended. That's useful because poll() doesn't - * attend to changes in POLLIN/OUT/ERR until it re-enters the wait. - */ -LWS_VISIBLE LWS_EXTERN void -lws_cancel_service(struct lws_context *context); - -/** - * lws_service_fd() - Service polled socket with something waiting - * \param context: Websocket context - * \param pollfd: The pollfd entry describing the socket fd and which events - * happened. - * - * This function takes a pollfd that has POLLIN or POLLOUT activity and - * services it according to the state of the associated - * struct lws. - * - * The one call deals with all "service" that might happen on a socket - * including listen accepts, http files as well as websocket protocol. - * - * If a pollfd says it has something, you can just pass it to - * lws_service_fd() whether it is a socket handled by lws or not. - * If it sees it is a lws socket, the traffic will be handled and - * pollfd->revents will be zeroed now. - * - * If the socket is foreign to lws, it leaves revents alone. So you can - * see if you should service yourself by checking the pollfd revents - * after letting lws try to service it. - */ -LWS_VISIBLE LWS_EXTERN int -lws_service_fd(struct lws_context *context, struct lws_pollfd *pollfd); - -/** - * lws_service_fd_tsi() - Service polled socket in specific service thread - * \param context: Websocket context - * \param pollfd: The pollfd entry describing the socket fd and which events - * happened. - * \param tsi: thread service index - * - * Same as lws_service_fd() but used with multiple service threads - */ -LWS_VISIBLE LWS_EXTERN int -lws_service_fd_tsi(struct lws_context *context, struct lws_pollfd *pollfd, - int tsi); - -/** - * lws_service_adjust_timeout() - Check for any connection needing forced service - * \param context: Websocket context - * \param timeout_ms: The original poll timeout value. You can just set this - * to 1 if you don't really have a poll timeout. - * \param tsi: thread service index - * - * Under some conditions connections may need service even though there is no - * pending network action on them, this is "forced service". For default - * poll() and libuv / libev, the library takes care of calling this and - * dealing with it for you. But for external poll() integration, you need - * access to the apis. - * - * If anybody needs "forced service", returned timeout is zero. In that case, - * you can call lws_plat_service_tsi() with a timeout of -1 to only service - * guys who need forced service. - */ -LWS_VISIBLE LWS_EXTERN int -lws_service_adjust_timeout(struct lws_context *context, int timeout_ms, int tsi); - -/** - * lws_plat_service_tsi() - Lowlevel platform-specific service api - * \param context: Websocket context - * \param timeout_ms: The original poll timeout value. You can just set this - * to 1 if you don't really have a poll timeout. - * \param tsi: thread service index - * - * For default poll() and libuv/ev, lws takes care of using this for you. and - * you can ignore it. - * - * But for external poll() integration, you need access to this api to service - * connections that need to be serviced but have no pending network activity. - * - * See lws_service_adjust_timeout() for more info. - */ -LWS_EXTERN LWS_VISIBLE int -lws_plat_service_tsi(struct lws_context *context, int timeout_ms, int tsi); - -///@} - -/*! \defgroup http HTTP - - Modules related to handling HTTP -*/ -//@{ - -/*! \defgroup httpft HTTP File transfer - * \ingroup http - - APIs for sending local files in response to HTTP requests -*/ -//@{ - -/** - * lws_get_mimetype() - Determine mimetype to use from filename - * - * \param file: filename - * \param m: NULL, or mount context - * - * This uses a canned list of known filetypes first, if no match and m is - * non-NULL, then tries a list of per-mount file suffix to mimtype mappings. - * - * Returns either NULL or a pointer to the mimetype matching the file. - */ -LWS_VISIBLE LWS_EXTERN const char * -lws_get_mimetype(const char *file, const struct lws_http_mount *m); - -/** - * lws_serve_http_file() - Send a file back to the client using http - * \param wsi: Websocket instance (available from user callback) - * \param file: The file to issue over http - * \param content_type: The http content type, eg, text/html - * \param other_headers: NULL or pointer to header string - * \param other_headers_len: length of the other headers if non-NULL - * - * This function is intended to be called from the callback in response - * to http requests from the client. It allows the callback to issue - * local files down the http link in a single step. - * - * Returning <0 indicates error and the wsi should be closed. Returning - * >0 indicates the file was completely sent and - * lws_http_transaction_completed() called on the wsi (and close if != 0) - * ==0 indicates the file transfer is started and needs more service later, - * the wsi should be left alone. - */ -LWS_VISIBLE LWS_EXTERN int -lws_serve_http_file(struct lws *wsi, const char *file, const char *content_type, - const char *other_headers, int other_headers_len); -LWS_VISIBLE LWS_EXTERN int -lws_serve_http_file_fragment(struct lws *wsi); -//@} - -/*! \defgroup html-chunked-substitution HTML Chunked Substitution - * \ingroup http - * - * ##HTML chunked Substitution - * - * APIs for receiving chunks of text, replacing a set of variable names via - * a callback, and then prepending and appending HTML chunked encoding - * headers. - */ -//@{ - -enum http_status { - HTTP_STATUS_OK = 200, - HTTP_STATUS_NO_CONTENT = 204, - - HTTP_STATUS_MOVED_PERMANENTLY = 301, - HTTP_STATUS_FOUND = 302, - HTTP_STATUS_SEE_OTHER = 303, - - HTTP_STATUS_BAD_REQUEST = 400, - HTTP_STATUS_UNAUTHORIZED, - HTTP_STATUS_PAYMENT_REQUIRED, - HTTP_STATUS_FORBIDDEN, - HTTP_STATUS_NOT_FOUND, - HTTP_STATUS_METHOD_NOT_ALLOWED, - HTTP_STATUS_NOT_ACCEPTABLE, - HTTP_STATUS_PROXY_AUTH_REQUIRED, - HTTP_STATUS_REQUEST_TIMEOUT, - HTTP_STATUS_CONFLICT, - HTTP_STATUS_GONE, - HTTP_STATUS_LENGTH_REQUIRED, - HTTP_STATUS_PRECONDITION_FAILED, - HTTP_STATUS_REQ_ENTITY_TOO_LARGE, - HTTP_STATUS_REQ_URI_TOO_LONG, - HTTP_STATUS_UNSUPPORTED_MEDIA_TYPE, - HTTP_STATUS_REQ_RANGE_NOT_SATISFIABLE, - HTTP_STATUS_EXPECTATION_FAILED, - - HTTP_STATUS_INTERNAL_SERVER_ERROR = 500, - HTTP_STATUS_NOT_IMPLEMENTED, - HTTP_STATUS_BAD_GATEWAY, - HTTP_STATUS_SERVICE_UNAVAILABLE, - HTTP_STATUS_GATEWAY_TIMEOUT, - HTTP_STATUS_HTTP_VERSION_NOT_SUPPORTED, -}; - -struct lws_process_html_args { - char *p; /**< pointer to the buffer containing the data */ - int len; /**< length of the original data at p */ - int max_len; /**< maximum length we can grow the data to */ - int final; /**< set if this is the last chunk of the file */ -}; - -typedef const char *(*lws_process_html_state_cb)(void *data, int index); - -struct lws_process_html_state { - char *start; /**< pointer to start of match */ - char swallow[16]; /**< matched character buffer */ - int pos; /**< position in match */ - void *data; /**< opaque pointer */ - const char * const *vars; /**< list of variable names */ - int count_vars; /**< count of variable names */ - - lws_process_html_state_cb replace; /**< called on match to perform substitution */ -}; - -/*! lws_chunked_html_process() - generic chunked substitution - * \param args: buffer to process using chunked encoding - * \param s: current processing state - */ -LWS_VISIBLE LWS_EXTERN int -lws_chunked_html_process(struct lws_process_html_args *args, - struct lws_process_html_state *s); -//@} - -/** \defgroup HTTP-headers-read HTTP headers: read - * \ingroup http - * - * ##HTTP header releated functions - * - * In lws the client http headers are temporarily stored in a pool, only for the - * duration of the http part of the handshake. It's because in most cases, - * the header content is ignored for the whole rest of the connection lifetime - * and would then just be taking up space needlessly. - * - * During LWS_CALLBACK_HTTP when the URI path is delivered is the last time - * the http headers are still allocated, you can use these apis then to - * look at and copy out interesting header content (cookies, etc) - * - * Notice that the header total length reported does not include a terminating - * '\0', however you must allocate for it when using the _copy apis. So the - * length reported for a header containing "123" is 3, but you must provide - * a buffer of length 4 so that "123\0" may be copied into it, or the copy - * will fail with a nonzero return code. - * - * In the special case of URL arguments, like ?x=1&y=2, the arguments are - * stored in a token named for the method, eg, WSI_TOKEN_GET_URI if it - * was a GET or WSI_TOKEN_POST_URI if POST. You can check the total - * length to confirm the method. - * - * For URL arguments, each argument is stored urldecoded in a "fragment", so - * you can use the fragment-aware api lws_hdr_copy_fragment() to access each - * argument in turn: the fragments contain urldecoded strings like x=1 or y=2. - * - * As a convenience, lws has an api that will find the fragment with a - * given name= part, lws_get_urlarg_by_name(). - */ -///@{ - -/** struct lws_tokens - * you need these to look at headers that have been parsed if using the - * LWS_CALLBACK_FILTER_CONNECTION callback. If a header from the enum - * list below is absent, .token = NULL and token_len = 0. Otherwise .token - * points to .token_len chars containing that header content. - */ -struct lws_tokens { - char *token; /**< pointer to start of the token */ - int token_len; /**< length of the token's value */ -}; - -/* enum lws_token_indexes - * these have to be kept in sync with lextable.h / minilex.c - * - * NOTE: These public enums are part of the abi. If you want to add one, - * add it at where specified so existing users are unaffected. - */ -enum lws_token_indexes { - WSI_TOKEN_GET_URI = 0, - WSI_TOKEN_POST_URI = 1, - WSI_TOKEN_OPTIONS_URI = 2, - WSI_TOKEN_HOST = 3, - WSI_TOKEN_CONNECTION = 4, - WSI_TOKEN_UPGRADE = 5, - WSI_TOKEN_ORIGIN = 6, - WSI_TOKEN_DRAFT = 7, - WSI_TOKEN_CHALLENGE = 8, - WSI_TOKEN_EXTENSIONS = 9, - WSI_TOKEN_KEY1 = 10, - WSI_TOKEN_KEY2 = 11, - WSI_TOKEN_PROTOCOL = 12, - WSI_TOKEN_ACCEPT = 13, - WSI_TOKEN_NONCE = 14, - WSI_TOKEN_HTTP = 15, - WSI_TOKEN_HTTP2_SETTINGS = 16, - WSI_TOKEN_HTTP_ACCEPT = 17, - WSI_TOKEN_HTTP_AC_REQUEST_HEADERS = 18, - WSI_TOKEN_HTTP_IF_MODIFIED_SINCE = 19, - WSI_TOKEN_HTTP_IF_NONE_MATCH = 20, - WSI_TOKEN_HTTP_ACCEPT_ENCODING = 21, - WSI_TOKEN_HTTP_ACCEPT_LANGUAGE = 22, - WSI_TOKEN_HTTP_PRAGMA = 23, - WSI_TOKEN_HTTP_CACHE_CONTROL = 24, - WSI_TOKEN_HTTP_AUTHORIZATION = 25, - WSI_TOKEN_HTTP_COOKIE = 26, - WSI_TOKEN_HTTP_CONTENT_LENGTH = 27, - WSI_TOKEN_HTTP_CONTENT_TYPE = 28, - WSI_TOKEN_HTTP_DATE = 29, - WSI_TOKEN_HTTP_RANGE = 30, - WSI_TOKEN_HTTP_REFERER = 31, - WSI_TOKEN_KEY = 32, - WSI_TOKEN_VERSION = 33, - WSI_TOKEN_SWORIGIN = 34, - - WSI_TOKEN_HTTP_COLON_AUTHORITY = 35, - WSI_TOKEN_HTTP_COLON_METHOD = 36, - WSI_TOKEN_HTTP_COLON_PATH = 37, - WSI_TOKEN_HTTP_COLON_SCHEME = 38, - WSI_TOKEN_HTTP_COLON_STATUS = 39, - - WSI_TOKEN_HTTP_ACCEPT_CHARSET = 40, - WSI_TOKEN_HTTP_ACCEPT_RANGES = 41, - WSI_TOKEN_HTTP_ACCESS_CONTROL_ALLOW_ORIGIN = 42, - WSI_TOKEN_HTTP_AGE = 43, - WSI_TOKEN_HTTP_ALLOW = 44, - WSI_TOKEN_HTTP_CONTENT_DISPOSITION = 45, - WSI_TOKEN_HTTP_CONTENT_ENCODING = 46, - WSI_TOKEN_HTTP_CONTENT_LANGUAGE = 47, - WSI_TOKEN_HTTP_CONTENT_LOCATION = 48, - WSI_TOKEN_HTTP_CONTENT_RANGE = 49, - WSI_TOKEN_HTTP_ETAG = 50, - WSI_TOKEN_HTTP_EXPECT = 51, - WSI_TOKEN_HTTP_EXPIRES = 52, - WSI_TOKEN_HTTP_FROM = 53, - WSI_TOKEN_HTTP_IF_MATCH = 54, - WSI_TOKEN_HTTP_IF_RANGE = 55, - WSI_TOKEN_HTTP_IF_UNMODIFIED_SINCE = 56, - WSI_TOKEN_HTTP_LAST_MODIFIED = 57, - WSI_TOKEN_HTTP_LINK = 58, - WSI_TOKEN_HTTP_LOCATION = 59, - WSI_TOKEN_HTTP_MAX_FORWARDS = 60, - WSI_TOKEN_HTTP_PROXY_AUTHENTICATE = 61, - WSI_TOKEN_HTTP_PROXY_AUTHORIZATION = 62, - WSI_TOKEN_HTTP_REFRESH = 63, - WSI_TOKEN_HTTP_RETRY_AFTER = 64, - WSI_TOKEN_HTTP_SERVER = 65, - WSI_TOKEN_HTTP_SET_COOKIE = 66, - WSI_TOKEN_HTTP_STRICT_TRANSPORT_SECURITY = 67, - WSI_TOKEN_HTTP_TRANSFER_ENCODING = 68, - WSI_TOKEN_HTTP_USER_AGENT = 69, - WSI_TOKEN_HTTP_VARY = 70, - WSI_TOKEN_HTTP_VIA = 71, - WSI_TOKEN_HTTP_WWW_AUTHENTICATE = 72, - - WSI_TOKEN_PATCH_URI = 73, - WSI_TOKEN_PUT_URI = 74, - WSI_TOKEN_DELETE_URI = 75, - - WSI_TOKEN_HTTP_URI_ARGS = 76, - WSI_TOKEN_PROXY = 77, - WSI_TOKEN_HTTP_X_REAL_IP = 78, - WSI_TOKEN_HTTP1_0 = 79, - - /****** add new things just above ---^ ******/ - - /* use token storage to stash these internally, not for - * user use */ - - _WSI_TOKEN_CLIENT_SENT_PROTOCOLS, - _WSI_TOKEN_CLIENT_PEER_ADDRESS, - _WSI_TOKEN_CLIENT_URI, - _WSI_TOKEN_CLIENT_HOST, - _WSI_TOKEN_CLIENT_ORIGIN, - _WSI_TOKEN_CLIENT_METHOD, - - /* always last real token index*/ - WSI_TOKEN_COUNT, - - /* parser state additions, no storage associated */ - WSI_TOKEN_NAME_PART, - WSI_TOKEN_SKIPPING, - WSI_TOKEN_SKIPPING_SAW_CR, - WSI_PARSING_COMPLETE, - WSI_INIT_TOKEN_MUXURL, -}; - -struct lws_token_limits { - unsigned short token_limit[WSI_TOKEN_COUNT]; /**< max chars for this token */ -}; - -/** - * lws_token_to_string() - returns a textual representation of a hdr token index - * - * \param: token index - */ -LWS_VISIBLE LWS_EXTERN const unsigned char * -lws_token_to_string(enum lws_token_indexes token); - - -/** - * lws_hdr_total_length: report length of all fragments of a header totalled up - * The returned length does not include the space for a - * terminating '\0' - * - * \param wsi: websocket connection - * \param h: which header index we are interested in - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_hdr_total_length(struct lws *wsi, enum lws_token_indexes h); - -/** - * lws_hdr_fragment_length: report length of a single fragment of a header - * The returned length does not include the space for a - * terminating '\0' - * - * \param wsi: websocket connection - * \param h: which header index we are interested in - * \param frag_idx: which fragment of h we want to get the length of - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_hdr_fragment_length(struct lws *wsi, enum lws_token_indexes h, int frag_idx); - -/** - * lws_hdr_copy() - copy a single fragment of the given header to a buffer - * The buffer length len must include space for an additional - * terminating '\0', or it will fail returning -1. - * - * \param wsi: websocket connection - * \param dest: destination buffer - * \param len: length of destination buffer - * \param h: which header index we are interested in - * - * copies the whole, aggregated header, even if it was delivered in - * several actual headers piece by piece - */ -LWS_VISIBLE LWS_EXTERN int -lws_hdr_copy(struct lws *wsi, char *dest, int len, enum lws_token_indexes h); - -/** - * lws_hdr_copy_fragment() - copy a single fragment of the given header to a buffer - * The buffer length len must include space for an additional - * terminating '\0', or it will fail returning -1. - * If the requested fragment index is not present, it fails - * returning -1. - * - * \param wsi: websocket connection - * \param dest: destination buffer - * \param len: length of destination buffer - * \param h: which header index we are interested in - * \param frag_idx: which fragment of h we want to copy - * - * Normally this is only useful - * to parse URI arguments like ?x=1&y=2, token index WSI_TOKEN_HTTP_URI_ARGS - * fragment 0 will contain "x=1" and fragment 1 "y=2" - */ -LWS_VISIBLE LWS_EXTERN int -lws_hdr_copy_fragment(struct lws *wsi, char *dest, int len, - enum lws_token_indexes h, int frag_idx); - -/** - * lws_get_urlarg_by_name() - return pointer to arg value if present - * \param wsi: the connection to check - * \param name: the arg name, like "token=" - * \param buf: the buffer to receive the urlarg (including the name= part) - * \param len: the length of the buffer to receive the urlarg - * - * Returns NULL if not found or a pointer inside buf to just after the - * name= part. - */ -LWS_VISIBLE LWS_EXTERN const char * -lws_get_urlarg_by_name(struct lws *wsi, const char *name, char *buf, int len); -///@} - -/*! \defgroup HTTP-headers-create HTTP headers: create - * - * ## HTTP headers: Create - * - * These apis allow you to create HTTP response headers in a way compatible with - * both HTTP/1.x and HTTP/2. - * - * They each append to a buffer taking care about the buffer end, which is - * passed in as a pointer. When data is written to the buffer, the current - * position p is updated accordingly. - * - * All of these apis are LWS_WARN_UNUSED_RESULT as they can run out of space - * and fail with nonzero return. - */ -///@{ -/** - * lws_add_http_header_status() - add the HTTP response status code - * - * \param wsi: the connection to check - * \param code: an HTTP code like 200, 404 etc (see enum http_status) - * \param p: pointer to current position in buffer pointer - * \param end: pointer to end of buffer - * - * Adds the initial response code, so should be called first - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_add_http_header_status(struct lws *wsi, - unsigned int code, unsigned char **p, - unsigned char *end); -/** - * lws_add_http_header_by_name() - append named header and value - * - * \param wsi: the connection to check - * \param name: the hdr name, like "my-header" - * \param value: the value after the = for this header - * \param length: the length of the value - * \param p: pointer to current position in buffer pointer - * \param end: pointer to end of buffer - * - * Appends name: value to the headers - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_add_http_header_by_name(struct lws *wsi, const unsigned char *name, - const unsigned char *value, int length, - unsigned char **p, unsigned char *end); -/** - * lws_add_http_header_by_token() - append given header and value - * - * \param wsi: the connection to check - * \param token: the token index for the hdr - * \param value: the value after the = for this header - * \param length: the length of the value - * \param p: pointer to current position in buffer pointer - * \param end: pointer to end of buffer - * - * Appends name=value to the headers, but is able to take advantage of better - * HTTP/2 coding mechanisms where possible. - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_add_http_header_by_token(struct lws *wsi, enum lws_token_indexes token, - const unsigned char *value, int length, - unsigned char **p, unsigned char *end); -/** - * lws_add_http_header_by_name() - append content-length helper - * - * \param wsi: the connection to check - * \param content_length: the content length to use - * \param p: pointer to current position in buffer pointer - * \param end: pointer to end of buffer - * - * Appends content-length: content_length to the headers - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_add_http_header_content_length(struct lws *wsi, - unsigned long content_length, - unsigned char **p, unsigned char *end); -/** - * lws_finalize_http_header() - terminate header block - * - * \param wsi: the connection to check - * \param p: pointer to current position in buffer pointer - * \param end: pointer to end of buffer - * - * Indicates no more headers will be added - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_finalize_http_header(struct lws *wsi, unsigned char **p, - unsigned char *end); -///@} - -/** \defgroup form-parsing Form Parsing - * \ingroup http - * ##POSTed form parsing functions - * - * These lws_spa (stateful post arguments) apis let you parse and urldecode - * POSTed form arguments, both using simple urlencoded and multipart transfer - * encoding. - * - * It's capable of handling file uploads as well a named input parsing, - * and the apis are the same for both form upload styles. - * - * You feed it a list of parameter names and it creates pointers to the - * urldecoded arguments: file upload parameters pass the file data in chunks to - * a user-supplied callback as they come. - * - * Since it's stateful, it handles the incoming data needing more than one - * POST_BODY callback and has no limit on uploaded file size. - */ -///@{ - -/** enum lws_spa_fileupload_states */ -enum lws_spa_fileupload_states { - LWS_UFS_CONTENT, - /**< a chunk of file content has arrived */ - LWS_UFS_FINAL_CONTENT, - /**< the last chunk (possibly zero length) of file content has arrived */ - LWS_UFS_OPEN - /**< a new file is starting to arrive */ -}; - -/** - * lws_spa_fileupload_cb() - callback to receive file upload data - * - * \param data: opt_data pointer set in lws_spa_create - * \param name: name of the form field being uploaded - * \param filename: original filename from client - * \param buf: start of data to receive - * \param len: length of data to receive - * \param state: information about how this call relates to file - * - * Notice name and filename shouldn't be trusted, as they are passed from - * HTTP provided by the client. - */ -typedef int (*lws_spa_fileupload_cb)(void *data, const char *name, - const char *filename, char *buf, int len, - enum lws_spa_fileupload_states state); - -/** struct lws_spa - opaque urldecode parser capable of handling multipart - * and file uploads */ -struct lws_spa; - -/** - * lws_spa_create() - create urldecode parser - * - * \param wsi: lws connection (used to find Content Type) - * \param param_names: array of form parameter names, like "username" - * \param count_params: count of param_names - * \param max_storage: total amount of form parameter values we can store - * \param opt_cb: NULL, or callback to receive file upload data. - * \param opt_data: NULL, or user pointer provided to opt_cb. - * - * Creates a urldecode parser and initializes it. - * - * opt_cb can be NULL if you just want normal name=value parsing, however - * if one or more entries in your form are bulk data (file transfer), you - * can provide this callback and filter on the name callback parameter to - * treat that urldecoded data separately. The callback should return -1 - * in case of fatal error, and 0 if OK. - */ -LWS_VISIBLE LWS_EXTERN struct lws_spa * -lws_spa_create(struct lws *wsi, const char * const *param_names, - int count_params, int max_storage, lws_spa_fileupload_cb opt_cb, - void *opt_data); - -/** - * lws_spa_process() - parses a chunk of input data - * - * \param spa: the parser object previously created - * \param in: incoming, urlencoded data - * \param len: count of bytes valid at \param in - */ -LWS_VISIBLE LWS_EXTERN int -lws_spa_process(struct lws_spa *spa, const char *in, int len); - -/** - * lws_spa_finalize() - indicate incoming data completed - * - * \param spa: the parser object previously created - */ -LWS_VISIBLE LWS_EXTERN int -lws_spa_finalize(struct lws_spa *spa); - -/** - * lws_spa_get_length() - return length of parameter value - * - * \param spa: the parser object previously created - * \param n: parameter ordinal to return length of value for - */ -LWS_VISIBLE LWS_EXTERN int -lws_spa_get_length(struct lws_spa *spa, int n); - -/** - * lws_spa_get_string() - return pointer to parameter value - * \param spa: the parser object previously created - * \param n: parameter ordinal to return pointer to value for - */ -LWS_VISIBLE LWS_EXTERN const char * -lws_spa_get_string(struct lws_spa *spa, int n); - -/** - * lws_spa_destroy() - destroy parser object - * - * \param spa: the parser object previously created - */ -LWS_VISIBLE LWS_EXTERN int -lws_spa_destroy(struct lws_spa *spa); -///@} - -/*! \defgroup urlendec Urlencode and Urldecode - * \ingroup http - * - * ##HTML chunked Substitution - * - * APIs for receiving chunks of text, replacing a set of variable names via - * a callback, and then prepending and appending HTML chunked encoding - * headers. - */ -//@{ - -/** - * lws_urlencode() - like strncpy but with urlencoding - * - * \param escaped: output buffer - * \param string: input buffer ('/0' terminated) - * \param len: output buffer max length - * - * Because urlencoding expands the output string, it's not - * possible to do it in-place, ie, with escaped == string - */ -LWS_VISIBLE LWS_EXTERN const char * -lws_urlencode(char *escaped, const char *string, int len); - -/* - * URLDECODE 1 / 2 - * - * This simple urldecode only operates until the first '\0' and requires the - * data to exist all at once - */ -/** - * lws_urldecode() - like strncpy but with urldecoding - * - * \param string: output buffer - * \param escaped: input buffer ('\0' terminated) - * \param len: output buffer max length - * - * This is only useful for '\0' terminated strings - * - * Since urldecoding only shrinks the output string, it is possible to - * do it in-place, ie, string == escaped - */ -LWS_VISIBLE LWS_EXTERN int -lws_urldecode(char *string, const char *escaped, int len); -///@} -/** - * lws_return_http_status() - Return simple http status - * \param wsi: Websocket instance (available from user callback) - * \param code: Status index, eg, 404 - * \param html_body: User-readable HTML description < 1KB, or NULL - * - * Helper to report HTTP errors back to the client cleanly and - * consistently - */ -LWS_VISIBLE LWS_EXTERN int -lws_return_http_status(struct lws *wsi, unsigned int code, - const char *html_body); - -/** - * lws_http_redirect() - write http redirect into buffer - * - * \param wsi: websocket connection - * \param code: HTTP response code (eg, 301) - * \param loc: where to redirect to - * \param len: length of loc - * \param p: pointer current position in buffer (updated as we write) - * \param end: pointer to end of buffer - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_http_redirect(struct lws *wsi, int code, const unsigned char *loc, int len, - unsigned char **p, unsigned char *end); - -/** - * lws_http_transaction_completed() - wait for new http transaction or close - * \param wsi: websocket connection - * - * Returns 1 if the HTTP connection must close now - * Returns 0 and resets connection to wait for new HTTP header / - * transaction if possible - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_http_transaction_completed(struct lws *wsi); -///@} - -/*! \defgroup pur Sanitize / purify SQL and JSON helpers - * - * ##Sanitize / purify SQL and JSON helpers - * - * APIs for escaping untrusted JSON and SQL safely before use - */ -//@{ - -/** - * lws_sql_purify() - like strncpy but with escaping for sql quotes - * - * \param escaped: output buffer - * \param string: input buffer ('/0' terminated) - * \param len: output buffer max length - * - * Because escaping expands the output string, it's not - * possible to do it in-place, ie, with escaped == string - */ -LWS_VISIBLE LWS_EXTERN const char * -lws_sql_purify(char *escaped, const char *string, int len); - -/** - * lws_json_purify() - like strncpy but with escaping for json chars - * - * \param escaped: output buffer - * \param string: input buffer ('/0' terminated) - * \param len: output buffer max length - * - * Because escaping expands the output string, it's not - * possible to do it in-place, ie, with escaped == string - */ -LWS_VISIBLE LWS_EXTERN const char * -lws_json_purify(char *escaped, const char *string, int len); -///@} - -/*! \defgroup ev libev helpers - * - * ##libev helpers - * - * APIs specific to libev event loop itegration - */ -///@{ - -#ifdef LWS_USE_LIBEV -typedef void (lws_ev_signal_cb_t)(EV_P_ struct ev_signal *w, int revents); - -LWS_VISIBLE LWS_EXTERN int -lws_ev_sigint_cfg(struct lws_context *context, int use_ev_sigint, - lws_ev_signal_cb_t *cb); - -LWS_VISIBLE LWS_EXTERN int -lws_ev_initloop(struct lws_context *context, struct ev_loop *loop, int tsi); - -LWS_VISIBLE LWS_EXTERN void -lws_ev_sigint_cb(struct ev_loop *loop, struct ev_signal *watcher, int revents); -#endif /* LWS_USE_LIBEV */ - -///@} - -/*! \defgroup uv libuv helpers - * - * ##libuv helpers - * - * APIs specific to libuv event loop itegration - */ -///@{ -#ifdef LWS_USE_LIBUV -LWS_VISIBLE LWS_EXTERN int -lws_uv_sigint_cfg(struct lws_context *context, int use_uv_sigint, - uv_signal_cb cb); - -LWS_VISIBLE LWS_EXTERN void -lws_libuv_run(const struct lws_context *context, int tsi); - -LWS_VISIBLE LWS_EXTERN void -lws_libuv_stop(struct lws_context *context); - -LWS_VISIBLE LWS_EXTERN int -lws_uv_initloop(struct lws_context *context, uv_loop_t *loop, int tsi); - -LWS_VISIBLE LWS_EXTERN uv_loop_t * -lws_uv_getloop(struct lws_context *context, int tsi); - -LWS_VISIBLE LWS_EXTERN void -lws_uv_sigint_cb(uv_signal_t *watcher, int signum); -#endif /* LWS_USE_LIBUV */ -///@} - -/*! \defgroup timeout Connection timeouts - - APIs related to setting connection timeouts -*/ -//@{ - -/* - * NOTE: These public enums are part of the abi. If you want to add one, - * add it at where specified so existing users are unaffected. - */ -enum pending_timeout { - NO_PENDING_TIMEOUT = 0, - PENDING_TIMEOUT_AWAITING_PROXY_RESPONSE = 1, - PENDING_TIMEOUT_AWAITING_CONNECT_RESPONSE = 2, - PENDING_TIMEOUT_ESTABLISH_WITH_SERVER = 3, - PENDING_TIMEOUT_AWAITING_SERVER_RESPONSE = 4, - PENDING_TIMEOUT_AWAITING_PING = 5, - PENDING_TIMEOUT_CLOSE_ACK = 6, - PENDING_TIMEOUT_AWAITING_EXTENSION_CONNECT_RESPONSE = 7, - PENDING_TIMEOUT_SENT_CLIENT_HANDSHAKE = 8, - PENDING_TIMEOUT_SSL_ACCEPT = 9, - PENDING_TIMEOUT_HTTP_CONTENT = 10, - PENDING_TIMEOUT_AWAITING_CLIENT_HS_SEND = 11, - PENDING_FLUSH_STORED_SEND_BEFORE_CLOSE = 12, - PENDING_TIMEOUT_SHUTDOWN_FLUSH = 13, - PENDING_TIMEOUT_CGI = 14, - PENDING_TIMEOUT_HTTP_KEEPALIVE_IDLE = 15, - PENDING_TIMEOUT_WS_PONG_CHECK_SEND_PING = 16, - PENDING_TIMEOUT_WS_PONG_CHECK_GET_PONG = 17, - PENDING_TIMEOUT_CLIENT_ISSUE_PAYLOAD = 18, - - /****** add new things just above ---^ ******/ -}; - -/** - * lws_set_timeout() - marks the wsi as subject to a timeout - * - * You will not need this unless you are doing something special - * - * \param wsi: Websocket connection instance - * \param reason: timeout reason - * \param secs: how many seconds - */ -LWS_VISIBLE LWS_EXTERN void -lws_set_timeout(struct lws *wsi, enum pending_timeout reason, int secs); -///@} - -/*! \defgroup sending-data Sending data - - APIs related to writing data on a connection -*/ -//@{ -#if !defined(LWS_SIZEOFPTR) -#define LWS_SIZEOFPTR (sizeof (void *)) -#endif -#if !defined(u_int64_t) -#define u_int64_t unsigned long long -#endif - -#if defined(__x86_64__) -#define _LWS_PAD_SIZE 16 /* Intel recommended for best performance */ -#else -#define _LWS_PAD_SIZE LWS_SIZEOFPTR /* Size of a pointer on the target arch */ -#endif -#define _LWS_PAD(n) (((n) % _LWS_PAD_SIZE) ? \ - ((n) + (_LWS_PAD_SIZE - ((n) % _LWS_PAD_SIZE))) : (n)) -#define LWS_PRE _LWS_PAD(4 + 10) -/* used prior to 1.7 and retained for backward compatibility */ -#define LWS_SEND_BUFFER_PRE_PADDING LWS_PRE -#define LWS_SEND_BUFFER_POST_PADDING 0 - -/* - * NOTE: These public enums are part of the abi. If you want to add one, - * add it at where specified so existing users are unaffected. - */ -enum lws_write_protocol { - LWS_WRITE_TEXT = 0, - /**< Send a ws TEXT message,the pointer must have LWS_PRE valid - * memory behind it. The receiver expects only valid utf-8 in the - * payload */ - LWS_WRITE_BINARY = 1, - /**< Send a ws BINARY message, the pointer must have LWS_PRE valid - * memory behind it. Any sequence of bytes is valid */ - LWS_WRITE_CONTINUATION = 2, - /**< Continue a previous ws message, the pointer must have LWS_PRE valid - * memory behind it */ - LWS_WRITE_HTTP = 3, - /**< Send HTTP content */ - - /* LWS_WRITE_CLOSE is handled by lws_close_reason() */ - LWS_WRITE_PING = 5, - LWS_WRITE_PONG = 6, - - /* Same as write_http but we know this write ends the transaction */ - LWS_WRITE_HTTP_FINAL = 7, - - /* HTTP2 */ - - LWS_WRITE_HTTP_HEADERS = 8, - /**< Send http headers (http2 encodes this payload and LWS_WRITE_HTTP - * payload differently, http 1.x links also handle this correctly. so - * to be compatible with both in the future,header response part should - * be sent using this regardless of http version expected) - */ - - /****** add new things just above ---^ ******/ - - /* flags */ - - LWS_WRITE_NO_FIN = 0x40, - /**< This part of the message is not the end of the message */ - - LWS_WRITE_CLIENT_IGNORE_XOR_MASK = 0x80 - /**< client packet payload goes out on wire unmunged - * only useful for security tests since normal servers cannot - * decode the content if used */ -}; - - -/** - * lws_write() - Apply protocol then write data to client - * \param wsi: Websocket instance (available from user callback) - * \param buf: The data to send. For data being sent on a websocket - * connection (ie, not default http), this buffer MUST have - * LWS_PRE bytes valid BEFORE the pointer. - * This is so the protocol header data can be added in-situ. - * \param len: Count of the data bytes in the payload starting from buf - * \param protocol: Use LWS_WRITE_HTTP to reply to an http connection, and one - * of LWS_WRITE_BINARY or LWS_WRITE_TEXT to send appropriate - * data on a websockets connection. Remember to allow the extra - * bytes before and after buf if LWS_WRITE_BINARY or LWS_WRITE_TEXT - * are used. - * - * This function provides the way to issue data back to the client - * for both http and websocket protocols. - * - * IMPORTANT NOTICE! - * - * When sending with websocket protocol - * - * LWS_WRITE_TEXT, - * LWS_WRITE_BINARY, - * LWS_WRITE_CONTINUATION, - * LWS_WRITE_PING, - * LWS_WRITE_PONG - * - * the send buffer has to have LWS_PRE bytes valid BEFORE - * the buffer pointer you pass to lws_write(). - * - * This allows us to add protocol info before and after the data, and send as - * one packet on the network without payload copying, for maximum efficiency. - * - * So for example you need this kind of code to use lws_write with a - * 128-byte payload - * - * char buf[LWS_PRE + 128]; - * - * // fill your part of the buffer... for example here it's all zeros - * memset(&buf[LWS_PRE], 0, 128); - * - * lws_write(wsi, &buf[LWS_PRE], 128, LWS_WRITE_TEXT); - * - * When sending HTTP, with - * - * LWS_WRITE_HTTP, - * LWS_WRITE_HTTP_HEADERS - * LWS_WRITE_HTTP_FINAL - * - * there is no protocol data prepended, and don't need to take care about the - * LWS_PRE bytes valid before the buffer pointer. - * - * LWS_PRE is at least the frame nonce + 2 header + 8 length - * LWS_SEND_BUFFER_POST_PADDING is deprecated, it's now 0 and can be left off. - * The example apps no longer use it. - * - * Pad LWS_PRE to the CPU word size, so that word references - * to the address immediately after the padding won't cause an unaligned access - * error. Sometimes for performance reasons the recommended padding is even - * larger than sizeof(void *). - * - * In the case of sending using websocket protocol, be sure to allocate - * valid storage before and after buf as explained above. This scheme - * allows maximum efficiency of sending data and protocol in a single - * packet while not burdening the user code with any protocol knowledge. - * - * Return may be -1 for a fatal error needing connection close, or a - * positive number reflecting the amount of bytes actually sent. This - * can be less than the requested number of bytes due to OS memory - * pressure at any given time. - */ -LWS_VISIBLE LWS_EXTERN int -lws_write(struct lws *wsi, unsigned char *buf, size_t len, - enum lws_write_protocol protocol); - -/* helper for case where buffer may be const */ -#define lws_write_http(wsi, buf, len) \ - lws_write(wsi, (unsigned char *)(buf), len, LWS_WRITE_HTTP) - -///@} - -/** \defgroup callback-when-writeable Callback when writeable - * - * ##Callback When Writeable - * - * lws can only write data on a connection when it is able to accept more - * data without blocking. - * - * So a basic requirement is we should only use the lws_write() apis when the - * connection we want to write on says that he can accept more data. - * - * When lws cannot complete your send at the time, it will buffer the data - * and send it in the background, suppressing any further WRITEABLE callbacks - * on that connection until it completes. So it is important to write new - * things in a new writeable callback. - * - * These apis reflect the various ways we can indicate we would like to be - * called back when one or more connections is writeable. - */ -///@{ - -/** - * lws_callback_on_writable() - Request a callback when this socket - * becomes able to be written to without - * blocking - * - * \param wsi: Websocket connection instance to get callback for - * - * - Which: only this wsi - * - When: when the individual connection becomes writeable - * - What: LWS_CALLBACK_*_WRITEABLE - */ -LWS_VISIBLE LWS_EXTERN int -lws_callback_on_writable(struct lws *wsi); - -/** - * lws_callback_on_writable_all_protocol() - Request a callback for all - * connections on same vhost using the given protocol when it - * becomes possible to write to each socket without - * blocking in turn. - * - * \param context: lws_context - * \param protocol: Protocol whose connections will get callbacks - * - * - Which: connections using this protocol on ANY VHOST - * - When: when the individual connection becomes writeable - * - What: LWS_CALLBACK_*_WRITEABLE - */ -LWS_VISIBLE LWS_EXTERN int -lws_callback_on_writable_all_protocol(const struct lws_context *context, - const struct lws_protocols *protocol); - -/** - * lws_callback_on_writable_all_protocol_vhost() - Request a callback for - * all connections using the given protocol when it - * becomes possible to write to each socket without - * blocking in turn. - * - * \param vhost: Only consider connections on this lws_vhost - * \param protocol: Protocol whose connections will get callbacks - * - * - Which: connections using this protocol on GIVEN VHOST ONLY - * - When: when the individual connection becomes writeable - * - What: LWS_CALLBACK_*_WRITEABLE - */ -LWS_VISIBLE LWS_EXTERN int -lws_callback_on_writable_all_protocol_vhost(const struct lws_vhost *vhost, - const struct lws_protocols *protocol); - -/** - * lws_callback_all_protocol() - Callback all connections using - * the given protocol with the given reason - * - * \param context: lws_context - * \param protocol: Protocol whose connections will get callbacks - * \param reason: Callback reason index - * - * - Which: connections using this protocol on ALL VHOSTS - * - When: when the individual connection becomes writeable - * - What: reason - */ -LWS_VISIBLE LWS_EXTERN int -lws_callback_all_protocol(struct lws_context *context, - const struct lws_protocols *protocol, int reason); - -/** - * lws_callback_all_protocol_vhost() - Callback all connections using - * the given protocol with the given reason - * - * \param vh: Vhost whose connections will get callbacks - * \param protocol: Which protocol to match - * \param reason: Callback reason index - * - * - Which: connections using this protocol on GIVEN VHOST ONLY - * - When: now - * - What: reason - */ -LWS_VISIBLE LWS_EXTERN int -lws_callback_all_protocol_vhost(struct lws_vhost *vh, - const struct lws_protocols *protocol, int reason); - -/** - * lws_callback_vhost_protocols() - Callback all protocols enabled on a vhost - * with the given reason - * - * \param wsi: wsi whose vhost will get callbacks - * \param reason: Callback reason index - * \param in: in argument to callback - * \param len: len argument to callback - * - * - Which: connections using this protocol on same VHOST as wsi ONLY - * - When: now - * - What: reason - */ -LWS_VISIBLE LWS_EXTERN int -lws_callback_vhost_protocols(struct lws *wsi, int reason, void *in, int len); - -LWS_VISIBLE LWS_EXTERN int -lws_callback_http_dummy(struct lws *wsi, enum lws_callback_reasons reason, - void *user, void *in, size_t len); - -/** - * lws_get_socket_fd() - returns the socket file descriptor - * - * You will not need this unless you are doing something special - * - * \param wsi: Websocket connection instance - */ -LWS_VISIBLE LWS_EXTERN int -lws_get_socket_fd(struct lws *wsi); - -/** - * lws_get_peer_write_allowance() - get the amount of data writeable to peer - * if known - * - * \param wsi: Websocket connection instance - * - * if the protocol does not have any guidance, returns -1. Currently only - * http2 connections get send window information from this API. But your code - * should use it so it can work properly with any protocol. - * - * If nonzero return is the amount of payload data the peer or intermediary has - * reported it has buffer space for. That has NO relationship with the amount - * of buffer space your OS can accept on this connection for a write action. - * - * This number represents the maximum you could send to the peer or intermediary - * on this connection right now without the protocol complaining. - * - * lws manages accounting for send window updates and payload writes - * automatically, so this number reflects the situation at the peer or - * intermediary dynamically. - */ -LWS_VISIBLE LWS_EXTERN size_t -lws_get_peer_write_allowance(struct lws *wsi); -///@} - -/** - * lws_rx_flow_control() - Enable and disable socket servicing for - * received packets. - * - * If the output side of a server process becomes choked, this allows flow - * control for the input side. - * - * \param wsi: Websocket connection instance to get callback for - * \param enable: 0 = disable read servicing for this connection, 1 = enable - */ -LWS_VISIBLE LWS_EXTERN int -lws_rx_flow_control(struct lws *wsi, int enable); - -/** - * lws_rx_flow_allow_all_protocol() - Allow all connections with this protocol to receive - * - * When the user server code realizes it can accept more input, it can - * call this to have the RX flow restriction removed from all connections using - * the given protocol. - * \param context: lws_context - * \param protocol: all connections using this protocol will be allowed to receive - */ -LWS_VISIBLE LWS_EXTERN void -lws_rx_flow_allow_all_protocol(const struct lws_context *context, - const struct lws_protocols *protocol); - -/** - * lws_remaining_packet_payload() - Bytes to come before "overall" - * rx packet is complete - * \param wsi: Websocket instance (available from user callback) - * - * This function is intended to be called from the callback if the - * user code is interested in "complete packets" from the client. - * libwebsockets just passes through payload as it comes and issues a buffer - * additionally when it hits a built-in limit. The LWS_CALLBACK_RECEIVE - * callback handler can use this API to find out if the buffer it has just - * been given is the last piece of a "complete packet" from the client -- - * when that is the case lws_remaining_packet_payload() will return - * 0. - * - * Many protocols won't care becuse their packets are always small. - */ -LWS_VISIBLE LWS_EXTERN size_t -lws_remaining_packet_payload(struct lws *wsi); - - -/** \defgroup sock-adopt Socket adoption helpers - * ##Socket adoption helpers - * - * When integrating with an external app with its own event loop, these can - * be used to accept connections from someone else's listening socket. - * - * When using lws own event loop, these are not needed. - */ -///@{ - -/** - * lws_adopt_socket() - adopt foreign socket as if listen socket accepted it - * \param context: lws context - * \param accept_fd: fd of already-accepted socket to adopt - * - * Either returns new wsi bound to accept_fd, or closes accept_fd and - * returns NULL, having cleaned up any new wsi pieces. - * - * LWS adopts the socket in http serving mode, it's ready to accept an upgrade - * to ws or just serve http. - */ -LWS_VISIBLE LWS_EXTERN struct lws * -lws_adopt_socket(struct lws_context *context, lws_sockfd_type accept_fd); -/** - * lws_adopt_socket_readbuf() - adopt foreign socket and first rx as if listen socket accepted it - * \param context: lws context - * \param accept_fd: fd of already-accepted socket to adopt - * \param readbuf: NULL or pointer to data that must be drained before reading from - * accept_fd - * \param len: The length of the data held at \param readbuf - * - * Either returns new wsi bound to accept_fd, or closes accept_fd and - * returns NULL, having cleaned up any new wsi pieces. - * - * LWS adopts the socket in http serving mode, it's ready to accept an upgrade - * to ws or just serve http. - * - * If your external code did not already read from the socket, you can use - * lws_adopt_socket() instead. - * - * This api is guaranteed to use the data at \param readbuf first, before reading from - * the socket. - * - * readbuf is limited to the size of the ah rx buf, currently 2048 bytes. - */ -LWS_VISIBLE LWS_EXTERN struct lws * -lws_adopt_socket_readbuf(struct lws_context *context, lws_sockfd_type accept_fd, - const char *readbuf, size_t len); -///@} - -/** \defgroup net Network related helper APIs - * ##Network related helper APIs - * - * These wrap miscellaneous useful network-related functions - */ -///@{ - -/** - * lws_canonical_hostname() - returns this host's hostname - * - * This is typically used by client code to fill in the host parameter - * when making a client connection. You can only call it after the context - * has been created. - * - * \param context: Websocket context - */ -LWS_VISIBLE LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT -lws_canonical_hostname(struct lws_context *context); - -/** - * lws_get_peer_addresses() - Get client address information - * \param wsi: Local struct lws associated with - * \param fd: Connection socket descriptor - * \param name: Buffer to take client address name - * \param name_len: Length of client address name buffer - * \param rip: Buffer to take client address IP dotted quad - * \param rip_len: Length of client address IP buffer - * - * This function fills in name and rip with the name and IP of - * the client connected with socket descriptor fd. Names may be - * truncated if there is not enough room. If either cannot be - * determined, they will be returned as valid zero-length strings. - */ -LWS_VISIBLE LWS_EXTERN void -lws_get_peer_addresses(struct lws *wsi, lws_sockfd_type fd, char *name, - int name_len, char *rip, int rip_len); - -/** - * lws_get_peer_simple() - Get client address information without RDNS - * - * \param wsi: Local struct lws associated with - * \param name: Buffer to take client address name - * \param namelen: Length of client address name buffer - * - * This provides a 123.123.123.123 type IP address in name from the - * peer that has connected to wsi - */ -LWS_VISIBLE LWS_EXTERN const char * -lws_get_peer_simple(struct lws *wsi, char *name, int namelen); -#ifndef LWS_WITH_ESP8266 -/** - * lws_interface_to_sa() - Convert interface name or IP to sockaddr struct - * - * \param ipv6: Allow IPV6 addresses - * \param ifname: Interface name or IP - * \param addr: struct sockaddr_in * to be written - * \param addrlen: Length of addr - * - * This converts a textual network interface name to a sockaddr usable by - * other network functions - */ -LWS_VISIBLE LWS_EXTERN int -lws_interface_to_sa(int ipv6, const char *ifname, struct sockaddr_in *addr, - size_t addrlen); -///@} -#endif - -/** \defgroup misc Miscellaneous APIs -* ##Miscellaneous APIs -* -* Various APIs outside of other categories -*/ -///@{ - -/** - * lws_snprintf(): snprintf that truncates the returned length too - * - * \param str: destination buffer - * \param size: bytes left in destination buffer - * \param format: format string - * \param ...: args for format - * - * This lets you correctly truncate buffers by concatenating lengths, if you - * reach the limit the reported length doesn't exceed the limit. - */ -LWS_VISIBLE LWS_EXTERN int -lws_snprintf(char *str, size_t size, const char *format, ...); - -/** - * lws_get_random(): fill a buffer with platform random data - * - * \param context: the lws context - * \param buf: buffer to fill - * \param len: how much to fill - * - * This is intended to be called from the LWS_CALLBACK_RECEIVE callback if - * it's interested to see if the frame it's dealing with was sent in binary - * mode. - */ -LWS_VISIBLE LWS_EXTERN int -lws_get_random(struct lws_context *context, void *buf, int len); -/** - * lws_daemonize(): fill a buffer with platform random data - * - * \param _lock_path: the filepath to write the lock file - * - * Spawn lws as a background process, taking care of various things - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_daemonize(const char *_lock_path); -/** - * lws_get_library_version(): return string describing the version of lws - * - * On unix, also includes the git describe - */ -LWS_VISIBLE LWS_EXTERN const char * LWS_WARN_UNUSED_RESULT -lws_get_library_version(void); - -/** - * lws_wsi_user() - get the user data associated with the connection - * \param wsi: lws connection - * - * Not normally needed since it's passed into the callback - */ -LWS_VISIBLE LWS_EXTERN void * -lws_wsi_user(struct lws *wsi); - -/** - * lws_parse_uri: cut up prot:/ads:port/path into pieces - * Notice it does so by dropping '\0' into input string - * and the leading / on the path is consequently lost - * - * \param p: incoming uri string.. will get written to - * \param prot: result pointer for protocol part (https://) - * \param ads: result pointer for address part - * \param port: result pointer for port part - * \param path: result pointer for path part - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_parse_uri(char *p, const char **prot, const char **ads, int *port, - const char **path); - -/** - * lws_now_secs(): return seconds since 1970-1-1 - */ -LWS_VISIBLE LWS_EXTERN unsigned long -lws_now_secs(void); - -/** - * lws_get_context - Allow geting lws_context from a Websocket connection - * instance - * - * With this function, users can access context in the callback function. - * Otherwise users may have to declare context as a global variable. - * - * \param wsi: Websocket connection instance - */ -LWS_VISIBLE LWS_EXTERN struct lws_context * LWS_WARN_UNUSED_RESULT -lws_get_context(const struct lws *wsi); - -/** - * lws_get_count_threads(): how many service threads the context uses - * - * \param context: the lws context - * - * By default this is always 1, if you asked for more than lws can handle it - * will clip the number of threads. So you can use this to find out how many - * threads are actually in use. - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_get_count_threads(struct lws_context *context); - -/** - * lws_get_parent() - get parent wsi or NULL - * \param wsi: lws connection - * - * Specialized wsi like cgi stdin/out/err are associated to a parent wsi, - * this allows you to get their parent. - */ -LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT -lws_get_parent(const struct lws *wsi); - -/** - * lws_get_child() - get child wsi or NULL - * \param wsi: lws connection - * - * Allows you to find a related wsi from the parent wsi. - */ -LWS_VISIBLE LWS_EXTERN struct lws * LWS_WARN_UNUSED_RESULT -lws_get_child(const struct lws *wsi); - - -/* - * \deprecated DEPRECATED Note: this is not normally needed as a user api. - * It's provided in case it is - * useful when integrating with other app poll loop service code. - */ -LWS_VISIBLE LWS_EXTERN int -lws_read(struct lws *wsi, unsigned char *buf, size_t len); - -/** - * lws_set_allocator() - custom allocator support - * - * \param realloc - * - * Allows you to replace the allocator (and deallocator) used by lws - */ -LWS_VISIBLE LWS_EXTERN void -lws_set_allocator(void *(*realloc)(void *ptr, size_t size)); -///@} - -/** \defgroup wsstatus Websocket status APIs - * ##Websocket connection status APIs - * - * These provide information about ws connection or message status - */ -///@{ -/** - * lws_send_pipe_choked() - tests if socket is writable or not - * \param wsi: lws connection - * - * Allows you to check if you can write more on the socket - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_send_pipe_choked(struct lws *wsi); - -/** - * lws_is_final_fragment() - tests if last part of ws message - * \param wsi: lws connection - */ -LWS_VISIBLE LWS_EXTERN int -lws_is_final_fragment(struct lws *wsi); - -/** - * lws_get_reserved_bits() - access reserved bits of ws frame - * \param wsi: lws connection - */ -LWS_VISIBLE LWS_EXTERN unsigned char -lws_get_reserved_bits(struct lws *wsi); - -/** - * lws_partial_buffered() - find out if lws buffered the last write - * \param wsi: websocket connection to check - * - * Returns 1 if you cannot use lws_write because the last - * write on this connection is still buffered, and can't be cleared without - * returning to the service loop and waiting for the connection to be - * writeable again. - * - * If you will try to do >1 lws_write call inside a single - * WRITEABLE callback, you must check this after every write and bail if - * set, ask for a new writeable callback and continue writing from there. - * - * This is never set at the start of a writeable callback, but any write - * may set it. - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_partial_buffered(struct lws *wsi); - -/** - * lws_frame_is_binary(): true if the current frame was sent in binary mode - * - * \param wsi: the connection we are inquiring about - * - * This is intended to be called from the LWS_CALLBACK_RECEIVE callback if - * it's interested to see if the frame it's dealing with was sent in binary - * mode. - */ -LWS_VISIBLE LWS_EXTERN int LWS_WARN_UNUSED_RESULT -lws_frame_is_binary(struct lws *wsi); - -/** - * lws_is_ssl() - Find out if connection is using SSL - * \param wsi: websocket connection to check - * - * Returns 0 if the connection is not using SSL, 1 if using SSL and - * using verified cert, and 2 if using SSL but the cert was not - * checked (appears for client wsi told to skip check on connection) - */ -LWS_VISIBLE LWS_EXTERN int -lws_is_ssl(struct lws *wsi); -/** - * lws_is_cgi() - find out if this wsi is running a cgi process - * \param wsi: lws connection - */ -LWS_VISIBLE LWS_EXTERN int -lws_is_cgi(struct lws *wsi); -///@} - - -/** \defgroup sha SHA and B64 helpers - * ##SHA and B64 helpers - * - * These provide SHA-1 and B64 helper apis - */ -///@{ -#ifdef LWS_SHA1_USE_OPENSSL_NAME -#define lws_SHA1 SHA1 -#else -/** - * lws_SHA1(): make a SHA-1 digest of a buffer - * - * \param d: incoming buffer - * \param n: length of incoming buffer - * \param md: buffer for message digest (must be >= 20 bytes) - * - * Reduces any size buffer into a 20-byte SHA-1 hash. - */ -LWS_VISIBLE LWS_EXTERN unsigned char * -lws_SHA1(const unsigned char *d, size_t n, unsigned char *md); -#endif -/** - * lws_b64_encode_string(): encode a string into base 64 - * - * \param in: incoming buffer - * \param in_len: length of incoming buffer - * \param out: result buffer - * \param out_size: length of result buffer - * - * Encodes a string using b64 - */ -LWS_VISIBLE LWS_EXTERN int -lws_b64_encode_string(const char *in, int in_len, char *out, int out_size); -/** - * lws_b64_decode_string(): decode a string from base 64 - * - * \param in: incoming buffer - * \param out: result buffer - * \param out_size: length of result buffer - * - * Decodes a string using b64 - */ -LWS_VISIBLE LWS_EXTERN int -lws_b64_decode_string(const char *in, char *out, int out_size); -///@} - - -/*! \defgroup cgi cgi handling - * - * ##CGI handling - * - * These functions allow low-level control over stdin/out/err of the cgi. - * - * However for most cases, binding the cgi to http in and out, the default - * lws implementation already does the right thing. - */ -#ifdef LWS_WITH_CGI -enum lws_enum_stdinouterr { - LWS_STDIN = 0, - LWS_STDOUT = 1, - LWS_STDERR = 2, -}; - -enum lws_cgi_hdr_state { - LCHS_HEADER, - LCHS_CR1, - LCHS_LF1, - LCHS_CR2, - LCHS_LF2, - LHCS_PAYLOAD, - LCHS_SINGLE_0A, -}; - -struct lws_cgi_args { - struct lws **stdwsi; /**< get fd with lws_get_socket_fd() */ - enum lws_enum_stdinouterr ch; /**< channel index */ - unsigned char *data; /**< for messages with payload */ - enum lws_cgi_hdr_state hdr_state; /**< track where we are in cgi headers */ - int len; /**< length */ -}; - - -/** - * lws_cgi: spawn network-connected cgi process - * - * \param wsi: connection to own the process - * \param exec_array: array of "exec-name" "arg1" ... "argn" NULL - * \param script_uri_path_len: how many chars on the left of the uri are the path to the cgi - * \param timeout_secs: seconds script should be allowed to run - * \param mp_cgienv: pvo list with per-vhost cgi options to put in env - */ -LWS_VISIBLE LWS_EXTERN int -lws_cgi(struct lws *wsi, const char * const *exec_array, - int script_uri_path_len, int timeout_secs, - const struct lws_protocol_vhost_options *mp_cgienv); - -/** - * lws_cgi_write_split_stdout_headers: write cgi output accounting for header part - * - * \param wsi: connection to own the process - */ -LWS_VISIBLE LWS_EXTERN int -lws_cgi_write_split_stdout_headers(struct lws *wsi); - -/** - * lws_cgi_kill: terminate cgi process associated with wsi - * - * \param wsi: connection to own the process - */ -LWS_VISIBLE LWS_EXTERN int -lws_cgi_kill(struct lws *wsi); -#endif -///@} - - -/*! \defgroup fops file operation wrapping - * - * ##File operation wrapping - * - * Use these helper functions if you want to access a file from the perspective - * of a specific wsi, which is usually the case. If you just want contextless - * file access, use the fops callbacks directly with NULL wsi instead of these - * helpers. - * - * If so, then it calls the platform handler or user overrides where present - * (as defined in info->fops) - * - * The advantage from all this is user code can be portable for file operations - * without having to deal with differences between platforms. - */ -//@{ - -/** struct lws_plat_file_ops - Platform-specific file operations - * - * These provide platform-agnostic ways to deal with filesystem access in the - * library and in the user code. - */ -struct lws_plat_file_ops { - lws_filefd_type (*open)(struct lws *wsi, const char *filename, - unsigned long *filelen, int flags); - /**< Open file (always binary access if plat supports it) - * filelen is filled on exit to be the length of the file - * flags should be set to O_RDONLY or O_RDWR */ - int (*close)(struct lws *wsi, lws_filefd_type fd); - /**< close file */ - unsigned long (*seek_cur)(struct lws *wsi, lws_filefd_type fd, - long offset_from_cur_pos); - /**< seek from current position */ - int (*read)(struct lws *wsi, lws_filefd_type fd, unsigned long *amount, - unsigned char *buf, unsigned long len); - /**< Read from file, on exit *amount is set to amount actually read */ - int (*write)(struct lws *wsi, lws_filefd_type fd, unsigned long *amount, - unsigned char *buf, unsigned long len); - /**< Write to file, on exit *amount is set to amount actually written */ - - /* Add new things just above here ---^ - * This is part of the ABI, don't needlessly break compatibility */ -}; - -/** - * lws_get_fops() - get current file ops - * - * \param context: context - */ -LWS_VISIBLE LWS_EXTERN struct lws_plat_file_ops * LWS_WARN_UNUSED_RESULT -lws_get_fops(struct lws_context *context); - -/** - * lws_plat_file_open() - file open operations - * - * \param wsi: connection doing the opening - * \param filename: filename to open - * \param filelen: length of file (filled in by call) - * \param flags: open flags - */ -static LWS_INLINE lws_filefd_type LWS_WARN_UNUSED_RESULT -lws_plat_file_open(struct lws *wsi, const char *filename, - unsigned long *filelen, int flags) -{ - return lws_get_fops(lws_get_context(wsi))->open(wsi, filename, - filelen, flags); -} - -/** - * lws_plat_file_close() - close file - * - * \param wsi: connection opened by - * \param fd: file descriptor - */ -static LWS_INLINE int -lws_plat_file_close(struct lws *wsi, lws_filefd_type fd) -{ - return lws_get_fops(lws_get_context(wsi))->close(wsi, fd); -} - -/** - * lws_plat_file_seek_cur() - close file - * - * \param wsi: connection opened by - * \param fd: file descriptor - * \param offset: position to seek to - */ -static LWS_INLINE unsigned long -lws_plat_file_seek_cur(struct lws *wsi, lws_filefd_type fd, long offset) -{ - return lws_get_fops(lws_get_context(wsi))->seek_cur(wsi, fd, offset); -} -/** - * lws_plat_file_read() - read from file - * - * \param wsi: connection opened by - * \param fd: file descriptor - * \param amount: how much to read (rewritten by call) - * \param buf: buffer to write to - * \param len: max length - */ -static LWS_INLINE int LWS_WARN_UNUSED_RESULT -lws_plat_file_read(struct lws *wsi, lws_filefd_type fd, unsigned long *amount, - unsigned char *buf, unsigned long len) -{ - return lws_get_fops(lws_get_context(wsi))->read(wsi, fd, amount, buf, - len); -} -/** - * lws_plat_file_write() - write from file - * - * \param wsi: connection opened by - * \param fd: file descriptor - * \param amount: how much to write (rewritten by call) - * \param buf: buffer to read from - * \param len: max length - */ -static LWS_INLINE int LWS_WARN_UNUSED_RESULT -lws_plat_file_write(struct lws *wsi, lws_filefd_type fd, unsigned long *amount, - unsigned char *buf, unsigned long len) -{ - return lws_get_fops(lws_get_context(wsi))->write(wsi, fd, amount, buf, - len); -} -//@} - -/** \defgroup smtp - * \ingroup lwsapi - * ##SMTP related functions - * - * These apis let you communicate with a local SMTP server to send email from - * lws. It handles all the SMTP sequencing and protocol actions. - * - * Your system should have postfix, sendmail or another MTA listening on port - * 25 and able to send email using the "mail" commandline app. Usually distro - * MTAs are configured for this by default. - * - * It runs via its own libuv events if initialized (which requires giving it - * a libuv loop to attach to). - * - * It operates using three callbacks, on_next() queries if there is a new email - * to send, on_get_body() asks for the body of the email, and on_sent() is - * called after the email is successfully sent. - * - * To use it - * - * - create an lws_email struct - * - * - initialize data, loop, the email_* strings, max_content_size and - * the callbacks - * - * - call lws_email_init() - * - * When you have at least one email to send, call lws_email_check() to - * schedule starting to send it. - */ -//@{ -#ifdef LWS_WITH_SMTP - -/** enum lwsgs_smtp_states - where we are in SMTP protocol sequence */ -enum lwsgs_smtp_states { - LGSSMTP_IDLE, /**< awaiting new email */ - LGSSMTP_CONNECTING, /**< opening tcp connection to MTA */ - LGSSMTP_CONNECTED, /**< tcp connection to MTA is connected */ - LGSSMTP_SENT_HELO, /**< sent the HELO */ - LGSSMTP_SENT_FROM, /**< sent FROM */ - LGSSMTP_SENT_TO, /**< sent TO */ - LGSSMTP_SENT_DATA, /**< sent DATA request */ - LGSSMTP_SENT_BODY, /**< sent the email body */ - LGSSMTP_SENT_QUIT, /**< sent the session quit */ -}; - -/** struct lws_email - abstract context for performing SMTP operations */ -struct lws_email { - void *data; - /**< opaque pointer set by user code and available to the callbacks */ - uv_loop_t *loop; - /**< the libuv loop we will work on */ - - char email_smtp_ip[32]; /**< Fill before init, eg, "127.0.0.1" */ - char email_helo[32]; /**< Fill before init, eg, "myserver.com" */ - char email_from[100]; /**< Fill before init or on_next */ - char email_to[100]; /**< Fill before init or on_next */ - - unsigned int max_content_size; - /**< largest possible email body size */ - - /* Fill all the callbacks before init */ - - int (*on_next)(struct lws_email *email); - /**< (Fill in before calling lws_email_init) - * called when idle, 0 = another email to send, nonzero is idle. - * If you return 0, all of the email_* char arrays must be set - * to something useful. */ - int (*on_sent)(struct lws_email *email); - /**< (Fill in before calling lws_email_init) - * called when transfer of the email to the SMTP server was - * successful, your callback would remove the current email - * from its queue */ - int (*on_get_body)(struct lws_email *email, char *buf, int len); - /**< (Fill in before calling lws_email_init) - * called when the body part of the queued email is about to be - * sent to the SMTP server. */ - - - /* private things */ - uv_timer_t timeout_email; /**< private */ - enum lwsgs_smtp_states estate; /**< private */ - uv_connect_t email_connect_req; /**< private */ - uv_tcp_t email_client; /**< private */ - time_t email_connect_started; /**< private */ - char email_buf[256]; /**< private */ - char *content; /**< private */ -}; - -/** - * lws_email_init() - Initialize a struct lws_email - * - * \param email: struct lws_email to init - * \param loop: libuv loop to use - * \param max_content: max email content size - * - * Prepares a struct lws_email for use ending SMTP - */ -LWS_VISIBLE LWS_EXTERN int -lws_email_init(struct lws_email *email, uv_loop_t *loop, int max_content); - -/** - * lws_email_check() - Request check for new email - * - * \param email: struct lws_email context to check - * - * Schedules a check for new emails in 1s... call this when you have queued an - * email for send. - */ -LWS_VISIBLE LWS_EXTERN void -lws_email_check(struct lws_email *email); -/** - * lws_email_destroy() - stop using the struct lws_email - * - * \param email: the struct lws_email context - * - * Stop sending email using email and free allocations - */ -LWS_VISIBLE LWS_EXTERN void -lws_email_destroy(struct lws_email *email); - -#endif -//@} - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/android/armeabi/include/websockets/lws_config.h b/android/armeabi/include/websockets/lws_config.h deleted file mode 100644 index bf49e46e..00000000 --- a/android/armeabi/include/websockets/lws_config.h +++ /dev/null @@ -1,117 +0,0 @@ -/* lws_config.h Generated from lws_config.h.in */ - -#ifndef NDEBUG - #ifndef _DEBUG - #define _DEBUG - #endif -#endif - -#define LWS_INSTALL_DATADIR "/Users/james/Project/cocos2d-x-3rd-party-libs-src/contrib/install-android/arm/share" - -/* Define to 1 to use wolfSSL/CyaSSL as a replacement for OpenSSL. - * LWS_OPENSSL_SUPPORT needs to be set also for this to work. */ -/* #undef USE_WOLFSSL */ - -/* Also define to 1 (in addition to USE_WOLFSSL) when using the - (older) CyaSSL library */ -/* #undef USE_OLD_CYASSL */ - -/* #undef LWS_USE_MBEDTLS */ -/* #undef LWS_USE_POLARSSL */ -/* #undef LWS_WITH_ESP8266 */ - -/* #undef LWS_WITH_PLUGINS */ -/* #undef LWS_WITH_NO_LOGS */ - -/* The Libwebsocket version */ -#define LWS_LIBRARY_VERSION "2.1.0" - -#define LWS_LIBRARY_VERSION_MAJOR 2 -#define LWS_LIBRARY_VERSION_MINOR 1 -#define LWS_LIBRARY_VERSION_PATCH 0 -/* LWS_LIBRARY_VERSION_NUMBER looks like 1005001 for e.g. version 1.5.1 */ -#define LWS_LIBRARY_VERSION_NUMBER (LWS_LIBRARY_VERSION_MAJOR*1000000)+(LWS_LIBRARY_VERSION_MINOR*1000)+LWS_LIBRARY_VERSION_PATCH - -/* The current git commit hash that we're building from */ -#define LWS_BUILD_HASH "james@James-Chen.local-v3.4-138-g60b1a6f" - -/* Build with OpenSSL support */ -#define LWS_OPENSSL_SUPPORT - -/* The client should load and trust CA root certs it finds in the OS */ -#define LWS_SSL_CLIENT_USE_OS_CA_CERTS - -/* Sets the path where the client certs should be installed. */ -#define LWS_OPENSSL_CLIENT_CERTS "../share" - -/* Turn off websocket extensions */ -/* #undef LWS_NO_EXTENSIONS */ - -/* Enable libev io loop */ -/* #undef LWS_USE_LIBEV */ - -/* Enable libuv io loop */ -/* #undef LWS_USE_LIBUV */ - -/* Build with support for ipv6 */ -#define LWS_USE_IPV6 - -/* Build with support for UNIX domain socket */ -/* #undef LWS_USE_UNIX_SOCK */ - -/* Build with support for HTTP2 */ -/* #undef LWS_USE_HTTP2 */ - -/* Turn on latency measuring code */ -/* #undef LWS_LATENCY */ - -/* Don't build the daemonizeation api */ -#define LWS_NO_DAEMONIZE - -/* Build without server support */ -#define LWS_NO_SERVER - -/* Build without client support */ -/* #undef LWS_NO_CLIENT */ - -/* If we should compile with MinGW support */ -/* #undef LWS_MINGW_SUPPORT */ - -/* Use the BSD getifaddrs that comes with libwebsocket, for uclibc support */ -#define LWS_BUILTIN_GETIFADDRS - -/* use SHA1() not internal libwebsockets_SHA1 */ -/* #undef LWS_SHA1_USE_OPENSSL_NAME */ - -/* SSL server using ECDH certificate */ -/* #undef LWS_SSL_SERVER_WITH_ECDH_CERT */ -#define LWS_HAVE_SSL_CTX_set1_param -#define LWS_HAVE_X509_VERIFY_PARAM_set1_host - -/* #undef LWS_HAVE_UV_VERSION_H */ - -/* CGI apis */ -/* #undef LWS_WITH_CGI */ - -/* whether the Openssl is recent enough, and / or built with, ecdh */ -#define LWS_HAVE_OPENSSL_ECDH_H - -/* HTTP Proxy support */ -/* #undef LWS_WITH_HTTP_PROXY */ - -/* Http access log support */ -/* #undef LWS_WITH_ACCESS_LOG */ -/* #undef LWS_WITH_SERVER_STATUS */ - -/* #undef LWS_WITH_STATEFUL_URLDECODE */ - -/* Maximum supported service threads */ -#define LWS_MAX_SMP 32 - -/* Lightweight JSON Parser */ -/* #undef LWS_WITH_LEJP */ - -/* SMTP */ -/* #undef LWS_WITH_SMTP */ - - diff --git a/android/armeabi/include/zlib/zconf.h b/android/armeabi/include/zlib/zconf.h deleted file mode 100644 index 996fff29..00000000 --- a/android/armeabi/include/zlib/zconf.h +++ /dev/null @@ -1,511 +0,0 @@ -/* zconf.h -- configuration of the zlib compression library - * Copyright (C) 1995-2013 Jean-loup Gailly. - * For conditions of distribution and use, see copyright notice in zlib.h - */ - -/* @(#) $Id$ */ - -#ifndef ZCONF_H -#define ZCONF_H - -/* - * If you *really* need a unique prefix for all types and library functions, - * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. - * Even better than compiling with -DZ_PREFIX would be to use configure to set - * this permanently in zconf.h using "./configure --zprefix". - */ -#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */ -# define Z_PREFIX_SET - -/* all linked symbols */ -# define _dist_code z__dist_code -# define _length_code z__length_code -# define _tr_align z__tr_align -# define _tr_flush_bits z__tr_flush_bits -# define _tr_flush_block z__tr_flush_block -# define _tr_init z__tr_init -# define _tr_stored_block z__tr_stored_block -# define _tr_tally z__tr_tally -# define adler32 z_adler32 -# define adler32_combine z_adler32_combine -# define adler32_combine64 z_adler32_combine64 -# ifndef Z_SOLO -# define compress z_compress -# define compress2 z_compress2 -# define compressBound z_compressBound -# endif -# define crc32 z_crc32 -# define crc32_combine z_crc32_combine -# define crc32_combine64 z_crc32_combine64 -# define deflate z_deflate -# define deflateBound z_deflateBound -# define deflateCopy z_deflateCopy -# define deflateEnd z_deflateEnd -# define deflateInit2_ z_deflateInit2_ -# define deflateInit_ z_deflateInit_ -# define deflateParams z_deflateParams -# define deflatePending z_deflatePending -# define deflatePrime z_deflatePrime -# define deflateReset z_deflateReset -# define deflateResetKeep z_deflateResetKeep -# define deflateSetDictionary z_deflateSetDictionary -# define deflateSetHeader z_deflateSetHeader -# define deflateTune z_deflateTune -# define deflate_copyright z_deflate_copyright -# define get_crc_table z_get_crc_table -# ifndef Z_SOLO -# define gz_error z_gz_error -# define gz_intmax z_gz_intmax -# define gz_strwinerror z_gz_strwinerror -# define gzbuffer z_gzbuffer -# define gzclearerr z_gzclearerr -# define gzclose z_gzclose -# define gzclose_r z_gzclose_r -# define gzclose_w z_gzclose_w -# define gzdirect z_gzdirect -# define gzdopen z_gzdopen -# define gzeof z_gzeof -# define gzerror z_gzerror -# define gzflush z_gzflush -# define gzgetc z_gzgetc -# define gzgetc_ z_gzgetc_ -# define gzgets z_gzgets -# define gzoffset z_gzoffset -# define gzoffset64 z_gzoffset64 -# define gzopen z_gzopen -# define gzopen64 z_gzopen64 -# ifdef _WIN32 -# define gzopen_w z_gzopen_w -# endif -# define gzprintf z_gzprintf -# define gzvprintf z_gzvprintf -# define gzputc z_gzputc -# define gzputs z_gzputs -# define gzread z_gzread -# define gzrewind z_gzrewind -# define gzseek z_gzseek -# define gzseek64 z_gzseek64 -# define gzsetparams z_gzsetparams -# define gztell z_gztell -# define gztell64 z_gztell64 -# define gzungetc z_gzungetc -# define gzwrite z_gzwrite -# endif -# define inflate z_inflate -# define inflateBack z_inflateBack -# define inflateBackEnd z_inflateBackEnd -# define inflateBackInit_ z_inflateBackInit_ -# define inflateCopy z_inflateCopy -# define inflateEnd z_inflateEnd -# define inflateGetHeader z_inflateGetHeader -# define inflateInit2_ z_inflateInit2_ -# define inflateInit_ z_inflateInit_ -# define inflateMark z_inflateMark -# define inflatePrime z_inflatePrime -# define inflateReset z_inflateReset -# define inflateReset2 z_inflateReset2 -# define inflateSetDictionary z_inflateSetDictionary -# define inflateGetDictionary z_inflateGetDictionary -# define inflateSync z_inflateSync -# define inflateSyncPoint z_inflateSyncPoint -# define inflateUndermine z_inflateUndermine -# define inflateResetKeep z_inflateResetKeep -# define inflate_copyright z_inflate_copyright -# define inflate_fast z_inflate_fast -# define inflate_table z_inflate_table -# ifndef Z_SOLO -# define uncompress z_uncompress -# endif -# define zError z_zError -# ifndef Z_SOLO -# define zcalloc z_zcalloc -# define zcfree z_zcfree -# endif -# define zlibCompileFlags z_zlibCompileFlags -# define zlibVersion z_zlibVersion - -/* all zlib typedefs in zlib.h and zconf.h */ -# define Byte z_Byte -# define Bytef z_Bytef -# define alloc_func z_alloc_func -# define charf z_charf -# define free_func z_free_func -# ifndef Z_SOLO -# define gzFile z_gzFile -# endif -# define gz_header z_gz_header -# define gz_headerp z_gz_headerp -# define in_func z_in_func -# define intf z_intf -# define out_func z_out_func -# define uInt z_uInt -# define uIntf z_uIntf -# define uLong z_uLong -# define uLongf z_uLongf -# define voidp z_voidp -# define voidpc z_voidpc -# define voidpf z_voidpf - -/* all zlib structs in zlib.h and zconf.h */ -# define gz_header_s z_gz_header_s -# define internal_state z_internal_state - -#endif - -#if defined(__MSDOS__) && !defined(MSDOS) -# define MSDOS -#endif -#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2) -# define OS2 -#endif -#if defined(_WINDOWS) && !defined(WINDOWS) -# define WINDOWS -#endif -#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__) -# ifndef WIN32 -# define WIN32 -# endif -#endif -#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32) -# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__) -# ifndef SYS16BIT -# define SYS16BIT -# endif -# endif -#endif - -/* - * Compile with -DMAXSEG_64K if the alloc function cannot allocate more - * than 64k bytes at a time (needed on systems with 16-bit int). - */ -#ifdef SYS16BIT -# define MAXSEG_64K -#endif -#ifdef MSDOS -# define UNALIGNED_OK -#endif - -#ifdef __STDC_VERSION__ -# ifndef STDC -# define STDC -# endif -# if __STDC_VERSION__ >= 199901L -# ifndef STDC99 -# define STDC99 -# endif -# endif -#endif -#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus)) -# define STDC -#endif -#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__)) -# define STDC -#endif -#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32)) -# define STDC -#endif -#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__)) -# define STDC -#endif - -#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */ -# define STDC -#endif - -#ifndef STDC -# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ -# define const /* note: need a more gentle solution here */ -# endif -#endif - -#if defined(ZLIB_CONST) && !defined(z_const) -# define z_const const -#else -# define z_const -#endif - -/* Some Mac compilers merge all .h files incorrectly: */ -#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__) -# define NO_DUMMY_DECL -#endif - -/* Maximum value for memLevel in deflateInit2 */ -#ifndef MAX_MEM_LEVEL -# ifdef MAXSEG_64K -# define MAX_MEM_LEVEL 8 -# else -# define MAX_MEM_LEVEL 9 -# endif -#endif - -/* Maximum value for windowBits in deflateInit2 and inflateInit2. - * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files - * created by gzip. (Files created by minigzip can still be extracted by - * gzip.) - */ -#ifndef MAX_WBITS -# define MAX_WBITS 15 /* 32K LZ77 window */ -#endif - -/* The memory requirements for deflate are (in bytes): - (1 << (windowBits+2)) + (1 << (memLevel+9)) - that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) - plus a few kilobytes for small objects. For example, if you want to reduce - the default memory requirements from 256K to 128K, compile with - make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" - Of course this will generally degrade compression (there's no free lunch). - - The memory requirements for inflate are (in bytes) 1 << windowBits - that is, 32K for windowBits=15 (default value) plus a few kilobytes - for small objects. -*/ - - /* Type declarations */ - -#ifndef OF /* function prototypes */ -# ifdef STDC -# define OF(args) args -# else -# define OF(args) () -# endif -#endif - -#ifndef Z_ARG /* function prototypes for stdarg */ -# if defined(STDC) || defined(Z_HAVE_STDARG_H) -# define Z_ARG(args) args -# else -# define Z_ARG(args) () -# endif -#endif - -/* The following definitions for FAR are needed only for MSDOS mixed - * model programming (small or medium model with some far allocations). - * This was tested only with MSC; for other MSDOS compilers you may have - * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, - * just define FAR to be empty. - */ -#ifdef SYS16BIT -# if defined(M_I86SM) || defined(M_I86MM) - /* MSC small or medium model */ -# define SMALL_MEDIUM -# ifdef _MSC_VER -# define FAR _far -# else -# define FAR far -# endif -# endif -# if (defined(__SMALL__) || defined(__MEDIUM__)) - /* Turbo C small or medium model */ -# define SMALL_MEDIUM -# ifdef __BORLANDC__ -# define FAR _far -# else -# define FAR far -# endif -# endif -#endif - -#if defined(WINDOWS) || defined(WIN32) - /* If building or using zlib as a DLL, define ZLIB_DLL. - * This is not mandatory, but it offers a little performance increase. - */ -# ifdef ZLIB_DLL -# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500)) -# ifdef ZLIB_INTERNAL -# define ZEXTERN extern __declspec(dllexport) -# else -# define ZEXTERN extern __declspec(dllimport) -# endif -# endif -# endif /* ZLIB_DLL */ - /* If building or using zlib with the WINAPI/WINAPIV calling convention, - * define ZLIB_WINAPI. - * Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI. - */ -# ifdef ZLIB_WINAPI -# ifdef FAR -# undef FAR -# endif -# include <windows.h> - /* No need for _export, use ZLIB.DEF instead. */ - /* For complete Windows compatibility, use WINAPI, not __stdcall. */ -# define ZEXPORT WINAPI -# ifdef WIN32 -# define ZEXPORTVA WINAPIV -# else -# define ZEXPORTVA FAR CDECL -# endif -# endif -#endif - -#if defined (__BEOS__) -# ifdef ZLIB_DLL -# ifdef ZLIB_INTERNAL -# define ZEXPORT __declspec(dllexport) -# define ZEXPORTVA __declspec(dllexport) -# else -# define ZEXPORT __declspec(dllimport) -# define ZEXPORTVA __declspec(dllimport) -# endif -# endif -#endif - -#ifndef ZEXTERN -# define ZEXTERN extern -#endif -#ifndef ZEXPORT -# define ZEXPORT -#endif -#ifndef ZEXPORTVA -# define ZEXPORTVA -#endif - -#ifndef FAR -# define FAR -#endif - -#if !defined(__MACTYPES__) -typedef unsigned char Byte; /* 8 bits */ -#endif -typedef unsigned int uInt; /* 16 bits or more */ -typedef unsigned long uLong; /* 32 bits or more */ - -#ifdef SMALL_MEDIUM - /* Borland C/C++ and some old MSC versions ignore FAR inside typedef */ -# define Bytef Byte FAR -#else - typedef Byte FAR Bytef; -#endif -typedef char FAR charf; -typedef int FAR intf; -typedef uInt FAR uIntf; -typedef uLong FAR uLongf; - -#ifdef STDC - typedef void const *voidpc; - typedef void FAR *voidpf; - typedef void *voidp; -#else - typedef Byte const *voidpc; - typedef Byte FAR *voidpf; - typedef Byte *voidp; -#endif - -#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC) -# include <limits.h> -# if (UINT_MAX == 0xffffffffUL) -# define Z_U4 unsigned -# elif (ULONG_MAX == 0xffffffffUL) -# define Z_U4 unsigned long -# elif (USHRT_MAX == 0xffffffffUL) -# define Z_U4 unsigned short -# endif -#endif - -#ifdef Z_U4 - typedef Z_U4 z_crc_t; -#else - typedef unsigned long z_crc_t; -#endif - -#if 1 /* was set to #if 1 by ./configure */ -# define Z_HAVE_UNISTD_H -#endif - -#if 1 /* was set to #if 1 by ./configure */ -# define Z_HAVE_STDARG_H -#endif - -#ifdef STDC -# ifndef Z_SOLO -# include <sys/types.h> /* for off_t */ -# endif -#endif - -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -# include <stdarg.h> /* for va_list */ -# endif -#endif - -#ifdef _WIN32 -# ifndef Z_SOLO -# include <stddef.h> /* for wchar_t */ -# endif -#endif - -/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and - * "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even - * though the former does not conform to the LFS document), but considering - * both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as - * equivalently requesting no 64-bit operations - */ -#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1 -# undef _LARGEFILE64_SOURCE -#endif - -#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H) -# define Z_HAVE_UNISTD_H -#endif -#ifndef Z_SOLO -# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE) -# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */ -# ifdef VMS -# include <unixio.h> /* for off_t */ -# endif -# ifndef z_off_t -# define z_off_t off_t -# endif -# endif -#endif - -#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0 -# define Z_LFS64 -#endif - -#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64) -# define Z_LARGE64 -#endif - -#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64) -# define Z_WANT64 -#endif - -#if !defined(SEEK_SET) && !defined(Z_SOLO) -# define SEEK_SET 0 /* Seek from beginning of file. */ -# define SEEK_CUR 1 /* Seek from current position. */ -# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#ifndef z_off_t -# define z_off_t long -#endif - -#if !defined(_WIN32) && defined(Z_LARGE64) -# define z_off64_t off64_t -#else -# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO) -# define z_off64_t __int64 -# else -# define z_off64_t z_off_t -# endif -#endif - -/* MVS linker does not support external names larger than 8 bytes */ -#if defined(__MVS__) - #pragma map(deflateInit_,"DEIN") - #pragma map(deflateInit2_,"DEIN2") - #pragma map(deflateEnd,"DEEND") - #pragma map(deflateBound,"DEBND") - #pragma map(inflateInit_,"ININ") - #pragma map(inflateInit2_,"ININ2") - #pragma map(inflateEnd,"INEND") - #pragma map(inflateSync,"INSY") - #pragma map(inflateSetDictionary,"INSEDI") - #pragma map(compressBound,"CMBND") - #pragma map(inflate_table,"INTABL") - #pragma map(inflate_fast,"INFA") - #pragma map(inflate_copyright,"INCOPY") -#endif - -#endif /* ZCONF_H */ diff --git a/android/armeabi/include/zlib/zlib.h b/android/armeabi/include/zlib/zlib.h deleted file mode 100644 index 3e0c7672..00000000 --- a/android/armeabi/include/zlib/zlib.h +++ /dev/null @@ -1,1768 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.8, April 28th, 2013 - - Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 - (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.8" -#define ZLIB_VERNUM 0x1280 -#define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 8 -#define ZLIB_VER_SUBREVISION 0 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed data. - This version of the library supports only one compression method (deflation) - but other algorithms will be added later and will have the same stream - interface. - - Compression can be done in a single step if the buffers are large enough, - or can be done by repeated calls of the compression function. In the latter - case, the application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never crash - even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - z_const Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total number of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total number of bytes output so far */ - - z_const char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has dropped - to zero. It must update next_out and avail_out when avail_out has dropped - to zero. The application must initialize zalloc, zfree and opaque before - calling the init function. All other fields are set by the compression - library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this if - the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers - returned by zalloc for objects of exactly 65536 bytes *must* have their - offset normalized to zero. The default allocation function provided by this - library ensures this (see zutil.c). To reduce memory requirements and avoid - any allocation of 64K objects, at the expense of compression ratio, compile - the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or progress - reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use in the decompressor (particularly - if the decompressor wants to decompress everything in a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -#define Z_TREES 6 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check - is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at all - (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION - requests a default compromise between speed and compression (currently - equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null - if there is no error message. deflateInit does not perform any compression: - this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). Some - output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating avail_in or avail_out accordingly; avail_out should - never be zero before the call. The application can consume the compressed - output when it wants, for example when the output buffer is full (avail_out - == 0), or after each call of deflate(). If deflate returns Z_OK and with - zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumulate before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In - particular avail_in is zero after the call if enough output space has been - provided before the call.) Flushing may degrade compression for some - compression algorithms and so it should be used only when necessary. This - completes the current deflate block and follows it with an empty stored block - that is three bits plus filler bits to the next byte, followed by four bytes - (00 00 ff ff). - - If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the - output buffer, but the output is not aligned to a byte boundary. All of the - input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. - This completes the current deflate block and follows it with an empty fixed - codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed code - block. - - If flush is set to Z_BLOCK, a deflate block is completed and emitted, as - for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to - seven bits of the current block are held to be written as the next byte after - the next deflate block is completed. In this case, the decompressor may not - be provided enough bits at this point in order to complete decompression of - the data provided so far to the compressor. It may need to wait for the next - block to be emitted. This is for advanced applications that need to control - the emission of deflate blocks. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the stream - are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least the - value returned by deflateBound (see below). Then deflate is guaranteed to - return Z_STREAM_END. If not enough output space is provided, deflate will - not return Z_STREAM_END, and it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect the - compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, msg - may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the - exact value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit() does not process any header information -- that is deferred - until inflate() is called. -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing will - resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there is - no more input data or no more space in the output buffer (see below about - the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. The - application can consume the uncompressed output when it wants, for example - when the output buffer is full (avail_out == 0), or after each call of - inflate(). If inflate returns Z_OK and with zero avail_out, it must be - called again after making room in the output buffer because there might be - more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, - Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() - stop if and when it gets to the next deflate block boundary. When decoding - the zlib or gzip format, this will cause inflate() to return immediately - after the header and before the first block. When doing a raw inflate, - inflate() will go ahead and process the first block, and will return when it - gets to the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 if - inflate() is currently decoding the last block in the deflate stream, plus - 128 if inflate() returned immediately after decoding an end-of-block code or - decoding the complete header up to just before the first byte of the deflate - stream. The end-of-block will not be indicated until all of the uncompressed - data from that block has been written to strm->next_out. The number of - unused bits may in general be greater than seven, except when bit 7 of - data_type is set, in which case the number of unused bits will be less than - eight. data_type is set as noted here every time inflate() returns for all - flush options, and so can be used to determine the amount of currently - consumed input in bits. - - The Z_TREES option behaves as Z_BLOCK does, but it also returns when the - end of each deflate block header is reached, before any actual data in that - block is decoded. This allows the caller to determine the length of the - deflate block header for later use in random access within a deflate block. - 256 is added to the value of strm->data_type when inflate() returns - immediately after reaching the end of the deflate block header. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step (a - single call of inflate), the parameter flush should be set to Z_FINISH. In - this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all of the uncompressed data for the - operation to complete. (The size of the uncompressed data may have been - saved by the compressor for this purpose.) The use of Z_FINISH is not - required to perform an inflation in one step. However it may be used to - inform inflate that a faster approach can be used for the single inflate() - call. Z_FINISH also informs inflate to not maintain a sliding window if the - stream completes, which reduces inflate's memory footprint. If the stream - does not complete, either because not all of the stream is provided or not - enough output space is provided, then a sliding window will be allocated and - inflate() can be called again to continue the operation as if Z_NO_FLUSH had - been used. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the effects of the flush parameter in this implementation are - on the return value of inflate() as noted below, when inflate() returns early - when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of - memory for a sliding window when Z_FINISH is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the Adler-32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the Adler-32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() can decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically, if requested when - initializing with inflateInit2(). Any information contained in the gzip - header is not retained, so applications that need that information should - instead use raw inflate, see inflateInit2() below, or inflateBack() and - perform their own processing of the gzip header and trailer. When processing - gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output - producted so far. The CRC-32 is checked against the gzip trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may - then call inflateSync() to look for a good compression block if a partial - recovery of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by the - caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but is - slow and reduces compression ratio; memLevel=9 uses maximum memory for - optimal speed. The default value is 8. See zconf.h for total memory usage - as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is - set to null if there is no error message. deflateInit2 does not perform any - compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. When using the zlib format, this - function must be called immediately after deflateInit, deflateInit2 or - deflateReset, and before any call of deflate. When doing raw deflate, this - function must be called either before any call of deflate, or immediately - after the completion of a deflate block, i.e. after all input has been - consumed and all output has been delivered when using any of the flush - options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The - compressor and decompressor must use exactly the same dictionary (see - inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size - provided in deflateInit or deflateInit2. Thus the strings most likely to be - useful should be put at the end of the dictionary, not at the front. In - addition, the current implementation of deflate will use at most the window - size minus 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if not at a block boundary for raw deflate). deflateSetDictionary does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and can - consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. The - stream will keep the same compression level and any other attributes that - may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different strategy. - If the compression level is changed, the input available so far is - compressed with the old level (and may be flushed); the new level will take - effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to be - compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if - strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() or - deflateInit2(), and after deflateSetHeader(), if used. This would be used - to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). If that first deflate() call is provided the - sourceLen input bytes, an output buffer allocated to the size returned by - deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed - to return Z_STREAM_END. Note that it is possible for the compressed size to - be larger than the value returned by deflateBound() if flush options other - than Z_FINISH or Z_NO_FLUSH are used. -*/ - -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, - unsigned *pending, - int *bits)); -/* - deflatePending() returns the number of bytes and bits of output that have - been generated, but not yet provided in the available output. The bytes not - provided would be due to the available output space having being consumed. - The number of bits of output not provided are between 0 and 7, where they - await more bits to join them in order to fill out a full byte. If pending - or bits are Z_NULL, then those values are not set. - - deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. - */ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the bits - leftover from a previous deflate stream when appending to it. As such, this - function can only be used for raw deflate, and must be used before the first - deflate() call after a deflateInit2() or deflateReset(). bits must be less - than or equal to 16, and that many of the least significant bits of value - will be inserted in the output. - - deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough - room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be zero to request that inflate use the window size in - the zlib header of the compressed stream. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit2 does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit2() does not process any header information -- that is - deferred until inflate() is called. -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called at any - time to set the dictionary. If the provided dictionary is smaller than the - window and there is already data in the window, then the provided dictionary - will amend what's there. The application must insure that the dictionary - that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm, - Bytef *dictionary, - uInt *dictLength)); -/* - Returns the sliding dictionary being maintained by inflate. dictLength is - set to the number of bytes in the dictionary, and that many bytes are copied - to dictionary. dictionary must have enough space, where 32768 bytes is - always enough. If inflateGetDictionary() is called with dictionary equal to - Z_NULL, then only the dictionary length is returned, and nothing is copied. - Similary, if dictLength is Z_NULL, then it is not set. - - inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the - stream state is inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a possible full flush point (see above - for the description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync searches for a 00 00 FF FF pattern in the compressed data. - All full flush points have this pattern, but not all occurrences of this - pattern are full flush points. - - inflateSync returns Z_OK if a possible full flush point has been found, - Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point - has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. The - stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); -/* - This function is the same as inflateReset, but it also permits changing - the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL), or if - the windowBits parameter is invalid. -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - If bits is negative, then the input stream bit buffer is emptied. Then - inflatePrime() can be called again to put bits in the buffer. This is used - to clear out bits leftover after feeding inflate a block description prior - to feeding inflate codes. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); -/* - This function returns two values, one in the lower 16 bits of the return - value, and the other in the remaining upper bits, obtained by shifting the - return value down 16 bits. If the upper value is -1 and the lower value is - zero, then inflate() is currently decoding information outside of a block. - If the upper value is -1 and the lower value is non-zero, then inflate is in - the middle of a stored block, with the lower value equaling the number of - bytes from the input remaining to copy. If the upper value is not -1, then - it is the number of bits back from the current bit position in the input of - the code (literal or length/distance pair) currently being processed. In - that case the lower value is the number of bytes already emitted for that - code. - - A code is being processed if inflate is waiting for more input to complete - decoding of the code, or if it has completed decoding but is waiting for - more output space to write the literal or match data. - - inflateMark() is used to mark locations in the input data for random - access, which may be at bit positions, and to note those cases where the - output of a code may span boundaries of random access blocks. The current - location in the input stream can be determined from avail_in and data_type - as noted in the description for the Z_BLOCK flush parameter for inflate. - - inflateMark returns the value noted above or -1 << 16 if the provided - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be - used to force inflate() to return immediately after header processing is - complete and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When any - of extra, name, or comment are not Z_NULL and the respective field is not - present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the parameters are invalid, Z_MEM_ERROR if the internal state could not be - allocated, or Z_VERSION_ERROR if the version of the library does not match - the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, - z_const unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is potentially more efficient than - inflate() for file i/o applications, in that it avoids copying between the - output and the sliding window by simply making the window itself the output - buffer. inflate() can be faster on modern CPUs when used with large - buffers. inflateBack() trusts the application to not change the output - buffer passed by the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free the - allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the normal - behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format error - in the deflate stream (in which case strm->msg is set to indicate the nature - of the error), or Z_STREAM_ERROR if the stream was not properly initialized. - In the case of Z_BUF_ERROR, an input or output error can be distinguished - using strm->next_in which will be Z_NULL only if in() returned an error. If - strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning - non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() - cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - -#ifndef Z_SOLO - - /* utility functions */ - -/* - The following utility functions are implemented on top of the basic - stream-oriented functions. To simplify the interface, some default options - are assumed (compression level and memory usage, standard memory allocation - functions). The source code of these utility functions can be modified if - you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before a - compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed buffer. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In - the case where there is not enough room, uncompress() will fill the output - buffer with the uncompressed data up to that point. -*/ - - /* gzip file access functions */ - -/* - This library supports reading and writing files in gzip (.gz) format with - an interface similar to that of stdio, using the functions that start with - "gz". The gzip format is different from the zlib format. gzip is a gzip - wrapper, documented in RFC 1952, wrapped around a deflate stream. -*/ - -typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ - -/* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); - - Opens a gzip (.gz) file for reading or writing. The mode parameter is as - in fopen ("rb" or "wb") but can also include a compression level ("wb9") or - a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only - compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' - for fixed code compression as in "wb9F". (See the description of - deflateInit2 for more information about the strategy parameter.) 'T' will - request transparent writing or appending with no compression and not using - the gzip format. - - "a" can be used instead of "w" to request that the gzip stream that will - be written be appended to the file. "+" will result in an error, since - reading and writing to the same gzip file is not supported. The addition of - "x" when writing will create the file exclusively, which fails if the file - already exists. On systems that support it, the addition of "e" when - reading or writing will set the flag to close the file on an execve() call. - - These functions, as well as gzip, will read and decode a sequence of gzip - streams in a file. The append function of gzopen() can be used to create - such a file. (Also see gzflush() for another way to do this.) When - appending, gzopen does not test whether the file begins with a gzip stream, - nor does it look for the end of the gzip streams to begin appending. gzopen - will simply append a gzip stream to the existing file. - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. When - reading, this will be detected automatically by looking for the magic two- - byte gzip header. - - gzopen returns NULL if the file could not be opened, if there was - insufficient memory to allocate the gzFile state, or if an invalid mode was - specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). - errno can be checked to determine if the reason gzopen failed was that the - file could not be opened. -*/ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen associates a gzFile with the file descriptor fd. File descriptors - are obtained from calls like open, dup, creat, pipe or fileno (if the file - has been previously opened with fopen). The mode parameter is as in gzopen. - - The next call of gzclose on the returned gzFile will also close the file - descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor - fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, - mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. If you are using fileno() to get the - file descriptor from a FILE *, then you will have to use dup() to avoid - double-close()ing the file descriptor. Both gzclose() and fclose() will - close the associated file descriptor, so they need to have different file - descriptors. - - gzdopen returns NULL if there was insufficient memory to allocate the - gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not - provided, or '+' was provided), or if fd is -1. The file descriptor is not - used until the next gz* read, write, seek, or close operation, so gzdopen - will not detect if fd is invalid (unless fd is -1). -*/ - -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); -/* - Set the internal buffer size used by this library's functions. The - default buffer size is 8192 bytes. This function must be called after - gzopen() or gzdopen(), and before any other calls that read or write the - file. The buffer memory allocation is always deferred to the first read or - write. Two buffers are allocated, either both of the specified size when - writing, or one of the specified size and the other twice that size when - reading. A larger buffer size of, for example, 64K or 128K bytes will - noticeably increase the speed of decompression (reading). - - The new buffer size also affects the maximum length for gzprintf(). - - gzbuffer() returns 0 on success, or -1 on failure, such as being called - too late. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. If - the input file is not in gzip format, gzread copies the given number of - bytes into the buffer directly from the file. - - After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream. Any number of gzip streams may be - concatenated in the input file, and will all be decompressed by gzread(). - If something other than a gzip stream is encountered after a gzip stream, - that remaining trailing garbage is ignored (and no error is returned). - - gzread can be used to read a gzip file that is being concurrently written. - Upon reaching the end of the input, gzread will return with the available - data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then - gzclearerr can be used to clear the end of file indicator in order to permit - gzread to be tried again. Z_OK indicates that a gzip stream was completed - on the last gzread. Z_BUF_ERROR indicates that the input file ended in the - middle of a gzip stream. Note that gzread does not return -1 in the event - of an incomplete gzip stream. This error is deferred until gzclose(), which - will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip - stream. Alternatively, gzerror can be used before gzclose to detect this - case. - - gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. -*/ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes written or 0 in case of - error. -*/ - -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the arguments to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or 0 in case of error. The number of - uncompressed bytes written is limited to 8191, or one less than the buffer - size given to gzbuffer(). The caller should assure that this limit is not - exceeded. If it is exceeded, then gzprintf() will return an error (0) with - nothing written. In this case, there may also be a buffer overflow with - unpredictable consequences, which is possible only if zlib was compiled with - the insecure functions sprintf() or vsprintf() because the secure snprintf() - or vsnprintf() functions were not available. This can be determined using - zlibCompileFlags(). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or a - newline character is read and transferred to buf, or an end-of-file - condition is encountered. If any characters are read or if len == 1, the - string is terminated with a null character. If no characters are read due - to an end-of-file or len < 1, then the buffer is left untouched. - - gzgets returns buf which is a null-terminated string, or it returns NULL - for end-of-file or in case of error. If there was an error, the contents at - buf are indeterminate. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. gzputc - returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte or -1 - in case of end of file or error. This is implemented as a macro for speed. - As such, it does not do all of the checking the other functions do. I.e. - it does not check to see if file is NULL, nor whether the structure file - points to has been clobbered or not. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read as the first character - on the next read. At least one character of push-back is allowed. - gzungetc() returns the character pushed, or -1 on failure. gzungetc() will - fail if c is -1, and may fail if a character has been pushed but not read - yet. If gzungetc is used immediately after gzopen or gzdopen, at least the - output buffer size of pushed characters is allowed. (See gzbuffer above.) - The pushed character will be discarded if the stream is repositioned with - gzseek() or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter flush - is as in the deflate() function. The return value is the zlib error number - (see function gzerror below). gzflush is only permitted when writing. - - If the flush parameter is Z_FINISH, the remaining data is written and the - gzip stream is completed in the output. If gzwrite() is called again, a new - gzip stream will be started in the output. gzread() is able to read such - concatented gzip streams. - - gzflush should be called only when strictly necessary because it will - degrade compression if called too often. -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); - - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); - - Returns the starting position for the next gzread or gzwrite on the given - compressed file. This position represents a number of bytes in the - uncompressed data stream, and is zero when starting, even if appending or - reading a gzip stream from the middle of a file using gzdopen(). - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); - - Returns the current offset in the file being read or written. This offset - includes the count of bytes that precede the gzip stream, for example when - appending or when using gzdopen() for reading. When reading, the offset - does not include as yet unused buffered input. This information can be used - for a progress indicator. On error, gzoffset() returns -1. -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns true (1) if the end-of-file indicator has been set while reading, - false (0) otherwise. Note that the end-of-file indicator is set only if the - read tried to go past the end of the input, but came up short. Therefore, - just like feof(), gzeof() may return false even if there is no more data to - read, in the event that the last read request was for the exact number of - bytes remaining in the input file. This will happen if the input file size - is an exact multiple of the buffer size. - - If gzeof() returns true, then the read functions will return no more data, - unless the end-of-file indicator is reset by gzclearerr() and the input file - has grown since the previous end of file was detected. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. - - If the input file is empty, gzdirect() will return true, since the input - does not contain a gzip stream. - - If gzdirect() is used immediately after gzopen() or gzdopen() it will - cause buffers to be allocated to allow reading the file to determine if it - is a gzip file. Therefore if gzbuffer() is used, it should be called before - gzdirect(). - - When writing, gzdirect() returns true (1) if transparent writing was - requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: - gzdirect() is not needed when writing. Transparent writing must be - explicitly requested, so the application already knows the answer. When - linking statically, using gzdirect() will include all of the zlib code for - gzip file reading and decompression, which may not be desired.) -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file and - deallocates the (de)compression state. Note that once file is closed, you - cannot call gzerror with file, since its structures have been deallocated. - gzclose must not be called more than once on the same file, just as free - must not be called more than once on the same allocation. - - gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the - last read ended in the middle of a gzip stream, or Z_OK on success. -*/ - -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); -/* - Same as gzclose(), but gzclose_r() is only for use when reading, and - gzclose_w() is only for use when writing or appending. The advantage to - using these instead of gzclose() is that they avoid linking in zlib - compression or decompression code that is not used when only reading or only - writing respectively. If gzclose() is used, then both compression and - decompression code will be included the application when linking to a static - zlib library. -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the given - compressed file. errnum is set to zlib error number. If an error occurred - in the file system and not in the compression library, errnum is set to - Z_ERRNO and the application may consult errno to get the exact error code. - - The application must not modify the returned string. Future calls to - this function may invalidate the previously returned string. If file is - closed, then the string previously returned by gzerror will no longer be - available. - - gzerror() should be used to distinguish errors from end-of-file for those - functions above that do not distinguish those cases in their return values. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - -#endif /* !Z_SOLO */ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the compression - library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is Z_NULL, this function returns the - required initial value for the checksum. - - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. - - Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); - - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note - that the z_off_t type (like off_t) is a signed integer. If len2 is - negative, the result has no meaning or utility. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the crc. Pre- and post-conditioning (one's complement) is - performed within this function so it shouldn't be done by the application. - - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) - -#ifndef Z_SOLO - -/* gzgetc() macro and its supporting function and exposed data structure. Note - * that the real internal state is much larger than the exposed structure. - * This abbreviated structure exposes just enough for the gzgetc() macro. The - * user should not mess with these exposed elements, since their names or - * behavior could change in the future, perhaps even capriciously. They can - * only be used by the gzgetc() macro. You have been warned. - */ -struct gzFile_s { - unsigned have; - unsigned char *next; - z_off64_t pos; -}; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */ -#ifdef Z_PREFIX_SET -# undef z_gzgetc -# define z_gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) -#else -# define gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g)) -#endif - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#ifdef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); -#endif - -#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64) -# ifdef Z_PREFIX_SET -# define z_gzopen z_gzopen64 -# define z_gzseek z_gzseek64 -# define z_gztell z_gztell64 -# define z_gzoffset z_gzoffset64 -# define z_adler32_combine z_adler32_combine64 -# define z_crc32_combine z_crc32_combine64 -# else -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# endif -# ifndef Z_LARGE64 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -# endif -#else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); -#endif - -#else /* Z_SOLO */ - - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - -#endif /* !Z_SOLO */ - -/* hack for buggy compilers */ -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; -#endif - -/* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); -#if defined(_WIN32) && !defined(Z_SOLO) -ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path, - const char *mode)); -#endif -#if defined(STDC) || defined(Z_HAVE_STDARG_H) -# ifndef Z_SOLO -ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file, - const char *format, - va_list va)); -# endif -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/android/armeabi/libPluginProtocolStatic.a b/android/armeabi/libPluginProtocolStatic.a deleted file mode 100644 index 37ec6ae1..00000000 Binary files a/android/armeabi/libPluginProtocolStatic.a and /dev/null differ diff --git a/android/armeabi/libchipmunk.a b/android/armeabi/libchipmunk.a deleted file mode 100644 index 1372ba20..00000000 Binary files a/android/armeabi/libchipmunk.a and /dev/null differ diff --git a/android/armeabi/libcrypto.a b/android/armeabi/libcrypto.a deleted file mode 100644 index 0e3e28d6..00000000 Binary files a/android/armeabi/libcrypto.a and /dev/null differ diff --git a/android/armeabi/libfreetype.a b/android/armeabi/libfreetype.a deleted file mode 100644 index 29b306c1..00000000 Binary files a/android/armeabi/libfreetype.a and /dev/null differ diff --git a/android/armeabi/libinspector.a b/android/armeabi/libinspector.a deleted file mode 100644 index 8423370f..00000000 Binary files a/android/armeabi/libinspector.a and /dev/null differ diff --git a/android/armeabi/libjpeg.a b/android/armeabi/libjpeg.a deleted file mode 100644 index 96fc4c19..00000000 Binary files a/android/armeabi/libjpeg.a and /dev/null differ diff --git a/android/armeabi/libjs_static.a b/android/armeabi/libjs_static.a deleted file mode 100644 index fe713fdf..00000000 Binary files a/android/armeabi/libjs_static.a and /dev/null differ diff --git a/android/armeabi/libmozglue.a b/android/armeabi/libmozglue.a deleted file mode 100644 index f9539188..00000000 Binary files a/android/armeabi/libmozglue.a and /dev/null differ diff --git a/android/armeabi/libpng.a b/android/armeabi/libpng.a deleted file mode 100644 index dd34c650..00000000 Binary files a/android/armeabi/libpng.a and /dev/null differ diff --git a/android/armeabi/libssl.a b/android/armeabi/libssl.a deleted file mode 100644 index 7a206297..00000000 Binary files a/android/armeabi/libssl.a and /dev/null differ diff --git a/android/armeabi/libtiff.a b/android/armeabi/libtiff.a deleted file mode 100644 index 3ee1176f..00000000 Binary files a/android/armeabi/libtiff.a and /dev/null differ diff --git a/android/armeabi/libuv.a b/android/armeabi/libuv.a deleted file mode 100644 index 06b5dd0d..00000000 Binary files a/android/armeabi/libuv.a and /dev/null differ diff --git a/android/armeabi/libv8_base.a b/android/armeabi/libv8_base.a deleted file mode 100644 index 5381314f..00000000 Binary files a/android/armeabi/libv8_base.a and /dev/null differ diff --git a/android/armeabi/libv8_builtins_generators.a b/android/armeabi/libv8_builtins_generators.a deleted file mode 100644 index 3cdfa880..00000000 Binary files a/android/armeabi/libv8_builtins_generators.a and /dev/null differ diff --git a/android/armeabi/libv8_builtins_setup.a b/android/armeabi/libv8_builtins_setup.a deleted file mode 100644 index 4a165c10..00000000 Binary files a/android/armeabi/libv8_builtins_setup.a and /dev/null differ diff --git a/android/armeabi/libv8_libbase.a b/android/armeabi/libv8_libbase.a deleted file mode 100644 index 502e3a54..00000000 Binary files a/android/armeabi/libv8_libbase.a and /dev/null differ diff --git a/android/armeabi/libv8_libplatform.a b/android/armeabi/libv8_libplatform.a deleted file mode 100644 index c4887047..00000000 Binary files a/android/armeabi/libv8_libplatform.a and /dev/null differ diff --git a/android/armeabi/libv8_libsampler.a b/android/armeabi/libv8_libsampler.a deleted file mode 100644 index 857fb8ee..00000000 Binary files a/android/armeabi/libv8_libsampler.a and /dev/null differ diff --git a/android/armeabi/libv8_nosnapshot.a b/android/armeabi/libv8_nosnapshot.a deleted file mode 100644 index 09847897..00000000 Binary files a/android/armeabi/libv8_nosnapshot.a and /dev/null differ diff --git a/android/armeabi/libwebp.a b/android/armeabi/libwebp.a deleted file mode 100644 index 3a0158d9..00000000 Binary files a/android/armeabi/libwebp.a and /dev/null differ diff --git a/android/armeabi/libwebsockets.a b/android/armeabi/libwebsockets.a deleted file mode 100644 index ceae680c..00000000 Binary files a/android/armeabi/libwebsockets.a and /dev/null differ diff --git a/android/armeabi/libz.a b/android/armeabi/libz.a deleted file mode 100644 index 4eb8ac37..00000000 Binary files a/android/armeabi/libz.a and /dev/null differ