g+
g+ Communities
Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  Index 2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014 
<== Date ==> <== Thread ==>

Subject: 64 bit integers (aka. long or long long)
From: Michael Davidsaver <mdavidsaver@bnl.gov>
To: EPICS core-talk <core-talk@aps.anl.gov>
Date: Fri, 17 Jun 2011 13:59:56 -0400
All,

I'd like to add a standard 64-bit integer type to epicsTypes.h. Currently this is only available when compiling with the C99 extensions enabled.

Attached are two proposed patches. The first adds sanity checks of the existing type sizes. The second defines epicsUInt64 and epicsInt64.

The C primitive used (either long or long long) is chosen by testing the size of LONG_MAX. I think this should work for all toolchains which actually provide a 64-bit integer type. The question is, are there any which don't and need to be supported?


Michael

>From 8580488483068b471e7ffc91129bdf3c6cf7888c Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <mdavidsaver@bnl.gov>
Date: Mon, 13 Jun 2011 09:24:02 -0400
Subject: [PATCH 1/5] verify types

Should be done early in the build.
---
 src/libCom/Makefile       |    2 ++
 src/libCom/staticChecks.c |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 0 deletions(-)
 create mode 100644 src/libCom/staticChecks.c

diff --git a/src/libCom/Makefile b/src/libCom/Makefile
index 7f0168f..8ac7683 100644
--- a/src/libCom/Makefile
+++ b/src/libCom/Makefile
@@ -22,6 +22,8 @@ osdThread_CPPFLAGS += $(THREAD_CPPFLAGS_$(USE_POSIX_THREAD_PRIORITY_SCHEDULING))
 #epicsVersion is created by this Makefile
 INC += epicsVersion.h
 
+SRCS += staticChecks.c
+
 SRC_DIRS += $(LIBCOM)/bucketLib
 INC += bucketLib.h
 SRCS += bucketLib.c
diff --git a/src/libCom/staticChecks.c b/src/libCom/staticChecks.c
new file mode 100644
index 0000000..d348741
--- /dev/null
+++ b/src/libCom/staticChecks.c
@@ -0,0 +1,20 @@
+#ifndef STATICCHECKS_H
+#define STATICCHECKS_H
+
+#include "epicsAssert.h"
+
+#include "epicsTypes.h"
+
+STATIC_ASSERT(sizeof(epicsUInt8)==1);
+STATIC_ASSERT(sizeof(epicsInt8)==1);
+
+STATIC_ASSERT(sizeof(epicsUInt16)==2);
+STATIC_ASSERT(sizeof(epicsInt16)==2);
+
+STATIC_ASSERT(sizeof(epicsUInt32)==4);
+STATIC_ASSERT(sizeof(epicsInt32)==4);
+
+STATIC_ASSERT(sizeof(epicsFloat32)==4);
+STATIC_ASSERT(sizeof(epicsFloat64)==8);
+
+#endif // STATICCHECKS_H
-- 
1.7.2.5

>From f0f56a03c66ec8aaa38fc0f52599ef456a3aa290 Mon Sep 17 00:00:00 2001
From: Michael Davidsaver <mdavidsaver@bnl.gov>
Date: Mon, 13 Jun 2011 09:24:02 -0400
Subject: [PATCH 2/5] add standard 64-bit integer type

---
 src/libCom/misc/epicsTypes.h |   23 +++++++++++++++++++++++
 src/libCom/staticChecks.c    |    3 +++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/src/libCom/misc/epicsTypes.h b/src/libCom/misc/epicsTypes.h
index 2d554ce..ae8eb8b 100644
--- a/src/libCom/misc/epicsTypes.h
+++ b/src/libCom/misc/epicsTypes.h
@@ -23,6 +23,8 @@
 #include <inttypes.h>
 #endif
 
+#include <limits.h>
+
 #ifndef stringOf
 #   if defined (__STDC__ ) || defined (__cplusplus)
 #       define stringOf(TOKEN) #TOKEN
