aboutsummaryrefslogtreecommitdiff
path: root/sys/fmio/fmiobind.x
diff options
context:
space:
mode:
authorJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
committerJoe Hunkeler <jhunkeler@gmail.com>2015-08-11 16:51:37 -0400
commit40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch)
tree4464880c571602d54f6ae114729bf62a89518057 /sys/fmio/fmiobind.x
downloadiraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fmio/fmiobind.x')
-rw-r--r--sys/fmio/fmiobind.x61
1 files changed, 61 insertions, 0 deletions
diff --git a/sys/fmio/fmiobind.x b/sys/fmio/fmiobind.x
new file mode 100644
index 00000000..b31c7ada
--- /dev/null
+++ b/sys/fmio/fmiobind.x
@@ -0,0 +1,61 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+include <mach.h>
+include "fmio.h"
+
+# FMIO_BIND -- Called when a new datafile is being created, to bind the
+# current datafile parameters set in the descriptor to the physical datafile.
+
+procedure fmio_bind (fm)
+
+pointer fm #I FMIO descriptor
+
+pointer ft, pti, pt
+int chan, szbpage, ftoff, ftlen, ptioff, ptilen, ptlen
+
+begin
+ if (FM_ACTIVE(fm) != NO)
+ return
+
+ # Initialize buffer sizes.
+ call fmio_setbuf (fm)
+
+ chan = FM_CHAN(fm)
+ szbpage = FM_SZBPAGE(fm)
+ ftoff = LEN_DHSTRUCT + 1
+ ftlen = (FM_NLFILES(fm) + 1) * LEN_FTE
+ ptioff = ftoff + (FM_NLFILES(fm) + 1) * LEN_FTEX
+ ptilen = FM_PTILEN(fm)
+ ptlen = szbpage / (SZ_SHORT * SZB_CHAR)
+
+ # Determine the byte offset of the first data page.
+ FM_DATASTART(fm) = max (1,
+ (((ptioff+ptilen-1) * SZ_INT*SZB_CHAR) + szbpage-1) /
+ szbpage) * szbpage + 1
+
+ # Initialize the file table.
+ call calloc (ft, ftlen, TY_STRUCT)
+ FM_FTOFF(fm) = ftoff
+ FM_FTLASTNF(fm) = 0
+ FM_FTABLE(fm) = ft
+
+ # Initialize the page table index.
+ call calloc (pti, ptilen, TY_INT)
+ FM_PTIOFF(fm) = ptioff
+ FM_PTINPTI(fm) = 0
+ FM_PTINDEX(fm) = pti
+
+ # Initialize the page table, stored in the data pages. Note that the
+ # page table length must be an integral multiple of the page size.
+
+ call calloc (pt, ptlen, TY_SHORT)
+ FM_PTLEN(fm) = ptlen
+ FM_PTNPTE(fm) = 0
+ FM_PTLUPTE(fm) = 0
+ FM_PTABLE(fm) = pt
+
+ FM_ACTIVE(fm) = YES
+ FM_DHMODIFIED(fm) = YES
+
+ call fm_sync (fm)
+end