Skip to content

Commit a049445

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

File tree

3 files changed

+16
-15
lines changed

3 files changed

+16
-15
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 12 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
@@ -148,15 +148,6 @@ jobs:
148148
run: make test
149149
shell: msys2 {0}
150150

151-
- name: check whisper CoreML linking (macOS)
152-
if: matrix.name == 'macos'
153-
run: |
154-
echo "Checking if whisper CoreML symbols are present..."
155-
nm -D dist/ai.dylib | grep -i coreml || echo "CoreML symbols not found in binary"
156-
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
159-
160151
- name: test sqlite-ai
161152
if: matrix.name == 'linux' || matrix.name == 'macos'
162153
run: make test

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)