This file is indexed.

/usr/include/rtai/rtai_malloc.h is in librtai-dev 3.8.1-4build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*
 * Copyright (C) 2001,2002,2003,2004 Philippe Gerum <rpm@xenomai.org>.
 *
 * RTAI is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * RTAI is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
 * License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with RTAI; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * This file provides the interface to the RTAI dynamic memory
 * allocator based on the algorithm described in "Design of a General
 * Purpose Memory Allocator for the 4.3BSD Unix Kernel" by Marshall
 * K. McKusick and Michael J. Karels.
 */

#ifndef _RTAI_MALLOC_H
#define _RTAI_MALLOC_H

#include <rtai_types.h>

#ifdef __KERNEL__

#ifndef __cplusplus

#include <linux/kernel.h>
#include <linux/list.h>
#include <linux/spinlock.h>

/*
 * LIMITS:
 *
 * Minimum page size is 2 ** RTHEAP_MINLOG2 (must be large enough to
 * hold a pointer).
 *
 * Maximum page size is 2 ** RTHEAP_MAXLOG2.
 *
 * Minimum block size equals the minimum page size.
 *
 * Requested block size smaller than the minimum block size is
 * rounded to the minimum block size.
 *
 * Requested block size larger than 2 times the page size is rounded
 * to the next page boundary and obtained from the free page
 * list. So we need a bucket for each power of two between
 * RTHEAP_MINLOG2 and RTHEAP_MAXLOG2 inclusive, plus one to honor
 * requests ranging from the maximum page size to twice this size.
 */

#define	RTHEAP_MINLOG2    4
#define	RTHEAP_MAXLOG2    22
#define	RTHEAP_MINALLOCSZ (1 << RTHEAP_MINLOG2)
#define	RTHEAP_MINALIGNSZ RTHEAP_MINALLOCSZ
#define	RTHEAP_NBUCKETS   (RTHEAP_MAXLOG2 - RTHEAP_MINLOG2 + 2)
#define	RTHEAP_MAXEXTSZ   0x7FFFFFFF
#define RTHEAP_GLOBALSZ   (CONFIG_RTAI_MALLOC_HEAPSZ * 1024)

#define RTHEAP_PFREE   0
#define RTHEAP_PCONT   1
#define RTHEAP_PLIST   2

#define KMALLOC_LIMIT  (128 * 1024)

#define RTHEAP_NOMEM   (-1)
#define RTHEAP_PARAM   (-2)

typedef struct rtextent {

    struct list_head link;

    caddr_t membase,	/* Base address of the page array */
	    memlim,	/* Memory limit of page array */
	    freelist;	/* Head of the free page list */

    u_char pagemap[1];	/* Beginning of page map */

} rtextent_t;

/* Creation flag */
#define RTHEAP_EXTENDABLE 0x1

/* Allocation flags */
#define RTHEAP_EXTEND    0x1

typedef struct rtheap {

    spinlock_t lock;

    int flags;

    u_long extentsize,
           pagesize,
           pageshift,
	   hdrsize,
	   npages,	/* Number of pages per extent */
	   ubytes,
           maxcont;

    struct list_head extents;

    caddr_t buckets[RTHEAP_NBUCKETS];

} rtheap_t;

#else /* __cplusplus */

struct rtheap;

typedef struct rtheap rtheap_t;

#endif /* !__cplusplus */

extern rtheap_t rtai_global_heap;

#define rtheap_page_size(heap)   ((heap)->pagesize)
#define rtheap_page_count(heap)  ((heap)->npages)
#define rtheap_used_mem(heap)    ((heap)->ubytes)

#ifdef CONFIG_RTAI_MALLOC
#define rt_malloc(sz)  rtheap_alloc(&rtai_global_heap, sz, 0)
#define rt_free(p)     rtheap_free(&rtai_global_heap, p)
#else
#define rt_malloc(sz)  kmalloc(sz, GFP_KERNEL)
#define rt_free(p)     kfree(p)
#endif

#ifdef __cplusplus
extern "C" {
#endif

int __rtai_heap_init(void);

void __rtai_heap_exit(void);

int rtheap_init(rtheap_t *heap, void *heapaddr, u_long heapsize, u_long pagesize, int suprt);

void rtheap_destroy(rtheap_t *heap, int suprt);

void *rtheap_alloc(rtheap_t *heap, u_long size, int flags);

int rtheap_free(rtheap_t *heap, void *block);

#ifdef __cplusplus
}
#endif

#endif /* __KERNEL__ */

#endif /* !_RTAI_MALLOC_H */