thunk
struct fopencookie_thunk *thunk;
thunk = cookie;
if (thunk->foc_io.write == NULL)
return ((int)thunk->foc_io.write(thunk->foc_cookie, buf,
struct fopencookie_thunk *thunk;
thunk = cookie;
if (thunk->foc_io.seek == NULL) {
res = thunk->foc_io.seek(thunk->foc_cookie, &off64, whence);
struct fopencookie_thunk *thunk;
thunk = cookie;
if (thunk->foc_io.close != NULL)
ret = thunk->foc_io.close(thunk->foc_cookie);
free(thunk);
struct fopencookie_thunk *thunk;
thunk = malloc(sizeof(*thunk));
if (thunk == NULL)
thunk->foc_cookie = cookie;
thunk->foc_io = io_funcs;
fp = funopen(thunk, readfn, writefn, _fopencookie_seek,
free(thunk);
struct fopencookie_thunk *thunk;
thunk = cookie;
if (thunk->foc_io.read == NULL)
return ((int)thunk->foc_io.read(thunk->foc_cookie, buf, (size_t)size));
qsort_r(void *a, size_t n, size_t es, void *thunk, cmp_t *cmp)
pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
pl = med3(pl, pl + d, pl + 2 * d, cmp, thunk);
pm = med3(pm - d, pm, pm + d, cmp, thunk);
pn = med3(pn - 2 * d, pn - d, pn, cmp, thunk);
pm = med3(pl, pm, pn, cmp, thunk);
while (pb <= pc && (cmp_result = CMP(thunk, pb, a)) <= 0) {
while (pb <= pc && (cmp_result = CMP(thunk, pc, a)) >= 0) {
pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
qsort_r(a, r / es, es, thunk, cmp);
med3(char *a, char *b, char *c, cmp_t *cmp, void *thunk
return CMP(thunk, a, b) < 0 ?
(CMP(thunk, b, c) < 0 ? b : (CMP(thunk, a, c) < 0 ? c : a ))
:(CMP(thunk, b, c) > 0 ? b : (CMP(thunk, a, c) < 0 ? a : c ));
kqsort_r(void *a, size_t n, size_t es, void *thunk, cmp_t *cmp)
for (pl = pm; pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
pl = med3(pl, pl + d, pl + 2 * d, cmp, thunk);
pm = med3(pm - d, pm, pm + d, cmp, thunk);
pn = med3(pn - 2 * d, pn - d, pn, cmp, thunk);
pm = med3(pl, pm, pn, cmp, thunk);
while (pb <= pc && (r = CMP(thunk, pb, a)) <= 0) {
while (pb <= pc && (r = CMP(thunk, pc, a)) >= 0) {
for (pl = pm; pl > (char *)a && CMP(thunk, pl - es, pl) > 0;
kqsort_r(a, r / es, es, thunk, cmp);
med3(char *a, char *b, char *c, cmp_t *cmp, void *thunk
return CMP(thunk, a, b) < 0 ?
(CMP(thunk, b, c) < 0 ? b : (CMP(thunk, a, c) < 0 ? c : a ))
:(CMP(thunk, b, c) > 0 ? b : (CMP(thunk, a, c) < 0 ? a : c ));
void kqsort_r(void *base, size_t nmemb, size_t size, void *thunk,