VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/drm/indent.sed

Last change on this file was 98103, checked in by vboxsync, 16 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: 9.8 KB
Line 
1# Oracle VM VirtualBox
2# VirtualBox to Linux kernel coding style conversion script.
3
4#
5# Copyright (C) 2017-2023 Oracle and/or its affiliates.
6#
7# This file is part of VirtualBox base platform packages, as
8# available from https://www.virtualbox.org.
9#
10# This program is free software; you can redistribute it and/or
11# modify it under the terms of the GNU General Public License
12# as published by the Free Software Foundation, in version 3 of the
13# License.
14#
15# This program is distributed in the hope that it will be useful, but
16# WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18# General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, see <https://www.gnu.org/licenses>.
22#
23# SPDX-License-Identifier: GPL-3.0-only
24#
25
26# This script is for converting code inside the vboxvideo module to Linux
27# kernel coding style. It assumes correct VirtualBox coding style, will break
28# break if the coding style is wrong (e.g. tab instead of spaces) and is not
29# indended to be a generic solution: for example, identifiers will be
30# translated case by case, not algorithmically. It also assumes that any
31# flexibility in either coding style will be used where possible to make the
32# code conform to both at once.
33
34# Replace up to six leading groups of four spaces with tabs.
35s/^ */\t\t\t\t\t\t/g
36s/^ /\t\t\t\t\t/g
37s/^ /\t\t\t\t/g
38s/^ /\t\t\t/g
39s/^ /\t\t/g
40s/^ /\t/g
41
42# Change various symbols and file names to fit kernel conventions.
43
44# Miscellaneous:
45# Remove @file headers.
46\|/\*\* @file| {
47:start
48 N
49 s|\*/|\*/|g
50 T start
51 N
52 d
53}
54/^\/\* \$Id:.*\*\/$/d
55/^typedef .* HGSMIOFFSET;/d
56/^typedef .* HGSMISIZE;/d
57s/^#\( *\)include <\([^/]*\)>/#\1include "\2"/g
58
59# File names:
60s/\bHGSMIBase\.h\b/vbox_drv.h/g
61s/\bHGSMIChannels\.h\b/hgsmi_channels.h/g
62s/\bHGSMIChSetup\.h\b/hgsmi_ch_setup.h/g
63s/\bHGSMIContext\.h\b/hgsmi_context.h/g
64s/\bHGSMIDefs\.h\b/hgsmi_defs.h/g
65s/\bVBoxVideoGuest\.h\b/vboxvideo_guest.h/g
66s/\bVBoxVideo\.h\b/vboxvideo.h/g
67s/\bVBoxVideoIPRT\.h\b/vbox_err.h/g
68s/\bVBoxVideoVBE\.h\b/vboxvideo_vbe.h/g
69
70# Function names:
71s/\btestQueryConf\b/hgsmi_test_query_conf/g
72s/\bVBoxHGSMIBufferAlloc\b/hgsmi_buffer_alloc/g
73s/\bVBoxHGSMIBufferFree\b/hgsmi_buffer_free/g
74s/\bVBoxHGSMIBufferSubmit\b/hgsmi_buffer_submit/g
75s/\bVBoxHGSMICursorPosition\b/hgsmi_cursor_position/g
76s/\bVBoxHGSMIGetModeHints\b/hgsmi_get_mode_hints/g
77s/\bVBoxHGSMIProcessDisplayInfo\b/hgsmi_process_display_info/g
78s/\bVBoxHGSMIReportFlagsLocation\b/hgsmi_report_flags_location/g
79s/\bVBoxHGSMISendCapsInfo\b/hgsmi_send_caps_info/g
80s/\bVBoxHGSMIUpdateInputMapping\b/hgsmi_update_input_mapping/g
81s/\bVBoxHGSMIUpdatePointerShape\b/hgsmi_update_pointer_shape/g
82s/\bvboxHwBufferAvail\b/vbva_buffer_available/g
83s/\bvboxHwBufferEndUpdate\b/vbva_buffer_end_update/g
84s/\bvboxHwBufferFlush\b/vbva_buffer_flush/g
85s/\bvboxHwBufferPlaceDataAt\b/vbva_buffer_place_data_at/g
86s/\bvboxHwBufferWrite\b/vbva_write/g
87s/\bVBoxQueryConfHGSMI\b/hgsmi_query_conf/g
88s/\bVBoxVBVABufferBeginUpdate\b/vbva_buffer_begin_update/g
89s/\bVBoxVBVABufferEndUpdate\b/vbva_buffer_end_update/g
90s/\bVBoxVBVADisable\b/vbva_disable/g
91s/\bVBoxVBVAEnable\b/vbva_enable/g
92s/\bvboxVBVAInformHost\b/vbva_inform_host/g
93s/\bvboxVBVASetupBufferContext\b/vbva_setup_buffer_context/g
94s/\bVBVO_PORT_READ_U8\b/inb/g
95s/\bVBVO_PORT_READ_U16\b/inw/g
96s/\bVBVO_PORT_READ_U32\b/inl/g
97s/\bVBVO_PORT_WRITE_U8\b *( *\(\b[^(),]*\b\) *, *\(\b[^(),]*\b\) *)/outb(\2, \1)/g
98s/\bVBVO_PORT_WRITE_U16\b *( *\(\b[^(),]*\b\) *, *\(\b[^(),]*\b\) *)/outw(\2, \1)/g
99s/\bVBVO_PORT_WRITE_U32\b *( *\(\b[^(),]*\b\) *, *\(\b[^(),]*\b\) *)/outl(\2, \1)/g
100s/\bVBVO_PORT_WRITE_U[0-9]*\b/VBVO_PORT_WRITE_statement_should_be_on_one_line/g
101
102# Macros:
103s/\b_1K\b/1024/g
104s/\b_4M\b/4*1024*1024/g
105s/\bAssert\b\([^;]*\);/WARN_ON_ONCE(!(\1));/g
106s/\bAssertCompile\b/assert_compile/g
107s/\bAssertCompileSize\b/assert_compile_size/g
108s/\bAssertPtr\b\([^;]*\);/WARN_ON_ONCE(!(\1));/g
109s/\bAssertPtrReturn\b/assert_ptr_return/g
110/AssertPtrNullReturnVoid/d
111s/\bAssertRC\b\([^;]*\);/WARN_ON_ONCE(RT_FAILURE\1);/g
112s/\bAssertRC\b/Assert_RC_statement_should_be_on_one_line/g
113s/\bDECLCALLBACK\b(\([^)]*\))/\1/g
114 s/\bDECLCALLBACKTYPE\b(\([^,)]*\), *\([^,)]*\), *(\([^;)]*\) *) *)/\1 \2(\3)/g
115s/\bDECLCALLBACKMEMBER\b(\([^,)]*\), *\([^,)]*\), *(\([^;)]*\) *) *)/\1 (*\2)(\3)/g
116s/^\bDECLHIDDEN\b(\([^)]*\))/\1/g
117s/\bDECLINLINE\b(\([^)]*\))/static inline \1/g
118s/\bRT_BIT\b/BIT/g
119s/\bRT_BOOL\b(\([^)]*\))/(!!(\1))/g
120/RT_C_DECLS/d
121s/\bUINT16_MAX\b/U16_MAX/g
122s/\bUINT32_MAX\b/U32_MAX/g
123s/\bUINT32_C\b(\(.*\))/\1u/g
124s/!RT_VALID_PTR(/WARN_ON(!/g
125s/\bRT_UNTRUSTED_VOLATILE_HOST\b//g
126s/\bRT_UNTRUSTED_VOLATILE_GUEST\b//g
127s/\bRT_UNTRUSTED_VOLATILE_HSTGST\b//g
128
129# Type names:
130s/\bint32_t\b/s32/g
131s/\buint8_t\b/u8/g
132s/\buint16_t\b/u16/g
133s/\buint32_t\b/u32/g
134s/(HGSMIBUFFERLOCATION \*)//g # Remove C++ casts from void.
135s/typedef struct HGSMIBUFFERLOCATION/struct hgsmi_buffer_location/g
136s/struct HGSMIBUFFERLOCATION/struct hgsmi_buffer_location/g
137s/} HGSMIBUFFERLOCATION/}/g
138s/\bHGSMIBUFFERLOCATION\b/struct hgsmi_buffer_location/g
139s/\([^*] *\)\bPHGSMIGUESTCOMMANDCONTEXT\b/\1struct gen_pool */g
140s/(HGSMIHOSTFLAGS \*)//g # Remove C++ casts from void.
141s/typedef struct HGSMIHOSTFLAGS/struct hgsmi_host_flags/g
142s/struct HGSMIHOSTFLAGS/struct hgsmi_host_flags/g
143s/} HGSMIHOSTFLAGS/}/g
144s/\bHGSMIHOSTFLAGS\b/struct hgsmi_host_flags/g
145s/\bHGSMIOFFSET\b/u32/g
146s/\bHGSMISIZE\b/u32/g
147s/\bRTRECT\b/void/g
148s/(VBVABUFFERCONTEXT \*)//g # Remove C++ casts from void.
149s/struct VBVABUFFERCONTEXT/struct vbva_buf_context/g
150s/} VBVABUFFERCONTEXT/} vbva_buf_context/g
151s/\bVBVABUFFERCONTEXT\b/struct vbva_buf_context/g
152s/\([^*] *\)\bPVBVABUFFERCONTEXT\b/\1struct vbva_buf_context */g
153s/(VBVACAPS \*)//g # Remove C++ casts from void.
154s/struct VBVACAPS/struct vbva_caps/g
155s/} VBVACAPS/} vbva_caps/g
156s/\bVBVACAPS\b/struct vbva_caps/g
157s/(VBVACONF32 \*)//g # Remove C++ casts from void.
158s/struct VBVACONF32/struct vbva_conf32/g
159s/} VBVACONF32/} vbva_conf32/g
160s/\bVBVACONF32\b/struct vbva_conf32/g
161s/(VBVACURSORPOSITION \*)//g # Remove C++ casts from void.
162s/struct VBVACURSORPOSITION/struct vbva_cursor_position/g
163s/} VBVACURSORPOSITION/} vbva_cursor_position/g
164s/\bVBVACURSORPOSITION\b/struct vbva_cursor_position/g
165s/(VBVAENABLE_EX \*)//g # Remove C++ casts from void.
166s/struct VBVAENABLE_EX/struct vbva_enable_ex/g
167s/} VBVAENABLE_EX/} vbva_enable_ex/g
168s/\bVBVAENABLE_EX\b/struct vbva_enable_ex/g
169s/(VBVAMOUSEPOINTERSHAPE \*)//g # Remove C++ casts from void.
170s/struct VBVAMOUSEPOINTERSHAPE/struct vbva_mouse_pointer_shape/g
171s/} VBVAMOUSEPOINTERSHAPE/} vbva_mouse_pointer_shape/g
172s/\bVBVAMOUSEPOINTERSHAPE\b/struct vbva_mouse_pointer_shape/g
173s/(VBVAMODEHINT \*)//g # Remove C++ casts from void.
174s/struct VBVAMODEHINT/struct vbva_modehint/g
175s/} VBVAMODEHINT/} vbva_modehint/g
176s/\bVBVAMODEHINT\b/struct vbva_modehint/g
177s/(VBVAQUERYMODEHINTS \*)//g # Remove C++ casts from void.
178s/struct VBVAQUERYMODEHINTS/struct vbva_query_mode_hints/g
179s/} VBVAQUERYMODEHINTS/} vbva_query_mode_hints/g
180s/\bVBVAQUERYMODEHINTS\b/struct vbva_query_mode_hints/g
181s/(VBVAREPORTINPUTMAPPING \*)//g # Remove C++ casts from void.
182s/struct VBVAREPORTINPUTMAPPING/struct vbva_report_input_mapping/g
183s/} VBVAREPORTINPUTMAPPING/} vbva_report_input_mapping/g
184s/\bVBVAREPORTINPUTMAPPING\b/struct vbva_report_input_mapping/g
185
186# Variable and parameter names:
187s/\baRecords\b/records/g
188s/\bau8Data\b/data/g
189s/\bau32Reserved\b/reserved/g
190s/\bBase\b/base/g
191s/\bbEnable\b/enable/g
192s/\bbRc\b/ret/g
193s/\bcb\b/len/g
194s/\bcbBuffer\b/buffer_length/g
195s/\bcbChunk\b/chunk/g
196s/\bcbData\b/data_len/g
197s/\bcbHintsStructureGuest\b/hints_structure_guest_size/g
198s/\bcbHwBufferAvail\b/available/g
199s/\bcbLength\b/len/g
200s/\bcbLocation\b/buf_len/g
201s/\bcbPartialWriteThreshold\b/partial_write_tresh/g ## @todo fix this?
202s/\bcbPitch\b/pitch/g
203s/\bcbPixels\b/pixel_len/g
204s/\bcBPP\b/bpp/g
205s/\bcbRecord\b/len_and_flags/g ## @todo fix this?
206s/\bcDisplay\b/display/g
207s/\bcHeight\b/height/g
208s/\bcHintsQueried\b/hints_queried_count/g
209s/\bcHotX\b/hot_x/g
210s/\bcHotY\b/hot_y/g
211s/\bcOriginX\b/origin_x/g
212s/\bcOriginY\b/origin_y/g
213s/\bcScreen\b/screen/g
214s/\bcScreens\b/screens/g
215s/\bcWidth\b/width/g
216s/\bfCaps\b/caps/g
217s/\bfFlags\b/flags/g
218s/\bfHwBufferOverflow\b/buffer_overflow/g
219s/\bfReportPosition\b/report_position/g
220s/\bfu32Flags\b/flags/g
221s/\bhostFlags\b/host_flags/g
222s/\bi32Diff\b/diff/g
223s/\bi32OriginX\b/origin_x/g
224s/\bi32OriginY\b/origin_y/g
225s/\bi32Result\b/result/g
226s/\bindexRecordFirst\b/first_record_index/g
227s/\bindexRecordFree\b/free_record_index/g
228s/\bindexRecordNext\b/next/g
229s/\boff32Data\b/data_offset/g
230s/\boff32Free\b/free_offset/g
231s/\boffLocation\b/location/g
232s/\boffStart\b/start_offset/g
233s/\boffVRAMBuffer\b/buffer_offset/g
234s/\bpaHints\b/hints/g
235s/\bpCtx\b/ctx/g
236s/\bpPixels\b/pixels/g
237s/\bpRecord\b/record/g
238s/\bpulValue\b/value_ret/g
239s/\bpVBVA\b/vbva/g
240s/\bpxHost\b/x_host/g
241s/\bpyHost\b/y_host/g
242s/\bu16BitsPerPixel\b/bits_per_pixel/g
243s/\bu16Flags\b/flags/g
244s/\bu32BytesTillBoundary\b/bytes_till_boundary/g
245s/\bu32Flags\b/flags/g
246s/\bu32Height\b/height/g
247s/\bu32HostEvents\b/host_events/g
248s/\bu32HostFlags\b/host_flags/g
249s/\bu32HotX\b/hot_x/g
250s/\bu32HotY\b/hot_y/g
251s/\bu32Index\b/index/g
252s/\bu32LineSize\b/line_size/g
253s/\bu32Offset\b/offset/g
254s/\bu32Reserved\b/reserved/g
255s/\bu32ScreenId\b/screen_id/g
256s/\bu32StartOffset\b/start_offset/g
257s/\bu32SupportedOrders\b/supported_orders/g
258s/\bu32Value\b/value/g
259s/\bu32ViewIndex\b/view_index/g
260s/\bu32Width\b/width/g
261s/\bulValue\b/value/g
262
263# Header file guard:
264s/__HGSMIChannels_h__/__HGSMI_CHANNELS_H__/g
265s/VBOX_INCLUDED_Graphics_HGSMIChSetup_h/__HGSMI_CH_SETUP_H__/g
266
267# And move braces. This must be the last expression as it jumps to the next
268# line.
269/..*$/ {
270 N
271 s/^\([\t ][\t ]*\)} *\n[\t ]*else/\1} else/g
272 t continue_else
273 b try_brace
274:continue_else
275 N
276:try_brace
277 s/^\([\t ].*\)\n[\t ][\t ]*{/\1 {/g
278 s/^\([^#()]*\)\n[\t ]*{/\1 {/g
279 t done_brace
280 P
281 D
282:done_brace
283 p
284 d
285}
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use