ANSI C conversion & select() under vxWorks

This commit is contained in:
Jeff Hill
1993-10-04 17:46:55 +00:00
parent c18ff9204b
commit da0e32587f
10 changed files with 1460 additions and 852 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -5,8 +5,8 @@ static char *sccsId = "@(#)acctst.c 1.8\t2/19/93";
*/
#if 1
#define CA_TEST_CHNL "ca:ai_2000"
#define CA_TEST_CHNL4 "ca:ai_2000"
#define CA_TEST_CHNL "fredy"
#define CA_TEST_CHNL4 "fredy"
#else
#if 0
#define CA_TEST_CHNL "ts2:ai0"
@@ -24,6 +24,7 @@ static char *sccsId = "@(#)acctst.c 1.8\t2/19/93";
# if defined(vxWorks)
# include <vxWorks.h>
# include <taskLib.h>
# include <stdio.h>
# endif
#endif
@@ -42,17 +43,32 @@ static char *sccsId = "@(#)acctst.c 1.8\t2/19/93";
#ifdef vxWorks
spacctst()
int spacctst()
{
int acctst();
return taskSpawn("acctst", 200, VX_FP_TASK, 20000, acctst);
return taskSpawn(
"acctst",
200,
VX_FP_TASK,
20000,
acctst,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL,
NULL);
}
#endif
#ifdef vxWorks
acctst()
int acctst()
#else
main()
#endif
@@ -77,7 +93,7 @@ main()
SEVCHK(ca_task_initialize(), "Unable to initialize");
ca_printf("begin\n");
printf("begin\n");
#ifdef VMS
lib$init_timer();
#endif
@@ -181,13 +197,13 @@ main()
SEVCHK(status, NULL);
if (INVALID_DB_REQ(chix1->type))
ca_printf("Failed to locate %s\n", CA_TEST_CHNL);
printf("Failed to locate %s\n", CA_TEST_CHNL);
if (INVALID_DB_REQ(chix2->type))
ca_printf("Failed to locate %s\n", CA_TEST_CHNL);
printf("Failed to locate %s\n", CA_TEST_CHNL);
if (INVALID_DB_REQ(chix3->type))
ca_printf("Failed to locate %s\n", CA_TEST_CHNL);
printf("Failed to locate %s\n", CA_TEST_CHNL);
if (INVALID_DB_REQ(chix4->type))
ca_printf("Failed to locate %s\n", CA_TEST_CHNL4);
printf("Failed to locate %s\n", CA_TEST_CHNL4);
/*
* SEVCHK(status,NULL); if(status == ECA_TIMEOUT) exit();
*/
@@ -198,7 +214,7 @@ main()
pfloat = &ptr->value;
for (i = 0; i < NUM; i++)
ca_printf("Value Returned from build %f\n", pfloat[i]);
printf("Value Returned from build %f\n", pfloat[i]);
#ifdef VMS
lib$init_timer();
@@ -208,7 +224,7 @@ main()
* verify we dont jam up on many uninterrupted
* solicitations
*/
ca_printf("Performing multiple get test...");
printf("Performing multiple get test...");
#ifdef UNIX
fflush(stdout);
#endif
@@ -220,12 +236,12 @@ main()
}
SEVCHK(ca_pend_io(200.0), NULL);
}
ca_printf("done.\n");
printf("done.\n");
/*
* verify we can add many monitors at once
*/
ca_printf("Performing multiple monitor test...");
printf("Performing multiple monitor test...");
#ifdef UNIX
fflush(stdout);
#endif
@@ -255,24 +271,49 @@ main()
SEVCHK(ca_get(DBR_FLOAT,chix4,&temp),NULL);
SEVCHK(ca_pend_io(100.0),NULL);
}
ca_printf("done.\n");
printf("done.\n");
if (VALID_DB_REQ(chix4->type)) {
status = ca_add_event(DBR_FLOAT, chix4, EVENT_ROUTINE, 0xaaaaaaaa, &monix);
status = ca_add_event(
DBR_FLOAT,
chix4,
EVENT_ROUTINE,
(void *)0xaaaaaaaa,
&monix);
SEVCHK(status, NULL);
SEVCHK(ca_clear_event(monix), NULL);
status = ca_add_event(DBR_FLOAT, chix4, EVENT_ROUTINE, 0xaaaaaaaa, &monix);
status = ca_add_event(
DBR_FLOAT,
chix4,
EVENT_ROUTINE,
(void *)0xaaaaaaaa,
&monix);
SEVCHK(status, NULL);
}
if (VALID_DB_REQ(chix4->type)) {
status = ca_add_event(DBR_FLOAT, chix4, EVENT_ROUTINE, 0xaaaaaaaa, &monix);
status = ca_add_event(
DBR_FLOAT,
chix4,
EVENT_ROUTINE,
(void *)0xaaaaaaaa,
&monix);
SEVCHK(status, NULL);
SEVCHK(ca_clear_event(monix), NULL);
}
if (VALID_DB_REQ(chix3->type)) {
status = ca_add_event(DBR_FLOAT, chix3, EVENT_ROUTINE, 0xaaaaaaaa, &monix);
status = ca_add_event(
DBR_FLOAT,
chix3,
EVENT_ROUTINE,
(void *)0xaaaaaaaa,
&monix);
SEVCHK(status, NULL);
status = ca_add_event(DBR_FLOAT, chix3, write_event, 0xaaaaaaaa, &monix);
status = ca_add_event(
DBR_FLOAT,
chix3,
write_event,
(void *)0xaaaaaaaa,
&monix);
SEVCHK(status, NULL);
}
pfloat = (float *) malloc(sizeof(float) * NUM);
@@ -285,13 +326,33 @@ main()
for (i = 0; i < NUM; i++) {
for (j = 0; j < NUM; j++)
sprintf(&pstring[j][0], "%d", j + 100);
SEVCHK(ca_array_put(DBR_STRING, NUM, chix1, pstring), NULL)
SEVCHK(ca_array_get(DBR_FLOAT, NUM, chix1, pfloat), NULL)
SEVCHK(ca_array_get(DBR_DOUBLE, NUM, chix1, pdouble), NULL)
SEVCHK(ca_array_get(DBR_GR_FLOAT, NUM, chix1, pgrfloat), NULL)
SEVCHK(ca_array_put(
DBR_STRING,
NUM,
chix1,
pstring),
NULL)
SEVCHK(ca_array_get(
DBR_FLOAT,
NUM,
chix1,
pfloat),
NULL)
SEVCHK(ca_array_get(
DBR_DOUBLE,
NUM,
chix1,
pdouble),
NULL)
SEVCHK(ca_array_get(
DBR_GR_FLOAT,
NUM,
chix1,
pgrfloat),
NULL)
}
else
abort();
abort(0);
SEVCHK(ca_pend_io(4.0), NULL);
@@ -299,15 +360,15 @@ main()
lib$show_timer();
#endif
for (i = 0; i < NUM; i++) {
ca_printf("Float value Returned from put/get %f\n", pfloat[i]);
ca_printf("Double value Returned from put/get %f\n", pdouble[i]);
ca_printf("GR Float value Returned from put/get %f\n", pgrfloat[i].value);
printf("Float value Returned from put/get %f\n", pfloat[i]);
printf("Double value Returned from put/get %f\n", pdouble[i]);
printf("GR Float value Returned from put/get %f\n", pgrfloat[i].value);
}
for (i = 0; i < 10; i++)
ca_get_callback(DBR_GR_FLOAT, chix1, ca_test_event, NULL);
ca_printf("-- Put/Gets done- waiting for Events --\n");
printf("-- Put/Gets done- waiting for Events --\n");
status = ca_pend_event(60.0);
if (status == ECA_TIMEOUT) {
@@ -315,10 +376,11 @@ main()
free(pfloat);
free(pgrfloat);
exit();
exit(0);
} else
SEVCHK(status, NULL);
return(0);
}
@@ -331,7 +393,7 @@ null_event()
static int i;
if (i++ > 1000) {
ca_printf("1000 occured\n");
printf("1000 occured\n");
i = 0;
}
}
@@ -359,9 +421,9 @@ conn(args)
{
if (args.op == CA_OP_CONN_UP)
ca_printf("Channel On Line [%s]\n", ca_name(args.chid));
printf("Channel On Line [%s]\n", ca_name(args.chid));
else if (args.op == CA_OP_CONN_DOWN)
ca_printf("Channel Off Line [%s]\n", ca_name(args.chid));
printf("Channel Off Line [%s]\n", ca_name(args.chid));
else
ca_printf("Ukn conn ev\n");
printf("Ukn conn ev\n");
}

