fix `compiler-sizeof' docs and error message
This commit is contained in:
parent
fa685207a3
commit
1ebde53db7
|
@ -67,11 +67,12 @@ list. Finally, the result can be a vector of size 2 containing an
|
|||
element representation followed by an exact-integer count.}
|
||||
|
||||
|
||||
@defproc[(compiler-sizeof [sym symbol?]) exact-nonnegative-integer?]{
|
||||
@defproc[(compiler-sizeof [sym (or/c symbol? (listof symbol?))]) exact-nonnegative-integer?]{
|
||||
|
||||
Possible values for @racket[symbol] are @racket['int], @racket['char],
|
||||
Possible values for @racket[sym] are @racket['int], @racket['char],
|
||||
@racket['short], @racket['long], @racket['*], @racket['void],
|
||||
@racket['float], @racket['double]. The result is the size of the
|
||||
@racket['float], @racket['double], or lists of symbols, such as
|
||||
@racket['(long long)]. The result is the size of the
|
||||
corresponding type according to the C @cpp{sizeof} operator for the
|
||||
current platform. The @racket[compiler-sizeof] operation should be
|
||||
used to gather information about the current platform, such as
|
||||
|
|
|
@ -37,6 +37,7 @@ foreign.@LTO@: $(srcdir)/foreign.c \
|
|||
$(srcdir)/../racket/include/scheme.h \
|
||||
$(srcdir)/../racket/include/schthread.h \
|
||||
$(srcdir)/../racket/src/schemef.h \
|
||||
$(srcdir)/../racket/src/stypes.h \
|
||||
$(srcdir)/../racket/src/schpriv.h
|
||||
$(CC) $(CFLAGS) -c $(srcdir)/foreign.c -o foreign.@LTO@
|
||||
|
||||
|
|
|
@ -1944,12 +1944,14 @@ static Scheme_Object *foreign_compiler_sizeof(int argc, Scheme_Object *argv[])
|
|||
int basetype = 0; /* 1=int, 2=char, 3=void, 4=float, 5=double */
|
||||
int intsize = 0; /* "short" => decrement, "long" => increment */
|
||||
int stars = 0; /* number of "*"s */
|
||||
int must_list = 0;
|
||||
Scheme_Object *l = argv[0], *p;
|
||||
while (!SAME_OBJ(l, scheme_null)) {
|
||||
if (SCHEME_PAIRP(l)) { p = SCHEME_CAR(l); l = SCHEME_CDR(l); }
|
||||
if (SCHEME_PAIRP(l)) { p = SCHEME_CAR(l); l = SCHEME_CDR(l); must_list = 1;}
|
||||
else if (must_list) { p = scheme_false; l = scheme_null; }
|
||||
else { p = l; l = scheme_null; }
|
||||
if (!SCHEME_SYMBOLP(p)) {
|
||||
scheme_wrong_type(MYNAME, "list of symbols", 0, argc, argv);
|
||||
scheme_wrong_type(MYNAME, "symbol or list of symbols", 0, argc, argv);
|
||||
} else if (!strcmp(SCHEME_SYM_VAL(p),"int")) {
|
||||
if (basetype==0) basetype=1;
|
||||
else scheme_signal_error(MYNAME": extraneous type: %V", p);
|
||||
|
@ -1976,7 +1978,7 @@ static Scheme_Object *foreign_compiler_sizeof(int argc, Scheme_Object *argv[])
|
|||
} else if (!strcmp(SCHEME_SYM_VAL(p),"*")) {
|
||||
stars++;
|
||||
} else {
|
||||
scheme_wrong_type(MYNAME, "list of C type symbols", 0, argc, argv);
|
||||
scheme_wrong_type(MYNAME, "C type symbol or list of C type symbols", 0, argc, argv);
|
||||
}
|
||||
}
|
||||
if (stars > 1)
|
||||
|
|
|
@ -1373,12 +1373,14 @@ static void* SCHEME2C(Scheme_Object *type, void *dst, intptr_t delta,
|
|||
int basetype = 0; /* 1=int, 2=char, 3=void, 4=float, 5=double */
|
||||
int intsize = 0; /* "short" => decrement, "long" => increment */
|
||||
int stars = 0; /* number of "*"s */
|
||||
int must_list = 0;
|
||||
Scheme_Object *l = argv[0], *p;
|
||||
while (!SAME_OBJ(l, scheme_null)) {
|
||||
if (SCHEME_PAIRP(l)) { p = SCHEME_CAR(l); l = SCHEME_CDR(l); }
|
||||
if (SCHEME_PAIRP(l)) { p = SCHEME_CAR(l); l = SCHEME_CDR(l); must_list = 1;}
|
||||
else if (must_list) { p = scheme_false; l = scheme_null; }
|
||||
else { p = l; l = scheme_null; }
|
||||
if (!SCHEME_SYMBOLP(p)) {
|
||||
scheme_wrong_type(MYNAME, "list of symbols", 0, argc, argv);
|
||||
scheme_wrong_type(MYNAME, "symbol or list of symbols", 0, argc, argv);
|
||||
} else if (!strcmp(SCHEME_SYM_VAL(p),"int")) {
|
||||
if (basetype==0) basetype=1;
|
||||
else scheme_signal_error(MYNAME": extraneous type: %V", p);
|
||||
|
@ -1405,7 +1407,7 @@ static void* SCHEME2C(Scheme_Object *type, void *dst, intptr_t delta,
|
|||
} else if (!strcmp(SCHEME_SYM_VAL(p),"*")) {
|
||||
stars++;
|
||||
} else {
|
||||
scheme_wrong_type(MYNAME, "list of C type symbols", 0, argc, argv);
|
||||
scheme_wrong_type(MYNAME, "C type symbol or list of C type symbols", 0, argc, argv);
|
||||
}
|
||||
}
|
||||
if (stars > 1)
|
||||
|
|
Loading…
Reference in New Issue
Block a user