diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2017-12-24 15:26:43 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2017-12-24 15:26:43 +0800 |
commit | 77fa156b15dbc0cdec2cdd30793f67b9aa37bc95 (patch) | |
tree | 0915a1209c7d78d385daeb554d3b55f0c53eb78d | |
parent | 3d693792d46545518eacaa09ce488b3d37b71af8 (diff) | |
download | tangerine-mcl-77fa156b15dbc0cdec2cdd30793f67b9aa37bc95.tar.gz tangerine-mcl-77fa156b15dbc0cdec2cdd30793f67b9aa37bc95.tar.zst tangerine-mcl-77fa156b15dbc0cdec2cdd30793f67b9aa37bc95.zip |
remove old deserialize apinew_deserialize_api
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | include/mcl/bn.h | 16 | ||||
-rw-r--r-- | src/bn_c_impl.hpp | 18 | ||||
-rw-r--r-- | test/bn_c_test.hpp | 36 |
4 files changed, 10 insertions, 62 deletions
@@ -221,7 +221,7 @@ endif emcc -o $@ src/fp.cpp src/she_c256.cpp $(EMCC_OPT) -s TOTAL_MEMORY=67108864 ../mcl-wasm/mcl_c.js: src/fp.cpp src/bn_c256.cpp include/mcl/bn.h Makefile - emcc -o $@ src/fp.cpp src/bn_c256.cpp $(EMCC_OPT) -DMCLBN_USE_NEW_DESERIALIZE_API + emcc -o $@ src/fp.cpp src/bn_c256.cpp $(EMCC_OPT) clean: $(RM) $(MCL_LIB) $(MCL_SLIB) $(BN256_LIB) $(BN256_SLIB) $(BN384_LIB) $(BN384_SLIB) $(OBJ_DIR)/*.o $(OBJ_DIR)/*.d $(EXE_DIR)/*.exe $(GEN_EXE) $(ASM_OBJ) $(LIB_OBJ) $(BN256_OBJ) $(BN384_OBJ) $(LLVM_SRC) $(FUNC_LIST) src/*.ll diff --git a/include/mcl/bn.h b/include/mcl/bn.h index 91bb9cb..75b1baa 100644 --- a/include/mcl/bn.h +++ b/include/mcl/bn.h @@ -42,14 +42,6 @@ #endif #endif -#ifdef MCLBN_USE_NEW_DESERIALIZE_API - // return read size if sucess else 0 - typedef mclSize mclRetType; -#else - // return 0 if success else -1 - typedef int mclRetType; -#endif - #ifdef __cplusplus extern "C" { #endif @@ -154,7 +146,7 @@ MCLBN_DLL_API void mclBnFr_setInt32(mclBnFr *y, int x); */ // return 0 if success MCLBN_DLL_API int mclBnFr_setStr(mclBnFr *x, const char *buf, mclSize bufSize, int ioMode); -MCLBN_DLL_API mclRetType mclBnFr_deserialize(mclBnFr *x, const void *buf, mclSize bufSize); +MCLBN_DLL_API mclSize mclBnFr_deserialize(mclBnFr *x, const void *buf, mclSize bufSize); // mask buf with (1 << (bitLen(r) - 1)) - 1 if buf >= r MCLBN_DLL_API int mclBnFr_setLittleEndian(mclBnFr *x, const void *buf, mclSize bufSize); @@ -189,7 +181,7 @@ MCLBN_DLL_API void mclBnG1_clear(mclBnG1 *x); // return 0 if success MCLBN_DLL_API int mclBnG1_setStr(mclBnG1 *x, const char *buf, mclSize bufSize, int ioMode); -MCLBN_DLL_API mclRetType mclBnG1_deserialize(mclBnG1 *x, const void *buf, mclSize bufSize); +MCLBN_DLL_API mclSize mclBnG1_deserialize(mclBnG1 *x, const void *buf, mclSize bufSize); // return 1 if true and 0 otherwise MCLBN_DLL_API int mclBnG1_isValid(const mclBnG1 *x); @@ -220,7 +212,7 @@ MCLBN_DLL_API void mclBnG2_clear(mclBnG2 *x); // return 0 if success MCLBN_DLL_API int mclBnG2_setStr(mclBnG2 *x, const char *buf, mclSize bufSize, int ioMode); -MCLBN_DLL_API mclRetType mclBnG2_deserialize(mclBnG2 *x, const void *buf, mclSize bufSize); +MCLBN_DLL_API mclSize mclBnG2_deserialize(mclBnG2 *x, const void *buf, mclSize bufSize); // return 1 if true and 0 otherwise MCLBN_DLL_API int mclBnG2_isValid(const mclBnG2 *x); @@ -253,7 +245,7 @@ MCLBN_DLL_API void mclBnGT_setInt32(mclBnGT *y, int x); // return 0 if success MCLBN_DLL_API int mclBnGT_setStr(mclBnGT *x, const char *buf, mclSize bufSize, int ioMode); -MCLBN_DLL_API mclRetType mclBnGT_deserialize(mclBnGT *x, const void *buf, mclSize bufSize); +MCLBN_DLL_API mclSize mclBnGT_deserialize(mclBnGT *x, const void *buf, mclSize bufSize); // return 1 if true and 0 otherwise MCLBN_DLL_API int mclBnGT_isEqual(const mclBnGT *x, const mclBnGT *y); diff --git a/src/bn_c_impl.hpp b/src/bn_c_impl.hpp index 4cfb4a8..a6d634f 100644 --- a/src/bn_c_impl.hpp +++ b/src/bn_c_impl.hpp @@ -90,22 +90,14 @@ int setStr(T *x, const char *buf, mclSize bufSize, int ioMode, const char *msg) } template<class T> -mclRetType deserialize(T *x, const void *buf, mclSize bufSize, const char *msg) +mclSize deserialize(T *x, const void *buf, mclSize bufSize, const char *msg) try { const size_t n = cast(x)->deserialize(buf, bufSize); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API return (mclSize)n; -#else - return n ? 0 : -1; -#endif } catch (std::exception& e) { if (g_fp) fprintf(g_fp, "%s %s\n", msg, e.what()); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API return 0; -#else - return -1; -#endif } int mclBn_setErrFile(const char *name) @@ -219,7 +211,7 @@ int mclBnFr_setLittleEndian(mclBnFr *x, const void *buf, mclSize bufSize) if (g_fp) fprintf(g_fp, "setArrayMask %s\n", e.what()); return -1; } -mclRetType mclBnFr_deserialize(mclBnFr *x, const void *buf, mclSize bufSize) +mclSize mclBnFr_deserialize(mclBnFr *x, const void *buf, mclSize bufSize) { return deserialize(x, buf, bufSize, "mclBnFr_deserialize"); } @@ -307,7 +299,7 @@ int mclBnG1_setStr(mclBnG1 *x, const char *buf, mclSize bufSize, int ioMode) { return setStr(x, buf, bufSize, ioMode, "mclBnG1_setStr"); } -mclRetType mclBnG1_deserialize(mclBnG1 *x, const void *buf, mclSize bufSize) +mclSize mclBnG1_deserialize(mclBnG1 *x, const void *buf, mclSize bufSize) { return deserialize(x, buf, bufSize, "mclBnG1_deserialize"); } @@ -382,7 +374,7 @@ int mclBnG2_setStr(mclBnG2 *x, const char *buf, mclSize bufSize, int ioMode) { return setStr(x, buf, bufSize, ioMode, "mclBnG2_setStr"); } -mclRetType mclBnG2_deserialize(mclBnG2 *x, const void *buf, mclSize bufSize) +mclSize mclBnG2_deserialize(mclBnG2 *x, const void *buf, mclSize bufSize) { return deserialize(x, buf, bufSize, "mclBnG2_deserialize"); } @@ -466,7 +458,7 @@ int mclBnGT_setStr(mclBnGT *x, const char *buf, mclSize bufSize, int ioMode) { return setStr(x, buf, bufSize, ioMode, "mclBnGT_setStr"); } -mclRetType mclBnGT_deserialize(mclBnGT *x, const void *buf, mclSize bufSize) +mclSize mclBnGT_deserialize(mclBnGT *x, const void *buf, mclSize bufSize) { return deserialize(x, buf, bufSize, "mclBnGT_deserialize"); } diff --git a/test/bn_c_test.hpp b/test/bn_c_test.hpp index 1840cb5..c1ef2b1 100644 --- a/test/bn_c_test.hpp +++ b/test/bn_c_test.hpp @@ -344,27 +344,15 @@ CYBOZU_TEST_AUTO(serialize) CYBOZU_TEST_EQUAL(n, expectSize); ret = mclBnFr_deserialize(&x2, buf, n); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API CYBOZU_TEST_EQUAL(ret, n); -#else - CYBOZU_TEST_EQUAL(ret, 0); -#endif CYBOZU_TEST_ASSERT(mclBnFr_isEqual(&x1, &x2)); ret = mclBnFr_deserialize(&x2, buf, n - 1); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API CYBOZU_TEST_EQUAL(ret, 0); -#else - CYBOZU_TEST_ASSERT(ret != 0); -#endif memset(&x2, 0, sizeof(x2)); ret = mclBnFr_deserialize(&x2, buf, n + 1); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API CYBOZU_TEST_EQUAL(ret, n); -#else - CYBOZU_TEST_EQUAL(ret, 0); -#endif CYBOZU_TEST_ASSERT(mclBnFr_isEqual(&x1, &x2)); n = mclBnFr_serialize(buf, expectSize, &x1); @@ -377,27 +365,15 @@ CYBOZU_TEST_AUTO(serialize) CYBOZU_TEST_EQUAL(n, expectSize); ret = mclBnG1_deserialize(&P2, buf, n); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API CYBOZU_TEST_EQUAL(ret, n); -#else - CYBOZU_TEST_EQUAL(ret, 0); -#endif CYBOZU_TEST_ASSERT(mclBnG1_isEqual(&P1, &P2)); ret = mclBnG1_deserialize(&P2, buf, n - 1); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API CYBOZU_TEST_EQUAL(ret, 0); -#else - CYBOZU_TEST_ASSERT(ret != 0); -#endif memset(&P2, 0, sizeof(P2)); ret = mclBnG1_deserialize(&P2, buf, n + 1); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API CYBOZU_TEST_EQUAL(ret, n); -#else - CYBOZU_TEST_EQUAL(ret, 0); -#endif CYBOZU_TEST_ASSERT(mclBnG1_isEqual(&P1, &P2)); n = mclBnG1_serialize(buf, expectSize, &P1); @@ -410,27 +386,15 @@ CYBOZU_TEST_AUTO(serialize) CYBOZU_TEST_EQUAL(n, expectSize); ret = mclBnG2_deserialize(&Q2, buf, n); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API CYBOZU_TEST_EQUAL(ret, n); -#else - CYBOZU_TEST_EQUAL(ret, 0); -#endif CYBOZU_TEST_ASSERT(mclBnG2_isEqual(&Q1, &Q2)); ret = mclBnG2_deserialize(&Q2, buf, n - 1); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API CYBOZU_TEST_EQUAL(ret, 0); -#else - CYBOZU_TEST_ASSERT(ret != 0); -#endif memset(&Q2, 0, sizeof(Q2)); ret = mclBnG2_deserialize(&Q2, buf, n + 1); -#ifdef MCLBN_USE_NEW_DESERIALIZE_API CYBOZU_TEST_EQUAL(ret, n); -#else - CYBOZU_TEST_EQUAL(ret, 0); -#endif CYBOZU_TEST_ASSERT(mclBnG2_isEqual(&Q1, &Q2)); n = mclBnG2_serialize(buf, expectSize, &Q1); |