Toggle navigation
Documentation
The friendly Operating System for the Internet of Things
Loading...
Searching...
No Matches
binsearch.h
1
/*
2
* Copyright (C) 2018 Freie Universität Berlin
3
*
4
* This file is subject to the terms and conditions of the GNU Lesser
5
* General Public License v2.1. See the file LICENSE in the top level
6
* directory for more details.
7
*/
8
44
#ifndef BINSEARCH_H
45
#define BINSEARCH_H
46
47
#include <stdint.h>
48
#include <
errno.h
>
49
50
#ifdef __cplusplus
51
extern
"C"
{
52
#endif
53
57
#define _ENSURE_LVALUE(x) ((void)sizeof(&(x)))
58
63
#define _ARRAY_STRIDE(arr) ((size_t)((const uint8_t *)((arr) + 1) - (const uint8_t *)(arr)))
64
69
#define _ARRAY_MEMBER_OFFS(arr, member) \
70
((size_t)((const uint8_t *)(&((arr)->member)) - (const uint8_t *)(arr)))
71
82
#define BINSEARCH_STR(arr, nmemb, member, str, n) \
83
(_ENSURE_LVALUE(arr), \
84
(binsearch_str((arr), _ARRAY_MEMBER_OFFS(arr, member), _ARRAY_STRIDE(arr), \
85
(nmemb), (str), (n))) \
86
)
87
95
#define BINSEARCH_STR_P(arr, nmemb, member, str, n) \
96
(_ENSURE_LVALUE(arr), \
97
(binsearch_str_p((arr), _ARRAY_MEMBER_OFFS(arr, member), _ARRAY_STRIDE(arr), \
98
(nmemb), (str), (n))) \
99
)
100
120
int
binsearch_str(
const
void
*start,
size_t
offset,
size_t
stride,
size_t
nmemb,
121
const
char
*str,
size_t
n);
122
129
const
void
*binsearch_str_p(
const
void
*start,
size_t
offset,
size_t
stride,
130
size_t
nmemb,
const
char
*str,
size_t
n);
131
132
#ifdef __cplusplus
133
}
134
#endif
135
136
#endif
/* BINSEARCH_H */
errno.h
Generated on Fri Jan 3 2025 13:31:20 by
1.9.8