Import Upstream version 20180207
[hcoop/debian/mlton.git] / runtime / gc / read_write.c
CommitLineData
7f918cf1
CE
1/* Copyright (C) 1999-2006 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 * Copyright (C) 1997-2000 NEC Research Institute.
4 *
5 * MLton is released under a BSD-style license.
6 * See the file MLton-LICENSE for details.
7 */
8
9static inline objptr readObjptr (FILE *f) {
10 objptr res;
11 fread_safe (&res, sizeof(objptr), 1, f);
12 return res;
13}
14
15static inline pointer readPointer (FILE *f) {
16 uintptr_t res;
17 fread_safe (&res, sizeof(uintptr_t), 1, f);
18 return (pointer)res;
19}
20
21static inline void writeObjptr (FILE *f, objptr op) {
22 fwrite_safe (&op, sizeof(objptr), 1, f);
23}
24
25static inline void writePointer (FILE *f, pointer p) {
26 uintptr_t u = (uintptr_t)p;
27 fwrite_safe (&u, sizeof(uintptr_t), 1, f);
28}