Skip to content

Commit

Permalink
Region allocator. Async I/O. Crypto. Result types. Socket adjustments…
Browse files Browse the repository at this point in the history
…. Trees.
  • Loading branch information
gliptic committed Jun 5, 2017
1 parent b38b2db commit 4eca1f1
Show file tree
Hide file tree
Showing 42 changed files with 4,887 additions and 855 deletions.
153 changes: 127 additions & 26 deletions _build/tl.vcxproj

Large diffs are not rendered by default.

60 changes: 43 additions & 17 deletions _build/tl.vcxproj.filters
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="..\socket.c" />
<ClCompile Include="..\fdlibm\e_rem_pio2.c">
<Filter>fdlibm</Filter>
</ClCompile>
Expand Down Expand Up @@ -199,13 +198,6 @@
<ClCompile Include="..\codec\polar_model.c">
<Filter>codec</Filter>
</ClCompile>
<ClCompile Include="..\std.c" />
<ClCompile Include="..\windows\std.c">
<Filter>windows</Filter>
</ClCompile>
<ClCompile Include="..\windows\io.c">
<Filter>windows</Filter>
</ClCompile>
<ClCompile Include="..\windows\runtime_vc.c">
<Filter>windows</Filter>
</ClCompile>
Expand Down Expand Up @@ -268,15 +260,29 @@
<ClCompile Include="..\rectpack.cpp">
<Filter>gfx</Filter>
</ClCompile>
<ClCompile Include="..\socket.cpp" />
<ClCompile Include="..\crypto\tweetnacl.c">
<Filter>crypto</Filter>
</ClCompile>
<ClCompile Include="..\windows\thread.cpp">
<Filter>windows</Filter>
</ClCompile>
<ClCompile Include="..\windows\std.cpp">
<Filter>windows</Filter>
</ClCompile>
<ClCompile Include="..\windows\io.cpp">
<Filter>windows</Filter>
</ClCompile>
<ClCompile Include="..\std.cpp" />
<ClCompile Include="..\region.cpp" />
<ClCompile Include="..\tree.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\platform.h" />
<ClInclude Include="..\cstdint.h" />
<ClInclude Include="..\coro.h" />
<ClInclude Include="..\impl.h" />
<ClInclude Include="..\config.h" />
<ClInclude Include="..\socket.h" />
<ClInclude Include="..\socket_sys.h" />
<ClInclude Include="..\memory.h" />
<ClInclude Include="..\ieee.h" />
<ClInclude Include="..\fdlibm\fdlibm.h">
Expand Down Expand Up @@ -317,13 +323,9 @@
<Filter>codec</Filter>
</ClInclude>
<ClInclude Include="..\std.h" />
<ClInclude Include="..\io.h" />
<ClInclude Include="..\utf8.h" />
<ClInclude Include="..\strscan.h" />
<ClInclude Include="..\char.h" />
<ClInclude Include="..\windows\win.hpp">
<Filter>windows</Filter>
</ClInclude>
<ClInclude Include="..\rect.hpp" />
<ClInclude Include="..\string.hpp" />
<ClInclude Include="..\approxmath\am.hpp">
Expand Down Expand Up @@ -391,6 +393,27 @@
<ClInclude Include="..\rectpack.hpp">
<Filter>gfx</Filter>
</ClInclude>
<ClInclude Include="..\socket.hpp" />
<ClInclude Include="..\crypto\tweetnacl.h">
<Filter>crypto</Filter>
</ClInclude>
<ClInclude Include="..\windows\miniwindows.h">
<Filter>windows</Filter>
</ClInclude>
<ClInclude Include="..\socket_sys.hpp" />
<ClInclude Include="..\windows\std_inline.h">
<Filter>windows</Filter>
</ClInclude>
<ClInclude Include="..\windows\win.hpp">
<Filter>windows</Filter>
</ClInclude>
<ClInclude Include="..\io.hpp" />
<ClInclude Include="..\io\async.hpp">
<Filter>io</Filter>
</ClInclude>
<ClInclude Include="..\thread.hpp" />
<ClInclude Include="..\result.hpp" />
<ClInclude Include="..\tree.hpp" />
</ItemGroup>
<ItemGroup>
<Filter Include="fdlibm">
Expand All @@ -414,18 +437,21 @@
<Filter Include="io">
<UniqueIdentifier>{f2eed4c9-a657-4bc8-842d-35bea9ba7bc1}</UniqueIdentifier>
</Filter>
<Filter Include="crypto">
<UniqueIdentifier>{961530ba-352f-45d4-9975-e9922984d2ed}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<None Include="..\codec\polar_model.ppc">
<Filter>codec</Filter>
</None>
</ItemGroup>
<ItemGroup>
<MASM Include="..\windows\allmul.asm">
<Filter>windows</Filter>
</MASM>
<MASM Include="..\approxmath\sincos.asm">
<Filter>approxmath</Filter>
</MASM>
<MASM Include="..\windows\llmul.asm">
<Filter>windows</Filter>
</MASM>
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions approxmath/am.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ VectorI2 sincos_fixed(i32 x);
VectorI2 sincos_fixed2(i32 x);
VectorD2 sincos_f64(i32 x);

