1 | # $Id: various.sed 69181 2017-10-23 18:13:56Z vboxsync $
|
---|
2 | ## @file
|
---|
3 | # Converts some C header elements into nasm/yasm syntax.
|
---|
4 | #
|
---|
5 | # This is used by 'incs' in /Maintenance.kmk (/Makefile.kmk).
|
---|
6 | #
|
---|
7 |
|
---|
8 | #
|
---|
9 | # Copyright (C) 2006-2017 Oracle Corporation
|
---|
10 | #
|
---|
11 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | # available from http://www.virtualbox.org. This file is free software;
|
---|
13 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | # General Public License (GPL) as published by the Free Software
|
---|
15 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | #
|
---|
19 | # The contents of this file may alternatively be used under the terms
|
---|
20 | # of the Common Development and Distribution License Version 1.0
|
---|
21 | # (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
22 | # VirtualBox OSE distribution, in which case the provisions of the
|
---|
23 | # CDDL are applicable instead of those of the GPL.
|
---|
24 | #
|
---|
25 | # You may elect to license modified versions of this file under the
|
---|
26 | # terms and conditions of either the GPL or the CDDL or both.
|
---|
27 | #
|
---|
28 |
|
---|
29 |
|
---|
30 | # Check for markers (typically in comments).
|
---|
31 | /ASM-INC/basm-inc
|
---|
32 | /ASM-NOINC/basm-noinc
|
---|
33 |
|
---|
34 | # Newline escapes.
|
---|
35 | :check-newline-escape
|
---|
36 | /\\$/!bno-more-newline-escapes
|
---|
37 | N
|
---|
38 | b check-newline-escape
|
---|
39 | :no-more-newline-escapes
|
---|
40 |
|
---|
41 | # Strip comments and trailing space.
|
---|
42 | s/[[:space:]][[:space:]]*\/\*.*$//g
|
---|
43 | s/[[:space:]][[:space:]]*\/\/.*$//g
|
---|
44 | s/[[:space:]][[:space:]]*$//g
|
---|
45 |
|
---|
46 | # Try identify the statement.
|
---|
47 | /#[[:space:]]*define[[:space:]]/bdefine
|
---|
48 | /#[[:space:]]*ifdef[[:space:]]/bifdef
|
---|
49 | /#[[:space:]]*ifndef[[:space:]]/bifndef
|
---|
50 | /#[[:space:]]*if[[:space:]]/bif
|
---|
51 | /#[[:space:]]*elif[[:space:]]/belif
|
---|
52 | /#[[:space:]]*else$/belse
|
---|
53 | /#[[:space:]]*endif$/bendif
|
---|
54 |
|
---|
55 | # Not recognized, drop it.
|
---|
56 | :asm-noinc
|
---|
57 | d
|
---|
58 | b end
|
---|
59 |
|
---|
60 | #
|
---|
61 | # Defines needs some extra massaging to work in yasm.
|
---|
62 | # Things like trailing type indicators ('U', 'ULL' ++) does not go down well.
|
---|
63 | #
|
---|
64 | :define
|
---|
65 | /\$/d
|
---|
66 | s/#\([[:space:]]*\)define/\1%define/
|
---|
67 |
|
---|
68 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)U$/\1/
|
---|
69 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)U\([[:space:]]*\))$/\1\2)/
|
---|
70 | s/\([[:space:]][0-9][0-9]*\)U[[:space:]]*$/\1/
|
---|
71 | s/\([[:space:]][0-9][0-9]*\)U\([[:space:]]*\))$/\1\2)/
|
---|
72 |
|
---|
73 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)UL$/\1/
|
---|
74 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)UL\([[:space:]]*\))$/\1\2)/
|
---|
75 | s/\([[:space:]][0-9][0-9]*\)UL[[:space:]]*$/\1/
|
---|
76 | s/\([[:space:]][0-9][0-9]*\)UL\([[:space:]]*\))$/\1\2)/
|
---|
77 |
|
---|
78 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)ULL$/\1/
|
---|
79 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)ULL\([[:space:]]*\))$/\1\2)/
|
---|
80 | s/\([[:space:]][0-9][0-9]*\)ULL[[:space:]]*$/\1/
|
---|
81 | s/\([[:space:]][0-9][0-9]*\)ULL\([[:space:]]*\))$/\1\2)/
|
---|
82 |
|
---|
83 | s/UINT64_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
|
---|
84 | s/UINT64_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
|
---|
85 | s/UINT32_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
|
---|
86 | s/UINT32_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
|
---|
87 | s/UINT16_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
|
---|
88 | s/UINT16_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
|
---|
89 | s/UINT8_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
|
---|
90 | s/UINT8_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
|
---|
91 |
|
---|
92 | b end
|
---|
93 |
|
---|
94 | #
|
---|
95 | # Conditional statements, 1:1.
|
---|
96 | #
|
---|
97 | :ifdef
|
---|
98 | s/#\([[:space:]]*\)ifdef/\1%ifdef/
|
---|
99 | b end
|
---|
100 |
|
---|
101 | :ifndef
|
---|
102 | s/#\([[:space:]]*\)ifndef/\1%ifndef/
|
---|
103 | b end
|
---|
104 |
|
---|
105 | :if
|
---|
106 | s/#\([[:space:]]*\)if/\1%if/
|
---|
107 | b end
|
---|
108 |
|
---|
109 | :elif
|
---|
110 | s/#\([[:space:]]*\)elif/\1%elif/
|
---|
111 | b end
|
---|
112 |
|
---|
113 | :else
|
---|
114 | s/#\([[:space:]]*\)else.*$/\1%else/
|
---|
115 | b end
|
---|
116 |
|
---|
117 | :endif
|
---|
118 | s/#\([[:space:]]*\)endif.*$/\1%endif/
|
---|
119 | b end
|
---|
120 |
|
---|
121 | #
|
---|
122 | # Assembly statement... may need adjusting when used.
|
---|
123 | #
|
---|
124 | :asm-inc
|
---|
125 | b end
|
---|
126 |
|
---|
127 | :end
|
---|
128 |
|
---|