View File

@@ -1,13 +1,52 @@
static char *sccsId = "@(#)ca_printf.c 1.2\t7/27/92";
/************************************************************************/
/* */
/* L O S A L A M O S */
/* Los Alamos National Laboratory */
/* Los Alamos, New Mexico 87545 */
/* */
/* Copyright, 1986, The Regents of the University of California. */
/* */
/* Author */
/* ------ */
/* Jeff Hill */
/* */
/* History */
/* ------- */
/* */
/*_begin */
/************************************************************************/
/* */
/* Title: channel access TCPIP interface include file */
/* File: ca_printf.c */
/* Environment: VMS, UNIX, VRTX */
/* */
/* */
/* Purpose */
/* ------- */
/* */
/* */
/* */
/* Special comments */
/* ------- -------- */
/* */
/************************************************************************/
/*_end */
static char *sccsId = "$Id$";
#if defined(UNIX) || defined(VMS)
# include <stdio.h>
#else
# if defined(vxWorks)
# include <vxWorks.h>
# include <logLib.h>
# endif
#endif
#ifdef __STDC__
#include <stdarg.h>
#else
#include <varargs.h>
#endif
/*
@@ -18,17 +57,26 @@ static char *sccsId = "@(#)ca_printf.c 1.2\t7/27/92";
* Dump error messages to the appropriate place
*
*/
int
ca_printf(va_alist)
#ifdef __STDC__
int ca_printf(char *pformat, ...)
#else
int ca_printf(va_alist)
va_dcl
#endif
{
va_list args;
char *pformat;
int status;
#ifndef __STDC__
char *pformat;
#endif
#ifdef __STDC__
va_start(args, pformat);
#else
va_start(args);
pformat = va_arg(args, char *);
#endif
#if defined(UNIX) || defined(VMS)
{
@@ -54,8 +102,7 @@ va_dcl
logMsgArgs[2],
logMsgArgs[3],
logMsgArgs[4],
logMsgArgs[5],
logMsgArgs[6]);
logMsgArgs[5]);
}
# else

View File

