Coverage Report

Created: 2020-05-07 18:36

/proc/self/cwd/c/compat.h
Line
Count
Source (jump to first uncovered line)
1
/*
2
Copyright 2020 Google LLC
3
4
Use of this source code is governed by a BSD-style
5
license that can be found in the LICENSE file or at
6
https://developers.google.com/open-source/licenses/bsd
7
*/
8
9
#ifndef COMPAT_H
10
#define COMPAT_H
11
12
#include <stdint.h>
13
14
/* functions that git-core provides, for standalone compilation */
15
16
uint64_t get_be64(uint8_t *in);
17
void put_be64(uint8_t *out, uint64_t i);
18
19
void put_be32(uint8_t *out, uint32_t i);
20
uint32_t get_be32(uint8_t *in);
21
22
uint16_t get_be16(uint8_t *in);
23
24
#define ARRAY_SIZE(a) sizeof((a)) / sizeof((a)[0])
25
#define FREE_AND_NULL(x)          \
26
6.05k
  do {                      \
27
6.05k
    reftable_free(x); \
28
6.05k
    (x) = NULL;       \
29
6.05k
  } while (0)
30
0
#define QSORT(arr, n, cmp) qsort(arr, n, sizeof(arr[0]), cmp)
31
#define SWAP(a, b)                              \
32
2.38k
  {                                       \
33
2.38k
    char tmp[sizeof(a)];            \
34
2.38k
    assert(sizeof(a) == sizeof(b)); \
35
2.38k
    memcpy(&tmp[0], &a, sizeof(a)); \
36
1.19k
    memcpy(&a, &b, sizeof(a));      \
37
1.19k
    memcpy(&b, &tmp[0], sizeof(a)); \
38
1.19k
  }
39
40
char *xstrdup(const char *s);
41
42
void sleep_millisec(int millisecs);
43
44
#endif