File: test_stdint.c

package info (click to toggle)
chibicc 1.0.23.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,832 kB
  • sloc: ansic: 62,911; sh: 275; makefile: 92
file content (21 lines) | stat: -rw-r--r-- 448 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <byteswap.h>
#include <stdint.h>
#include <float.h>
#include <stddef.h>
#include "test.h"

uint16_t swap_bytes(uint16_t x) {
  return (x >> 8) | (x << 8);
}

int main() {
  uint16_t x = 0x1234;
  uint16_t y = swap_bytes(x);
  printf("Original: 0x%x, Swapped: 0x%x\n", x, y);
  ASSERT(0x3412, y);
  __uint16_t a = 0x3456;
  __uint16_t b = swap_bytes(a);
  printf("Original: 0x%x, Swapped: 0x%x\n", a, b);
  ASSERT(0x5634, b);
  return 0;
}