Browse Source

Initial work on the file parser

master
despair 2 years ago
parent
commit
41c1aa20ff
67 changed files with 2033 additions and 47 deletions
  1. 9
    0
      .gitignore
  2. 18
    11
      Makefile
  3. 56
    24
      NTMakefile
  4. 12
    6
      README.md
  5. 4
    0
      deps/include/mbedtls/cipher.h
  6. 1
    1
      deps/include/mbedtls/ssl_ciphersuites.h
  7. BIN
      deps/lib/nt_amd64/glew32.dll
  8. BIN
      deps/lib/nt_amd64/libbz2.a
  9. BIN
      deps/lib/nt_amd64/libfreetype.a
  10. BIN
      deps/lib/nt_amd64/libglfw.a
  11. BIN
      deps/lib/nt_amd64/libharfbuzz.a
  12. BIN
      deps/lib/nt_amd64/libpng.a
  13. BIN
      deps/lib/nt_amd64/libpolarssl.a
  14. BIN
      deps/lib/nt_amd64/libz.a
  15. BIN
      deps/lib/nt_amd64/release/glew32.dll
  16. BIN
      deps/lib/nt_amd64/release/libbz2.a
  17. BIN
      deps/lib/nt_amd64/release/libfreetype.a
  18. BIN
      deps/lib/nt_amd64/release/libglfw.a
  19. BIN
      deps/lib/nt_amd64/release/libharfbuzz.a
  20. BIN
      deps/lib/nt_amd64/release/libpng.a
  21. BIN
      deps/lib/nt_amd64/release/libpolarssl.a
  22. BIN
      deps/lib/nt_amd64/release/libz.a
  23. 0
    0
      deps/lib/nt_i386/glew32.dll
  24. 0
    0
      deps/lib/nt_i386/libbz2.a
  25. 0
    0
      deps/lib/nt_i386/libfreetype.a
  26. 0
    0
      deps/lib/nt_i386/libglfw.a
  27. 0
    0
      deps/lib/nt_i386/libharfbuzz.a
  28. 0
    0
      deps/lib/nt_i386/libpng.a
  29. BIN
      deps/lib/nt_i386/libpolarssl.a
  30. 0
    0
      deps/lib/nt_i386/libz.a
  31. BIN
      deps/lib/nt_i386/release/glew32.dll
  32. BIN
      deps/lib/nt_i386/release/libbz2.a
  33. BIN
      deps/lib/nt_i386/release/libfreetype.a
  34. BIN
      deps/lib/nt_i386/release/libglfw3.a
  35. BIN
      deps/lib/nt_i386/release/libharfbuzz.a
  36. BIN
      deps/lib/nt_i386/release/libpng.a
  37. BIN
      deps/lib/nt_i386/release/libpolarssl.a
  38. BIN
      deps/lib/nt_i386/release/libz.a
  39. BIN
      netrunner.zip
  40. BIN
      netrunner_ssl.zip
  41. BIN
      reltools/darwin/libmbedcrypto.0.dylib
  42. BIN
      reltools/darwin/libmbedtls.10.dylib
  43. BIN
      reltools/darwin/libmbedx509.0.dylib
  44. BIN
      reltools/winnt/amd64/glew32.dll
  45. BIN
      reltools/winnt/amd64/libgcc_s_seh-1.dll
  46. BIN
      reltools/winnt/amd64/libssp-0.dll
  47. BIN
      reltools/winnt/amd64/libstdc++-6.dll
  48. BIN
      reltools/winnt/amd64/libwinpthread-1.dll
  49. BIN
      reltools/winnt/i386/glew32.dll
  50. 0
    0
      reltools/winnt/i386/libgcc_s_sjlj-1.dll
  51. 0
    0
      reltools/winnt/i386/libssp-0.dll
  52. 0
    0
      reltools/winnt/i386/libstdc++-6.dll
  53. 19
    0
      src/CFGFileParser.cpp
  54. 56
    0
      src/CFGFileParser.h
  55. 334
    0
      src/Murmur3.cpp
  56. 37
    0
      src/Murmur3.h
  57. 72
    0
      src/TLSFAlloc.h
  58. 17
    2
      src/main.cpp
  59. 1
    1
      src/networking/HTTPSRequest.cpp
  60. 4
    0
      src/networking/HTTPSRequest.h
  61. 1
    1
      src/pnm.cpp
  62. 7
    1
      src/pnm.h
  63. 12
    0
      src/target.h
  64. 84
    0
      src/tlsf-winnt.h
  65. 1230
    0
      src/tlsf.c
  66. 39
    0
      src/tlsf.h
  67. 20
    0
      winnt-ci.sh

+ 9
- 0
.gitignore View File

@@ -10,3 +10,12 @@ src/networking/URI
*.user
NetRunner2008.ncb
*.suo
*.id*
*.nam
*.til
*.dbg
/glew32.dll
/libgcc_s_sjlj-1.dll
/libssp-0.dll
/libstdc++-6.dll
/netrunner.exe

+ 18
- 11
Makefile View File

@@ -1,22 +1,26 @@
UNAME := $(shell uname)
CXX = g++
CC = gcc

GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
PLATFORM := $(shell g++ -dumpmachine)

CXXFLAGS = -O3 -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CXXFLAGS = -O3 -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\" -DPLATFORM=\"$(PLATFORM)\"
CFLAGS = -O3 -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
CWARN = -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused
WARNINGS = -Werror -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wzero-as-null-pointer-constant -Wuseless-cast
LIBS = -lglfw -lGL -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
LDFLAGS = -O3 -flto=8
INCPATH = -I /usr/include/freetype2 -I /usr/include/harfbuzz
MD5SUM = md5sum

