Skip to content

Move send code from headers to their own compilation units#793

Merged
zakird merged 2 commits intozmap:mainfrom
droe:droe/refactor-send
Feb 25, 2024
Merged

Move send code from headers to their own compilation units#793
zakird merged 2 commits intozmap:mainfrom
droe:droe/refactor-send

Conversation

@droe
Copy link
Contributor

@droe droe commented Feb 24, 2024

Changes

  • Move BSD and netmap send code from headers to separate compilation units, like Linux already has.
  • Remove static inline declarations of send interface from send.c and move as regular declarations into send-internal.h (like recv-internal.h).
  • No longer declare send_packet.

Motivation

  • Allows cleanly calling into OS-specific send functions from other compilation units than send.c (which was my primary motivation, as this is blocking droe/netmap-wait-ping).
  • Prevent OS-specific headers from unnecessarily leaking into generic compilation units.
  • Getting rid of compiler warnings related to send_packet.

Notes

Testing

Smoke-tested on:

  • macOS Sonoma
  • FreeBSD 14.0 with WITH_NETMAP=OFF and WITH_NETMAP=ON (with and without droe/netmap-wait-ping on top of this change)
  • Ubuntu 23.10 with WITH_NETMAP=OFF and WITH_NETMAP=ON (the latter with droe/netmap-linux on top of this change)

droe added 2 commits February 24, 2024 21:45
- Move BSD and netmap send code from headers to separate compilation
  units, like Linux.
- Remove static inline declarations of send interface from send.c and
  move as regular declarations into `send-internal.h` (like
  `recv-internal.h`).
- Minimal cleanups to make it all work.

Except for better code structure, there are two main benefits:

- Prevent OS-specific headers to leak into generic compilation units,
  creating footguns for developers working on other OSes.
- It will now be possible to cleanly call into OS-specific send
  functions from other compilation units than `send.c` (which was my
  primary motivation for this work, as this is blocking further netmap
  improvements).
@zakird zakird merged commit 4ec0258 into zmap:main Feb 25, 2024
@droe droe deleted the droe/refactor-send branch March 11, 2024 08:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants