commit for tech_9
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
/*
|
||||
* Minimal replacement for wpa_supplicant's src/utils/common.h + the parts
|
||||
* of src/utils/os.h that wpa_ctrl.c (CONFIG_CTRL_IFACE_UNIX build path)
|
||||
* actually needs. Trivial os_* helpers are mapped directly onto libc via
|
||||
* macros (matching upstream's own os.h fallback definitions); the handful
|
||||
* that need a real body (os_zalloc, os_strlcpy, os_get_reltime, os_sleep)
|
||||
* are implemented in jl_wpa_os_shim.c.
|
||||
*/
|
||||
|
||||
#ifndef JL_WPA_CTRL_COMMON_H
|
||||
#define JL_WPA_CTRL_COMMON_H
|
||||
|
||||
typedef long os_time_t;
|
||||
|
||||
struct os_reltime {
|
||||
os_time_t sec;
|
||||
os_time_t usec;
|
||||
};
|
||||
|
||||
void *os_zalloc(size_t size);
|
||||
size_t os_strlcpy(char *dest, const char *src, size_t siz);
|
||||
int os_get_reltime(struct os_reltime *t);
|
||||
void os_sleep(os_time_t sec, os_time_t usec);
|
||||
|
||||
#define os_free(p) free((p))
|
||||
#define os_memcmp(s1, s2, n) memcmp((s1), (s2), (n))
|
||||
#define os_strncmp(s1, s2, n) strncmp((s1), (s2), (n))
|
||||
#define os_snprintf snprintf
|
||||
|
||||
static inline int os_snprintf_error(size_t size, int res)
|
||||
{
|
||||
return res < 0 || (unsigned int) res >= size;
|
||||
}
|
||||
|
||||
static inline int os_reltime_before(struct os_reltime *a,
|
||||
struct os_reltime *b)
|
||||
{
|
||||
return (a->sec < b->sec) ||
|
||||
(a->sec == b->sec && a->usec < b->usec);
|
||||
}
|
||||
|
||||
static inline void os_reltime_sub(struct os_reltime *a, struct os_reltime *b,
|
||||
struct os_reltime *res)
|
||||
{
|
||||
res->sec = a->sec - b->sec;
|
||||
res->usec = a->usec - b->usec;
|
||||
if (res->usec < 0) {
|
||||
res->sec--;
|
||||
res->usec += 1000000;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int os_reltime_expired(struct os_reltime *now,
|
||||
struct os_reltime *ts,
|
||||
os_time_t timeout_secs)
|
||||
{
|
||||
struct os_reltime age;
|
||||
|
||||
os_reltime_sub(now, ts, &age);
|
||||
return (age.sec > timeout_secs) ||
|
||||
(age.sec == timeout_secs && age.usec > 0);
|
||||
}
|
||||
|
||||
#endif /* JL_WPA_CTRL_COMMON_H */
|
||||
Reference in New Issue
Block a user