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>
This commit is contained in:
committed by
Daniel D’Aquino
parent
201cdd7edc
commit
a8d7d971b1
1
nostrdb/ccan/ccan/endian/LICENSE
Symbolic link
1
nostrdb/ccan/ccan/endian/LICENSE
Symbolic link
@@ -0,0 +1 @@
|
||||
../../licenses/CC0
|
||||
55
nostrdb/ccan/ccan/endian/_info
Normal file
55
nostrdb/ccan/ccan/endian/_info
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "config.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/**
|
||||
* endian - endian conversion macros for simple types
|
||||
*
|
||||
* Portable protocols (such as on-disk formats, or network protocols)
|
||||
* are often defined to be a particular endian: little-endian (least
|
||||
* significant bytes first) or big-endian (most significant bytes
|
||||
* first).
|
||||
*
|
||||
* Similarly, some CPUs lay out values in memory in little-endian
|
||||
* order (most commonly, Intel's 8086 and derivatives), or big-endian
|
||||
* order (almost everyone else).
|
||||
*
|
||||
* This module provides conversion routines, inspired by the linux kernel.
|
||||
* It also provides leint32_t, beint32_t etc typedefs, which are annotated for
|
||||
* the sparse checker.
|
||||
*
|
||||
* Example:
|
||||
* #include <stdio.h>
|
||||
* #include <err.h>
|
||||
* #include <ccan/endian/endian.h>
|
||||
*
|
||||
* //
|
||||
* int main(int argc, char *argv[])
|
||||
* {
|
||||
* uint32_t value;
|
||||
*
|
||||
* if (argc != 2)
|
||||
* errx(1, "Usage: %s <value>", argv[0]);
|
||||
*
|
||||
* value = atoi(argv[1]);
|
||||
* printf("native: %08x\n", value);
|
||||
* printf("little-endian: %08x\n", cpu_to_le32(value));
|
||||
* printf("big-endian: %08x\n", cpu_to_be32(value));
|
||||
* printf("byte-reversed: %08x\n", bswap_32(value));
|
||||
* exit(0);
|
||||
* }
|
||||
*
|
||||
* License: License: CC0 (Public domain)
|
||||
* Author: Rusty Russell <rusty@rustcorp.com.au>
|
||||
*/
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
if (argc != 2)
|
||||
return 1;
|
||||
|
||||
if (strcmp(argv[1], "depends") == 0)
|
||||
/* Nothing */
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
/* CC0 (Public domain) */
|
||||
/* CC0 (Public domain) - see LICENSE file for details */
|
||||
#ifndef CCAN_ENDIAN_H
|
||||
#define CCAN_ENDIAN_H
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "cursor.h"
|
||||
|
||||
/**
|
||||
* BSWAP_16 - reverse bytes in a constant uint16_t value.
|
||||
@@ -346,6 +344,8 @@ static inline uint16_t be16_to_cpu(beint16_t be_val)
|
||||
return BE16_TO_CPU(be_val);
|
||||
}
|
||||
|
||||
/* Whichever they include first, they get these definitions. */
|
||||
#ifdef CCAN_SHORT_TYPES_H
|
||||
/**
|
||||
* be64/be32/be16 - 64/32/16 bit big-endian representation.
|
||||
*/
|
||||
@@ -359,7 +359,5 @@ typedef beint16_t be16;
|
||||
typedef leint64_t le64;
|
||||
typedef leint32_t le32;
|
||||
typedef leint16_t le16;
|
||||
|
||||
|
||||
#endif
|
||||
#endif /* CCAN_ENDIAN_H */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user