1 | # $Id: various.sed 76553 2019-01-01 01:45:53Z 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-2019 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 | # Pass thru the file header and copyright.
|
---|
30 | 1,/^\#ifndef/{
|
---|
31 | /^\#ifndef/b next
|
---|
32 | s/^[/ ]//
|
---|
33 | s/^\*\//;/
|
---|
34 | s/\*/;/g
|
---|
35 | 4s/^.*$/; Automatically generated by various.sed. DO NOT EDIT!/
|
---|
36 | b end
|
---|
37 | }
|
---|
38 | :next
|
---|
39 |
|
---|
40 | # Check for markers (typically in comments).
|
---|
41 | /ASM-INC/basm-inc
|
---|
42 | /ASM-NOINC/basm-noinc
|
---|
43 |
|
---|
44 | # Newline escapes.
|
---|
45 | :check-newline-escape
|
---|
46 | /\\$/!bno-more-newline-escapes
|
---|
47 | N
|
---|
48 | b check-newline-escape
|
---|
49 | :no-more-newline-escapes
|
---|
50 |
|
---|
51 | # Strip comments and trailing space.
|
---|
52 | s/[[:space:]][[:space:]]*\/\*.*$//g
|
---|
53 | s/[[:space:]][[:space:]]*\/\/.*$//g
|
---|
54 | s/[[:space:]][[:space:]]*$//g
|
---|
55 |
|
---|
56 | # Try identify the statement.
|
---|
57 | /#[[:space:]]*define[[:space:]]/bdefine
|
---|
58 | /#[[:space:]]*ifdef[[:space:]]/bifdef
|
---|
59 | /#[[:space:]]*ifndef[[:space:]]/bifndef
|
---|
60 | /#[[:space:]]*if[[:space:]]/bif
|
---|
61 | /#[[:space:]]*elif[[:space:]]/belif
|
---|
62 | /#[[:space:]]*else$/belse
|
---|
63 | /#[[:space:]]*endif$/bendif
|
---|
64 |
|
---|
65 | # Not recognized, drop it.
|
---|
66 | :asm-noinc
|
---|
67 | d
|
---|
68 | b end
|
---|
69 |
|
---|
70 | #
|
---|
71 | # Defines needs some extra massaging to work in yasm.
|
---|
72 | # Things like trailing type indicators ('U', 'ULL' ++) does not go down well.
|
---|
73 | #
|
---|
74 | :define
|
---|
75 | /\$/d
|
---|
76 | s/#\([[:space:]]*\)define/\1%define/
|
---|
77 |
|
---|
78 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)U$/\1/
|
---|
79 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)U\([[:space:]]*\))$/\1\2)/
|
---|
80 | s/\([[:space:]][0-9][0-9]*\)U[[:space:]]*$/\1/
|
---|
81 | s/\([[:space:]][0-9][0-9]*\)U\([[:space:]]*\))$/\1\2)/
|
---|
82 |
|
---|
83 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)UL$/\1/
|
---|
84 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)UL\([[:space:]]*\))$/\1\2)/
|
---|
85 | s/\([[:space:]][0-9][0-9]*\)UL[[:space:]]*$/\1/
|
---|
86 | s/\([[:space:]][0-9][0-9]*\)UL\([[:space:]]*\))$/\1\2)/
|
---|
87 |
|
---|
88 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)ULL$/\1/
|
---|
89 | s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)ULL\([[:space:]]*\))$/\1\2)/
|
---|
90 | s/\([[:space:]][0-9][0-9]*\)ULL[[:space:]]*$/\1/
|
---|
91 | s/\([[:space:]][0-9][0-9]*\)ULL\([[:space:]]*\))$/\1\2)/
|
---|
92 |
|
---|
93 | s/UINT64_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
|
---|
94 | s/UINT64_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
|
---|
95 | s/UINT32_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
|
---|
96 | s/UINT32_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
|
---|
97 | s/UINT16_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
|
---|
98 | s/UINT16_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
|
---|
99 | s/UINT8_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
|
---|
100 | s/UINT8_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
|
---|
101 |
|
---|
102 | b end
|
---|
103 |
|
---|
104 | #
|
---|
105 | # Conditional statements, 1:1.
|
---|
106 | #
|
---|
107 | :ifdef
|
---|
108 | s/#\([[:space:]]*\)ifdef/\1%ifdef/
|
---|
109 | b end
|
---|
110 |
|
---|
111 | :ifndef
|
---|
112 | s/#\([[:space:]]*\)ifndef/\1%ifndef/
|
---|
113 | b end
|
---|
114 |
|
---|
115 | :if
|
---|
116 | s/#\([[:space:]]*\)if/\1%if/
|
---|
117 | b end
|
---|
118 |
|
---|
119 | :elif
|
---|
120 | s/#\([[:space:]]*\)elif/\1%elif/
|
---|
121 | b end
|
---|
122 |
|
---|
123 | :else
|
---|
124 | s/#\([[:space:]]*\)else.*$/\1%else/
|
---|
125 | b end
|
---|
126 |
|
---|
127 | :endif
|
---|
128 | s/#\([[:space:]]*\)endif.*$/\1%endif/
|
---|
129 | b end
|
---|
130 |
|
---|
131 | #
|
---|
132 | # Assembly statement... may need adjusting when used.
|
---|
133 | #
|
---|
134 | :asm-inc
|
---|
135 | b end
|
---|
136 |
|
---|
137 | :end
|
---|
138 |
|
---|