libroot/posix/stdio: Remove unused portions.
[haiku.git] / src / system / libroot / stubbed / generate_stubs.py
blobedf9f1ac52d7b67a6ed61e00f5975eb491e135fe
1 #! /usr/bin/env python
3 import sys;
5 dataSymbolsByAddress = {}
6 dataSymbols = []
7 versionedDataSymbolsByName = {}
8 functionSymbolsByAddress = {}
9 functionSymbols = []
10 versionedFunctionSymbolsByName = {}
12 for line in sys.stdin.readlines():
13 if line[0] != '0':
14 # ignore lines without an address
15 continue
17 (address, type, symbol) = line.split()
19 # select interesting types of symbols
20 if type not in 'BCDGRSTuVvWw':
21 continue
23 # drop symbols from legacy compiler that contain a dot (those produce
24 # syntax errors)
25 if '.' in symbol:
26 continue
28 if type in 'BD':
29 if '@' in symbol:
30 versionedDataSymbolsByName[symbol] = address
31 else:
32 if type not in 'VW':
33 dataSymbolsByAddress[address] = symbol
34 dataSymbols.append(symbol)
35 else:
36 if '@' in symbol:
37 versionedFunctionSymbolsByName[symbol] = address
38 else:
39 if type not in 'VW':
40 functionSymbolsByAddress[address] = symbol
41 functionSymbols.append(symbol)
43 # add data symbols
44 for dataSymbol in sorted(dataSymbols):
45 print 'int %s;' % dataSymbol
47 print
49 # add function symbols
50 for functionSymbol in sorted(functionSymbols):
51 print 'void %s() {}' % functionSymbol
53 print
54 print "#include <symbol_versioning.h>"
55 print
57 # add symbol versioning information for data symbols
58 for symbol in sorted(versionedDataSymbolsByName.keys()):
59 address = versionedDataSymbolsByName[symbol]
60 targetSymbol = dataSymbolsByAddress[address]
61 (symbolName, unused, versionTag) = symbol.partition('LIBROOT_')
62 print 'DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("%s", "%s", "%s");' \
63 % (targetSymbol, symbolName, versionTag)
65 # add symbol versioning information for function symbols
66 for symbol in sorted(versionedFunctionSymbolsByName.keys()):
67 address = versionedFunctionSymbolsByName[symbol]
68 targetSymbol = functionSymbolsByAddress[address]
69 (symbolName, unused, versionTag) = symbol.partition('LIBROOT_')
70 print 'DEFINE_LIBROOT_KERNEL_SYMBOL_VERSION("%s", "%s", "%s");' \
71 % (targetSymbol, symbolName, versionTag)