netfilter
firewalling, NAT, and packet mangling for linux
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
utils.h File Reference
#include <asm/byteorder.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdarg.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
#include <list.h>
#include <gmputil.h>
Include dependency graph for utils.h:
This graph shows which files directly or indirectly include this file:

Macros

#define BITS_PER_BYTE   8
 
#define pr_debug(fmt, arg...)   ({ if (false) {}; 0; })
 
#define pr_gmp_debug(fmt, arg...)   ({ if (false) {}; 0; })
 
#define __fmtstring(x, y)   __attribute__((format(printf, x, y)))
 
#define __gmp_fmtstring(x, y)
 
#define __init   __attribute__((constructor))
 
#define __exit   __attribute__((destructor))
 
#define __must_check   __attribute__((warn_unused_result))
 
#define __noreturn   __attribute__((__noreturn__))
 
#define BUG(fmt, arg...)   assert(0)
 
#define BUILD_BUG_ON(condition)   ((void)sizeof(char[1 - 2*!!(condition)]))
 
#define BUILD_BUG_ON_ZERO(e)   (sizeof(char[1 - 2 * !!(e)]) - 1)
 
#define __must_be_array(a)   BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
 
#define container_of(ptr, type, member)
 
#define field_sizeof(t, f)   (sizeof(((t *)NULL)->f))
 Return a pointer to a constant variable of a size smaller than the variable. More...
 
#define array_size(arr)   (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
 
#define div_round_up(n, d)   (((n) + (d) - 1) / (d))
 
#define min(x, y)
 
#define max(x, y)
 
#define memory_allocation_error()   __memory_allocation_error(__FILE__, __LINE__);
 

Functions

void __memory_allocation_error (const char *filename, uint32_t line) __noreturn
 
void xfree (const void *ptr)
 
void * xmalloc (size_t size)
 
void * xrealloc (void *ptr, size_t size)
 
void * xzalloc (size_t size)
 
char * xstrdup (const char *s)
 

Macro Definition Documentation

#define __exit   __attribute__((destructor))
#define __fmtstring (   x,
 
)    __attribute__((format(printf, x, y)))
#define __gmp_fmtstring (   x,
 
)
#define __init   __attribute__((constructor))
#define __must_be_array (   a)    BUILD_BUG_ON_ZERO(__builtin_types_compatible_p(typeof(a), typeof(&a[0])))
#define __must_check   __attribute__((warn_unused_result))
#define __noreturn   __attribute__((__noreturn__))
#define array_size (   arr)    (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))
#define BUG (   fmt,
  arg... 
)    assert(0)
#define BUILD_BUG_ON (   condition)    ((void)sizeof(char[1 - 2*!!(condition)]))

Referenced by datatype_register().

#define BUILD_BUG_ON_ZERO (   e)    (sizeof(char[1 - 2 * !!(e)]) - 1)
#define container_of (   ptr,
  type,
  member 
)
Value:
({ \
typeof( ((type *)0)->member ) *__mptr = (ptr); \
(type *)( (void *)__mptr - offsetof(type,member) );})
struct expr
#define offsetof(TYPE, MEMBER)
Definition: linux_list.h:7
#define div_round_up (   n,
 
)    (((n) + (d) - 1) / (d))
#define field_sizeof (   t,
 
)    (sizeof(((t *)NULL)->f))

Return a pointer to a constant variable of a size smaller than the variable.

#define max (   x,
 
)
Value:
({ \
typeof(x) _max1 = (x); \
typeof(y) _max2 = (y); \
(void) (&_max1 == &_max2); \
_max1 > _max2 ? _max1 : _max2; })
#define min (   x,
 
)
Value:
({ \
typeof(x) _min1 = (x); \
typeof(y) _min2 = (y); \
(void) (&_min1 == &_min2); \
_min1 < _min2 ? _min1 : _min2; })
#define pr_debug (   fmt,
  arg... 
)    ({ if (false) {}; 0; })
#define pr_gmp_debug (   fmt,
  arg... 
)    ({ if (false) {}; 0; })

Referenced by set_to_intervals().

Function Documentation

void __memory_allocation_error ( const char *  filename,
uint32_t  line 
)

References NFT_EXIT_NOMEM.

void xfree ( const void *  ptr)
void* xmalloc ( size_t  size)

References memory_allocation_error, and NULL.

Referenced by __attribute__(), export_alloc(), mnl_batch_init(), monitor_alloc(), netlink_delinearize_rule(), rt_symbol_table_init(), and xzalloc().

Here is the caller graph for this function:

void* xrealloc ( void *  ptr,
size_t  size 
)

References memory_allocation_error, and NULL.

Referenced by rt_symbol_table_init().

Here is the caller graph for this function:

char* xstrdup ( const char *  s)
void* xzalloc ( size_t  size)

References xmalloc().

Referenced by chain_alloc(), cmd_alloc(), expr_alloc(), main(), rule_alloc(), set_alloc(), stmt_alloc(), symbol_bind(), and table_alloc().

Here is the call graph for this function:

Here is the caller graph for this function: