Skip to content

Commit

Permalink
Reduce headers processed through C2Rust to minimum
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysn committed Jan 7, 2025
1 parent eaa84f9 commit 88febad
Show file tree
Hide file tree
Showing 4 changed files with 256 additions and 246 deletions.
157 changes: 156 additions & 1 deletion riot-bindgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,159 @@
#define UINT16_MAX 0xffff
#define UINT32_MAX 0xffffffff

#include "riot-headers.h"

/* core libraries */
#include <irq.h>
#ifdef MODULE_CORE_MSG
#include <msg.h>
#endif
#include <mutex.h>
#include <panic.h>
#ifdef MODULE_CORE_THREAD_FLAGS
#include <thread_flags.h>
#endif
#include <thread.h>

/* board include */
#include <board.h>

#include "riot-periph.h"

/* sys libraries */
#ifdef MODULE_BLUETIL_AD
#include <net/bluetil/ad.h>
#endif
#ifdef MODULE_CORD_COMMON
#include <net/cord/common.h>
#endif
#ifdef MODULE_CORD_EP
#include <net/cord/ep.h>
#endif
#ifdef MODULE_CORD_EP_STANDALONE
#include <net/cord/ep_standalone.h>
#endif
#ifdef MODULE_CORD_EPSIM
#include <net/cord/epsim.h>
#endif
#ifdef MODULE_GCOAP
#include <net/gcoap.h>
#endif
#include <net/gnrc.h>
#include <net/gnrc/udp.h>
#include <net/gnrc/pktbuf.h>
#include <net/gnrc/ipv6.h>
#include <net/gnrc/nettype.h>
#include <net/gnrc/netapi.h>
#ifdef MODULE_GNRC_ICMPV6
#include "net/gnrc/icmpv6.h"
#endif
#ifdef MODULE_HASHES
#include <hashes.h>
#include <hashes/aes128_cmac.h>
#include <hashes/md5.h>
#include <hashes/pbkdf2.h>
#include <hashes/sha1.h>
#include <hashes/sha224.h>
#include <hashes/sha256.h>
#include <hashes/sha3.h>
#include <hashes/sha512.h>
#endif
#ifdef MODULE_NANOCOAP
#include <net/nanocoap.h>
#endif
#ifdef MODULE_NANOCOAP_SOCK
#include <net/nanocoap_sock.h>
#endif
#ifdef MODULE_RANDOM
#include <random.h>
#endif
#ifdef MODULE_SOCK
#include <net/sock.h>
#endif
#ifdef MODULE_SOCK_UDP
#include <net/sock/udp.h>
#endif
#ifdef MODULE_SOCK_ASYNC
#include <net/sock/async.h>
#endif
#include <saul.h>
#include <saul_reg.h>
#include <stdio_base.h>
#ifdef MODULE_SHELL
#include <shell.h>
#endif
#ifdef MODULE_SOCK_UTIL
#include <net/sock/util.h>
#endif
#ifdef MODULE_PTHREAD
#include <pthread.h>
#endif
#ifdef MODULE_SUIT
#include "suit.h"
#include "suit/conditions.h"
#include "suit/transport/worker.h"
#endif
#ifdef MODULE_SUIT_TRANSPORT_COAP
#include "suit/transport/coap.h"
#endif
#ifdef MODULE_RIOTBOOT_SLOT
#include "riotboot/slot.h"
#endif
#ifdef MODULE_TINY_STRERROR
#include "tiny_strerror.h"
#endif
#ifdef MODULE_UUID
#include "uuid.h"
#endif
#ifdef MODULE_XTIMER
// Uses C11 generics since https://github.com/RIOT-OS/RIOT/pull/20494
#include <xtimer.h>
#endif
#ifdef MODULE_ZTIMER
#include <ztimer.h>
#endif
#ifdef MODULE_ZTIMER64
#include <ztimer64.h>
#endif
#ifdef MODULE_ZTIMER_PERIODIC
#include <ztimer/periodic.h>
#endif
#ifdef MODULE_VFS
// Actually using VFS needs constants like O_RDONLY
#include <fcntl.h>
#include <vfs.h>
#endif
#ifdef MODULE_AUTO_INIT
#include "auto_init_utils.h"
#endif

/* packages */
#ifdef MODULE_NIMBLE_AUTOADV
# include "nimble_autoadv.h"
# include "nimble_autoadv_params.h"
#endif
#ifdef MODULE_NIMBLE_HOST
# include "host/ble_gatt.h"
# include "host/ble_gap.h"
# include "host/ble_hs_adv.h"
#endif
#ifdef MODULE_NIMBLE_SVC_GAP
#include "services/gap/ble_svc_gap.h"
#endif

/* drivers */
#ifdef MODULE_MICROBIT
#include "microbit.h"
#endif
#ifdef MODULE_WS281X
#include "ws281x_params.h"
#include "ws281x.h"
#endif

/* wolfSSL */
#if defined(MODULE_WOLFSSL)
#include <wolfssl/wolfcrypt/settings.h>
#include <wolfssl/wolfcrypt/sha256.h>
#include <wolfssl/ssl.h>
#include <sock_tls.h>
#endif
35 changes: 31 additions & 4 deletions riot-c2rust.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,35 @@ static inline void __masked_builtin_arm_set_fpscr(int fpscr){
#undef atomic_intmax_t
#undef atomic_uintmax_t

// Allow header files that pull in lots of odd stuff but don't depend on
// inlines -- like nimble's host/ble_gap.h -- to opt out of C2Rust altogether
#define IS_C2RUST
/* core libraries */
/* for mutex_MUTEX_INIT */
#include <mutex.h>

#include "riot-headers.h"
/* board include */
#include <board.h>

/* All peripherals are also built through C2Rust because the macro_SPI_DEV etc need them */
#include "riot-periph.h"

/* sys libraries */
#ifdef MODULE_BLUETIL_AD
#include <net/bluetil/ad.h>
#endif
#include <net/gnrc/netif.h>
#include <net/gnrc/ipv6.h>
#ifdef MODULE_NANOCOAP
#include <net/nanocoap.h>
#endif
#ifdef MODULE_SHELL
#include <shell.h>
#endif
#ifdef MODULE_SOCK
#include <net/sock.h>
#endif
#ifdef MODULE_ZTIMER
#include <ztimer.h>
#endif

/* This defines the fallback macros in the LED macros' absence from board.h;
* needed for macro_LED<nonexistent>_TOGGLE etc */
#include <led.h>
Loading

0 comments on commit 88febad

Please sign in to comment.