xref: /csrg-svn/lib/libc/vax/sys/cache.lib/getuid.c (revision 47917)
1*47917Sbostic /*
2*47917Sbostic  * Copyright (c) 1983 The Regents of the University of California.
3*47917Sbostic  * All rights reserved.
4*47917Sbostic  *
5*47917Sbostic  * Redistribution and use in source and binary forms are permitted
6*47917Sbostic  * provided that the above copyright notice and this paragraph are
7*47917Sbostic  * duplicated in all such forms and that any documentation,
8*47917Sbostic  * advertising materials, and other materials related to such
9*47917Sbostic  * distribution and use acknowledge that the software was developed
10*47917Sbostic  * by the University of California, Berkeley.  The name of the
11*47917Sbostic  * University may not be used to endorse or promote products derived
12*47917Sbostic  * from this software without specific prior written permission.
13*47917Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*47917Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*47917Sbostic  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
16*47917Sbostic  */
17*47917Sbostic 
18*47917Sbostic #if defined(LIBC_SCCS) && !defined(lint)
19*47917Sbostic 	.asciz "@(#)getuid.c	5.1 (Berkeley) 04/12/91"
20*47917Sbostic #endif /* LIBC_SCCS and not lint */
21*47917Sbostic 
22*47917Sbostic #include "SYS.h"
23*47917Sbostic 
24*47917Sbostic 	.data
25*47917Sbostic myuid:	.long	-1
26*47917Sbostic myeuid:	.long	-1
27*47917Sbostic 	.text
28*47917Sbostic 
29*47917Sbostic ENTRY(getuid)
30*47917Sbostic 	movl	myuid,r0	# check cache
31*47917Sbostic 	cmpl	$-1,r0
32*47917Sbostic 	bneq	doit
33*47917Sbostic 	ret
34*47917Sbostic doit:
35*47917Sbostic 	chmk	$SYS_getuid
36*47917Sbostic 	jcs	err
37*47917Sbostic 	movl	r0,myuid	# set cache
38*47917Sbostic 	movl	r1,myeuid	# set cache
39*47917Sbostic 	ret			# uid = getuid();
40*47917Sbostic 
41*47917Sbostic ENTRY(geteuid)
42*47917Sbostic 	movl	myeuid,r0	# check cache
43*47917Sbostic 	cmpl	$-1,r0
44*47917Sbostic 	bneq	doit
45*47917Sbostic 	ret
46*47917Sbostic doit:
47*47917Sbostic 	chmk	$SYS_getuid
48*47917Sbostic 	jcs	err
49*47917Sbostic 	movl	r0,myuid	# set cache
50*47917Sbostic 	movl	r1,r0
51*47917Sbostic 	movl	r0,myeuid	# set cache
52*47917Sbostic 	ret			# uid = geteuid();
53*47917Sbostic err:
54*47917Sbostic 	jmp cerror
55*47917Sbostic 
56*47917Sbostic ENTRY(setreuid)
57*47917Sbostic 	mnegl	$1,myuid
58*47917Sbostic 	mnegl	$1,myeuid
59*47917Sbostic 	chmk	$SYS_setreuid
60*47917Sbostic 	jcs	err
61*47917Sbostic 	ret		# setreuid(ruid, euid)
62