Skip to content

Commit

Permalink
sparse: Configure target operating system and fix fallout.
Browse files Browse the repository at this point in the history
cgcc, the "sparse" wrapper that OVS uses, can be told the host architecture
or the host OS or both.  Until now, OVS has told it the host architecture
because it is fairly common that it doesn't guess it automatically.  Until
now, OS has not told it the host OS, assuming that it would get it right.
However, it doesn't--if you tell it the host OS or the host architecture,
it doesn't really have a default for the other.  This means that on Linux
(presumably the only OS where sparse works properly for OVS), it was not
defining __linux__, which caused some weird behavior.

This commit adds a flag to the cgcc invocation to make it define __linux__
on Linux, and it fixes some errors that this would otherwise cause.

Acked-by: Ilya Maximets <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
blp committed Apr 24, 2019
1 parent 46124c1 commit 0cdd5b1
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 5 deletions.
6 changes: 3 additions & 3 deletions acinclude.m4
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- autoconf -*-

# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017 Nicira, Inc.
# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2019 Nicira, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -1107,8 +1107,8 @@ AC_DEFUN([OVS_CHECK_SPARSE_TARGET],
[x86_64-*], [ac_cv_sparse_target=x86_64],
[ac_cv_sparse_target=other])])
AS_CASE([$ac_cv_sparse_target],
[x86], [SPARSEFLAGS= CGCCFLAGS=-target=i86],
[x86_64], [SPARSEFLAGS=-m64 CGCCFLAGS=-target=x86_64],
[x86], [SPARSEFLAGS= CGCCFLAGS="-target=i86 -target=host_os_specs"],
[x86_64], [SPARSEFLAGS=-m64 CGCCFLAGS="-target=x86_64 -target=host_os_specs"],
[SPARSEFLAGS= CGCCFLAGS=])
AC_SUBST([SPARSEFLAGS])
AC_SUBST([CGCCFLAGS])])
Expand Down
1 change: 1 addition & 0 deletions include/sparse/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,5 @@ noinst_HEADERS += \
include/sparse/sys/types.h \
include/sparse/sys/wait.h \
include/sparse/threads.h \
include/sparse/linux/if_packet.h \
include/sparse/linux/tc_act/tc_pedit.h
30 changes: 30 additions & 0 deletions include/sparse/linux/if_packet.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#ifndef FIX_LINUX_IF_PACKET_H
#define FIX_LINUX_IF_PACKET_H

#ifndef __CHECKER__
#error "Use this header only with sparse. It is not a correct implementation."
#endif

#include_next <linux/if_packet.h>

/* Fix endianness of 'spkt_protocol' and 'sll_protocol' members. */

#define sockaddr_pkt rpl_sockaddr_pkt
struct sockaddr_pkt {
unsigned short spkt_family;
unsigned char spkt_device[14];
ovs_be16 spkt_protocol;
};

#define sockaddr_ll rpl_sockaddr_ll
struct sockaddr_ll {
unsigned short sll_family;
ovs_be16 sll_protocol;
int sll_ifindex;
unsigned short sll_hatype;
unsigned char sll_pkttype;
unsigned char sll_halen;
unsigned char sll_addr[8];
};

#endif
4 changes: 2 additions & 2 deletions lib/perf-counter.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, 2016 Nicira, Inc.
* Copyright (c) 2015, 2016, 2019 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,7 +17,7 @@
/* This implementation only applies to the Linux platform. */

#include <config.h>
#if defined(__linux__) && defined(HAVE_LINUX_PERF_EVENT_H)
#if defined(__linux__) && defined(HAVE_LINUX_PERF_EVENT_H) && !__CHECKER__

#include <stddef.h>
#include <sys/types.h>
Expand Down

0 comments on commit 0cdd5b1

Please sign in to comment.