Made to work with some other compilers

This commit is contained in:
ceriel 1987-02-13 09:40:08 +00:00
parent 0905b2ba25
commit 3378831ba5
2 changed files with 14 additions and 4 deletions

View file

@ -1,5 +1,10 @@
#define MININT (1 << (sizeof(int) * 8 - 1))
#define MAXCHUNK (-(MININT + 1)) /* Highest count we write(2). */
#define MAXCHUNK (~MININT) /* Highest count we read(2). */
/* Unfortunately, MAXCHUNK is too large with some compilers. Put it in
an int!
*/
int maxchunk = MAXCHUNK;
/*
* We don't have to worry about byte order here.
@ -12,7 +17,7 @@ rd_bytes(fd, string, cnt)
{
while (cnt) {
register int n = cnt >= MAXCHUNK ? MAXCHUNK : cnt;
register int n = cnt >= maxchunk ? maxchunk : cnt;
if (read(fd, string, n) != n)
rd_fatal();

View file

@ -1,5 +1,10 @@
#define MININT (1 << (sizeof(int) * 8 - 1))
#define MAXCHUNK (-(MININT + 1)) /* Highest count we write(2). */
#define MAXCHUNK (~MININT) /* Highest count we write(2). */
/* Notice that MAXCHUNK itself might be too large with some compilers.
You have to put it in an int!
*/
int maxchunk = MAXCHUNK;
/*
* Just write "cnt" bytes to file-descriptor "fd".
@ -10,7 +15,7 @@ wr_bytes(fd, string, cnt)
{
while (cnt) {
register int n = cnt >= MAXCHUNK ? MAXCHUNK : cnt;
register int n = cnt >= maxchunk ? maxchunk : cnt;
if (write(fd, string, n) != n)
wr_fatal();