Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: schnef/curve25519
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: master
Choose a base ref
...
head repository: peatio/curve25519
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref
Able to merge. These branches can be automatically merged.
  • 5 commits
  • 5 files changed
  • 2 contributors

Commits on Aug 1, 2019

  1. fix: modify app.src

    LanfordCai committed Aug 1, 2019
    Copy the full SHA
    11371fb View commit details

Commits on Sep 23, 2022

  1. fix use new Makefile

    Ljzn committed Sep 23, 2022
    Copy the full SHA
    3f748f1 View commit details
  2. remove arch flag

    Ljzn committed Sep 23, 2022
    Copy the full SHA
    c1bf7ba View commit details
  3. add arm

    Ljzn committed Sep 23, 2022
    Copy the full SHA
    0e82ac9 View commit details
  4. ignore arch

    Ljzn committed Sep 23, 2022
    Copy the full SHA
    49b6213 View commit details
Showing with 68 additions and 31 deletions.
  1. +2 −1 .gitignore
  2. +63 −22 c_src/Makefile
  3. BIN priv/curve25519_drv.so
  4. +2 −7 rebar.config
  5. +1 −1 src/curve25519.app.src
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -18,4 +18,5 @@ _build
.idea
*.iml
rebar3.crashdump
.*#
.*#
*.so
85 changes: 63 additions & 22 deletions c_src/Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,74 @@
OTPROOT=/usr/lib/erlang
INCLUDES = -I/usr/lib/erlang/usr/include
# Based on c_src.mk from erlang.mk by Loic Hoguin <essen@ninenines.eu>

# OS X flags.
#GCCFLAGS = -O3 -fPIC -bundle -flat_namespace -undefined suppress -fno-common -Wall
CURDIR := $(shell pwd)
BASEDIR := $(abspath $(CURDIR)/..)

# Linux Flags
GCCFLAGS = -O3 -fPIC -shared -fno-common -Wall
PROJECT ?= $(notdir $(BASEDIR))
PROJECT := $(strip $(PROJECT))

CFLAGS = $(GCCFLAGS) $(INCLUDES)
CFLAGS_32=-m32
LDFLAGS = $(CFLAGS) $(LIBS)
ERTS_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~ts/erts-~ts/include/\", [code:root_dir(), erlang:system_info(version)]).")
ERL_INTERFACE_INCLUDE_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~ts\", [code:lib_dir(erl_interface, include)]).")
ERL_INTERFACE_LIB_DIR ?= $(shell erl -noshell -s init stop -eval "io:format(\"~ts\", [code:lib_dir(erl_interface, lib)]).")

#OBJECTS = curve25519-donna.o curve25519-donna-c64.o curve25519_donna_nif.c
C_SRC_DIR = $(CURDIR)
C_SRC_OUTPUT ?= $(CURDIR)/../priv/$(PROJECT).so

DRIVER = curve25519_donna_nif.so curve25519_donna_c64_nif.so
BEAM = curve25519.beam
# System type and C compiler/flags.

all: $(DRIVER) $(BEAM)
UNAME_SYS := $(shell uname -s)
ifeq ($(UNAME_SYS), Darwin)
CC ?= cc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
CXXFLAGS ?= -O3 -finline-functions -Wall
LDFLAGS ?= -flat_namespace -undefined suppress
else ifeq ($(UNAME_SYS), FreeBSD)
CC ?= cc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
CXXFLAGS ?= -O3 -finline-functions -Wall
else ifeq ($(UNAME_SYS), Linux)
CC ?= gcc
CFLAGS ?= -O3 -std=c99 -finline-functions -Wall -Wmissing-prototypes
CXXFLAGS ?= -O3 -finline-functions -Wall
endif

clean:
rm -f *.o *.beam *.so
CFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)
CXXFLAGS += -fPIC -I $(ERTS_INCLUDE_DIR) -I $(ERL_INTERFACE_INCLUDE_DIR)

curve25519_donna_nif.so: curve25519-donna.c curve25519_donna_nif.c
gcc -o $@ $^ $(LDFLAGS) $(CFLAGS_32)
LDLIBS += -L $(ERL_INTERFACE_LIB_DIR) -lei
LDFLAGS += -shared

curve25519_donna_c64_nif.so: curve25519-donna-c64.c curve25519_donna_nif.c
gcc -o $@ $^ $(LDFLAGS)
# Verbosity.

$(BEAM): curve25519.erl
erlc $^
c_verbose_0 = @echo " C " $(?F);
c_verbose = $(c_verbose_$(V))

# EOF
cpp_verbose_0 = @echo " CPP " $(?F);
cpp_verbose = $(cpp_verbose_$(V))

link_verbose_0 = @echo " LD " $(@F);
link_verbose = $(link_verbose_$(V))

SOURCES := $(shell find $(C_SRC_DIR) -type f \( -name "*.c" -o -name "*.C" -o -name "*.cc" -o -name "*.cpp" \))
OBJECTS = $(addsuffix .o, $(basename $(SOURCES)))

COMPILE_C = $(c_verbose) $(CC) $(CFLAGS) $(CPPFLAGS) -c
COMPILE_CPP = $(cpp_verbose) $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c

$(C_SRC_OUTPUT): $(OBJECTS)
@mkdir -p $(BASEDIR)/priv/
$(link_verbose) $(CC) $(OBJECTS) $(LDFLAGS) $(LDLIBS) -o $(C_SRC_OUTPUT)

%.o: %.c
$(COMPILE_C) $(OUTPUT_OPTION) $<

%.o: %.cc
$(COMPILE_CPP) $(OUTPUT_OPTION) $<

%.o: %.C
$(COMPILE_CPP) $(OUTPUT_OPTION) $<

%.o: %.cpp
$(COMPILE_CPP) $(OUTPUT_OPTION) $<

clean:
@rm -f $(C_SRC_OUTPUT) $(OBJECTS)
Binary file removed priv/curve25519_drv.so
Binary file not shown.
9 changes: 2 additions & 7 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -8,14 +8,9 @@

{port_env, [ {"CFLAGS", "$CFLAGS -Ic_src/ed25519 -Ic_src/ed25519/nacl_includes -Ic_src/ed25519/additions"} ]}.

{port_specs, [{"x86_64", "priv/curve25519_drv.so", ["c_src/curve25519-donna-c64.c",
{port_specs, [{"priv/curve25519_drv.so", ["c_src/curve25519-donna-c64.c",
"c_src/ed25519/*.c",
"c_src/ed25519/nacl_sha512/*.c",
"c_src/ed25519/additions/*.c",
"c_src/curve25519_nif.c"]},
{"i[36]86", "priv/curve25519_drv.so", ["c_src/curve25519-donna.c",
"c_src/ed25519/*.c",
"c_src/ed25519/nacl_sha512/*.c",
"c_src/ed25519/additions/*.c",
"c_src/curve25519_nif.c"]}
"c_src/curve25519_nif.c"]}
]}.
2 changes: 1 addition & 1 deletion src/curve25519.app.src
Original file line number Diff line number Diff line change
@@ -7,6 +7,6 @@
kernel,
stdlib
]},
{mod, { curve25519_app, []}},
{modules, []},
{env, []}
]}.