[BACK]Return to ci_malloc.h CVS log [TXT][DIR] Up to [Development] / failsafe / FailSafe / cluster_services / include

File: [Development] / failsafe / FailSafe / cluster_services / include / ci_malloc.h (download)

Revision 1.3, Mon May 6 10:42:31 2002 UTC (15 years, 5 months ago) by lmb
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +2 -2 lines

addr_t -> cs_addr_t due to a name clash.

/*
 * Copyright (c) 2000,2001 Silicon Graphics, Inc.  All Rights Reserved.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of version 2.1 of the GNU Lesser General Public
 * License as published by the Free Software Foundation.
 * 
 * This program is distributed in the hope that it would be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * 
 * Further, this software is distributed without any warranty that it is
 * free of the rightful claim of any third person regarding infringement
 * or the like.  Any license provided herein, whether implied or
 * otherwise, applies only to this software file.  Patent licenses, if
 * any, provided herein do not apply to combinations of this program with
 * other software, or any other product whatsoever.
 * 
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston MA 02111-1307,
 * USA.
 * 
 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
 * Mountain View, CA 94043, or:
 * 
 * http://www.sgi.com 
 * 
 * For further information regarding this notice, see: 
 * 
 * http://oss.sgi.com/projects/GenInfo/NoticeExplan
 */
/* 
 * ci_malloc.h
 *
 * What's in this file?
 */

#ifndef	CI_MALLOC_H
#define	CI_MALLOC_H
#ident "$Id: ci_malloc.h,v 1.3 2002/05/06 10:42:31 lmb Exp $"

typedef struct ci_memmap_entry_s {
	cs_addr_t	m_addr;
	size_t	m_size;
} ci_memmap_entry_t;

typedef struct ci_memmap_s {
	ci_memmap_entry_t	*entry;
	size_t			size;
	boolean_t		am_pinned; 
	size_t			tot_size;
} ci_memmap_t;

#define	CI_MEM_BLOCKSIZE	8
#define CI_MEM_ROUND(x)		(((x) % CI_MEM_BLOCKSIZE) ? \
				 ((x) + CI_MEM_BLOCKSIZE) - \
				 ((x) % CI_MEM_BLOCKSIZE) : (x))

#define MAX_MEM_BUFS 32
#define CI_DEFAULT_MEMBUF_SIZE 32*1024
#define CI_DEFAULT_MEMMAP_SIZE 256


void		ci_mem_init(char *, size_t, size_t, boolean_t);

#ifdef CI_MEM_DEBUG

void 		*ci_mem_alloc(size_t, boolean_t, int lineno, char* filename);
void		ci_mem_free(void *, size_t, int lineno, char* filename);

#else

void 		*ci_mem_alloc(size_t, boolean_t);
void		ci_mem_free(void *, size_t);

#endif

void		ci_mem_destroy(void);
void 		dump_mem_map(int );
void 		*zmalloc(size_t);

ci_memmap_t 	*mem_init(size_t mapsize, size_t memsize, int flag);
void		*mem_alloc(ci_memmap_t *map, size_t Size);
ci_err_t	mem_free(ci_memmap_t *map, void *Addr, size_t Size);
void 		mem_destroy(ci_memmap_t *mem);

#ifdef MEM_DEBUG
#define MALLOC(size)		ci_malloc(size, __FILE__, __LINE__)
#define CALLOC(n, size)		ci_calloc(n, size, __FILE__, __LINE__)
#define REALLOC(ptr, size)	ci_realloc(ptr, size, __FILE__, __LINE__)
#define FREE(addr)		ci_free(addr, __FILE__, __LINE__, -1)
#define FREE1(addr, size)	ci_free(addr, __FILE__, __LINE__, size)
#else
#define MALLOC(size)		malloc(size)
#define CALLOC(n, size)		calloc(n, size)
#define REALLOC(ptr, size)	realloc(ptr, size)
#define FREE(addr)		free(addr)
#define FREE1(addr, size) 	free(addr)
#endif

void *		ci_malloc(size_t, char *, int);
void *		ci_calloc(size_t, size_t, char *, int);
void		ci_free(void *, char *, int, int);

ci_err_t	ci_mem_log(__uint32_t level, ci_err_t err, const char *format, ...);

#define CI_MEM_LOG(args) (CI_LOG_START, ci_mem_log args, CI_LOG_END)
#endif	/* CI_MALLOC_H */