Files
carbon 0545e9dc6d init version 2024-05-07
commit d1edce71135cc6d98c0a4b5729774542b676e769
Author: sophgo-forum-service <forum_service@sophgo.com>
Date:   Fri Mar 15 16:07:33 2024 +0800

    [fix] recommend using ssh method to clone repo.
    [fix] fix sensor driver repo branch name.
2024-05-07 19:36:36 +08:00

52 lines
846 B
C

#pragma once
#undef NDEBUG
#include <assert.h>
#include <dirent.h>
#include <errno.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/syscall.h>
static inline pid_t sys_getpid(void)
{
return syscall(SYS_getpid);
}
static inline pid_t sys_gettid(void)
{
return syscall(SYS_gettid);
}
static inline bool streq(const char *s1, const char *s2)
{
return strcmp(s1, s2) == 0;
}
static unsigned long long xstrtoull(const char *p, char **end)
{
if (*p == '0') {
*end = (char *)p + 1;
return 0;
} else if ('1' <= *p && *p <= '9') {
unsigned long long val;
errno = 0;
val = strtoull(p, end, 10);
assert(errno == 0);
return val;
} else
assert(0);
}
static struct dirent *xreaddir(DIR *d)
{
struct dirent *de;
errno = 0;
de = readdir(d);
assert(de || errno == 0);
return de;
}