本文整理匯總了C++中CHECKS函數的典型用法代碼示例。如果您正苦於以下問題:C++ CHECKS函數的具體用法?C++ CHECKS怎麽用?C++ CHECKS使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了CHECKS函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: main
int main(void)
{
const char *filedir = "dirfile";
const char *format = "dirfile/format";
const char *data = "dirfile/data";
const char *zata = "dirfile/zata";
const char *format_data = "cata RAW UINT8 8\n/ALIAS data cata\n"
"eata RAW UINT8 8\n";
unsigned char data_data[256];
int fd, ret, error, unlink_data, unlink_zata, r = 0;
const char **fl;
char *field_list[4];
DIRFILE *D;
rmdirfile();
mkdir(filedir, 0777);
for (fd = 0; fd < 256; ++fd)
data_data[fd] = (unsigned char)fd;
fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666);
write(fd, format_data, strlen(format_data));
close(fd);
fd = open(data, O_CREAT | O_EXCL | O_WRONLY | O_BINARY, 0666);
write(fd, data_data, 256);
close(fd);
D = gd_open(filedir, GD_RDWR | GD_VERBOSE);
ret = gd_rename(D, "data", "zata", GD_REN_DATA);
error = gd_error(D);
fl = gd_field_list(D);
field_list[0] = strdup(fl[0]);
field_list[1] = strdup(fl[1]);
field_list[2] = strdup(fl[2]);
field_list[3] = strdup(fl[3]);
gd_close(D);
unlink_data = unlink(data);
unlink_zata = unlink(zata);
unlink(format);
rmdir(filedir);
CHECKI(error, 0);
CHECKI(ret, 0);
CHECKS(field_list[0], "INDEX");
CHECKS(field_list[1], "cata");
CHECKS(field_list[2], "eata");
CHECKS(field_list[3], "zata");
CHECKI(unlink_data, 0);
CHECKI(unlink_zata, -1);
free(field_list[0]);
free(field_list[1]);
free(field_list[2]);
free(field_list[3]);
return r;
}
示例2: main
int main(void)
{
const char *filedir = "dirfile";
const char *format = "dirfile/format";
const char *format_data =
"early RAW UINT8 c\n"
"late RAW UINT8 c\n"
"/ALIAS b c\n"
"e CONST UINT8 2\n"
"/ALIAS c e\n";
int fd, e1, e2, e3, e4, r = 0;
char *s1, *s2, *s3;
DIRFILE *D;
gd_entry_t E;
rmdirfile();
mkdir(filedir, 0777);
fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666);
write(fd, format_data, strlen(format_data));
close(fd);
D = gd_open(filedir, GD_RDWR);
gd_validate(D, "early");
gd_rename(D, "c", "d", GD_REN_UPDB);
e1 = gd_error(D);
gd_spf(D, "early");
e2 = gd_error(D);
gd_spf(D, "late");
e3 = gd_error(D);
gd_entry(D, "early", &E);
s1 = E.scalar[0];
E.scalar[0] = NULL;
gd_free_entry_strings(&E);
gd_entry(D, "late", &E);
s2 = E.scalar[0];
E.scalar[0] = NULL;
gd_free_entry_strings(&E);
gd_entry(D, "b", &E);
e4 = gd_error(D);
s3 = strdup(gd_alias_target(D, "b"));
gd_discard(D);
unlink(format);
rmdir(filedir);
CHECKI(e1,0);
CHECKI(e2,0);
CHECKI(e3,0);
CHECKI(e4,0);
CHECKS(s1, "d");
CHECKS(s2, "d");
CHECKS(s3, "d");
return r;
}
示例3: main
int main(void)
{
const char *filedir = "dirfile";
const char *format = "dirfile/format";
int error, ge_error, r = 0;
gd_entry_t e;
DIRFILE *D;
rmdirfile();
D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
gd_add_phase(D, "new", "in", 3, 0);
gd_madd_linterp(D, "new", "meta", "in", "table");
error = gd_error(D);
/* check */
gd_entry(D, "new/meta", &e);
ge_error = gd_error(D);
CHECKI(ge_error, 0);
if (!r) {
CHECKI(e.field_type, GD_LINTERP_ENTRY);
CHECKS(e.in_fields[0], "in");
CHECKS(e.EN(linterp,table), "table");
CHECKI(e.fragment_index, 0);
gd_free_entry_strings(&e);
}
gd_close(D);
unlink(format);
rmdir(filedir);
CHECKI(error, GD_E_OK);
return r;
}
示例4: Parse_Start
/* Parse_Start. */
ParseFilePtr Parse_Start(const char *fileroot,const char *filename,char *erstr) {
ParseFilePtr pfp;
char string[STRCHAR];
pfp=Parse_AllocFilePtr(fileroot,filename);
CHECKS(pfp,"Unable to allocate memory for reading configuration file");
pfp->fptr=fopen(pfp->fname,"r");
if(!pfp->fptr) {
sprintf(string,"File '%s' not found\n",pfp->fname);
Parse_FreeFilePtr(pfp);
CHECKS(0,"%s",string); }
return pfp;
failure:
return NULL; }
示例5: VMArenaCheck
static Bool VMArenaCheck(VMArena vmArena)
{
Arena arena;
VMChunk primary;
CHECKS(VMArena, vmArena);
arena = VMArena2Arena(vmArena);
CHECKD(Arena, arena);
/* spare pages are committed, so must be less spare than committed. */
CHECKL(vmArena->spareSize <= arena->committed);
CHECKL(vmArena->extendBy > 0);
CHECKL(vmArena->extendMin <= vmArena->extendBy);
if (arena->primary != NULL) {
primary = Chunk2VMChunk(arena->primary);
CHECKD(VMChunk, primary);
/* We could iterate over all chunks accumulating an accurate */
/* count of committed, but we don't have all day. */
CHECKL(VMMapped(primary->vm) <= arena->committed);
}
CHECKD_NOSIG(Ring, &vmArena->spareRing);
/* FIXME: Can't check VMParams */
return TRUE;
}
示例6: LockCheck
Bool LockCheck(Lock lock)
{
CHECKS(Lock, lock);
/* While claims can't be very large, I don't dare to put a limit on it. */
/* There's no way to test the mutex, or check if it's held by somebody. */
return TRUE;
}
示例7: MutatorContextCheck
Bool MutatorContextCheck(MutatorContext context)
{
CHECKS(MutatorContext, context);
CHECKL(NONNEGATIVE(context->var));
CHECKL(context->var < MutatorContextLIMIT);
return TRUE;
}
示例8: KeyCheck
Bool KeyCheck(Key key)
{
CHECKS(Key, key);
CHECKL(key->name != NULL);
CHECKL(FUNCHECK(key->check));
return TRUE;
}
示例9: SegBufCheck
Bool SegBufCheck(SegBuf segbuf)
{
Buffer buffer;
CHECKS(SegBuf, segbuf);
buffer = MustBeA(Buffer, segbuf);
CHECKD(Buffer, buffer);
CHECKL(RankSetCheck(segbuf->rankSet));
if (buffer->mode & BufferModeTRANSITION) {
/* nothing to check */
} else if ((buffer->mode & BufferModeATTACHED) == 0) {
CHECKL(segbuf->seg == NULL);
} else {
/* The buffer is attached to a segment. */
CHECKL(segbuf->seg != NULL);
CHECKD(Seg, segbuf->seg);
/* To avoid recursive checking, leave it to SegCheck to make */
/* sure the buffer and segment fields tally. */
if (buffer->mode & BufferModeFLIPPED) {
/* Only buffers that allocate pointers get flipped. */
CHECKL(segbuf->rankSet != RankSetEMPTY);
}
}
return TRUE;
}
示例10: AMSTCheck
ATTRIBUTE_UNUSED
static Bool AMSTCheck(AMST amst)
{
CHECKS(AMST, amst);
CHECKD_NOSIG(AMS, AMST2AMS(amst)); /* <design/check#.hidden-type> */
return TRUE;
}
示例11: FormattedObjectsStepClosureCheck
static Bool FormattedObjectsStepClosureCheck(FormattedObjectsStepClosure c)
{
CHECKS(FormattedObjectsStepClosure, c);
CHECKL(FUNCHECK(c->f));
/* p and s fields are arbitrary closures which cannot be checked */
return TRUE;
}
示例12: main
int main(void)
{
const char *filedir = "dirfile";
const char *format = "dirfile/format";
const char *format_data = "/ALIAS alias target\n/ALIAS target next\n";
int fd, e, r = 0;
DIRFILE *D;
const char *t;
rmdirfile();
mkdir(filedir, 0777);
fd = open(format, O_CREAT | O_EXCL | O_WRONLY, 0666);
write(fd, format_data, strlen(format_data));
close(fd);
D = gd_open(filedir, GD_RDONLY | GD_VERBOSE);
t = gd_alias_target(D, "alias");
CHECKS(t, "target");
e = gd_error(D);
CHECKI(e, GD_E_OK);
gd_close(D);
unlink(format);
rmdir(filedir);
return r;
}
示例13: main
int main(void)
{
const char *filedir = "dirfile";
const char *format = "dirfile/format";
int error, r = 0;
gd_entry_t e;
DIRFILE *D;
rmdirfile();
D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
gd_add_sbit(D, "new", "input", 1, 1, 0);
error = gd_error(D);
/* check */
gd_entry(D, "new", &e);
if (gd_error(D))
r = 1;
else {
CHECKI(e.field_type, GD_SBIT_ENTRY);
CHECKS(e.in_fields[0], "input");
CHECKI(e.fragment_index, 0);
CHECKI(e.EN(bit,bitnum), 1);
CHECKI(e.EN(bit,numbits), 1);
gd_free_entry_strings(&e);
}
gd_close(D);
unlink(format);
rmdir(filedir);
CHECKI(error, GD_E_OK);
return r;
}
示例14: MVTCheck
ATTRIBUTE_UNUSED
static Bool MVTCheck(MVT mvt)
{
CHECKS(MVT, mvt);
CHECKC(MVTPool, mvt);
CHECKD(Pool, MVTPool(mvt));
CHECKC(MVTPool, mvt);
CHECKD(CBS, &mvt->cbsStruct);
CHECKD(ABQ, &mvt->abqStruct);
CHECKD(Freelist, &mvt->flStruct);
CHECKD(Failover, &mvt->foStruct);
CHECKL(mvt->reuseSize >= 2 * mvt->fillSize);
CHECKL(mvt->fillSize >= mvt->maxSize);
CHECKL(mvt->maxSize >= mvt->meanSize);
CHECKL(mvt->meanSize >= mvt->minSize);
CHECKL(mvt->minSize > 0);
CHECKL(mvt->fragLimit <= 100);
CHECKL(mvt->availLimit == mvt->size * mvt->fragLimit / 100);
CHECKL(BoolCheck(mvt->abqOverflow));
CHECKL(BoolCheck(mvt->splinter));
if (mvt->splinter) {
CHECKL(AddrOffset(mvt->splinterBase, mvt->splinterLimit) >=
mvt->minSize);
CHECKL(mvt->splinterBase < mvt->splinterLimit);
}
CHECKL(mvt->size == mvt->allocated + mvt->available +
mvt->unavailable);
/* --- could check that sum of segment sizes == mvt->size */
/* --- check meters? */
return TRUE;
}
示例15: main
int main(void)
{
const char *filedir = "dirfile";
const char *format = "dirfile/format";
int error, r = 0;
gd_entry_t e;
char val[1000];
DIRFILE *D;
rmdirfile();
D = gd_open(filedir, GD_RDWR | GD_CREAT | GD_VERBOSE);
gd_add_string(D, "data", "A string.", 0);
error = gd_error(D);
/* check */
gd_entry(D, "data", &e);
if (gd_error(D))
r = 1;
else {
CHECKI(e.field_type, GD_STRING_ENTRY);
CHECKI(e.fragment_index, 0);
gd_get_string(D, "data", 1000, val);
CHECKS(val, "A string.");
gd_free_entry_strings(&e);
}
gd_close(D);
unlink(format);
rmdir(filedir);
CHECKI(error, GD_E_OK);
return r;
}