OSDN Git Service

core component can be build as all-in-one now
authorIvailo Monev <xakepa10@laimg.moc>
Fri, 26 Aug 2016 14:36:42 +0000 (14:36 +0000)
committerIvailo Monev <xakepa10@laimg.moc>
Fri, 26 Aug 2016 14:36:42 +0000 (14:36 +0000)
Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
src/3rdparty/sha3/KeccakNISTInterface.c
src/3rdparty/sha3/KeccakNISTInterface.h
src/core/CMakeLists.txt
src/core/global/qglobal.cpp
src/core/kernel/qsystemerror.cpp
src/core/qcorecommon_p.h [new file with mode: 0644]
src/core/tools/qcryptographichash.cpp
src/core/tools/tools.cmake

index 1b3a728..706bf65 100644 (file)
@@ -15,7 +15,7 @@ http://creativecommons.org/publicdomain/zero/1.0/
 //#include "KeccakNISTInterface.h"
 #include "KeccakF-1600-interface.h"
 
-static HashReturn Init(hashState *state, int hashbitlen)
+static HashReturn s3Init(hashState *state, int hashbitlen)
 {
     switch(hashbitlen) {
         case 0: // Default parameters, arbitrary length output
@@ -40,7 +40,7 @@ static HashReturn Init(hashState *state, int hashbitlen)
     return SUCCESS;
 }
 
-static HashReturn Update(hashState *state, const BitSequence *data, DataLength databitlen)
+static HashReturn s3Update(hashState *state, const BitSequence *data, DataLength databitlen)
 {
     if ((databitlen % 8) == 0)
         return (HashReturn) Absorb((spongeState*)state, data, databitlen);
@@ -57,26 +57,26 @@ static HashReturn Update(hashState *state, const BitSequence *data, DataLength d
     }
 }
 
-static HashReturn Final(hashState *state, BitSequence *hashval)
+static HashReturn s3Final(hashState *state, BitSequence *hashval)
 {
     return (HashReturn) Squeeze(state, hashval, state->fixedOutputLength);
 }
 
 #ifndef QT_KATIE
-static HashReturn Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval)
+static HashReturn s3Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval)
 {
     hashState state;
     HashReturn result;
 
     if ((hashbitlen != 224) && (hashbitlen != 256) && (hashbitlen != 384) && (hashbitlen != 512))
         return BAD_HASHLEN; // Only the four fixed output lengths available through this API
-    result = Init(&state, hashbitlen);
+    result = s3Init(&state, hashbitlen);
     if (result != SUCCESS)
         return result;
-    result = Update(&state, data, databitlen);
+    result = s3Update(&state, data, databitlen);
     if (result != SUCCESS)
         return result;
-    result = Final(&state, hashval);
+    result = s3Final(&state, hashval);
     return result;
 }
 #endif
index cd85f24..5a9de94 100644 (file)
@@ -32,7 +32,7 @@ typedef spongeState hashState;
   * @pre    The value of hashbitlen must be one of 0, 224, 256, 384 and 512.
   * @return SUCCESS if successful, BAD_HASHLEN if the value of hashbitlen is incorrect.
   */
-static HashReturn Init(hashState *state, int hashbitlen);
+static HashReturn s3Init(hashState *state, int hashbitlen);
 /**
   * Function to give input data for the sponge function to absorb.
   * @param  state       Pointer to the state of the sponge function initialized by Init().
@@ -43,7 +43,7 @@ static HashReturn Init(hashState *state, int hashbitlen);
   * @pre    In the previous call to Absorb(), databitLen was a multiple of 8.
   * @return SUCCESS if successful, FAIL otherwise.
   */
-static HashReturn Update(hashState *state, const BitSequence *data, DataLength databitlen);
+static HashReturn s3Update(hashState *state, const BitSequence *data, DataLength databitlen);
 /**
   * Function to squeeze output data from the sponge function.
   * If @a hashbitlen was not 0 in the call to Init(), the number of output bits is equal to @a hashbitlen.
@@ -52,7 +52,7 @@ static HashReturn Update(hashState *state, const BitSequence *data, DataLength d
   * @param  hashval     Pointer to the buffer where to store the output data.
   * @return SUCCESS if successful, FAIL otherwise.
   */
-static HashReturn Final(hashState *state, BitSequence *hashval);
+static HashReturn s3Final(hashState *state, BitSequence *hashval);
 /**
   * Function to compute a hash using the Keccak[r, c] sponge function.
   * The rate r and capacity c values are determined from @a hashbitlen.
@@ -65,6 +65,6 @@ static HashReturn Final(hashState *state, BitSequence *hashval);
   * @pre    The value of hashbitlen must be one of 224, 256, 384 and 512.
   * @return SUCCESS if successful, BAD_HASHLEN if the value of hashbitlen is incorrect.
   */