VectorD2 sincos_che(double x);

}

#endif // TL_APPROXMATH_HPP
Expand Down
37 changes: 37 additions & 0 deletions approxmath/sincos.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,43 @@ VectorD2 sincos(double x) {
}
}

VectorD2 sincos_che(double x) {
double c = 1.57079632679489661923 - x;

double coeffs[] = {
-0.101321183346709072589001712988183609230944236760490476, // x
0.00662087952180793343258682906697112938547424931632185616, // x^3
-0.000173505057912483501491115906801116298084629719204655552, // x^5
2.52229235749396866288379170129828403876289663605034418e-6, // x^7
-2.33177897192836082466066115718536782354224647348350113e-8, // x^9
1.32913446369766718120324917415992976452154154051525892e-10, // x^11
};

//auto const pi_major = 3.1415927;
//auto const pi_minor = -0.00000008742278;
auto const pi = 3.1415926535897932384626433832795;

auto x2 = x*x;
auto c2 = c*c;
auto p11 = coeffs[5];
auto p9 = p11*x2 + coeffs[4];
auto cp9 = p11*c2 + coeffs[4];
auto p7 = p9*x2 + coeffs[3];
auto cp7 = p9*c2 + coeffs[3];
auto p5 = p7*x2 + coeffs[2];
auto cp5 = p7*c2 + coeffs[2];
auto p3 = p5*x2 + coeffs[1];
auto cp3 = p5*c2 + coeffs[1];
auto p1 = p3*x2 + coeffs[0];
auto cp1 = p3*c2 + coeffs[0];
//auto sin = (x - pi_major - pi_minor) * (x + pi_major + pi_minor) * p1 * x;
//auto cos = (c - pi_major - pi_minor) * (c + pi_major + pi_minor) * cp1 * c;
auto sin = (x - pi) * (x + pi) * p1 * x;
auto cos = (c - pi) * (c + pi) * cp1 * c;

return VectorD2(cos, sin);
}

#if 1 // TL_MSVCPP

alignas(16) u8 abs_mask[] = {
Expand Down
32 changes: 24 additions & 8 deletions bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,42 +32,52 @@ extern "C" {

#if TL_MSVCPP

TL_INLINE int tl_ffs(u32 x) {
TL_INLINE i32 tl_ffs(u32 x) {
unsigned long r; _BitScanForward(&r, x); return r;
}

TL_INLINE int tl_fls(u32 x) {
TL_INLINE i32 tl_fls(u32 x) {
unsigned long r; _BitScanReverse(&r, x); return r;
}

#if TL_X86_64
TL_INLINE int tl_fls64(u64 x) {
TL_INLINE i32 tl_fls64(u64 x) {
unsigned long r; _BitScanReverse64(&r, x); return r;
}
# define TL_HAS_FLS64 1
#endif

TL_INLINE int tl_log2(u32 v) {
TL_INLINE i32 tl_log2(u32 v) {
unsigned long r;
if(!_BitScanReverse(&r, v))
r = 0;
return r;
}

TL_INLINE int tl_top_bit(u32 v) {
TL_INLINE i32 tl_top_bit(u32 v) {
unsigned long r;
if(!_BitScanReverse(&r, v))
return -1;
return r;
}

TL_INLINE int tl_bottom_bit(u32 v) {
TL_INLINE i32 tl_bottom_bit(u32 v) {
unsigned long r;
if(!_BitScanForward(&r, v))
return -1;
return r;
}

#if TL_X86_64
TL_INLINE i32 tl_top_bit64(u64 v) {
unsigned long r;
if (!_BitScanReverse64(&r, v))
return -1;
return r;
}
# define TL_HAS_TOP_BIT64 1
#endif

#else // if !TL_MSVCPP

TL_INLINE uint16_t tl_byteswap16(uint16_t x) { return (x << 8) | (x >> 8); }
Expand All @@ -79,8 +89,14 @@ TL_INLINE u32 tl_byteswap32(u32 x) { return (x << 24) | (x >> 24) | ((x >> 8) &
#endif // elseif !TL_MSVCPP

#ifndef TL_HAS_FLS64
TL_INLINE int tl_fls64(u64 x) {
return (x>>32) ? 32 + (int32_t)tl_fls((u32)(x>>32)) : (int32_t)tl_fls((u32)x);
TL_INLINE i32 tl_fls64(u64 x) {
return (x>>32) ? 32 + (i32)tl_fls((u32)(x>>32)) : (i32)tl_fls((u32)x);
}
#endif

#ifndef TL_HAS_TOP_BIT64
TL_INLINE i32 tl_top_bit64(u64 x) {
return (x >> 32) ? 32 + (i32)tl_top_bit((u32)(x >> 32)) : (i32)tl_top_bit((u32)x);
}
#endif

Expand Down
Loading

0 comments on commit 4eca1f1

Please sign in to comment.