[MLton-commit] r4306
Matthew Fluet
MLton@mlton.org
Tue, 24 Jan 2006 19:19:10 -0800
More unified c-side/ml-side basis functions
----------------------------------------------------------------------
U mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Stat.c
A mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/IEEEReal-consts.c
U mlton/branches/on-20050822-x86_64-branch/runtime/basis/System/Date.c
U mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h
U mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def
U mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c
----------------------------------------------------------------------
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Stat.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Stat.c 2006-01-25 01:56:56 UTC (rev 4305)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/Posix/FileSys/Stat.c 2006-01-25 03:19:07 UTC (rev 4306)
@@ -46,6 +46,14 @@
return statbuf.st_ctime;
}
+C_BlkSize_t Posix_FileSys_Stat_getBlkSize (void) {
+ return statbuf.st_blksize;
+}
+
+C_BlkCnt_t Posix_FileSys_Stat_getBlkCnt (void) {
+ return statbuf.st_blocks;
+}
+
C_Errno_t(C_Int_t) Posix_FileSys_Stat_fstat (C_Fd_t f) {
return fstat (f, &statbuf);
}
Added: mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/IEEEReal-consts.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/IEEEReal-consts.c 2006-01-25 01:56:56 UTC (rev 4305)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/Real/IEEEReal-consts.c 2006-01-25 03:19:07 UTC (rev 4306)
@@ -0,0 +1,33 @@
+#include "platform.h"
+
+#define FE_NOSUPPORT -1
+
+/* Can't handle undefined rounding modes with code like the following.
+ * #ifndef FE_TONEAREST
+ * #define FE_TONEAREST FE_NOSUPPORT
+ * #endif
+ * On some platforms, FE_* are defined via an enum, not the
+ * preprocessor, and hence don't show up as #defined. In that case,
+ * the below code overwrites them.
+ */
+
+#if not HAS_FEROUND
+#ifndef FE_TONEAREST
+#define FE_TONEAREST 0
+#endif
+#ifndef FE_DOWNWARD
+#define FE_DOWNWARD 1
+#endif
+#ifndef FE_UPWARD
+#define FE_UPWARD 2
+#endif
+#ifndef FE_TOWARDZERO
+#define FE_TOWARDZERO 3
+#endif
+#endif
+
+const C_Int_t IEEEReal_RoundingMode_FE_TONEAREST = FE_TONEAREST;
+const C_Int_t IEEEReal_RoundingMode_FE_DOWNWARD = FE_DOWNWARD;
+const C_Int_t IEEEReal_RoundingMode_FE_NOSUPPORT = FE_NOSUPPORT;
+const C_Int_t IEEEReal_RoundingMode_FE_UPWARD = FE_UPWARD;
+const C_Int_t IEEEReal_RoundingMode_FE_TOWARDZERO = FE_TOWARDZERO;
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/basis/System/Date.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/basis/System/Date.c 2006-01-25 01:56:56 UTC (rev 4305)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/basis/System/Date.c 2006-01-25 03:19:07 UTC (rev 4306)
@@ -58,6 +58,6 @@
return mktime(&tm_in);
}
-C_Size_t Date_strfTime(String_t buf, C_Size_t n, NullString_t fmt) {
+C_Size_t Date_strfTime(Array(Char8_t) buf, C_Size_t n, NullString_t fmt) {
return strftime((char*)(buf), n, (char*)(fmt), &tm_in);
}
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h 2006-01-25 01:56:56 UTC (rev 4305)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/cenv.h 2006-01-25 03:19:07 UTC (rev 4306)
@@ -12,7 +12,7 @@
/* GNU C Library Feature Macros */
#define _ISOC99_SOURCE
#define _BSD_SOURCE
-// #define _XOPEN_SOURCE 600
+#define _XOPEN_SOURCE 600
/* Only enable _POSIX_C_SOURCE on platforms that don't have broken
* system headers.
*/
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def 2006-01-25 01:56:56 UTC (rev 4305)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/basis-ffi.def 2006-01-25 03:19:07 UTC (rev 4306)
@@ -23,7 +23,7 @@
Date.localOffset = _import : unit -> C.Double.t
Date.localTime = _import : C.Time.t ref -> C.Int.t C.Errno.t
Date.mkTime = _import : unit -> C.Time.t C.Errno.t
-Date.strfTime = _import : String8.t * C.Size.t * NullString8.t -> C.Size.t
+Date.strfTime = _import : Char8.t array * C.Size.t * NullString8.t -> C.Size.t
IEEEReal.RoundingMode.FE_DOWNWARD = _const : C.Int.t
IEEEReal.RoundingMode.FE_NOSUPPORT = _const : C.Int.t
IEEEReal.RoundingMode.FE_TONEAREST = _const : C.Int.t
@@ -383,3 +383,5 @@
Posix.FileSys.Stat.fstat = _import : C.Fd.t -> C.Int.t C.Errno.t
Posix.FileSys.Stat.lstat = _import : NullString8.t -> C.Int.t C.Errno.t
Posix.FileSys.Stat.stat = _import : NullString8.t -> C.Int.t C.Errno.t
+Posix.FileSys.Stat.getBlkSize = _import : unit -> C.BlkSize.t
+Posix.FileSys.Stat.getBlkCnt = _import : unit -> C.BlkCnt.t
Modified: mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c
===================================================================
--- mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c 2006-01-25 01:56:56 UTC (rev 4305)
+++ mlton/branches/on-20050822-x86_64-branch/runtime/gen/gen-types.c 2006-01-25 03:19:07 UTC (rev 4306)
@@ -123,12 +123,12 @@
#define systype(t, bt, name) \
do { \
writeString (fd, "typedef "); \
- writeString (fd, "/* "); \
writeString (fd, #t); \
- writeString (fd, " */ "); \
+ writeString (fd, " /* "); \
writeString (fd, bt); \
writeUintmaxU (fd, CHAR_BIT * sizeof(t));\
writeString (fd, "_t "); \
+ writeString (fd, "*/ "); \
writeString (fd, name); \
writeString (fd, ";"); \
writeNewline (fd); \
@@ -235,6 +235,8 @@
writeNewline (fd);
writeString (fd, "/* from <sys/types.h> */");
writeNewline (fd);
+ systype(blkcnt_t, "Int", "C_BlkCnt_t");
+ systype(blksize_t, "Int", "C_BlkSize_t");
chknumsystype(clock_t, "C_Clock");
chknumsystype(dev_t, "C_Dev_t");
chkintsystype(gid_t, "C_GId_t");