aboutsummaryrefslogtreecommitdiff
path: root/sys/memdbg/mgdptr.x
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2015-07-08 20:46:52 -0400
commitfa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch)
treebdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/memdbg/mgdptr.x
downloadiraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz
Initial commit
Diffstat (limited to 'sys/memdbg/mgdptr.x')
-rw-r--r--sys/memdbg/mgdptr.x33
1 files changed, 33 insertions, 0 deletions
diff --git a/sys/memdbg/mgdptr.x b/sys/memdbg/mgdptr.x
new file mode 100644
index 00000000..4c6cce22
--- /dev/null
+++ b/sys/memdbg/mgdptr.x
@@ -0,0 +1,33 @@
+# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc.
+
+# MGDPTR -- Given the fwa of a memory area, compute a pointer to the start
+# of the data area which satisfies the desired alignment criteria. Memory
+# is allocated in units of chars, and ZLOCVA, ZMALOC, etc., return pointers
+# in units of chars.
+
+pointer procedure mgdptr (fwa, dtype, sz_align, fwa_align)
+
+int fwa, dtype, sz_align, fwa_align
+long bufadr
+pointer bufptr
+int modulus, loc_Mem
+int sizeof()
+data loc_Mem /NULL/
+
+begin
+ # Compute the address of the start of the user buffer area, which
+ # must be aligned with fwa_align (usually Mem) for all data types.
+
+ if (loc_Mem == NULL)
+ call zlocva (Memc, loc_Mem)
+ bufadr = fwa + SZ_INT
+
+ modulus = mod (bufadr - fwa_align, sz_align)
+ if (modulus != 0)
+ bufadr = bufadr + (sz_align - modulus)
+
+ # Compute the buffer pointer for the desired datatype.
+ bufptr = (bufadr - loc_Mem) / sizeof(dtype) + 1
+
+ return (bufptr)
+end