Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Linux/include/asm-generic/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 1 kB image not shown  

Quelle  getorder.h   Sprache: C

 
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef __ASM_GENERIC_GETORDER_H
#define __ASM_GENERIC_GETORDER_H

#ifndef __ASSEMBLY__

#include <linux/compiler.h>
#include <linux/log2.h>

/**
 * get_order - Determine the allocation order of a memory size
 * @size: The size for which to get the order
 *
 * Determine the allocation order of a particular sized block of memory.  This
 * is on a logarithmic scale, where:
 *
 * 0 -> 2^0 * PAGE_SIZE and below
 * 1 -> 2^1 * PAGE_SIZE to 2^0 * PAGE_SIZE + 1
 * 2 -> 2^2 * PAGE_SIZE to 2^1 * PAGE_SIZE + 1
 * 3 -> 2^3 * PAGE_SIZE to 2^2 * PAGE_SIZE + 1
 * 4 -> 2^4 * PAGE_SIZE to 2^3 * PAGE_SIZE + 1
 * ...
 *
 * The order returned is used to find the smallest allocation granule required
 * to hold an object of the specified size.
 *
 * The result is undefined if the size is 0.
 */

static __always_inline __attribute_const__ int get_order(unsigned long size)
{
 if (__builtin_constant_p(size)) {
  if (!size)
   return BITS_PER_LONG - PAGE_SHIFT;

  if (size < (1UL << PAGE_SHIFT))
   return 0;

  return ilog2((size) - 1) - PAGE_SHIFT + 1;
 }

 size--;
 size >>= PAGE_SHIFT;
#if BITS_PER_LONG == 32
 return fls(size);
#else
 return fls64(size);
#endif
}

#endif /* __ASSEMBLY__ */

#endif /* __ASM_GENERIC_GETORDER_H */

Messung V0.5
C=93 H=100 G=96

¤ Dauer der Verarbeitung: 0.20 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.