Files
wuffs/cmd/puffs-gen-c/base-impl.h
T
Nigel Tao 187bde7540 Pull out duplicate short_read_src code.
name                          old speed      new speed       delta
lzw_puffs_decode_20k/clang     127MB/s ± 0%    127MB/s ± 0%  +0.40%  (p=0.008 n=5+5)
lzw_puffs_decode_100k/clang    176MB/s ± 0%    176MB/s ± 0%  +0.23%  (p=0.008 n=5+5)
gif_puffs_decode_1k/clang      380MB/s ± 1%    389MB/s ± 2%  +2.26%  (p=0.008 n=5+5)
gif_puffs_decode_10k/clang     136MB/s ± 0%    137MB/s ± 0%  +0.59%  (p=0.016 n=4+5)
gif_puffs_decode_100k/clang    121MB/s ± 0%    121MB/s ± 0%  +0.33%  (p=0.008 n=5+5)
gif_puffs_decode_1000k/clang   124MB/s ± 0%    124MB/s ± 0%  +0.25%  (p=0.008 n=5+5)
lzw_puffs_decode_20k/gcc       150MB/s ± 1%    151MB/s ± 0%  +0.97%  (p=0.008 n=5+5)
lzw_puffs_decode_100k/gcc      207MB/s ± 0%    197MB/s ± 0%  -4.84%  (p=0.008 n=5+5)
gif_puffs_decode_1k/gcc        413MB/s ± 1%    406MB/s ± 1%  -1.71%  (p=0.008 n=5+5)
gif_puffs_decode_10k/gcc       147MB/s ± 0%    158MB/s ± 0%  +7.15%  (p=0.008 n=5+5)
gif_puffs_decode_100k/gcc      136MB/s ± 0%    138MB/s ± 0%  +1.68%  (p=0.008 n=5+5)
gif_puffs_decode_1000k/gcc     139MB/s ± 0%    142MB/s ± 0%  +2.07%  (p=0.008 n=5+5)
2017-07-02 16:11:51 +10:00

29 lines
917 B
C

// After editing this file, run "go generate" in this directory.
#ifndef PUFFS_BASE_IMPL_H
#define PUFFS_BASE_IMPL_H
// Use of this source code is governed by a BSD-style license that can be found
// in the LICENSE file.
// Use switch cases for coroutine state, similar to the technique in
// https://www.chiark.greenend.org.uk/~sgtatham/coroutines.html
//
// We use a trivial macro instead of an explicit assignment and case statement
// so that clang-format doesn't get confused by the unusual "case"s.
#define PUFFS_COROUTINE_STATE(n) \
coro_state = n; \
case n:
#define PUFFS_LOW_BITS(x, n) ((x) & ((1 << (n)) - 1))
#if defined(__clang__) || defined(__GNUC__)
#define PUFFS_LIKELY(expr) (__builtin_expect((expr), 1))
#define PUFFS_UNLIKELY(expr) (__builtin_expect((expr), 0))
#else
#define PUFFS_LIKELY(expr) (expr)
#define PUFFS_UNLIKELY(expr) (expr)
#endif
#endif // PUFFS_BASE_IMPL_H