aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@bfcf8e34-485d-4d46-a995-1fd6fa6fb178>2003-03-10 11:07:23 +0000
committertradke <tradke@bfcf8e34-485d-4d46-a995-1fd6fa6fb178>2003-03-10 11:07:23 +0000
commita066e1765252c042f734cc0b387d686774319d47 (patch)
tree6b243406596da828bc7fa6cafb1853b479231f2d
parent97392d54bd3dd0ff23688076bb4f6d454fdf4685 (diff)
Removed an ugly artefact where a union was used to convert a 'const cGH*'
pointer into 'cGH *' which was required by the old flesh's reduction API. This API has been fixed now. You need to update the flesh for this. git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IsoSurfacer/trunk@70 bfcf8e34-485d-4d46-a995-1fd6fa6fb178
-rw-r--r--src/IsoSurfacer.c123
-rw-r--r--src/Sockets.c216
2 files changed, 125 insertions, 214 deletions
diff --git a/src/IsoSurfacer.c b/src/IsoSurfacer.c
index 3e3f120..f779eb9 100644
--- a/src/IsoSurfacer.c
+++ b/src/IsoSurfacer.c
@@ -1,14 +1,14 @@
-/*@@
+/*@@
@file IsoSurfacer.c
@date Wed Oct 8 11:30:45 MET 2000
@author Joe Blow
- @desc
+ @desc
Gutted original isosurfacer code from SC97.
Has completely new implementation for marching
- cubes and sockets are integrated in Sockets.c
+ cubes and sockets are integrated in Sockets.c
rather than coming from TCP++ or other external
modules.
- @enddesc
+ @enddesc
@@*/
#include <stdio.h>
@@ -77,7 +77,7 @@ static int IsoSurfacerHandleCommands(const cGH *GH)
/*
0)For each command bcast catenated string to all
processors
-
+
Command to change existing isovalue is of format
"isosurf",<gridname>[<instance>],<newvalue>
1) Select GF
@@ -133,7 +133,7 @@ static int IsoSurfacerHandleCommands(const cGH *GH)
new_isovalue = isovalue;
}
- tmpval=new_isovalue;
+ tmpval=new_isovalue;
CACTUS_MPI_ERROR(MPI_Bcast(&tmpval,1,
PUGH_MPI_REAL,0, /* ugh. nor REAL8 */
pughGH->PUGH_COMM_WORLD));
@@ -144,7 +144,7 @@ static int IsoSurfacerHandleCommands(const cGH *GH)
/* Steer the parameter */
CCTK_ParameterSet("isovalue","isosurfacer",stringval);
}
-#else
+#else
if(Iso_PollCommand(GH,&command)){
if (CCTK_Equals (verbose, "full"))
{
@@ -165,10 +165,10 @@ static int doIso(int vindex, const cGH *GH, isosurfacerGH *myGH)
if(!myGH->RunIsoSurfacer) return 0;
- fullname = CCTK_FullName (vindex);
+ fullname = CCTK_FullName (vindex);
/* printf("Check doIso: fullname[%s]:[%s]",fullname,myGH->funcName);*/
if(CCTK_Equals(fullname,myGH->funcName)){
- if(myGH->firstIteration<=GH->cctk_iteration &&
+ if(myGH->firstIteration<=GH->cctk_iteration &&
!((GH->cctk_iteration-myGH->firstIteration) % myGH->outfreq)){
free(fullname);
return 1;
@@ -189,19 +189,10 @@ static void computeIso(int vindex, const cGH *GH, isosurfacerGH *myGH)
int nx,ny,nz;
CCTK_REAL *xcoords,*ycoords,*zcoords,*data;
int timelevel=0;
- /*** FIXME: can CCTK_Reduce() have a 'const cGH *' parameter ?? ***/
- union
- {
- const cGH *const_ptr;
- cGH *non_const_ptr;
- } GH_fake_const;
-
-
- GH_fake_const.const_ptr = GH;
if(!myGH->RunIsoSurfacer) return; /* not running */
-
+
fullname = CCTK_FullName (vindex);
data = (CCTK_REAL *) GH->data [vindex][timelevel];
nx=GH->cctk_lsh[0]; ny=GH->cctk_lsh[1]; nz=GH->cctk_lsh[2];
@@ -224,13 +215,11 @@ static void computeIso(int vindex, const cGH *GH, isosurfacerGH *myGH)
if(myGH->formats & (SOCK|ISOHDF5|BIN)){
int handle;
handle = CCTK_ReductionHandle ("minimum");
- CCTK_Reduce (GH_fake_const.non_const_ptr, 0,handle,1,CCTK_VARIABLE_REAL,
- &(myGH->minval),1, vindex);
+ CCTK_Reduce (GH, 0,handle,1,CCTK_VARIABLE_REAL, &myGH->minval,1, vindex);
handle = CCTK_ReductionHandle ("maximum");
- CCTK_Reduce (GH_fake_const.non_const_ptr, 0, handle, 1, CCTK_VARIABLE_REAL,
- &(myGH->maxval), 1, vindex);
+ CCTK_Reduce (GH, 0, handle, 1, CCTK_VARIABLE_REAL, &myGH->maxval, 1, vindex);
}
-
+
if (CCTK_MyProc (GH) == 0){
CCTK_INT4 tmppolys[3] = {0,0,0};
CCTK_REAL4 tmpverts[3] = {0.0,0.0,0.0};
@@ -245,31 +234,31 @@ static void computeIso(int vindex, const cGH *GH, isosurfacerGH *myGH)
if (CCTK_Equals (verbose, "full"))
printf(" | IsoSurfacer: GF=%s, value %f,",
fullname, myGH->isovalue);
-
+
if(myGH->totals.nverts > 0) {
-
+
if (CCTK_Equals (verbose, "full"))
printf("%d vertices, %d triangles\n", myGH->totals.nverts, myGH->totals.npolys);
-
+
if(myGH->formats & BIN)
WriteBin(GH, &myGH->totals, myGH, fullname, myGH->isovalue);
-
+
if(myGH->formats & ASCII)
WriteASCII(GH, &myGH->totals, fullname, myGH->isovalue);
-
+
if(myGH->formats & UCD)
WriteUCD(GH, &myGH->totals,fullname, myGH->isovalue);
-
+
if(myGH->formats & VRML)
WriteVRML(GH, &myGH->totals, fullname,myGH->isovalue);
-
+
/* !!!!!!!!!!!!!!!!!! what is J representing???? */
if(myGH->formats & SOCK)
WriteSock(GH, &myGH->totals,myGH,fullname,0, myGH->isovalue);
-
+
if(myGH->formats & ISOHDF5)
WriteHDF5(GH, &myGH->totals,myGH,fullname,0, myGH->isovalue);
-
+
}
else
{
@@ -277,7 +266,7 @@ static void computeIso(int vindex, const cGH *GH, isosurfacerGH *myGH)
"No isosurface for '%s' isolevel %f",
fullname, myGH->isovalue);
}
-
+
/* !!!!!!!!!!!!!!!! Why the hell are we doing this? !!!!!!!!!!!! */
if(polybackup || vertbackup){ /* copy back datastructures */
myGH->totals.polys=polybackup;
@@ -304,15 +293,15 @@ int IsoSurfacer (const cGH *GH)
IsoSurfacerHandleCommands (GH);
myGH->isovalue=isovalue; /* take the contents of the "steered" isosurface value and put it here */
/* do a check for new isosurfaces */
- /* Perhaps do a bcast for "changed" flags.
+ /* Perhaps do a bcast for "changed" flags.
which are embedded in each iso. */
/* for each Grid */
for (i = retval = 0, n = CCTK_NumVars (); i < n; i++)
{
- if (! doIso (i, GH, myGH))
+ if (! doIso (i, GH, myGH))
{
- continue;
+ continue;
}
if (CCTK_QueryGroupStorageI(GH,CCTK_GroupIndexFromVarI(i)))
{
@@ -323,7 +312,7 @@ int IsoSurfacer (const cGH *GH)
{
CCTK_VWarn (9, __LINE__, __FILE__, CCTK_THORNSTRING,
"No storage assigned for '%s'", CCTK_VarName (i));
- }
+ }
}
return (retval);
@@ -334,14 +323,14 @@ int IsoSurfacer (const cGH *GH)
void CollectData(const cGH *GH, polypatch *perprocessor, polypatch *totals) {
DECLARE_CCTK_PARAMETERS
#ifdef CCTK_MPI
-
+
/* Collect the isosurface data onto processor 0 */
/* First collect the numbers of vertices (MPI_Gather)*/
/* Then the vertices themselves (MPI_Gatherv)*/
/* Then the number of polygons (MPI_Gather)*/
/* Then the polygon list. This needs to be offset by the number of
vertices ahead of me, so do that after collection. */
-
+
static int a, b;
static int *vcount = NULL;
static int *pcount = NULL;
@@ -352,7 +341,7 @@ void CollectData(const cGH *GH, polypatch *perprocessor, polypatch *totals) {
static CCTK_INT4 my_vpcount [2];
static CCTK_INT4 *vpcount = NULL;
pGH *pughGH;
-
+
pughGH = PUGH_pGH (GH);
/* Allocate temporary arrays for the MPI_Gatherv() operation */
if(pughGH->myproc == 0) {
@@ -364,41 +353,41 @@ void CollectData(const cGH *GH, polypatch *perprocessor, polypatch *totals) {
pdispl = &vcount[3*pughGH->nprocs];
}
}
-
+
/* **** Gather counts of vertex and polygon lists in one wash */
my_vpcount [0] = 3*perprocessor->nverts;
my_vpcount [1] = 3*perprocessor->npolys;
CACTUS_MPI_ERROR (MPI_Gather (my_vpcount, 2, PUGH_MPI_INT4, vpcount, 2,
PUGH_MPI_INT4, 0, pughGH->PUGH_COMM_WORLD));
-
+
/* Allocate for the vertices */
if(pughGH->myproc == 0){
totals->nverts = 0;
totals->npolys = 0;
-
+
for (a = 0; a < pughGH->nprocs; a++) {
/* now sort out the vcounts and pcounts into the int-arrays
used in MPI_Gatherv() */
vcount [a] = vpcount [2*a + 0];
pcount [a] = vpcount [2*a + 1];
-
+
/* compute the displacements and total number of elements */
vdispl[a] = totals->nverts;
pdispl[a] = totals->npolys;
totals->nverts += vcount[a];
totals->npolys += pcount[a];
}
-
+
totals->nverts /= 3;
totals->npolys /= 3;
if(compute_normals)
totals->nnorms=totals->nverts;
else
totals->nnorms=0;
-
+
/*
Kludge:
- Allocate 3 more than necessary so as to divert
+ Allocate 3 more than necessary so as to divert
the output of processors
with nverts=0 to a dummy area in the upper part of totals->verts.
Otherwise the MPI_Gatherv routine gives lots of problems.
@@ -415,19 +404,19 @@ void CollectData(const cGH *GH, polypatch *perprocessor, polypatch *totals) {
if(lastNpolys < totals->npolys){
REALLOC(totals->polys, 3+3*totals->npolys, CCTK_INT4);
lastNpolys = totals->npolys;
- }
+ }
} /* end processor 0 setup */
-
+
/* Gather the vertex lists from all processors */
CACTUS_MPI_ERROR (MPI_Gatherv (perprocessor->verts, perprocessor->nverts*3,
PUGH_MPI_REAL4, totals->verts, vcount, vdispl, PUGH_MPI_REAL4,
0, pughGH->PUGH_COMM_WORLD));
-
+
/* Gather the polygon lists from all processors */
CACTUS_MPI_ERROR (MPI_Gatherv (perprocessor->polys, perprocessor->npolys*3,
PUGH_MPI_INT4, totals->polys, pcount, pdispl, PUGH_MPI_INT4,
0, pughGH->PUGH_COMM_WORLD));
- if(compute_normals){
+ if(compute_normals){
CACTUS_MPI_ERROR (MPI_Gatherv (perprocessor->norms, perprocessor->nnorms*3,
PUGH_MPI_REAL4, totals->norms, vcount, vdispl, PUGH_MPI_REAL4,
0, pughGH->PUGH_COMM_WORLD));
@@ -445,7 +434,7 @@ void CollectData(const cGH *GH, polypatch *perprocessor, polypatch *totals) {
}
}
}
-
+
#else /* !MPI */
GH = GH;
*totals = *perprocessor;
@@ -454,8 +443,8 @@ void CollectData(const cGH *GH, polypatch *perprocessor, polypatch *totals) {
/**************************************************************/
-int IsoWriteDataToClients(char *metadata,
- CCTK_INT8 size,
+int IsoWriteDataToClients(char *metadata,
+ CCTK_INT8 size,
IsoType type,
void *data);
@@ -478,20 +467,20 @@ void WriteSock(const cGH *GH, polypatch *totals, isosurfacerGH *myGH,
fullname,myGH->isovalue,
GH->cctk_iteration,
myGH->minval,myGH->maxval);
- /*puts("sock out+++++++++++++++++");
- puts(tmpstring); */
+ /*puts("sock out+++++++++++++++++");
+ puts(tmpstring); */
/********Now write vertices**********/
*tmpstring='v';
verts = totals->nverts > 0 ? totals->verts : tmpverts;
- IsoWriteDataToClients(tmpstring,
- 3*totals->nverts,
+ IsoWriteDataToClients(tmpstring,
+ 3*totals->nverts,
Int32,
(CCTK_INT4 *)verts);
/********Now write polygons**********/
*tmpstring='c';
polys = totals->npolys > 0 ? totals->polys : tmppolys;
- IsoWriteDataToClients(tmpstring,
- 3*totals->npolys,
+ IsoWriteDataToClients(tmpstring,
+ 3*totals->npolys,
Float32,
(CCTK_INT4 *)polys);
}
@@ -600,7 +589,7 @@ void
WriteVRML(const cGH *GH, polypatch *totals, const char *fullname,
CCTK_REAL4 isolevel)
{
- /* Write isosurfaces in VRML 1.0 ASCII format
+ /* Write isosurfaces in VRML 1.0 ASCII format
(can be read by ivview) */
DECLARE_CCTK_PARAMETERS
@@ -646,12 +635,12 @@ WriteVRML(const cGH *GH, polypatch *totals, const char *fullname,
sprintf(tmps, "]\n\t}\n\tIndexedFaceSet {\n\t\tcoordIndex [ ");
Append_Or_EnlargeAndAppend(outs, tmps);
- sprintf (tmps, "%d, %d, %d, -1",
+ sprintf (tmps, "%d, %d, %d, -1",
totals->polys[0], totals->polys[1], totals->polys[2]);
Append_Or_EnlargeAndAppend(outs, tmps);
for (a = 3; a<3*totals->npolys; a += 3)
{
- sprintf (tmps, ", \n\t\t%d, %d, %d, -1",
+ sprintf (tmps, ", \n\t\t%d, %d, %d, -1",
totals->polys[a], totals->polys[a+1], totals->polys[a+2]);
Append_Or_EnlargeAndAppend(outs, tmps);
}
@@ -711,7 +700,7 @@ WriteASCII(const cGH *GH, polypatch *totals, const char *fullname,
for (a = 0; a<3*totals->npolys; a += 3)
{
- sprintf (tmps, "%d %d %d\n",
+ sprintf (tmps, "%d %d %d\n",
totals->polys[a], totals->polys[a+1], totals->polys[a+2]);
Append_Or_EnlargeAndAppend(outs, tmps);
}
@@ -736,7 +725,7 @@ WriteUCD(const cGH *GH, polypatch *totals, const char *fullname,
static char tmps[256];
static CCTK_INT4 efs = 0, lfs = 0;
- sprintf(fname, "%s/%s%s_%3.3f_%d.iso.inp",
+ sprintf(fname, "%s/%s%s_%3.3f_%d.iso.inp",
out_dir, fullname, PUGH_pGH (GH)->identity_string, isolevel,
GH->cctk_iteration);
@@ -797,7 +786,7 @@ int IsoSurfacer_TimeForOutput(const cGH *GH, int i){
if (!myGH ||!myGH->RunIsoSurfacer)
return 0;
/* do a check for new isosurfaces */
- /* Perhaps do a bcast for "changed" flags.
+ /* Perhaps do a bcast for "changed" flags.
which are embedded in each iso. */
return doIso(i, GH, myGH);
}
diff --git a/src/Sockets.c b/src/Sockets.c
index 7b3a7f1..3d51641 100644
--- a/src/Sockets.c
+++ b/src/Sockets.c
@@ -2,12 +2,12 @@
@file Sockets.c
@date Wed Sep 13 20:39:15 2000
@author Tom Goodale
- @desc
- Routines which deal with sockets.
- These should probably move into thorn Socket at some point if
- they aren't already there.
+ @desc
+ Routines which deal with sockets.
+ These should probably move into thorn Socket at some point if
+ they aren't already there.
@enddesc
- @version $Header$
+ @version $Id$
@@*/
#include "cctk.h"
@@ -84,7 +84,7 @@ typedef enum {closed, open} isoSocketState;
typedef struct ISOSocket
{
struct ISOSocket *prev;
- struct ISOSocket *next;
+ struct ISOSocket *next;
unsigned long filedes;
isoSocketState state;
} isoSocket;
@@ -108,8 +108,8 @@ int Iso_SetupServer(const cGH *GH,isosurfacerGH *myGH,
int Iso_ShutdownServer(void);
int Iso_Poll(const cGH *GH, long sec, long usec);
int Iso_Read(isoSocket *connection, char *buffer, size_t count);
-int IsoWriteDataToClients(const char *metadata,
- CCTK_INT8 size,
+int IsoWriteDataToClients(const char *metadata,
+ CCTK_INT8 size,
IsoType type,
void *dataP);
@@ -122,7 +122,7 @@ static int InitialiseTCP(void);
/********************************************************************
********************* Local Data *****************************
********************************************************************/
-/* OK, maybe this stuff should go into the isosurfacer GH?
+/* OK, maybe this stuff should go into the isosurfacer GH?
Just general fear of global variables... putting it into the
GH uses the same amount of space as the static vars, but gives
us a sort of a "namespace".
@@ -155,15 +155,9 @@ static char *advertised_filename = NULL;
@routine Iso_SetupServer
@date Wed Sep 13 20:39:15 2000
@author Tom Goodale
- @desc
+ @desc
Creates a socket to listen on.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
+ @enddesc
@@*/
int Iso_SetupServer(const cGH *GH,isosurfacerGH *myGH,int dataport, int controlport, int queue_size, int hunt)
{
@@ -253,15 +247,9 @@ int Iso_SetupServer(const cGH *GH,isosurfacerGH *myGH,int dataport, int controlp
@routine Iso_ShutdownServer
@date Wed Sep 13 20:39:15 2000
@author Tom Goodale
- @desc
+ @desc
Closes all sockets we are interested in.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
+ @enddesc
@@*/
int Iso_ShutdownServer(void)
{
@@ -290,17 +278,11 @@ int Iso_ShutdownServer(void)
@routine Iso_Poll
@date Wed Sep 13 20:39:15 2000
@author Tom Goodale
- @desc
+ @desc
Main workhorse routine.
Looks for activity on any of the sockets which are open
and dispatches work.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
+ @enddesc
@@*/
int Iso_Poll(const cGH *GH, long sec, long usec)
{
@@ -316,15 +298,6 @@ int Iso_Poll(const cGH *GH, long sec, long usec)
struct sockaddr_in clientname;
struct timeval timeout;
struct timeval *real_timeout;
- /*** FIXME: can CCTK_Abort() have a 'const cGH *' parameter ?? ***/
- union
- {
- const cGH *const_ptr;
- cGH *non_const_ptr;
- } GH_fake_const;
-
-
- GH_fake_const.const_ptr = GH;
if(CCTK_MyProc(GH) != 0) return 0; /* not the root processor */
@@ -346,9 +319,9 @@ int Iso_Poll(const cGH *GH, long sec, long usec)
if (ERROR_CHECK(select (FD_SETSIZE, &read_fd_set, NULL, NULL, real_timeout)))
{
perror ("select");
- CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE);
+ abort ();
}
-
+
/* Service all the sockets with input pending. */
if (FD_ISSET (datasock, &read_fd_set))
{
@@ -361,7 +334,7 @@ int Iso_Poll(const cGH *GH, long sec, long usec)
if (ERROR_CHECK(new))
{
perror ("accept");
- CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE);
+ abort ();
}
fprintf (stderr,
"Isosurfacer: data connect to port %u from host %s, port %hd.\n",
@@ -383,7 +356,7 @@ int Iso_Poll(const cGH *GH, long sec, long usec)
if (ERROR_CHECK(new))
{
perror ("accept");
- CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE);
+ abort ();
}
fprintf (stderr,
"Isosurfacer: control connect to port %u from host %s, port %hd.\n",
@@ -393,7 +366,7 @@ int Iso_Poll(const cGH *GH, long sec, long usec)
SocketCreate(new, &controlsocklist);
}
-
+
return 0;
}
@@ -404,15 +377,6 @@ IsoCommand *Iso_PollCommand(const cGH *GH,IsoCommand *cmd)
struct timeval *real_timeout;
isoSocket *this;
- /*** FIXME: can CCTK_Abort() have a 'const cGH *' parameter ?? ***/
- union
- {
- const cGH *const_ptr;
- cGH *non_const_ptr;
- } GH_fake_const;
-
-
- GH_fake_const.const_ptr = GH;
if(CCTK_MyProc(GH) != 0) return 0; /* not the root processor */
@@ -421,13 +385,13 @@ IsoCommand *Iso_PollCommand(const cGH *GH,IsoCommand *cmd)
timeout.tv_sec = 0;
timeout.tv_usec = 0;
real_timeout = &timeout;
-
+
/* Check if any input is available on one or more active sockets. */
read_fd_set = active_fd_set;
if (ERROR_CHECK(select (FD_SETSIZE, &read_fd_set, NULL, NULL, real_timeout))){
perror ("select");
- CCTK_Abort(GH_fake_const.non_const_ptr, EXIT_FAILURE);
+ abort ();
}
/* get next command on the control socket list */
for(this = controlsocklist; this; this = this->next){
@@ -455,8 +419,8 @@ IsoCommand *Iso_PollCommand(const cGH *GH,IsoCommand *cmd)
return NULL;
}
-int IsoWriteDataToClients(const char *metadata,
- CCTK_INT8 size,
+int IsoWriteDataToClients(const char *metadata,
+ CCTK_INT8 size,
IsoType type,
void *dataP)
{
@@ -472,26 +436,26 @@ int IsoWriteDataToClients(const char *metadata,
byteswap(data,size,4);
/* for(i = 0; i < size; i++)
{
- I wish htons/htonl actually worked as you'd expect them to
+ I wish htons/htonl actually worked as you'd expect them to
data[i] = htons(data[i]);
}*/
/* printf("Pre-Swap Datasize=%lld:%llx\n",datasize,datasize); */
byteswap(&datatype,1,4);
byteswap(&datasize,1,8);
/* printf("PostSwap Datasize=%lld:%llx\n",datasize,datasize); */
- /* unfortunately short is 16 bits and long is 32 bits on some systems
- datatype = htons(datatype);
+ /* unfortunately short is 16 bits and long is 32 bits on some systems
+ datatype = htons(datatype);
datasize = htonl(datasize); */
/* Send data down all connected sockets. */
for(this = datasocklist; this; this = next)
{
next = this->next;
-
- retval=Iso_Write(this, (void*)(&datasize), 8);
+
+ retval=Iso_Write(this, (void*)(&datasize), 8);
/* printf("RetVal on size write=%d\n",retval); */
- Iso_Write(this, (void*)(&datatype), 4);
- Iso_Write(this, metadata, 64);
+ Iso_Write(this, (void*)(&datatype), 4);
+ Iso_Write(this, metadata, 64);
retval = Iso_Write(this, (void *)data, size*4);
if(retval < 0)
@@ -517,15 +481,9 @@ int IsoWriteDataToClients(const char *metadata,
@routine Iso_Write
@date Fri Sep 15 18:47:41 2000
@author Tom Goodale
- @desc
+ @desc
Writes part or all of an Iso data connection.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
+ @enddesc
@@*/
int Iso_Write(isoSocket *connection, const char *buffer, size_t count)
{
@@ -544,20 +502,20 @@ int Iso_Write(isoSocket *connection, const char *buffer, size_t count)
while(!done)
{
/* Try and send the data. Make sure we don't get a SIGPIPE if the
- * other end is closed.
+ * other end is closed.
*/
- retval = send(connection->filedes,
- buffer+bytes_sent,
- count-bytes_sent,
+ retval = send(connection->filedes,
+ buffer+bytes_sent,
+ count-bytes_sent,
MSG_NOSIGNAL);
-
+
/* Check for errors */
if(ERROR_CHECK(retval))
{
switch(errno)
{
#ifdef EMSGSIZE
- case EMSGSIZE : /* The socket requires that message be sent atomically,
+ case EMSGSIZE : /* The socket requires that message be sent atomically,
* and the size of the message to be sent made this
* impossible.
*/
@@ -579,7 +537,7 @@ int Iso_Write(isoSocket *connection, const char *buffer, size_t count)
break;
#endif
-#ifdef ENOBUFS
+#ifdef ENOBUFS
case ENOBUFS :
/* The output queue for a network interface was full. This generally indicates that the interface has
* stopped sending, but may be caused by transient congestion. (This cannot occur in Linux, packets are
@@ -589,10 +547,10 @@ int Iso_Write(isoSocket *connection, const char *buffer, size_t count)
break;
#endif
case EBADF : /* An invalid descriptor was specified. */
-#ifdef ENOTSOCK
+#ifdef ENOTSOCK
case ENOTSOCK : /* The filedescriptor is not a socket. */
#endif
-#ifdef ECONNRESET
+#ifdef ECONNRESET
case ECONNRESET : /* Connection reset by peer */
#endif
case EPIPE : /* The local end has been shut down on a connection oriented socket. In this case the process will also
@@ -600,13 +558,13 @@ int Iso_Write(isoSocket *connection, const char *buffer, size_t count)
*/
SocketClose(connection);
break;
-
+
case EINTR : /* A signal occurred.*/
-
+
case ENOMEM : /* No memory available. */
case EINVAL : /* Invalid argument passed. */
-
+
case EFAULT : /* An invalid user space address was specified for a parameter. */
break;
@@ -663,20 +621,14 @@ int Iso_Write(isoSocket *connection, const char *buffer, size_t count)
@routine Iso_Read
@date Mon Sep 18 10:14:03 2000
@author Tom Goodale
- @desc
+ @desc
Reads part or all of an Iso request.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
+ @enddesc
@@*/
int Iso_Read(isoSocket *connection, char *buffer, size_t count)
{
int retval;
-
+
if(connection->state == open)
{
/* Currently don't do anything fancy. */
@@ -700,17 +652,11 @@ int Iso_Read(isoSocket *connection, char *buffer, size_t count)
/*@@
@routine byteswap
- @date
+ @date
@author John Shalf
- @desc
-
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
+ @desc
+ @enddesc
@@*/
static int byteswap(void *buf,CCTK_INT8 nelements,int elementsize)
{
@@ -721,16 +667,16 @@ static int byteswap(void *buf,CCTK_INT8 nelements,int elementsize)
return 0;
#else
buffer=(char *)buf;
- if(elementsize<=1) return 0;
-
+ if(elementsize<=1) return 0;
+
for(i=0;i<nelements;i++,buffer+=elementsize){
- /* do the swap thing on each element */
+ /* do the swap thing on each element */
for(s=0,d=elementsize-1;s<d;s++,d--){
- char c=buffer[s];
- buffer[s]=buffer[d];
+ char c=buffer[s];
+ buffer[s]=buffer[d];
buffer[d]=c;
}
- }
+ }
return 1;
#endif
}
@@ -739,15 +685,9 @@ static int byteswap(void *buf,CCTK_INT8 nelements,int elementsize)
@routine Iso_MakeSocket
@date Wed Sep 13 20:39:15 2000
@author Tom Goodale
- @desc
+ @desc
Creates a socket.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
+ @enddesc
@@*/
int Iso_MakeSocket (unsigned long port, int *hunt)
{
@@ -771,12 +711,12 @@ int Iso_MakeSocket (unsigned long port, int *hunt)
opt = 1;
setsockopt(this_sock, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(opt));
#endif
-
+
done = 0;
realport = port;
while(!done)
- {
+ {
/* Give the socket a name. */
name.sin_family = AF_INET;
name.sin_port = htons (realport);
@@ -786,7 +726,7 @@ int Iso_MakeSocket (unsigned long port, int *hunt)
if(hunt)
{
/* Hunt for a new port */
- fprintf(stderr, "Port %u taken, trying %u\n", realport, realport+1);
+ fprintf(stderr, "Port %u taken, trying %u\n", realport, realport+1);
realport++;
}
else
@@ -817,15 +757,9 @@ int Iso_MakeSocket (unsigned long port, int *hunt)
@routine SocketCreate
@date Thu Sep 21 15:03:32 2000
@author Tom Goodale
- @desc
+ @desc
Creates an isoSocket structure and links it to the list.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
+ @enddesc
@@*/
static isoSocket *SocketCreate(unsigned long int filedes, isoSocket **list)
{
@@ -839,7 +773,7 @@ static isoSocket *SocketCreate(unsigned long int filedes, isoSocket **list)
this->state = open;
this->prev = NULL;
this->next = *list;
-
+
if(*list)
{
(*list)->prev = this;
@@ -857,15 +791,9 @@ static isoSocket *SocketCreate(unsigned long int filedes, isoSocket **list)
@routine SocketDestroy
@date Thu Sep 21 15:04:03 2000
@author Tom Goodale
- @desc
+ @desc
Destroys an isoSocket structure and removes it from the list.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
+ @enddesc
@@*/
static void SocketDestroy(isoSocket *this, isoSocket **list)
{
@@ -898,15 +826,9 @@ static void SocketDestroy(isoSocket *this, isoSocket **list)
@routine SocketClose
@date Thu Sep 21 15:04:27 2000
@author Tom Goodale
- @desc
+ @desc
Closes the socket associated with an isoSocket structure.
- @enddesc
- @calls
- @calledby
- @history
-
- @endhistory
-
+ @enddesc
@@*/
static void SocketClose(isoSocket *this)
{