Skip to content

Commit

Permalink
Use better runtime/Makefile rules for gen/sizes
Browse files Browse the repository at this point in the history
Avoid using `.stamp` file.
  • Loading branch information
MatthewFluet committed Jan 16, 2020
1 parent 304873d commit 45041d9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
15 changes: 6 additions & 9 deletions runtime/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Copyright (C) 2010-2013,2018,2019 Matthew Fluet.
## Copyright (C) 2010-2013,2018,2019-2020 Matthew Fluet.
# Copyright (C) 1999-2009 Henry Cejtin, Matthew Fluet, Suresh
# Jagannathan, and Stephen Weeks.
# Copyright (C) 1997-2000 NEC Research Institute.
Expand Down Expand Up @@ -294,14 +294,11 @@ libmlton-pic.a: $(MLTON_PIC_OBJS)

### gen/sizes ###

gen/sizes: gen/gen-sizes.stamp
@touch $@
gen/gen-sizes.stamp: gen/gen-sizes.c libmlton.a $(HFILES)
$(CROSS_PREFIX)$(CC) $(OPTCFLAGS) -o gen/gen-sizes gen/gen-sizes.c -L. -lmlton
rm -f gen/sizes
cd gen && ./gen-sizes
rm -f gen/gen-sizes$(EXE) gen/gen-sizes
touch $@
gen/sizes: gen/gen-sizes$(EXE)
./gen/gen-sizes > gen/sizes

gen/gen-sizes$(EXE): gen/gen-sizes.c util.o $(HFILES)
$(CROSS_PREFIX)$(CC) $(OPTCFLAGS) -o gen/gen-sizes gen/gen-sizes.c util.o


######
Expand Down
1 change: 0 additions & 1 deletion runtime/gen/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
/gen-basis-ffi.exe
/gen-sizes
/gen-sizes.exe
/gen-sizes.stamp
/gen-types
/gen-types.exe
/gen-types.stamp
Expand Down
28 changes: 11 additions & 17 deletions runtime/gen/gen-sizes.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (C) 2016-2017 Matthew Fluet.
/* Copyright (C) 2016-2017,2020 Matthew Fluet.
* Copyright (C) 2007 Henry Cejtin, Matthew Fluet, Suresh
* Jagannathan, and Stephen Weeks.
*
Expand All @@ -8,26 +8,20 @@

#define MLTON_GC_INTERNAL_TYPES
#include "platform.h"
struct GC_state gcState;

int main (__attribute__ ((unused)) int argc,
__attribute__ ((unused)) char* argv[]) {
FILE *sizesFd;

sizesFd = fopen_safe ("sizes", "w");

fprintf (sizesFd, "sequenceMetaData = %"PRIuMAX"\n", (uintmax_t)GC_SEQUENCE_METADATA_SIZE);
fprintf (sizesFd, "cint = %"PRIuMAX"\n", (uintmax_t)sizeof(C_Int_t));
fprintf (sizesFd, "cpointer = %"PRIuMAX"\n", (uintmax_t)sizeof(C_Pointer_t));
fprintf (sizesFd, "cptrdiff = %"PRIuMAX"\n", (uintmax_t)sizeof(C_Ptrdiff_t));
fprintf (sizesFd, "csize = %"PRIuMAX"\n", (uintmax_t)sizeof(C_Size_t));
fprintf (sizesFd, "header = %"PRIuMAX"\n", (uintmax_t)sizeof(GC_header));
fprintf (sizesFd, "mplimb = %"PRIuMAX"\n", (uintmax_t)sizeof(C_MPLimb_t));
fprintf (sizesFd, "normalMetaData = %"PRIuMAX"\n", (uintmax_t)GC_NORMAL_METADATA_SIZE);
fprintf (sizesFd, "objptr = %"PRIuMAX"\n", (uintmax_t)sizeof(objptr));
fprintf (sizesFd, "seqIndex = %"PRIuMAX"\n", (uintmax_t)sizeof(GC_sequenceLength));

fclose_safe(sizesFd);
fprintf (stdout, "cint = %"PRIuMAX"\n", (uintmax_t)sizeof(C_Int_t));
fprintf (stdout, "cpointer = %"PRIuMAX"\n", (uintmax_t)sizeof(C_Pointer_t));
fprintf (stdout, "cptrdiff = %"PRIuMAX"\n", (uintmax_t)sizeof(C_Ptrdiff_t));
fprintf (stdout, "csize = %"PRIuMAX"\n", (uintmax_t)sizeof(C_Size_t));
fprintf (stdout, "header = %"PRIuMAX"\n", (uintmax_t)sizeof(GC_header));
fprintf (stdout, "mplimb = %"PRIuMAX"\n", (uintmax_t)sizeof(C_MPLimb_t));
fprintf (stdout, "normalMetaData = %"PRIuMAX"\n", (uintmax_t)GC_NORMAL_METADATA_SIZE);
fprintf (stdout, "objptr = %"PRIuMAX"\n", (uintmax_t)sizeof(objptr));
fprintf (stdout, "seqIndex = %"PRIuMAX"\n", (uintmax_t)sizeof(GC_sequenceLength));
fprintf (stdout, "sequenceMetaData = %"PRIuMAX"\n", (uintmax_t)GC_SEQUENCE_METADATA_SIZE);

return 0;
}

0 comments on commit 45041d9

Please sign in to comment.