1BEGIN {
2	getline;
3	while (!match($0, "^/[/*] static char cvs_id")) {
4		print;
5		getline;
6	}
7	getline;
8	while (!match($0, "^// WARRANTY DISCLAIMER")) {
9		print;
10		if (!getline) {
11			break;
12		}
13	}
14	if (getline)
15	{
16		printf								      \
17"// Redistribution and use in source and binary forms, with or without\n"     \
18"// modification, are permitted provided that the following conditions are\n" \
19"// met:\n"								      \
20"//\n"									      \
21"// * Redistributions of source code must retain the above copyright\n"	      \
22"// notice, this list of conditions and the following disclaimer.\n"	      \
23"//\n"									      \
24"// * Redistributions in binary form must reproduce the above copyright\n"    \
25"// notice, this list of conditions and the following disclaimer in the\n"    \
26"// documentation and/or other materials provided with the distribution.\n"   \
27"//\n"									      \
28"// * The name of Intel Corporation may not be used to endorse or promote\n"  \
29"// products derived from this software without specific prior written\n"     \
30"// permission.\n\n";
31		if (LICENSE_ONLY == "y") {
32			do {
33				print;
34			} while (getline);
35		}
36	}
37}
38
39/^[.]data/ {
40	print "RODATA";
41	next;
42}
43/^([a-zA-Z_0-9]*_(tb[l0-9]|Tt|[tT]able|data|low|coeffs|constants|CONSTANTS|reduction|Stirling)(_?([1-9cdimpqstPQT]+|tail))?|(Constants|Poly|coeff)_.+|(double_sin_?cos|double_cis)[fl]?_.+):/ {
44	table_name=substr($1,1,length($1)-1);
45	printf "LOCAL_OBJECT_START(%s)\n", table_name;
46	getline;
47	while (!match($0, "^[ \t]*data")) {
48		print;
49		getline;
50	}
51	while (match($0, "(//|^[ \t]*data)")) {
52		print;
53		getline;
54	}
55	printf "LOCAL_OBJECT_END(%s)\n\n", table_name;
56	next;
57}
58/^[.]proc[ \t]+__libm_(error_region|callout)/ {
59	printf "LOCAL_LIBM_ENTRY(%s)\n", $2;
60	getline;
61	next;
62}
63/^[.]endp[ \t]+__libm_(error_region|callout)/ {
64	printf "LOCAL_LIBM_END(%s)\n", $2;
65	next;
66}
67/^[.]global/ {
68	split($2, part, "#");
69	name=part[1];
70	if (match(name, "^"FUNC"$")) {
71		next;
72	}
73}
74/^[.]proc/ {
75	split($2, part, "#");
76	name=part[1];
77	if (match(name, "^"FUNC"$")) {
78		local_funcs=("^("			\
79			     "cis|cisf|cisl"		\
80			     "|cabs|cabsf|cabsl"	\
81			     "|cot|cotf|cotl"		\
82			     ")$");
83		ieee754_funcs=("^("					  \
84			       "atan2|atan2f|atan2l|atanl"		  \
85			       "|cos|cosf|cosl"				  \
86			       "|cosh|coshf|coshl"			  \
87			       "|exp|expf|expl"				  \
88			       "|exp10|exp10f|exp10l"			  \
89			       "|expm1|expm1f|expm1l"			  \
90			       "|fmod|fmodf|fmodl"			  \
91			       "|hypot|hypotf|hypotl"			  \
92			       "|fabs|fabsf|fabsl"			  \
93			       "|floor|floorf|floorl"			  \
94			       "|log1p|log1pf|log1pl"			  \
95			       "|log|log10|log10f|log10l|log2l|logf|logl" \
96			       "|remainder|remainderf|remainderl|"	  \
97			       "|rint|rintf|rintl|"			  \
98			       "|scalb|scalbf|scalbl"			  \
99			       "|sin|sinf|sinl"				  \
100			       "|sincos|sincosf|sincosl"		  \
101			       "|sinh|sinhf|sinhl"			  \
102			       "|sqrt|sqrtf|sqrtl"			  \
103			       "|tan|tanf|tanl"				  \
104			       ")$");
105		if (match(name, ieee754_funcs)) {
106			type="GLOBAL_IEEE754";
107		} else if (match (name, local_funcs)) {
108			type="LOCAL_LIBM";
109		} else {
110			type="GLOBAL_LIBM";
111		}
112		printf "%s_ENTRY(%s)\n", type, name;
113		getline;
114		while (!match($0, "^"name"#?:")) {
115			getline;
116		}
117		getline;
118		while (!match($0, "^.endp")) {
119			print
120			getline;
121		}
122		printf "%s_END(%s)\n", type, name;
123		if (match(name, "^exp10[fl]?$")) {
124			t=substr(name,6)
125			printf "weak_alias (exp10%s, pow10%s)\n", t, t
126		}
127		next;
128	}
129}
130/^[a-zA-Z_]+:/ {
131	split($1, part, ":");
132	name=part[1];
133	if (match(name, "^"FUNC"$")) {
134		printf "GLOBAL_LIBM_ENTRY(%s)\n", name;
135		getline;
136		while (!match($0, "^"name"#?:")) {
137			getline;
138		}
139		getline;
140		while (!match($0, "^.endp")) {
141			print
142			getline;
143		}
144		getline;
145		printf "GLOBAL_LIBM_END(%s)\n", name;
146		next;
147	}
148}
149
150{ print }
151