-static HashReturn Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval);
+static HashReturn s3Hash(int hashbitlen, const BitSequence *data, DataLength databitlen, BitSequence *hashval);
 
 #endif
index 8b5e0d9..946ff67 100644 (file)
@@ -364,12 +364,50 @@ if(WITH_THREADS AND THREADS_FOUND)
     )
 endif()
 
+set(CORE_HEADERS
+    ${CORE_HEADERS}
+    ${CMAKE_CURRENT_SOURCE_DIR}/qcorecommon_p.h
+)
+
 katie_generate_misc("${CORE_HEADERS}" QtCore)
 katie_generate_public("${CORE_PUBLIC_HEADERS}" QtCore)
 katie_setup_paths()
 katie_generate_package(KtCore "")
 katie_setup_target(KtCore ${CORE_SOURCES} ${CORE_HEADERS})
 
+# those are set after katie_setup_target() because they are known to cause
+# trouble for all-in-one-build
+if(WITH_HARFBUZZ AND HARFBUZZ_FOUND)
+    set(EXTRA_CORE_LIBS
+        ${EXTRA_CORE_LIBS}
+        ${HARFBUZZ_LIBRARIES}
+    )
+    include_directories(${HARFBUZZ_INCLUDE_DIRS})
+else()
+    # TODO: move to main CMakeLists?
+    add_definitions(-DHB_EXPORT=Q_CORE_EXPORT)
+    set(CORE_HEADERS
+        ${CORE_HEADERS}
+        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz.h
+        ${CMAKE_CURRENT_SOURCE_DIR}/tools/qharfbuzz_p.h
+    )
+    set(KtCore_SOURCES
+        ${KtCore_SOURCES}
+        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-buffer.c
+        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-gdef.c
+        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-gsub.c
+        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c
+        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-impl.c
+        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-open.c
+        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-stream.c
+        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-shaper-all.cpp
+        ${CMAKE_CURRENT_SOURCE_DIR}/tools/qharfbuzz.cpp
+    )
+    include_directories(
+        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src
+    )
+endif()
+
 add_library(KtCore ${KATIE_TYPE} ${KtCore_SOURCES})
 target_link_libraries(KtCore ${EXTRA_CORE_LIBS})
 set_target_properties(KtCore PROPERTIES
index f2e1559..622d9e1 100644 (file)
@@ -48,7 +48,8 @@
 #include "qstringlist.h"
 #include "qdatetime.h"
 
-#include <qsystemlibrary_p.h>
+#include "qsystemlibrary_p.h"
+#include "qcorecommon_p.h"
 
 #ifndef QT_NO_QOBJECT
 #include <qthread_p.h>
@@ -2074,29 +2075,6 @@ static void slog2_default_handler(QtMsgType msgType, const char *message)
 }
 #endif // QT_USE_SLOG2
 
