xref: /titanic_51/usr/src/lib/libast/common/features/sys (revision 0b7ba6115657ff183e0d3fa2c90c90f7f1cbf6ec)
1set	prototyped
2iff	AST_SYS
3ref	-D_def_map_ast
4
5print	#if __mips == 2 && !defined(_NO_LARGEFILE64_SOURCE)
6print	#define	_NO_LARGEFILE64_SOURCE	1
7print	#endif
8print	#if !defined(_NO_LARGEFILE64_SOURCE) && _typ_off64_t && _lib_lseek64 && _lib_stat64
9print	#if !defined(_LARGEFILE64_SOURCE)
10print	#define _LARGEFILE64_SOURCE	1
11print	#endif
12print	#if !defined(_LARGEFILE_SOURCE)
13print	#define _LARGEFILE_SOURCE	1
14print	#endif
15print	#else
16print	#undef	_LARGEFILE64_SOURCE
17print	#undef	_LARGEFILE_SOURCE
18print	#undef	_typ_off64_t
19print	#undef	_typ_struct_dirent64
20print	#undef	_lib_creat64
21print	#undef	_lib_fstat64
22print	#undef	_lib_fstatvfs64
23print	#undef	_lib_ftruncate64
24print	#undef	_lib_lseek64
25print	#undef	_lib_lstat64
26print	#undef	_lib_mmap64
27print	#undef	_lib_open64
28print	#undef	_lib_readdir64
29print	#undef	_lib_stat64
30print	#undef	_lib_statvfs64
31print	#undef	_lib_truncate64
32print	#endif
33
34print	#if defined(__STDC__) && !defined(__USE_FIXED_PROTOTYPES__)
35print	#define __USE_FIXED_PROTOTYPES__	1	/* kick gcc out of the past */
36print	#endif
37
38header	stdlib.h
39header	stddef.h
40header	sys/types.h
41header	stdint.h
42header	inttypes.h
43header	string.h
44header	unistd.h
45header	limits.h
46header	fcntl.h
47header	locale.h
48
49typ dev_t,nlink_t fail{
50	echo "#ifndef $m"
51	echo "#define $m	1"
52	echo "typedef short $v;"
53	echo "#endif"
54}end
55typ gid_t,mode_t,uid_t fail{
56	echo "#ifndef $m"
57	echo "#define $m	1"
58	echo "typedef unsigned short $v;"
59	echo "#endif"
60}end
61typ wchar_t stdio.h wchar.h fail{
62	echo "#ifndef $m"
63	echo "#define $m	1"
64	echo "typedef unsigned short $v;"
65	echo "#endif"
66}end
67typ pid_t,ssize_t fail{
68	echo "#ifndef $m"
69	echo "#define $m	1"
70	echo "typedef int $v;"
71	echo "#endif"
72}end
73typ wint_t stdio.h wchar.h fail{
74	echo "#ifndef $m"
75	echo "#define $m	1"
76	echo "typedef int $v;"
77	echo "#endif"
78}end
79typ socklen_t sys/socket.h fail{
80	echo "#ifndef $m"
81	echo "#define $m	1"
82	echo "typedef int $v;"
83	echo "#endif"
84}end
85typ size_t fail{
86	echo "#ifndef $m"
87	echo "#define $m	1"
88	echo "typedef unsigned int $v;"
89	echo "#endif"
90}end
91typ clock_t,ino_t,off_t,ptrdiff_t fail{
92	echo "#ifndef $m"
93	echo "#define $m	1"
94	echo "typedef long $v;"
95	echo "#endif"
96}end
97typ time_t fail{
98	echo "#ifndef $m"
99	echo "#define $m	1"
100	echo "typedef unsigned long $v;"
101	echo "#endif"
102}end
103typ div_t fail{
104	echo "#ifndef $m"
105	echo "#define $m	1"
106	echo "typedef struct { int quot; int rem; } $v;"
107	echo "#endif"
108}end
109typ ldiv_t fail{
110	echo "#ifndef $m"
111	echo "#define $m	1"
112	echo "typedef struct { long quot; long rem; } $v;"
113	echo "#endif"
114}end
115tst	typ_signed_size_t output{
116	#include <sys/types.h>
117	int
118	main()
119	{
120		unsigned long u = ~0;
121		size_t s = ~0;
122		if (s >= 0)
123			return 1;
124		printf("#if !defined(__cplusplus) && !defined(c_plusplus) && !defined(_typ_signed_size_t)\n/* what dipsticks made size_t signed? sun. */\ntypedef unsigned %s _ast_size_t;\n#undef\tsize_t\n#define size_t\t_ast_size_t\n#endif\n", u == (unsigned long)s ? "long" : "int");
125		return 0;
126	}
127}end
128
129define	offsetof	(type,member)	((size_t)&(((type*)0)->member))
130define	EXIT_FAILURE	1
131define	EXIT_SUCCESS	0
132define	MB_CUR_MAX	1
133define	RAND_MAX	32767
134
135define	STDIN_FILENO	0
136define	STDOUT_FILENO	1
137define	STDERR_FILENO	2
138
139define	NULL		0
140
141define	SEEK_SET	0
142define	SEEK_CUR	1
143define	SEEK_END	2
144
145define	F_OK		0
146define	X_OK		1
147define	W_OK		2
148define	R_OK		4
149
150print	#if _BLD_ast && defined(__EXPORT__)
151print	#define extern	__EXPORT__
152print	#endif
153
154extern	_exit		void		(int)
155extern	abort		void		(void)
156extern	abs		int		(int)
157extern	access		int		(const char*, int)
158extern	alarm		unsigned	(unsigned)
159extern	atexit		int		(void(*)(void))
160extern	atof		double		(const char*)
161extern	atoi		int		(const char*)
162extern	atol		long		(const char*)
163extern	bsearch		void*		(const void*, const void*, size_t, size_t, int(*)(const void*, const void*))
164extern	calloc		void*		(size_t, size_t)
165extern	cfree		void		(void*)
166extern	chdir		int		(const char*)
167extern	chown		int		(const char*, uid_t, gid_t)
168extern	close		int		(int)
169extern	confstr		size_t		(int, char*, size_t)
170extern	div		div_t		(int, int)
171extern	dup		int		(int)
172extern	dup2		int		(int, int)
173extern	eaccess		int		(const char*, int)
174extern	execl		int		(const char*, const char*, ...)
175extern	execle		int		(const char*, const char*, ...)
176extern	execlp		int		(const char*, const char*, ...)
177extern	execv		int		(const char*, char* const[])
178extern	execve		int		(const char*, char* const[], char* const[])
179extern	execve		int		(const char*, char* const[], char* const[])
180extern	execvp		int		(const char*, char* const[])
181extern	execvpe		int		(const char*, char* const[], char* const[])
182extern	exit		void		(int)
183extern	fork		pid_t		(void)
184extern	fpathconf	long		(int, int)
185extern	free		void		(void*)
186extern	fsync		int		(int)
187extern	ftruncate	int		(int, off_t)
188extern	getcwd		char*		(char*, size_t)
189extern	getegid		gid_t		(void)
190extern	getenv		char*		(const char*)
191extern	geteuid		uid_t		(void)
192extern	getgid		gid_t		(void)
193extern	getgroups	int		(int, gid_t[])
194extern	getlogin	char*		(void)
195extern	getpgrp		pid_t		(void)
196extern	getpid		pid_t		(void)
197extern	getppid		pid_t		(void)
198extern	gettxt		char*		(const char*, const char*)
199extern	getuid		uid_t		(void)
200extern	isatty		int		(int)
201extern	labs		long		(long)
202extern	ldiv		ldiv_t		(long, long)
203extern	link		int		(const char*, const char*)
204extern	lseek		off_t		(int, off_t, int)
205extern	malloc		void*		(size_t)
206extern	mblen		int		(const char*, size_t)
207extern	mbstowcs	size_t		(wchar_t*, const char*, size_t)
208extern	mbtowc		int		(wchar_t*, const char*, size_t)
209extern	memalign	void*		(size_t, size_t)
210extern	memccpy		void*		(void*, const void*, int, size_t)
211extern	memchr		void*		(const void*, int, size_t)
212extern	memcmp		int		(const void*, const void*, size_t)
213extern	memcpy		void*		(void*, const void*, size_t)
214extern	memmove		void*		(void*, const void*, size_t)
215extern	memset		void*		(void*, int, size_t)
216extern	pathconf	long		(const char*, int)
217extern	pause		int		(void)
218extern	pipe		int		(int[])
219extern	pvalloc		void*		(size_t)
220extern	qsort		void		(void*, size_t, size_t, int(*)(const void*, const void*))
221extern	rand		int		(void)
222extern	read		ssize_t		(int, void*, size_t)
223extern	realloc		void*		(void*, size_t)
224extern	realpath	char*		(const char*, char*)
225extern	resolvepath	char*		(const char*, char*, size_t)
226extern	rmdir		int		(const char*)
227extern	setgid		int		(gid_t)
228extern	setpgid		int		(pid_t, pid_t)
229extern	setsid		pid_t		(void)
230extern	setuid		int		(uid_t)
231extern	sleep		unsigned		(unsigned int)
232extern	spawnveg	pid_t		(const char*, char* const[], char* const[], pid_t)
233extern	srand		void		(unsigned int)
234extern	strcasecmp	int		(const char*, const char*)
235extern	strcat		char*		(char*, const char*)
236extern	strchr		char*		(const char*, int)
237extern	strcmp		int		(const char*, const char*)
238extern	strcoll		int		(const char*, const char*)
239extern	strcpy		char*		(char*, const char*)
240extern	strcspn		size_t		(const char*, const char*)
241extern	strdup		char*		(const char*)
242extern	strlcat		size_t		(char*, const char*, size_t)
243extern	strlcpy		size_t		(char*, const char*, size_t)
244extern	strlen		size_t		(const char*)
245extern	strncasecmp	int		(const char*, const char*, size_t)
246extern	strncat		char*		(char*, const char*, size_t)
247extern	strncmp		int		(const char*, const char*, size_t)
248extern	strncpy		char*		(char*, const char*, size_t)
249extern	strpbrk		char*		(const char*, const char*)
250extern	strrchr		char*		(const char*, int)
251extern	strspn		size_t		(const char*, const char*)
252extern	strstr		char*		(const char*, const char*)
253extern	strtok		char*		(char*, const char*)
254extern	strxfrm		size_t		(char*, const char*, size_t)
255extern	swab		void		(const void*, void*, ssize_t)
256extern	sysconf		long		(int)
257extern	system		int		(const char*)
258extern	tcgetpgrp	pid_t		(int)
259extern	tcsetpgrp	int		(int, pid_t)
260extern	truncate	int		(const char*, off_t)
261extern	ttyname		char*		(int)
262extern	unlink		int		(const char*)
263extern	valloc		void*		(size_t)
264extern	wcstombs	size_t		(char*, const wchar_t*, size_t)
265extern	wctomb		int		(char*, wchar_t)
266extern	write		ssize_t		(int, const void*, size_t)
267
268print	#undef	extern
269
270# <stdarg.h> is handled by proto so this must be after the last test
271
272print	#include <stdarg.h>
273