diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/memdbg/coerce.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/memdbg/coerce.x')
-rw-r--r-- | sys/memdbg/coerce.x | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/sys/memdbg/coerce.x b/sys/memdbg/coerce.x new file mode 100644 index 00000000..7d42f3bf --- /dev/null +++ b/sys/memdbg/coerce.x @@ -0,0 +1,25 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +# COERCE -- Coerce a pointer from one datatype to another, choosing the +# next larger element for t2 in the event that t1 is not aligned with t2. + +pointer procedure coerce (ptr, type1, type2) + +pointer ptr # input pointer +int type1, type2 # from, to data types +int n +pointer p +include <szdtype.inc> + +begin + p = ptr - 1 + if (type1 == TY_CHAR) + return (p / ty_size[type2] + 1) + else if (type2 == TY_CHAR) + return (p * ty_size[type1] + 1) + else { + p = p * ty_size[type1] # ptr to char + n = ty_size[type2] + return (((p + n-1) / n) + 1) + } +end |