avoid compiler warnings with MinGW
Makefile and configure improvements turn on more checking with MinGW, so fix the resulting warnings-as-errors. original commit: df2ff94b2b878924b5ca925c48253d147f668e79
This commit is contained in:
parent
56049bcd47
commit
d6c5abe542
|
@ -127,7 +127,7 @@ static ptr s_ee_read_char(IBOOL blockp) {
|
|||
if (ker.bKeyDown) {
|
||||
wchar_t c;
|
||||
|
||||
if (c = ker.uChar.UnicodeChar) {
|
||||
if ((c = ker.uChar.UnicodeChar)) {
|
||||
/* translate ^<space> to nul */
|
||||
if (c == 0x20 && (ker.dwControlKeyState & (LEFT_CTRL_PRESSED|RIGHT_CTRL_PRESSED)))
|
||||
buf[0] = 0;
|
||||
|
|
2
c/gc.c
2
c/gc.c
|
@ -895,7 +895,7 @@ ptr GCENTRY(ptr tc, IGEN mcg, IGEN tg, ptr count_roots_ls) {
|
|||
rep = GUARDIANREP(ls);
|
||||
/* ftype_guardian_rep is a marker for reference-counted ftype pointer */
|
||||
if (rep == ftype_guardian_rep) {
|
||||
int b; uptr *addr;
|
||||
int b; iptr *addr;
|
||||
rep = GUARDIANOBJ(ls);
|
||||
if (FWDMARKER(rep) == forward_marker) rep = FWDADDRESS(rep);
|
||||
/* Caution: Building in assumption about shape of an ftype pointer */
|
||||
|
|
|
@ -494,12 +494,21 @@ void Scompact_heap() {
|
|||
If noisy is nonzero, additional comments may be included in the output
|
||||
*/
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# include <inttypes.h>
|
||||
# define PHtx "%" PRIxPTR
|
||||
# define Ptd "%" PRIdPTR
|
||||
#else
|
||||
# define PHtx "%#tx"
|
||||
# define Ptd "%td"
|
||||
#endif
|
||||
|
||||
static void segment_tell(seg) uptr seg; {
|
||||
seginfo *si;
|
||||
ISPC s, s1;
|
||||
static char *spacename[max_space+1] = { alloc_space_names };
|
||||
|
||||
printf("segment %#tx", (ptrdiff_t)seg);
|
||||
printf("segment "PHtx"", (ptrdiff_t)seg);
|
||||
if ((si = MaybeSegInfo(seg)) == NULL) {
|
||||
printf(" out of heap bounds\n");
|
||||
} else {
|
||||
|
@ -532,7 +541,7 @@ static void check_heap_dirty_msg(msg, x) char *msg; ptr *x; {
|
|||
|
||||
si = SegInfo(addr_get_segment(TO_PTR(x)));
|
||||
d = (INT)(((uptr)TO_PTR(x) >> card_offset_bits) & ((1 << segment_card_offset_bits) - 1));
|
||||
printf("%s dirty byte %d found in segment %#tx, card %d at %#tx\n", msg, si->dirty_bytes[d], (ptrdiff_t)(si->number), d, (ptrdiff_t)x);
|
||||
printf("%s dirty byte %d found in segment "PHtx", card %d at "PHtx"\n", msg, si->dirty_bytes[d], (ptrdiff_t)(si->number), d, (ptrdiff_t)x);
|
||||
printf("from "); segment_tell(addr_get_segment(TO_PTR(x)));
|
||||
printf("to "); segment_tell(addr_get_segment(*x));
|
||||
}
|
||||
|
@ -563,7 +572,7 @@ void S_check_heap(aftergc, mcg) IBOOL aftergc; IGEN mcg; {
|
|||
}
|
||||
if ((chunk->segs - count) != chunk->nused_segs) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! unexpected used segs count %td with %td total segs and %td segs on the unused list\n",
|
||||
printf("!!! unexpected used segs count "Ptd" with "Ptd" total segs and "Ptd" segs on the unused list\n",
|
||||
(ptrdiff_t)chunk->nused_segs, (ptrdiff_t)chunk->segs, (ptrdiff_t)count);
|
||||
}
|
||||
used_segments += chunk->nused_segs;
|
||||
|
@ -590,21 +599,21 @@ void S_check_heap(aftergc, mcg) IBOOL aftergc; IGEN mcg; {
|
|||
|
||||
if (used_segments != nonstatic_segments + static_segments) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! found %#tx used segments and %#tx occupied segments\n",
|
||||
printf("!!! found "PHtx" used segments and "PHtx" occupied segments\n",
|
||||
(ptrdiff_t)used_segments,
|
||||
(ptrdiff_t)(nonstatic_segments + static_segments));
|
||||
}
|
||||
|
||||
if (S_G.number_of_nonstatic_segments != nonstatic_segments) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! S_G.number_of_nonstatic_segments %#tx is different from occupied number %#tx\n",
|
||||
printf("!!! S_G.number_of_nonstatic_segments "PHtx" is different from occupied number "PHtx"\n",
|
||||
(ptrdiff_t)S_G.number_of_nonstatic_segments,
|
||||
(ptrdiff_t)nonstatic_segments);
|
||||
}
|
||||
|
||||
if (S_G.number_of_empty_segments != empty_segments) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! S_G.number_of_empty_segments %#tx is different from unused number %#tx\n",
|
||||
printf("!!! S_G.number_of_empty_segments "PHtx" is different from unused number "PHtx"\n",
|
||||
(ptrdiff_t)S_G.number_of_empty_segments,
|
||||
(ptrdiff_t)empty_segments);
|
||||
}
|
||||
|
@ -617,22 +626,22 @@ void S_check_heap(aftergc, mcg) IBOOL aftergc; IGEN mcg; {
|
|||
seginfo *recorded_si; uptr recorded_seg;
|
||||
if ((seg = si->number) != (recorded_seg = (chunk->base + chunk->segs - nsegs))) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! recorded segment number %#tx differs from actual segment number %#tx", (ptrdiff_t)seg, (ptrdiff_t)recorded_seg);
|
||||
printf("!!! recorded segment number "PHtx" differs from actual segment number "PHtx"", (ptrdiff_t)seg, (ptrdiff_t)recorded_seg);
|
||||
}
|
||||
if ((recorded_si = SegInfo(seg)) != si) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! recorded segment %#tx seginfo %#tx differs from actual seginfo %#tx", (ptrdiff_t)seg, (ptrdiff_t)recorded_si, (ptrdiff_t)si);
|
||||
printf("!!! recorded segment "PHtx" seginfo "PHtx" differs from actual seginfo "PHtx"", (ptrdiff_t)seg, (ptrdiff_t)recorded_si, (ptrdiff_t)si);
|
||||
}
|
||||
s = si->space;
|
||||
g = si->generation;
|
||||
|
||||
if (si->use_marks)
|
||||
printf("!!! use_marks set on generation %d segment %#tx\n", g, (ptrdiff_t)seg);
|
||||
printf("!!! use_marks set on generation %d segment "PHtx"\n", g, (ptrdiff_t)seg);
|
||||
|
||||
if (s == space_new) {
|
||||
if (g != 0 && !si->marked_mask) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! unexpected generation %d segment %#tx in space_new\n", g, (ptrdiff_t)seg);
|
||||
printf("!!! unexpected generation %d segment "PHtx" in space_new\n", g, (ptrdiff_t)seg);
|
||||
}
|
||||
} else if (s == space_impure || s == space_symbol || s == space_pure || s == space_weakpair || s == space_ephemeron
|
||||
|| s == space_immobile_impure || s == space_count_pure || s == space_count_impure || s == space_closure) {
|
||||
|
@ -664,7 +673,7 @@ void S_check_heap(aftergc, mcg) IBOOL aftergc; IGEN mcg; {
|
|||
|| psi->old_space
|
||||
|| (psi->marked_mask && !(psi->marked_mask[segment_bitmap_byte(p)] & segment_bitmap_bit(p)))) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! dangling reference at %#tx to %#tx%s\n", (ptrdiff_t)pp1, (ptrdiff_t)p, (aftergc ? " after gc" : ""));
|
||||
printf("!!! dangling reference at "PHtx" to "PHtx"%s\n", (ptrdiff_t)pp1, (ptrdiff_t)p, (aftergc ? " after gc" : ""));
|
||||
printf("from: "); segment_tell(seg);
|
||||
printf("to: "); segment_tell(ptr_get_segment(p));
|
||||
{
|
||||
|
@ -697,7 +706,7 @@ void S_check_heap(aftergc, mcg) IBOOL aftergc; IGEN mcg; {
|
|||
if (found_eos) {
|
||||
if (si->dirty_bytes[d] != 0xff) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! Dirty byte set past end-of-segment for segment %#tx, card %d\n", (ptrdiff_t)seg, d);
|
||||
printf("!!! Dirty byte set past end-of-segment for segment "PHtx", card %d\n", (ptrdiff_t)seg, d);
|
||||
segment_tell(seg);
|
||||
}
|
||||
continue;
|
||||
|
@ -710,7 +719,7 @@ void S_check_heap(aftergc, mcg) IBOOL aftergc; IGEN mcg; {
|
|||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
printf("pp1 = %#tx, pp2 = %#tx, nl = %#tx\n", (ptrdiff_t)pp1, (ptrdiff_t)pp2, (ptrdiff_t)nl);
|
||||
printf("pp1 = "PHtx", pp2 = "PHtx", nl = "PHtx"\n", (ptrdiff_t)pp1, (ptrdiff_t)pp2, (ptrdiff_t)nl);
|
||||
fflush(stdout);
|
||||
#endif
|
||||
|
||||
|
@ -752,7 +761,7 @@ void S_check_heap(aftergc, mcg) IBOOL aftergc; IGEN mcg; {
|
|||
cards with dirty pointers to segments older than the
|
||||
maximum copyied generation, so we can get legitimate
|
||||
conservative dirty bytes even after gc */
|
||||
printf("... Conservative dirty byte %x (%x) %sfor segment %#tx card %d ",
|
||||
printf("... Conservative dirty byte %x (%x) %sfor segment "PHtx" card %d ",
|
||||
si->dirty_bytes[d], dirty,
|
||||
(aftergc ? "after gc " : ""),
|
||||
(ptrdiff_t)seg, d);
|
||||
|
@ -770,7 +779,7 @@ void S_check_heap(aftergc, mcg) IBOOL aftergc; IGEN mcg; {
|
|||
for (d = 0; d < cards_per_segment; d += 1) {
|
||||
if (si->dirty_bytes[d] != 0xff) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! Unnecessary dirty byte %x (%x) after gc for segment %#tx card %d ",
|
||||
printf("!!! Unnecessary dirty byte %x (%x) after gc for segment "PHtx" card %d ",
|
||||
si->dirty_bytes[d], 0xff, (ptrdiff_t)(si->number), d);
|
||||
segment_tell(seg);
|
||||
}
|
||||
|
@ -818,18 +827,18 @@ static void check_dirty_space(ISPC s) {
|
|||
if (to_g < min_to_g) min_to_g = to_g;
|
||||
if (from_g == 0) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! (check_dirty): space %d, generation %d segment %#tx card %d is marked dirty\n", s, from_g, (ptrdiff_t)(si->number), d);
|
||||
printf("!!! (check_dirty): space %d, generation %d segment "PHtx" card %d is marked dirty\n", s, from_g, (ptrdiff_t)(si->number), d);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (min_to_g != si->min_dirty_byte) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! (check_dirty): space %d, generation %d segment %#tx min_dirty_byte is %d while actual min is %d\n", s, from_g, (ptrdiff_t)(si->number), si->min_dirty_byte, min_to_g);
|
||||
printf("!!! (check_dirty): space %d, generation %d segment "PHtx" min_dirty_byte is %d while actual min is %d\n", s, from_g, (ptrdiff_t)(si->number), si->min_dirty_byte, min_to_g);
|
||||
segment_tell(si->number);
|
||||
} else if (min_to_g != 0xff) {
|
||||
if (!dirty_listedp(si, from_g, min_to_g)) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! (check_dirty): space %d, generation %d segment %#tx is marked dirty but not in dirty-segment list\n", s, from_g, (ptrdiff_t)(si->number));
|
||||
printf("!!! (check_dirty): space %d, generation %d segment "PHtx" is marked dirty but not in dirty-segment list\n", s, from_g, (ptrdiff_t)(si->number));
|
||||
segment_tell(si->number);
|
||||
}
|
||||
}
|
||||
|
@ -855,17 +864,17 @@ static void check_dirty() {
|
|||
IGEN mingval = si->min_dirty_byte;
|
||||
if (g != from_g) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! (check_dirty): generation %d segment %#tx in %d -> %d dirty list\n", g, (ptrdiff_t)(si->number), from_g, to_g);
|
||||
printf("!!! (check_dirty): generation %d segment "PHtx" in %d -> %d dirty list\n", g, (ptrdiff_t)(si->number), from_g, to_g);
|
||||
}
|
||||
if (mingval != to_g) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! (check_dirty): dirty byte = %d for segment %#tx in %d -> %d dirty list\n", mingval, (ptrdiff_t)(si->number), from_g, to_g);
|
||||
printf("!!! (check_dirty): dirty byte = %d for segment "PHtx" in %d -> %d dirty list\n", mingval, (ptrdiff_t)(si->number), from_g, to_g);
|
||||
}
|
||||
if (s != space_new && s != space_impure && s != space_symbol && s != space_port
|
||||
&& s != space_impure_record && s != space_impure_typed_object && s != space_immobile_impure
|
||||
&& s != space_weakpair && s != space_ephemeron) {
|
||||
S_checkheap_errors += 1;
|
||||
printf("!!! (check_dirty): unexpected space %d for dirty segment %#tx\n", s, (ptrdiff_t)(si->number));
|
||||
printf("!!! (check_dirty): unexpected space %d for dirty segment "PHtx"\n", s, (ptrdiff_t)(si->number));
|
||||
}
|
||||
si = si->dirty_next;
|
||||
}
|
||||
|
|
17
c/io.c
17
c/io.c
|
@ -21,7 +21,9 @@
|
|||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#include <shlobj.h>
|
||||
#if !defined(__MINGW32__)
|
||||
#pragma comment(lib, "shell32.lib")
|
||||
#endif
|
||||
#else /* WIN32 */
|
||||
#include <sys/file.h>
|
||||
#include <dirent.h>
|
||||
|
@ -33,6 +35,13 @@
|
|||
static ptr s_wstring_to_bytevector PROTO((const wchar_t *s));
|
||||
#else
|
||||
static ptr s_string_to_bytevector PROTO((const char *s));
|
||||
# define WIN32_UNUSED
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
# define WIN32_UNUSED UNUSED
|
||||
#else
|
||||
# define WIN32_UNUSED
|
||||
#endif
|
||||
|
||||
/* raises an exception if insufficient space cannot be malloc'd.
|
||||
|
@ -114,7 +123,7 @@ IBOOL S_fixedpathp(inpath) const char *inpath; {
|
|||
res = (c = *path) == 0
|
||||
|| DIRMARKERP(c)
|
||||
#ifdef WIN32
|
||||
|| ((*(path + 1) == ':') && (c >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z'))
|
||||
|| ((*(path + 1) == ':') && ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')))
|
||||
#endif
|
||||
|| ((c == '.')
|
||||
&& ((c = *(path + 1)) == 0
|
||||
|
@ -124,7 +133,7 @@ IBOOL S_fixedpathp(inpath) const char *inpath; {
|
|||
return res;
|
||||
}
|
||||
|
||||
IBOOL S_file_existsp(inpath, followp) const char *inpath; IBOOL followp; {
|
||||
IBOOL S_file_existsp(const char *inpath, WIN32_UNUSED IBOOL followp) {
|
||||
#ifdef WIN32
|
||||
wchar_t *wpath; IBOOL res;
|
||||
WIN32_FILE_ATTRIBUTE_DATA filedata;
|
||||
|
@ -146,7 +155,7 @@ IBOOL S_file_existsp(inpath, followp) const char *inpath; IBOOL followp; {
|
|||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
IBOOL S_file_regularp(inpath, followp) const char *inpath; IBOOL followp; {
|
||||
IBOOL S_file_regularp(const char *inpath, WIN32_UNUSED IBOOL followp) {
|
||||
#ifdef WIN32
|
||||
wchar_t *wpath; IBOOL res;
|
||||
WIN32_FILE_ATTRIBUTE_DATA filedata;
|
||||
|
@ -170,7 +179,7 @@ IBOOL S_file_regularp(inpath, followp) const char *inpath; IBOOL followp; {
|
|||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
IBOOL S_file_directoryp(inpath, followp) const char *inpath; IBOOL followp; {
|
||||
IBOOL S_file_directoryp(const char *inpath, WIN32_UNUSED IBOOL followp) {
|
||||
#ifdef WIN32
|
||||
wchar_t *wpath; IBOOL res;
|
||||
WIN32_FILE_ATTRIBUTE_DATA filedata;
|
||||
|
|
2
c/main.c
2
c/main.c
|
@ -47,7 +47,7 @@ static const char *path_last(const char *p) {
|
|||
const char *s;
|
||||
#ifdef WIN32
|
||||
char c;
|
||||
if ((c = *p) >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
|
||||
if (((c = *p) >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
||||
if (*(p + 1) == ':')
|
||||
p += 2;
|
||||
|
||||
|
|
14
c/new-io.c
14
c/new-io.c
|
@ -20,6 +20,9 @@
|
|||
#include <limits.h>
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#ifdef __MINGW32__
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
#else /* WIN32 */
|
||||
#include <sys/file.h>
|
||||
#include <dirent.h>
|
||||
|
@ -132,6 +135,11 @@ static int is_valid_lz4_length(iptr count);
|
|||
#define O_BINARY 0
|
||||
#endif /* O_BINARY */
|
||||
|
||||
#ifdef WIN32
|
||||
# define WIN32_UNUSED UNUSED
|
||||
#else
|
||||
# define WIN32_UNUSED
|
||||
#endif
|
||||
|
||||
/* These functions are intended for use immediately upon opening
|
||||
* (lockfile) fd. They need to be redesigned for general-purpose
|
||||
|
@ -448,7 +456,7 @@ ptr S_bytevector_read(ptr file, ptr bv, iptr start, iptr count, IBOOL gzflag) {
|
|||
DWORD error_code;
|
||||
SetConsoleCtrlHandler(NULL, TRUE);
|
||||
SetLastError(0);
|
||||
m = read_console(&BVIT(bv,start), (IO_SIZE_T)count);
|
||||
m = read_console((char *)&BVIT(bv,start), (IO_SIZE_T)count);
|
||||
error_code = GetLastError();
|
||||
if (m == 0 && error_code == 0x3e3) {
|
||||
/* Guard against Windows calling the ConsoleCtrlHandler after we
|
||||
|
@ -695,7 +703,7 @@ ptr S_set_fd_pos(ptr file, ptr pos, IBOOL gzflag) {
|
|||
}
|
||||
}
|
||||
|
||||
ptr S_get_fd_non_blocking(ptr file, IBOOL gzflag) {
|
||||
ptr S_get_fd_non_blocking(WIN32_UNUSED ptr file, WIN32_UNUSED IBOOL gzflag) {
|
||||
#ifdef WIN32
|
||||
return Sfalse;
|
||||
#else /* WIN32 */
|
||||
|
@ -713,7 +721,7 @@ ptr S_get_fd_non_blocking(ptr file, IBOOL gzflag) {
|
|||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
ptr S_set_fd_non_blocking(ptr file, IBOOL x, IBOOL gzflag) {
|
||||
ptr S_set_fd_non_blocking(WIN32_UNUSED ptr file, WIN32_UNUSED IBOOL x, WIN32_UNUSED IBOOL gzflag) {
|
||||
#ifdef WIN32
|
||||
return Sstring("unsupported");
|
||||
#else /* WIN32 */
|
||||
|
|
81
c/prim5.c
81
c/prim5.c
|
@ -121,6 +121,12 @@ static ptr s_widechartomultibyte PROTO((unsigned cp, ptr inbv));
|
|||
static ptr s_profile_counters PROTO((void));
|
||||
static ptr s_profile_release_counters PROTO((void));
|
||||
|
||||
#ifdef WIN32
|
||||
# define WIN32_UNUSED UNUSED
|
||||
#else
|
||||
# define WIN32_UNUSED
|
||||
#endif
|
||||
|
||||
#define require(test,who,msg,arg) if (!(test)) S_error1(who, msg, arg)
|
||||
|
||||
ptr S_strerror(INT errnum) {
|
||||
|
@ -274,6 +280,15 @@ static ptr sorted_chunk_list(void) {
|
|||
return sort_chunks(ls, n);
|
||||
}
|
||||
|
||||
#ifdef __MINGW32__
|
||||
# include <inttypes.h>
|
||||
# define PHtx "%" PRIxPTR
|
||||
# define Ptd "%" PRIdPTR
|
||||
#else
|
||||
# define PHtx "%#tx"
|
||||
# define Ptd "%td"
|
||||
#endif
|
||||
|
||||
#ifdef segment_t2_bits
|
||||
static void s_show_info(FILE *out) {
|
||||
void *max_addr = 0;
|
||||
|
@ -296,9 +311,9 @@ static void s_show_info(FILE *out) {
|
|||
}
|
||||
}
|
||||
}
|
||||
addrwidth = snprintf(fmtbuf, FMTBUFSIZE, "%#tx", (ptrdiff_t)max_addr);
|
||||
addrwidth = snprintf(fmtbuf, FMTBUFSIZE, ""PHtx"", (ptrdiff_t)max_addr);
|
||||
if (addrwidth < (INT)strlen(addrtitle)) addrwidth = (INT)strlen(addrtitle);
|
||||
byteswidth = snprintf(fmtbuf, FMTBUFSIZE, "%#tx", (ptrdiff_t)(sizeof(t1table) > sizeof(t2table) ? sizeof(t1table) : sizeof(t2table)));
|
||||
byteswidth = snprintf(fmtbuf, FMTBUFSIZE, ""PHtx"", (ptrdiff_t)(sizeof(t1table) > sizeof(t2table) ? sizeof(t1table) : sizeof(t2table)));
|
||||
snprintf(fmtbuf, FMTBUFSIZE, "%%s %%-%ds %%-%ds\n\n", addrwidth, byteswidth);
|
||||
fprintf(out, fmtbuf, "level", addrtitle, "bytes");
|
||||
snprintf(fmtbuf, FMTBUFSIZE, "%%-5d %%#0%dtx %%#0%dtx\n", addrwidth, byteswidth);
|
||||
|
@ -321,11 +336,11 @@ static void s_show_info(FILE *out) {
|
|||
if ((void *)t1t > max_addr) max_addr = (void *)t1t;
|
||||
}
|
||||
}
|
||||
addrwidth = 1 + snprintf(fmtbuf, FMTBUFSIZE, "%#tx", (ptrdiff_t)max_addr);
|
||||
addrwidth = 1 + snprintf(fmtbuf, FMTBUFSIZE, ""PHtx"", (ptrdiff_t)max_addr);
|
||||
if (addrwidth < (INT)strlen(addrtitle) + 1) addrwidth = (INT)strlen(addrtitle) + 1;
|
||||
snprintf(fmtbuf, FMTBUFSIZE, "%%s %%-%ds %%s\n\n", addrwidth);
|
||||
fprintf(out, fmtbuf, "level", addrtitle, "bytes");
|
||||
snprintf(fmtbuf, FMTBUFSIZE, "%%-5d %%#0%dtx %%#tx\n", (ptrdiff_t)addrwidth);
|
||||
snprintf(fmtbuf, FMTBUFSIZE, "%%-5d %%#0%dtx %"PHtx"\n", (ptrdiff_t)addrwidth);
|
||||
for (i2 = 0; i2 < SEGMENT_T2_SIZE; i2 += 1) {
|
||||
t1table *t1t = S_segment_info[i2];
|
||||
if (t1t != NULL) {
|
||||
|
@ -353,13 +368,13 @@ static void s_show_chunks(FILE *out, ptr sorted_chunks) {
|
|||
if ((void *)chunk > max_header_addr) max_header_addr = (void *)chunk;
|
||||
}
|
||||
|
||||
addrwidth = (INT)snprintf(fmtbuf, FMTBUFSIZE, "%#tx", (ptrdiff_t)max_addr);
|
||||
addrwidth = (INT)snprintf(fmtbuf, FMTBUFSIZE, ""PHtx"", (ptrdiff_t)max_addr);
|
||||
if (addrwidth < (INT)strlen(addrtitle)) addrwidth = (INT)strlen(addrtitle);
|
||||
byteswidth = (INT)snprintf(fmtbuf, FMTBUFSIZE, "%#tx", (ptrdiff_t)(max_segs * bytes_per_segment));
|
||||
byteswidth = (INT)snprintf(fmtbuf, FMTBUFSIZE, ""PHtx"", (ptrdiff_t)(max_segs * bytes_per_segment));
|
||||
if (byteswidth < (INT)strlen(bytestitle)) byteswidth = (INT)strlen(bytestitle);
|
||||
headerbyteswidth = (INT)snprintf(fmtbuf, FMTBUFSIZE, "%#tx", (ptrdiff_t)(sizeof(chunkinfo) + sizeof(seginfo) * max_segs));
|
||||
headeraddrwidth = (INT)snprintf(fmtbuf, FMTBUFSIZE, "%#tx", (ptrdiff_t)max_header_addr);
|
||||
segswidth = (INT)snprintf(fmtbuf, FMTBUFSIZE, "%td", (ptrdiff_t)max_segs);
|
||||
headerbyteswidth = (INT)snprintf(fmtbuf, FMTBUFSIZE, ""PHtx"", (ptrdiff_t)(sizeof(chunkinfo) + sizeof(seginfo) * max_segs));
|
||||
headeraddrwidth = (INT)snprintf(fmtbuf, FMTBUFSIZE, ""PHtx"", (ptrdiff_t)max_header_addr);
|
||||
segswidth = (INT)snprintf(fmtbuf, FMTBUFSIZE, ""Ptd"", (ptrdiff_t)max_segs);
|
||||
headerwidth = headerbyteswidth + headeraddrwidth + 13;
|
||||
|
||||
snprintf(fmtbuf, FMTBUFSIZE, "%%-%ds %%-%ds %%-%ds %%s\n\n", addrwidth, byteswidth, headerwidth);
|
||||
|
@ -447,7 +462,7 @@ static void s_showalloc(IBOOL show_dump, const char *outfn) {
|
|||
|
||||
for (g = 0; g <= generation_total; INCRGEN(g)) {
|
||||
if (count[space_total][g] != 0) {
|
||||
int n = 1 + snprintf(fmtbuf, FMTBUFSIZE, "%td", (ptrdiff_t)count[space_total][g]);
|
||||
int n = 1 + snprintf(fmtbuf, FMTBUFSIZE, ""Ptd"", (ptrdiff_t)count[space_total][g]);
|
||||
column_size[g] = n < 8 ? 8 : n;
|
||||
}
|
||||
}
|
||||
|
@ -505,8 +520,8 @@ static void s_showalloc(IBOOL show_dump, const char *outfn) {
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(out, "segment size = %#tx bytes. percentages show the portion actually occupied.\n", (ptrdiff_t)bytes_per_segment);
|
||||
fprintf(out, "%td segments are presently reserved for future allocation or collection.\n", (ptrdiff_t)S_G.number_of_empty_segments);
|
||||
fprintf(out, "segment size = "PHtx" bytes. percentages show the portion actually occupied.\n", (ptrdiff_t)bytes_per_segment);
|
||||
fprintf(out, ""Ptd" segments are presently reserved for future allocation or collection.\n", (ptrdiff_t)S_G.number_of_empty_segments);
|
||||
|
||||
fprintf(out, "\nMemory chunks obtained and not returned to the O/S:\n\n");
|
||||
sorted_chunks = sorted_chunk_list();
|
||||
|
@ -534,7 +549,7 @@ static void s_showalloc(IBOOL show_dump, const char *outfn) {
|
|||
if (last_seg > max_seg) max_seg = last_seg;
|
||||
}
|
||||
|
||||
segwidth = snprintf(fmtbuf, FMTBUFSIZE, "%#tx ", (ptrdiff_t)max_seg);
|
||||
segwidth = snprintf(fmtbuf, FMTBUFSIZE, ""PHtx" ", (ptrdiff_t)max_seg);
|
||||
segsperline = (99 - segwidth) & ~0xf;
|
||||
|
||||
snprintf(fmtbuf, FMTBUFSIZE, " %%-%ds", segwidth);
|
||||
|
@ -562,7 +577,7 @@ static void s_showalloc(IBOOL show_dump, const char *outfn) {
|
|||
}
|
||||
|
||||
if (chunk->base > next_base && next_base != 0) {
|
||||
fprintf(out, "\n-------- skipping %td segments --------", (ptrdiff_t)(chunk->base - next_base));
|
||||
fprintf(out, "\n-------- skipping "Ptd" segments --------", (ptrdiff_t)(chunk->base - next_base));
|
||||
}
|
||||
|
||||
for (i = 0; i < chunk->segs; i += 1) {
|
||||
|
@ -1018,7 +1033,7 @@ ptr S_uninterned(x) ptr x; {
|
|||
return sym;
|
||||
}
|
||||
|
||||
static ptr s_mkdir(const char *inpath, INT mode) {
|
||||
static ptr s_mkdir(const char *inpath, WIN32_UNUSED INT mode) {
|
||||
INT status; ptr res; char *path;
|
||||
|
||||
path = S_malloc_pathname(inpath);
|
||||
|
@ -1098,7 +1113,7 @@ static ptr s_getmod(const char *inpath, IBOOL followp) {
|
|||
return res;
|
||||
}
|
||||
|
||||
static ptr s_path_atime(const char *inpath, IBOOL followp) {
|
||||
static ptr s_path_atime(const char *inpath, WIN32_UNUSED IBOOL followp) {
|
||||
#ifdef WIN32
|
||||
ptr res;
|
||||
wchar_t *wpath;
|
||||
|
@ -1138,7 +1153,7 @@ static ptr s_path_atime(const char *inpath, IBOOL followp) {
|
|||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
static ptr s_path_ctime(const char *inpath, IBOOL followp) {
|
||||
static ptr s_path_ctime(const char *inpath, WIN32_UNUSED IBOOL followp) {
|
||||
#ifdef WIN32
|
||||
ptr res;
|
||||
wchar_t *wpath;
|
||||
|
@ -1178,7 +1193,7 @@ static ptr s_path_ctime(const char *inpath, IBOOL followp) {
|
|||
#endif /* WIN32 */
|
||||
}
|
||||
|
||||
static ptr s_path_mtime(const char *inpath, IBOOL followp) {
|
||||
static ptr s_path_mtime(const char *inpath, WIN32_UNUSED IBOOL followp) {
|
||||
#ifdef WIN32
|
||||
ptr res;
|
||||
wchar_t *wpath;
|
||||
|
@ -2021,9 +2036,9 @@ static void s_free(uptr addr) {
|
|||
#ifdef FEATURE_ICONV
|
||||
#ifdef WIN32
|
||||
typedef void *iconv_t;
|
||||
typedef __declspec(dllimport) iconv_t (*iconv_open_ft)(const char *tocode, const char *fromcode);
|
||||
typedef __declspec(dllimport) size_t (*iconv_ft)(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
|
||||
typedef __declspec(dllimport) int (*iconv_close_ft)(iconv_t cd);
|
||||
typedef iconv_t (*iconv_open_ft)(const char *tocode, const char *fromcode);
|
||||
typedef size_t (*iconv_ft)(iconv_t cd, char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft);
|
||||
typedef int (*iconv_close_ft)(iconv_t cd);
|
||||
|
||||
static iconv_open_ft iconv_open_f = (iconv_open_ft)0;
|
||||
static iconv_ft iconv_f = (iconv_ft)0;
|
||||
|
@ -2052,7 +2067,7 @@ static ptr s_iconv_trouble(HMODULE h, const char *what) {
|
|||
FreeLibrary(h);
|
||||
n = strlen(what) + strlen(dll) + 17;
|
||||
msg = (char *)malloc(n);
|
||||
sprintf_s(msg, n, "cannot find %s in %s", what, dll);
|
||||
sprintf(msg, "cannot find %s in %s", what, dll);
|
||||
free(dll);
|
||||
r = Sstring_utf8(msg, -1);
|
||||
free(msg);
|
||||
|
@ -2072,14 +2087,14 @@ static ptr s_iconv_open(const char *tocode, const char *fromcode) {
|
|||
if (h == NULL) h = LoadLibraryW(L".\\libiconv.dll");
|
||||
if (h == NULL) h = LoadLibraryW(L".\\libiconv-2.dll");
|
||||
if (h == NULL) return Sstring("cannot load iconv.dll, libiconv.dll, or libiconv-2.dll");
|
||||
if ((iconv_open_f = (iconv_open_ft)GetProcAddress(h, "iconv_open")) == NULL &&
|
||||
(iconv_open_f = (iconv_open_ft)GetProcAddress(h, "libiconv_open")) == NULL)
|
||||
if ((iconv_open_f = (void *)GetProcAddress(h, "iconv_open")) == NULL &&
|
||||
(iconv_open_f = (void *)GetProcAddress(h, "libiconv_open")) == NULL)
|
||||
return s_iconv_trouble(h, "iconv_open or libiconv_open");
|
||||
if ((iconv_f = (iconv_ft)GetProcAddress(h, "iconv")) == NULL &&
|
||||
(iconv_f = (iconv_ft)GetProcAddress(h, "libiconv")) == NULL)
|
||||
if ((iconv_f = (void *)GetProcAddress(h, "iconv")) == NULL &&
|
||||
(iconv_f = (void *)GetProcAddress(h, "libiconv")) == NULL)
|
||||
return s_iconv_trouble(h, "iconv or libiconv");
|
||||
if ((iconv_close_f = (iconv_close_ft)GetProcAddress(h, "iconv_close")) == NULL &&
|
||||
(iconv_close_f = (iconv_close_ft)GetProcAddress(h, "libiconv_close")) == NULL)
|
||||
if ((iconv_close_f = (void *)GetProcAddress(h, "iconv_close")) == NULL &&
|
||||
(iconv_close_f = (void *)GetProcAddress(h, "libiconv_close")) == NULL)
|
||||
return s_iconv_trouble(h, "iconv_close or libiconv_close");
|
||||
iconv_is_loaded = 1;
|
||||
}
|
||||
|
@ -2175,15 +2190,15 @@ static ptr s_multibytetowidechar(unsigned cp, ptr inbv) {
|
|||
inbytes = Sbytevector_length(inbv);
|
||||
|
||||
#if (ptr_bits > int_bits)
|
||||
if ((int)inbytes != inbytes) S_error1("multibyte->string", "input size ~s is beyond MultiByteToWideChar's limit", Sinteger(inbytes));
|
||||
if ((uptr)(int)inbytes != inbytes) S_error1("multibyte->string", "input size ~s is beyond MultiByteToWideChar's limit", Sinteger(inbytes));
|
||||
#endif
|
||||
|
||||
if ((outwords = MultiByteToWideChar(cp, 0, &BVIT(inbv,0), (int)inbytes, NULL, 0)) == 0)
|
||||
if ((outwords = MultiByteToWideChar(cp, 0, (char *)&BVIT(inbv,0), (int)inbytes, NULL, 0)) == 0)
|
||||
S_error1("multibyte->string", "conversion failed: ~a", S_LastErrorString());
|
||||
|
||||
outbv = S_bytevector(outwords * 2);
|
||||
|
||||
if (MultiByteToWideChar(cp, 0, &BVIT(inbv,0), (int)inbytes, (wchar_t *)&BVIT(outbv, 0), outwords) == 0)
|
||||
if (MultiByteToWideChar(cp, 0, (char *)&BVIT(inbv,0), (int)inbytes, (wchar_t *)&BVIT(outbv, 0), outwords) == 0)
|
||||
S_error1("multibyte->string", "conversion failed: ~a", S_LastErrorString());
|
||||
|
||||
return outbv;
|
||||
|
@ -2195,7 +2210,7 @@ static ptr s_widechartomultibyte(unsigned cp, ptr inbv) {
|
|||
inwords = Sbytevector_length(inbv) / 2;
|
||||
|
||||
#if (ptr_bits > int_bits)
|
||||
if ((int)inwords != inwords) S_error1("multibyte->string", "input size ~s is beyond WideCharToMultiByte's limit", Sinteger(inwords));
|
||||
if ((uptr)(int)inwords != inwords) S_error1("multibyte->string", "input size ~s is beyond WideCharToMultiByte's limit", Sinteger(inwords));
|
||||
#endif
|
||||
|
||||
if ((outbytes = WideCharToMultiByte(cp, 0, (wchar_t *)&BVIT(inbv,0), (int)inwords, NULL, 0, NULL, NULL)) == 0)
|
||||
|
@ -2203,7 +2218,7 @@ static ptr s_widechartomultibyte(unsigned cp, ptr inbv) {
|
|||
|
||||
outbv = S_bytevector(outbytes);
|
||||
|
||||
if (WideCharToMultiByte(cp, 0, (wchar_t *)&BVIT(inbv,0), (int)inwords, &BVIT(outbv, 0), outbytes, NULL, NULL) == 0)
|
||||
if (WideCharToMultiByte(cp, 0, (wchar_t *)&BVIT(inbv,0), (int)inwords, (char *)&BVIT(outbv, 0), outbytes, NULL, NULL) == 0)
|
||||
S_error1("string->multibyte", "conversion failed: ~a", S_LastErrorString());
|
||||
|
||||
return outbv;
|
||||
|
|
|
@ -433,7 +433,7 @@ static const char *path_last(p) const char *p; {
|
|||
#ifdef WIN32
|
||||
char c;
|
||||
|
||||
if ((c = *p) >= 'a' && c <= 'z' || c >= 'A' && c <= 'Z')
|
||||
if (((c = *p) >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
|
||||
if (*(p + 1) == ':')
|
||||
p += 2;
|
||||
#endif
|
||||
|
|
|
@ -535,7 +535,7 @@ void S_noncontinuable_interrupt() {
|
|||
}
|
||||
|
||||
#ifdef WIN32
|
||||
ptr S_dequeue_scheme_signals(ptr tc) {
|
||||
ptr S_dequeue_scheme_signals(UNUSED ptr tc) {
|
||||
return Snil;
|
||||
}
|
||||
|
||||
|
@ -543,7 +543,7 @@ ptr S_allocate_scheme_signal_queue() {
|
|||
return (ptr)0;
|
||||
}
|
||||
|
||||
void S_register_scheme_signal(sig) iptr sig; {
|
||||
void S_register_scheme_signal(UNUSED iptr sig) {
|
||||
S_error("register_scheme_signal", "unsupported in this version");
|
||||
}
|
||||
|
||||
|
|
|
@ -519,7 +519,7 @@ void S_stats_init() {
|
|||
/* Use GetSystemTimePreciseAsFileTime when available (Windows 8 and later). */
|
||||
HMODULE h = LoadLibraryW(L"kernel32.dll");
|
||||
if (h != NULL) {
|
||||
GetSystemTimeAsFileTime_t proc = (GetSystemTimeAsFileTime_t)GetProcAddress(h, "GetSystemTimePreciseAsFileTime");
|
||||
GetSystemTimeAsFileTime_t proc = (void *)GetProcAddress(h, "GetSystemTimePreciseAsFileTime");
|
||||
if (proc != NULL)
|
||||
s_GetSystemTimeAsFileTime = proc;
|
||||
else
|
||||
|
|
10
c/thread.h
10
c/thread.h
|
@ -35,7 +35,7 @@ typedef void s_thread_rv_t;
|
|||
#define s_thread_self() GetCurrentThreadId()
|
||||
#define s_thread_equal(t1, t2) ((t1) == (t2))
|
||||
/* CreateThread description says to use _beginthread if thread uses the C library */
|
||||
#define s_thread_create(start_routine, arg) (_beginthread(start_routine, 0, arg) == -1 ? EAGAIN : 0)
|
||||
#define s_thread_create(start_routine, arg) (_beginthread(start_routine, 0, arg) == (uintptr_t)-1 ? EAGAIN : 0)
|
||||
#define s_thread_key_create(key) ((*key = TlsAlloc()) == TLS_OUT_OF_INDEXES ? EAGAIN : 0)
|
||||
#define s_thread_key_delete(key) (TlsFree(key) == 0 ? EINVAL : 0)
|
||||
#define s_thread_getspecific(key) TlsGetValue(key)
|
||||
|
@ -44,12 +44,12 @@ typedef void s_thread_rv_t;
|
|||
#define s_thread_mutex_lock(mutex) (EnterCriticalSection(mutex), 0)
|
||||
#define s_thread_mutex_unlock(mutex) (LeaveCriticalSection(mutex), 0)
|
||||
#define s_thread_mutex_trylock(mutex) (TryEnterCriticalSection(mutex) ? 0 : EBUSY)
|
||||
#define s_thread_mutex_destroy(mutex) (DeleteCriticalSection(mutex), 0)
|
||||
#define s_thread_mutex_destroy(mutex) DeleteCriticalSection(mutex)
|
||||
#define s_thread_cond_init(cond) InitializeConditionVariable(cond)
|
||||
#define s_thread_cond_signal(cond) (WakeConditionVariable(cond), 0)
|
||||
#define s_thread_cond_broadcast(cond) (WakeAllConditionVariable(cond), 0)
|
||||
#define s_thread_cond_signal(cond) WakeConditionVariable(cond)
|
||||
#define s_thread_cond_broadcast(cond) WakeAllConditionVariable(cond)
|
||||
#define s_thread_cond_wait(cond, mutex) (SleepConditionVariableCS(cond, mutex, INFINITE) == 0 ? EINVAL : 0)
|
||||
#define s_thread_cond_destroy(cond) (0)
|
||||
#define s_thread_cond_destroy(cond) /* empty */
|
||||
|
||||
#else /* FEATURE_WINDOWS */
|
||||
|
||||
|
|
|
@ -251,7 +251,11 @@ struct timespec;
|
|||
#define NSECMTIME(sb) 0
|
||||
#define ICONV_INBUF_TYPE char **
|
||||
struct timespec;
|
||||
#define UNUSED
|
||||
#if defined(__MINGW32__)
|
||||
# define UNUSED __attribute__((__unused__))
|
||||
#else
|
||||
# define UNUSED
|
||||
#endif
|
||||
#if defined(__MINGW32__) && (machine_type == machine_type_ti3nt || machine_type == machine_type_i3nt)
|
||||
#define time_t __time64_t
|
||||
#define time _time64
|
||||
|
|
|
@ -252,7 +252,7 @@ static ptr s_ErrorString(DWORD dwMessageId) {
|
|||
if (len == 0) {
|
||||
#define HEXERRBUFSIZ ((sizeof(dwMessageId) * 2) + 3)
|
||||
char hexerrbuf[HEXERRBUFSIZ];
|
||||
snprintf(hexerrbuf, HEXERRBUFSIZ, "0x%x", dwMessageId);
|
||||
snprintf(hexerrbuf, HEXERRBUFSIZ, "0x%x", (unsigned int)dwMessageId);
|
||||
return Sstring(hexerrbuf);
|
||||
#undef HEXERRBUFSIZ
|
||||
}
|
||||
|
@ -429,7 +429,7 @@ int S_windows_unlink(const char *pathname) {
|
|||
}
|
||||
}
|
||||
|
||||
char *S_windows_getcwd(char *buffer, int maxlen) {
|
||||
char *S_windows_getcwd(char *buffer, UNUSED int maxlen) {
|
||||
wchar_t wbuffer[PATH_MAX];
|
||||
if (_wgetcwd(wbuffer, PATH_MAX) == NULL) return NULL;
|
||||
if (WideCharToMultiByte(CP_UTF8,0,wbuffer,-1,buffer,PATH_MAX,NULL,NULL) == 0) {
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
(define-constant asm-arg-reg-cnt 1)
|
||||
(define-constant asm-fpreg-max 2)
|
||||
(define-constant typedef-ptr "void *")
|
||||
(define-constant typedef-iptr "int")
|
||||
(define-constant typedef-uptr "unsigned int")
|
||||
(define-constant typedef-iptr "long")
|
||||
(define-constant typedef-uptr "unsigned long")
|
||||
(define-constant typedef-i8 "char")
|
||||
(define-constant typedef-u8 "unsigned char")
|
||||
(define-constant typedef-i16 "short")
|
||||
|
|
|
@ -31,8 +31,8 @@
|
|||
(define-constant asm-arg-reg-cnt 1)
|
||||
(define-constant asm-fpreg-max 2)
|
||||
(define-constant typedef-ptr "void *")
|
||||
(define-constant typedef-iptr "int")
|
||||
(define-constant typedef-uptr "unsigned int")
|
||||
(define-constant typedef-iptr "long")
|
||||
(define-constant typedef-uptr "unsigned long")
|
||||
(define-constant typedef-i8 "char")
|
||||
(define-constant typedef-u8 "unsigned char")
|
||||
(define-constant typedef-i16 "short")
|
||||
|
|
Loading…
Reference in New Issue
Block a user