summaryrefslogtreecommitdiffstats
path: root/src/libnetdata/os/uuid_generate.c
blob: 6019f88444173263d475c51dbf6df1065b2feda8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// SPDX-License-Identifier: GPL-3.0-or-later

#include "../libnetdata.h"
#undef uuid_generate
#undef uuid_generate_random
#undef uuid_generate_time

#ifdef OS_WINDOWS
void os_uuid_generate(void *out) {
    RPC_STATUS status = UuidCreate(out);
    while (status != RPC_S_OK && status != RPC_S_UUID_LOCAL_ONLY) {
        tinysleep();
        status = UuidCreate(out);
    }
}

void os_uuid_generate_random(void *out) {
    os_uuid_generate(out);
}

void os_uuid_generate_time(void *out) {
    os_uuid_generate(out);
}

#else

#if !defined(OS_MACOS)
#include <uuid.h>
#endif

void os_uuid_generate(void *out) {
    uuid_generate(out);
}

void os_uuid_generate_random(void *out) {
    uuid_generate_random(out);
}

void os_uuid_generate_time(void *out) {
    uuid_generate_time(out);
}

#endif