Added missing libsw library

This commit is contained in:
Guilhem Lavaux 2013-03-01 15:43:05 -05:00
parent dd5e51c09c
commit 9dff8cfb5a
57 changed files with 13454 additions and 0 deletions

59
external/libsdf/libsw/files.c vendored Normal file
View file

@ -0,0 +1,59 @@
/* Some common routines for dealing with files. */
#include <unistd.h>
#include <fcntl.h>
#include "protos.h"
#include "Malloc.h"
#include "mpmy.h"
int fexists(const char *name){
int fd, ret;
ret = 0;
if( MPMY_Procnum() == 0 ){
/* We could call stat, but then we'd have to deal with the */
/* complications of different flavors of struct stat on different */
/* machines...Yuck. */
if( (fd=open(name, O_RDONLY)) >= 0 ){
close(fd);
ret = 1;
}
}
MPMY_Combine(&ret, &ret, 1, MPMY_INT, MPMY_SUM);
return ret;
}
int fexists_and_unlink(const char *name){
int fd, ret;
ret = 0;
if( MPMY_Procnum() == 0 ){
/* We could call stat, but then we'd have to deal with the */
/* complications of different flavors of struct stat on different */
/* machines...Yuck. */
if( (fd=open(name, O_RDONLY)) >= 0 ){
close(fd);
ret = 1;
}
unlink(name);
}
MPMY_Combine(&ret, &ret, 1, MPMY_INT, MPMY_SUM);
return ret;
}
int
ForceCheckpoint(void)
{
return fexists_and_unlink("_ForceCheckpoint_") || fexists("_ForceStop_");
}
int
ForceOutput(void)
{
return fexists_and_unlink("_ForceOutput_");
}
int
ForceStop(void)
{
return fexists_and_unlink("_ForceStop_");
}