Skip to content

Commit

Permalink
Merge pull request #1 from guanshaoheng/master
Browse files Browse the repository at this point in the history
Fixed some extension problems
  • Loading branch information
guanshaoheng authored Oct 21, 2024
2 parents bad9c9d + e625d1a commit 5479a13
Show file tree
Hide file tree
Showing 7 changed files with 523 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
if [ `uname` == Darwin ]; then
meson setup --buildtype=release --unity on builddir
else
env CC=clang CXX=clang meson setup --buildtype=release --unity on builddir
env CC=clang CXX=clang++ meson setup --buildtype=release --unity on builddir
fi
- name: meson_compile
Expand Down
38 changes: 38 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
cmake_minimum_required(VERSION 3.0)

project(PretextGraph LANGUAGES CXX C)

set(CMAKE_CXX_STANDARD 11)

set(version "0.0.6")

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
message(STATUS "No build type selected, default to Debug")
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")

link_directories(
${CMAKE_SOURCE_DIR}/libdeflate
)
add_executable(PretextGraph PretextGraph.cpp)

target_include_directories(
PretextGraph
PRIVATE
wrapper
libdeflate
)

target_link_libraries(
PretextGraph
PRIVATE
pthread
deflate
)

if (CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(PretextGraph PRIVATE DEBUG)
endif()

target_compile_definitions(PretextGraph PRIVATE PV="${version}")
54 changes: 33 additions & 21 deletions Header.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ SOFTWARE.
#include <Shlobj.h>
#endif


// cpp includes
#include <iostream>
#include <string>
#include <atomic>
#include <mutex>
#include <unordered_map> // used to store the data_type_dic


#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
Expand Down Expand Up @@ -112,22 +121,23 @@ typedef size_t memptr;
#define EndMain return(0)

#ifndef _WIN32
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#include <pthread.h>
#include <signal.h>
#include <unistd.h>
#else
#define __atomic_fetch_add(x, y, z) _InterlockedExchangeAdd(x, y)
#define __atomic_add_fetch(x, y, z) (y + _InterlockedExchangeAdd(x, y))
#define __sync_fetch_and_add(x, y) _InterlockedExchangeAdd(x, y)
#define __sync_fetch_and_sub(x, y) _InterlockedExchangeAdd(x, -y)
#define __atomic_store(x, y, z) _InterlockedCompareExchange(x, *y, *x)
#define __atomic_fetch_add(x, y, z) _InterlockedExchangeAdd(x, y)
#define __atomic_add_fetch(x, y, z) (y + _InterlockedExchangeAdd(x, y))
#define __sync_fetch_and_add(x, y) _InterlockedExchangeAdd(x, y)
#define __sync_fetch_and_sub(x, y) _InterlockedExchangeAdd(x, -y)
#define __atomic_store(x, y, z) _InterlockedCompareExchange(x, *y, *x)
#endif

#ifndef _WIN32
#define ThreadFence __asm__ volatile("" ::: "memory")
#define ThreadFence __asm__ volatile("" ::: "memory")
#else
#define ThreadFence _mm_mfence()
#define ThreadFence _mm_mfence()
#endif

#define FenceIn(x) ThreadFence; \
x; \
ThreadFence
Expand Down Expand Up @@ -268,10 +278,10 @@ thread_context
};

#ifdef DEBUG
#include <assert.h>
#define Assert(x) assert(x)
#include <assert.h>
#define Assert(x) assert(x)
#else
#define Assert(x)
#define Assert(x)
#endif

#define KiloByte(x) 1024*x
Expand Down Expand Up @@ -763,9 +773,8 @@ ThreadPoolWait(thread_pool *threadPool)
{
LockMutex(threadPool->threadCountLock);

while (threadPool->jobQueue.len || threadPool->numThreadsWorking)
{
WaitOnCond(threadPool->threadsAllIdle, threadPool->threadCountLock);
while (threadPool->jobQueue.len || threadPool->numThreadsWorking) {
WaitOnCond(threadPool->threadsAllIdle, threadPool->threadCountLock);
}

UnlockMutex(threadPool->threadCountLock);
Expand Down Expand Up @@ -934,9 +943,9 @@ StringToInt_Check(u08 *string, u32 *result, u08 stringTerminator = '\0')

while(--strLen > 0 && goodResult)
{
*result += (u32)(*--string - '0') * pow;
goodResult = (*string >= '0' && *string <= '9');
pow *= 10;
*result += (u32)(*--string - '0') * pow;
goodResult = (*string >= '0' && *string <= '9');
pow *= 10;
}

*result += (u32)(*--string - '0') * pow;
Expand Down Expand Up @@ -1037,26 +1046,29 @@ PushStringIntoIntArray(u32 *intArray, u32 arrayLength, u08 *string, u08 stringTe
u08 *stringToInt = (u08 *)intArray;
u32 stringLength = 0;

// Copy the string into the integer array until the string terminator is reached or the integer array is full
while (*string != stringTerminator && stringLength < (arrayLength << 2))
{
*(stringToInt++) = *(string++);
++stringLength;
}


// Pad the integer array with zeros until it is 4 byte aligned
while (stringLength & 3)
{
*(stringToInt++) = 0;
++stringLength;
}

// make sure the integer array is zeroed out
for ( u32 index = (stringLength >> 2);
index < arrayLength;
++index )
{
intArray[index] = 0;
}

return(string);
return(string); // return the line buffer pointer
}

global_function
Expand Down
Loading

0 comments on commit 5479a13

Please sign in to comment.