[comp.unix.xenix] alloca

daveh@marob.masa.com (Dave Hammond) (12/13/89)

I tried emailing this, but our mailer couldn't find buddha.

Date: Tue, 12 Dec 89 22:31 EST
From: daveh@marob.masa.com (Dave Hammond)
To: rodeen@buddha.uucp
Subject: Re: alloca function needed
Newsgroups: comp.unix.xenix
In-Reply-To: <718@buddha.UUCP>

In article <718@buddha.UUCP> you write:
>Has anyone got the GNU diff program to compile under Xenix 386 2.3.2?  
>When I tried I got a link error reporting alloca missing.  
>
>If anyone has an alloca function for Xenix or knows where one is archived
>I would appreciate it.

I have an excellent assembler version of alloca() for Xenix 386, written
by Chip Salzenberg.  If he doesn't send it to you directly, I can post a
copy here.

--
Dave Hammond
daveh@marob.masa.com
uunet!masa.com!marob!daveh

simon@ms.uky.edu (G. Simon Gales) (07/02/90)

I'm need an alloc() for Xenix, to compile gas/gcc/etc.  I know this has been
asked before, I just don't know where to get it from!

chip@tct.uucp (Chip Salzenberg) (07/03/90)

According to simon@ms.uky.edu (G. Simon Gales):
>I'm need an alloc() for Xenix, to compile gas/gcc/etc.

Your wish is my sharchive...

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  alloca386.s Makefile
# Wrapped by chip@tct on Tue Jul  3 11:14:43 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'alloca386.s' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'alloca386.s'\"
else
echo shar: Extracting \"'alloca386.s'\" \(1282 characters\)
sed "s/^X//" >'alloca386.s' <<'END_OF_FILE'
X; alloca386.s 1.2
X; GNU-compatible stack allocation function for Xenix/386.
X; Written by Chip Salzenberg at ComDev.
X; Last modified 90/01/11
X
X	TITLE   $alloca386
X
X	.386
XDGROUP	GROUP	CONST, _BSS, _DATA
X_DATA	SEGMENT  DWORD USE32 PUBLIC 'DATA'
X_DATA      ENDS
X_BSS	SEGMENT  DWORD USE32 PUBLIC 'BSS'
X_BSS      ENDS
XCONST	SEGMENT  DWORD USE32 PUBLIC 'CONST'
XCONST      ENDS
X_TEXT	SEGMENT  DWORD USE32 PUBLIC 'CODE'
X	ASSUME   CS: _TEXT, DS: DGROUP, SS: DGROUP, ES: DGROUP
X
X	PUBLIC  _alloca
X_alloca PROC NEAR
X
X; Get argument.
X	pop     edx             ; edx -> return address
X	pop     eax             ; eax = amount to allocate
X
X; Validate allocation amount.
X	add     eax,3
X	and     eax,not 3
X	cmp     eax,0
X	jg      aa_size_ok
X	mov     eax,4
Xaa_size_ok:
X
X; Allocate stack space.
X	mov     ecx,esp         ; ecx -> old stack pointer
X	sub     esp,eax         ; perform allocation
X	mov     eax,esp         ; eax -> new stack pointer
X
X; Copy the three saved register variables from old stack top to new stack top.
X; They may not be there.  So we waste twelve bytes.  Big fat hairy deal.
X	push    DWORD PTR 8[ecx]
X	push    DWORD PTR 4[ecx]
X	push    DWORD PTR 0[ecx]
X
X; Push something so the caller can pop it off.
X	push    eax
X
X; Return to caller.
X	jmp     edx
X
X_alloca ENDP
X
X_TEXT   ENDS
X	END
END_OF_FILE
if test 1282 -ne `wc -c <'alloca386.s'`; then
    echo shar: \"'alloca386.s'\" unpacked with wrong size!
fi
# end of 'alloca386.s'
fi
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(215 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X# Makefile for alloca386
X
XLIB     = Sliballoca.a
XOBJ     = alloca386.o
X
X$(LIB): $(OBJ)
X	ar rc $(LIB) $(OBJ)
X	ranlib $(LIB)
X
Xclean:
X	rm -f $(OBJ)
Xclobber: clean
X	rm -f $(LIB)
X
X.SUFFIXES: .s
X.s.o:
X	masm -Mx -o$@ $*.s
END_OF_FILE
if test 215 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
echo shar: End of shell archive.
exit 0
-- 
Chip Salzenberg at ComDev/TCT     <chip@tct.uucp>, <uunet!ateng!tct!chip>