ifeq ($(UNAME), Darwin)
CXXFLAGS = -O3 -std=c++1y -DVERSION=\"$(GIT_VERSION)\"
CXXFLAGS = -O3 -std=c++1y -DVERSION=\"$(GIT_VERSION)\" -DPLATFORM\"$(PLATFORM)\"
CFLAGS = -O3 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
WARNINGS =
LIBS = -L/usr/local/lib -lglfw -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
LDFLAGS = -O3 -L /usr/local/lib
CWARN =
LIBS = -L/usr/local/lib -lglfw3 -framework OpenGL -framework Cocoa -framework IOKit -framework CoreVideo -lGLEW -lfreetype -lharfbuzz -lmbedtls -lmbedcrypto -lmbedx509
LDFLAGS = -O3
INCPATH = -I /usr/local/include -I /usr/local/include/freetype2 -I /usr/local/include/harfbuzz
MD5SUM = md5
endif

EXECUTABLE = netrunner
@@ -31,13 +35,13 @@ OBJECTS = $(subst $(SRCDIR),$(OBJDIR),$(SOURCES:.cpp=.o))

all: $(SOURCES) netrunner

netrunner: $(OBJECTS)
netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)

# make make 3.81 happy (since it can't parse any echo parameters)
ifeq ($(UNAME), Darwin)
shaders:
ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | $(MD5SUM)), $(shell cat src/graphics/opengl/shaders/gen/hashsum))
ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum), $(shell cat src/graphics/opengl/shaders/gen/hashsum))
@mkdir -p "src/graphics/opengl/shaders/gen"
@echo "#ifndef FONTSHADER_H\n#define FONTSHADER_H\n\nconst char *fontVertexShaderSource =\n" > src/graphics/opengl/shaders/gen/FontShader.h;
@cat src/graphics/opengl/shaders/FontShader.vert | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/FontShader.h;
@@ -49,13 +53,13 @@ ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/open
@echo "const char *textureFragmentShaderSource =\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
@cat src/graphics/opengl/shaders/TextureShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
@echo "#endif\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
@cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | $(MD5SUM) > src/graphics/opengl/shaders/gen/hashsum;
@cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum > src/graphics/opengl/shaders/gen/hashsum;
endif
else
shaders:
ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | $(MD5SUM)), $(shell cat src/graphics/opengl/shaders/gen/hashsum))
ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum), $(shell cat src/graphics/opengl/shaders/gen/hashsum))
@mkdir -p "src/graphics/opengl/shaders/gen"
@cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | $(MD5SUM) > src/graphics/opengl/shaders/gen/hashsum;
@cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum > src/graphics/opengl/shaders/gen/hashsum;
@/bin/echo -ne "#ifndef FONTSHADER_H\n#define FONTSHADER_H\n\nconst char *fontVertexShaderSource =\n" > src/graphics/opengl/shaders/gen/FontShader.h;
@cat src/graphics/opengl/shaders/FontShader.vert | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/FontShader.h;
@/bin/echo -ne "const char *fontFragmentShaderSource =\n" >> src/graphics/opengl/shaders/gen/FontShader.h;
@@ -75,6 +79,9 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp | shaders
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARNINGS) -c -o $@ $<
@mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@

