xref: /titanic_50/usr/src/stand/lib/sa/unistd.c (revision c77a61a72b5ecdc507d6cf104142edd371a16c84)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #pragma ident	"%Z%%M%	%I%	%E% SMI"
28 
29 #include <netdb.h>
30 #include <string.h>
31 #include <unistd.h>
32 #include <sys/socket.h>
33 #include <sys/sysmacros.h>
34 #include <sys/promif.h>
35 
36 static char hostname[MAXHOSTNAMELEN] = "UNKNOWN";
37 
38 /*
39  * Get system hostname
40  */
41 int
42 gethostname(char *name, int namelen)
43 {
44 	(void) strlcpy(name, hostname, MIN(namelen, MAXHOSTNAMELEN));
45 	return (0);
46 }
47 
48 /*
49  * Set system hostname
50  */
51 int
52 sethostname(char *name, int namelen)
53 {
54 	(void) strlcpy(hostname, name, MIN(namelen + 1, MAXHOSTNAMELEN));
55 	return (0);
56 }
57 
58 /*
59  * Get the current PID; in standalone we always use 2 since it's the first
60  * "mortal" PID.
61  */
62 pid_t
63 getpid(void)
64 {
65 	return (2);
66 }
67 
68 /*
69  * Sleep for a given number of seconds
70  */
71 unsigned int
72 sleep(unsigned int secs)
73 {
74 	uint_t end = (secs * 1000) + prom_gettime();
75 
76 	while (prom_gettime() < end)
77 		/* Null body */;
78 
79 	return (0);
80 }
81