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