Makefile: Nouveau systeme d'autoconfiguration.

io.[ch]: l'argument "longueur" de getblock et putblock est un long.


git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@627 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Xavier Leroy 1996-02-13 16:26:14 +00:00
parent 567aebacc7
commit 2560ad0f58
3 changed files with 26 additions and 18 deletions

View File

@ -1,5 +1,4 @@
include ../config/Makefile.h include ../config/Makefile
include ../Makefile.config
CC=$(BYTECC) CC=$(BYTECC)
CFLAGS=-O $(BYTECCCOMPOPTS) CFLAGS=-O $(BYTECCCOMPOPTS)
@ -19,10 +18,10 @@ PRIMS=array.c compare.c extern.c floats.c gc_ctrl.c hash.c \
all: cslrun all: cslrun
cslrun: $(OBJS) prims.o cslrun: $(OBJS) prims.o
$(BYTECC) $(BYTECCCOMPOPTS) $(BYTECCLINKOPTS) $(LOWADDRESSES) -o cslrun prims.o $(OBJS) $(CCLIBS) $(BYTECC) $(BYTECCCOMPOPTS) $(BYTECCLINKOPTS) -o cslrun prims.o $(OBJS) $(CCLIBS)
cslrund: $(DOBJS) prims.o cslrund: $(DOBJS) prims.o
$(BYTECC) -g $(BYTECCCOMPOPTS) $(BYTECCLINKOPTS) $(LOWADDRESSES) -o cslrund prims.o $(DOBJS) $(CCLIBS) $(BYTECC) -g $(BYTECCCOMPOPTS) $(BYTECCLINKOPTS) -o cslrund prims.o $(DOBJS) $(CCLIBS)
install: install:
cp cslrun $(BINDIR)/cslrun cp cslrun $(BINDIR)/cslrun

View File

@ -17,6 +17,9 @@
#include <fcntl.h> #include <fcntl.h>
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#ifdef __STDC__
#include <limits.h>
#endif
#include "alloc.h" #include "alloc.h"
#include "fail.h" #include "fail.h"
#include "io.h" #include "io.h"
@ -29,6 +32,10 @@
#include "ui.h" #include "ui.h"
#endif #endif
#ifndef INT_MAX
#define INT_MAX 0x7FFFFFFF
#endif
/* Common functions. */ /* Common functions. */
struct channel * open_descr(fd) struct channel * open_descr(fd)
@ -132,13 +139,14 @@ value output_int(channel, w) /* ML */
return Val_unit; return Val_unit;
} }
void putblock(channel, p, n) void putblock(channel, p, len)
struct channel * channel; struct channel * channel;
char * p; char * p;
unsigned n; long len;
{ {
unsigned m; int n, m;
n = len >= INT_MAX ? INT_MAX : (int) len;
m = channel->end - channel->curr; m = channel->end - channel->curr;
if (channel->curr == channel->buff && n >= m) { if (channel->curr == channel->buff && n >= m) {
really_write(channel->fd, p, n); really_write(channel->fd, p, n);
@ -170,7 +178,7 @@ value output(channel, buff, start, length) /* ML */
{ {
putblock((struct channel *) channel, putblock((struct channel *) channel,
&Byte(buff, Long_val(start)), &Byte(buff, Long_val(start)),
(unsigned) Long_val(length)); Long_val(length));
return Val_unit; return Val_unit;
} }
@ -276,13 +284,14 @@ value input_int(channel) /* ML */
return Val_long(i); return Val_long(i);
} }
unsigned getblock(channel, p, n) int getblock(channel, p, len)
struct channel * channel; struct channel * channel;
char * p; char * p;
unsigned n; long len;
{ {
unsigned m, l; int n, m, l;
n = len >= INT_MAX ? INT_MAX : (int) len;
m = channel->max - channel->curr; m = channel->max - channel->curr;
if (n <= m) { if (n <= m) {
bcopy(channel->curr, p, n); bcopy(channel->curr, p, n);
@ -312,11 +321,11 @@ unsigned getblock(channel, p, n)
int really_getblock(chan, p, n) int really_getblock(chan, p, n)
struct channel * chan; struct channel * chan;
char * p; char * p;
unsigned long n; long n;
{ {
unsigned r; int r;
while (n > 0) { while (n > 0) {
r = getblock(chan, p, (unsigned) n); r = getblock(chan, p, n);
if (r == 0) return 0; if (r == 0) return 0;
p += r; p += r;
n -= r; n -= r;
@ -329,7 +338,7 @@ value input(channel, buff, start, length) /* ML */
{ {
return Val_long(getblock((struct channel *) channel, return Val_long(getblock((struct channel *) channel,
&Byte(buff, Long_val(start)), &Byte(buff, Long_val(start)),
(unsigned) Long_val(length))); Long_val(length)));
} }
value seek_in(channel, pos) /* ML */ value seek_in(channel, pos) /* ML */

View File

@ -52,13 +52,13 @@ struct channel {
struct channel * open_descr P((int)); struct channel * open_descr P((int));
value flush P((struct channel *)); value flush P((struct channel *));
void putword P((struct channel *, uint32)); void putword P((struct channel *, uint32));
void putblock P((struct channel *, char *, unsigned)); void putblock P((struct channel *, char *, long));
unsigned char refill P((struct channel *)); unsigned char refill P((struct channel *));
value pos_out P((struct channel *)); value pos_out P((struct channel *));
value seek_out P((struct channel *, value)); value seek_out P((struct channel *, value));
uint32 getword P((struct channel *)); uint32 getword P((struct channel *));
unsigned getblock P((struct channel *, char *, unsigned)); int getblock P((struct channel *, char *, long));
int really_getblock P((struct channel *, char *, unsigned long)); int really_getblock P((struct channel *, char *, long));
value close_in P((struct channel *)); value close_in P((struct channel *));