home *** CD-ROM | disk | FTP | other *** search
/ Windows News 2005 November / WNnov2005.iso / Windows / Equipement / Blender / blender-2.37a-windows.exe / $_5_ / plugins / include / util.h < prev   
C/C++ Source or Header  |  2005-06-14  |  3KB  |  96 lines

  1. /* Copyright (c) 1999, Not a Number / NeoGeo b.v. 
  2.  * $Id: util.h,v 1.6 2004/12/13 13:51:35 sirdude Exp $
  3.  * 
  4.  * All rights reserved.
  5.  * 
  6.  * Contact:      info@blender.org   
  7.  * Information:  http://www.blender.org
  8.  *
  9.  * Redistribution and use in source and binary forms, with or without
  10.  * modification, are permitted provided that the following conditions
  11.  * are met:
  12.  * 1. Redistributions of source code must retain the above copyright
  13.  *    notice, this list of conditions and the following disclaimer.
  14.  * 2. Redistributions in binary form must reproduce the above copyright
  15.  *    notice, this list of conditions and the following disclaimer in the
  16.  *    documentation and/or other materials provided with the distribution.
  17.  *
  18.  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  19.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  20.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  21.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  22.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  23.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  24.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  25.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  26.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  27.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28.  * SUCH DAMAGE.
  29.  */
  30.  
  31. #ifndef UTIL_H
  32. #define UTIL_H
  33.  
  34. #include <sys/types.h>
  35. #include <stdlib.h>
  36. #include <string.h>
  37.  
  38. #ifndef    NULL
  39. #define NULL            0
  40. #endif
  41.  
  42. #ifndef    FALSE
  43. #define FALSE            0
  44. #endif
  45.  
  46. #ifndef    TRUE
  47. #define TRUE            1
  48. #endif
  49.  
  50. #ifndef ulong
  51. #define ulong unsigned long
  52. #endif
  53.  
  54. #ifndef ushort
  55. #define ushort unsigned short
  56. #endif
  57.  
  58. #ifndef uchar
  59. #define uchar unsigned char
  60. #endif
  61.  
  62. #ifndef uint
  63. #define uint unsigned int
  64. #endif
  65.  
  66. #define MIN2(x,y)        ( (x)<(y) ? (x) : (y) )
  67. #define MIN3(x,y,z)        MIN2( MIN2((x),(y)) , (z) )
  68. #define MIN4(x,y,z,a)        MIN2( MIN2((x),(y)) , MIN2((z),(a)) )
  69.  
  70. #define MAX2(x,y)        ( (x)>(y) ? (x) : (y) )
  71. #define MAX3(x,y,z)        MAX2( MAX2((x),(y)) , (z) )
  72. #define MAX4(x,y,z,a)        MAX2( MAX2((x),(y)) , MAX2((z),(a)) )
  73.  
  74. #define SWAP(type, a, b)    { type sw_ap; sw_ap=(a); (a)=(b); (b)=sw_ap; }
  75.  
  76. #define ABS(x)    ((x) < 0 ? -(x) : (x))
  77. #define FLOOR(x) ((int)(x) - ((x) < 0 && (x) != (int)(x)))
  78. #define CEIL(x) ((int)(x) + ((x) > 0 && (x) != (int)(x)))
  79. #define STEP(a,b)    ( (a)>(b) ? (1) : (0) )
  80. #define CLAMP(val, low, high) ((val>high)?high:((val<low)?low:val))
  81. #define LERP(t,x0,x1) ((x0) + (t)*((x1)-(x0)))
  82. #define PULSE(a,b,x) (STEP((a),(x)) - STEP((b),(x)))
  83. #define BOXSTEP(a,b,x) CLAMP(((x)-(a))/((b)-(a)),0,1)
  84.  
  85. #define PRINT(d, var1)    printf(# var1 ":%" # d "\n", var1)
  86. #define PRINT2(d, e, var1, var2)    printf(# var1 ":%" # d " " # var2 ":%" # e "\n", var1, var2)
  87. #define PRINT3(d, e, f, var1, var2, var3)    printf(# var1 ":%" # d " " # var2 ":%" # e " " # var3 ":%" # f "\n", var1, var2, var3)
  88. #define PRINT4(d, e, f, g, var1, var2, var3, var4)    printf(# var1 ":%" # d " " # var2 ":%" # e " " # var3 ":%" # f " " # var4 ":%" # g "\n", var1, var2, var3, var4)
  89.  
  90. extern          void *mallocN(int len, char *str);
  91. extern          void *callocN(int len, char *str);
  92. extern          short freeN(void *vmemh);   
  93.  
  94. #endif /* UTIL_H */
  95.  
  96.