1#!/usr/bin/perl -p 2# 3# This script is part of the Xen build system. It has a very 4# permissive licence to avoid complicating the licence of the 5# generated header file and to allow this seddery to be reused by 6# other projects. 7# 8# Permission is hereby granted, free of charge, to any person 9# obtaining a copy of this individual file (the "Software"), to deal 10# in the Software without restriction, including without limitation 11# the rights to use, copy, modify, merge, publish, distribute, 12# sublicense, and/or sell copies of the Software, and to permit 13# persons to whom the Software is furnished to do so, subject to the 14# following conditions: 15# 16# The above copyright notice and this permission notice shall be 17# included in all copies or substantial portions of the Software. 18# 19# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 22# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 23# BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 24# ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 25# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26# SOFTWARE. 27# 28# Copyright (C) 2011 Citrix Ltd 29 30our $namespace, $ucnamespace; 31 32BEGIN { 33 die unless @ARGV; 34 $namespace = pop @ARGV; 35 $namespace =~ s/^--prefix=// or die; 36 $ucnamespace = uc $namespace; 37 38 print <<END or die $!; 39/* 40 * DO NOT EDIT THIS FILE 41 * 42 * Generated automatically by bsd-sys-queue-h-seddery to 43 * - introduce ${ucnamespace}_ and ${namespace}_ namespace prefixes 44 * - turn "struct type" into "type" so that type arguments 45 * to the macros are type names not struct tags 46 * - remove the reference to sys/cdefs.h, which is not needed 47 * 48 * The purpose of this seddery is to allow the resulting file to be 49 * freely included by software which might also want to include other 50 * list macros; to make it usable when struct tags are not being used 51 * or not known; to make it more portable. 52 */ 53END 54} 55 56s/\b( _SYS_QUEUE | 57 SLIST | LIST | STAILQ | TAILQ | QUEUE 58 )/${ucnamespace}_$1/xg; 59 60s/\b( TRACEBUF | TRASHIT | 61 QMD_ 62 )/${ucnamespace}__$1/xg; 63 64s/\b( 65 qm_ 66 )/${namespace}__$1/xg; 67 68s/\b struct \s+ type \b/type/xg; 69 70s,^\#include.*sys/cdefs.*,/* $& */,xg; 71 72s,\b __offsetof \b ,offsetof,xg; 73 74s/\b( NULL )/0/xg; 75