diff options
author | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-08-19 03:12:28 +0000 |
---|---|---|
committer | giraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8> | 2006-08-19 03:12:28 +0000 |
commit | 1fd361a1ea06e44286c213ca1f814f49306fdc43 (patch) | |
tree | 64c8c96cf54d8718847339a403e5e67b922e8c3f /lib/util/pm_c_util.h | |
download | netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.gz netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.tar.xz netpbm-mirror-1fd361a1ea06e44286c213ca1f814f49306fdc43.zip |
Create Subversion repository
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@1 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'lib/util/pm_c_util.h')
-rw-r--r-- | lib/util/pm_c_util.h | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/lib/util/pm_c_util.h b/lib/util/pm_c_util.h new file mode 100644 index 00000000..f21a2f82 --- /dev/null +++ b/lib/util/pm_c_util.h @@ -0,0 +1,62 @@ +#ifndef PM_C_UTIL_INCLUDED +#define PM_C_UTIL_INCLUDED + +#undef MAX +#define MAX(a,b) ((a) > (b) ? (a) : (b)) +#undef MIN +#define MIN(a,b) ((a) < (b) ? (a) : (b)) +#undef ABS +#define ABS(a) ((a) >= 0 ? (a) : -(a)) +#undef SGN +#define SGN(a) (((a)<0) ? -1 : 1) +#undef ODD +#define ODD(n) ((n) & 1) +#undef ROUND +#define ROUND(X) (((X) >= 0) ? (int)((X)+0.5) : (int)((X)-0.5)) +#undef ROUNDU +#define ROUNDU(X) ((unsigned int)((X)+0.5)) +#undef SQR +#define SQR(a) ((a)*(a)) + +/* NOTE: do not use "bool" as a type in an external interface. It could + have different definitions on either side of the interface. Even if both + sides include this interface header file, the conditional compilation + here means one side may use the typedef below and the other side may + use some other definition. For an external interface, be safe and just + use "int". +*/ + +/* We used to assume that if TRUE was defined, then bool was too. + However, we had a report on 2001.09.21 of a Tru64 system that had + TRUE but not bool and on 2002.03.21 of an AIX 4.3 system that was + likewise. So now we define bool all the time, unless the macro + HAVE_BOOL is defined. If someone is using the Netpbm libraries and + also another library that defines bool, he can either make the + other library define/respect HAVE_BOOL or just define HAVE_BOOL in + the file that includes pm_config.h or with a compiler option. Note + that C++ always has bool. + + A preferred way of getting booleans is <stdbool.h>. But it's not + available on all platforms, and it's easy to reproduce what it does + here. +*/ +#ifndef TRUE + #define TRUE 1 + #endif +#ifndef FALSE + #define FALSE 0 + #endif +/* C++ has a bool type and false and true constants built in. */ +#ifndef __cplusplus + #ifndef HAVE_BOOL + #define HAVE_BOOL 1 + typedef int bool; + #endif + #ifndef true + enum boolvalue {false=0, true=1}; + #endif + #endif + +#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) + +#endif |