$(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
$(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_MMAP=1 -DUSE_SBRK=1 -c -o $@ $<

$(DEPDIR)/%d: ;
.PRECIOUS: $(DEPDIR)/%.d


+ 56
- 24
NTMakefile View File

@@ -1,21 +1,69 @@
UNAME := $(shell uname)
CXX = g++
CC = gcc
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always --tags)
ifdef DEBUG
CXXFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\"
else
ifdef RELEASE_PACK
CXXFLAGS = -O3 -march=i686 -mtune=generic -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -O3 -march=i686 -mtune=generic -fstack-protector-strong -fPIE -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
else
CXXFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
endif
endif
ifdef AMD64_DEBUG
CXXFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -Og -g3 -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\"
else
ifdef AMD64_RELEASE
CXXFLAGS = -O3 -march=opteron -mtune=opteron -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -O3 -march=opteron -mtune=opteron -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c11 -DVERSION=\"$(GIT_VERSION)\"
else
ifdef AMD64
CXXFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8 -std=c++14 -DVERSION=\"$(GIT_VERSION)\"
CFLAGS = -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -std=c11 -DVERSION=\"$(GIT_VERSION)\" -flto=8
endif
endif
endif
WARNINGS = -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wnoexcept -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-null-sentinel -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused -Wzero-as-null-pointer-constant -Wuseless-cast
CWARN = -pedantic -Wall -Wextra -Wcast-align -Wcast-qual -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-declarations -Wmissing-include-dirs -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wswitch-default -Wundef -Wno-unused
# i686 builds
ifdef DEBUG
LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_i386 -Og -g3 -fstack-protector-strong -fPIE
else
ifdef RELEASE_PACK
LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
ifndef DEBUG
LDFLAGS = -L ./deps/lib -O3 -flto=8 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE
LDFLAGS = -L ./deps/lib/nt_i386/release -O3 -flto=8 -march=i686 -mtune=generic -fstack-protector-strong -fPIE
else
LDFLAGS = -L ./deps/lib -Og -g3 -fstack-protector-strong -fPIE
LIBS = -lglfw -lopenGL32 -lGLEW32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_i386 -O3 -flto=8 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE
endif
endif
ifdef AMD64_DEBUG
LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_amd64 -Og -g3 -fstack-protector-strong -fPIE
else
ifdef AMD64_RELEASE
LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_amd64/release -O3 -flto=8 -march=opteron -mtune=opteron -mfpmath=sse -fstack-protector-strong -fPIE
else
ifdef AMD64
LIBS = -lglfw -lopenGL32 -lglew32 -lgdi32 -lpolarssl -lws2_32 -lharfbuzz -lfreetype -lpng -lbz2 -lz
LDFLAGS = -L ./deps/lib/nt_amd64 -O3 -march=core2 -mfpmath=sse -fstack-protector-strong -fPIE -flto=8
endif
endif
endif
INCPATH = -I ./deps/include
EXECUTABLE = netrunner
@@ -30,27 +78,9 @@ OBJECTS = $(subst $(SRCDIR),$(OBJDIR),$(SOURCES:.cpp=.o))
all: $(SOURCES) netrunner
netrunner: $(OBJECTS)
netrunner: $(OBJECTS) $(OBJDIR)/tlsf.o
$(LINK) $(LDFLAGS) -o $@ $^ $(LIBS)
# make make 3.81 happy (since it can't parse any echo parameters)
ifeq ($(UNAME), Darwin)
shaders:
ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum), $(shell cat src/graphics/opengl/shaders/gen/hashsum))
@mkdir -p "src/graphics/opengl/shaders/gen"
@echo "#ifndef FONTSHADER_H\n#define FONTSHADER_H\n\nconst char *fontVertexShaderSource =\n" > src/graphics/opengl/shaders/gen/FontShader.h;
@cat src/graphics/opengl/shaders/FontShader.vert | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/FontShader.h;
@echo "const char *fontFragmentShaderSource =\n" >> src/graphics/opengl/shaders/gen/FontShader.h;
@cat src/graphics/opengl/shaders/FontShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/FontShader.h;
@echo "#endif\n" >> src/graphics/opengl/shaders/gen/FontShader.h;
@echo "#ifndef TEXTURESHADER_H\n#define TEXTURESHADER_H\n\nconst char *textureVertexShaderSource =\n" > src/graphics/opengl/shaders/gen/TextureShader.h;
@cat src/graphics/opengl/shaders/TextureShader.vert | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
@echo "const char *textureFragmentShaderSource =\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
@cat src/graphics/opengl/shaders/TextureShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
@echo "#endif\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
@cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum > src/graphics/opengl/shaders/gen/hashsum;
endif
else
shaders:
ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/opengl/shaders/FontShader.frag src/graphics/opengl/shaders/TextureShader.vert src/graphics/opengl/shaders/TextureShader.frag | md5sum), $(shell cat src/graphics/opengl/shaders/gen/hashsum))
@mkdir -p "src/graphics/opengl/shaders/gen"
@@ -66,14 +96,16 @@ ifneq ($(shell cat src/graphics/opengl/shaders/FontShader.vert src/graphics/open
@cat src/graphics/opengl/shaders/TextureShader.frag | awk '{if ($$0!="}") {print "\t\""$$0"\\n\""} else {print "\t\""$$0"\";\n"}}' >> src/graphics/opengl/shaders/gen/TextureShader.h;
@/bin/echo -ne "#endif\n" >> src/graphics/opengl/shaders/gen/TextureShader.h;
endif
endif
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp | shaders
@mkdir -p $(@D)
@mkdir -p $(subst gen,d,$(@D))
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) -c -o $@ $<
$(CXX) -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td $(CXXFLAGS) $(INCPATH) $(WARNINGS) -c -o $@ $<
@mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d && touch $@
$(OBJDIR)/tlsf.o: $(SRCDIR)/tlsf.c
$(CC) $(INCPATH) $(CWARN) -DTLSF_USE_LOCKS=0 -DUSE_SBRK=1 -c -o $@ $<
$(DEPDIR)/%d: ;
.PRECIOUS: $(DEPDIR)/%.d

+ 12
- 6
README.md View File

@@ -1,3 +1,6 @@
NT5+ (i386): [![Build Status](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-i686/badge/icon)](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-i686/)
.NET Server+ (AMD64): [![Build Status](https://nt-build-bot.rvx86.net:7421/buildStatus/icon?job=netrunner-winnt-amd64)](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-amd64/)

# Netrunner

is an implementation of a new web browser engine written in C++ utilizing OpenGL.
@@ -38,24 +41,27 @@ Also will need either libmbedtls-dev (Debian 9/Ubuntu 16LTS (xenial)) or libpola
#### Gentoo
`sudo emerge freetype harfbuzz glew glfw`

#### Mac OS X
`brew install glew glfw freetype harfbuzz mbedtls`

## Binaries
### Linux
[2017-08-22 binary package](https://my.mixtape.moe/pejuau.tar.gz)

GyroNinja.net is back online
[nightly binary only (no font/pnm files)](https://gyroninja.net:1615/job/NetRunner/lastSuccessfulBuild/artifact/netrunner)

[Jenkins](https://gyroninja.net:1615/job/NetRunner/)

### OSX
[2017-08-22v2 binary package](https://my.mixtape.moe/gbxees.zip)
[2017-08-22 binary package](https://my.mixtape.moe/xqfpiu.zip)

### Windows
[2017-08-20 binary package](https://my.mixtape.moe/exebyr.zip)
[Jenkins 32bit](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-i686/)
[Jenkins 64bit](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-amd64/)

[Jenkins](https://nt-build-bot.rvx86.net:7421/)


[i386 nightly binary pkg](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-i686/lastSuccessfulBuild/artifact/*zip*/archive.zip)

[amd64 nightly binary pkg](https://nt-build-bot.rvx86.net:7421/job/netrunner-winnt-amd64/lastSuccessfulBuild/artifact/*zip*/archive.zip)

## Milestones
- Browse 4chan /g/ board

+ 4
- 0
deps/include/mbedtls/cipher.h View File

@@ -408,7 +408,11 @@ static inline mbedtls_cipher_type_t mbedtls_cipher_get_type( const mbedtls_ciphe
static inline const char *mbedtls_cipher_get_name( const mbedtls_cipher_context_t *ctx )
{
if( NULL == ctx || NULL == ctx->cipher_info )
#ifdef __cplusplus
return nullptr;
#else
return 0;
#endif

return ctx->cipher_info->name;
}

+ 1
- 1
deps/include/mbedtls/ssl_ciphersuites.h View File

@@ -349,7 +349,7 @@ struct mbedtls_ssl_ciphersuite_t
unsigned char flags;
};

const int *mbedtls_ssl_list_ciphersuites( void );
//const int *mbedtls_ssl_list_ciphersuites( void );

const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_string( const char *ciphersuite_name );
const mbedtls_ssl_ciphersuite_t *mbedtls_ssl_ciphersuite_from_id( int ciphersuite_id );

BIN
deps/lib/nt_amd64/glew32.dll View File


BIN
deps/lib/nt_amd64/libbz2.a View File


BIN
deps/lib/nt_amd64/libfreetype.a View File


BIN
deps/lib/nt_amd64/libglfw.a View File


BIN
deps/lib/nt_amd64/libharfbuzz.a View File


BIN
deps/lib/nt_amd64/libpng.a View File


BIN
deps/lib/nt_amd64/libpolarssl.a View File


BIN
deps/lib/nt_amd64/libz.a View File


BIN
deps/lib/nt_amd64/release/glew32.dll View File


BIN
deps/lib/nt_amd64/release/libbz2.a View File


BIN
deps/lib/nt_amd64/release/libfreetype.a View File


BIN
deps/lib/nt_amd64/release/libglfw.a View File


BIN
deps/lib/nt_amd64/release/libharfbuzz.a View File


BIN
deps/lib/nt_amd64/release/libpng.a View File


BIN
deps/lib/nt_amd64/release/libpolarssl.a View File


BIN
deps/lib/nt_amd64/release/libz.a View File


deps/lib/glew32.dll → deps/lib/nt_i386/glew32.dll View File


deps/lib/libbz2.a → deps/lib/nt_i386/libbz2.a View File


deps/lib/libfreetype.a → deps/lib/nt_i386/libfreetype.a View File


deps/lib/libglfw.a → deps/lib/nt_i386/libglfw.a View File


deps/lib/libharfbuzz.a → deps/lib/nt_i386/libharfbuzz.a View File


deps/lib/libpng.a → deps/lib/nt_i386/libpng.a View File


BIN
deps/lib/libpolarssl.a → deps/lib/nt_i386/libpolarssl.a View File


deps/lib/libz.a → deps/lib/nt_i386/libz.a View File


BIN
reltools/winnt/glew32.dll → deps/lib/nt_i386/release/glew32.dll View File


BIN
deps/lib/nt_i386/release/libbz2.a View File


BIN
deps/lib/nt_i386/release/libfreetype.a View File


BIN
deps/lib/nt_i386/release/libglfw3.a View File


BIN
deps/lib/nt_i386/release/libharfbuzz.a View File


BIN
deps/lib/nt_i386/release/libpng.a View File


BIN
deps/lib/nt_i386/release/libpolarssl.a View File


BIN
deps/lib/nt_i386/release/libz.a View File


BIN
netrunner.zip View File


BIN
netrunner_ssl.zip View File


BIN
reltools/darwin/libmbedcrypto.0.dylib View File


BIN
reltools/darwin/libmbedtls.10.dylib View File


BIN
reltools/darwin/libmbedx509.0.dylib View File


BIN
reltools/winnt/amd64/glew32.dll View File


BIN
reltools/winnt/amd64/libgcc_s_seh-1.dll View File


BIN
reltools/winnt/amd64/libssp-0.dll View File


BIN
reltools/winnt/amd64/libstdc++-6.dll View File


BIN
reltools/winnt/amd64/libwinpthread-1.dll View File


BIN
reltools/winnt/i386/glew32.dll View File


reltools/winnt/libgcc_s_sjlj-1.dll → reltools/winnt/i386/libgcc_s_sjlj-1.dll View File


reltools/winnt/libssp-0.dll → reltools/winnt/i386/libssp-0.dll View File


reltools/winnt/libstdc++-6.dll → reltools/winnt/i386/libstdc++-6.dll View File


+ 19
- 0
src/CFGFileParser.cpp View File

@@ -0,0 +1,19 @@
#include "CFGFileParser.h"
CFGFileParser::CFGFileParser(const char* filename)
{
// Open the config file, get its size,
// allocate the buffer, read it into
// the buffer, close the file
cfg_file = fopen(filename, "r");
stat(filename, cfg_fileinfo);
buffer = (char*)tlsf_calloc(cfg_fileinfo->st_size,sizeof(char));
fread(buffer,sizeof(char),cfg_fileinfo->st_size,cfg_file);
fclose(cfg_file);
}
CFGFileParser::~CFGFileParser()
{
// clean up!
tlsf_free(buffer);
}

+ 56
- 0
src/CFGFileParser.h View File

@@ -0,0 +1,56 @@
#ifndef __CFGFILEPARSER_H__
#define __CFGFILEPARSER_H__
#include <string>
#include <unordered_map>
#include <utility>
#include <functional>
#include <algorithm>
#include "TLSFAlloc.h"
#include "Murmur3.h"
extern "C"{
#include "tlsf.h"
#include <sys/stat.h>
}
#include <cstdint>
// let's try fast strings
typedef std::basic_string<char, std::char_traits<char>, despair::TLSFAlloc<char>> fast_string;
namespace despair{ size_t string_hash(const fast_string &str); }
namespace despair{
size_t string_hash(const fast_string &str)
{
size_t out;
#if UINTPTR_MAX == 0xffffffff
MurmurHash3_x86_128 ( &str, sizeof(str), 7904542L, &out );
#elif UINTPTR_MAX == 0xffffffffffffffff
MurmurHash3_x64_128 ( &str, sizeof(str), 5484754L, &out );
#else
#endif
return out;
}
}
typedef std::unordered_map<fast_string,char*,std::function<decltype(despair::string_hash)>,std::equal_to<std::string>,despair::TLSFAlloc<std::pair<const fast_string, fast_string>>> stringmap;
// Class which holds the parsed configuration options after
// being processed by CFGFileParser. No longer a "trivial class"
// just select by cfg->GlobalSettings....
struct BrowserConfiguration{
stringmap GlobalSettings;
// fast allocation!
static void* operator new(size_t n){ if (void *mem = tlsf_malloc(n)) return mem; throw std::bad_alloc {}; }
static void operator delete(void *p){tlsf_free(p);}
void clear();
};

class CFGFileParser {
public:
CFGFileParser(const char* filename);
~CFGFileParser();
static void* operator new(size_t n){ if (void *mem = tlsf_malloc(n)) return mem; throw std::bad_alloc {}; }
static void operator delete(void *p){tlsf_free(p);}
private:
FILE *cfg_file;
char *buffer;
struct stat *cfg_fileinfo;
};
#endif // __CFGFILEPARSER_H__

+ 334
- 0
src/Murmur3.cpp View File

@@ -0,0 +1,334 @@
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
// Note - The x86 and x64 versions do _not_ produce the same results, as the
// algorithms are optimized for their respective platforms. You can still
// compile and run any of them on any platform, but your performance with the
// non-native version will be less than optimal.
#include "Murmur3.h"
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
// Microsoft Visual Studio
#if defined(_MSC_VER)
#define FORCE_INLINE __forceinline
#include <stdlib.h>
#define ROTL32(x,y) _rotl(x,y)
#define ROTL64(x,y) _rotl64(x,y)
#define BIG_CONSTANT(x) (x)
// Other compilers
#else // defined(_MSC_VER)
#define FORCE_INLINE inline __attribute__((always_inline))
inline uint32_t rotl32 ( uint32_t x, int8_t r )
{
return (x << r) | (x >> (32 - r));
}
inline uint64_t rotl64 ( uint64_t x, int8_t r )
{
return (x << r) | (x >> (64 - r));
}
#define ROTL32(x,y) rotl32(x,y)
#define ROTL64(x,y) rotl64(x,y)
#define BIG_CONSTANT(x) (x##LLU)
#endif // !defined(_MSC_VER)
//-----------------------------------------------------------------------------
// Block read - if your platform needs to do endian-swapping or can only
// handle aligned reads, do the conversion here
FORCE_INLINE uint32_t getblock32 ( const uint32_t * p, int i )
{
return p[i];
}
FORCE_INLINE uint64_t getblock64 ( const uint64_t * p, int i )
{
return p[i];
}
//-----------------------------------------------------------------------------
// Finalization mix - force all bits of a hash block to avalanche
FORCE_INLINE uint32_t fmix32 ( uint32_t h )
{
h ^= h >> 16;
h *= 0x85ebca6b;
h ^= h >> 13;
h *= 0xc2b2ae35;
h ^= h >> 16;
return h;
}
//----------
FORCE_INLINE uint64_t fmix64 ( uint64_t k )
{
k ^= k >> 33;
k *= BIG_CONSTANT(0xff51afd7ed558ccd);
k ^= k >> 33;
k *= BIG_CONSTANT(0xc4ceb9fe1a85ec53);
k ^= k >> 33;
return k;
}
//-----------------------------------------------------------------------------
void MurmurHash3_x86_32 ( const void * key, int len,
uint32_t seed, void * out )
{
const uint8_t * data = (const uint8_t*)key;
const int nblocks = len / 4;
uint32_t h1 = seed;
const uint32_t c1 = 0xcc9e2d51;
const uint32_t c2 = 0x1b873593;
//----------
// body
const uint32_t * blocks = (const uint32_t *)(data + nblocks*4);
for(int i = -nblocks; i; i++)
{
uint32_t k1 = getblock32(blocks,i);
k1 *= c1;
k1 = ROTL32(k1,15);
k1 *= c2;
h1 ^= k1;
h1 = ROTL32(h1,13);
h1 = h1*5+0xe6546b64;
}
//----------
// tail
const uint8_t * tail = (const uint8_t*)(data + nblocks*4);
uint32_t k1 = 0;
switch(len & 3)
{
case 3: k1 ^= tail[2] << 16;
case 2: k1 ^= tail[1] << 8;
case 1: k1 ^= tail[0];
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
};
//----------
// finalization
h1 ^= len;
h1 = fmix32(h1);
*(uint32_t*)out = h1;
}
//-----------------------------------------------------------------------------
void MurmurHash3_x86_128 ( const void * key, const int len,
uint32_t seed, void * out )
{
const uint8_t * data = (const uint8_t*)key;
const int nblocks = len / 16;
uint32_t h1 = seed;
uint32_t h2 = seed;
uint32_t h3 = seed;
uint32_t h4 = seed;
const uint32_t c1 = 0x239b961b;
const uint32_t c2 = 0xab0e9789;
const uint32_t c3 = 0x38b34ae5;
const uint32_t c4 = 0xa1e38b93;
//----------
// body
const uint32_t * blocks = (const uint32_t *)(data + nblocks*16);
for(int i = -nblocks; i; i++)
{
uint32_t k1 = getblock32(blocks,i*4+0);
uint32_t k2 = getblock32(blocks,i*4+1);
uint32_t k3 = getblock32(blocks,i*4+2);
uint32_t k4 = getblock32(blocks,i*4+3);
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
h1 = ROTL32(h1,19); h1 += h2; h1 = h1*5+0x561ccd1b;
k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
h2 = ROTL32(h2,17); h2 += h3; h2 = h2*5+0x0bcaa747;
k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
h3 = ROTL32(h3,15); h3 += h4; h3 = h3*5+0x96cd1c35;
k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
h4 = ROTL32(h4,13); h4 += h1; h4 = h4*5+0x32ac3b17;
}
//----------
// tail
const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
uint32_t k1 = 0;
uint32_t k2 = 0;
uint32_t k3 = 0;
uint32_t k4 = 0;
switch(len & 15)
{
case 15: k4 ^= tail[14] << 16;
case 14: k4 ^= tail[13] << 8;
case 13: k4 ^= tail[12] << 0;
k4 *= c4; k4 = ROTL32(k4,18); k4 *= c1; h4 ^= k4;
case 12: k3 ^= tail[11] << 24;
case 11: k3 ^= tail[10] << 16;
case 10: k3 ^= tail[ 9] << 8;
case 9: k3 ^= tail[ 8] << 0;
k3 *= c3; k3 = ROTL32(k3,17); k3 *= c4; h3 ^= k3;
case 8: k2 ^= tail[ 7] << 24;
case 7: k2 ^= tail[ 6] << 16;
case 6: k2 ^= tail[ 5] << 8;
case 5: k2 ^= tail[ 4] << 0;
k2 *= c2; k2 = ROTL32(k2,16); k2 *= c3; h2 ^= k2;
case 4: k1 ^= tail[ 3] << 24;
case 3: k1 ^= tail[ 2] << 16;
case 2: k1 ^= tail[ 1] << 8;
case 1: k1 ^= tail[ 0] << 0;
k1 *= c1; k1 = ROTL32(k1,15); k1 *= c2; h1 ^= k1;
};
//----------
// finalization
h1 ^= len; h2 ^= len; h3 ^= len; h4 ^= len;
h1 += h2; h1 += h3; h1 += h4;
h2 += h1; h3 += h1; h4 += h1;
h1 = fmix32(h1);
h2 = fmix32(h2);
h3 = fmix32(h3);
h4 = fmix32(h4);
h1 += h2; h1 += h3; h1 += h4;
h2 += h1; h3 += h1; h4 += h1;
((uint32_t*)out)[0] = h1;
((uint32_t*)out)[1] = h2;
((uint32_t*)out)[2] = h3;
((uint32_t*)out)[3] = h4;
}
//-----------------------------------------------------------------------------
void MurmurHash3_x64_128 ( const void * key, const int len,
const uint32_t seed, void * out )
{
const uint8_t * data = (const uint8_t*)key;
const int nblocks = len / 16;
uint64_t h1 = seed;
uint64_t h2 = seed;
const uint64_t c1 = BIG_CONSTANT(0x87c37b91114253d5);
const uint64_t c2 = BIG_CONSTANT(0x4cf5ad432745937f);
//----------
// body
const uint64_t * blocks = (const uint64_t *)(data);
for(int i = 0; i < nblocks; i++)
{
uint64_t k1 = getblock64(blocks,i*2+0);
uint64_t k2 = getblock64(blocks,i*2+1);
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
h1 = ROTL64(h1,27); h1 += h2; h1 = h1*5+0x52dce729;
k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
h2 = ROTL64(h2,31); h2 += h1; h2 = h2*5+0x38495ab5;
}
//----------
// tail
const uint8_t * tail = (const uint8_t*)(data + nblocks*16);
uint64_t k1 = 0;
uint64_t k2 = 0;
switch(len & 15)
{
case 15: k2 ^= ((uint64_t)tail[14]) << 48;
case 14: k2 ^= ((uint64_t)tail[13]) << 40;
case 13: k2 ^= ((uint64_t)tail[12]) << 32;
case 12: k2 ^= ((uint64_t)tail[11]) << 24;
case 11: k2 ^= ((uint64_t)tail[10]) << 16;
case 10: k2 ^= ((uint64_t)tail[ 9]) << 8;
case 9: k2 ^= ((uint64_t)tail[ 8]) << 0;
k2 *= c2; k2 = ROTL64(k2,33); k2 *= c1; h2 ^= k2;
case 8: k1 ^= ((uint64_t)tail[ 7]) << 56;
case 7: k1 ^= ((uint64_t)tail[ 6]) << 48;
case 6: k1 ^= ((uint64_t)tail[ 5]) << 40;
case 5: k1 ^= ((uint64_t)tail[ 4]) << 32;
case 4: k1 ^= ((uint64_t)tail[ 3]) << 24;
case 3: k1 ^= ((uint64_t)tail[ 2]) << 16;
case 2: k1 ^= ((uint64_t)tail[ 1]) << 8;
case 1: k1 ^= ((uint64_t)tail[ 0]) << 0;
k1 *= c1; k1 = ROTL64(k1,31); k1 *= c2; h1 ^= k1;
};
//----------
// finalization
h1 ^= len; h2 ^= len;
h1 += h2;
h2 += h1;
h1 = fmix64(h1);
h2 = fmix64(h2);
h1 += h2;
h2 += h1;
((uint64_t*)out)[0] = h1;
((uint64_t*)out)[1] = h2;
}
//-----------------------------------------------------------------------------

+ 37
- 0
src/Murmur3.h View File

@@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// MurmurHash3 was written by Austin Appleby, and is placed in the public
// domain. The author hereby disclaims copyright to this source code.
#ifndef _MURMURHASH3_H_
#define _MURMURHASH3_H_
//-----------------------------------------------------------------------------
// Platform-specific functions and macros
// Microsoft Visual Studio
#if defined(_MSC_VER) && (_MSC_VER < 1600)
typedef unsigned char uint8_t;
typedef unsigned int uint32_t;
typedef unsigned __int64 uint64_t;
// Other compilers
#else // defined(_MSC_VER)
#include <stdint.h>
#endif // !defined(_MSC_VER)
//-----------------------------------------------------------------------------
void MurmurHash3_x86_32 ( const void * key, int len, uint32_t seed, void * out );
void MurmurHash3_x86_128 ( const void * key, int len, uint32_t seed, void * out );
void MurmurHash3_x64_128 ( const void * key, int len, uint32_t seed, void * out );
//-----------------------------------------------------------------------------
#endif // _MURMURHASH3_H_

+ 72
- 0
src/TLSFAlloc.h View File

@@ -0,0 +1,72 @@
// This is a custom C++ allocator that wraps the 2LSF C heap allocator
// -despair
// in case of emergency, set DEBUG_TLSF_CPP somewhere before including this header
#include <limits>
#include <iostream>
extern "C"{
#include "tlsf.h"
}
namespace despair {
template <class T>
class TLSFAlloc {
public:
typedef T value_type;
typedef T* ptr;
typedef const T* const_ptr;
typedef T& ref;
typedef const T& const_ref;
typedef std::size_t size_type;
typedef std::ptrdiff_t diff_type;
template <class U>
struct rebind { typedef TLSFAlloc<U> other; };
ptr address (ref value) const {return &value;}
const_ptr address (const_ref value) const {return &value;}
// these are the constructors for same: had I not ported sbrk(2) to winnt,
// the constructor would have generated a memory pool from above.
TLSFAlloc() throw() {}
TLSFAlloc(const TLSFAlloc&) throw() {}
template <class U> TLSFAlloc(const TLSFAlloc<U>&) throw() {}
~TLSFAlloc() throw() {}
// return maximum number of elements that can be allocated
size_type max_size() const throw() {return std::numeric_limits<std::size_t>::max() / sizeof(T);}
// allocate but don't initialize num elements of type T
ptr allocate(size_type num, const void* = 0) {
#ifdef DEBUG_TLSF_CPP
// print message and allocate memory with 2LSF
std::cerr << "allocate " << num << " element(s)" << " of size " << sizeof(T) << std::endl;
ptr ret = (ptr)(tlsf_malloc(num*sizeof(T)));
std::cerr << " allocated at: " << (void*)ret << std::endl; return ret;
#else
ptr ret = reinterpret_cast<ptr>(tlsf_malloc(num*sizeof(T))); return ret;
#endif
}
// initialize elements of allocated storage p with value value
// using placement new (defined here)
void construct (ptr p, const T& value) {new (reinterpret_cast<void*>(p))T(value);}
// placement new
void* operator new (std::size_t size, void*){return allocate(size);}
// destroy elements of initialized storage p
void destroy (ptr p) {p->~T();}
// deallocate storage p of deleted elements
void deallocate(ptr p, size_type num) {
#ifdef DEBUG_TLSF_CPP
// print message and deallocate memory with global delete
std::cerr << "deallocate " << num << " element(s)" << " of size " << sizeof(T) << " at: " << (void*)p << std::endl;
#endif
tlsf_free(reinterpret_cast<void*>(p));
}
};
// return that all specializations of this allocator are interchangeable
template <class T1, class T2> bool operator== (const TLSFAlloc<T1>&,const TLSFAlloc<T2>&) throw() { return true; }
template <class T1, class T2> bool operator!= (const TLSFAlloc<T1>&, const TLSFAlloc<T2>&) throw() { return false; }
}

+ 17
- 2
src/main.cpp View File

@@ -4,11 +4,23 @@
#include "Log.h"
#include "URL.h"
#include "WebResource.h"

extern "C"{
#include "tlsf.h"
#ifdef _WIN32
void init_heap();
#endif
}
#include <ctime>
#include <iostream>
#include <sys/stat.h>

#if defined(_WIN32) && !defined(_WIN64)
#define PLATFORM "i686-pc-winnt"
#endif
#ifdef _WIN64
#define PLATFORM "amd64-pc-winnt"
#endif

const std::unique_ptr<Window> window = std::make_unique<Window>();
//URL currentURL;

@@ -53,7 +65,10 @@ int main(int argc, char *argv[]) {
return 1;
}
*/
std::cout << "/g/ntr - NetRunner build " << __DATE__ << std::endl;
# ifdef _WIN32
init_heap(); // the NT port requires it. We do it at startup now, to allow 2LSF to run at any time
# endif
std::cout << "/g/ntr - NetRunner build " << __DATE__ << ": rev-" << VERSION << " for " << PLATFORM << std::endl;

// we need to set up OGL before we can setDOM (because component can't be constructed (currently) without OGL)
// but should be after CommandLineParams incase we need to change some type of window config

+ 1
- 1
src/networking/HTTPSRequest.cpp View File

@@ -134,7 +134,7 @@ bool HTTPSRequest::initTLS()
mbedtls_x509_crt_init( &cacert );
mbedtls_ctr_drbg_init( &ctr_drbg );
const char *seed = "netrunner_ssl_seed$%?rvx86_despair^^%$#@";
const char *seed = "!@netrunner_ssl_seed$%?rvx86_despair##^^%$#@";
mbedtls_entropy_init( &entropy );
if(mbedtls_ctr_drbg_seed( &ctr_drbg, mbedtls_entropy_func, &entropy, reinterpret_cast<const unsigned char*>(seed), strlen(seed) ) != 0 )
{

+ 4
- 0
src/networking/HTTPSRequest.h View File

@@ -6,6 +6,10 @@
#include "../URL.h"
#include <functional>
#include <string>
#ifdef NULL
#undef NULL
#define NULL nullptr
#endif
// PolarSSL
#include <mbedtls/ssl.h>
#include <mbedtls/entropy.h>

+ 1
- 1
src/pnm.cpp View File

@@ -58,7 +58,7 @@ RGBAPNMObject * readPPM(const char* fileName) {
}

// allocate array for pixels
char* pixels = new char[size];
char* pixels = reinterpret_cast<char*>(tlsf_calloc(size, sizeof(char)));/*new char[size]*/;

// unformatted read of binary pixel data
res = fread(pixels, sizeof(int), size, fr);

+ 7
- 1
src/pnm.h View File

@@ -1,10 +1,16 @@
#include <string>

extern "C"{
#include "tlsf.h"
}
// this structure expects RGBA
struct RGBAPNMObject {
std::string magicNum;
unsigned int width, height, maxColVal;
char * m_Ptr;

// fast allocation!
static void* operator new(size_t n){if (void *mem = tlsf_malloc(n)) return mem; throw std::bad_alloc {}; }
static void operator delete(void *p){tlsf_free(p);}
};

RGBAPNMObject * readPPM(const char* fileName);

+ 12
- 0
src/target.h View File

@@ -0,0 +1,12 @@
#ifndef _TARGET_H_
#define _TARGET_H_

#include <pthread.h>

#define TLSF_MLOCK_T pthread_mutex_t
#define TLSF_CREATE_LOCK(l) pthread_mutex_init (l, NULL)
#define TLSF_DESTROY_LOCK(l) pthread_mutex_destroy(l)
#define TLSF_ACQUIRE_LOCK(l) pthread_mutex_lock(l)
#define TLSF_RELEASE_LOCK(l) pthread_mutex_unlock(l)

#endif

+ 84
- 0
src/tlsf-winnt.h View File

@@ -0,0 +1,84 @@
/* Heap management routines (including unexec) for NetRunner on Windows NT.

This file was taken from GNU Emacs.
Copyright (C) 1994, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009 Free Software Foundation, Inc.
*/

#ifndef NTHEAP_H_
#define NTHEAP_H_

#include <windows.h>

#define ROUND_UP(p, align) (((DWORD)(p) + (align)-1) & ~((align)-1))
#define ROUND_DOWN(p, align) ((DWORD)(p) & ~((align)-1))

/*
* Heap related stuff.
*/
#define get_reserved_heap_size() reserved_heap_size
#define get_committed_heap_size() (get_data_end () - get_data_start ())
#define get_heap_start() get_data_start ()
#define get_heap_end() get_data_end ()
#define get_page_size() nt_sysinfo.dwPageSize
#define get_allocation_unit() nt_sysinfo.dwAllocationGranularity
#define get_processor_type() nt_sysinfo.dwProcessorType
#define get_w32_major_version() nt_major_version
#define get_w32_minor_version() nt_minor_version

extern unsigned char *get_data_start();
extern unsigned char *get_data_end();
extern unsigned long reserved_heap_size;
extern SYSTEM_INFO nt_sysinfo;
extern OSVERSIONINFO nt_apilevel;
extern BOOL using_dynamic_heap;
extern int nt_major_version;
extern int nt_minor_version;
extern int nt_build_number;

enum {
OS_WIN95 = 1,
OS_NT
};

extern int os_subtype;

/* Emulation of Unix sbrk(). */
extern void *sbrk (unsigned long size);

/* Initialize heap structures for sbrk on startup. */
extern void init_heap ();

/* Round the heap to this size. */
extern void round_heap (unsigned long size);

/* Cache system info, e.g., the NT page size. */
extern void cache_system_info (void);

/* ----------------------------------------------------------------- */
/* Useful routines for manipulating memory-mapped files. */

typedef struct file_data {
char *name;
unsigned long size;
HANDLE file;
HANDLE file_mapping;
unsigned char *file_base;
} file_data;

int open_input_file (file_data *p_file, char *name);
int open_output_file (file_data *p_file, char *name, unsigned long size);
void close_file_data (file_data *p_file);

/* Return pointer to section header for named section. */
IMAGE_SECTION_HEADER * find_section (char * name, IMAGE_NT_HEADERS * nt_header);

/* Return pointer to section header for section containing the given
relative virtual address. */
IMAGE_SECTION_HEADER * rva_to_section (DWORD rva, IMAGE_NT_HEADERS * nt_header);
#define RVA_TO_PTR(rva) ((unsigned char *)((DWORD)(rva) + (DWORD)GetModuleHandle(NULL)))
#ifndef VALBITS
#define VALBITS (32 - 3)
#endif
#define VALMASK ((((int) 1) << VALBITS) - 1)
#endif /* NTHEAP_H_ */

+ 1230
- 0
src/tlsf.c
File diff suppressed because it is too large
View File


+ 39
- 0
src/tlsf.h View File

@@ -0,0 +1,39 @@
/*
* Two Levels Segregate Fit memory allocator (TLSF)
* Version 2.4.6
*
* Written by Miguel Masmano Tello <mimastel@doctor.upv.es>
*
* Thanks to Ismael Ripoll for his suggestions and reviews
*
* Copyright (C) 2008, 2007, 2006, 2005, 2004
*
* This code is released using a dual license strategy: GPL/LGPL
* You can choose the licence that better fits your requirements.
*
* Released under the terms of the GNU General Public License Version 2.0
* Released under the terms of the GNU Lesser General Public License Version 2.1
*
*/

#ifndef _TLSF_H_
#define _TLSF_H_

#include <sys/types.h>

extern size_t init_memory_pool(size_t, void *);
extern size_t get_used_size(void *);
extern size_t get_max_size(void *);
extern void destroy_memory_pool(void *);
extern size_t add_new_area(void *, size_t, void *);
extern void *malloc_ex(size_t, void *);
extern void free_ex(void *, void *);
extern void *realloc_ex(void *, size_t, void *);
extern void *calloc_ex(size_t, size_t, void *);

extern void *tlsf_malloc(size_t size);
extern void tlsf_free(void *ptr);
extern void *tlsf_realloc(void *ptr, size_t size);
extern void *tlsf_calloc(size_t nelem, size_t elem_size);

#endif

+ 20
- 0
winnt-ci.sh View File

@@ -0,0 +1,20 @@
#!/usr/bin/sh
if [ $MSYSTEM == "MINGW32" ]
then
make -fNTMakeFile
else
make -fNTMakefile AMD64=1
fi
strip -s netrunner.exe
[ -e 'bin' ] || mkdir bin
mv *.pnm bin 2> /dev/null
mv *.crt bin 2> /dev/null
mv *.ttf bin 2> /dev/null
if [ $MSYSTEM == "MINGW32" ]
then
cp reltools/winnt/i386/*.dll bin
else
cp reltools/winnt/amd64/*.dll bin
fi
mv LICENSE bin
mv netrunner.exe bin

Loading…
Cancel
Save