diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/c.h | 4 | ||||
-rw-r--r-- | include/list.h | 21 | ||||
-rw-r--r-- | include/path.h | 2 | ||||
-rw-r--r-- | include/sysfs.h | 1 | ||||
-rw-r--r-- | include/timer.h | 15 |
5 files changed, 39 insertions, 4 deletions
diff --git a/include/c.h b/include/c.h index 059fadf0b..fb6835253 100644 --- a/include/c.h +++ b/include/c.h @@ -147,8 +147,8 @@ */ #ifndef container_of #define container_of(ptr, type, member) __extension__ ({ \ - void *__mptr = (void *)(ptr); \ - ((type *)(__mptr - offsetof(type, member))); }) + const __typeof__( ((type *)0)->member ) *__mptr = (ptr); \ + (type *)( (char *)__mptr - offsetof(type,member) );}) #endif #ifndef HAVE_PROGRAM_INVOCATION_SHORT_NAME diff --git a/include/list.h b/include/list.h index f3ffc7985..96c84e572 100644 --- a/include/list.h +++ b/include/list.h @@ -137,6 +137,16 @@ _INLINE_ int list_entry_is_last(struct list_head *entry, struct list_head *head) } /** + * list_entry_is_first - tests whether is entry first in the list + * @entry: the entry to test. + * @head: the list to test. + */ +_INLINE_ int list_entry_is_first(struct list_head *entry, struct list_head *head) +{ + return head->next == entry; +} + +/** * list_splice - join two lists * @list: the new list to add. * @head: the place to add it in the first list. @@ -198,6 +208,17 @@ _INLINE_ void list_splice(struct list_head *list, struct list_head *head) for (pos = (head)->next, pnext = pos->next; pos != (head); \ pos = pnext, pnext = pos->next) +_INLINE_ size_t list_count_entries(struct list_head *head) +{ + struct list_head *pos; + size_t ct = 0; + + list_for_each(pos, head) + ct++; + + return ct; +} + #define MAX_LIST_LENGTH_BITS 20 /* diff --git a/include/path.h b/include/path.h index 7ab9779a5..b34aa366e 100644 --- a/include/path.h +++ b/include/path.h @@ -40,6 +40,8 @@ void *ul_path_get_dialect(struct path_cxt *pc); int ul_path_set_enoent_redirect(struct path_cxt *pc, int (*func)(struct path_cxt *, const char *, int *)); int ul_path_get_dirfd(struct path_cxt *pc); +void ul_path_close_dirfd(struct path_cxt *pc); +int ul_path_isopen_dirfd(struct path_cxt *pc); char *ul_path_get_abspath(struct path_cxt *pc, char *buf, size_t bufsz, const char *path, ...) __attribute__ ((__format__ (__printf__, 4, 5))); diff --git a/include/sysfs.h b/include/sysfs.h index 74f69fb9c..edda8ca99 100644 --- a/include/sysfs.h +++ b/include/sysfs.h @@ -97,6 +97,7 @@ dev_t sysfs_devname_to_devno(const char *name); dev_t __sysfs_devname_to_devno(const char *prefix, const char *name, const char *parent); char *sysfs_devno_to_devpath(dev_t devno, char *buf, size_t bufsiz); char *sysfs_devno_to_devname(dev_t devno, char *buf, size_t bufsiz); +int sysfs_devno_count_partitions(dev_t devno); int sysfs_blkdev_scsi_get_hctl(struct path_cxt *pc, int *h, int *c, int *t, int *l); char *sysfs_blkdev_scsi_host_strdup_attribute(struct path_cxt *pc, diff --git a/include/timer.h b/include/timer.h index aa9f9c018..70da1ba9e 100644 --- a/include/timer.h +++ b/include/timer.h @@ -4,8 +4,19 @@ #include <signal.h> #include <sys/time.h> -extern int setup_timer(timer_t * t_id, struct itimerval *timeout, +#ifdef HAVE_TIMER_CREATE +struct ul_timer { + timer_t t_id; +}; +#else +struct ul_timer { + struct itimerval old_timer; + struct sigaction old_sa; +}; +#endif + +extern int setup_timer(struct ul_timer *timer, struct itimerval *timeout, void (*timeout_handler)(int, siginfo_t *, void *)); -extern void cancel_timer(timer_t * t_id); +extern void cancel_timer(struct ul_timer *timer); #endif /* UTIL_LINUX_TIMER_H */ |