@@ -22,6 +22,8 @@
/* .08 010493 joh removed `<Trying>' message */
/* .09 090293 joh removed flush from manage_conn */
/* (now handled by the send needed flag) */
/* .10 102093 joh improved broadcast schedualing for */
/* reconnects */
/* */
/*_begin */
/************************************************************************/
@@ -44,7 +46,11 @@ static char *sccsId = "$Id$\t$Date$";
# if defined(VMS)
# else
# if defined(vxWorks)
#include <vxWorks.h>
#include <vxWorks.h>
#include <sockLib.h>
#include <tickLib.h>
#include <sysLib.h>
#include <stdio.h>
# else
@@@@ dont compile @@@@
# endif
@@ -56,6 +62,7 @@ static char *sccsId = "$Id$\t$Date$";
#include <iocmsg.h>
#include <iocinf.h>
/*
*
@@ -67,79 +74,81 @@ static char *sccsId = "$Id$\t$Date$";
* NOTES:
* Lock must be applied while in this routine
*/
#ifdef __STDC__
void manage_conn(int silent)
#else
void manage_conn(silent)
char silent;
int silent;
#endif
{
register chid chix;
register unsigned int retry_cnt = 0;
register unsigned int keepalive_cnt = 0;
struct ioc_in_use *piiu;
chid chix;
unsigned int retry_cnt = 0;
unsigned int keepalive_cnt = 0;
unsigned int retry_cnt_no_handler = 0;
ca_time current;
int i;
current = time(NULL);
for(i=0; i< nxtiiu; i++){
int search_type;
/*
* issue connection heartbeat
*/
for( piiu = (struct ioc_in_use *) iiuList.node.next;
piiu;
piiu = (struct ioc_in_use *) piiu->node.next){
if(iiu[i].next_retry == CA_CURRENT_TIME){
if(!iiu[i].conn_up || i==BROADCAST_IIU){
iiu[i].next_retry =
current + iiu[i].retry_delay;
}
else{
iiu[i].next_retry =
current + CA_RETRY_PERIOD;
}
if(piiu == piiuCast || !piiu->conn_up){
continue;
}
if(iiu[i].next_retry > current)
if(piiu->next_retry == CA_CURRENT_TIME){
piiu->next_retry = current + CA_RETRY_PERIOD;
continue;
}
if(piiu->next_retry > current)
continue;
/*
* periodic keepalive on unused channels
*/
if(i != BROADCAST_IIU && iiu[i].conn_up){
/*
* reset of delay to the next keepalive
* occurs when the message is sent
*/
noop_msg(&iiu[i]);
keepalive_cnt++;
/*
* reset of delay to the next keepalive
* occurs when the message is sent
*/
noop_msg(piiu);
keepalive_cnt++;
}
/*
* allow execution to continue through
* the connection retry code below
* since we may be connected while
* some channels which have not been
* verified to exist on the recently
* booted IOC.
*/
if(!piiuCast){
return;
}
if(piiuCast->next_retry == CA_CURRENT_TIME){
piiuCast->next_retry = current + piiuCast->retry_delay;
}
if(piiuCast->next_retry > current)
return;
if(piiuCast->nconn_tries++ > MAXCONNTRIES)
return;
piiuCast->retry_delay += piiuCast->retry_delay;
piiuCast->next_retry = current + piiuCast->retry_delay;
chix = (chid) &piiuCast->chidlist.node.next;
while(chix = (chid) chix->node.next){
build_msg(chix, DONTREPLY);
retry_cnt++;
if(!(silent || chix->connection_func)){
ca_signal(ECA_CHIDNOTFND, (char *)(chix+1));
retry_cnt_no_handler++;
}
if(iiu[i].nconn_tries++ > MAXCONNTRIES)
continue;
iiu[i].retry_delay += iiu[i].retry_delay;
iiu[i].next_retry = current + iiu[i].retry_delay;
search_type = (i==BROADCAST_IIU? DONTREPLY: DOREPLY);
chix = (chid) &iiu[i].chidlist;
while(chix = (chid) chix->node.next){
if(chix->type != TYPENOTCONN)
continue;
build_msg(chix,search_type);
retry_cnt++;
if(!(silent || chix->connection_func)){
ca_signal(ECA_CHIDNOTFND, (char *)(chix+1));
retry_cnt_no_handler++;
}
}
}
}
if(retry_cnt){
#ifdef TRYING_MESSAGE
@@ -168,12 +177,14 @@ char silent;
* Lock must be applied while in this routine
*
*/
void
mark_server_available(pnet_addr)
#ifdef __STDC__
void mark_server_available(struct in_addr *pnet_addr)
#else
void mark_server_available(pnet_addr)
struct in_addr *pnet_addr;
#endif
{
unsigned port;
int i;
/*
* if timers have expired take care of them
@@ -188,43 +199,17 @@ struct in_addr *pnet_addr;
#endif
#endif
for(i=0;i<nxtiiu;i++)
if( (pnet_addr->s_addr ==
iiu[i].sock_addr.sin_addr.s_addr)){
if(iiu[i].conn_up){
/*
* Check if the conn is down but TCP
* has not informed me by sending a NULL msg
*/
noop_msg(&iiu[i]);
cac_send_msg();
}
else{
/*
* reset the delay to the next retry
*/
iiu[i].next_retry = CA_CURRENT_TIME;
iiu[i].nconn_tries = 0;
iiu[i].retry_delay = CA_RECAST_DELAY;
manage_conn(TRUE);
}
return;
}
if(!piiuCast){
return;
}
/*
* never connected to this IOC before
*
* We end up here when the client starts before the server
*
* It would be best if this used a directed UDP
* reply rather than a broadcast
*/
/*
* reset the retry cnt
*/
iiu[BROADCAST_IIU].nconn_tries = 0;
/*
* This part is very important since many machines
@@ -243,11 +228,11 @@ struct in_addr *pnet_addr;
int status;
status = getsockname(
iiu[BROADCAST_IIU].sock_chan,
&saddr,
piiuCast->sock_chan,
(struct sockaddr *)&saddr,
&saddr_length);
if(status<0)
abort();
abort(0);
port = saddr.sin_port;
}
@@ -256,17 +241,25 @@ struct in_addr *pnet_addr;
int next;
delay = (port&CA_RECAST_PORT_MASK) + CA_RECAST_PERIOD;
iiu[BROADCAST_IIU].retry_delay =
min(iiu[BROADCAST_IIU].retry_delay, delay);
next = time(NULL) + iiu[BROADCAST_IIU].retry_delay;
iiu[BROADCAST_IIU].next_retry =
min(next, iiu[BROADCAST_IIU].next_retry);
next = time(NULL) + delay;
/*
* next retry time most likely
* invalid in this case
*/
if(piiuCast->nconn_tries >= MAXCONNTRIES ||
next < piiuCast->next_retry){
piiuCast->next_retry = next;
piiuCast->retry_delay = CA_RECAST_DELAY;
}
piiuCast->nconn_tries = 0;
}
#ifdef DEBUG
ca_printf("CAC: <Trying ukn online after pseudo random delay=%d sec> ",
iiu[BROADCAST_IIU].retry_delay);
piiuCast->retry_delay);
#ifdef UNIX
fflush(stdout);
#endif

View File

@@ -37,6 +37,7 @@ static char *sccsId = "@(#)convert.c 1.5\t7/27/92";
# define memset(D,V,N) bfill(D,N,V)
#endif
static void no_cvrt();
/*
* Routine we will do later
@@ -44,7 +45,7 @@ static char *sccsId = "@(#)convert.c 1.5\t7/27/92";
*
*
*/
no_cvrt()
static void no_cvrt()
{
ca_printf("Sorry, conversion for that type currently not implemented\n");
exit();
@@ -83,11 +84,20 @@ cvrt_ctrl_double() {no_cvrt();}
*
*
*/
#ifdef __STDC__
cvrt_short(
short *s, /* source */
short *d, /* destination */
int encode, /* cvrt VAX to IEEE if T */
int num /* number of values */
)
#else
cvrt_short(s,d,encode,num)
short *s; /* source */
short *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
short *s; /* source */
short *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
#endif
{
unsigned int i;
@@ -105,11 +115,20 @@ int num; /* number of values */
*
*
*/
cvrt_char(s,d,encode,num)
char *s; /* source */
char *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
#ifdef __STDC__
int cvrt_char(
char *s; /* source */
char *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
)
#else
int cvrt_char(
char *s, /* source */
char *d, /* destination */
int encode, /* cvrt VAX to IEEE if T */
int num /* number of values */
#endif
{
unsigned int i;
@@ -127,11 +146,20 @@ int num; /* number of values */
*
*
*/
cvrt_long(s,d,encode,num)
long *s; /* source */
long *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
#ifdef __STDC__
int cvrt_long(
long *s, /* source */
long *d, /* destination */
int encode, /* cvrt VAX to IEEE if T */
int num /* number of values */
)
#else
int cvrt_long(s,d,encode,num)
long *s; /* source */
long *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
#endif
{
unsigned int i;
@@ -149,11 +177,20 @@ int num; /* number of values */
*
*
*/
cvrt_enum(s,d,encode,num)
short *s; /* source */
short *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
#ifdef __STDC__
int cvrt_enum(
short *s, /* source */
short *d, /* destination */
int encode, /* cvrt VAX to IEEE if T */
int num /* number of values */
)
#else
int cvrt_enum(s,d,encode,num)
short *s; /* source */
short *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
#endif
{
unsigned int i;
@@ -173,11 +210,19 @@ int num; /* number of values */
* code but better performance.
*
*/
cvrt_float(s,d,encode,num)
#ifdef __STDC__
int cvrt_float(
float *s, /* source */
float *d, /* destination */
int encode, /* cvrt VAX to IEEE if T*/
int num /* number of values */
#else
int cvrt_float(s,d,encode,num)
float *s; /* source */
float *d; /* destination */
int encode; /* cvrt VAX to IEEE if T*/
int num; /* number of values */
#endif
{
unsigned int i;
@@ -206,11 +251,20 @@ int num; /* number of values */
*
*
*/
cvrt_double(s,d,encode,num)
double *s; /* source */
double *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
#ifdef __STDC__
int cvrt_double(
double *s, /* source */
double *d, /* destination */
int encode, /* cvrt VAX to IEEE if T */
int num /* number of values */
)
#else
int cvrt_double(s,d,encode,num)
double *s; /* source */
double *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
#endif
{
unsigned int i;
@@ -231,11 +285,20 @@ int num; /* number of values */
*
*
*/
cvrt_string(s,d,encode,num)
char *s; /* source */
char *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
#ifdef __STDC__
int cvrt_string(
char *s, /* source */
char *d, /* destination */
int encode, /* cvrt VAX to IEEE if T */
int num /* number of values */
)
#else
int cvrt_string(s,d,encode,num)
char *s; /* source */
char *d; /* destination */
int encode; /* cvrt VAX to IEEE if T */
int num; /* number of values */
#endif
{
unsigned int i;
@@ -264,11 +327,20 @@ int num; /* number of values */
** format;
****************************************************************************/
#ifdef __STDC__
cvrt_sts_string(
struct dbr_sts_string *s, /* source */
struct dbr_sts_string *d, /* destination */
int encode, /* do VAX to IEEE */
int num /* number of values */
)
#else
cvrt_sts_string(s,d,encode,num)
struct dbr_sts_string *s; /* source */
struct dbr_sts_string *d; /* destination */
int encode; /* do VAX to IEEE */
int num; /* number of values */
#endif
{
/* convert ieee to vax format or vax to ieee */
@@ -296,11 +368,20 @@ int num; /* number of values */
** format
****************************************************************************/
#ifdef __STDC__
cvrt_sts_short(
struct dbr_sts_int *s, /* source */
struct dbr_sts_int *d, /* destination */
int encode, /* if true; vax to ieee */
int num /* number of values */
)
#else
cvrt_sts_short(s,d,encode,num)
struct dbr_sts_int *s; /* source */
struct dbr_sts_int *d; /* destination */
int encode; /* if true, vax to ieee */
int num; /* number of values */
#endif
{
register i;
short *sval_ptr,*dval_ptr; /* ptrs to source, destination */
@@ -343,11 +424,20 @@ int num; /* number of values */
** format;
****************************************************************************/
#ifdef __STDC__
cvrt_sts_float(
struct dbr_sts_float *s, /* source */
struct dbr_sts_float *d, /* destination */
int encode, /* it true, vax to ieee */
int num /* number of values */
)
#else
cvrt_sts_float(s,d,encode,num)
struct dbr_sts_float *s; /* source */
struct dbr_sts_float *d; /* destination */
int encode; /* it true, vax to ieee */
int num; /* number of values */
#endif
{
register i;
float *sval_ptr,*dval_ptr;
@@ -446,11 +536,20 @@ int num; /* number of values */
**
****************************************************************************/
cvrt_gr_short(s,d,encode,num)
#ifdef __STDC__
int cvrt_gr_short(
struct dbr_gr_int *s, /* source */
struct dbr_gr_int *d, /* destination */
int encode, /* if true, vax to ieee */
int num /* number of values */
)
#else
int cvrt_gr_short(s,d,encode,num)
struct dbr_gr_int *s; /* source */
struct dbr_gr_int *d; /* destination */
int encode; /* if true, vax to ieee */
int num; /* number of values */
#endif
{
register i;
short *sval_ptr,*dval_ptr;
@@ -499,11 +598,20 @@ int num; /* number of values */
** format;
****************************************************************************/
cvrt_gr_float(s,d,encode,num)
#ifdef __STDC__
int cvrt_gr_float(
struct dbr_gr_float *s, /* source */
struct dbr_gr_float *d, /* destination */
int encode, /* if true, vax to ieee */
int num /* number of values */
)
#else
int cvrt_gr_float(s,d,encode,num)
struct dbr_gr_float *s; /* source */
struct dbr_gr_float *d; /* destination */
int encode; /* if true, vax to ieee */
int num; /* number of values */
#endif
{
register i;
float *sval_ptr,*dval_ptr;
@@ -577,11 +685,20 @@ int num; /* number of values */
**
****************************************************************************/
cvrt_ctrl_short(s,d,encode,num)
#ifdef __STDC__
int cvrt_ctrl_short(
struct dbr_ctrl_int *s, /* source */
struct dbr_ctrl_int *d, /* destination */
int encode, /* if true, vax to ieee */
int num /* number of values */
)
#else
int cvrt_ctrl_short(s,d,encode,num)
struct dbr_ctrl_int *s; /* source */
struct dbr_ctrl_int *d; /* destination */
int encode; /* if true, vax to ieee */
int num; /* number of values */
#endif
{
register i;
short *sval_ptr,*dval_ptr;
@@ -633,11 +750,20 @@ int num; /* number of values */
** format;
****************************************************************************/
cvrt_ctrl_float(s,d,encode,num)
#ifdef __STDC__
int cvrt_ctrl_float(
struct dbr_ctrl_float *s, /* source */
struct dbr_ctrl_float *d, /* destination */
int encode, /* if true, vax to ieee */
int num /* number of values */
)
#else
int cvrt_ctrl_float(s,d,encode,num)
struct dbr_ctrl_float *s; /* source */
struct dbr_ctrl_float *d; /* destination */
int encode; /* if true, vax to ieee */
int num; /* number of values */
#endif
{
register i;
float *sval_ptr,*dval_ptr;
@@ -712,11 +838,20 @@ int num; /* number of values */
** format;
****************************************************************************/
#ifdef __STDC__
cvrt_ctrl_enum(
struct dbr_ctrl_enum *s, /* source */
struct dbr_ctrl_enum *d, /* destination */
int encode, /* if true, vax to ieee */
int num /* number of values */
)
#else
cvrt_ctrl_enum(s,d,encode,num)
struct dbr_ctrl_enum *s; /* source */
struct dbr_ctrl_enum *d; /* destination */
int encode; /* if true, vax to ieee */
int num; /* number of values */
#endif
{
register i;
short *sval_ptr,*dval_ptr;

View File

@@ -33,7 +33,7 @@
/************************************************************************/
/*_end */
static char *sccsId = "@(#)flow_control.c 1.7\t6/2/93";
static char *sccsId = "$Id$";
#if defined(vxWorks)
# include <vxWorks.h>
@@ -75,9 +75,12 @@ static char *sccsId = "@(#)flow_control.c 1.7\t6/2/93";
* suppress monitors if we are behind
* (an update is sent when we catch up)
*/
void
flow_control(piiu)
struct ioc_in_use *piiu;
#ifdef __STDC__
void flow_control(struct ioc_in_use *piiu)
#else
void flow_control(piiu)
struct ioc_in_use *piiu;
#endif
{
unsigned nbytes;
register int status;
@@ -89,9 +92,11 @@ flow_control(piiu)
*/
status = socket_ioctl(piiu->sock_chan,
FIONREAD,
&nbytes);
(int)&nbytes);
if (status < 0) {
LOCK;
close_ioc(piiu);
UNLOCK;
return;
}

File diff suppressed because it is too large Load Diff

View File

@@ -79,6 +79,10 @@ static char *sccsId = "$Id$\t$Date$";
# include <errno.h>
# include <types.h>
# include <socket.h>
# include <sockLib.h>
# include <ioLib.h>
# include <string.h>
# include <errnoLib.h>
# include <in.h>
# else
@@@@ dont compile @@@@
@@ -86,8 +90,12 @@ static char *sccsId = "$Id$\t$Date$";
# endif
#endif
#include <ellLib.h>
#ifdef vxWorks
#include <taskwd.h>
#endif
#include <cadef.h>
#include <iocmsg.h>
#include <iocinf.h>
#include <os_depen.h>
/*
@@ -105,9 +113,13 @@ ELLLIST client_list;
static
char buf[MAX_UDP];
static int clean_client();
static int ca_repeater();
int local_addr();
#ifdef __STDC__
LOCAL int clean_client(struct one_client *pclient);
LOCAL int ca_repeater();
#else
LOCAL int clean_client();
LOCAL int ca_repeater();
#endif
#define NTRIES 100
@@ -121,7 +133,7 @@ int local_addr();
#ifdef VMS
main()
#else
ca_repeater_task()
int ca_repeater_task()
#endif
{
#if REPEATER_RETRY
@@ -163,8 +175,7 @@ ca_repeater_task()
*
*
*/
static int
ca_repeater()
LOCAL int ca_repeater()
{
int status;
int size;
@@ -195,11 +206,11 @@ ca_repeater()
__FILE__);
}
memset(&bd,0,sizeof bd);
memset((char *)&bd,0,sizeof bd);
bd.sin_family = AF_INET;
bd.sin_addr.s_addr = htonl(INADDR_ANY);
bd.sin_port = htons(CA_CLIENT_PORT);
status = bind(sock, &bd, sizeof bd);
status = bind(sock, (struct sockaddr *)&bd, sizeof bd);
if(status<0){
if(MYERRNO != EADDRINUSE){
ca_printf("CA Repeater: unexpected bind fail %d\n",
@@ -230,7 +241,7 @@ ca_repeater()
buf,
sizeof buf,
0,
&from,
(struct sockaddr *)&from,
&from_size);
if(size > 0){
@@ -246,7 +257,7 @@ ca_repeater()
buf,
size,
0,
&pclient->from,
(struct sockaddr *)&pclient->from,
sizeof pclient->from);
if(status < 0){
ca_printf("CA Repeater: fanout err %d\n",
@@ -263,7 +274,7 @@ ca_repeater()
/*
* If this is a processor local message then add to
* the list of clients to repeat to if not there
* allready
* already
*/
for( pclient = (struct one_client *)
client_list.node.next;
@@ -278,22 +289,25 @@ ca_repeater()
malloc(sizeof *pclient);
if(pclient){
pclient->from = from;
ellAdd(&client_list, pclient);
ellAdd( &client_list,
&pclient->node);
#ifdef DEBUG
ca_printf("Added %x %d\n", from.sin_port, size);
ca_printf(
"Added %x %d\n",
from.sin_port, size);
#endif
}
}
memset(&confirm, NULL, sizeof confirm);
memset((char *)&confirm, NULL, sizeof confirm);
confirm.m_cmmd = htons(REPEATER_CONFIRM);
confirm.m_available = local.sin_addr.s_addr;
status = sendto(
sock,
&confirm,
(char *)&confirm,
sizeof confirm,
0,
&from, /* reflect back to sender */
(struct sockaddr *)&from, /* back to sender */
sizeof from);
if(status != sizeof confirm){
ca_printf("CA Repeater: confirm err %d\n",
@@ -324,9 +338,12 @@ ca_repeater()
* check to see if this client is still around
*
*/
static int
clean_client(pclient)
#ifdef __STDC__
LOCAL int clean_client(struct one_client *pclient)
#else
LOCAL int clean_client(pclient)
struct one_client *pclient;
#endif
{
int port = pclient->from.sin_port;
int sock;
@@ -344,11 +361,11 @@ struct one_client *pclient;
return ERROR;
}
memset(&bd,0,sizeof bd);
memset((char *)&bd,0,sizeof bd);
bd.sin_family = AF_INET;
bd.sin_addr.s_addr = htonl(INADDR_ANY);
bd.sin_port = port;
status = bind(sock, &bd, sizeof bd);
status = bind(sock, (struct sockaddr *)&bd, sizeof bd);
if(status<0){
if(MYERRNO == EADDRINUSE)
present = TRUE;
@@ -360,7 +377,7 @@ struct one_client *pclient;
socket_close(sock);
if(!present){
ellDelete(&client_list, pclient);
ellDelete(&client_list, &pclient->node);
free(pclient);
#ifdef DEBUG
ca_printf("Deleted\n");

View File

@@ -68,7 +68,7 @@
/************************************************************************/
/*_end */
static char *sccsId = "@(#)service.c 1.17\t6/2/93";
static char *sccsId = "$Id$";
#if defined(VMS)
# include <sys/types.h>
@@ -79,6 +79,8 @@ static char *sccsId = "@(#)service.c 1.17\t6/2/93";
# include <stdio.h>
# else
# if defined(vxWorks)
# include <string.h>
# include <stdio.h>
# include <vxWorks.h>
# else
@@@@ dont compile @@@@
@@ -86,17 +88,27 @@ static char *sccsId = "@(#)service.c 1.17\t6/2/93";
# endif
#endif
#include <os_depen.h>
#include <cadef.h>
#include <db_access.h>
#include <os_depen.h>
#include <iocmsg.h>
#include <iocinf.h>
#include <db_access.h>
#include <net_convert.h>
static void reconnect_channel();
void ca_request_event();
#ifdef __STDC__
#define BUFSTAT ca_printf("CAC: expected %d left %d\n",msgcnt,*pbufcnt);
LOCAL void reconnect_channel(
struct extmsg *hdrptr,
struct in_addr *pnet_addr
);
#else
LOCAL void reconnect_channel();
#endif
#define BUFSTAT ca_printf("CAC: expected %d left %d\n",msgcnt,*pbufcnt);
@@ -106,21 +118,29 @@ void ca_request_event();
*
*
*/
int
post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
register struct extmsg *hdrptr;
register long *pbufcnt;
struct in_addr *pnet_addr;
struct ioc_in_use *piiu;
#ifdef __STDC__
int post_msg(
struct extmsg *hdrptr,
long *pbufcnt,
struct in_addr *pnet_addr,
struct ioc_in_use *piiu
)
#else
int post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
struct extmsg *hdrptr;
long *pbufcnt;
struct in_addr *pnet_addr;
struct ioc_in_use *piiu;
#endif
{
evid monix;
long msgcnt;
register void *t_available;
register unsigned short t_postsize;
register unsigned short t_cmmd;
register chtype t_type;
register unsigned short t_count;
void *t_available;
unsigned short t_postsize;
unsigned short t_cmmd;
chtype t_type;
unsigned short t_count;
int status;
@@ -200,8 +220,8 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
UNLOCKEVENTS;
}
LOCK;
ellDelete(&pend_read_list, monix);
ellAdd(&free_event_list, monix);
ellDelete(&pend_read_list, &monix->node);
ellAdd(&free_event_list, &monix->node);
UNLOCK;
piiu->outstanding_ack_count--;
@@ -225,8 +245,8 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
*/
if (!t_postsize) {
LOCK;
ellDelete(&monix->chan->eventq, monix);
ellAdd(&free_event_list, monix);
ellDelete(&monix->chan->eventq, &monix->node);
ellAdd(&free_event_list, &monix->node);
UNLOCK;
piiu->outstanding_ack_count--;
@@ -287,8 +307,17 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
chan = bucketLookupItem(pBucket, hdrptr->m_cid);
UNLOCK;
if(!chan){
ca_signal(ECA_INTERNAL,
"bad client channel id from server");
if(t_cmmd == IOC_READ_BUILD){
printf(
"Stale build reply from %s with id %x ignored",
host_from_addr(pnet_addr),
hdrptr->m_cid);
UNLOCK;
}
else{
ca_signal(ECA_INTERNAL,
"bad client channel id from server");
}
break;
}
@@ -323,8 +352,8 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
t_count);
#else
memcpy(
t_available,
hdrptr + 1,
(char *) t_available,
(char *) (hdrptr + 1),
size);
#endif
@@ -375,33 +404,13 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
break;
case IOC_NOT_FOUND:
{
chid chix = (chid) t_available;
struct ioc_in_use *piiu = &iiu[chix->iocix];
LOCK;
ellDelete(&piiu->chidlist, chix);
ellAdd(&iiu[BROADCAST_IIU].chidlist, chix);
chix->iocix = BROADCAST_IIU;
if (!piiu->chidlist.count)
close_ioc(piiu);
/*
* reset the delay to the next retry or keepalive
*/
iiu[BROADCAST_IIU].next_retry = CA_CURRENT_TIME;
iiu[BROADCAST_IIU].nconn_tries = 0;
manage_conn(TRUE);
UNLOCK;
break;
}
case IOC_CLEAR_CHANNEL:
{
chid chix = (chid) t_available;
struct ioc_in_use *piiu = &iiu[chix->iocix];
register evid monix;
chid chix = (chid) t_available;
struct ioc_in_use *piiu = chix->piiu;
register evid monix;
LOCK;
@@ -413,11 +422,15 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
monix;
monix = (evid) monix->node.next)
if (monix->chan == chix) {
ellDelete(&pend_read_list, monix);
ellAdd(&free_event_list, monix);
ellDelete(
&pend_read_list,
&monix->node);
ellAdd(
&free_event_list,
&monix->node);
}
ellConcat(&free_event_list, &chix->eventq);
ellDelete(&piiu->chidlist, chix);
ellDelete(&piiu->chidlist, &chix->node);
status = bucketRemoveItem(pBucket, chix->cid, chix);
if(status != BUCKET_SUCCESS){
ca_signal(
@@ -426,8 +439,9 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
}
free(chix);
piiu->outstanding_ack_count--;
if (!piiu->chidlist.count)
if (!piiu->chidlist.count){
close_ioc(piiu);
}
UNLOCK;
break;
}
@@ -457,7 +471,7 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
sprintf(context,
"detected by: %s for: %s",
name,
hdrptr + 2);
(char *)(hdrptr + 2));
}
else{
sprintf(context, "detected by: %s", name);
@@ -537,16 +551,23 @@ post_msg(hdrptr, pbufcnt, pnet_addr, piiu)
* LOCK must be on
*
*/
static void reconnect_channel(hdrptr,pnet_addr)
register struct extmsg *hdrptr;
struct in_addr *pnet_addr;
#ifdef __STDC__
LOCAL void reconnect_channel(
struct extmsg *hdrptr,
struct in_addr *pnet_addr
)
#else
LOCAL void reconnect_channel(hdrptr,pnet_addr)
struct extmsg *hdrptr;
struct in_addr *pnet_addr;
#endif
{
chid chan;
unsigned short newiocix;
evid pevent;
int status;
enum channel_state prev_cs;
struct ioc_in_use *chpiiu;
IIU *allocpiiu;
IIU *chpiiu;
/*
* ignore broadcast replies for deleted channels
@@ -568,7 +589,13 @@ struct in_addr *pnet_addr;
return;
}
chpiiu = &iiu[chan->iocix];
chpiiu = chan->piiu;
if(!chpiiu){
ca_printf("cast reply to local channel??\n");
UNLOCK;
return;
}
if (chan->state == cs_conn) {
@@ -591,7 +618,7 @@ struct in_addr *pnet_addr;
sprintf(
sprintf_buf,
"Channel: %s Accepted: %s Rejected: %s ",
chan + 1,
(char *)(chan + 1),
acc,
rej);
ca_signal(ECA_DBLCHNL, sprintf_buf);
@@ -616,12 +643,13 @@ struct in_addr *pnet_addr;
status = alloc_ioc (
pnet_addr,
IPPROTO_TCP,
&newiocix
);
&allocpiiu);
if(status != ECA_NORMAL){
ca_printf("CAC: ... %s ...\n", ca_message(status));
ca_printf("CAC: for %s on %s\n", chan+1, host_from_addr(pnet_addr));
ca_printf("CAC: ignored search reply- proceeding\n");
ca_printf( "CAC: ... %s ...\n", ca_message(status));
ca_printf( "CAC: for %s on %s\n",
chan+1,
host_from_addr(pnet_addr));
ca_printf( "CAC: ignored search reply- proceeding\n");
UNLOCK;
return;
}
@@ -631,18 +659,16 @@ struct in_addr *pnet_addr;
chan->count = ntohs(hdrptr->m_count);
chan->id.sid = hdrptr->m_cid;
if(chan->iocix != newiocix){
struct ioc_in_use *chpiiu;
if(chpiiu != allocpiiu){
/*
* The address changed (or was found for the first time)
*/
if(chan->iocix != BROADCAST_IIU)
if(chpiiu != piiuCast)
ca_signal(ECA_NEWADDR, (char *)(chan+1));
chpiiu = &iiu[chan->iocix];
ellDelete(&chpiiu->chidlist, chan);
chan->iocix = newiocix;
ellAdd(&iiu[newiocix].chidlist, chan);
ellDelete(&chpiiu->chidlist, &chan->node);
chan->piiu = chpiiu = allocpiiu;
ellAdd(&chpiiu->chidlist, &chan->node);
}
/*
@@ -658,7 +684,7 @@ struct in_addr *pnet_addr;
* over TCP so problems with duplicate UDP port
* after reboot go away
*/
issue_claim_channel(&iiu[chan->iocix], chan);
issue_claim_channel(chpiiu, chan);
/*
* NOTE: monitor and callback reissue must occur prior to calling
@@ -710,9 +736,12 @@ struct in_addr *pnet_addr;
*
*
*/
void
cac_io_done(lock)
#ifdef __STDC__
void cac_io_done(int lock)
#else
void cac_io_done(lock)
int lock;
#endif
{
register struct pending_io_event *pioe;

View File

@@ -14,17 +14,21 @@
*
*/
static char *sccsId = "@(#)test_event.c 1.6\t7/27/92";
static char *sccsId = "$Id$";
/* System includes */
#include <cadef.h>
#include <db_access.h>
#include <cadef.h>
#include <iocmsg.h>
#include <iocinf.h>
void
ca_test_event(args)
#ifdef __STDC__
void ca_test_event(struct event_handler_args args)
#else
void ca_test_event(args)
struct event_handler_args args;
#endif
{
ca_printf("CAC: ~~~### in test event for [%s] ###~~~\n",args.chid+1);
ca_printf("CAC: User argument\t%x\n", args.usr);