]> git.sur5r.net Git - cc65/blobdiff - src/cc65/datatype.h
Fixed two compiler warnings.
[cc65] / src / cc65 / datatype.h
index 4a6a95cb0be3d7a7468e244c64a2311fa93f0d05..0fe46f6d2b0b781ed53a6424b6d350ad8bae888e 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 1998-2008 Ullrich von Bassewitz                                       */
-/*               Roemerstrasse 52                                            */
-/*               D-70794 Filderstadt                                         */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 1998-2010, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -110,7 +110,9 @@ enum {
     T_QUAL_FAR      = 0x008000,
     T_QUAL_ADDRSIZE = T_QUAL_NEAR | T_QUAL_FAR,
     T_QUAL_FASTCALL = 0x010000,
-    T_MASK_QUAL            = 0x01F800,
+    T_QUAL_CDECL    = 0x020000,
+    T_QUAL_CCONV    = T_QUAL_FASTCALL | T_QUAL_CDECL,
+    T_MASK_QUAL            = 0x03F800,
 
     /* Types */
     T_CHAR             = T_TYPE_CHAR     | T_CLASS_INT    | T_SIGN_UNSIGNED | T_SIZE_NONE,
@@ -165,14 +167,24 @@ struct Type {
 #define FLEXIBLE        0L      /* Flexible array struct member */
 
 /* Sizes. Floating point sizes come from fp.h */
-#define SIZEOF_CHAR     1
-#define SIZEOF_SHORT    2
-#define SIZEOF_INT      2
-#define SIZEOF_LONG     4
-#define SIZEOF_LONGLONG 8
+#define SIZEOF_CHAR     1U
+#define SIZEOF_SHORT    2U
+#define SIZEOF_INT      2U
+#define SIZEOF_LONG     4U
+#define SIZEOF_LONGLONG 8U
 #define SIZEOF_FLOAT    (FP_F_Size())
 #define SIZEOF_DOUBLE   (FP_D_Size())
-#define SIZEOF_PTR      2
+#define SIZEOF_PTR      SIZEOF_INT
+
+/* Bit sizes */
+#define CHAR_BITS       (8 * SIZEOF_CHAR)
+#define SHORT_BITS      (8 * SIZEOF_SHORT)
+#define INT_BITS        (8 * SIZEOF_INT)
+#define LONG_BITS       (8 * SIZEOF_LONG)
+#define LONGLONG_BITS   (8 * SIZEOF_LONGLONG)
+#define FLOAT_BITS      (8 * SIZEOF_FLOAT)
+#define DOUBLE_BITS     (8 * SIZEOF_DOUBLE)
+#define PTR_BITS        (8 * SIZEOF_PTR)
 
 /* Predefined type strings */
 extern Type type_schar[];
@@ -288,7 +300,7 @@ Type* Indirect (Type* T);
  * given type points to.
  */
 
-Type* ArrayToPtr (const Type* T);
+Type* ArrayToPtr (Type* T);
 /* Convert an array to a pointer to it's first element */
 
 #if defined(HAVE_INLINE)
@@ -467,7 +479,7 @@ INLINE int IsClassStruct (const Type* T)
 {
     return (GetClass (T) == T_CLASS_STRUCT);
 }
-#else                                
+#else
 #  define IsClassStruct(T)      (GetClass (T) == T_CLASS_STRUCT)
 #endif
 
@@ -581,6 +593,16 @@ INLINE int IsQualFastcall (const Type* T)
 #  define IsQualFastcall(T)     (((T)->C & T_QUAL_FASTCALL) != 0)
 #endif
 
+#if defined(HAVE_INLINE)
+INLINE int IsQualCDecl (const Type* T)
+/* Return true if the given type has a cdecl qualifier */
+{
+    return (T->C & T_QUAL_CDECL) != 0;
+}
+#else
+#  define IsQualCDecl(T)        (((T)->C & T_QUAL_CDECL) != 0)
+#endif
+
 int IsVariadicFunc (const Type* T) attribute ((const));
 /* Return true if this is a function type or pointer to function type with
  * variable parameter list