Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

tools.h

Go to the documentation of this file.
00001 /*
00002  *      HT Editor
00003  *      tools.h
00004  *
00005  *      Copyright (C) 1999-2002 Sebastian Biallas (sb@web-productions.de)
00006  *
00007  *      This program is free software; you can redistribute it and/or modify
00008  *      it under the terms of the GNU General Public License version 2 as
00009  *      published by the Free Software Foundation.
00010  *
00011  *      This program is distributed in the hope that it will be useful,
00012  *      but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  *      GNU General Public License for more details.
00015  *
00016  *      You should have received a copy of the GNU General Public License
00017  *      along with this program; if not, write to the Free Software
00018  *      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00019  */
00020 
00021 #ifndef __TOOLS_H__
00022 #define __TOOLS_H__
00023 
00024 #include <stdlib.h>
00025 #include <string.h>
00026 #include "global.h"
00027 #include "htdata.h"
00028 
00029 #ifdef HAVE_CONFIG_H
00030 #include "config.h"
00031 #endif
00032 
00033 #define MIN(a, b) ((a) < (b) ? (a) : (b))
00034 #define MAX(a, b) ((a) > (b) ? (a) : (b))
00035 
00036 #ifdef NO_NATIVE_UNALIGNED_MOVES
00037 #define UNALIGNED_MOVE(a, b) memcpy(&(a), &(b), sizeof(a))
00038 #define UNALIGNED_MOVE_CONST(a, b, type) {assert(sizeof(a)==sizeof(type));type c = b;memcpy(&(a), &c, sizeof(a));}
00039 #else
00040 #define UNALIGNED_MOVE(a, b) (a) = (b)
00041 #define UNALIGNED_MOVE_CONST(a, b, type) (a) = (b)
00042 #endif
00043 
00044 dword delinearize(dword d);
00045 
00046 int compare_keys_int_delinear(Object *key_a, Object *key_b);
00047 int compare_keys_uint_delinear(Object *key_a, Object *key_b);
00048 
00049 int *random_permutation(int max);
00050 
00051 double calc_entropy(byte *buf, int size);
00052 int calc_entropy2(byte *buf, int size);
00053 
00054 #define OUT_OF_MEMORY_FAIL 0
00055 #define OUT_OF_MEMORY_IGNORE 1
00056 #define OUT_OF_MEMORY_RETRY 2
00057 extern int (*out_of_memory_func)(int size);
00058 int out_of_memory(int size);
00059 
00060 // savety mallocs
00061 void *smalloc(size_t size);
00062 void *smalloc0(size_t size);
00063 
00064 #endif /* __TOOLS_H__ */

Generated on Fri May 7 21:15:45 2004 by doxygen 1.3.5