From: Dave Taht <d...@taht.net> This adds compile guards and Makefile support to building all of babeld in a single shot, as "babeld-whole".
This has compelling advantages: - It lets you A/B two versions with different compilation options such as debugging on or off, or selectively enable work in progress. Example: make EXTRA_DEFINES="-DNO_DEBUG -DHAVE_NEON" babeld-whole - (theoretically) gives the compiler more chances to find optimizations - Compiles faster This patch also enables verbose assembly language output of the resulting code with babeld-whole.s. --- Makefile | 15 ++++++++++++++- babeld.h | 4 ++++ configuration.h | 5 ++++- disambiguation.h | 5 +++++ generate-version.sh | 2 ++ interface.h | 4 ++++ kernel.h | 4 ++++ local.h | 4 ++++ message.h | 4 ++++ neighbour.h | 5 +++++ net.h | 5 +++++ resend.h | 6 +++++- route.h | 5 ++++- rule.h | 6 +++++- source.h | 5 +++++ util.h | 4 ++++ xroute.h | 5 +++++ 17 files changed, 83 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 9454b1a..e8795fb 100644 --- a/Makefile +++ b/Makefile @@ -68,6 +68,19 @@ xroute.o: xroute.c babeld.h kernel.h neighbour.h message.h route.h util.h \ version.h: ./generate-version.sh > version.h +# Whole program compilation with maximum optimization + +babeld-whole.c: $(SRCS) $(INCLUDES) + cat $(SRCS) > babeld-whole.c + +babeld-whole.s: babeld-whole.c + $(CC) $(CFLAGS) -O3 $(LDFLAGS) -fwhole-program -fverbose-asm \ + babeld-whole.c -S -o babeld-whole.s + +babeld-whole: babeld-whole.c + $(CC) $(CFLAGS) $(LDFLAGS) -O3 -fwhole-program babeld-whole.c \ + -o babeld-whole $(LDLIBS) + .SUFFIXES: .man .html .man.html: @@ -99,7 +112,7 @@ uninstall: -rm -f $(TARGET)$(MANDIR)/man8/babeld.8 clean: - -rm -f babeld babeld.html version.h *.o *~ core + -rm -f babeld babeld.html version.h *.o *~ core babeld-whole* reallyclean: clean -rm -f TAGS tags gmon.out cscope.out diff --git a/babeld.h b/babeld.h index e46dd79..2b1b64d 100644 --- a/babeld.h +++ b/babeld.h @@ -1,3 +1,5 @@ +#ifndef _BABEL_BABELD +#define _BABEL_BABELD /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -110,3 +112,5 @@ void schedule_neighbours_check(int msecs, int override); void schedule_interfaces_check(int msecs, int override); int resize_receive_buffer(int size); int reopen_logfile(void); + +#endif diff --git a/configuration.h b/configuration.h index de2b1ba..7a4a349 100644 --- a/configuration.h +++ b/configuration.h @@ -1,3 +1,5 @@ +#ifndef _BABEL_CONFIGURATION +#define _BABEL_CONFIGURATION /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -19,7 +21,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - /* Values returned by parse_config_from_string. */ #define CONFIG_ACTION_DONE 0 @@ -77,3 +78,5 @@ int install_filter(const unsigned char *prefix, unsigned short plen, const unsigned char *src_prefix, unsigned short src_plen, struct filter_result *result); int finalise_config(void); + +#endif diff --git a/disambiguation.h b/disambiguation.h index 13fc89a..aa67a68 100644 --- a/disambiguation.h +++ b/disambiguation.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_DISAMBIGUATION +#define _BABEL_DISAMBIGUATION + /* Copyright (c) 2014 by Matthieu Boutier and Juliusz Chroboczek. @@ -25,3 +28,5 @@ int kuninstall_route(const struct babel_route *route); int kswitch_routes(const struct babel_route *old, const struct babel_route *new); int kchange_route_metric(const struct babel_route *route, unsigned refmetric, unsigned cost, unsigned add); + +#endif diff --git a/generate-version.sh b/generate-version.sh index 22dba7d..7cd00f4 100755 --- a/generate-version.sh +++ b/generate-version.sh @@ -10,4 +10,6 @@ else version="unknown" fi +echo "#ifndef BABELD_VERSION" echo "#define BABELD_VERSION \"$version\"" +echo "#endif" diff --git a/interface.h b/interface.h index 7294196..a2eb390 100644 --- a/interface.h +++ b/interface.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_INTERFACE +#define _BABEL_INTERFACE + /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -143,3 +146,4 @@ void set_timeout(struct timeval *timeout, int msecs); int interface_up(struct interface *ifp, int up); int interface_ll_address(struct interface *ifp, const unsigned char *address); void check_interfaces(void); +#endif diff --git a/kernel.h b/kernel.h index b6286fc..e2a7565 100644 --- a/kernel.h +++ b/kernel.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_KERNEL +#define _BABEL_KERNEL + /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -109,3 +112,4 @@ int add_rule(int prio, const unsigned char *src_prefix, int src_plen, int flush_rule(int prio, int family); int change_rule(int new_prio, int old_prio, const unsigned char *src, int plen, int table); +#endif diff --git a/local.h b/local.h index 2316111..0f10b66 100644 --- a/local.h +++ b/local.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_LOCAL +#define _BABEL_LOCAL + /* Copyright (c) 2008 by Juliusz Chroboczek @@ -55,3 +58,4 @@ int local_read(struct local_socket *s); int local_header(struct local_socket *s); struct local_socket *local_socket_create(int fd); void local_socket_destroy(int i); +#endif diff --git a/message.h b/message.h index 5a80561..443d297 100644 --- a/message.h +++ b/message.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_MESSAGE +#define _BABEL_MESSAGE + /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -109,3 +112,4 @@ void handle_request(struct neighbour *neigh, const unsigned char *prefix, const unsigned char *src_prefix, unsigned char src_plen, unsigned char hop_count, unsigned short seqno, const unsigned char *id); +#endif diff --git a/neighbour.h b/neighbour.h index 62f8a7f..ad340b3 100644 --- a/neighbour.h +++ b/neighbour.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_NEIGHBOUR +#define _BABEL_NEIGHBOUR + /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -57,3 +60,5 @@ unsigned neighbour_rxcost(struct neighbour *neigh); unsigned neighbour_rttcost(struct neighbour *neigh); unsigned neighbour_cost(struct neighbour *neigh); int valid_rtt(struct neighbour *neigh); + +#endif diff --git a/net.h b/net.h index 56c1bb2..63d1643 100644 --- a/net.h +++ b/net.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_NET +#define _BABEL_NET + /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -27,3 +30,5 @@ int babel_send(int s, const struct sockaddr *sin, int slen); int tcp_server_socket(int port, int local); int unix_server_socket(const char *path); + +#endif diff --git a/resend.h b/resend.h index 05e182c..a8d4dd0 100644 --- a/resend.h +++ b/resend.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_RESEND +#define _BABEL_RESEND + /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -19,7 +22,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - #define REQUEST_TIMEOUT 65000 #define RESEND_MAX 3 @@ -66,3 +68,5 @@ int satisfy_request(const unsigned char *prefix, unsigned char plen, void expire_resend(void); void recompute_resend_time(void); void do_resend(void); + +#endif diff --git a/route.h b/route.h index 1d3211f..1756764 100644 --- a/route.h +++ b/route.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_ROUTE +#define _BABEL_ROUTE + /* Copyright (c) 2007-2011 by Juliusz Chroboczek @@ -19,7 +22,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - #define DIVERSITY_NONE 0 #define DIVERSITY_INTERFACE_1 1 #define DIVERSITY_CHANNEL_1 2 @@ -125,3 +127,4 @@ void route_changed(struct babel_route *route, struct source *oldsrc, unsigned short oldmetric); void route_lost(struct source *src, unsigned oldmetric); void expire_routes(void); +#endif diff --git a/rule.h b/rule.h index 3e20a57..7c9de1e 100644 --- a/rule.h +++ b/rule.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_RULE +#define _BABEL_RULE + /* Copyright (c) 2015 by Matthieu Boutier and Juliusz Chroboczek. @@ -19,7 +22,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - #define SRC_TABLE_NUM 10 extern int src_table_idx; /* number of the first table */ @@ -31,3 +33,5 @@ int find_table(const unsigned char *dest, unsigned short plen, const unsigned char *src, unsigned short src_plen); void release_tables(void); int check_rules(void); + +#endif diff --git a/source.h b/source.h index 4625bc8..74051a0 100644 --- a/source.h +++ b/source.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_SOURCE +#define _BABEL_SOURCE + /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -46,3 +49,5 @@ void update_source(struct source *src, unsigned short seqno, unsigned short metric); void expire_sources(void); void check_sources_released(void); + +#endif diff --git a/util.h b/util.h index dd7bfb7..22046e3 100644 --- a/util.h +++ b/util.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_UTIL +#define _BABEL_UTIL + /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -156,3 +159,4 @@ static inline void kdebugf(const char *format, ...) { return; } #endif +#endif diff --git a/xroute.h b/xroute.h index 44fcffa..ef260c0 100644 --- a/xroute.h +++ b/xroute.h @@ -1,3 +1,6 @@ +#ifndef _BABEL_XROUTE +#define _BABEL_XROUTE + /* Copyright (c) 2007, 2008 by Juliusz Chroboczek @@ -45,3 +48,5 @@ void xroute_stream_done(struct xroute_stream *stream); int kernel_addresses(int ifindex, int ll, struct kernel_route *routes, int maxroutes); int check_xroutes(int send_updates); + +#endif -- 2.7.4 _______________________________________________ Babel-users mailing list Babel-users@lists.alioth.debian.org http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/babel-users