jameschennerd commited on
Commit
84d9ccd
·
verified ·
1 Parent(s): b1b2b5e

Delete fnptr-callback.md with huggingface_hub

Browse files
Files changed (1) hide show
  1. fnptr-callback.md +0 -1334
fnptr-callback.md DELETED
@@ -1,1334 +0,0 @@
1
- # Example 1
2
-
3
- ## Callsite
4
-
5
- */home/yuanting/work/icall-benchmarks/llm/curl-build/lib/../../curl-8.5.0/lib/vauth/digest.c:806:3*
6
-
7
- fnptr: *convert_to_ascii*
8
-
9
- targets: auth_digest_md5_to_ascii, auth_digest_sha256_to_ascii
10
-
11
- ## Related Code Snippets
12
-
13
- ```c
14
- static CURLcode auth_create_digest_http_message(
15
- struct Curl_easy *data,
16
- const char *userp,
17
- const char *passwdp,
18
- const unsigned char *request,
19
- const unsigned char *uripath,
20
- struct digestdata *digest,
21
- char **outptr, size_t *outlen,
22
- void (*convert_to_ascii)(unsigned char *, unsigned char *),
23
- CURLcode (*hash)(unsigned char *, const unsigned char *,
24
- const size_t))
25
- {
26
- if(digest->userhash) {
27
- hashthis = aprintf("%s:%s", userp, digest->realm ? digest->realm : "");
28
- if(!hashthis)
29
- return CURLE_OUT_OF_MEMORY;
30
-
31
- hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
32
- free(hashthis);
33
- convert_to_ascii(hashbuf, (unsigned char *)userh);
34
- }
35
- }
36
- ```
37
-
38
- ```c
39
- CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
40
- const char *userp,
41
- const char *passwdp,
42
- const unsigned char *request,
43
- const unsigned char *uripath,
44
- struct digestdata *digest,
45
- char **outptr, size_t *outlen)
46
- {
47
- if(digest->algo <= ALGO_MD5SESS)
48
- return auth_create_digest_http_message(data, userp, passwdp,
49
- request, uripath, digest,
50
- outptr, outlen,
51
- auth_digest_md5_to_ascii,
52
- Curl_md5it);
53
- DEBUGASSERT(digest->algo <= ALGO_SHA512_256SESS);
54
- return auth_create_digest_http_message(data, userp, passwdp,
55
- request, uripath, digest,
56
- outptr, outlen,
57
- auth_digest_sha256_to_ascii,
58
- Curl_sha256it);
59
- }
60
- ```
61
-
62
- # Example 2
63
-
64
- ## Callsite
65
-
66
- */home/yuanting/work/icall-benchmarks/llm/wrk-4.2.0/src/wrk.c:551:17*
67
-
68
- fnptr: *fmt*
69
-
70
- targets: format_time_us, format_metric
71
-
72
- ## Related Code Snippets
73
-
74
- ```c
75
- static void print_units(long double n, char *(*fmt)(long double), int width) {
76
- char *msg = fmt(n);
77
- int len = strlen(msg), pad = 2;
78
-
79
- if (isalpha(msg[len-1])) pad--;
80
- if (isalpha(msg[len-2])) pad--;
81
- width -= pad;
82
-
83
- printf("%*.*s%.*s", width, width, msg, pad, " ");
84
-
85
- free(msg);
86
- }
87
- ```
88
-
89
- ```c
90
- static void print_stats_latency(stats *stats) {
91
- long double percentiles[] = { 50.0, 75.0, 90.0, 99.0 };
92
- printf(" Latency Distribution\n");
93
- for (size_t i = 0; i < sizeof(percentiles) / sizeof(long double); i++) {
94
- long double p = percentiles[i];
95
- uint64_t n = stats_percentile(stats, p);
96
- printf("%7.0Lf%%", p);
97
- print_units(n, format_time_us, 10);
98
- printf("\n");
99
- }
100
- }
101
- ```
102
-
103
- ```c
104
- static void print_stats(char *name, stats *stats, char *(*fmt)(long double)) {
105
- uint64_t max = stats->max;
106
- long double mean = stats_mean(stats);
107
- long double stdev = stats_stdev(stats, mean);
108
-
109
- printf(" %-10s", name);
110
- print_units(mean, fmt, 8);
111
- print_units(stdev, fmt, 10);
112
- print_units(max, fmt, 9);
113
- printf("%8.2Lf%%\n", stats_within_stdev(stats, mean, stdev, 1));
114
- }
115
- ```
116
-
117
- ```c
118
- int main(int argc, char **argv) {
119
- char *url, **headers = zmalloc(argc * sizeof(char *));
120
- struct http_parser_url parts = {};
121
-
122
- if (parse_args(&cfg, &url, &parts, headers, argc, argv)) {
123
- usage();
124
- exit(1);
125
- }
126
- ...
127
- print_stats_header();
128
- print_stats("Latency", statistics.latency, format_time_us);
129
- print_stats("Req/Sec", statistics.requests, format_metric);
130
- ...
131
- }
132
- ```
133
-
134
- # Example 3
135
-
136
- ## Callsite
137
-
138
- */home/yuanting/work/icall-benchmarks/llm/zfs-build/../zfs-2.2.2/lib/libshare/nfs.c:202:11*
139
-
140
- fnptr: *cbk*
141
-
142
- targets: nfs_is_shared_cb, nfs_copy_entries_cb
143
-
144
- ## Related Code Snippets
145
-
146
- ```c
147
- static nfs_process_exports(const char *exports, const char *mountpoint,
148
- boolean_t (*cbk)(void *userdata, char *line, boolean_t found_mountpoint),
149
- void *userdata)
150
- {
151
- int error = SA_OK;
152
- boolean_t cont = B_TRUE;
153
-
154
- FILE *oldfp = fopen(exports, "re");
155
- if (oldfp != NULL) {
156
- ...
157
-
158
- while (cont && getline(&buf, &buflen, oldfp) != -1) {
159
- if (buf[0] == '\n' || buf[0] == '#')
160
- continue;
161
-
162
- cont = cbk(userdata, buf,
163
- (sep = strpbrk(buf, "\t \n")) != NULL &&
164
- sep - buf == mplen &&
165
- strncmp(buf, mp, mplen) == 0);
166
- ...
167
- }
168
-
169
- return (error);
170
- }
171
- }
172
- ```
173
-
174
- ```c
175
- static nfs_copy_entries(FILE *newfp, const char *exports, const char *mountpoint)
176
- {
177
- fputs(FILE_HEADER, newfp);
178
-
179
- int error = nfs_process_exports(
180
- exports, mountpoint, nfs_copy_entries_cb, newfp);
181
-
182
- if (error == SA_OK && ferror(newfp) != 0)
183
- error = ferror(newfp);
184
-
185
- return (error);
186
- }
187
- ```
188
-
189
- ```c
190
- boolean_t nfs_is_shared_impl(const char *exports, sa_share_impl_t impl_share)
191
- {
192
- boolean_t found = B_FALSE;
193
- nfs_process_exports(exports, impl_share->sa_mountpoint,
194
- nfs_is_shared_cb, &found);
195
- return (found);
196
- }
197
- ```
198
-
199
- # Example 4
200
-
201
- ## Callsite
202
-
203
- */home/yuanting/work/icall-benchmarks/llm/ffmpeg-6.1.1/libavcodec/allcodecs.c:957:14*
204
-
205
- fnptr: *x*
206
-
207
- targets: av_codec_is_decoder, av_codec_is_encoder
208
-
209
- ## Related Code Snippets
210
-
211
- ```c
212
- static const AVCodec *find_codec(enum AVCodecID id, int (*x)(const AVCodec *))
213
- {
214
- const AVCodec *p, *experimental = NULL;
215
- void *i = 0;
216
-
217
- id = remap_deprecated_codec_id(id);
218
-
219
- while ((p = av_codec_iterate(&i))) {
220
- if (!x(p))
221
- continue;
222
- if (p->id == id) {
223
- if (p->capabilities & AV_CODEC_CAP_EXPERIMENTAL && !experimental) {
224
- experimental = p;
225
- } else
226
- return p;
227
- }
228
- }
229
-
230
- return experimental;
231
- }
232
- ```
233
-
234
- ```c
235
- const AVCodec *avcodec_find_encoder(enum AVCodecID id)
236
- {
237
- return find_codec(id, av_codec_is_encoder);
238
- }
239
-
240
- const AVCodec *avcodec_find_decoder(enum AVCodecID id)
241
- {
242
- return find_codec(id, av_codec_is_decoder);
243
- }
244
-
245
- ```
246
-
247
- # Example 5
248
-
249
- ## Callsite
250
-
251
- */home/yuanting/work/icall-benchmarks/llm/redis-stable/src/quicklist.c:1543:21*
252
-
253
- fnptr: *saver*
254
-
255
- targets: _quicklistSaver, listPopSaver
256
-
257
- ## Related Code Snippets
258
-
259
- ```c
260
- int quicklistPopCustom(quicklist *quicklist, int where, unsigned char **data,
261
- size_t *sz, long long *sval,
262
- void *(*saver)(unsigned char *data, size_t sz)) {
263
- unsigned char *p;
264
- unsigned char *vstr;
265
- unsigned int vlen;
266
- long long vlong;
267
- int pos = (where == QUICKLIST_HEAD) ? 0 : -1;
268
-
269
- ...
270
-
271
- if (unlikely(QL_NODE_IS_PLAIN(node))) {
272
- if (data)
273
- *data = saver(node->entry, node->sz);
274
- if (sz)
275
- *sz = node->sz;
276
- quicklistDelIndex(quicklist, node, NULL);
277
- return 1;
278
- }
279
- ...
280
- }
281
- ```
282
-
283
- ```c
284
- robj *listTypePop(robj *subject, int where) {
285
- robj *value = NULL;
286
-
287
- if (subject->encoding == OBJ_ENCODING_QUICKLIST) {
288
- long long vlong;
289
- int ql_where = where == LIST_HEAD ? QUICKLIST_HEAD : QUICKLIST_TAIL;
290
- if (quicklistPopCustom(subject->ptr, ql_where, (unsigned char **)&value,
291
- NULL, &vlong, listPopSaver)) {
292
- if (!value)
293
- value = createStringObjectFromLongLong(vlong);
294
- }
295
- ...
296
- }
297
- }
298
- ```
299
-
300
- ```c
301
- int quicklistPop(quicklist *quicklist, int where, unsigned char **data,
302
- size_t *sz, long long *slong) {
303
- unsigned char *vstr = NULL;
304
- size_t vlen = 0;
305
- long long vlong = 0;
306
- if (quicklist->count == 0)
307
- return 0;
308
- int ret = quicklistPopCustom(quicklist, where, &vstr, &vlen, &vlong,
309
- _quicklistSaver);
310
- ...
311
- }
312
- ```
313
-
314
- # Example 6
315
-
316
- ## Callsite
317
-
318
- */home/yuanting/work/icall-benchmarks/llm/redis-stable/deps/jemalloc/include/jemalloc/internal/emap.h:329:21*
319
-
320
- fnptr: *ptr_getter*
321
-
322
- targets: tcache_bin_flush_ptr_getter
323
-
324
- ## Related Code Snippets
325
-
326
- ```c
327
- JEMALLOC_ALWAYS_INLINE void
328
- emap_edata_lookup_batch(tsd_t *tsd, emap_t *emap, size_t nptrs,
329
- emap_ptr_getter ptr_getter, void *ptr_getter_ctx,
330
- emap_metadata_visitor metadata_visitor, void *metadata_visitor_ctx,
331
- emap_batch_lookup_result_t *result) {
332
- ...
333
-
334
- for (size_t i = 0; i < nptrs; i++) {
335
- const void *ptr = ptr_getter(ptr_getter_ctx, i);
336
-
337
- result[i].rtree_leaf = rtree_leaf_elm_lookup(tsd_tsdn(tsd),
338
- &emap->rtree, rtree_ctx, (uintptr_t)ptr,
339
- /* dependent */ true, /* init_missing */ false);
340
- }
341
-
342
- ...
343
- }
344
- ```
345
-
346
- ```c
347
- static void
348
- tcache_bin_flush_edatas_lookup(tsd_t *tsd, cache_bin_ptr_array_t *arr,
349
- szind_t binind, size_t nflush, emap_batch_lookup_result_t *edatas) {
350
-
351
- size_t szind_sum = binind * nflush;
352
- emap_edata_lookup_batch(tsd, &arena_emap_global, nflush,
353
- &tcache_bin_flush_ptr_getter, (void *)arr,
354
- &tcache_bin_flush_metadata_visitor, (void *)&szind_sum,
355
- edatas);
356
- if (config_opt_safety_checks && unlikely(szind_sum != 0)) {
357
- tcache_bin_flush_size_check_fail(arr, binind, nflush, edatas);
358
- }
359
- }
360
- ```
361
-
362
- # Example 7
363
-
364
- ## Callsite
365
-
366
- */home/yuanting/work/icall-benchmarks/llm/redis-stable/src/defrag.c:583:23*
367
-
368
- fnptr: *element_cb*
369
-
370
- targets: defragStreamConsumerPendingEntry, defragStreamConsumer, defragStreamConsumerGroup
371
-
372
- ## Related Code Snippets
373
-
374
- ```c
375
- void defragRadixTree(rax **raxref, int defrag_data, raxDefragFunction *element_cb, void *element_cb_data) {
376
- raxIterator ri;
377
- rax* rax;
378
- ...
379
- while (raxNext(&ri)) {
380
- void *newdata = NULL;
381
- if (element_cb)
382
- newdata = element_cb(&ri, element_cb_data);
383
- if (defrag_data && !newdata)
384
- newdata = activeDefragAlloc(ri.data);
385
- if (newdata)
386
- raxSetData(ri.node, ri.data=newdata);
387
- }
388
- raxStop(&ri);
389
- }
390
- ```
391
-
392
- ```c
393
- void* defragStreamConsumer(raxIterator *ri, void *privdata) {
394
- streamConsumer *c = ri->data;
395
- streamCG *cg = privdata;
396
- void *newc = activeDefragAlloc(c);
397
- if (newc) {
398
- c = newc;
399
- }
400
- sds newsds = activeDefragSds(c->name);
401
- if (newsds)
402
- c->name = newsds;
403
- if (c->pel) {
404
- PendingEntryContext pel_ctx = {cg, c};
405
- defragRadixTree(&c->pel, 0, defragStreamConsumerPendingEntry, &pel_ctx);
406
- }
407
- return newc; /* returns NULL if c was not defragged */
408
- }
409
- ```
410
-
411
- ```c
412
- void* defragStreamConsumerGroup(raxIterator *ri, void *privdata) {
413
- streamCG *cg = ri->data;
414
- UNUSED(privdata);
415
- if (cg->consumers)
416
- defragRadixTree(&cg->consumers, 0, defragStreamConsumer, cg);
417
- if (cg->pel)
418
- defragRadixTree(&cg->pel, 0, NULL, NULL);
419
- return NULL;
420
- }
421
- ```
422
-
423
- ```c
424
- void defragStream(redisDb *db, dictEntry *kde) {
425
- robj *ob = dictGetVal(kde);
426
- serverAssert(ob->type == OBJ_STREAM && ob->encoding == OBJ_ENCODING_STREAM);
427
- stream *s = ob->ptr, *news;
428
-
429
- /* handle the main struct */
430
- if ((news = activeDefragAlloc(s)))
431
- ob->ptr = s = news;
432
-
433
- if (raxSize(s->rax) > server.active_defrag_max_scan_fields) {
434
- rax *newrax = activeDefragAlloc(s->rax);
435
- if (newrax)
436
- s->rax = newrax;
437
- defragLater(db, kde);
438
- } else
439
- defragRadixTree(&s->rax, 1, NULL, NULL);
440
-
441
- if (s->cgroups)
442
- defragRadixTree(&s->cgroups, 1, defragStreamConsumerGroup, NULL);
443
- }
444
- ```
445
-
446
- # Example 8
447
-
448
- ## Callsite
449
-
450
- */home/yuanting/work/icall-benchmarks/llm/redis-stable/src/pqsort.c:95:38*
451
-
452
- fnptr: *cmp*
453
-
454
- targets: sort_gp_asc, sort_gp_desc, sortCompare
455
-
456
- ## Related Code Snippets
457
-
458
- ```c
459
- static inline char *
460
- med3(char *a, char *b, char *c,
461
- int (*cmp) (const void *, const void *))
462
- {
463
-
464
- return cmp(a, b) < 0 ?
465
- (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a ))
466
- :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c ));
467
- }
468
- ```
469
-
470
- ```c
471
- static void _pqsort(void *a, size_t n, size_t es,
472
- int (*cmp) (const void *, const void *), void *lrange, void *rrange)
473
- {
474
- char *pa, *pb, *pc, *pd, *pl, *pm, *pn;
475
- size_t d, r;
476
- int swaptype, cmp_result;
477
-
478
- loop: SWAPINIT(a, es);
479
- if (n < 7) {
480
- for (pm = (char *) a + es; pm < (char *) a + n * es; pm += es)
481
- for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0;
482
- pl -= es)
483
- swap(pl, pl - es);
484
- return;
485
- }
486
- pm = (char *) a + (n / 2) * es;
487
- if (n > 7) {
488
- pl = (char *) a;
489
- pn = (char *) a + (n - 1) * es;
490
- if (n > 40) {
491
- d = (n / 8) * es;
492
- pl = med3(pl, pl + d, pl + 2 * d, cmp);
493
- pm = med3(pm - d, pm, pm + d, cmp);
494
- pn = med3(pn - 2 * d, pn - d, pn, cmp);
495
- }
496
- pm = med3(pl, pm, pn, cmp);
497
- }
498
- }
499
- ```
500
-
501
- ```c
502
- void
503
- pqsort(void *a, size_t n, size_t es,
504
- int (*cmp) (const void *, const void *), size_t lrange, size_t rrange)
505
- {
506
- _pqsort(a,n,es,cmp,((unsigned char*)a)+(lrange*es),
507
- ((unsigned char*)a)+((rrange+1)*es)-1);
508
- }
509
- ```
510
-
511
- ```c
512
- void georadiusGeneric(client *c, int srcKeyIndex, int flags) {
513
- robj *storekey = NULL;
514
- ...
515
-
516
- /* Process [optional] requested sorting */
517
- if (sort != SORT_NONE) {
518
- int (*sort_gp_callback)(const void *a, const void *b) = NULL;
519
- if (sort == SORT_ASC) {
520
- sort_gp_callback = sort_gp_asc;
521
- } else if (sort == SORT_DESC) {
522
- sort_gp_callback = sort_gp_desc;
523
- }
524
-
525
- if (returned_items == result_length) {
526
- qsort(ga->array, result_length, sizeof(geoPoint), sort_gp_callback);
527
- } else {
528
- pqsort(ga->array, result_length, sizeof(geoPoint), sort_gp_callback,
529
- 0, (returned_items - 1));
530
- }
531
- }
532
- }
533
- ```
534
-
535
- ```c
536
- void sortCommandGeneric(client *c, int readonly) {
537
- ...
538
-
539
- /* Now it's time to load the right scores in the sorting vector */
540
- if (!dontsort) {
541
- ...
542
- if (sortby && (start != 0 || end != vectorlen-1))
543
- pqsort(vector,vectorlen,sizeof(redisSortObject),sortCompare, start,end);
544
- else
545
- qsort(vector,vectorlen,sizeof(redisSortObject),sortCompare);
546
- }
547
- }
548
- ```
549
-
550
- # Example 9
551
-
552
- ## Callsite
553
-
554
- */home/yuanting/work/icall-benchmarks/llm/redis-stable/src/server.c:4872:9*
555
-
556
- fnptr: *reply_function*
557
-
558
- targets: addReplyCommandInfo, addReplyCommandDocs
559
-
560
- ## Related Code Snippets
561
-
562
- ```c
563
- void addReplyCommandSubCommands(client *c, struct redisCommand *cmd, void (*reply_function)(client*, struct redisCommand*), int use_map) {
564
- if (!cmd->subcommands_dict) {
565
- addReplySetLen(c, 0);
566
- return;
567
- }
568
-
569
- if (use_map)
570
- addReplyMapLen(c, dictSize(cmd->subcommands_dict));
571
- else
572
- addReplyArrayLen(c, dictSize(cmd->subcommands_dict));
573
- dictEntry *de;
574
- dictIterator *di = dictGetSafeIterator(cmd->subcommands_dict);
575
- while((de = dictNext(di)) != NULL) {
576
- struct redisCommand *sub = (struct redisCommand *)dictGetVal(de);
577
- if (use_map)
578
- addReplyBulkCBuffer(c, sub->fullname, sdslen(sub->fullname));
579
- reply_function(c, sub);
580
- }
581
- dictReleaseIterator(di);
582
- }
583
- ```
584
-
585
- ```c
586
- void addReplyCommandInfo(client *c, struct redisCommand *cmd) {
587
- if (!cmd) {
588
- addReplyNull(c);
589
- } else {
590
- int firstkey = 0, lastkey = 0, keystep = 0;
591
- if (cmd->legacy_range_key_spec.begin_search_type != KSPEC_BS_INVALID) {
592
- firstkey = cmd->legacy_range_key_spec.bs.index.pos;
593
- lastkey = cmd->legacy_range_key_spec.fk.range.lastkey;
594
- if (lastkey >= 0)
595
- lastkey += firstkey;
596
- keystep = cmd->legacy_range_key_spec.fk.range.keystep;
597
- }
598
-
599
- addReplyArrayLen(c, 10);
600
- addReplyBulkCBuffer(c, cmd->fullname, sdslen(cmd->fullname));
601
- addReplyLongLong(c, cmd->arity);
602
- addReplyFlagsForCommand(c, cmd);
603
- addReplyLongLong(c, firstkey);
604
- addReplyLongLong(c, lastkey);
605
- addReplyLongLong(c, keystep);
606
- addReplyCommandCategories(c, cmd);
607
- addReplyCommandTips(c, cmd);
608
- addReplyCommandKeySpecs(c, cmd);
609
- addReplyCommandSubCommands(c, cmd, addReplyCommandInfo, 0);
610
- }
611
- }
612
- ```
613
-
614
- ```c
615
- void addReplyCommandDocs(client *c, struct redisCommand *cmd) {
616
- /* Count our reply len so we don't have to use deferred reply. */
617
- long maplen = 1;
618
- ...
619
- if (cmd->args) {
620
- addReplyBulkCString(c, "arguments");
621
- addReplyCommandArgList(c, cmd->args, cmd->num_args);
622
- }
623
- if (cmd->subcommands_dict) {
624
- addReplyBulkCString(c, "subcommands");
625
- addReplyCommandSubCommands(c, cmd, addReplyCommandDocs, 1);
626
- }
627
- }
628
- ```
629
-
630
- # Example 10
631
-
632
- ## Callsite
633
-
634
- */home/yuanting/work/icall-benchmarks/llm/zfs-build/../zfs-2.2.2/module/icp/algs/modes/ccm.c:97:3*
635
-
636
- fnptr: *encrypt_block*
637
-
638
- targets: aes_encrypt_block
639
-
640
- ## Related Code Snippets
641
-
642
- ```c
643
- int ccm_mode_encrypt_contiguous_blocks(ccm_ctx_t *ctx, char *data, size_t length,
644
- crypto_data_t *out, size_t block_size,
645
- int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
646
- void (*copy_block)(uint8_t *, uint8_t *),
647
- void (*xor_block)(uint8_t *, uint8_t *))
648
- {
649
- size_t remainder = length;
650
- ...
651
-
652
- if (length + ctx->ccm_remainder_len < block_size) {
653
- /* accumulate bytes here and return */
654
- memcpy((uint8_t *)ctx->ccm_remainder + ctx->ccm_remainder_len,
655
- datap,
656
- length);
657
- ctx->ccm_remainder_len += length;
658
- ctx->ccm_copy_to = datap;
659
- return (CRYPTO_SUCCESS);
660
- }
661
-
662
- crypto_init_ptrs(out, &iov_or_mp, &offset);
663
-
664
- mac_buf = (uint8_t *)ctx->ccm_mac_buf;
665
-
666
- do {
667
- /* Unprocessed data from last call. */
668
- ...
669
-
670
- xor_block(blockp, mac_buf);
671
- encrypt_block(ctx->ccm_keysched, mac_buf, mac_buf);
672
-
673
- /* ccm_cb is the counter block */
674
- encrypt_block(ctx->ccm_keysched, (uint8_t *)ctx->ccm_cb,
675
- (uint8_t *)ctx->ccm_tmp);
676
-
677
- ...
678
- ctx->ccm_copy_to = NULL;
679
-
680
- } while (remainder > 0);
681
-
682
- out:
683
- return (CRYPTO_SUCCESS);
684
- }
685
- ```
686
-
687
- ```c
688
- int aes_encrypt_contiguous_blocks(void *ctx, char *data, size_t length,
689
- crypto_data_t *out)
690
- {
691
- aes_ctx_t *aes_ctx = ctx;
692
- int rv;
693
-
694
- if (aes_ctx->ac_flags & CTR_MODE) {
695
- rv = ctr_mode_contiguous_blocks(ctx, data, length, out,
696
- AES_BLOCK_LEN, aes_encrypt_block, aes_xor_block);
697
- } else if (aes_ctx->ac_flags & CCM_MODE) {
698
- rv = ccm_mode_encrypt_contiguous_blocks(ctx, data, length,
699
- out, AES_BLOCK_LEN, aes_encrypt_block, aes_copy_block,
700
- aes_xor_block);
701
- }
702
- ...
703
- }
704
- ```
705
-
706
- # Example 11
707
-
708
- ## Callsite
709
-
710
- */home/yuanting/work/icall-benchmarks/llm/zfs-build/../zfs-2.2.2/module/icp/algs/modes/ccm.c:232:3*
711
-
712
- fnptr: *xor_block*
713
-
714
- targets: aes_xor_block
715
-
716
- ## Related Code Snippets
717
-
718
- ```c
719
- int ccm_encrypt_final(ccm_ctx_t *ctx, crypto_data_t *out, size_t block_size,
720
- int (*encrypt_block)(const void *, const uint8_t *, uint8_t *),
721
- void (*xor_block)(uint8_t *, uint8_t *))
722
- {
723
- ...
724
-
725
- if (ctx->ccm_remainder_len > 0) {
726
-
727
- ...
728
-
729
- /* calculate the CBC MAC */
730
- xor_block(macp, mac_buf);
731
- encrypt_block(ctx->ccm_keysched, mac_buf, mac_buf);
732
-
733
- /* calculate the counter mode */
734
- lastp = (uint8_t *)ctx->ccm_tmp;
735
- encrypt_block(ctx->ccm_keysched, (uint8_t *)ctx->ccm_cb, lastp);
736
-
737
- /* XOR with counter block */
738
- for (i = 0; i < ctx->ccm_remainder_len; i++) {
739
- macp[i] ^= lastp[i];
740
- }
741
- ctx->ccm_processed_data_len += ctx->ccm_remainder_len;
742
- }
743
- }
744
- ```
745
-
746
- ```c
747
- static int
748
- aes_encrypt_atomic(crypto_mechanism_t *mechanism,
749
- crypto_key_t *key, crypto_data_t *plaintext, crypto_data_t *ciphertext,
750
- crypto_spi_ctx_template_t template)
751
- {
752
- ...
753
-
754
- if (ret == CRYPTO_SUCCESS) {
755
- if (mechanism->cm_type == AES_CCM_MECH_INFO_TYPE) {
756
- ret = ccm_encrypt_final((ccm_ctx_t *)&aes_ctx,
757
- ciphertext, AES_BLOCK_LEN, aes_encrypt_block,
758
- aes_xor_block);
759
- }
760
- }
761
- ...
762
- }
763
- ```
764
-
765
- ```c
766
- static int
767
- aes_encrypt_final(crypto_ctx_t *ctx, crypto_data_t *data)
768
- {
769
- aes_ctx_t *aes_ctx;
770
- ...
771
-
772
- if (aes_ctx->ac_flags & CTR_MODE) {
773
- ...
774
- } else if (aes_ctx->ac_flags & CCM_MODE) {
775
- ret = ccm_encrypt_final((ccm_ctx_t *)aes_ctx, data,
776
- AES_BLOCK_LEN, aes_encrypt_block, aes_xor_block);
777
- }
778
- }
779
- ```
780
-
781
- ```c
782
- static int
783
- aes_encrypt(crypto_ctx_t *ctx, crypto_data_t *plaintext,
784
- crypto_data_t *ciphertext)
785
- {
786
- ...
787
- if (aes_ctx->ac_flags & CCM_MODE) {
788
- /*
789
- * ccm_encrypt_final() will compute the MAC and append
790
- * it to existing ciphertext. So, need to adjust the left over
791
- * length value accordingly
792
- */
793
-
794
- /* order of following 2 lines MUST not be reversed */
795
- ciphertext->cd_offset = ciphertext->cd_length;
796
- ciphertext->cd_length = saved_length - ciphertext->cd_length;
797
- ret = ccm_encrypt_final((ccm_ctx_t *)aes_ctx, ciphertext,
798
- AES_BLOCK_LEN, aes_encrypt_block, aes_xor_block);
799
- if (ret != CRYPTO_SUCCESS) {
800
- return (ret);
801
- }
802
- }
803
- }
804
- ```
805
-
806
- # Example 12
807
-
808
- ## Callsite
809
-
810
- */home/yuanting/work/icall-benchmarks/llm/curl-build/lib/../../curl-8.5.0/lib/vauth/digest.c:789:3*
811
-
812
- fnptr: *hash*
813
-
814
- targets: Curl_md5it, Curl_sha256it
815
-
816
- ## Related Code Snippets
817
-
818
- ```c
819
- static CURLcode auth_create_digest_http_message(
820
- struct Curl_easy *data,
821
- const char *userp,
822
- const char *passwdp,
823
- const unsigned char *request,
824
- const unsigned char *uripath,
825
- struct digestdata *digest,
826
- char **outptr, size_t *outlen,
827
- void (*convert_to_ascii)(unsigned char *, unsigned char *),
828
- CURLcode (*hash)(unsigned char *, const unsigned char *,
829
- const size_t))
830
- {
831
- ...
832
- if(!hashthis)
833
- return CURLE_OUT_OF_MEMORY;
834
-
835
- hash(hashbuf, (unsigned char *) hashthis, strlen(hashthis));
836
- ...
837
- }
838
- ```
839
-
840
- ```c
841
- CURLcode Curl_auth_create_digest_http_message(struct Curl_easy *data,
842
- const char *userp,
843
- const char *passwdp,
844
- const unsigned char *request,
845
- const unsigned char *uripath,
846
- struct digestdata *digest,
847
- char **outptr, size_t *outlen)
848
- {
849
- if(digest->algo <= ALGO_MD5SESS)
850
- return auth_create_digest_http_message(data, userp, passwdp,
851
- request, uripath, digest,
852
- outptr, outlen,
853
- auth_digest_md5_to_ascii,
854
- Curl_md5it);
855
- DEBUGASSERT(digest->algo <= ALGO_SHA512_256SESS);
856
- return auth_create_digest_http_message(data, userp, passwdp,
857
- request, uripath, digest,
858
- outptr, outlen,
859
- auth_digest_sha256_to_ascii,
860
- Curl_sha256it);
861
- }
862
- ```
863
-
864
- # Example 13
865
-
866
- ## Callsite
867
-
868
- */home/yuanting/work/icall-benchmarks/llm/gcc-clang-build/gcc/../../gcc-13.2.0/gcc/gimple-fold.cc:7670:17*
869
-
870
- fnptr: *valueize*
871
-
872
- targets: pta_valueize, threadedge_valueize, vn_valueize, dom_valueize, valueize_val, valueize_op, do_valueize
873
-
874
- ## Related Code Snippets
875
-
876
- ```c
877
- tree
878
- gimple_fold_stmt_to_constant_1 (gimple *stmt, tree (*valueize) (tree),
879
- tree (*gvalueize) (tree))
880
- {
881
- gimple_match_op res_op;
882
- ...
883
- if (gimple_call_internal_p (stmt))
884
- {
885
- tree arg0 = gimple_call_arg (stmt, 0);
886
- tree arg1 = gimple_call_arg (stmt, 1);
887
- tree op0 = (*valueize) (arg0);
888
- tree op1 = (*valueize) (arg1);
889
- }
890
- ...
891
- }
892
- ```
893
-
894
- ```c
895
- tree
896
- gimple_fold_stmt_to_constant (gimple *stmt, tree (*valueize) (tree))
897
- {
898
- tree res = gimple_fold_stmt_to_constant_1 (stmt, valueize);
899
- if (res && is_gimple_min_invariant (res))
900
- return res;
901
- return NULL_TREE;
902
- }
903
- ```
904
-
905
- ```c
906
- static unsigned int
907
- object_sizes_execute (function *fun, bool early)
908
- {
909
- basic_block bb;
910
- ...
911
-
912
- result = gimple_fold_stmt_to_constant (call, do_valueize);
913
- ...
914
- }
915
- ```
916
-
917
- ```c
918
- static tree
919
- ccp_fold (gimple *stmt)
920
- {
921
- switch (gimple_code (stmt))
922
- {
923
- case GIMPLE_SWITCH:
924
- {
925
- /* Return the constant switch index. */
926
- return valueize_op (gimple_switch_index (as_a <gswitch *> (stmt)));
927
- }
928
-
929
- case GIMPLE_COND:
930
- case GIMPLE_ASSIGN:
931
- case GIMPLE_CALL:
932
- return gimple_fold_stmt_to_constant_1 (stmt,
933
- valueize_op, valueize_op_1);
934
-
935
- default:
936
- gcc_unreachable ();
937
- }
938
- }
939
- ```
940
-
941
- ```c
942
- static enum ssa_prop_result
943
- copy_prop_visit_assignment (gimple *stmt, tree *result_p)
944
- {
945
- tree lhs = gimple_assign_lhs (stmt);
946
- tree rhs = gimple_fold_stmt_to_constant_1 (stmt, valueize_val);
947
- if (rhs
948
- && (TREE_CODE (rhs) == SSA_NAME
949
- || is_gimple_min_invariant (rhs)))
950
- {
951
- if (!may_propagate_copy (lhs, rhs))
952
- rhs = lhs;
953
- }
954
- else
955
- rhs = lhs;
956
- }
957
- ```
958
-
959
- ```c
960
- static void
961
- back_propagate_equivalences (tree lhs, edge e,
962
- class const_and_copies *const_and_copies,
963
- bitmap domby)
964
- {
965
- ...
966
-
967
- tree res = gimple_fold_stmt_to_constant_1 (use_stmt, dom_valueize,
968
- no_follow_ssa_edges);
969
- if (res && (TREE_CODE (res) == SSA_NAME || is_gimple_min_invariant (res)))
970
- record_equality (lhs2, res, const_and_copies);
971
- ...
972
- }
973
- ```
974
-
975
- ```c
976
- static tree
977
- try_to_simplify (gassign *stmt)
978
- {
979
- enum tree_code code = gimple_assign_rhs_code (stmt);
980
- tree tem;
981
-
982
- /* For stores we can end up simplifying a SSA_NAME rhs. Just return
983
- in this case, there is no point in doing extra work. */
984
- if (code == SSA_NAME)
985
- return NULL_TREE;
986
-
987
- /* First try constant folding based on our current lattice. */
988
- mprts_hook = vn_lookup_simplify_result;
989
- tem = gimple_fold_stmt_to_constant_1 (stmt, vn_valueize, vn_valueize);
990
- mprts_hook = NULL;
991
- if (tem
992
- && (TREE_CODE (tem) == SSA_NAME
993
- || is_gimple_min_invariant (tem)))
994
- return tem;
995
-
996
- return NULL_TREE;
997
- }
998
- ```
999
-
1000
- ```c
1001
- static bool
1002
- visit_stmt (gimple *stmt, bool backedges_varying_p = false)
1003
- {
1004
- bool changed = false;
1005
- ...
1006
- tree simplified = gimple_fold_stmt_to_constant_1 (call_stmt,
1007
- vn_valueize);
1008
- if (simplified)
1009
- {
1010
- if (dump_file && (dump_flags & TDF_DETAILS))
1011
- {
1012
- fprintf (dump_file, "call ");
1013
- print_gimple_expr (dump_file, call_stmt, 0);
1014
- fprintf (dump_file, " simplified to ");
1015
- print_generic_expr (dump_file, simplified);
1016
- fprintf (dump_file, "\n");
1017
- }
1018
- }
1019
- ...
1020
- }
1021
- ```
1022
-
1023
- ```c
1024
- void
1025
- jt_state::register_equivs_stmt (gimple *stmt, basic_block bb,
1026
- jt_simplifier *simplifier)
1027
- {
1028
- tree cached_lhs = NULL;
1029
- ...
1030
- if (gimple_assign_single_p (stmt)
1031
- && TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME)
1032
- cached_lhs = gimple_assign_rhs1 (stmt);
1033
- else
1034
- {
1035
- ...
1036
- cached_lhs = gimple_fold_stmt_to_constant_1 (stmt, threadedge_valueize);
1037
- }
1038
- ...
1039
- }
1040
- ```
1041
-
1042
- ```c
1043
- void
1044
- pointer_equiv_analyzer::visit_stmt (gimple *stmt)
1045
- {
1046
- if (gimple_code (stmt) != GIMPLE_ASSIGN)
1047
- return;
1048
-
1049
- tree lhs = gimple_assign_lhs (stmt);
1050
- if (!supported_pointer_equiv_p (lhs))
1051
- return;
1052
-
1053
- tree rhs = gimple_assign_rhs1 (stmt);
1054
- rhs = get_equiv_expr (gimple_assign_rhs_code (stmt), rhs);
1055
- if (rhs)
1056
- {
1057
- set_global_equiv (lhs, rhs);
1058
- return;
1059
- }
1060
-
1061
- // If we couldn't find anything, try fold.
1062
- x_fold_context = { stmt, m_ranger, this};
1063
- rhs = gimple_fold_stmt_to_constant_1 (stmt, pta_valueize, pta_valueize);
1064
- if (rhs)
1065
- {
1066
- rhs = get_equiv_expr (TREE_CODE (rhs), rhs);
1067
- if (rhs)
1068
- {
1069
- set_global_equiv (lhs, rhs);
1070
- return;
1071
- }
1072
- }
1073
- }
1074
- ```
1075
-
1076
- # Example 14
1077
-
1078
- ## Callsite
1079
-
1080
- */home/yuanting/work/icall-benchmarks/llm/gcc-clang-build/gcc/./gtype-lto.h:1256:13*
1081
-
1082
- fnptr: *op*
1083
-
1084
- targets: relocate_ptrs
1085
-
1086
- ## Related Code Snippets
1087
-
1088
- ```c
1089
- void
1090
- gt_pch_p_14lang_tree_node (ATTRIBUTE_UNUSED void *this_obj,
1091
- void *x_p,
1092
- ATTRIBUTE_UNUSED gt_pointer_operator op,
1093
- ATTRIBUTE_UNUSED void *cookie)
1094
- {
1095
- union lang_tree_node * x ATTRIBUTE_UNUSED = (union lang_tree_node *)x_p;
1096
- switch ((int) (lto_tree_node_structure (&((*x)))))
1097
- {
1098
- case TS_LTO_GENERIC:
1099
- switch ((int) (tree_node_structure (&((*x).generic))))
1100
- {
1101
- case TS_BASE:
1102
- break;
1103
- case TS_TYPED:
1104
- if ((void *)(x) == this_obj)
1105
- op (&((*x).generic.typed.type), NULL, cookie);
1106
- break;
1107
- }
1108
- }
1109
- }
1110
- ```
1111
-
1112
- ```c
1113
- void
1114
- gt_pch_nx_lang_tree_node (void *x_p)
1115
- {
1116
- union lang_tree_node * x = (union lang_tree_node *)x_p;
1117
- union lang_tree_node * xlimit = x;
1118
- while (gt_pch_note_object (xlimit, xlimit, gt_pch_p_14lang_tree_node))
1119
- xlimit = (CODE_CONTAINS_STRUCT (TREE_CODE (&(*xlimit).generic), TS_TYPE_COMMON) ? ((union lang_tree_node *) (*xlimit).generic.type_common.next_variant) : CODE_CONTAINS_STRUCT (TREE_CODE (&(*xlimit).generic), TS_COMMON) ? ((union lang_tree_node *) (*xlimit).generic.common.chain) : NULL);
1120
- }
1121
- ```
1122
-
1123
- ```c
1124
- int
1125
- gt_pch_note_object (void *obj, void *note_ptr_cookie,
1126
- gt_note_pointers note_ptr_fn,
1127
- size_t length_override)
1128
- {
1129
- struct ptr_data **slot;
1130
-
1131
- if (obj == NULL || obj == (void *) 1)
1132
- return 0;
1133
-
1134
- slot = (struct ptr_data **)
1135
- saving_htab->find_slot_with_hash (obj, POINTER_HASH (obj), INSERT);
1136
- if (*slot != NULL)
1137
- {
1138
- gcc_assert ((*slot)->note_ptr_fn == note_ptr_fn
1139
- && (*slot)->note_ptr_cookie == note_ptr_cookie);
1140
- return 0;
1141
- }
1142
-
1143
- *slot = XCNEW (struct ptr_data);
1144
- (*slot)->obj = obj;
1145
- (*slot)->note_ptr_fn = note_ptr_fn;
1146
- (*slot)->note_ptr_cookie = note_ptr_cookie;
1147
- if (length_override != (size_t)-1)
1148
- (*slot)->size = length_override;
1149
- else if (note_ptr_fn == gt_pch_p_S)
1150
- (*slot)->size = strlen ((const char *)obj) + 1;
1151
- else
1152
- (*slot)->size = ggc_get_size (obj);
1153
- return 1;
1154
- }
1155
- ```
1156
-
1157
- ```c
1158
- void
1159
- gt_pch_save (FILE *f)
1160
- {
1161
- state.ptrs[i]->note_ptr_fn (state.ptrs[i]->obj,
1162
- state.ptrs[i]->note_ptr_cookie,
1163
- relocate_ptrs, &state);
1164
- }
1165
- ```
1166
-
1167
- ```c
1168
- static void
1169
- relocate_ptrs (void *ptr_p, void *real_ptr_p, void *state_p)
1170
- {
1171
- void **ptr = (void **)ptr_p;
1172
- struct traversal_state *state
1173
- = (struct traversal_state *)state_p;
1174
- struct ptr_data *result;
1175
-
1176
- if (*ptr == NULL || *ptr == (void *)1)
1177
- return;
1178
-
1179
- result = (struct ptr_data *)
1180
- saving_htab->find_with_hash (*ptr, POINTER_HASH (*ptr));
1181
- gcc_assert (result);
1182
- *ptr = result->new_addr;
1183
- if (ptr_p == real_ptr_p)
1184
- return;
1185
- if (real_ptr_p == NULL)
1186
- real_ptr_p = ptr_p;
1187
- gcc_assert (real_ptr_p >= state->ptrs[state->ptrs_i]->obj
1188
- && ((char *) real_ptr_p + sizeof (void *)
1189
- <= ((char *) state->ptrs[state->ptrs_i]->obj
1190
- + state->ptrs[state->ptrs_i]->size)));
1191
- void *addr
1192
- = (void *) ((char *) state->ptrs[state->ptrs_i]->new_addr
1193
- + ((char *) real_ptr_p
1194
- - (char *) state->ptrs[state->ptrs_i]->obj));
1195
- reloc_addrs_vec.safe_push (addr);
1196
- }
1197
- ```
1198
-
1199
- # Example 15
1200
-
1201
- ## Callsite
1202
-
1203
- */home/yuanting/work/icall-benchmarks/llm/openssh-build/../openssh-9.6p1/atomicio.c:71:23*
1204
-
1205
- fnptr: *cb*
1206
-
1207
- targets: scpio, sftpio
1208
-
1209
- ## Related Code Snippets
1210
-
1211
- ```c
1212
- size_t
1213
- atomicio6(ssize_t (*f) (int, void *, size_t), int fd, void *_s, size_t n,
1214
- int (*cb)(void *, size_t), void *cb_arg)
1215
- {
1216
- char *s = _s;
1217
- size_t pos = 0;
1218
- ssize_t res;
1219
- struct pollfd pfd;
1220
-
1221
- pfd.fd = fd;
1222
- #ifndef BROKEN_READ_COMPARISON
1223
- pfd.events = f == read ? POLLIN : POLLOUT;
1224
- #else
1225
- pfd.events = POLLIN|POLLOUT;
1226
- #endif
1227
- while (n > pos) {
1228
- res = (f) (fd, s + pos, n - pos);
1229
- switch (res) {
1230
- case -1:
1231
- if (errno == EINTR) {
1232
- /* possible SIGALARM, update callback */
1233
- if (cb != NULL && cb(cb_arg, 0) == -1) {
1234
- errno = EINTR;
1235
- return pos;
1236
- }
1237
- continue;
1238
- } else if (errno == EAGAIN || errno == EWOULDBLOCK) {
1239
- (void)poll(&pfd, 1, -1);
1240
- continue;
1241
- }
1242
- return 0;
1243
- case 0:
1244
- errno = EPIPE;
1245
- return pos;
1246
- default:
1247
- pos += (size_t)res;
1248
- if (cb != NULL && cb(cb_arg, (size_t)res) == -1) {
1249
- errno = EINTR;
1250
- return pos;
1251
- }
1252
- }
1253
- }
1254
- return pos;
1255
- }
1256
- ```
1257
-
1258
- ```c
1259
- void
1260
- source(int argc, char **argv)
1261
- {
1262
- if (atomicio6(vwrite, remout, bp->buf, amt, scpio,
1263
- &statbytes) != amt)
1264
- haderr = errno;
1265
- }
1266
- ```
1267
-
1268
- ```c
1269
- static int
1270
- scpio(void *_cnt, size_t s)
1271
- {
1272
- off_t *cnt = (off_t *)_cnt;
1273
-
1274
- *cnt += s;
1275
- refresh_progress_meter(0);
1276
- if (limit_kbps > 0)
1277
- bandwidth_limit(&bwlimit, s);
1278
- return 0;
1279
- }
1280
- ```
1281
-
1282
- ```c
1283
- static void
1284
- get_msg_extended(struct sftp_conn *conn, struct sshbuf *m, int initial)
1285
- {
1286
- u_int msg_len;
1287
- u_char *p;
1288
- int r;
1289
-
1290
- sshbuf_reset(m);
1291
- if ((r = sshbuf_reserve(m, 4, &p)) != 0)
1292
- fatal_fr(r, "reserve");
1293
- if (atomicio6(read, conn->fd_in, p, 4, sftpio,
1294
- conn->limit_kbps > 0 ? &conn->bwlimit_in : NULL) != 4) {
1295
- if (errno == EPIPE || errno == ECONNRESET)
1296
- fatal("Connection closed");
1297
- else
1298
- fatal("Couldn't read packet: %s", strerror(errno));
1299
- }
1300
-
1301
- if ((r = sshbuf_get_u32(m, &msg_len)) != 0)
1302
- fatal_fr(r, "sshbuf_get_u32");
1303
- if (msg_len > SFTP_MAX_MSG_LENGTH) {
1304
- do_log2(initial ? SYSLOG_LEVEL_ERROR : SYSLOG_LEVEL_FATAL,
1305
- "Received message too long %u", msg_len);
1306
- fatal("Ensure the remote shell produces no output "
1307
- "for non-interactive sessions.");
1308
- }
1309
-
1310
- if ((r = sshbuf_reserve(m, msg_len, &p)) != 0)
1311
- fatal_fr(r, "reserve");
1312
- if (atomicio6(read, conn->fd_in, p, msg_len, sftpio,
1313
- conn->limit_kbps > 0 ? &conn->bwlimit_in : NULL)
1314
- != msg_len) {
1315
- if (errno == EPIPE)
1316
- fatal("Connection closed");
1317
- else
1318
- fatal("Read packet: %s", strerror(errno));
1319
- }
1320
- }
1321
- ```
1322
-
1323
- ```c
1324
- static int
1325
- sftpio(void *_bwlimit, size_t amount)
1326
- {
1327
- struct bwlimit *bwlimit = (struct bwlimit *)_bwlimit;
1328
-
1329
- refresh_progress_meter(0);
1330
- if (bwlimit != NULL)
1331
- bandwidth_limit(bwlimit, amount);
1332
- return 0;
1333
- }
1334
- ```