Skip to content

Commit 3efec8f

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

File tree

3 files changed

+32
-11
lines changed

3 files changed

+32
-11
lines changed

.github/workflows/main.yml

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@ jobs:
1919
# os: ubuntu-latest
2020
# arch: x86_64
2121
# make: LLAMA="-DGGML_BACKEND_DL=ON -DGGML_NATIVE=OFF -DGGML_CPU_ALL_VARIANTS=ON -DGGML_VULKAN=ON"
22-
- name: macos
23-
os: macos-latest
24-
# - name: windows
25-
# os: windows-latest
26-
# arch: x86_64
22+
# - name: macos
23+
# os: macos-latest
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: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <ctype.h>
1515
#include <stdlib.h>
1616
#include <string.h>
17+
#include <time.h>
1718

1819
#ifdef _WIN32
1920
#include <windows.h>
@@ -29,6 +30,11 @@
2930
#endif
3031
#endif
3132

33+
// Define TIME_UTC if not available (for non-Windows platforms)
34+
#ifndef TIME_UTC
35+
#define TIME_UTC 1
36+
#endif
37+
3238
#ifndef SQLITE_CORE
3339
SQLITE_EXTENSION_INIT3
3440
#endif
@@ -369,15 +375,25 @@ int ai_uuid_v7_generate (uint8_t value[UUID_LEN]) {
369375
#endif
370376

371377
// get current timestamp in ms
378+
uint64_t timestamp;
379+
#if defined(_WIN32)
380+
// Use GetSystemTimeAsFileTime for Windows/MinGW
381+
FILETIME ft;
382+
GetSystemTimeAsFileTime(&ft);
383+
uint64_t t = ((uint64_t)ft.dwHighDateTime << 32) | ft.dwLowDateTime;
384+
// Convert FILETIME (100-ns intervals since Jan 1, 1601) to ms since Unix epoch
385+
timestamp = (t / 10000ULL) - 11644473600000ULL;
386+
#else
372387
struct timespec ts;
373-
#ifdef __ANDROID__
388+
#if defined(__ANDROID__)
374389
if (clock_gettime(CLOCK_REALTIME, &ts) != 0) return -1;
375390
#else
376391
if (timespec_get(&ts, TIME_UTC) == 0) return -1;
377392
#endif
393+
timestamp = (uint64_t)ts.tv_sec * 1000 + ts.tv_nsec / 1000000;
394+
#endif
378395

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

0 commit comments

Comments
 (0)