Skip to content

Commit 4f69177

Browse files
authored
Merge pull request #1730 from riscv-software-src/test-headers
Check in CI that all installed headers are usable
2 parents 6b89a49 + aa73432 commit 4f69177

File tree

10 files changed

+30
-22
lines changed

10 files changed

+30
-22
lines changed

Makefile.in

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,15 @@ install-hdrs : $(install_hdrs)
385385
$(INSTALL_HDR) $(src_dir)/$$file $(install_hdrs_dir)/`dirname $$file`; \
386386
done
387387

388+
install-hdrs-list.h: $(install_hdrs)
389+
rm -f $@.tmp
390+
for file in $(subst $(src_dir)/,,$^); \
391+
do \
392+
$(MKINSTALLDIRS) $(install_hdrs_dir)/`dirname $$file`; \
393+
echo "#include <$(src_dir)/$$file>" >> $@.tmp; \
394+
done
395+
mv $@.tmp $@
396+
388397
install-libs : $(install_libs)
389398
$(MKINSTALLDIRS) $(install_libs_dir)
390399
for file in $^; \

ci-tests/build-spike

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ mkdir install
1111
CXXFLAGS="-Wnon-virtual-dtor" CFLAGS="-Werror -Wignored-qualifiers -Wunused-function -Wunused-parameter -Wunused-variable" $DIR/../configure --prefix=`pwd`/install
1212
make -j"$(nproc 2> /dev/null || sysctl -n hw.ncpu)"
1313
make check
14-
make install
14+
make install install-hdrs-list.h
1515

1616
# check that help message prints without error
1717
install/bin/spike -h

ci-tests/test-spike

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ tar xf spike-ci.tar
1313
time ../install/bin/spike --isa=rv64gc pk hello | grep "Hello, world! Pi is approximately 3.141588."
1414

1515
# check that including sim.h in an external project works
16-
g++ -std=c++17 -I../install/include -L../install/lib $DIR/testlib.c -lriscv -o test-libriscv
17-
g++ -std=c++17 -I../install/include -L../install/lib $DIR/test-customext.cc -lriscv -o test-customext
16+
g++ -std=c++2a -I../install/include -L../install/lib $DIR/testlib.cc -lriscv -o test-libriscv
17+
g++ -std=c++2a -I../install/include -L../install/lib $DIR/test-customext.cc -lriscv -o test-customext
18+
19+
# check that all installed headers are functional
20+
g++ -std=c++2a -I../install/include -L../install/lib $DIR/testlib.cc -lriscv -o /dev/null -include ../install-hdrs-list.h
1821

1922
LD_LIBRARY_PATH=../install/lib ./test-libriscv pk hello| grep "Hello, world! Pi is approximately 3.141588."
2023
LD_LIBRARY_PATH=../install/lib ./test-customext pk dummy-slliuw | grep "Executed successfully"
File renamed without changes.

fdt/libfdt.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
* Copyright (C) 2006 David Gibson, IBM Corporation.
77
*/
88

9-
#include <libfdt_env.h>
10-
#include <fdt.h>
9+
#include "libfdt_env.h"
10+
#include "fdt.h"
1111

1212
#define FDT_FIRST_SUPPORTED_VERSION 0x02
1313
#define FDT_LAST_SUPPORTED_VERSION 0x11

fesvr/byteorder.h

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#ifndef _RISCV_BYTEORDER_H
44
#define _RISCV_BYTEORDER_H
55

6-
#include "config.h"
76
#include <stdint.h>
7+
#include <arpa/inet.h>
88

99
static inline uint8_t swap(uint8_t n) { return n; }
1010
static inline uint16_t swap(uint16_t n) { return (n >> 8) | (n << 8); }
@@ -22,17 +22,11 @@ static inline uint128_t swap(uint128_t n) { return (uint128_t(swap(uint64_t(n)))
2222
static inline int128_t swap(int128_t n) { return int128_t(swap(uint128_t(n))); }
2323
#endif
2424

25-
#ifdef WORDS_BIGENDIAN
26-
template<typename T> static inline T from_be(T n) { return n; }
27-
template<typename T> static inline T to_be(T n) { return n; }
28-
template<typename T> static inline T from_le(T n) { return swap(n); }
29-
template<typename T> static inline T to_le(T n) { return swap(n); }
30-
#else
31-
template<typename T> static inline T from_le(T n) { return n; }
32-
template<typename T> static inline T to_le(T n) { return n; }
33-
template<typename T> static inline T from_be(T n) { return swap(n); }
34-
template<typename T> static inline T to_be(T n) { return swap(n); }
35-
#endif
25+
static inline bool is_be() { return htonl(1) == 1; }
26+
template<typename T> static inline T from_be(T n) { return is_be() ? n : swap(n); }
27+
template<typename T> static inline T to_be(T n) { return from_be(n); }
28+
template<typename T> static inline T from_le(T n) { return is_be() ? swap(n) : n; }
29+
template<typename T> static inline T to_le(T n) { return from_le(n); }
3630

3731
// Wrapper to mark a value as target endian, to guide conversion code
3832

fesvr/elfloader.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#define _ELFLOADER_H
55

66
#include "elf.h"
7+
#include "memif.h"
78
#include <map>
89
#include <string>
910

riscv/cfg.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// See LICENSE for license details.
22

3+
#include "config.h"
34
#include "cfg.h"
45
#include "mmu.h"
56
#include "decode.h"

riscv/entropy_source.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
// See LICENSE for license details.
2+
3+
#ifndef _RISCV_ENTROPY_SOURCE_H
4+
#define _RISCV_ENTROPY_SOURCE_H
15

26
#include <fstream>
37
#include <iostream>
@@ -116,3 +120,4 @@ class entropy_source {
116120

117121
};
118122

123+
#endif

softfloat/softfloat.mk.in

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,8 +243,3 @@ softfloat_test_srcs =
243243
softfloat_install_hdrs = \
244244
softfloat.h \
245245
softfloat_types.h \
246-
primitives.h \
247-
internals.h \
248-
platform.h \
249-
primitiveTypes.h \
250-
specialize.h \

0 commit comments

Comments
 (0)