~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/lib/zstd/common/zstd_deps.h

Version: ~ [ linux-6.11-rc3 ] ~ [ linux-6.10.4 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.45 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.104 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.164 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.223 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.281 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.319 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0+ OR BSD-3-Clause */
  2 /*
  3  * Copyright (c) Facebook, Inc.
  4  * All rights reserved.
  5  *
  6  * This source code is licensed under both the BSD-style license (found in the
  7  * LICENSE file in the root directory of this source tree) and the GPLv2 (found
  8  * in the COPYING file in the root directory of this source tree).
  9  * You may select, at your option, one of the above-listed licenses.
 10  */
 11 
 12 /*
 13  * This file provides common libc dependencies that zstd requires.
 14  * The purpose is to allow replacing this file with a custom implementation
 15  * to compile zstd without libc support.
 16  */
 17 
 18 /* Need:
 19  * NULL
 20  * INT_MAX
 21  * UINT_MAX
 22  * ZSTD_memcpy()
 23  * ZSTD_memset()
 24  * ZSTD_memmove()
 25  */
 26 #ifndef ZSTD_DEPS_COMMON
 27 #define ZSTD_DEPS_COMMON
 28 
 29 #include <linux/limits.h>
 30 #include <linux/stddef.h>
 31 
 32 #define ZSTD_memcpy(d,s,n) __builtin_memcpy((d),(s),(n))
 33 #define ZSTD_memmove(d,s,n) __builtin_memmove((d),(s),(n))
 34 #define ZSTD_memset(d,s,n) __builtin_memset((d),(s),(n))
 35 
 36 #endif /* ZSTD_DEPS_COMMON */
 37 
 38 /*
 39  * Define malloc as always failing. That means the user must
 40  * either use ZSTD_customMem or statically allocate memory.
 41  * Need:
 42  * ZSTD_malloc()
 43  * ZSTD_free()
 44  * ZSTD_calloc()
 45  */
 46 #ifdef ZSTD_DEPS_NEED_MALLOC
 47 #ifndef ZSTD_DEPS_MALLOC
 48 #define ZSTD_DEPS_MALLOC
 49 
 50 #define ZSTD_malloc(s) ({ (void)(s); NULL; })
 51 #define ZSTD_free(p) ((void)(p))
 52 #define ZSTD_calloc(n,s) ({ (void)(n); (void)(s); NULL; })
 53 
 54 #endif /* ZSTD_DEPS_MALLOC */
 55 #endif /* ZSTD_DEPS_NEED_MALLOC */
 56 
 57 /*
 58  * Provides 64-bit math support.
 59  * Need:
 60  * U64 ZSTD_div64(U64 dividend, U32 divisor)
 61  */
 62 #ifdef ZSTD_DEPS_NEED_MATH64
 63 #ifndef ZSTD_DEPS_MATH64
 64 #define ZSTD_DEPS_MATH64
 65 
 66 #include <linux/math64.h>
 67 
 68 static uint64_t ZSTD_div64(uint64_t dividend, uint32_t divisor) {
 69   return div_u64(dividend, divisor);
 70 }
 71 
 72 #endif /* ZSTD_DEPS_MATH64 */
 73 #endif /* ZSTD_DEPS_NEED_MATH64 */
 74 
 75 /*
 76  * This is only requested when DEBUGLEVEL >= 1, meaning
 77  * it is disabled in production.
 78  * Need:
 79  * assert()
 80  */
 81 #ifdef ZSTD_DEPS_NEED_ASSERT
 82 #ifndef ZSTD_DEPS_ASSERT
 83 #define ZSTD_DEPS_ASSERT
 84 
 85 #include <linux/kernel.h>
 86 
 87 #define assert(x) WARN_ON(!(x))
 88 
 89 #endif /* ZSTD_DEPS_ASSERT */
 90 #endif /* ZSTD_DEPS_NEED_ASSERT */
 91 
 92 /*
 93  * This is only requested when DEBUGLEVEL >= 2, meaning
 94  * it is disabled in production.
 95  * Need:
 96  * ZSTD_DEBUG_PRINT()
 97  */
 98 #ifdef ZSTD_DEPS_NEED_IO
 99 #ifndef ZSTD_DEPS_IO
100 #define ZSTD_DEPS_IO
101 
102 #include <linux/printk.h>
103 
104 #define ZSTD_DEBUG_PRINT(...) pr_debug(__VA_ARGS__)
105 
106 #endif /* ZSTD_DEPS_IO */
107 #endif /* ZSTD_DEPS_NEED_IO */
108 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php