-#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \
-    defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
-namespace {
-    // There are two incompatible versions of strerror_r:
-    // a) the XSI/POSIX.1 version, which returns an int,
-    //    indicating success or not
-    // b) the GNU version, which returns a char*, which may or may not
-    //    be the beginning of the buffer we used
-    // The GNU libc manpage for strerror_r says you should use the the XSI
-    // version in portable code. However, it's impossible to do that if
-    // _GNU_SOURCE is defined so we use C++ overloading to decide what to do
-    // depending on the return type
-    static inline QString fromstrerror_helper(int, const QByteArray &buf)
-    {
-        return QString::fromLocal8Bit(buf);
-    }
-    static inline QString fromstrerror_helper(const char *str, const QByteArray &)
-    {
-        return QString::fromLocal8Bit(str);
-    }
-}
-#endif
-
 QString qt_error_string(int errorCode)
 {
     const char *s = 0;
index 0af4647..bae0a6f 100644 (file)
 **
 ****************************************************************************/
 
-#include <qglobal.h>
+#include "qglobal.h"
 #include "qsystemerror_p.h"
+#include "qcorecommon_p.h"
+
 #if !defined(Q_OS_WINCE)
 #  include <errno.h>
 #  if defined(Q_CC_MSVC)
 
 QT_BEGIN_NAMESPACE
 
-#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \
-    defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
-namespace {
-    // There are two incompatible versions of strerror_r:
-    // a) the XSI/POSIX.1 version, which returns an int,
-    //    indicating success or not
-    // b) the GNU version, which returns a char*, which may or may not
-    //    be the beginning of the buffer we used
-    // The GNU libc manpage for strerror_r says you should use the the XSI
-    // version in portable code. However, it's impossible to do that if
-    // _GNU_SOURCE is defined so we use C++ overloading to decide what to do
-    // depending on the return type
-    static inline QString fromstrerror_helper(int, const QByteArray &buf)
-    {
-        return QString::fromLocal8Bit(buf);
-    }
-    static inline QString fromstrerror_helper(const char *str, const QByteArray &)
-    {
-        return QString::fromLocal8Bit(str);
-    }
-}
-#endif
-
 #ifdef Q_OS_WIN
 static QString windowsErrorString(int errorCode)
 {
diff --git a/src/core/qcorecommon_p.h b/src/core/qcorecommon_p.h
new file mode 100644 (file)
index 0000000..ee7af60
--- /dev/null
@@ -0,0 +1,29 @@
+#ifndef QCORECOMMON_P_H
+#define QCORECOMMON_P_H
+
+#include "qstring.h"
+
+#if !defined(Q_OS_WIN) && !defined(QT_NO_THREAD) && !defined(Q_OS_INTEGRITY) && !defined(Q_OS_QNX) && \
+    defined(_POSIX_THREAD_SAFE_FUNCTIONS) && _POSIX_VERSION >= 200112L
+namespace {
+    // There are two incompatible versions of strerror_r:
+    // a) the XSI/POSIX.1 version, which returns an int,
+    //    indicating success or not
+    // b) the GNU version, which returns a char*, which may or may not
+    //    be the beginning of the buffer we used
+    // The GNU libc manpage for strerror_r says you should use the the XSI
+    // version in portable code. However, it's impossible to do that if
+    // _GNU_SOURCE is defined so we use C++ overloading to decide what to do
+    // depending on the return type
+    static inline QString fromstrerror_helper(int, const QByteArray &buf)
+    {
+        return QString::fromLocal8Bit(buf);
+    }
+    static inline QString fromstrerror_helper(const char *str, const QByteArray &)
+    {
+        return QString::fromLocal8Bit(str);
+    }
+}
+#endif
+
+#endif // QCORECOMMON_P_H
index 466333a..6d78fdd 100644 (file)
@@ -66,22 +66,13 @@ typedef HashReturn (SHA3Update)(hashState *state, const BitSequence *data, DataL
 typedef HashReturn (SHA3Final)(hashState *state, BitSequence *hashval);
 
 #if QT_POINTER_SIZE == 8 // 64 bit version
-
 #include "../../3rdparty/sha3/KeccakF-1600-opt64.c"
-
-static SHA3Init * const sha3Init = Init;
-static SHA3Update * const sha3Update = Update;
-static SHA3Final * const sha3Final = Final;
-
 #else // 32 bit optimised fallback
-
 #include "../../3rdparty/sha3/KeccakF-1600-opt32.c"
-
-static SHA3Init * const sha3Init = Init;
-static SHA3Update * const sha3Update = Update;
-static SHA3Final * const sha3Final = Final;
-
 #endif
+static SHA3Init * const sha3Init = s3Init;
+static SHA3Update * const sha3Update = s3Update;
+static SHA3Final * const sha3Final = s3Final;
 
 /*
     These #defines replace the typedefs needed by the RFC6234 code. Normally
index bfc4c8d..9757e08 100644 (file)
@@ -140,37 +140,6 @@ if(WITH_ICU AND ICU_FOUND)
     include_directories(${ICU_INCLUDES})
 endif()
 
-if(WITH_HARFBUZZ AND HARFBUZZ_FOUND)
-    set(EXTRA_CORE_LIBS
-        ${EXTRA_CORE_LIBS}
-        ${HARFBUZZ_LIBRARIES}
-    )
-    include_directories(${HARFBUZZ_INCLUDE_DIRS})
-else()
-    # TODO: move to main CMakeLists?
-    add_definitions(-DHB_EXPORT=Q_CORE_EXPORT)
-    set(CORE_HEADERS
-        ${CORE_HEADERS}
-        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz.h
-        ${CMAKE_CURRENT_SOURCE_DIR}/tools/qharfbuzz_p.h
-    )
-    set(CORE_SOURCES
-        ${CORE_SOURCES}
-        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-buffer.c
-        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-gdef.c
-        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-gsub.c
-        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-gpos.c
-        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-impl.c
-        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-open.c
-        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-stream.c
-        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src/harfbuzz-shaper-all.cpp
-        ${CMAKE_CURRENT_SOURCE_DIR}/tools/qharfbuzz.cpp
-    )
-    include_directories(
-        ${CMAKE_SOURCE_DIR}/src/3rdparty/harfbuzz/src
-    )
-endif()
-
 # Note: libm should be present by default becaue this is C++
 if(NOT KATIE_PLATFORM MATCHES "(mac|vxworks)" AND UNIX)
     set(EXTRA_CORE_LIBS