Skip to content

Commit

Permalink
patch relic to be compatible with wasm
Browse files Browse the repository at this point in the history
  • Loading branch information
fominok committed Sep 16, 2022
1 parent bcce0b2 commit 881e6d7
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ FetchContent_Declare(
GIT_TAG ${RELIC_GIT_TAG}
)

string(CONCAT RELIC_SRC ${FETCHCONTENT_BASE_DIR} "/relic-src")

# Relic related options

set(STBIN TRUE)
Expand Down Expand Up @@ -132,6 +134,13 @@ set(PP_METHD "LAZYR;OATEP" CACHE STRING "")

FetchContent_MakeAvailable(relic)

message(STATUS "Patching Relic to make setjmp.h inclusion conditional")

execute_process(
COMMAND bash -c "git apply ${CMAKE_SOURCE_DIR}/setjmp_patch.diff"
WORKING_DIRECTORY ${RELIC_SRC}
)

add_subdirectory(src)


Expand Down
41 changes: 41 additions & 0 deletions setjmp_patch.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/include/relic_err.h b/include/relic_err.h
index e16f71fe..a4adb107 100644
--- a/include/relic_err.h
+++ b/include/relic_err.h
@@ -33,7 +33,6 @@
#define RLC_ERR_H

#include <stdint.h>
-#include <setjmp.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
@@ -43,6 +42,10 @@
#include "relic_util.h"
#include "relic_label.h"

+#ifdef CHECK
+#include <setjmp.h>
+#endif
+
/*============================================================================*/
/* Constant definitions */
/*============================================================================*/
@@ -94,6 +97,8 @@ enum errors {
*/
typedef int err_t;

+#ifdef CHECK
+
/**
* Type that describes an error status, including the error code and the program
* location where the error occurred.
@@ -107,6 +112,8 @@ typedef struct _sts_t {
int block;
} sts_t;

+#endif
+
/*============================================================================*/
/* Macro definitions */
/*============================================================================*/

0 comments on commit 881e6d7

Please sign in to comment.