Skip to content

Commit

Permalink
windows compatability
Browse files Browse the repository at this point in the history
Signed-off-by: Ed Harry <e.f.harry@gmail.com>
  • Loading branch information
EdHarry committed May 22, 2019
1 parent a1d9354 commit 2dbca74
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 29 deletions.
32 changes: 7 additions & 25 deletions Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ SOFTWARE.
#define HEADER_H

#ifdef _WIN32
#define WINVER 0x0601 // Target Windows 7 as a Minimum Platform
#define _WIN32_WINNT 0x0601
#include <windows.h>
#endif

Expand Down Expand Up @@ -675,6 +677,11 @@ ThreadPoolInit(memory_arena *arena, u32 nThreads)

#define ThreadPoolAddTask(pool, func, args) ThreadPoolAddWork(pool, (void (*)(void *))func, (void *)args)

#ifdef _WIN32
#include <ctime>
#define sleep(x) Sleep(1000 * x)
#endif

global_function
void
ThreadPoolAddWork(thread_pool *threadPool, void (*function)(void*), void *arg)
Expand Down Expand Up @@ -709,11 +716,6 @@ ThreadPoolWait(thread_pool *threadPool)
UnlockMutex(threadPool->threadCountLock);
}

#ifdef _WIN32
#include <ctime>
#define sleep(x) Sleep(1000 * x)
#endif

global_function
void
ThreadPoolDestroy(thread_pool *threadPool)
Expand Down Expand Up @@ -888,26 +890,6 @@ StringToInt_Check(u08 *string, u32 *result)
return(goodResult);
}

global_function
u32
SIMDTestEquali(__m128i a, __m128i b)
{
__m128i neq = _mm_xor_si128(a, b);
return((u32)_mm_test_all_zeros(neq, neq));
}

global_function
__m128i
CountSetBitsPerByte(__m128i x)
{
__m128i countMask = _mm_set1_epi8(0x0F);
__m128i countTable = _mm_setr_epi8(0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4);
__m128i count0 = _mm_shuffle_epi8(countTable, _mm_and_si128(x, countMask));
__m128i count1 = _mm_shuffle_epi8(countTable, _mm_and_si128(_mm_srli_epi16(x, 4), countMask));

return(_mm_add_epi8(count0, count1));
}

global_function
u32
IntDivideCeil(u32 x, u32 y)
Expand Down
2 changes: 1 addition & 1 deletion LICENCE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

Third-party software and resorces used in this project, along with their respective licenses:
Third-party software and resources used in this project, along with their respective licenses:

This project uses libdeflate (https://github.com/ebiggers/libdeflate)

Expand Down
127 changes: 125 additions & 2 deletions PretextMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,107 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/

#define PretextMap_Version "PretextMap Version 0.0.3"

#include "Header.h"
#include <math.h>

global_variable
u08
Licence[] = R"lic(
Copyright (c) 2019 Ed Harry, Wellcome Sanger Institute
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
)lic";

global_variable
u08
ThirdParty[] = R"thirdparty(
Third-party software and resources used in this project, along with their respective licenses:
This project uses libdeflate (https://github.com/ebiggers/libdeflate)
Copyright 2016 Eric Biggers
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation files
(the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge,
publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
This project uses stb_sprintf (https://github.com/nothings/stb/blob/master/stb_sprintf.h)
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This project uses stb_dxt (https://github.com/nothings/stb/blob/master/stb_dxt.h)
ALTERNATIVE B - Public Domain (www.unlicense.org)
This is free and unencumbered software released into the public domain.
Anyone is free to copy, modify, publish, use, compile, sell, or distribute this
software, either in source code form or as a compiled binary, for any purpose,
commercial or non-commercial, and by any means.
In jurisdictions that recognize copyright laws, the author or authors of this
software dedicate any and all copyright interest in the software to the public
domain. We make this dedication for the benefit of the public at large and to
the detriment of our heirs and successors. We intend this dedication to be an
overt act of relinquishment in perpetuity of all present and future rights to
this software under copyright law.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
)thirdparty";

#pragma clang diagnostic push
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
#pragma GCC diagnostic ignored "-Wsign-conversion"
Expand Down Expand Up @@ -374,11 +472,18 @@ AddReadPairToImage(u64 read1, u64 read2)
u32 min = Min(pixel1, pixel2);
u32 max = Max(pixel1, pixel2);
volatile u16 *pixel = &Images[0][min][max - min];
#ifndef _WIN32
volatile u16 oldVal = __atomic_fetch_add(pixel, 1, 0);

#else
volatile u16 oldVal = __atomic_fetch_add((volatile unsigned long *)pixel, 1, 0);
#endif
if (oldVal == u16_max)
{
#ifndef _WIN32
__atomic_store(pixel, &oldVal, 0);
#else
__atomic_store((volatile unsigned long *)pixel, (volatile unsigned long *)&oldVal, 0);
#endif
}
}

Expand Down Expand Up @@ -1557,9 +1662,27 @@ MainArgs
{
if (ArgCount == 1)
{
printf("(...samformat |) PretextMap -o output.pretex (--sortby ({length}, name, nosort) --sortorder ({descend}, ascend) --mapq {10}) (< samfile)");
printf("%s\n\n", PretextMap_Version);
printf("(...samformat |) PretextMap -o output.pretext (--sortby ({length}, name, nosort) --sortorder ({descend}, ascend) --mapq {10}) (< samfile)\n\n");
printf("PretextMap --licence <- view software licence\n");
printf("PretextMap --thirdparty <- view third party software used\n");
exit(0);
}

if (ArgCount == 2)
{
if (AreNullTerminatedStringsEqual((u08 *)ArgBuffer[1], (u08 *)"--licence"))
{
printf("%s\n", Licence);
exit(0);
}

if (AreNullTerminatedStringsEqual((u08 *)ArgBuffer[1], (u08 *)"--thirdparty"))
{
printf("%s\n", ThirdParty);
exit(0);
}
}

u32 outputNameGiven = 0;
for ( u32 index = 1;
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,13 @@ Contact maps are saved in a compressed texture format (hence the name). Maps can
# Requirments, running
3G of RAM and 2 CPU cores

# Requirments, installation
# Windows, Mac and Linux Builds
Prebuild binaries for Windows, Mac and Linux are available<br/>
The Mac binary was build on MacOS 10.13.6<br/>
The Linux binary was build on kernel 3.13<br/>
The Windows binary was build on Windows 10, and should work on at least Windows 7<br/>

# Requirments, building via script (Mac and Linux only)
make<br/>
python (2 or 3) to run the installation script<br/>
clang or gcc to compile<br/>
Expand All @@ -37,3 +43,13 @@ Tested on MacOS 10.13.6 with clang-9, clang-10-apple<br/>
PretextMap requires libdeflate (https://github.com/ebiggers/libdeflate). By default the install script will clone and build the libdeflate.a static library for compilation with PretextMap. You can specify your own version to the install script if you wish (you'll have to specify appropriate liking flags as well if you specify a shared library).

run ./install to build (run ./install -h to see options)

# Requirments, building on Windows
Only recomended if the prebuilt binary doesn't work for you and you know how to compile executables for Windows.<br/>

Tested on Windows 10 using the Visual Studio 2019 toolchain<br/>
Tested with Microsoft cl and clang-9<br/>

Requires libdeflate (https://github.com/ebiggers/libdeflate)<br/>

Compile PretextMap.cpp and link against libdeflate<br/>

0 comments on commit 2dbca74

Please sign in to comment.