@@ -57,6 +59,13 @@ typedef enum {
     typedef epicsUInt16     epicsEnum16;
     typedef int             epicsInt32;
     typedef unsigned int    epicsUInt32;
+#if LONG_MAX>0x7fffffff
+    typedef long            epicsInt64;
+    typedef unsigned long   epicsUInt64;
+#else
+    typedef long long       epicsInt64;
+    typedef unsigned long long epicsUInt64;
+#endif
 #endif
 typedef float           epicsFloat32;
 typedef double          epicsFloat64;
@@ -95,6 +104,8 @@ typedef union epics_any{
     epicsEnum16     enum16;
     epicsInt32      int32;
     epicsUInt32     uInt32;
+    epicsInt64      int64;
+    epicsUInt64     uInt64;
     epicsFloat32    float32;
     epicsFloat64    float64;
     epicsString     string;
@@ -115,6 +126,8 @@ typedef enum {
                 epicsEnum16T,
                 epicsInt32T,
                 epicsUInt32T,
+                epicsInt64T,
+                epicsUInt64T,
                 epicsFloat32T,
                 epicsFloat64T,
                 epicsStringT,
@@ -139,6 +152,8 @@ epicsShareDef const char *epicsTypeNames [lastEpicsType+1] = {
         "epicsEnum16",
         "epicsInt32",
         "epicsUInt32",
+        "epicsInt64",
+        "epicsUInt64",
         "epicsFloat32",
         "epicsFloat64",
         "epicsString",
@@ -161,6 +176,8 @@ epicsShareDef const char *epicsTypeCodeNames [lastEpicsType+1] = {
         "epicsEnum16T",
         "epicsInt32T",
         "epicsUInt32T",
+        "epicsInt64T",
+        "epicsUInt64T",
         "epicsFloat32T",
         "epicsFloat64T",
         "epicsStringT",
@@ -179,6 +196,8 @@ epicsShareDef const unsigned epicsTypeSizes [lastEpicsType+1] = {
         sizeof (epicsEnum16),
         sizeof (epicsInt32),
         sizeof (epicsUInt32),
+        sizeof (epicsInt64),
+        sizeof (epicsUInt64),
         sizeof (epicsFloat32),
         sizeof (epicsFloat64),
         sizeof (epicsString),
@@ -208,6 +227,8 @@ epicsShareDef const epicsTypeClass epicsTypeClasses [lastEpicsType+1] = {
         epicsEnumC,
         epicsIntC,
         epicsUIntC,
+        epicsIntC,
+        epicsUIntC,
         epicsFloatC,
         epicsFloatC,
         epicsStringC,
@@ -227,6 +248,8 @@ epicsShareDef const char *epicsTypeAnyFieldName [lastEpicsType+1] = {
             "enum16",
             "int32",
             "uInt32",
+            "int64",
+            "uInt64",
             "float32",
             "float64",
             "string",
diff --git a/src/libCom/staticChecks.c b/src/libCom/staticChecks.c
index d348741..807f138 100644
--- a/src/libCom/staticChecks.c
+++ b/src/libCom/staticChecks.c
@@ -14,6 +14,9 @@ STATIC_ASSERT(sizeof(epicsInt16)==2);
 STATIC_ASSERT(sizeof(epicsUInt32)==4);
 STATIC_ASSERT(sizeof(epicsInt32)==4);
 
+STATIC_ASSERT(sizeof(epicsUInt64)==8);
+STATIC_ASSERT(sizeof(epicsInt64)==8);
+
 STATIC_ASSERT(sizeof(epicsFloat32)==4);
 STATIC_ASSERT(sizeof(epicsFloat64)==8);
 
-- 
1.7.2.5


Replies:
Re: 64 bit integers (aka. long or long long) Andrew Johnson

Navigate by Date:
Prev: Re: Gateway / CAS include issue Michael Davidsaver
Next: Re: 64 bit integers (aka. long or long long) Andrew Johnson
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014 
Navigate by Thread:
Prev: Re: Gateway / CAS include issue Michael Davidsaver
Next: Re: 64 bit integers (aka. long or long long) Andrew Johnson
Index: 2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICSv4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·