VirtualBox

source: vbox/trunk/include/VBox/various.sed@ 99734

Last change on this file since 99734 was 98103, checked in by vboxsync, 23 months ago

Copyright year updates by scm.

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 4.0 KB
Line 
1# $Id: various.sed 98103 2023-01-17 14:15:46Z 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-2023 Oracle and/or its affiliates.
10#
11# This file is part of VirtualBox base platform packages, as
12# available from https://www.virtualbox.org.
13#
14# This program is free software; you can redistribute it and/or
15# modify it under the terms of the GNU General Public License
16# as published by the Free Software Foundation, in version 3 of the
17# License.
18#
19# This program is distributed in the hope that it will be useful, but
20# WITHOUT ANY WARRANTY; without even the implied warranty of
21# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22# General Public License for more details.
23#
24# You should have received a copy of the GNU General Public License
25# along with this program; if not, see <https://www.gnu.org/licenses>.
26#
27# The contents of this file may alternatively be used under the terms
28# of the Common Development and Distribution License Version 1.0
29# (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
30# in the VirtualBox distribution, in which case the provisions of the
31# CDDL are applicable instead of those of the GPL.
32#
33# You may elect to license modified versions of this file under the
34# terms and conditions of either the GPL or the CDDL or both.
35#
36# SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
37#
38
39# Pass thru the file header and copyright.
401,/^\#ifndef/{
41/^\#ifndef/b next
42s/^[/ ]//
43s/^\*\//;/
44s/\*/;/g
454s/^.*$/; Automatically generated by various.sed. DO NOT EDIT!/
46b end
47}
48:next
49
50# Check for markers (typically in comments).
51/ASM-INC/basm-inc
52/ASM-NOINC/basm-noinc
53
54# Newline escapes.
55:check-newline-escape
56/\\$/!bno-more-newline-escapes
57N
58b check-newline-escape
59:no-more-newline-escapes
60
61# Strip comments and trailing space.
62s/[[:space:]][[:space:]]*\/\*.*$//g
63s/[[:space:]][[:space:]]*\/\/.*$//g
64s/[[:space:]][[:space:]]*$//g
65
66# Try identify the statement.
67/#[[:space:]]*define[[:space:]]/bdefine
68/#[[:space:]]*ifdef[[:space:]]/bifdef
69/#[[:space:]]*ifndef[[:space:]]/bifndef
70/#[[:space:]]*if[[:space:]]/bif
71/#[[:space:]]*elif[[:space:]]/belif
72/#[[:space:]]*else$/belse
73/#[[:space:]]*endif$/bendif
74
75# Not recognized, drop it.
76:asm-noinc
77d
78b end
79
80#
81# Defines needs some extra massaging to work in yasm.
82# Things like trailing type indicators ('U', 'ULL' ++) does not go down well.
83#
84:define
85/\$/d
86s/#\([[:space:]]*\)define/\1%define/
87
88s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)U$/\1/
89s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)U\([[:space:]]*\))$/\1\2)/
90s/\([[:space:]][0-9][0-9]*\)U[[:space:]]*$/\1/
91s/\([[:space:]][0-9][0-9]*\)U\([[:space:]]*\))$/\1\2)/
92
93s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)UL$/\1/
94s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)UL\([[:space:]]*\))$/\1\2)/
95s/\([[:space:]][0-9][0-9]*\)UL[[:space:]]*$/\1/
96s/\([[:space:]][0-9][0-9]*\)UL\([[:space:]]*\))$/\1\2)/
97
98s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)ULL$/\1/
99s/\([[:space:]]0[xX][0-9a-fA-F][0-9a-fA-F]*\)ULL\([[:space:]]*\))$/\1\2)/
100s/\([[:space:]][0-9][0-9]*\)ULL[[:space:]]*$/\1/
101s/\([[:space:]][0-9][0-9]*\)ULL\([[:space:]]*\))$/\1\2)/
102
103s/UINT64_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
104s/UINT64_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
105s/UINT32_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
106s/UINT32_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
107s/UINT16_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
108s/UINT16_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
109s/UINT8_C([[:space:]]*\(0[xX][0-9a-fA-F][0-9a-fA-F]*\)[[:space:]]*)/\1/
110s/UINT8_C([[:space:]]*\([0-9][0-9]*\)[[:space:]]*)/\1/
111
112b end
113
114#
115# Conditional statements, 1:1.
116#
117:ifdef
118s/#\([[:space:]]*\)ifdef/\1%ifdef/
119b end
120
121:ifndef
122s/#\([[:space:]]*\)ifndef/\1%ifndef/
123b end
124
125:if
126s/#\([[:space:]]*\)if/\1%if/
127b end
128
129:elif
130s/#\([[:space:]]*\)elif/\1%elif/
131b end
132
133:else
134s/#\([[:space:]]*\)else.*$/\1%else/
135b end
136
137:endif
138s/#\([[:space:]]*\)endif.*$/\1%endif/
139b end
140
141#
142# Assembly statement... may need adjusting when used.
143#
144:asm-inc
145b end
146
147:end
148
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette