• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

taosdata / TDengine / #4720

08 Sep 2025 08:43AM UTC coverage: 58.139% (-0.6%) from 58.762%
#4720

push

travis-ci

web-flow
Merge pull request #32881 from taosdata/enh/add-new-windows-ci

fix(ci): update workflow reference to use new Windows CI YAML

133181 of 292179 branches covered (45.58%)

Branch coverage included in aggregate %.

201691 of 283811 relevant lines covered (71.07%)

5442780.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

42.5
/tools/taos-tools/src/toolsSys.c
1
/*
2
 * Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
3
 *
4
 * This program is free software: you can use, redistribute, and/or modify
5
 * it under the terms of the MIT license as published by the Free Software Foundation.
6
 *
7
 * This program is distributed in the hope that it will be useful, but WITHOUT
8
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
9
 * FITNESS FOR A PARTICULAR PURPOSE.
10
 */
11

12
#include <stdio.h>
13
#include <stdlib.h>
14
#include <inttypes.h>
15

16
#ifdef WINDOWS
17
#include <time.h>
18
#include <WinSock2.h>
19
#include <sysinfoapi.h>
20
#else
21
#include <unistd.h>
22
#include <termios.h>
23
#include <errno.h>
24
#endif
25

26
#include <toolsdef.h>
27

28
int64_t atomic_add_fetch_64(int64_t volatile* ptr, int64_t val) {
5,723,364✔
29
#ifdef WINDOWS
30
    return InterlockedExchangeAdd64((int64_t volatile*)(ptr), (int64_t)(val)) + (int64_t)(val);
31
#elif defined(_TD_NINGSI_60)
32
    return __sync_add_and_fetch((ptr), (val));
33
#else
34
    return __atomic_add_fetch((ptr), (val), __ATOMIC_SEQ_CST);
5,723,364✔
35
#endif
36
}
37

38
FORCE_INLINE int32_t toolsGetNumberOfCores() {
116✔
39
#ifdef WINDOWS
40
    SYSTEM_INFO info;
41
    GetSystemInfo(&info);
42
    return (int32_t)info.dwNumberOfProcessors;
43
#else
44
    return (int32_t)sysconf(_SC_NPROCESSORS_ONLN);
116✔
45
#endif
46
}
47

48
void errorWrongValue(char *program, char *wrong_arg, char *wrong_value) {
×
49
    fprintf(stderr, "%s %s: %s is an invalid value\n",
×
50
            program, wrong_arg, wrong_value);
51
    fprintf(stderr, "Try `%s --help' or `%s --usage' for more "
×
52
            "information.\n", program, program);
53
}
×
54

55
void errorPrintReqArg(char *program, char *wrong_arg) {
×
56
    fprintf(stderr,
×
57
            "%s: option requires an argument -- '%s'\n",
58
            program, wrong_arg);
59
    fprintf(stderr,
×
60
            "Try `%s --help' or `%s --usage' for more "
61
            "information.\n", program, program);
62
}
×
63

64
void errorPrintReqArg2(char *program, char *wrong_arg) {
14✔
65
    fprintf(stderr,
14✔
66
            "%s: option requires a number argument '-%s'\n",
67
            program, wrong_arg);
68
    fprintf(stderr,
14✔
69
            "Try `%s --help' or `%s --usage' for more information.\n",
70
            program, program);
71
}
14✔
72

73
void errorPrintReqArg3(char *program, char *wrong_arg) {
3✔
74
    fprintf(stderr,
3✔
75
            "%s: option '%s' requires an argument\n",
76
            program, wrong_arg);
77
    fprintf(stderr,
3✔
78
            "Try `taosdump --help' or `taosdump --usage' for more "
79
            "information.\n");
80
}
3✔
81

82
int setConsoleEcho(bool on) {
10✔
83
#if defined(WINDOWS)
84
    HANDLE hStdin = GetStdHandle(STD_INPUT_HANDLE);
85
    DWORD  mode = 0;
86
    GetConsoleMode(hStdin, &mode);
87
    if (on) {
88
        mode |= ENABLE_ECHO_INPUT;
89
    } else {
90
        mode &= ~ENABLE_ECHO_INPUT;
91
    }
92
    SetConsoleMode(hStdin, mode);
93

94
#else
95
#define ECHOFLAGS (ECHO | ECHOE | ECHOK | ECHONL)
96
    int err;
97
    struct termios term;
98

99
    if (tcgetattr(STDIN_FILENO, &term) == -1) {
10!
100
        perror("Cannot get the attribution of the terminal");
10✔
101
        return -1;
10✔
102
    }
103

104
    if (on)
×
105
        term.c_lflag |= ECHOFLAGS;
×
106
    else
107
        term.c_lflag &= ~ECHOFLAGS;
×
108

109
    err = tcsetattr(STDIN_FILENO, TCSAFLUSH, &term);
×
110
    if (err == -1 || err == EINTR) {
×
111
        perror("Cannot set the attribution of the terminal");
×
112
        return -1;
×
113
    }
114

115
#endif
116
    return 0;
×
117
}
118

STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc