Projectname
large_stringclasses
15 values
Filepath
large_stringlengths
4
106
⌀
Function
large_stringlengths
11
3.45k
Label
list
Linux Kernel
tools/firewire/nosy-dump.c
static void set_input_mode(void) { struct termios tattr; if (!isatty(STDIN_FILENO)) { fprintf(stderr, "Not a terminal.\n"); exit(EXIT_FAILURE); } /* Save the terminal attributes so we can restore them later. */ tcgetattr(STDIN_FILENO, &saved_attributes); atexit(reset_input_mode); /* Set the fun...
[ 0, 0 ]
Linux Kernel
tools/gpio/gpio-event-mon.c
void print_usage(void) { fprintf(stderr, "Usage: gpio-event-mon [options]...\n" "Listen to events on GPIO lines, 0->1 1->0\n" " -n <name> Listen on GPIOs on a named device (must be stated)\n" " -o <n> Offset of line to monitor (may be repeated)\n" " -d ...
[ 1, 0 ]
Linux Kernel
tools/gpio/gpio-hammer.c
void print_usage(void) { fprintf( stderr, "Usage: gpio-hammer [options]...\n" "Hammer GPIO lines, 0->1->0->1...\n" " -n <name> Hammer GPIOs on a named device (must be stated)\n" " -o <n> Offset[s] to hammer, at least one, several can be stated\n" " [-c <n>] Do <n> loops ...
[ 1, 0 ]
Linux Kernel
tools/gpio/gpio-utils.c
int gpiotools_release_line(const int fd) { int ret; ret = close(fd); if (ret == -1) { perror("Failed to close GPIO LINE device file"); ret = -errno; } return ret; }
[ 0, 0 ]
Linux Kernel
tools/gpio/gpio-utils.c
int gpiotools_gets(const char *device_name, unsigned int *lines, unsigned int num_lines, unsigned int *values) { int fd, i; int ret; int ret_close; struct gpio_v2_line_config config; struct gpio_v2_line_values lv; memset(&config, 0, sizeof(config)); config.flags = GPIO_V2_LINE_FLAG_INP...
[ 1, 0 ]
Linux Kernel
tools/gpio/gpio-utils.c
int gpiotools_set(const char *device_name, unsigned int line, unsigned int value) { unsigned int lines[] = {line}; return gpiotools_sets(device_name, lines, 1, &value); }
[ 1, 0 ]
Linux Kernel
tools/gpio/lsgpio.c
static void print_attributes(struct gpio_v2_line_info *info) { int i; const char *field_format = "%s"; for (i = 0; i < ARRAY_SIZE(flagnames); i++) { if (info->flags & flagnames[i].mask) { fprintf(stdout, field_format, flagnames[i].name); field_format = ", %s"; } } if ((info->flags & GPI...
[ 0, 0 ]
Linux Kernel
tools/gpio/lsgpio.c
int list_device(const char *device_name) { struct gpiochip_info cinfo; char *chrdev_name; int fd; int ret; int i; ret = asprintf(&chrdev_name, "/dev/%s", device_name); if (ret < 0) return -ENOMEM; fd = open(chrdev_name, 0); if (fd == -1) { ret = -errno; fprintf(stderr, "Failed to open %s...
[ 1, 0 ]
Linux Kernel
tools/hv/hv_fcopy_daemon.c
static int hv_copy_finished(void) { close(target_fd); target_fname[0] = '\0'; return 0; }
[ 0, 0 ]
Linux Kernel
tools/hv/hv_kvp_daemon.c
static int kvp_key_delete(int pool, const __u8 *key, int key_size) { int i; int j, k; int num_records; struct kvp_record *record; kvp_update_mem_state(pool); num_records = kvp_file_info[pool].num_records; record = kvp_file_info[pool].records; for (i = 0; i < num_records; i++) { if (memcmp(key, re...
[ 1, 0 ]
Linux Kernel
tools/hv/hv_kvp_daemon.c
static char *kvp_get_if_name(char *guid) { DIR *dir; struct dirent *entry; FILE *file; char *p, *x; char *if_name = NULL; char buf[256]; char dev_id[PATH_MAX]; dir = opendir(KVP_NET_DIR); if (dir == NULL) return NULL; while ((entry = readdir(dir)) != NULL) { snprintf(dev_id, sizeof(dev_id...
[ 1, 0 ]
Linux Kernel
tools/hv/hv_kvp_daemon.c
static int expand_ipv6(char *addr, int type) { int ret; struct in6_addr v6_addr; ret = inet_pton(AF_INET6, addr, &v6_addr); if (ret != 1) { if (type == NETMASK) return 1; return 0; } sprintf(addr, "%02x%02x:%02x%02x:%02x%02x:%02x%02x:%02x%02x:" "%02x%02x:%02x%02x:%02x%0...
[ 1, 0 ]
Linux Kernel
tools/hv/hv_kvp_daemon.c
static void kvp_get_domain_name(char *buffer, int length) { struct addrinfo hints, *info; int error = 0; gethostname(buffer, length); memset(&hints, 0, sizeof(hints)); hints.ai_family = AF_INET; hints.ai_socktype = SOCK_STREAM; hints.ai_flags = AI_CANONNAME; error = getaddrinfo(buffer, NULL, &hints, &...
[ 1, 0 ]
Linux Kernel
tools/hv/hv_vss_daemon.c
static bool is_dev_loop(const char *blkname) { char *buffer; DIR *dir; struct dirent *entry; bool ret = false; buffer = malloc(PATH_MAX); if (!buffer) { syslog(LOG_ERR, "Can't allocate memory!"); exit(1); } snprintf(buffer, PATH_MAX, "%s/loop", blkname); if (!access(buffer, R_OK | X_OK)) { ...
[ 1, 0 ]
Linux Kernel
tools/iio/iio_generic_buffer.c
static int enable_disable_all_channels(char *dev_dir_name, int buffer_idx, int enable) { const struct dirent *ent; char scanelemdir[256]; DIR *dp; int ret; snprintf(scanelemdir, sizeof(scanelemdir), FORMAT_SCAN_ELEMENTS_DIR, dev_dir_name, buffer_idx); scan...
[ 1, 0 ]
Linux Kernel
tools/iio/iio_generic_buffer.c
static void register_cleanup(void) { struct sigaction sa = {.sa_handler = sig_handler}; const int signums[] = {SIGINT, SIGTERM, SIGABRT}; int ret, i; for (i = 0; i < ARRAY_SIZE(signums); ++i) { ret = sigaction(signums[i], &sa, NULL); if (ret) { perror("Failed to register signal handler"); ...
[ 0, 0 ]
Linux Kernel
tools/iio/iio_utils.c
int iioutils_break_up_name(const char *full_name, char **generic_name) { char *current; char *w, *r; char *working, *prefix = ""; int i, ret; for (i = 0; i < ARRAY_SIZE(iio_direction); i++) if (!strncmp(full_name, iio_direction[i], strlen(iio_direction[i]))) { prefix = iio_direction[i]; break...
[ 1, 0 ]
Linux Kernel
tools/iio/iio_utils.c
static int calc_digits(int num) { int count = 0; if (!num) return 1; while (num != 0) { num /= 10; count++; } return count; }
[ 0, 0 ]
Linux Kernel
tools/iio/iio_utils.c
int write_sysfs_string_and_verify(const char *filename, const char *basedir, const char *val) { return _write_sysfs_string(filename, basedir, val, 1); }
[ 0, 0 ]
Linux Kernel
tools/iio/iio_utils.c
int read_sysfs_float(const char *filename, const char *basedir, float *val) { int ret = 0; FILE *sysfsfp; char *temp = malloc(strlen(basedir) + strlen(filename) + 2); if (!temp) { fprintf(stderr, "Memory allocation failed"); return -ENOMEM; } ret = sprintf(temp, "%s/%s", basedir, filename); if (...
[ 1, 0 ]
Linux Kernel
tools/iio/iio_utils.h
static inline int iioutils_check_suffix(const char *str, const char *suffix) { return strlen(str) >= strlen(suffix) && strncmp(str + strlen(str) - strlen(suffix), suffix, strlen(suffix)) == 0; }
[ 0, 0 ]
Linux Kernel
tools/iio/lsiio.c
static inline int check_prefix(const char *str, const char *prefix) { return strlen(str) > strlen(prefix) && strncmp(str, prefix, strlen(prefix)) == 0; }
[ 0, 0 ]
Linux Kernel
tools/include/asm-generic/atomic-gcc.h
static inline void atomic_inc(atomic_t *v) { __sync_add_and_fetch(&v->counter, 1); }
[ 0, 0 ]
Linux Kernel
tools/include/asm-generic/atomic-gcc.h
static inline int atomic_cmpxchg(atomic_t *v, int oldval, int newval) { return cmpxchg(&(v)->counter, oldval, newval); } #endif
[ 0, 0 ]
Linux Kernel
tools/include/asm-generic/bitops/arch_hweight.h
static inline unsigned int __arch_hweight32(unsigned int w) { return __sw_hweight32(w); }
[ 0, 0 ]
Linux Kernel
tools/include/asm-generic/bitops/arch_hweight.h
static inline unsigned int __arch_hweight16(unsigned int w) { return __sw_hweight16(w); }
[ 0, 0 ]
Linux Kernel
tools/include/asm-generic/bitops/atomic.h
static inline void set_bit(int nr, unsigned long *addr) { addr[nr / __BITS_PER_LONG] |= 1UL << (nr % __BITS_PER_LONG); }
[ 1, 0 ]
Linux Kernel
tools/include/asm-generic/bitops/fls64.h
static __always_inline int fls64(__u64 x) { __u32 h = x >> 32; if (h) return fls(h) + 32; return fls(x); } #elif BITS_PER_LONG == 64
[ 0, 0 ]
Linux Kernel
tools/include/asm-generic/bitops/non-atomic.h
static __always_inline bool ___test_and_set_bit(unsigned long nr, volatile unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long old = *p; *p = old | mask; return (old & mask) != 0; }
[ 1, 0 ]
Linux Kernel
tools/include/asm-generic/bitops/non-atomic.h
static __always_inline bool ___test_and_clear_bit(unsigned long nr, volatile unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long old = *p; *p = old & ~mask; return (old & mask) != 0; }
[ 1, 0 ]
Linux Kernel
tools/include/asm-generic/bitops/non-atomic.h
static __always_inline bool ___test_and_change_bit(unsigned long nr, volatile unsigned long *addr) { unsigned long mask = BIT_MASK(nr); unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr); unsigned long old = *p; *p = old ^ mask; return (old & mask) != 0; }
[ 1, 0 ]
Linux Kernel
tools/include/asm-generic/bitops/non-atomic.h
static __always_inline bool _test_bit(unsigned long nr, const volatile unsigned long *addr) { return 1UL & (addr[BIT_WORD(nr)] >> (nr & (BITS_PER_LONG - 1))); } #endif
[ 0, 0 ]
Linux Kernel
tools/include/linux/bitmap.h
static inline bool bitmap_empty(const unsigned long *src, unsigned int nbits) { if (small_const_nbits(nbits)) return !(*src & BITMAP_LAST_WORD_MASK(nbits)); return find_first_bit(src, nbits) == nbits; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/ctype.h
static inline int __isdigit(int c) { return '0' <= c && c <= '9'; } #define isdigit(c) __isdigit(c) #endif
[ 1, 0 ]
Linux Kernel
tools/include/linux/ctype.h
static inline char _tolower(const char c) { return c | 0x20; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/err.h
static inline long __must_check PTR_ERR(__force const void *ptr) { return (long)ptr; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/err.h
static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr) { return unlikely(!ptr) || IS_ERR_VALUE((unsigned long)ptr); }
[ 0, 0 ]
Linux Kernel
tools/include/linux/hash.h
static inline u32 hash_ptr(const void *ptr, unsigned int bits) { return hash_long((unsigned long)ptr, bits); }
[ 0, 0 ]
Linux Kernel
tools/include/linux/jhash.h
static inline u32 jhash(const void *key, u32 length, u32 initval) { u32 a, b, c; const u8 *k = key; a = b = c = JHASH_INITVAL + length + initval; /* All but the last block: affect some 32 bits of (a,b,c) */ while (length > 12) { a += __get_unaligned_cpu32(k); b += __get_unaligned_cpu32(k + 4); c...
[ 1, 0 ]
Linux Kernel
tools/include/linux/jhash.h
static inline u32 jhash2(const u32 *k, u32 length, u32 initval) { u32 a, b, c; a = b = c = JHASH_INITVAL + (length << 2) + initval; /* Handle most of the key */ while (length > 3) { a += k[0]; b += k[1]; c += k[2]; __jhash_mix(a, b, c); length -= 3; k += 3; } /* Handle the last 3 ...
[ 1, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline void INIT_LIST_HEAD(struct list_head *list) { list->next = list; list->prev = list; } #ifndef CONFIG_DEBUG_LIST
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline void __list_del_entry(struct list_head *entry) { __list_del(entry->prev, entry->next); }
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline void list_del(struct list_head *entry) { __list_del(entry->prev, entry->next); entry->next = LIST_POISON1; entry->prev = LIST_POISON2; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline void list_replace_init(struct list_head *old, struct list_head *new) { list_replace(old, new); INIT_LIST_HEAD(old); }
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline void list_move_tail(struct list_head *list, struct list_head *head) { __list_del_entry(list); list_add_tail(list, head); }
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline int list_empty(const struct list_head *head) { return head->next == head; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline void list_rotate_left(struct list_head *head) { struct list_head *first; if (!list_empty(head)) { first = head->next; list_move_tail(first, head); } }
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline void list_splice_tail(struct list_head *list, struct list_head *head) { if (!list_empty(list)) __list_splice(list, head->prev, head); }
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline void __hlist_del(struct hlist_node *n) { struct hlist_node *next = n->next; struct hlist_node **pprev = n->pprev; WRITE_ONCE(*pprev, next); if (next) next->pprev = pprev; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline void hlist_del(struct hlist_node *n) { __hlist_del(n); n->next = LIST_POISON1; n->pprev = LIST_POISON2; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline void hlist_add_behind(struct hlist_node *n, struct hlist_node *prev) { n->next = prev->next; prev->next = n; n->pprev = &prev->next; if (n->next) n->next->pprev = &n->next; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/list.h
static inline bool hlist_fake(struct hlist_node *h) { return h->pprev == &h->next; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/math64.h
static inline u64 mul_u64_u64_div64(u64 a, u64 b, u64 c) { u64 q; asm("mulq %2; divq %3" : "=a"(q) : "a"(a), "rm"(b), "rm"(c) : "rdx"); return q; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/math64.h
static inline u64 mul_u64_u32_shr(u64 a, u32 b, unsigned int shift) { u32 ah, al; u64 ret; al = a; ah = a >> 32; ret = mul_u32_u32(al, b) >> shift; if (ah) ret += mul_u32_u32(ah, b) << (32 - shift); return ret; }
[ 0, 0 ]
Linux Kernel
tools/include/linux/math64.h
static inline u64 mul_u64_u64_div64(u64 a, u64 b, u64 c) { u64 quot, rem; quot = a / c; rem = a % c; return quot * b + (rem * b) / c; }
[ 1, 0 ]
Linux Kernel
tools/include/linux/rbtree.h
static inline void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new, struct rb_root_cached *root) { if (root->rb_leftmost == victim) root->rb_leftmost = new; rb_replace_node(victim, new, &root->rb_root); }
[ 0, 0 ]
Linux Kernel
tools/include/linux/rbtree.h
static __always_inline void rb_add_cached(struct rb_node *node, struct rb_root_cached *tree, bool (*less)(struct rb_node *, const struct rb_node *)) { struct rb_node **link = &tree->rb_root.rb_node; struct rb_node *parent = NULL; bool leftmost = true; while (*link) { parent = *link; if (l...
[ 0, 0 ]
Linux Kernel
tools/include/linux/rbtree.h
__always_inline struct rb_node * rb_find(const void *key, const struct rb_root *tree, int (*cmp)(const void *key, const struct rb_node *)) { struct rb_node *node = tree->rb_node; while (node) { int c = cmp(key, node); if (c < 0) node = node->rb_left; else if (c > 0) node = node->rb...
[ 0, 0 ]
Linux Kernel
tools/include/linux/rbtree.h
__always_inline struct rb_node * rb_next_match(const void *key, struct rb_node *node, int (*cmp)(const void *key, const struct rb_node *)) { node = rb_next(node); if (node && cmp(key, node)) node = NULL; return node; } #define rb_for_each(node, key, tree, cmp) ...
[ 1, 0 ]
Linux Kernel
tools/include/linux/refcount.h
static inline void refcount_inc(refcount_t *r) { REFCOUNT_WARN(!refcount_inc_not_zero(r), "refcount_t: increment on 0; use-after-free.\n"); }
[ 0, 0 ]
Linux Kernel
tools/include/linux/spinlock.h
static inline void arch_spin_lock(arch_spinlock_t *mutex) { pthread_mutex_lock(mutex); }
[ 0, 0 ]
Linux Kernel
tools/include/linux/unaligned/packed_struct.h
static inline u16 __get_unaligned_cpu16(const void *p) { const struct __una_u16 *ptr = (const struct __una_u16 *)p; return ptr->x; }
[ 0, 0 ]
Linux Kernel
tools/include/nolibc/stdio.h
int putchar(int c) { return fputc(c, stdout); }
[ 0, 0 ]
Linux Kernel
tools/include/nolibc/stdlib.h
int atoi(const char *s) { return atol(s); }
[ 0, 0 ]
Linux Kernel
tools/include/nolibc/string.h
void *memset(void *dst, int b, size_t len) { char *p = dst; while (len--) *(p++) = b; return dst; }
[ 0, 0 ]
Linux Kernel
tools/include/nolibc/string.h
int strcmp(const char *a, const char *b) { unsigned int c; int diff; while (!(diff = (unsigned char)*a++ - (c = (unsigned char)*b++)) && c) ; return diff; }
[ 0, 0 ]
Linux Kernel
tools/include/nolibc/string.h
char *strdup(const char *str) { size_t len; char *ret; len = strlen(str); ret = malloc(len + 1); if (__builtin_expect(ret != NULL, 1)) memcpy(ret, str, len + 1); return ret; }
[ 1, 0 ]
Linux Kernel
tools/include/nolibc/string.h
char *strncat(char *dst, const char *src, size_t size) { char *orig = dst; while (*dst) dst++; while (size && (*dst = *src)) { src++; dst++; size--; } *dst = 0; return orig; }
[ 0, 0 ]
Linux Kernel
tools/include/nolibc/string.h
char *strncpy(char *dst, const char *src, size_t size) { size_t len; for (len = 0; len < size; len++) if ((dst[len] = *src)) src++; return dst; }
[ 0, 0 ]
Linux Kernel
tools/include/nolibc/sys.h
int sys_getdents64(int fd, struct linux_dirent64 *dirp, int count) { return my_syscall3(__NR_getdents64, fd, dirp, count); }
[ 0, 0 ]
Linux Kernel
tools/include/nolibc/sys.h
pid_t sys_getpgid(pid_t pid) { return my_syscall1(__NR_getpgid, pid); }
[ 0, 0 ]
Linux Kernel
tools/include/nolibc/sys.h
int sys_stat(const char *path, struct stat *buf) { struct sys_stat_struct stat; long ret; #ifdef __NR_newfstatat ret = my_syscall4(__NR_newfstatat, AT_FDCWD, path, &stat, 0); #elif defined(__NR_stat) ret = my_syscall2(__NR_stat, path, &stat); #else #error Neither __NR_newfstatat nor __NR_stat defined, cannot ...
[ 0, 0 ]
Linux Kernel
tools/include/tools/be_byteshift.h
static inline uint16_t __get_unaligned_be16(const uint8_t *p) { return p[0] << 8 | p[1]; }
[ 0, 0 ]
Linux Kernel
tools/include/tools/be_byteshift.h
static inline uint32_t __get_unaligned_be32(const uint8_t *p) { return p[0] << 24 | p[1] << 16 | p[2] << 8 | p[3]; }
[ 1, 0 ]
Linux Kernel
tools/include/tools/be_byteshift.h
static inline void __put_unaligned_be16(uint16_t val, uint8_t *p) { *p++ = val >> 8; *p++ = val; }
[ 1, 0 ]
Linux Kernel
tools/include/tools/be_byteshift.h
static inline void __put_unaligned_be32(uint32_t val, uint8_t *p) { __put_unaligned_be16(val >> 16, p); __put_unaligned_be16(val, p + 2); }
[ 0, 0 ]
Linux Kernel
tools/include/tools/be_byteshift.h
static inline void put_unaligned_be64(uint64_t val, void *p) { __put_unaligned_be64(val, p); }
[ 0, 0 ]
Linux Kernel
tools/include/tools/dis-asm-compat.h
static inline int fprintf_styled(void *out, enum disassembler_style style, const char *fmt, ...) { va_list args; int r; (void)style; va_start(args, fmt); r = vfprintf(out, fmt, args); va_end(args); return r; }
[ 0, 0 ]
Linux Kernel
tools/include/tools/dis-asm-compat.h
static inline void init_disassemble_info_compat(struct disassemble_info *info, void *stream, fprintf_ftype unstyled_func, fprintf_styled_ftype styled_func) { #ifdef DISASM_INIT_STYLED init_disassemble_info(info, stream, unstyled_func, styled_func); #else (vo...
[ 0, 0 ]
Linux Kernel
tools/include/tools/le_byteshift.h
static inline uint16_t __get_unaligned_le16(const uint8_t *p) { return p[0] | p[1] << 8; }
[ 0, 0 ]
Linux Kernel
tools/include/tools/le_byteshift.h
static inline uint32_t __get_unaligned_le32(const uint8_t *p) { return p[0] | p[1] << 8 | p[2] << 16 | p[3] << 24; }
[ 1, 0 ]
Linux Kernel
tools/include/tools/le_byteshift.h
static inline uint64_t __get_unaligned_le64(const uint8_t *p) { return (uint64_t)__get_unaligned_le32(p + 4) << 32 | __get_unaligned_le32(p); }
[ 1, 0 ]
Linux Kernel
tools/include/tools/le_byteshift.h
static inline void __put_unaligned_le16(uint16_t val, uint8_t *p) { *p++ = val; *p++ = val >> 8; }
[ 1, 0 ]
Linux Kernel
tools/include/tools/le_byteshift.h
static inline uint32_t get_unaligned_le32(const void *p) { return __get_unaligned_le32((const uint8_t *)p); }
[ 0, 0 ]
Linux Kernel
tools/include/tools/le_byteshift.h
static inline void put_unaligned_le32(uint32_t val, void *p) { __put_unaligned_le32(val, p); }
[ 0, 0 ]
Linux Kernel
tools/io_uring/io_uring-bench.c
static int lk_gettid(void) { return syscall(__NR_gettid); }
[ 0, 0 ]
Linux Kernel
tools/io_uring/io_uring-bench.c
static int prep_more_ios(struct submitter *s, unsigned max_ios) { struct io_sq_ring *ring = &s->sq_ring; unsigned index, tail, next_tail, prepped = 0; next_tail = tail = *ring->tail; do { next_tail++; read_barrier(); if (next_tail == *ring->head) break; index = tail & sq_ring_mask; i...
[ 1, 0 ]
Linux Kernel
tools/io_uring/io_uring-bench.c
static int reap_events(struct submitter *s) { struct io_cq_ring *ring = &s->cq_ring; struct io_uring_cqe *cqe; unsigned head, reaped = 0; head = *ring->head; do { struct file *f; read_barrier(); if (head == *ring->tail) break; cqe = &ring->cqes[head & cq_ring_mask]; if (!do_nop) {...
[ 1, 0 ]
Linux Kernel
tools/io_uring/io_uring-bench.c
static void arm_sig_int(void) { struct sigaction act; memset(&act, 0, sizeof(act)); act.sa_handler = sig_int; act.sa_flags = SA_RESTART; sigaction(SIGINT, &act, NULL); }
[ 1, 0 ]
Linux Kernel
tools/io_uring/io_uring-cp.c
static int queue_read(struct io_uring *ring, off_t size, off_t offset) { struct io_uring_sqe *sqe; struct io_data *data; data = malloc(size + sizeof(*data)); if (!data) return 1; sqe = io_uring_get_sqe(ring); if (!sqe) { free(data); return 1; } data->read = 1; data->offset = data->firs...
[ 1, 0 ]
Linux Kernel
tools/io_uring/io_uring-cp.c
static void queue_write(struct io_uring *ring, struct io_data *data) { data->read = 0; data->offset = data->first_offset; data->iov.iov_base = data + 1; data->iov.iov_len = data->first_len; queue_prepped(ring, data); io_uring_submit(ring); }
[ 0, 0 ]
Linux Kernel
tools/io_uring/queue.c
static int __io_uring_get_cqe(struct io_uring *ring, struct io_uring_cqe **cqe_ptr, int wait) { struct io_uring_cq *cq = &ring->cq; const unsigned mask = *cq->kring_mask; unsigned head; int ret; *cqe_ptr = NULL; head = *cq->khead; do { read_barrier(); if (head != *c...
[ 1, 0 ]
Linux Kernel
tools/io_uring/queue.c
struct io_uring_sqe *io_uring_get_sqe(struct io_uring *ring) { struct io_uring_sq *sq = &ring->sq; unsigned next = sq->sqe_tail + 1; struct io_uring_sqe *sqe; if (next - sq->sqe_head > *sq->kring_entries) return NULL; sqe = &sq->sqes[sq->sqe_tail & *sq->kring_mask]; sq->sqe_tail = next; return sqe; ...
[ 1, 0 ]
Linux Kernel
tools/io_uring/setup.c
int io_uring_queue_init(unsigned entries, struct io_uring *ring, unsigned flags) { struct io_uring_params p; int fd, ret; memset(&p, 0, sizeof(p)); p.flags = flags; fd = io_uring_setup(entries, &p); if (fd < 0) return fd; ret = io_uring_queue_mmap(fd, &p, ring); if (ret) ...
[ 1, 0 ]
Linux Kernel
tools/io_uring/syscall.c
int io_uring_register(int fd, unsigned int opcode, void *arg, unsigned int nr_args) { return syscall(__NR_io_uring_register, fd, opcode, arg, nr_args); }
[ 0, 0 ]
Linux Kernel
tools/laptop/dslm/dslm.c
static int check_powermode(int fd) { unsigned char args[4] = {WIN_CHECKPOWERMODE1, 0, 0, 0}; int state; if (ioctl(fd, HDIO_DRIVE_CMD, &args) && (args[0] = WIN_CHECKPOWERMODE2) && ioctl(fd, HDIO_DRIVE_CMD, &args)) { if (errno != EIO || args[0] != 0 || args[1] != 0) { state = -1; /* "unknown"; */ ...
[ 1, 0 ]
Linux Kernel
tools/laptop/dslm/dslm.c
static char *myctime(time_t time) { char *ts = ctime(&time); ts[strlen(ts) - 1] = 0; return ts; }
[ 0, 0 ]
Linux Kernel
tools/laptop/freefall/freefall.c
static int set_unload_heads_path(char *device) { if (strlen(device) <= 5 || strncmp(device, "/dev/", 5) != 0) return -EINVAL; strncpy(device_path, device, sizeof(device_path) - 1); snprintf(unload_heads_path, sizeof(unload_heads_path) - 1, "/sys/block/%s/device/unload_heads", device + 5); retur...
[ 1, 0 ]
Linux Kernel
tools/laptop/freefall/freefall.c
static void write_int(char *path, int i) { char buf[1024]; int fd = open(path, O_RDWR); if (fd < 0) { perror("open"); exit(1); } sprintf(buf, "%d", i); if (write(fd, buf, strlen(buf)) != strlen(buf)) { perror("write"); exit(1); } close(fd); }
[ 1, 0 ]
Linux Kernel
tools/laptop/freefall/freefall.c
int main(int argc, char **argv) { int fd, ret; struct stat st; struct sched_param param; if (argc == 1) ret = set_unload_heads_path("/dev/sda"); else if (argc == 2) ret = set_unload_heads_path(argv[1]); else ret = -EINVAL; if (ret || !valid_disk()) { fprintf(stderr, "usage: %s <device> (...
[ 1, 0 ]