Files
damus/nostrdb/ccan/ccan/likely/_info
Rusty Russell a8d7d971b1 nostrdb: ccan: sync with normal versions.
This is the version of CCAN which CLN was using at the time these
were taken.  Unfortunately lots of whitespace has been changed,
but AFAICT no source changes.

Here's the command I ran (with ../ccan checked out to 1ae4c432):

```
make update-ccan CCAN_NEW="alignof array_size build_assert check_type container_of cppmagic likely list mem short_types str structeq take tal tal/str typesafe_cb utf8 endian crypto/sha256"
```

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: William Casarin <jb55@jb55.com>
2025-08-11 16:40:00 -07:00

58 lines
1.3 KiB
Plaintext

#include "config.h"
#include <string.h>
#include <stdio.h>
/**
* likely - macros for annotating likely/unlikely branches in the code
*
* Inspired by Andi Kleen's macros for the Linux Kernel, these macros
* help you annotate rare paths in your code for the convenience of the
* compiler and the reader.
*
* With CCAN_LIKELY_DEBUG defined, it provides statistics for each
* likely()/unlikely() call (but note that this requires LGPL dependencies).
*
* License: CC0 (Public domain)
* Author: Rusty Russell <rusty@rustcorp.com.au>
*
* Example:
* #include <ccan/likely/likely.h>
* #include <stdio.h>
*
* int main(int argc, char *argv[])
* {
* // This example is silly: the compiler knows exit() is unlikely.
* if (unlikely(argc == 1)) {
* fprintf(stderr, "Usage: %s <args>...\n", argv[0]);
* return 1;
* }
* for (argc++; argv[argc]; argc++)
* printf("%s\n", argv[argc]);
* return 0;
* }
*/
int main(int argc, char *argv[])
{
/* Expect exactly one argument */
if (argc != 2)
return 1;
if (strcmp(argv[1], "depends") == 0) {
#ifdef CCAN_LIKELY_DEBUG
printf("ccan/str\n");
printf("ccan/htable\n");
printf("ccan/hash\n");
#endif
return 0;
}
if (strcmp(argv[1], "testdepends") == 0) {
#ifndef CCAN_LIKELY_DEBUG
printf("ccan/str\n");
printf("ccan/htable\n");
printf("ccan/hash\n");
#endif
return 0;
}
return 1;
}