Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

duplicating changes from jdpipe/gs-netstream #108

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ Ipopt-3.13.4/build

FMIL/build/
FMIL/install/
FMIL/include/

SuiteSparse/build/

Expand Down Expand Up @@ -149,4 +150,4 @@ sundials-5.4.0/build_msvc/

/libffi/install/
/libffi/x86_64-*-gnu/
/libffi/x86_64-w64-mingw32/
/libffi/x86_64-w64-mingw32/
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,25 @@ set(GC_BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared libraries")
set(enable_java_finalization OFF CACHE BOOL "Support for java finalization")
set(enable_gcj_support OFF CACHE BOOL "Support for gcj")
set(enable_large_config ON CACHE BOOL "Optimize for large heap or root set")

omc_add_subdirectory(gc)
target_include_directories(omcgc PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/gc/include)
set(LIBOMCGC omcgc)
# note that native GC will have a different library name

target_include_directories(${LIBOMCGC} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/gc/include)
# make sure every target that links to gc-lib has its sources
# compiled with -DGC_WIN32_PTHREADS (for pthreads on Windows, i.e., our MingW)
# Or -DGC_THREADS (for auto detection on other systems.)
# On Windows with MinGW OM uses pthreads-win32. GC_WIN32_PTHREADS is required
# to be set explicitly for use of pthreads API on Windows.
if(MINGW)
target_compile_definitions(omcgc PUBLIC GC_WIN32_PTHREADS)
target_compile_definitions(${LIBOMCGC} PUBLIC GC_WIN32_PTHREADS)
else()
target_compile_definitions(omcgc PUBLIC GC_THREADS)
target_compile_definitions(${LIBOMCGC} PUBLIC GC_THREADS)
endif(MINGW)

# Finally add an alias for clarity purposes.
add_library(omc::3rd::omcgc ALIAS omcgc)
add_library(omc::3rd::omcgc ALIAS ${LIBOMCGC})



Expand Down
9 changes: 9 additions & 0 deletions gc/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,12 @@ ADD_TEST(NAME realloc_test COMMAND realloc_test)
ADD_EXECUTABLE(smashtest smash_test.c)
TARGET_LINK_LIBRARIES(smashtest gc-lib)
ADD_TEST(NAME smashtest COMMAND smashtest)

if(CMAKE_USE_PTHREADS_INIT)
target_link_libraries(gctest pthread)
target_link_libraries(hugetest pthread)
target_link_libraries(leaktest pthread)
target_link_libraries(middletest pthread)
target_link_libraries(realloc_test pthread)
target_link_libraries(smashtest pthread)
endif()
6 changes: 6 additions & 0 deletions graphstream/gs-netstream/c++/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
netstream-main
*.exe
*.dll
*.so
*.o
*.a
24 changes: 13 additions & 11 deletions graphstream/gs-netstream/c++/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,33 @@ OBJDIR=obj
SRCDIR=src
INCDIR=include

ifeq (darwin,$(findstring darwin,$(shell $(CC) -v 2>&1 | grep ^Target)))
ifeq ($(shell uname),Darwin)
AR=libtool
ARFLAGS=-static -o
else
AR=ar
ARFLAGS=rcs
endif

CC = g++
CWARN = -W -Wall -Wshadow -Wimplicit -Wreturn-type -Wcomment -Wtrigraphs -Wformat -Wparentheses -Wpointer-arith -Wuninitialized -O

CDBG = -g $(CWARN) -fno-inline
CFLAGS = -I$(INCDIR) -O3
DFLAGS = -I$(INCDIR) -g $(CWARN) -fno-inline -DDEBUG=1

ifeq (MINGW,$(findstring MINGW,$(shell uname)))
# https://stackoverflow.com/questions/714100/os-detecting-makefile
ifeq ($(OS),Windows_NT)
SOCKET_LIB = -lwsock32
else
SOCKET_LIB =
SOCKET_LIB =
endif


CTAG = ctags
CTAGFILE = filelist
# src, object and bin files
OUT_BINARY := netstream-main
OUT_BINARY := netstream-main
OUT_LIBRARY := libnetstream.a

HEADERS = $(INCDIR)/global.h
Expand All @@ -35,22 +38,22 @@ OBJS = \
$(OBJDIR)/netstream-storage.o \
$(OBJDIR)/netstream-socket.o \
$(OBJDIR)/netstream-sender.o \
$(OBJDIR)/netstream-main.o

$(OBJDIR)/netstream-main.o
.SECONDARY:

#-- Rules
all: $(OUT_BINARY) $(OUT_LIBRARY)

$(OUT_BINARY): $(OBJS)
$(CXX) $(CFLAGS) -I$(INCDIR) $(OBJS) -o $(OUT_BINARY) $(SOCKET_LIB)
$(CC) $(CFLAGS) $(OBJS) -o $(OUT_BINARY) $(SOCKET_LIB)

$(OUT_LIBRARY): $(OBJS)
$(AR) $(ARFLAGS) $(OUT_LIBRARY) $(OBJS)
$(AR) $(ARFLAGS) $(OUT_LIBRARY) $(OBJS)

$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
mkdir -p $(OBJDIR)
$(CXX) $(CFLAGS) -c $? -o $@
$(CC) $(CFLAGS) -c $? -o $@

.PHONY: clean depend fresh

Expand All @@ -64,8 +67,7 @@ clean:
-rm -f $(SRCDIR)/*.output $(LEX_C)
-rm -f */*~ *~ core
-rm -f $(BINDIR)/*
-rm -f $(OUT_BINARY) $(OUT_BINARY).exe
-rm -f $(OUT_BINARY)
-rm -f $(OUT_LIBRARY)
-rm -rf $(OBJDIR)

fresh: clean all
20 changes: 20 additions & 0 deletions graphstream/gs-netstream/c++/src/netstream-constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,19 @@ namespace netstream{
* An array of bytes. Followed by first, a 16-bits integer for the number
* of integers and then, a list of signed bytes.
*/

const unsigned char TYPE_BYTE_ARRAY=0x53;
/**
* Followed by an 16-bit signed integer (a short)
*/
const unsigned char TYPE_SHORT=0x54;

/**
* An array of shorts. Followed by first, a 16-bits integer for the number
* of integers and then, a list of 16-bit signed shorts
*/
const unsigned char TYPE_SHORT_ARRAY=0x55;

/**
* Followed by an 32-bit signed integer
*/
Expand All @@ -173,6 +176,7 @@ namespace netstream{
* of integers and then, a list of 32-bit signed integers
*/
const unsigned char TYPE_INT_ARRAY=0x57;

/**
* Followed by an 64-bit signed integer
*/
Expand All @@ -182,6 +186,9 @@ namespace netstream{
* longs and then, a list of 62-bit signed integers
*/
const unsigned char TYPE_LONG_ARRAY=0x59;

/** NOTE: see also LONGLONG below, out of order */

/**
* Followed by a single precision 32-bits floating point number
*/
Expand Down Expand Up @@ -219,6 +226,19 @@ namespace netstream{
*/
const unsigned char TYPE_ARRAY=0x60;

/**
* Followed by an 64-bit signed integer
*/
const unsigned char TYPE_LONGLONG=0x61;
/**
* An array of longs. Followed by first, a 16-bits integer for the number of
* longs and then, a list of 62-bit signed integers
*/
const unsigned char TYPE_LONGLONG_ARRAY=0x62;




}// end netstream namespace

#endif
71 changes: 37 additions & 34 deletions graphstream/gs-netstream/c++/src/netstream-main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@

#include <iostream>
#include <sstream>

#include "netstream-sizes.h"
#include "netstream-storage.h"
#include "netstream-socket.h"
#include "netstream-constants.h"
Expand All @@ -38,7 +36,7 @@ int main (int argc, char const *argv[])

void e(){
string source_id="C++_netstream_test";
GS_LONG time_id=0L;
long time_id=0L;
NetStreamSender stream("default","localhost",2001,false);
string n1("node");
while(1) {
Expand All @@ -48,49 +46,55 @@ void e(){
}





void example(){
string source_id("C");
GS_LONG time_id = 0L;
string source_id("C++_netstream_test");
long time_id=0L;
NetStreamSender stream("default","localhost",2001,false);
string style("node{fill-mode:plain;fill-color:#567;size:6px;}");
stream.addGraphAttribute(source_id, time_id++, "stylesheet", style);
stream.addGraphAttribute(source_id, time_id++, "test", "test");
stream.changeGraphAttribute(source_id, time_id++, "test", "test",false);
stream.addGraphAttribute(source_id, time_id++, "ui.antialias", true);
stream.addGraphAttribute(source_id, time_id++, "layout.stabilization-limit", 0);
for (int i = 0; i < 10; i++) {
for (int i = 0; i < 500; i++) {
stringstream n1;
n1<<i;
stream.addNode(source_id, time_id++, n1.str());
stream.addNodeAttribute(source_id, time_id++, n1.str(), "ui.label", n1.str());
if (i > 0) {
stringstream n2;
n2<<(i-1);
stringstream n3;
n3<<(i/2);
stringstream e1;
e1<<n1.str()<<"-"<<n2.str();
stringstream e2;
e2<<n1.str()<<"-"<<n3.str();
//cout<<"edge :"<<e1.str()<<endl;
stream.addEdge(source_id, time_id++, e1.str(), n1.str(), n2.str(), false);
stream.addEdge(source_id, time_id++, e2.str(), n1.str(), n3.str(), false);
}
stream.addNode(source_id, time_id++, n1.str());
if (i > 0) {


stringstream n2;
n2<<(i-1);

stringstream n3;
n3<<(i/2);

stringstream e1;
e1<<n1.str()<<"-"<<n2.str();
stringstream e2;
e2<<n1.str()<<"-"<<n3.str();
//cout<<"edge :"<<e1.str()<<endl;
stream.addEdge(source_id, time_id++, e1.str(), n1.str(), n2.str(), false);
stream.addEdge(source_id, time_id++, e2.str(), n1.str(), n3.str(), false);
}
}
}

void types_test(){
string source_id="C++_netstream_test";
GS_LONG time_id=0L;
long time_id=0L;
NetStreamSender stream("default","localhost",2001,true);


stream.addGraphAttribute(source_id, time_id++, "int", (GS_INT)1);
stream.addGraphAttribute(source_id, time_id++, "float", (GS_FLOAT)1);
stream.addGraphAttribute(source_id, time_id++, "double", (GS_DOUBLE)1.0);
stream.addGraphAttribute(source_id, time_id++, "long", (GS_LONG)1);
stream.addGraphAttribute(source_id, time_id++, "byte", (GS_CHAR)0);
stream.addGraphAttribute(source_id, time_id++, "boolean", (GS_BOOL)true);
stream.addGraphAttribute(source_id, time_id++, "int", 1);
stream.addGraphAttribute(source_id, time_id++, "float", (float)1);
stream.addGraphAttribute(source_id, time_id++, "double", 1.0);
stream.addGraphAttribute(source_id, time_id++, "long", 1L);
stream.addGraphAttribute(source_id, time_id++, "byte", (char) 0);
stream.addGraphAttribute(source_id, time_id++, "boolean", true);

int v[] = {1776,7,4};
vector<int> value(v,v+3);
Expand All @@ -104,12 +108,12 @@ void types_test(){
vector<double> value3(v3,v3+2);
stream.addGraphAttribute(source_id, time_id++, "doubleArray", value3);

GS_LONG v4[] = {1776,7,4};
vector<GS_LONG> value4(v4,v4+3);
long int v4[] = {1776,7,4};
vector<long int> value4(v4,v4+3);
stream.addGraphAttribute(source_id, time_id++, "longArray", value4);

GS_CHAR v5[] = {'0',(GS_CHAR)0,'z'};
vector<GS_CHAR> value5(v5,v5+3);
char v5[] = {'0',(char)0,'z'};
vector<char> value5(v5,v5+3);
stream.addGraphAttribute(source_id, time_id++, "byteArray",value5 );

bool v6[] = {true,false};
Expand All @@ -121,10 +125,9 @@ void types_test(){

void events_test(){
string source_id="C++_netstream_test";
GS_LONG time_id = 0L;
long time_id=0L;
NetStreamSender stream("localhost", 2001);
stream.addNode(source_id, time_id++, "node0");
stream.addNode(source_id, time_id++, "node1");
stream.addEdge(source_id, time_id++, "edge", "node0", "node1", true);
stream.addNodeAttribute(source_id, time_id++, "node0","nodeAttribute", 0);
stream.changeNodeAttribute(source_id, time_id++, "node0","nodeAttribute",0, 1);
Expand Down
Loading