Skip to content

Commit 73eee5d

Browse files
author
Daniele Briggi
committed
fix(windows): use GetSystemTimeAsFileTime for timestamp
- missing liks to bcrypt library
1 parent 9a466f1 commit 73eee5d

File tree

3 files changed

+24
-9
lines changed

3 files changed

+24
-9
lines changed

.github/workflows/main.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ jobs:
2121
# make: LLAMA="-DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON -DGGML_VULKAN=ON"
2222
- name: macos
2323
os: macos-latest
24-
# - name: windows
25-
# os: windows-latest
26-
# arch: x86_64
24+
- name: windows
25+
os: windows-latest
26+
arch: x86_64
2727
# - name: android
2828
# os: ubuntu-latest
2929
# arch: arm64-v8a
@@ -152,10 +152,15 @@ jobs:
152152
if: matrix.name == 'macos'
153153
run: |
154154
echo "Checking if whisper CoreML symbols are present..."
155-
nm -D dist/ai.dylib | grep -i coreml || echo "CoreML symbols not found in binary"
155+
echo "=== Dynamic symbols in ai.dylib ==="
156+
nm -D dist/ai.dylib | grep -i coreml || echo "CoreML symbols not found in dynamic symbol table"
157+
echo "=== All symbols in ai.dylib ==="
158+
nm dist/ai.dylib | grep -i coreml || echo "CoreML symbols not found in symbol table"
159+
echo "=== Linked frameworks ==="
156160
otool -L dist/ai.dylib | grep CoreML || echo "CoreML framework not linked"
157-
nm build/whisper.cpp/src/libwhisper.a | grep coreml
158-
nm build/whisper.cpp/src/libwhisper.coreml.a | grep coreml
161+
echo "=== CoreML symbols in whisper libraries ==="
162+
nm build/whisper.cpp/src/libwhisper.a | grep coreml || echo "No CoreML symbols in libwhisper.a"
163+
nm build/whisper.cpp/src/libwhisper.coreml.a | grep coreml || echo "No CoreML symbols in libwhisper.coreml.a"
159164
160165
- name: test sqlite-ai
161166
if: matrix.name == 'linux' || matrix.name == 'macos'

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ MINIAUDIO_LIBS = $(BUILD_MINIAUDIO)/libminiaudio.a
6161
# Platform-specific settings
6262
ifeq ($(PLATFORM),windows)
6363
TARGET := $(DIST_DIR)/ai.dll
64-
LDFLAGS = -L./$(BUILD_LLAMA)/common -L./$(BUILD_LLAMA)/ggml/src -L./$(BUILD_LLAMA)/src -L./$(BUILD_WHISPER)/src -L./$(BUILD_MINIAUDIO) -l:libllama.a -l:libwhisper.a -l:libminiaudio.a -l:libcommon.a -l:ggml.a -l:ggml-cpu.a -l:ggml-base.a -fopenmp -static-libgcc -static-libstdc++ -shared
64+
LDFLAGS = -L./$(BUILD_LLAMA)/common -L./$(BUILD_LLAMA)/ggml/src -L./$(BUILD_LLAMA)/src -L./$(BUILD_WHISPER)/src -L./$(BUILD_MINIAUDIO) -l:libllama.a -l:libwhisper.a -l:libminiaudio.a -l:libcommon.a -l:ggml.a -l:ggml-cpu.a -l:ggml-base.a -fopenmp -static-libgcc -static-libstdc++ -shared -lbcrypt
6565
# Create .def file for Windows
6666
DEF_FILE := $(BUILD_DIR)/ai.def
6767
STRIP = strip --strip-unneeded $@

src/utils.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -369,15 +369,25 @@ int ai_uuid_v7_generate (uint8_t value[UUID_LEN]) {
369369
#endif
370370

371371
// get current timestamp in ms
372+
uint64_t timestamp;
373+
#if defined(_WIN32)
374+
// Use GetSystemTimeAsFileTime for Windows/MinGW
375+
FILETIME ft;
376+
GetSystemTimeAsFileTime(&ft);
377+
uint64_t t = ((uint64_t)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
378+
// Convert FILETIME (100-ns intervals since Jan 1, 1601) to ms since Unix epoch
379+
timestamp = (t / 10000ULL) - 11644473600000ULL;
380+
#else
372381
struct timespec ts;
373-
#ifdef __ANDROID__
382+
#if defined(__ANDROID__)
374383
if (clock_gettime(CLOCK_REALTIME, &ts) != 0) return -1;
375384
#else
376385
if (timespec_get(&ts, TIME_UTC) == 0) return -1;
377386
#endif
387+
timestamp = (uint64_t)ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
388+
#endif
378389

379390
// add timestamp part to UUID
380-
uint64_t timestamp = (uint64_t)ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
381391
value[0] = (timestamp >> 40) & 0xFF;
382392
value[1] = (timestamp >> 32) & 0xFF;
383393
value[2] = (timestamp >> 24) & 0xFF;

0 commit comments

Comments
 (0)