64 #include <sys/types.h> 72 #include <sys/timeb.h> 73 #include <sysinfoapi.h> 76 #if defined(_M_IX86) || (defined(_M_X64) && !defined(_M_ARM64EC)) 77 #define _is_machine_x86_64 80 #include <isa_availability.h> 86 #define KILL_BUFSIZE (128) 96 ErrMsg =
"Generic error.";
99 ErrMsg =
"Error loading dynamic library.";
102 ErrMsg =
"Error closing dynamic library.";
105 ErrMsg =
"Unknown error.";
115 res = HeapAlloc(GetProcessHeap(), 0, (SIZE_T)size);
130 res = HeapReAlloc(GetProcessHeap(), 0, ptr, (SIZE_T)size);
134 res = realloc(ptr, size);
142 res = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (SIZE_T)(nmemb * size));
144 res = calloc(nmemb, size);
164 const BOOL res = HeapFree(GetProcessHeap(), 0, ptr);
182 const SIZE_T s = HeapSize(GetProcessHeap(), 0, ptr);
183 res = (s == (SIZE_T)-1) ? 0 : (size_t)s;
189 res = malloc_usable_size(ptr);
198 res = memcpy(res, str, size);
207 const size_t len = strlen(str);
215 const size_t len = strnlen(str, size);
225 errno_t ret = _ftime_s(&tv);
230 sec = (uint64_t)tv.time;
231 msec = (uint64_t)tv.millitm;
234 int ret = gettimeofday(&tv, NULL);
239 sec = (uint64_t)tv.tv_sec;
240 msec = (uint64_t)tv.tv_usec / UINT64_C(1000);
242 return (sec * UINT64_C(1000)) + msec;
249 struct termios oldattr;
250 if (tcgetattr(STDIN_FILENO, &oldattr) == -1) perror(NULL);
251 struct termios newattr = oldattr;
252 newattr.c_lflag &= ~(ICANON | ECHO);
253 newattr.c_cc[VTIME] = 0;
254 newattr.c_cc[VMIN] = 1;
255 if (tcsetattr(STDIN_FILENO, TCSANOW, &newattr) == -1) perror(NULL);
256 const int ch = getchar();
257 if (tcsetattr(STDIN_FILENO, TCSANOW, &oldattr) == -1) perror(NULL);
266 struct termios oldattr;
267 if (tcgetattr(STDIN_FILENO, &oldattr) == -1) perror(NULL);
268 struct termios newattr = oldattr;
269 newattr.c_lflag &= ~(ICANON | ECHO);
270 newattr.c_cc[VTIME] = 0;
271 newattr.c_cc[VMIN] = 1;
272 if (tcsetattr(STDIN_FILENO, TCSANOW, &newattr) == -1) perror(NULL);
275 FD_ZERO(&read_handles);
276 FD_SET(0, &read_handles);
277 struct timeval timeout;
278 timeout.tv_sec = timeout.tv_usec = 0;
279 int status = select(0 + 1, &read_handles, NULL, NULL, &timeout);
280 if (status < 0) perror(NULL);
281 if (tcsetattr(STDIN_FILENO, TCSANOW, &oldattr) == -1) perror(NULL);
289 return _access(pathname, mode);
291 if (pathname == NULL) {
295 return access(pathname, mode);
310 if (size > (
size_t)INT_MAX)
312 local_buf = _getcwd(NULL, (
int)size);
316 local_buf = getcwd(NULL, PATH_MAX);
318 if (local_buf == NULL) {
330 char *realloc_buf =
c_realloc(buf, size);
331 if (realloc_buf == NULL) {
343 if (size > (
size_t)INT_MAX)
345 return _getcwd(buf, (
int)size);
347 return getcwd(buf, size);
372 return (int64_t)_getpid();
374 return (int64_t)getpid();
380 return _stricmp(s1, s2);
382 return strcasecmp(s1, s2);
388 return _strnicmp(s1, s2, n);
390 return strncasecmp(s1, s2, n);
396 if (filename == NULL)
399 char *varValue = NULL, *varName = NULL;
400 char *p1 = strchr(filename,
'$');
401 char *p2 = strchr(filename,
')');
404 size_t varNameLength, resultLength;
406 if (p1 != NULL && p2 != NULL && p2 - p1 > 2) {
407 varNameLength = p2 - p1 - 2;
408 varName =
c_malloc(varNameLength + 1);
412 strncpy(varName, p1 + 2, varNameLength);
413 varName[varNameLength] =
'\0';
416 varValue = getenv(varName);
421 resultLength = strlen(filename) - (strlen(varName) + 3) + strlen(varValue) + 1;
426 strncpy(result, filename, p1 - filename);
428 result[p1 - filename] =
'\0';
429 strcat(result, varValue);
430 strcat(result, p2 + 1);
431 if (strchr(result,
'$')) {
453 strcpy(dest, source);
454 char *p1 = strrchr(dest, dirseps[0]);
457 char *p2 = strrchr(dest, dirseps[1]);
458 char *last =
max(p1, p2);
473 if (dest == NULL || source == NULL)
479 char *p1 = strrchr(source, dirseps[0]);
482 char *p2 = strrchr(source, dirseps[1]);
483 char *last =
max(p1, p2);
491 strcpy(dest, last + 1);
498 return (proc != NULL);
508 LPCH env = GetEnvironmentStringsA();
509 size_t sz, totsz = 0;
510 while ((sz = strlen(env + totsz)) != 0) {
511 char *var = env + totsz;
512 char *div = strchr(var,
'=');
536 FreeEnvironmentStringsA(env);
539 if (environ != NULL) {
542 while ((s = environ[i++]) != NULL) {
543 char *div = strchr(s,
'=');
571 const uint32_t initial_nbuckets = 128;
582 proc->
argv[0] = NULL;
610 if (proc->
argv[0] == NULL)
615 if (proc->
argv[0] == NULL)
656 for (
size_t i = 0; i < size; i++)
664 char **result = NULL;
680 result =
c_malloc(totcnt *
sizeof(*result));
681 if (result == NULL) {
688 for (
size_t i = 0; i < totcnt; ++i)
703 const size_t sz = strlen(key) + strlen(value) + 2;
704 result[cnt] =
c_malloc(sz *
sizeof(*result[cnt]));
705 if (result[cnt] == NULL) {
710 sprintf(result[cnt],
"%s=%s", key, value);
731 static int _compareStringsInsensitive(
const void* a,
const void* b) {
736 proc->procInfo.dwProcessId = 0;
737 proc->procInfo.dwThreadId = 0;
738 proc->procInfo.hProcess = NULL;
739 proc->procInfo.hThread = NULL;
740 proc->jobObject = NULL;
743 static int32_t _startProcessWin(
c_Process_t *proc) {
747 char *CommandString = NULL;
748 JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0 };
749 STARTUPINFOA si = { 0 };
750 const char *fName = NULL;
751 char **envarray = NULL;
762 _uninitHandlers(proc);
764 stringlen = strlen(proc->
execName) + 1;
765 for(int32_t i = 1; i < proc->
argc; i++) {
766 if(proc->
argv[i] != NULL)
767 stringlen += strlen(proc->
argv[i]) + 1;
771 CommandString =
c_malloc(stringlen + 5);
772 if (CommandString == NULL)
774 sprintf(CommandString,
"\"%s\"", proc->
execName);
775 for(int32_t i = 1; i < proc->
argc; i++) {
776 if(proc->
argv[i] != NULL) {
777 strcat(CommandString,
" ");
778 strcat(CommandString, proc->
argv[i]);
784 proc->jobObject = CreateJobObject(NULL, NULL);
785 if(proc->jobObject == NULL) {
786 proc->lastErr = GetLastError();
787 fName =
"CreateJobObject";
791 jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK;
792 if(SetInformationJobObject(proc->jobObject, JobObjectExtendedLimitInformation, &jeli,
sizeof(jeli)) ==
FALSE) {
793 proc->lastErr = GetLastError();
794 fName =
"SetInformationJobObject";
805 fName =
"mapToStringArray";
812 qsort(envarray, envc,
sizeof(*envarray), _compareStringsInsensitive);
813 for (
size_t e = 0; e < envc; e++) {
814 const char *var = envarray[e];
815 size_t addsz = strlen(var) + 1;
818 fName =
"<AllocateEnv>";
823 strcpy(env + envsz - 1, var);
826 env[envsz - 1] =
'\0';
829 ok = CreateProcessA(NULL,
830 (LPSTR)CommandString,
834 CREATE_SUSPENDED | CREATE_BREAKAWAY_FROM_JOB | CREATE_NO_WINDOW,
840 proc->lastErr = GetLastError();
841 fName =
"CreateProcess";
846 if(AssignProcessToJobObject(proc->jobObject, proc->procInfo.hProcess) ==
FALSE) {
847 proc->lastErr = GetLastError();
848 fName =
"AssignProcessToJobObject";
853 ResumeThread(proc->procInfo.hThread);
869 if (proc->procInfo.hProcess != NULL) {
870 WaitForSingleObject(proc->procInfo.hProcess,
INFINITE);
871 TerminateProcess(proc->procInfo.hProcess, ret);
872 CloseHandle(proc->procInfo.hProcess);
874 if (proc->procInfo.hThread != NULL)
875 CloseHandle(proc->procInfo.hThread);
876 if (proc->jobObject != NULL) {
877 TerminateJobObject(proc->jobObject, ret);
878 CloseHandle(proc->jobObject);
881 _uninitHandlers(proc);
886 static int32_t _getNCPUWin(
void) {
888 GetSystemInfo(&info);
889 return info.dwNumberOfProcessors;
898 char **tempenv = NULL;
899 char **envarray = NULL;
912 envarray =
c_malloc((envc + 1) *
sizeof(*envarray));
913 if (envarray == NULL) {
918 c_memcpy(envarray, tempenv, envc *
sizeof(*envarray));
919 envarray[envc] = NULL;
940 if ((res = posix_spawn(&proc->
pid, proc->
execName, NULL, NULL, proc->
argv, envarray)) != 0) {
958 waitpid(proc->
pid, &status, 0);
964 #ifdef _SC_NPROCESSORS_ONLN 965 ret = sysconf(_SC_NPROCESSORS_ONLN);
977 if (name && name[0]) {
978 size_t base_length = strlen(name);
980 const char* all = strchr(
"/\\", name[base_length - 1]) ?
"*" :
"/*";
981 if ((dir =
c_malloc(
sizeof(*dir))) != NULL && (dir->name =
c_malloc(base_length + strlen(all) + 1)) != NULL) {
982 strcat(strcpy(dir->name, name), all);
983 dir->handle = (handle_type)_findfirst(dir->name, &dir->info);
984 if (dir->handle != -1) {
985 dir->result.d_name = 0;
1003 return opendir(name);
1011 if (dir->handle != -1) {
1012 result = _findclose(dir->handle);
1022 return closedir(dir);
1028 struct dirent* result = NULL;
1029 if (dir && dir->handle != -1) {
1030 if (!dir->result.d_name || _findnext(dir->handle, &dir->info) != -1) {
1031 result = &dir->result;
1032 result->d_name = dir->info.name;
1039 return readdir(dir);
1045 if (dir && dir->handle != -1) {
1046 _findclose(dir->handle);
1047 dir->handle = (handle_type)_findfirst(dir->name, &dir->info);
1048 dir->result.d_name = 0;
1060 return _startProcessWin(proc);
1068 return _endProcessWin(proc);
1079 for(int32_t i = 0; i < proc->
argc; i++) {
1080 if(proc->
argv[i] == NULL)
1096 _uninitHandlers(proc);
1102 return _getNCPUWin();
1109 puts(
"Press any key to continue...");
1116 const int r = _mkdir(path);
1118 const int r = mkdir(path, ACCESSPERMS);
1120 return (r == 0 || errno == EEXIST) ? 0 : -1;
1132 while (strchr(dirseps, tmp[len - 1]) != NULL) {
1133 tmp[len - 1] =
'\0';
1144 for (
char *p = tmp + 1; *p !=
'\0'; ++p) {
1145 if (strchr(dirseps, *p) != NULL) {
1152 for (; (p[1] !=
'\0') && strchr(dirseps, p[1]) != NULL; ++p);
1163 *libHandle = LoadLibraryA(libName);
1165 size_t linuxLibNameSize = 3 + strlen(libName) + 3 + 1;
1166 char *linuxLibName =
c_malloc(linuxLibNameSize);
1167 if (linuxLibName == NULL)
1169 snprintf(linuxLibName, linuxLibNameSize,
"lib%s.so", libName);
1170 *libHandle = dlopen(linuxLibName, RTLD_LAZY);
1172 char *error = dlerror();
1173 if (error != NULL) {
1178 if (*libHandle == NULL) {
1188 *funcPtr = GetProcAddress(hLib, fcnName);
1189 if (*funcPtr == NULL) {
1194 *funcPtr = dlsym(hLib, fcnName);
1195 char* error = dlerror();
1196 if (error != NULL) {
1201 if (*funcPtr == NULL) {
1211 if (!FreeLibrary(hLib))
1215 char *error = dlerror();
1216 if (error != NULL) {
1227 dest->
wYear = (
unsigned short)(src->tm_year) + 1900;
1228 dest->
wMonth = (
unsigned short)(src->tm_mon) + 1;
1229 dest->
wDay = (
unsigned short)(src->tm_mday);
1230 dest->
wHour = (
unsigned short)(src->tm_hour);
1231 dest->
wMinute = (
unsigned short)(src->tm_min);
1232 dest->
wSecond = (
unsigned short)(src->tm_sec);
1233 dest->
wDayOfWeek = (
unsigned short)(src->tm_wday);
1238 if (src->tm_sec == 60) {
1245 dest->tm_year = src->
wYear - 1900;
1246 dest->tm_mon = src->
wMonth - 1;
1247 dest->tm_mday = src->
wDay;
1248 dest->tm_hour = src->
wHour;
1261 struct tm *timeinfo;
1262 struct timespec spec;
1263 uint16_t millis = 0;
1264 clock_gettime(CLOCK_REALTIME, &spec);
1265 timeinfo = localtime(&spec.tv_sec);
1266 millis = (uint16_t)(spec.tv_nsec / 1.e6);
1275 struct tm *timeinfo;
1276 struct timespec spec;
1277 uint16_t millis = 0;
1278 clock_gettime(CLOCK_REALTIME, &spec);
1279 timeinfo = gmtime(&spec.tv_sec);
1280 millis = (uint16_t)(spec.tv_nsec / 1.e6);
1305 ULARGE_INTEGER u1, u2;
1307 if (!(SystemTimeToFileTime(s1, &f1) && SystemTimeToFileTime(s2, &f2))) {
1312 u1.HighPart = f1.dwHighDateTime;
1313 u1.LowPart = f1.dwLowDateTime;
1314 u2.HighPart = f2.dwHighDateTime;
1315 u2.LowPart = f2.dwLowDateTime;
1320 res = (u2.QuadPart - u1.QuadPart) / 1.e7;
1333 res = difftime(t2, t1);
1338 res += (mdiff / 1000.0);
1347 #if UINT32_MAX == UINT_MAX 1348 #define _gcc_builtin(function, value) __builtin_##function(value) 1349 #elif UINT32_MAX == ULONG_MAX 1350 #define _gcc_builtin(function, value) __builtin_##function##l(value) 1351 #elif UINT32_MAX == ULLONG_MAX 1352 #define _gcc_builtin(function, value) __builtin_##function##ll(value) 1354 #error cannot implement GCC 32-bit builtin functions 1357 #if UINT64_MAX == UINT_MAX 1358 #define _gcc_builtin_64(function, value) __builtin_##function(value) 1359 #elif UINT64_MAX == ULONG_MAX 1360 #define _gcc_builtin_64(function, value) __builtin_##function##l(value) 1361 #elif UINT64_MAX == ULLONG_MAX 1362 #define _gcc_builtin_64(function, value) __builtin_##function##ll(value) 1364 #error cannot implement GCC 64-bit builtin functions 1369 #ifdef _is_machine_x86_64 1386 static bool _definitely_have_popcnt() {
1388 extern int __isa_available;
1389 return (__isa_available >= __ISA_AVAILABLE_SSE42);
1395 static uint32_t _popcount_fallback(uint32_t value) {
1396 value -= (value >> 1) & UINT32_C(0x55555555);
1397 value = (value & UINT32_C(0x33333333)) + ((value >> 2) & UINT32_C(0x33333333));
1398 value = (value + (value >> 4)) & UINT32_C(0x0F0F0F0F);
1399 return (value * UINT32_C(0x01010101)) >> 24;
1402 static uint32_t _popcount64_fallback(uint64_t value) {
1403 value -= (value >> 1) & UINT64_C(0x5555555555555555);
1404 value = (value & UINT64_C(0x3333333333333333)) + ((value >> 2) & UINT64_C(0x3333333333333333));
1405 value = (value + (value >> 4)) & UINT64_C(0x0F0F0F0F0F0F0F0F);
1406 return (value * UINT64_C(0x0101010101010101)) >> 56;
1415 return BitScanForward(&res, (DWORD)value) ? (uint32_t)(res) : UINT32_C(32);
1418 return (value != 0) ? (uint32_t)
_gcc_builtin(ctz, value) : UINT32_C(32);
1427 return BitScanReverse(&res, (DWORD)value) ? (uint32_t)(UINT32_C(31) - res) : UINT32_C(32);
1430 return (value != 0) ? (uint32_t)
_gcc_builtin(clz, value) : UINT32_C(32);
1436 #ifdef _is_machine_x86_64 1437 if (!_definitely_have_popcnt())
1438 return _popcount_fallback(value);
1439 return __popcnt(value);
1441 return _popcount_fallback(value);
1452 return BitScanForward64(&res, (DWORD64)value) ? (uint32_t)(res) : UINT32_C(64);
1455 return (value != 0) ? (uint32_t)
_gcc_builtin_64(ctz, value) : UINT32_C(64);
1463 return BitScanReverse64(&res, (DWORD64)value) ? (uint32_t)(UINT32_C(63) - res) : UINT32_C(64);
1466 return (value != 0) ? (uint32_t)
_gcc_builtin_64(clz, value) : UINT32_C(64);
1472 #ifdef _is_machine_x86_64 1473 if (!_definitely_have_popcnt())
1474 return _popcount64_fallback(value);
1477 return __popcnt((uint32_t)(value >> 32)) + __popcnt((uint32_t)(value));
1480 return (uint32_t)__popcnt64((DWORD64)value);
1483 return _popcount64_fallback(value);
1494 static const double twop60 = 1.152921504606846976e+18;
1495 static const double twom60 = 8.673617379884035472e-19;
1498 if (
c_unlikely(exponent == NULL || classification == NULL))
1503 double norm_fraction;
1507 switch (fpclassify(value)) {
1512 mantissa = signbit(value) ? INT64_C(-1) : INT64_C(1);
1520 mantissa = signbit(value) ? INT64_C(-1) : INT64_C(1);
1526 mantissa = signbit(value) ? INT64_C(-1) : INT64_C(1);
1531 norm_fraction = frexp(value, &exp);
1532 mantissa = (int64_t)(norm_fraction *
twop60);
1538 norm_fraction = frexp(value, &exp);
1539 mantissa = (int64_t)(norm_fraction * twop60);
1542 *exponent = (int16_t)exp;
1550 const double norm_fraction = (double)mantissa *
twom60;
1554 switch (classification) {
1558 value = copysign(HUGE_VAL, norm_fraction);
1565 value = copysign(NAN, norm_fraction);
1569 value = copysign(0., norm_fraction);
1575 value = ldexp(norm_fraction, (
int)exponent);
1587 #ifdef _WIN32 // On Linux, defined by unistd.h 1595 static char *next = NULL;
1601 if (next == NULL || *next ==
'\0') {
1615 if (c_mp_optind < argc)
1626 char *cp = strchr(options, c);
1628 if (cp == NULL || c ==
':') {
1635 if (*next !=
'\0') {
1657 FILE *
const f = fopen(fname,
"r");
1660 return (fclose(f) == 0);
1665 struct tm * timeinfo;
1666 char datetimestr[
sizeof(
"YYYYMMDDHHMMSS")];
1667 char p1[
sizeof(
"YYYYMMDD")];
1668 char p2[
sizeof(
"HHMMSS")];
1674 timeinfo = localtime(&rawtime);
1675 strftime(datetimestr,
sizeof(datetimestr),
"%Y%m%d%H%M%S", timeinfo);
1676 nc =
sizeof(p1) - 1;
1677 strncpy(p1, datetimestr, nc);
1679 nc =
sizeof(p2) - 1;
1680 strncpy(p2, datetimestr +
sizeof(p1) - 1, nc);
1683 res = (uint64_t)tmp * 1000000;
1696 if (dr == NULL || path == NULL) {
1703 const char *fname = de->d_name;
1704 if (!strcmp(fname,
".") || !strcmp(fname,
".."))
1706 sprintf(path,
"%s" DIRSEP0 "%s", dir, fname);
1707 if (stat(path, &st) != 0) {
1712 if (st.st_mode & S_IFDIR) {
1724 if (
remove(path) != 0) {
1744 char *fname =
c_malloc(strlen(procName) + 1);
1751 CONST HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
1752 PROCESSENTRY32 pEntry;
1753 pEntry.dwSize =
sizeof(pEntry);
1754 CONST DWORD currPID = GetCurrentProcessId();
1756 for (BOOL hRes = Process32First(hSnapShot, &pEntry); hRes; hRes = Process32Next(hSnapShot, &pEntry)) {
1758 if (strcmp(pEntry.szExeFile, fname) == 0 && pEntry.th32ProcessID != currPID) {
1759 HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, 0, pEntry.th32ProcessID);
1760 if (hProcess != NULL) {
1761 TerminateProcess(hProcess, 9);
1762 CloseHandle(hProcess);
1767 CloseHandle(hSnapShot);
1774 const char *format =
"ps -A | grep -w '%s' | grep -v 'grep' | awk '{print $1}'";
1777 int needed = snprintf(NULL, 0, format, fname);
1790 sprintf(cmd, format, fname);
1793 if ((fp = popen(cmd,
"r")) == NULL) {
1802 if (sscanf(buf,
"%" SCNd64, &pid) == 1) {
1803 if (pid != this_pid) {
1805 int32_t l_ret = kill((pid_t)pid, SIGKILL);
1806 if (ret == 0 && l_ret != 0)
1831 #undef _is_machine_x86_64
static const double twop60
static void _freePointersArray(char **arr, size_t size)
void c_freeProc(c_Process_t *proc)
DIR * c_opendir(const char *name)
Not marked CAEN_UTILITY_API (meaningful only on 32-bit Windows), likely an original sin more than a c...
Corresponds to FP_INFINITE defined by math.h.
static int32_t _endProcessLin(c_Process_t *proc)
int32_t c_dfload(c_libhandle_t hLib, const char *fcnName, c_fcnhandle_t *funcPtr)
int32_t c_dlload(const char *libName, c_libhandle_t *libHandle)
static void * c_memcpy(void *__restrict dest, const void *__restrict src, size_t size)
Wrapper to memcpy(dest, src, size), with check for NULL arguments.
int c_access(const char *pathname, int mode)
unsigned short wMilliseconds
uint32_t c_clz(uint32_t value)
void * c_calloc(size_t nmemb, size_t size)
bool c_checkFileExists(const char *fname)
static const double twom60
int32_t c_killProcess(const char *procName)
#define c_unused_parameter(P)
Platform independent macro to remove unreferenced parameter warning.
int32_t c_dlclose(c_libhandle_t hLib)
char * c_getcwd(char *buf, size_t size)
int32_t c_mkdirp(const char *dir)
Same of c_mkdir() but creates also intermediate directories.
int32_t c_mkdir(const char *path)
#define c_map_next(m, iter)
static void _systemtimeToTm(const c_systemtime_t *src, struct tm *dest)
uint32_t c_ctz(uint32_t value)
int32_t c_getCurrentEnvironment(c_environment_t *dest)
uint64_t c_get_time(void)
Get time in milliseconds since 00:00:00 UTC, January 1, 1970.
double c_DiffSystemTime_sec(const c_systemtime_t *s1, const c_systemtime_t *s2)
#define _gcc_builtin_64(function, value)
static void _tmToSystemtime(const struct tm *src, c_systemtime_t *dest, uint16_t millis)
int c_rmdir(const char *path)
void c_GetSystemTime(c_systemtime_t *t)
uint32_t c_popcount64(uint64_t value)
#define _gcc_builtin(function, value)
int32_t c_endProcess(c_Process_t *proc)
int32_t c_getBaseName(char *dest, const char *source)
char * c_getExpandedString(const char *filename)
int32_t c_addProcEnv(const char *varname, const char *varvalue, c_Process_t *proc)
void c_rewinddir(DIR *dir)
Corresponds to FP_SUBNORMAL defined by math.h.
int32_t c_setProcExec(const char *exec, c_Process_t *proc)
size_t c_malloc_size(void *ptr)
#define c_attribute_nonnull(...)
static c_libhandle_t libHandle
int c_strncasecmp(const char *s1, const char *s2, size_t n)
Corresponds to FP_NORMAL defined by math.h.
Hash table. Implementation from rxi's "map" project.
c_environment_t environment
#define c_map_set(m, key, value)
static int32_t _getNCPULin(void)
void * c_malloc(size_t size)
double c_ldexp(int64_t mantissa, int16_t exponent, int8_t classification)
int32_t c_addProcArg(const char *arg, c_Process_t *proc)
Generic wrappers to platform-dependent functions.
static void _decodeError(const char *functName, int32_t resCode)
#define INIT_C_LOGGER(fname, mname)
#define c_map_get(m, key)
c_Process_t * c_newProc(void)
void c_GetLocalTime(c_systemtime_t *now)
int32_t c_startProcess(c_Process_t *proc)
int c_chdir(const char *path)
static char * _strndup(const char *str, size_t size)
#define c_map_init(m, nreserved)
#define c_use_decl_annotations
int c_strcasecmp(const char *s1, const char *s2)
Corresponds to FP_ZERO defined by math.h.
int64_t c_frexp(double value, int16_t *exponent, int8_t *classification)
char * c_strndup(const char *str, size_t size)
Wrapper to strndup(str, size), with check for NULL arguments. To be freed with c_free().
struct dirent * c_readdir(DIR *dir)
Not marked CAEN_UTILITY_API (meaningful only on 32-bit Windows), likely an original sin more than a c...
void * c_realloc(void *ptr, size_t size)
Corresponds to FP_NAN defined by math.h.
static int32_t _mapToStringArray(c_environment_t *map, char ***dest, size_t *count)
char * c_strdup(const char *str)
Wrapper to strdup(str), with check for NULL arguments. To be freed with c_free(). ...
uint32_t c_clz64(uint64_t value)
unsigned short wDayOfWeek
uint64_t c_getCurrentTimeRepresentation(void)
uint32_t c_ctz64(uint64_t value)
int32_t c_remAllFiles(const char *dir)
static bool _isProcValid(c_Process_t *proc)
int32_t c_getDirName(char *dest, const char *source)
static int32_t _startProcessLin(c_Process_t *proc)
uint32_t c_popcount(uint32_t value)