dpp icon indicating copy to clipboard operation
dpp copied to clipboard

virtio_net: dpp struggles to translate certain linux system headers (log2.h,init.h,printk.h,swap.h)

Open Laeeth opened this issue 5 years ago • 0 comments

Alexandru Miltaru gave a dconf talk on writing linux device drivers in D, focusing on replacing virtio_net.c in the kernel. He mentioned some problem with dpp.

https://drive.google.com/file/d/1cV2HYGkznFIHTc0QsbRykoi4Pm_1RTZM/view (will be moved to dconf.org site shortly)

Code is here: https://github.com/Laeeth/dlang-safer-linux-kernel-dpp

With 5.01.1 kernel I get the following problems:

➜  ~ d++ --include-path linux-kernel/linux/trunk/src/archlinux-linux/include --include-path linux-kernel/linux/trunk/src/archlinux-linux/arch/x86/include virtio_net_stub.dpp
Error: Error parsing '/tmp/fileyFO9EW':
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/log2.h:201:15: error: unknown type name '__attribute_const__'
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/log2.h:202:1: error: expected identifier or '('
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:142:13: error: expected parameter declarator
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:142:13: error: expected ')'
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:142:24: error: expected function body after function declarator
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:149:5: error: expected parameter declarator
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:149:5: error: expected ')'
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:149:5: error: expected function body after function declarator
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:287:6: error: expected parameter declarator
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:287:6: error: expected ')'
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:287:6: error: expected function body after function declarator
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:288:6: error: expected parameter declarator
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:288:6: error: expected ')'
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/init.h:288:6: error: expected function body after function declarator
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/printk.h:144:24: error: expected parameter declarator
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/printk.h:144:24: error: expected ')'
linux-kernel/linux/trunk/src/archlinux-linux/include/linux/printk.h:144:30: error: expected function body after function declarator
linux-kernel/linux/trunk/src/archlinux-linux/include/uapi/linux/swab.h:47:15: error: unknown type name '__attribute_const__'
linux-kernel/linux/trunk/src/archlinux-linux/include/uapi/linux/swab.h:47:8: error: 'inline' can only appear on functions
fatal error: too many errors emitted, stopping now
➜

original file is:

/* A network driver using virtio.
 *
 * Copyright 2007 Rusty Russell <[email protected]> IBM Corporation
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
//#define DEBUG
#include <linux/netdevice.h>
#include "etherdevice.h"
//#include <linux/etherdevice.h>
#include <linux/ethtool.h>
#include <linux/module.h>
#include "virtio.h"
//#include <linux/virtio.h>
#include <linux/virtio_net.h>
#include <linux/bpf.h>
#include "bpf_trace.h"
//#include <linux/bpf_trace.h>
//#include <linux/scatterlist.h>
#include "scatterlist.h"
#include <linux/if_vlan.h>
//#include <linux/slab.h>
#include "slab.h"
#include "cpu.h"
//#include <linux/cpu.h>
#include <linux/average.h>
#include <linux/filter.h>
#include <linux/kernel.h>
#include <linux/pci.h>
#include <net/route.h>
#include <net/xdp.h>
#include <net/net_failover.h>

Laeeth avatar May 13 '19 13:05 Laeeth