From: Rick Hohensee <humbubba@smarty.smart.net>
To: linux-kernel@vger.kernel.org
Subject: elevator with layers
Date: Wed, 18 Jul 2001 17:33:58 -0400 (EDT) [thread overview]
Message-ID: <200107182133.RAA00850@smarty.smart.net> (raw)
A guy posted some test results based on some code like this...
#include <stdio.h>
#include <assert.h>
#define TEST_SZ 25000000
#define RD_BUFF_SZ 5000
int main(int argc, const char **argv, const char **env)
{
FILE* fp;
if(argc > 1) fp = fopen(argv[1], "r+");
else fp =tmpfile();
if(NULL != fp) {
int j = -1;
int o;
while(1) {
if(++j != TEST_SZ) {
if (j == (TEST_SZ - RD_BUFF_SZ) ) o = ftello(fp);
fwrite(&j, sizeof(int), 1, fp);
} else {
int i, buffer[RD_BUFF_SZ];
fflush(fp);
fseek(fp, o, SEEK_SET);
fread(buffer, sizeof(int), sizeof(buffer), fp);
printf("Validating end of file writes\n");
for(i = (RD_BUFF_SZ - 1); i >= 0; i--) {
assert(buffer[i] == --j) ;
}
rewind(fp);
j = -1;
}
}
return 1;
}
return 0;
}
That's not it exactly. o wasn't an int. Probably a long long by some other
name. I don't know what he's trying to do with the above, but I believe
the following has the same basic action...
#include <stdio.h>
#include <assert.h>
int main () {
int i, j, buffer[5000], isize, bufsize;
isize = sizeof(int);
bufsize = sizeof(buffer);
FILE * stream = tmpfile();
top: j = -1;
fflush(stream);
fseek(stream, 0, SEEK_SET);
fread(buffer, isize, bufsize, stream);
printf("x ");
for(i = 4999; i >=0 ; i --) { assert(buffer[i] == --j) ; }
rewind(stream);
goto top ;
}
which should be a bit easier to assess if I'm right about what it's doing.
There's probably still some stuff there that can go away, but I'm not
familiar with rewind() and friends.
Rick Hohensee
www.clienux.com
reply other threads:[~2001-07-18 21:19 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200107182133.RAA00850@smarty.smart.net \
--to=humbubba@smarty.smart.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox