summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--Makefile8
-rw-r--r--README.md18
-rw-r--r--changelog.md8
-rw-r--r--include/benoit/d/ver.hh2
-rw-r--r--include/benoit/err/clsfil.hh7
-rw-r--r--include/benoit/err/wrttofil.hh7
-rw-r--r--include/benoit/print.hh1
-rw-r--r--include/benoit/t/pos.hh9
-rw-r--r--include/benoit/t/rgba.hh8
-rw-r--r--include/benoit/t/thrddat.hh3
-rw-r--r--src/benoit/crtcfg.cc30
-rw-r--r--src/benoit/d/cfg.cc2
-rw-r--r--src/benoit/err/clsfil.cc8
-rw-r--r--src/benoit/err/wrttofil.cc8
-rw-r--r--src/benoit/helpscrn.cc4
-rw-r--r--src/benoit/loadcfg.cc35
-rw-r--r--src/benoit/main.cc1
-rw-r--r--src/benoit/plotmandelbrot.cc106
-rw-r--r--src/benoit/print.cc12
-rw-r--r--src/benoit/t/pos/pos.cc7
-rw-r--r--src/benoit/wrtimg.cc18
22 files changed, 213 insertions, 91 deletions
diff --git a/.gitignore b/.gitignore
index bd6d5c7..674bb53 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,5 +1,5 @@
+*.json
*.o
*.png
*.webp
-*.xml
/benoit
diff --git a/Makefile b/Makefile
index e7e2762..a3384a0 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,11 @@
CXX=g++
-CXXFLAGS=-Iinclude -D_ATFILE_SOURCE -D_FORTIFY_SOURCE=0x2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_ISOC99_SOURCE -D_ISOC11_SOURCE -D_ISOC2X_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D__STDC_WANT_IEC_60559_BFP_EXT__ -D__STDC_WANT_IEC_60559_FUNCS_EXT__ -D__STDC_WANT_IEC_60559_TYPES_EXT__ -D__STDC_WANT_LIB_EXT2__=0x1
+CXXFLAGS=-Iinclude -D_ATFILE_SOURCE -D_FORTIFY_SOURCE=0x2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_ISOC99_SOURCE -D_ISOC11_SOURCE -D_ISOC2X_SOURCE -D_POSIX_C_SOURCE=200809L -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED -D__STDC_WANT_IEC_60559_BFP_EXT__ -D__STDC_WANT_IEC_60559_DFP_EXT__ -D__STDC_WANT_IEC_60559_FUNCS_EXT__ -D__STDC_WANT_IEC_60559_TYPES_EXT__ -D__STDC_WANT_LIB_EXT2__=0x1
ifneq ($(debug),true)
CXXFLAGS += -DNDEBUG -g
endif
CXXFLAGS += -std=c++20 -Wall -Wextra -Wpedantic
CXXFLAGS += -march=native -mtune=native -O3
-LDFLAGS = -lfmt -lgmp -lmpfr -lpng -lpthread -lpugixml -lwebp
+LDFLAGS = -lfmt -lpng -lpthread -lwebp
HDRS_CXX = \
include/benoit/archstr.hh \
include/benoit/arghandl.hh \
@@ -27,6 +27,8 @@ HDRS_CXX = \
include/benoit/d/resy.hh \
include/benoit/d/thelog.hh \
include/benoit/d/ver.hh \
+ include/benoit/err/clsfil.hh \
+ include/benoit/err/wrttofil.hh \
include/benoit/exit.hh \
include/benoit/helpscrn.hh \
include/benoit/kernelstr.hh \
@@ -61,6 +63,8 @@ SRCS_CXX = \
src/benoit/d/resx.cc \
src/benoit/d/resy.cc \
src/benoit/d/thelog.cc \
+ src/benoit/err/clsfil.cc \
+ src/benoit/err/wrttofil.cc \
src/benoit/exit.cc \
src/benoit/helpscrn.cc \
src/benoit/kernelstr.cc \
diff --git a/README.md b/README.md
index 8f738fa..5c52320 100644
--- a/README.md
+++ b/README.md
@@ -12,7 +12,7 @@ For information regarding copyright of the software and it's license, please rea
## Building
-The included Makefile is supposed to work for most platforms.
+The included Makefile is supposed to work.
In the event it doesn't, find a solution.
@@ -20,19 +20,11 @@ In the event it doesn't, find a solution.
This project depends on the following libraries:
-* Boost.Multiprecision (for multiprecision calculations)
-* {FMT} (for string-formatting)
-* GMP (a dependency of Boost.Multiprecision)
-* libpng (for encoding PNG images)
-* libwebp (for encoding WebP images)
-* MPFR (a dependency of Boost.Multiprecision)
-* pugixml (for XML parsing)
+* [*{FMT}*](https://github.com/fmtlib/fmt) for string-formatting.
+* [*libpng*](https://github.com/glennrp/libpng) for encoding PNG images.
+* [*libwebp*](https://chromium.googlesource.com/webm/libwebp) for encoding WebP images.
-The project is written for POSIX and therefore requires the POSIX libraries.
-
-Other than that, it also requires the target system to have the LLP64 data-model or greater.
-
-Targets with a pointer size of less than 64b are currently incompatible, but architectures like Aarch64, AMD64, IA-64 and PPC64 are expected to work, no-problem.
+The project requires the target system to use the LLP64 data-model or greater.
## Copyright & License
diff --git a/changelog.md b/changelog.md
index c6bc39a..7601586 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,11 @@
+# ↋
+
+* Drop *boost::multiprecision::mpfr_float* in favour of the standard type *::__float128* for multiprecision.
+* Create a prettier colour palette.
+* Use JSON instead of XML for configuration.
+* Automatically create a configuration file if one doesn't already exist.
+* Greatly improve render time.
+
# ↊
* Fix #3.
diff --git a/include/benoit/d/ver.hh b/include/benoit/d/ver.hh
index 95e28b9..42fc054 100644
--- a/include/benoit/d/ver.hh
+++ b/include/benoit/d/ver.hh
@@ -1,6 +1,6 @@
# pragma once
namespace benoit {
namespace d {
- unsigned long long constexpr ver = 0xA;
+ unsigned long long constexpr ver = 0xB;
}
}
diff --git a/include/benoit/err/clsfil.hh b/include/benoit/err/clsfil.hh
new file mode 100644
index 0000000..ed853b9
--- /dev/null
+++ b/include/benoit/err/clsfil.hh
@@ -0,0 +1,7 @@
+# pragma once
+# include <string>
+namespace benoit {
+ namespace err {
+ void clsfil(std::string const fil) noexcept;
+ }
+}
diff --git a/include/benoit/err/wrttofil.hh b/include/benoit/err/wrttofil.hh
new file mode 100644
index 0000000..232d431
--- /dev/null
+++ b/include/benoit/err/wrttofil.hh
@@ -0,0 +1,7 @@
+# pragma once
+# include <string>
+namespace benoit {
+ namespace err {
+ void wrttofil(std::string const fil) noexcept;
+ }
+}
diff --git a/include/benoit/print.hh b/include/benoit/print.hh
index 64ad638..0f85fd3 100644
--- a/include/benoit/print.hh
+++ b/include/benoit/print.hh
@@ -1,6 +1,5 @@
# pragma once
# include <string>
namespace benoit {
- void print(char const * msg,bool stderr = false);
void print(std::string msg,bool stderr = false);
}
diff --git a/include/benoit/t/pos.hh b/include/benoit/t/pos.hh
index aa43522..697fdef 100644
--- a/include/benoit/t/pos.hh
+++ b/include/benoit/t/pos.hh
@@ -1,13 +1,12 @@
# pragma once
-# include <boost/multiprecision/mpfr.hpp>
namespace benoit {
namespace t {
class pos {
public:
- pos(boost::multiprecision::mpfr_float x = 0x0,boost::multiprecision::mpfr_float y = 0x0);
- long double x = 0x0;
- long double y = 0x0;
- long double zoom = 0x1;
+ pos(__float128 x = 0x0,__float128 y = 0x0);
+ __float128 x = 0x0;
+ __float128 y = 0x0;
+ __float128 zoom = 0x1;
};
}
}
diff --git a/include/benoit/t/rgba.hh b/include/benoit/t/rgba.hh
index e34112f..a1bdcf7 100644
--- a/include/benoit/t/rgba.hh
+++ b/include/benoit/t/rgba.hh
@@ -4,10 +4,10 @@ namespace benoit {
namespace t {
class rgba {
public:
- std::uint8_t a = 0xFF;
- std::uint8_t b = 0x0;
- std::uint8_t g = 0x0;
- std::uint8_t r = 0x0;
+ std::uint8_t a = 0xFFu;
+ std::uint8_t b = 0x0u;
+ std::uint8_t g = 0x0u;
+ std::uint8_t r = 0x0u;
};
}
}
diff --git a/include/benoit/t/thrddat.hh b/include/benoit/t/thrddat.hh
index 1318c00..85b3bfb 100644
--- a/include/benoit/t/thrddat.hh
+++ b/include/benoit/t/thrddat.hh
@@ -6,8 +6,9 @@ namespace benoit {
namespace t {
class thrddat {
public:
- pthread_t * thrd = nullptr;
benoit::t::rgba * img = nullptr;
+ bool * isrun = nullptr;
+ pthread_t * thrd = nullptr;
unsigned * id = nullptr;
unsigned long long * imgbegin = nullptr;
unsigned long long * imgend = nullptr;
diff --git a/src/benoit/crtcfg.cc b/src/benoit/crtcfg.cc
index 202016c..6784467 100644
--- a/src/benoit/crtcfg.cc
+++ b/src/benoit/crtcfg.cc
@@ -1,10 +1,40 @@
# include <benoit/crtcfg.hh>
+# include <benoit/d/cfg.hh>
+# include <benoit/err/clsfil.hh>
+# include <benoit/err/wrttofil.hh>
# include <benoit/logfunc.hh>
# include <benoit/logfuncret.hh>
+# include <benoit/print.hh>
+# include <cstdint>
+# include <fcntl.h>
+# include <fmt/core.h>
# include <string>
+# include <unistd.h>
using namespace std::literals::string_literals;
void benoit::crtcfg() {
std::string const funcname = "benoit::crtcfg()"s;
benoit::logfunc(funcname);
+ std::string cfgstr = ""s;
+ cfgstr.append("{\u000A"s);
+ cfgstr.append("\u0009\u0022benoit\u0022:[\u000A"s);
+ cfgstr.append("\u0009\u0009{\u000A"s);
+ cfgstr.append("\u0009\u0009\u0009\u0022x\u0022:\u00221÷1\u0022,\u000A"s);
+ cfgstr.append("\u0009\u0009\u0009\u0022y\u0022:\u00221÷1\u0022,\u000A"s);
+ cfgstr.append("\u0009\u0009\u0009\u0022zoom\u0022:\u00220÷1\u0022\u000A"s);
+ cfgstr.append("\u0009\u0009}\u000A"s);
+ cfgstr.append("\u0009]\u000A"s);
+ cfgstr.append("}\u000A"s);
+ std::uint8_t * dat = reinterpret_cast<std::uint8_t *>(const_cast<char *>(cfgstr.c_str()));
+ int fil = ::open(benoit::d::cfg.c_str(),(O_CREAT | O_TRUNC | O_WRONLY),0x1B4);
+ for(unsigned long long pos = 0x0;(pos < cfgstr.size());++pos) {
+ ::ssize_t byteswrtn = ::write(fil,&dat[pos],0x1);
+ if(byteswrtn < 0x0) {
+ benoit::err::wrttofil(benoit::d::cfg);
+ return;
+ }
+ }
+ if(::close(fil) < 0x0) {
+ benoit::err::clsfil(benoit::d::cfg);
+ }
benoit::logfuncret(funcname);
}
diff --git a/src/benoit/d/cfg.cc b/src/benoit/d/cfg.cc
index 7b9cf99..0f8e82c 100644
--- a/src/benoit/d/cfg.cc
+++ b/src/benoit/d/cfg.cc
@@ -1,4 +1,4 @@
# include <benoit/d/cfg.hh>
# include <string>
using namespace std::literals::string_literals;
-std::string benoit::d::cfg = "benoit.xml"s;
+std::string benoit::d::cfg = "benoit.json"s;
diff --git a/src/benoit/err/clsfil.cc b/src/benoit/err/clsfil.cc
new file mode 100644
index 0000000..548ce7a
--- /dev/null
+++ b/src/benoit/err/clsfil.cc
@@ -0,0 +1,8 @@
+# include <benoit/err/clsfil.hh>
+# include <benoit/print.hh>
+# include <fmt/core.h>
+# include <string>
+using namespace std::literals::string_literals;
+void benoit::err::clsfil(std::string const fil) noexcept {
+ benoit::print(fmt::format("Unable to close file “{}”."s,fil),true);
+}
diff --git a/src/benoit/err/wrttofil.cc b/src/benoit/err/wrttofil.cc
new file mode 100644
index 0000000..eb756f9
--- /dev/null
+++ b/src/benoit/err/wrttofil.cc
@@ -0,0 +1,8 @@
+# include <benoit/err/wrttofil.hh>
+# include <benoit/print.hh>
+# include <fmt/core.h>
+# include <string>
+using namespace std::literals::string_literals;
+void benoit::err::wrttofil(std::string const fil) noexcept {
+ benoit::print(fmt::format("Unable to write to “{}”."s,fil),true);
+}
diff --git a/src/benoit/helpscrn.cc b/src/benoit/helpscrn.cc
index 70dd5c6..02ef215 100644
--- a/src/benoit/helpscrn.cc
+++ b/src/benoit/helpscrn.cc
@@ -115,11 +115,13 @@ using namespace std::literals::string_literals;
else {
datmod = fmt::format("{} AKA how the fuck did this get compiled?"s,datmod);
}
+ bool logdoprint = benoit::d::logdoprint;
benoit::d::logdoprint = false;
benoit::d::printdolog = false;
benoit::print(""s);
benoit::print(fmt::format("benoit {}",benoit::d::ver));
benoit::print("Copyright 2021 Gabriel Jensen"s);
+ benoit::print("All rigths reserved."s);
benoit::print(""s);
benoit::print("Arguments:"s);
benoit::print("\u0009alpha={false,true}:"s);
@@ -144,7 +146,7 @@ using namespace std::literals::string_literals;
benoit::print(fmt::format("\u0009Data Model: {}"s,datmod));
benoit::print(fmt::format("\u0009System Kernel: {}"s,benoit::kernelstr(benoit::d::kernel)));
benoit::print(""s);
- benoit::d::logdoprint = true;
+ benoit::d::logdoprint = logdoprint;
benoit::d::printdolog = true;
benoit::exit(EXIT_SUCCESS);
}
diff --git a/src/benoit/loadcfg.cc b/src/benoit/loadcfg.cc
index 937d5a8..b1be003 100644
--- a/src/benoit/loadcfg.cc
+++ b/src/benoit/loadcfg.cc
@@ -1,15 +1,48 @@
# include <benoit/crtcfg.hh>
# include <benoit/d/cfg.hh>
+# include <benoit/d/pos.hh>
# include <benoit/loadcfg.hh>
+# include <benoit/log.hh>
+# include <benoit/logfunc.hh>
+# include <benoit/logfuncret.hh>
+# include <benoit/print.hh>
+# include <fcntl.h>
+# include <fmt/core.h>
# include <iostream>
-# include <pugixml.hpp>
# include <string>
+# include <sys/stat.h>
# include <unistd.h>
+# include <iostream>
using namespace std::literals::string_literals;
void benoit::loadcfg() {
std::string const funcname = "benoit::loadcfg()"s;
+ benoit::logfunc(funcname);
if(::access(benoit::d::cfg.c_str(),R_OK) < 0x0) {
benoit::crtcfg();
return;
}
+ int filsiz = 0x0;
+ {
+ struct ::stat st;
+ ::stat(benoit::d::cfg.c_str(),&st);
+ filsiz = static_cast<int>(st.st_size);
+ }
+ benoit::log(fmt::format("The size of “{}” is {}."s,benoit::d::cfg,filsiz));
+ if(filsiz == 0x0) {
+ benoit::crtcfg();
+ return;
+ }
+ std::string cfgstr = ""s;
+ {
+ int fil = ::open(benoit::d::cfg.c_str(),O_RDONLY);
+ char * cfgcstr = ::new char[filsiz];
+ for(int pos = 0x0;(pos < filsiz);++pos) {
+ if(::read(fil,&cfgcstr[pos],0x1) < 0x0) {
+ }
+ }
+ cfgstr = std::string(cfgcstr);
+ delete[] cfgcstr;
+ ::close(fil);
+ }
+ benoit::logfuncret(funcname);
}
diff --git a/src/benoit/main.cc b/src/benoit/main.cc
index 267f7f1..fbddfa2 100644
--- a/src/benoit/main.cc
+++ b/src/benoit/main.cc
@@ -20,7 +20,6 @@ static_assert(((sizeof(short) >= 0x2) && (sizeof(int) >= 0x4) && (sizeof(long) >
using namespace std::literals::string_literals;
[[noreturn]] void benoit::main(int const argc,char const * * argv) noexcept {
std::string const funcname = "benoit::main(int const,char const * *)"s;
- benoit::log(fmt::format("{}"s,argv[0x0]));
benoit::logfunc(funcname);
benoit::d::numthrds = std::thread::hardware_concurrency();
benoit::log(fmt::format("{} availabe threads have been detected."s,benoit::d::numthrds));
diff --git a/src/benoit/plotmandelbrot.cc b/src/benoit/plotmandelbrot.cc
index 8517c99..6d3b993 100644
--- a/src/benoit/plotmandelbrot.cc
+++ b/src/benoit/plotmandelbrot.cc
@@ -11,8 +11,7 @@
# include <benoit/print.hh>
# include <benoit/t/thrddat.hh>
# include <benoit/t/rgba.hh>
-# include <boost/multiprecision/mpfr.hpp>
-# include <cassert>
+# include <cmath>
# include <cstdint>
# include <fmt/core.h>
# include <pthread.h>
@@ -22,37 +21,54 @@ using namespace std::literals::string_literals;
namespace {
void * plotarea(void * thrddatptr) {
benoit::t::thrddat * thrddat = reinterpret_cast<benoit::t::thrddat *>(thrddatptr);
- const long double maxR = 0x2p0;
- const long double minR = -0x2p0;
- const long double maxI = 0x2p0;
- const long double minI = -0x2p0;
for(unsigned long long px = *thrddat->imgbegin;(px <= *thrddat->imgend);++px) {
unsigned x = (px % benoit::d::resx);
unsigned y = ((px - (px % benoit::d::resy)) / benoit::d::resy);
- long double r = x * ((maxR + benoit::d::pos.x * benoit::d::pos.zoom) / benoit::d::pos.zoom - (minR + benoit::d::pos.x * benoit::d::pos.zoom) / benoit::d::pos.zoom) / benoit::d::resx + (minR + benoit::d::pos.x * benoit::d::pos.zoom) / benoit::d::pos.zoom;
- long double i = y * ((maxI + benoit::d::pos.y * benoit::d::pos.zoom) / benoit::d::pos.zoom - (minI + benoit::d::pos.y * benoit::d::pos.zoom) / benoit::d::pos.zoom) / benoit::d::resx + (minI + benoit::d::pos.y * benoit::d::pos.zoom) / benoit::d::pos.zoom;
- long double r2 = 0x0p0;
- long double i2 = 0x0p0;
- unsigned iter;
- for(iter = 0x0u; iter < benoit::d::maxiter; ++iter) {
- if(r2 * r2 + i2 * i2 >= 0x4p0) {
+ ::__float128 r = x * ((0x2p0 + benoit::d::pos.x * benoit::d::pos.zoom) / benoit::d::pos.zoom - (-0x2p0 + benoit::d::pos.x * benoit::d::pos.zoom) / benoit::d::pos.zoom) / benoit::d::resx + (-0x2p0 + benoit::d::pos.x * benoit::d::pos.zoom) / benoit::d::pos.zoom;
+ ::__float128 i = y * ((0x2p0 + benoit::d::pos.y * benoit::d::pos.zoom) / benoit::d::pos.zoom - (-0x2p0 + benoit::d::pos.y * benoit::d::pos.zoom) / benoit::d::pos.zoom) / benoit::d::resx + (-0x2p0 + benoit::d::pos.y * benoit::d::pos.zoom) / benoit::d::pos.zoom;
+ ::__float128 r1 = 0x0p0;
+ ::__float128 i1 = 0x0p0;
+ unsigned long long iter = 0x0ull;
+ for(;(iter < benoit::d::maxiter);++iter) {
+ if((r1 * r1 + i1 * i1) >= 0x4p0) {
break;
}
- long double r2Temp = r2 * r2 - i2 * i2 + r;
- long double i2Temp = 0x2p0 * r2 * i2 + i;
- if(r2 == r2Temp && i2 == i2Temp) {
+ ::__float128 r1tmp = (r1 * r1 - i1 * i1 + r);
+ ::__float128 i1tmp = (0x2p0 * r1 * i1 + i);
+ if((r1 == r1tmp) && (i1 == i1tmp)) {
iter = benoit::d::maxiter;
break;
}
- r2 = r2Temp;
- i2 = i2Temp;
+ r1 = r1tmp;
+ i1 = i1tmp;
}
- {
- float tmp = ((float)(iter) / (float)(benoit::d::maxiter));
- thrddat->img[px].r = static_cast<std::uint8_t>((0x1p0 - tmp) * 0xFFp0);
- thrddat->img[px].g = static_cast<std::uint8_t>((0x1p0 - tmp) * 0xFFp0);
- thrddat->img[px].b = static_cast<std::uint8_t>((0x1p0 - tmp) * 0xFFp0);
- thrddat->img[px].a = static_cast<std::uint8_t>(tmp * 0xFFp0);
+ if(iter != benoit::d::maxiter) {
+ float fac = (static_cast<float>(iter) / 0x40p0);
+ fac = (fac - std::floor(fac));
+ if(fac <= (0x1p0 / 0x4p0)) {
+ thrddat->img[px].r = static_cast<std::uint8_t>(fac * 0xFFp0 * 0x4p0);
+ thrddat->img[px].g = static_cast<std::uint8_t>(0x0p0);
+ thrddat->img[px].b = static_cast<std::uint8_t>(0x0p0);
+ }
+ else if(fac <= (0x1p0 / 0x2p0)) {
+ thrddat->img[px].r = static_cast<std::uint8_t>(0xFFp0);
+ thrddat->img[px].g = static_cast<std::uint8_t>(fac * 0xFFp0 * 0x4p0);
+ thrddat->img[px].b = static_cast<std::uint8_t>(0x0p0);
+ }
+ else if(fac <= (0x3p0 / 0x4p0)) {
+ thrddat->img[px].r = static_cast<std::uint8_t>(0xFFp0);
+ thrddat->img[px].g = static_cast<std::uint8_t>(0xFFp0);
+ thrddat->img[px].b = static_cast<std::uint8_t>(fac * 0xFFp0 * 0x4p0);
+ }
+ else {
+ fac = (0x1p0 - fac);
+ thrddat->img[px].r = static_cast<std::uint8_t>(fac * 0xFFp0 * 0x4p0);
+ thrddat->img[px].g = static_cast<std::uint8_t>(fac * 0xFFp0 * 0x4p0);
+ thrddat->img[px].b = static_cast<std::uint8_t>(fac * 0xFFp0 * 0x4p0);
+ }
+ }
+ else {
+ thrddat->img[px].a = 0x0u;
}
}
pthread_exit(nullptr);
@@ -67,28 +83,40 @@ std::vector<std::uint8_t> * benoit::plotmandelbrot() {
benoit::t::rgba * rgbaimg = ::new benoit::t::rgba[numpx];
std::vector<benoit::t::thrddat> thrds(benoit::d::numthrds);
for(unsigned thrdid = 0x0;(thrdid < benoit::d::numthrds);++thrdid) {
- thrds[thrdid].id = ::new unsigned(thrdid);
- thrds[thrdid].img = rgbaimg;
- thrds[thrdid].imgbegin = ::new unsigned long long(numpx / benoit::d::numthrds * thrdid);
- if((thrdid + 0x1) == benoit::d::numthrds) {
- thrds[thrdid].imgend = ::new unsigned long long(*thrds[thrdid].imgbegin + remainpx);
+ benoit::log(fmt::format("Allocating data for thread #{}."s,thrdid));
+ thrds[thrdid].id = ::new unsigned(thrdid);
+ thrds[thrdid].img = rgbaimg;
+ thrds[thrdid].isrun = ::new bool(false);
+ thrds[thrdid].thrd = ::new pthread_t;
+ }
+ for(unsigned thrdid = 0x0,y = 0x0u;(y < benoit::d::resy);++thrdid,++y) {
+ if(remainpx == 0x0) {
+ break;
}
- else {
- thrds[thrdid].imgend = ::new unsigned long long(*thrds[thrdid].imgbegin + numpx / benoit::d::numthrds);
+ if(thrdid == benoit::d::numthrds) {
+ thrdid = 0x0;
}
- --*thrds[thrdid].imgend;
- assert(*thrds[thrdid].imgend <= numpx);
- remainpx -= (*thrds[thrdid].imgend - *thrds[thrdid].imgbegin + 0x1);
- thrds[thrdid].thrd = ::new pthread_t;
- benoit::log(fmt::format("Thread #{} will render a total of {} pixels, starting at position {} and ending at position {}, which means there are {} pixels remaining."s,thrdid,(*thrds[thrdid].imgend - *thrds[thrdid].imgbegin + 0x1),*thrds[thrdid].imgbegin,*thrds[thrdid].imgend,remainpx));
+ if(*thrds[thrdid].isrun) {
+ pthread_join(*thrds[thrdid].thrd,nullptr);
+ delete thrds[thrdid].isrun;
+ thrds[thrdid].isrun = ::new bool(false);
+ }
+ thrds[thrdid].imgbegin = ::new unsigned long long(y * benoit::d::resx);
+ thrds[thrdid].imgend = ::new unsigned long long(*thrds[thrdid].imgbegin + benoit::d::resx - 0x1);
::pthread_create(thrds[thrdid].thrd,nullptr,::plotarea,&thrds[thrdid]);
+ delete thrds[thrdid].isrun;
+ thrds[thrdid].isrun = ::new bool(true);
}
for(auto thrd : thrds) {
- ::pthread_join(*thrd.thrd,nullptr);
- benoit::log(fmt::format("Thread #{} has joined."s,*thrd.id));
+ benoit::log(fmt::format("Destroying thread #{}'s data."s,*thrd.id));
+ if(*thrd.isrun) {
+ ::pthread_join(*thrd.thrd,nullptr);
+ }
+ thrd.img = nullptr;
::delete thrd.id;
::delete thrd.imgbegin;
::delete thrd.imgend;
+ ::delete thrd.isrun;
::delete thrd.thrd;
}
std::vector<std::uint8_t> * img = ::new std::vector<std::uint8_t>;
@@ -103,7 +131,7 @@ std::vector<std::uint8_t> * benoit::plotmandelbrot() {
img->push_back(0xFF);
}
}
- ::delete rgbaimg;
+ ::delete[] rgbaimg;
benoit::logfuncret(funcname);
return img;
}
diff --git a/src/benoit/print.cc b/src/benoit/print.cc
index e1488bd..6d9d953 100644
--- a/src/benoit/print.cc
+++ b/src/benoit/print.cc
@@ -6,22 +6,18 @@
# include <string>
# include <unistd.h>
using namespace std::literals::string_literals;
-void benoit::print(char const * msg,bool stderr) {
- std::string const funcname = "benoit::print(char const *,bool)"s;
- benoit::print(std::string(msg),stderr);
-}
void benoit::print(std::string msg,bool stderr) {
std::string const funcname = "benoit::print(std::string,bool)"s;
if(benoit::d::printdolog) {
benoit::d::thelog.insert(benoit::d::thelog.begin(),msg);
}
msg.append("\u000A"s);
- int file = 0x0;
+ int fil = 0x0;
if(stderr) {
- file = 0x1;
+ fil = 0x1;
}
- if(::write(file,msg.c_str(),msg.size()) < 0x0) {
+ if(::write(fil,msg.c_str(),msg.size()) < 0x0) {
throw std::runtime_error("Unable to write to Stdout.");
}
- fsync(file);
+ fsync(fil);
}
diff --git a/src/benoit/t/pos/pos.cc b/src/benoit/t/pos/pos.cc
index a69f8ec..50fa2df 100644
--- a/src/benoit/t/pos/pos.cc
+++ b/src/benoit/t/pos/pos.cc
@@ -1,6 +1,5 @@
# include <benoit/t/pos.hh>
-# include <boost/multiprecision/mpfr.hpp>
-benoit::t::pos::pos(boost::multiprecision::mpfr_float x,boost::multiprecision::mpfr_float y) {
- //this->x = x;
- //this->y = y;
+benoit::t::pos::pos(__float128 x,__float128 y) {
+ this->x = x;
+ this->y = y;
}
diff --git a/src/benoit/wrtimg.cc b/src/benoit/wrtimg.cc
index 0f10257..1053a9e 100644
--- a/src/benoit/wrtimg.cc
+++ b/src/benoit/wrtimg.cc
@@ -2,6 +2,8 @@
# include <benoit/d/outimg.hh>
# include <benoit/d/resx.hh>
# include <benoit/d/resy.hh>
+# include <benoit/err/clsfil.hh>
+# include <benoit/err/wrttofil.hh>
# include <benoit/logfunc.hh>
# include <benoit/logfuncret.hh>
# include <benoit/print.hh>
@@ -23,7 +25,7 @@ void benoit::wrtimg(std::vector<std::uint8_t> * img) {
std::string const funcname = "benoit::wrtimg(std::vector<std::uint8_t> *)"s;
benoit::logfunc(funcname);
std::uint8_t * dat;
- unsigned long long datsiz;
+ unsigned long long datsiz = 0x0;
switch(benoit::d::imgfmt) {
case benoit::t::imgfmt::png:
break;
@@ -31,18 +33,18 @@ void benoit::wrtimg(std::vector<std::uint8_t> * img) {
datsiz = WebPEncodeLosslessRGBA(img->data(),benoit::d::resx,benoit::d::resy,(benoit::d::resx * 0x4),&dat);
break;
}
- int file = ::open(benoit::d::outimg.c_str(),(O_CREAT | O_TRUNC | O_WRONLY),0x1B4);
+ int fil = ::open(benoit::d::outimg.c_str(),(O_CREAT | O_TRUNC | O_WRONLY),0x1B4);
for(unsigned long long pos = 0x0;(pos < datsiz);++pos) {
- ::ssize_t byteswrtn = ::write(file,&dat[pos],0x1);
+ ::ssize_t byteswrtn = ::write(fil,&dat[pos],0x1);
if(byteswrtn < 0x0) {
- benoit::print(fmt::format("Unable to write to “{}”."s,benoit::d::outimg));
+ benoit::err::wrttofil(benoit::d::outimg);
return;
}
}
delete dat;
delete img;
- if(::close(file) < 0x0) {
- benoit::print(fmt::format("Unable to close file “{}”."s,benoit::d::outimg));
+ if(::close(fil) < 0x0) {
+ benoit::err::clsfil(benoit::d::outimg);
}
benoit::logfuncret(funcname);
}
@@ -86,8 +88,8 @@ auto buf = std::vector<std::uint8_t>();
buf.push_back(0xFF);
buf.push_back(0x0);
buf.push_back(0x0);
-auto file = std::fstream(benoit::outimt,std::fstream::binary | std::fstream::out | std::fstream::trunc);
-if(!file.is_open()) {
+auto fil = std::fstream(benoit::outimt,std::fstream::binary | std::fstream::out | std::fstream::trunc);
+if(!fil.is_open()) {
::_exit(EXIT_FAILURE);
}
*/