/[pspp]/pspp/src/misc.h
ViewVC logotype

Diff of /pspp/src/misc.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by blp, Tue Mar 30 00:42:55 2004 UTC revision 1.4 by blp, Tue Mar 15 06:04:10 2005 UTC
# Line 28  Line 28 
28  /* HUGE_VAL is traditionally defined as positive infinity, or  /* HUGE_VAL is traditionally defined as positive infinity, or
29     alternatively, DBL_MAX. */     alternatively, DBL_MAX. */
30  #if !HAVE_ISINF  #if !HAVE_ISINF
31  #define isinf(X)                                \  #define isinf(X) (fabs (X) == HUGE_VAL)
         (fabs (X) == HUGE_VAL)  
32  #endif  #endif
33    
34  /* A Not a Number is not equal to itself. */  /* A Not a Number is not equal to itself. */
35  #if !HAVE_ISNAN  #if !HAVE_ISNAN
36  #define isnan(X)                                \  #define isnan(X) ((X) != (X))
         ((X) != (X))  
37  #endif  #endif
38    
39  /* Finite numbers are not infinities or NaNs. */  /* Finite numbers are not infinities or NaNs. */
40  #if !HAVE_FINITE  #if !HAVE_FINITE
41  #define finite(X)                               \  #define finite(X) (!isinf (X) && !isnan (X))
         (!isinf (X) && !isnan (X))  
42  #elif HAVE_IEEEFP_H  #elif HAVE_IEEEFP_H
43  #include <ieeefp.h>             /* Declares finite() under Solaris. */  #include <ieeefp.h>             /* Declares finite() under Solaris. */
44  #endif  #endif
45    
 #if __TURBOC__  
 #include <stdlib.h>             /* screwed-up Borland headers define min(), max(),  
                                    so we might as well let 'em */  
 #endif  
   
46  #ifndef min  #ifndef min
47  #if __GNUC__ && !__STRICT_ANSI__  #define min(A, B) ((A) < (B) ? (A) : (B))
48  #define min(A, B)                               \  #endif
         ({                                      \  
           int _a = (A), _b = (B);               \  
           _a < _b ? _a : _b;                    \  
         })  
 #else /* !__GNUC__ */  
 #define min(A, B)                               \  
         ((A) < (B) ? (A) : (B))  
 #endif /* !__GNUC__ */  
 #endif /* !min */  
49    
50  #ifndef max  #ifndef max
51  #if __GNUC__ && !__STRICT_ANSI__  #define max(A, B) ((A) > (B) ? (A) : (B))
52  #define max(A, B)                               \  #endif
         ({                                      \  
           int _a = (A), _b = (B);               \  
           _a > _b ? _a : _b;                    \  
         })  
 #else /* !__GNUC__ */  
 #define max(A, B)                               \  
         ((A) > (B) ? (A) : (B))  
 #endif /* !__GNUC__ */  
 #endif /* !max */  
53    
54  /* Clamps A to be between B and C. */  /* Clamps A to be between B and C. */
55  #define range(A, B, C)                          \  #define range(A, B, C) ((A) < (B) ? (B) : ((A) > (C) ? (C) : (A)))
         ((A) < (B) ? (B) : ((A) > (C) ? (C) : (A)))  
56    
57  /* Divides nonnegative X by positive Y, rounding up. */  /* Divides nonnegative X by positive Y, rounding up. */
58  #define DIV_RND_UP(X, Y)                        \  #define DIV_RND_UP(X, Y) (((X) + ((Y) - 1)) / (Y))
         (((X) + ((Y) - 1)) / (Y))  
59    
60  /* Returns nonnegative difference between {nonnegative X} and {the  /* Returns nonnegative difference between {nonnegative X} and {the
61     least multiple of positive Y greater than or equal to X}. */     least multiple of positive Y greater than or equal to X}. */
62  #if __GNUC__ && !__STRICT_ANSI__  #define REM_RND_UP(X, Y) ((X) % (Y) ? (Y) - (X) % (Y) : 0)
 #define REM_RND_UP(X, Y)                        \  
         ({                                      \  
           int rem = (X) % (Y);                  \  
           rem ? (Y) - rem : 0;                  \  
         })  
 #else  
 #define REM_RND_UP(X, Y)                        \  
         ((X) % (Y) ? (Y) - (X) % (Y) : 0)  
 #endif  
63    
64  /* Rounds X up to the next multiple of Y. */  /* Rounds X up to the next multiple of Y. */
65  #define ROUND_UP(X, Y)                          \  #define ROUND_UP(X, Y) (((X) + ((Y) - 1)) / (Y) * (Y))
         (((X) + ((Y) - 1)) / (Y) * (Y))  
66    
67  /* Rounds X down to the previous multiple of Y. */  /* Rounds X down to the previous multiple of Y. */
68  #define ROUND_DOWN(X, Y)                        \  #define ROUND_DOWN(X, Y) ((X) / (Y) * (Y))
         ((X) / (Y) * (Y))  
69    
70  int intlog10 (unsigned);  int intlog10 (unsigned);
71    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26