Skip to content

Commit

Permalink
(Continued)
Browse files Browse the repository at this point in the history
  • Loading branch information
wberube committed Aug 27, 2024
1 parent 8f46df8 commit ebfd352
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 117 deletions.
6 changes: 3 additions & 3 deletions src/hal/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,8 +239,8 @@ enum ConfigError parse_uint64(
if (!*end) {
if (res < min || res > max) {
HAL_DANGER("config",
"Can't parse param '%s' value '%s'. Value '%lld' is not in a "
"range [%lld; %lld].\n",
"Can't parse param '%s' value '%s'. Value '%lu' is not in a "
"range [%lu; %lu].\n",
param_name, param_value, res, min, max);
return CONFIG_PARAM_ISNT_IN_RANGE;
}
Expand Down Expand Up @@ -303,4 +303,4 @@ bool open_config(struct IniConfig *ini, FILE **file) {
ini->str[length] = 0;

return true;
}
}
15 changes: 15 additions & 0 deletions src/hal/macros.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,18 @@
fprintf(stderr, (x), ##__VA_ARGS__); \
fprintf(stderr, "\033[0m"); \
} while (0)

#ifndef CEILING
#define CEILING_POS(X) ((X-(int)(X)) > 0 ? (int)(X+1) : (int)(X))
#define CEILING_NEG(X) (int)(X)
#define CEILING(X) ( ((X) > 0) ? CEILING_POS(X) : CEILING_NEG(X) )
#endif

#define STARTS_WITH(a, b) !strncmp(a, b, strlen(b))
#define EQUALS(a, b) !strcmp(a, b)
#define EQUALS_CASE(a, b) !strcasecmp(a, b)
#define ENDS_WITH(a, b) \
size_t alen = strlen(a); \
size_t blen = strlen(b); \
return (alen > blen) && strcmp(a + alen - blen, b);
#define EMPTY(x) (x[0] == '\0')
19 changes: 4 additions & 15 deletions src/hal/support.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,11 @@
#include <sys/mman.h>
#include <unistd.h>

#ifndef CEILING
#define CEILING_POS(X) ((X-(int)(X)) > 0 ? (int)(X+1) : (int)(X))
#define CEILING_NEG(X) (int)(X)
#define CEILING(X) ( ((X) > 0) ? CEILING_POS(X) : CEILING_NEG(X) )
#ifdef __UCLIBC__
extern int asprintf(char **restrict strp, const char *restrict fmt, ...);
#endif

#define starts_with(a, b) !strncmp(a, b, strlen(b))
#define equals(a, b) !strcmp(a, b)
#define equals_case(a, b) !strcasecmp(a, b)
#define ends_with(a, b) \
size_t alen = strlen(a); \
size_t blen = strlen(b); \
return (alen > blen) && strcmp(a + alen - blen, b);
#define empty(x) (x[0] == '\0')
void *mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off);

extern void *aud_thread;
extern void *isp_thread;
Expand Down Expand Up @@ -62,6 +53,4 @@ extern hal_chnstate t31_state[T31_VENC_CHN_NUM];
#endif

bool hal_registry(unsigned int addr, unsigned int *data, hal_register_op op);
void hal_identify(void);

void *mmap64(void *start, size_t len, int prot, int flags, int fd, off_t off);
void hal_identify(void);
6 changes: 3 additions & 3 deletions src/region.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ void region_fill_formatted(char* str)

for (ifa = ifaddr; ifa != NULL; ifa = ifa->ifa_next)
{
if (equals(ifa->ifa_name, "lo")) continue;
if (EQUALS(ifa->ifa_name, "lo")) continue;
if (!ifa->ifa_addr || ifa->ifa_addr->sa_family != AF_PACKET) continue;
if (!ifa->ifa_data) continue;

Expand Down Expand Up @@ -218,7 +218,7 @@ void *region_thread(void)

while (keepRunning) {
for (char id = 0; id < MAX_OSD; id++) {
if (!empty(osds[id].text))
if (!EMPTY(osds[id].text))
{
char out[80];
strcpy(out, osds[id].text);
Expand Down Expand Up @@ -280,7 +280,7 @@ void *region_thread(void)
}
}
}
else if (empty(osds[id].text) && osds[id].updt)
else if (EMPTY(osds[id].text) && osds[id].updt)
{
char img[32];
sprintf(img, "/tmp/osd%d.bmp", id);
Expand Down
4 changes: 0 additions & 4 deletions src/region.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@
#include <unistd.h>
#include <time.h>

#ifdef __UCLIBC__
extern int asprintf(char **restrict strp, const char *restrict fmt, ...);
#endif

#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 4, 0)
#include <sys/sysinfo.h>
#else
Expand Down
Loading

0 comments on commit ebfd352

Please sign in to comment.