Blender  V2.59
BKE_utildefines.h
Go to the documentation of this file.
00001 /* 
00002  * $Id: BKE_utildefines.h 34962 2011-02-18 13:05:18Z jesterking $
00003  *
00004  * ***** BEGIN GPL LICENSE BLOCK *****
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU General Public License
00008  * as published by the Free Software Foundation; either version 2
00009  * of the License, or (at your option) any later version.
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 Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  *
00020  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
00021  * All rights reserved.
00022  *
00023  * The Original Code is: all of this file.
00024  *
00025  * Contributor(s): none yet.
00026  *
00027  * ***** END GPL LICENSE BLOCK *****
00028 */
00029 
00037 #ifndef BKE_UTILDEFINES_H
00038 #define BKE_UTILDEFINES_H
00039 
00040 /* these values need to be hardcoded in structs, dna does not recognize defines */
00041 /* also defined in DNA_space_types.h */
00042 #ifndef FILE_MAXDIR
00043 #define FILE_MAXDIR                     160
00044 #define FILE_MAXFILE            80
00045 #define FILE_MAX                        240
00046 #endif
00047 
00048 /* this weirdo pops up in two places ... */
00049 #if !defined(WIN32)
00050 #ifndef O_BINARY
00051 #define O_BINARY 0
00052 #endif
00053 #endif
00054 
00055 /* INTEGER CODES */
00056 #if defined(__sgi) || defined (__sparc) || defined (__sparc__) || defined (__PPC__) || defined (__ppc__) || defined (__hppa__) || defined (__BIG_ENDIAN__)
00057         /* Big Endian */
00058 #define MAKE_ID(a,b,c,d) ( (int)(a)<<24 | (int)(b)<<16 | (c)<<8 | (d) )
00059 #else
00060         /* Little Endian */
00061 #define MAKE_ID(a,b,c,d) ( (int)(d)<<24 | (int)(c)<<16 | (b)<<8 | (a) )
00062 #endif
00063 
00064 #define ID_NEW(a)               if( (a) && (a)->id.newid ) (a)= (void *)(a)->id.newid
00065 
00066 #define DATA MAKE_ID('D','A','T','A')
00067 #define GLOB MAKE_ID('G','L','O','B')
00068 
00069 #define DNA1 MAKE_ID('D','N','A','1')
00070 #define TEST MAKE_ID('T','E','S','T') /* used as preview between 'REND' and 'GLOB' */
00071 #define REND MAKE_ID('R','E','N','D')
00072 #define USER MAKE_ID('U','S','E','R')
00073 
00074 #define ENDB MAKE_ID('E','N','D','B')
00075 
00076 /* Bit operations */
00077 #define BTST(a,b)       ( ( (a) & 1<<(b) )!=0 )   
00078 #define BNTST(a,b)      ( ( (a) & 1<<(b) )==0 )
00079 #define BTST2(a,b,c)    ( BTST( (a), (b) ) || BTST( (a), (c) ) )
00080 #define BSET(a,b)       ( (a) | 1<<(b) )
00081 #define BCLR(a,b)       ( (a) & ~(1<<(b)) )
00082 /* bit-row */
00083 #define BROW(min, max)  (((max)>=31? 0xFFFFFFFF: (1<<(max+1))-1) - ((min)? ((1<<(min))-1):0) )
00084 
00085 #define BMEMSET(mem, val, size) {unsigned int _i; char *_c = (char*) mem; for (_i=0; _i<size; _i++) *_c++ = val;}
00086 
00087 #endif // BKE_UTILDEFINES_H