try to make things work on 64 bit systems
Warning, cannot access the index:
_darcs/index: opening of '_darcs/index' failed: permission denied (Permission denied)
diff -rN -u old-branch-2-0/src/pv/pv.h new-branch-2-0/src/pv/pv.h
--- old-branch-2-0/src/pv/pv.h 2022-11-28 23:13:47.783739439 +0100
+++ new-branch-2-0/src/pv/pv.h 2022-11-28 23:13:47.783739439 +0100
@@ -13,7 +13,8 @@
#ifndef INCLpvh
#define INCLpvh
-#include "shareLib.h" /* reset share lib defines */
+#include "shareLib.h" /* reset share lib defines */
+#include "epicsTypes.h" /* for thread ids */
#include "epicsThread.h" /* for thread ids */
#include "epicsMutex.h" /* for locks */
#include "epicsTime.h" /* for time stamps */
@@ -60,12 +61,12 @@
/*
* Value-related types (c.f. db_access.h)
*/
-typedef char pvChar;
-typedef short pvShort;
-typedef long pvLong;
-typedef float pvFloat;
-typedef double pvDouble;
-typedef char pvString[256]; /* use sizeof( pvString ) */
+typedef epicsInt8 pvChar;
+typedef epicsInt16 pvShort;
+typedef epicsInt32 pvLong;
+typedef epicsFloat32 pvFloat;
+typedef epicsFloat64 pvDouble;
+typedef char pvString[256]; /* use sizeof( pvString ) */
#define PV_TIME_XXX(_type) \
typedef struct { \
diff -rN -u old-branch-2-0/src/seq/seq_ca.c new-branch-2-0/src/seq/seq_ca.c
--- old-branch-2-0/src/seq/seq_ca.c 2022-11-28 23:13:47.783739439 +0100
+++ new-branch-2-0/src/seq/seq_ca.c 2022-11-28 23:13:47.787739537 +0100
@@ -212,7 +212,7 @@
}
else
{
- pVal = (void *)((long)pValue + pDB->dbOffset); /* ptr to data */
+ pVal = (void *)((char *)pValue + pDB->dbOffset); /* ptr to data */
memcpy(pDB->pVar, pVal, pDB->size * pDB->dbCount);
}
diff -rN -u old-branch-2-0/src/seq/seq_main.c new-branch-2-0/src/seq/seq_main.c
--- old-branch-2-0/src/seq/seq_main.c 2022-11-28 23:13:47.783739439 +0100
+++ new-branch-2-0/src/seq/seq_main.c 2022-11-28 23:13:47.787739537 +0100
@@ -510,52 +510,52 @@
} typeMap[] = {
{
"char", pvTypeCHAR, pvTypeTIME_CHAR,
- sizeof (char), OFFSET(pvTimeChar, value[0])
+ sizeof (pvChar), OFFSET(pvTimeChar, value[0])
},
{
"short", pvTypeSHORT, pvTypeTIME_SHORT,
- sizeof (short), OFFSET(pvTimeShort, value[0])
+ sizeof (pvShort), OFFSET(pvTimeShort, value[0])
},
{
"int", pvTypeLONG, pvTypeTIME_LONG,
- sizeof (long), OFFSET(pvTimeLong, value[0])
+ sizeof (pvLong), OFFSET(pvTimeLong, value[0])
},
{
"long", pvTypeLONG, pvTypeTIME_LONG,
- sizeof (long), OFFSET(pvTimeLong, value[0])
+ sizeof (pvLong), OFFSET(pvTimeLong, value[0])
},
{
"unsigned char", pvTypeCHAR, pvTypeTIME_CHAR,
- sizeof (char), OFFSET(pvTimeChar, value[0])
+ sizeof (pvChar), OFFSET(pvTimeChar, value[0])
},
{
"unsigned short",pvTypeSHORT, pvTypeTIME_SHORT,
- sizeof (short), OFFSET(pvTimeShort, value[0])
+ sizeof (pvShort), OFFSET(pvTimeShort, value[0])
},
{
"unsigned int", pvTypeLONG, pvTypeTIME_LONG,
- sizeof (long), OFFSET(pvTimeLong, value[0])
+ sizeof (pvLong), OFFSET(pvTimeLong, value[0])
},
{
"unsigned long", pvTypeLONG, pvTypeTIME_LONG,
- sizeof (long), OFFSET(pvTimeLong, value[0])
+ sizeof (pvLong), OFFSET(pvTimeLong, value[0])
},
{
"float", pvTypeFLOAT, pvTypeTIME_FLOAT,
- sizeof (float), OFFSET(pvTimeFloat, value[0])
+ sizeof (pvFloat), OFFSET(pvTimeFloat, value[0])
},
{
"double", pvTypeDOUBLE, pvTypeTIME_DOUBLE,
- sizeof (double), OFFSET(pvTimeDouble, value[0])
+ sizeof (pvDouble), OFFSET(pvTimeDouble, value[0])
},
{
diff -rN -u old-branch-2-0/src/seq/seq_qry.c new-branch-2-0/src/seq/seq_qry.c
--- old-branch-2-0/src/seq/seq_qry.c 2022-11-28 23:13:47.783739439 +0100
+++ new-branch-2-0/src/seq/seq_qry.c 2022-11-28 23:13:47.787739537 +0100
@@ -396,11 +396,12 @@
int count, type;
{
int i;
- char *c;
- short *s;
- long *l;
- float *f;
- double *d;
+ pvChar *c;
+ pvShort *s;
+ pvLong *l;
+ pvFloat *f;
+ pvDouble *d;
+ pvString *r;
printf(" Value =");
for (i = 0; i < count; i++)
@@ -408,15 +409,15 @@
switch (type)
{
case pvTypeSTRING:
- c = (char *)pVal;
- for (i = 0; i < count; i++, c += sizeof(pvString))
+ r = (pvString *)pVal;
+ for (i = 0; i < count; i++, r++)
{
- printf(" %s", c);
+ printf(" %s", *r);
}
break;
case pvTypeCHAR:
- c = (char *)pVal;
+ c = (pvChar *)pVal;
for (i = 0; i < count; i++, c++)
{
printf(" %d", *c);
@@ -424,7 +425,7 @@
break;
case pvTypeSHORT:
- s = (short *)pVal;
+ s = (pvShort *)pVal;
for (i = 0; i < count; i++, s++)
{
printf(" %d", *s);
@@ -432,15 +433,15 @@
break;
case pvTypeLONG:
- l = (long *)pVal;
+ l = (pvLong *)pVal;
for (i = 0; i < count; i++, l++)
{
- printf(" %ld", *l);
+ printf(" %d", *l);
}
break;
case pvTypeFLOAT:
- f = (float *)pVal;
+ f = (pvFloat *)pVal;
for (i = 0; i < count; i++, f++)
{
printf(" %g", *f);
@@ -448,7 +449,7 @@
break;
case pvTypeDOUBLE:
- d = (double *)pVal;
+ d = (pvDouble *)pVal;
for (i = 0; i < count; i++, d++)
{
printf(" %g", *d);
diff -rN -u old-branch-2-0/src/snc/parse.c new-branch-2-0/src/snc/parse.c
--- old-branch-2-0/src/snc/parse.c 2022-11-28 23:13:47.783739439 +0100
+++ new-branch-2-0/src/snc/parse.c 2022-11-28 23:13:47.787739537 +0100
@@ -194,6 +194,24 @@
return;
}
+int check_type_too_long(Var *vp)
+{
+ extern int line_num;
+
+ if ((sizeof(long) > 4 && (vp->type == V_LONG || vp->type == V_ULONG))
+ || (sizeof(int) > 4 && (vp->type == V_INT || vp->type == V_UINT)))
+ {
+ fprintf(stderr,
+ "line %d: cannot assign variable >%s< because on this architecture "
+ "its (base) type is larger than 4 bytes. Such variables cannot be faithfully "
+ "mapped to any of the Channel Access base types.\nTry declaring the "
+ "variable as 'int' or, if that is still too large on your system, as 'short'.\n",
+ line_num, vp->name);
+ return FALSE;
+ }
+ return TRUE;
+}
+
/* "Assign" statement: Assign a variable to a DB channel.
* Format: assign <variable> to <string;
* Note: Variable may be subscripted.
@@ -227,6 +245,8 @@
return;
}
+ if (!check_type_too_long(vp)) return;
+
/* Build structure for this channel */
cp = build_db_struct(vp);
@@ -270,6 +290,8 @@
return;
}
+ if (!check_type_too_long(vp)) return;
+
cp = vp->chan;
if (cp == NULL)
{
@@ -352,6 +374,8 @@
return;
}
+ if (!check_type_too_long(vp)) return;
+
/* Build a db structure for this variable */
cp = build_db_struct(vp);
diff -rN -u old-branch-2-0/test/demo/demo.st new-branch-2-0/test/demo/demo.st
--- old-branch-2-0/test/demo/demo.st 2022-11-28 23:13:47.783739439 +0100
+++ new-branch-2-0/test/demo/demo.st 2022-11-28 23:13:47.787739537 +0100
@@ -36,7 +36,11 @@
option +r;
/* control variables and transition points for light control */
+#if 0
+/* trying to assign a long variable now gives a compiler error on 64 bit systems */
long light;
+#endif
+int light;
assign light to LIGHT;
double lightOn;
diff -rN -u old-branch-2-0/test/validate/Makefile new-branch-2-0/test/validate/Makefile
--- old-branch-2-0/test/validate/Makefile 2022-11-28 23:13:47.783739439 +0100
+++ new-branch-2-0/test/validate/Makefile 2022-11-28 23:13:47.787739537 +0100
@@ -11,16 +11,14 @@
SNCFLAGS_vxWorks += -nil-
# Sequence programs and/or object files to create
-SEQS = sncDelay sncEntry sncEntryOpte sncEntryVar sncExitOptx sncOptt sncOpttVar
-PROD_HOST = $(SEQS)
-
-sncDelay_SRCS = sncDelay.st
-sncEntry_SRCS = sncEntry.st
-sncEntryOpte_SRCS = sncEntryOpte.st
-sncEntryVar_SRCS = sncEntryVar.st
-sncExitOptx_SRCS = sncExitOptx.st
-sncOptt_SRCS = sncOptt.st
-sncOpttVar_SRCS = sncOpttVar.st
+PROD += sncDelay
+PROD += sncEntry
+PROD += sncEntryOpte
+PROD += sncEntryVar
+PROD += sncExitOptx
+PROD += sncOptt
+PROD += sncOpttVar
+PROD += tooLong
# Libraries
PROD_LIBS += seq
@@ -30,4 +28,3 @@
include $(TOP)/configure/RULES
#----------------------------------------
# ADD RULES AFTER THIS LINE
-
diff -rN -u old-branch-2-0/test/validate/tooLong.st new-branch-2-0/test/validate/tooLong.st
--- old-branch-2-0/test/validate/tooLong.st 1970-01-01 01:00:00.000000000 +0100
+++ new-branch-2-0/test/validate/tooLong.st 2022-11-28 23:13:47.787739537 +0100
@@ -0,0 +1,27 @@
+/*
+ * Test proper rejection of variables whose type is too long
+ * to allow faithfull representation in CA, i.e. 64 bit types.
+ * On linux-x86_64 this should give error messages for the l and ul
+ * variables. On systems where sizeof(int)==8 (64 bit Windows?)
+ * even i and ui should be rejected.
+ */
+program tooLong
+
+int i;
+assign i to "";
+
+unsigned int ui;
+assign ui to "";
+
+long l;
+assign l to "";
+
+unsigned long ul;
+assign ul to "";
+
+ss tooLong {
+ state xy {
+ when () {
+ } state xy
+ }
+}
patch 41656482809861d993607895eee0b410b4efda3d
Author: ben.franksen@online.de
Date: Wed Apr 6 20:59:29 CEST 2011
* try to make things work on 64 bit system