Endian Swap 32-bit Word
Write a C function that converts a 32-bit word between big-endian and little-endian byte order. Needed whenever a network packet or a foreign-endian peripheral hands you a raw word.
Constraints
- Signature: `uint32_t swap32(uint32_t value)`.
- Pure arithmetic - no pointer casting or type punning.
- Must not depend on the host's native endianness.
- Single expression preferred.
- No library calls.
1#include <stdint.h>2 3uint32_t swap32(uint32_t value) {4 // TODO: reverse byte order5 return 0;6}