tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

macros.h (2408B)


      1 /*
      2 * This file is part of FFmpeg.
      3 *
      4 * FFmpeg is free software; you can redistribute it and/or
      5 * modify it under the terms of the GNU Lesser General Public
      6 * License as published by the Free Software Foundation; either
      7 * version 2.1 of the License, or (at your option) any later version.
      8 *
      9 * FFmpeg is distributed in the hope that it will be useful,
     10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     12 * Lesser General Public License for more details.
     13 *
     14 * You should have received a copy of the GNU Lesser General Public
     15 * License along with FFmpeg; if not, write to the Free Software
     16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
     17 */
     18 
     19 /**
     20 * @file
     21 * @ingroup lavu
     22 * Utility Preprocessor macros
     23 */
     24 
     25 #ifndef AVUTIL_MACROS_H
     26 #define AVUTIL_MACROS_H
     27 
     28 #include "libavutil/avconfig.h"
     29 
     30 #if AV_HAVE_BIGENDIAN
     31 #  define AV_NE(be, le) (be)
     32 #else
     33 #  define AV_NE(be, le) (le)
     34 #endif
     35 
     36 /**
     37 * Comparator.
     38 * For two numerical expressions x and y, gives 1 if x > y, -1 if x < y, and 0
     39 * if x == y. This is useful for instance in a qsort comparator callback.
     40 * Furthermore, compilers are able to optimize this to branchless code, and
     41 * there is no risk of overflow with signed types.
     42 * As with many macros, this evaluates its argument multiple times, it thus
     43 * must not have a side-effect.
     44 */
     45 #define FFDIFFSIGN(x, y) (((x) > (y)) - ((x) < (y)))
     46 
     47 #define FFMAX(a, b) ((a) > (b) ? (a) : (b))
     48 #define FFMAX3(a, b, c) FFMAX(FFMAX(a, b), c)
     49 #define FFMIN(a, b) ((a) > (b) ? (b) : (a))
     50 #define FFMIN3(a, b, c) FFMIN(FFMIN(a, b), c)
     51 
     52 #define FFSWAP(type, a, b) \
     53  do {                     \
     54    type SWAP_tmp = b;     \
     55    b = a;                 \
     56    a = SWAP_tmp;          \
     57  } while (0)
     58 #define FF_ARRAY_ELEMS(a) (sizeof(a) / sizeof((a)[0]))
     59 
     60 #define MKTAG(a, b, c, d) \
     61  ((a) | ((b) << 8) | ((c) << 16) | ((unsigned)(d) << 24))
     62 #define MKBETAG(a, b, c, d) \
     63  ((d) | ((c) << 8) | ((b) << 16) | ((unsigned)(a) << 24))
     64 
     65 /**
     66 * @addtogroup preproc_misc Preprocessor String Macros
     67 *
     68 * String manipulation macros
     69 *
     70 * @{
     71 */
     72 
     73 #define AV_STRINGIFY(s) AV_TOSTRING(s)
     74 #define AV_TOSTRING(s) #s
     75 
     76 #define AV_GLUE(a, b) a##b
     77 #define AV_JOIN(a, b) AV_GLUE(a, b)
     78 
     79 /**
     80 * @}
     81 */
     82 
     83 #define AV_PRAGMA(s) _Pragma(#s)
     84 
     85 #define FFALIGN(x, a) (((x) + (a)-1) & ~((a)-1))
     86 
     87 #endif /* AVUTIL_MACROS_H */