From 90f72c7c605a0334e2acd6cac9e6441417a3dbb9 Mon Sep 17 00:00:00 2001 From: Karl Linden Date: Mon, 1 Jan 2018 12:12:15 +0100 Subject: Handle alloca properly This adds missing includes for alloca. The man page of alloca(3) states that alloca.h should be #include'd to use alloca. Also work around missing alloca.h header on Windows by adding a compatibility module. Closes: #197 --- common/JackNetOneDriver.cpp | 5 ++--- common/netjack.c | 2 ++ common/netjack_packet.c | 2 ++ compat/alloca/README.md | 7 +++++++ compat/alloca/alloca.h | 34 ++++++++++++++++++++++++++++++++++ compat/alloca/wscript | 32 ++++++++++++++++++++++++++++++++ example-clients/alsa_out.c | 1 + example-clients/session_notify.c | 2 ++ 8 files changed, 82 insertions(+), 3 deletions(-) create mode 100644 compat/alloca/README.md create mode 100644 compat/alloca/alloca.h create mode 100644 compat/alloca/wscript diff --git a/common/JackNetOneDriver.cpp b/common/JackNetOneDriver.cpp index 90731c20..7a0c0efb 100644 --- a/common/JackNetOneDriver.cpp +++ b/common/JackNetOneDriver.cpp @@ -1,4 +1,5 @@ /* +Copyright (C) 2018 Karl Linden Copyright (C) 2008-2011 Torben Horn This program is free software; you can redistribute it and/or modify @@ -16,9 +17,7 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#ifdef WIN32 -#include -#endif +#include #include "JackNetOneDriver.h" #include "JackEngineControl.h" diff --git a/common/netjack.c b/common/netjack.c index 36337995..76e5519d 100644 --- a/common/netjack.c +++ b/common/netjack.c @@ -3,6 +3,7 @@ /* NetJack Abstraction. +Copyright (C) 2018 Karl Linden Copyright (C) 2008 Pieter Palmers Copyright (C) 2006 Torben Hohn Copyright (C) 2003 Robert Ham @@ -25,6 +26,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. $Id: net_driver.c,v 1.17 2006/04/16 20:16:10 torbenh Exp $ */ +#include #include #include #include diff --git a/common/netjack_packet.c b/common/netjack_packet.c index e69f8062..7e8f7be8 100644 --- a/common/netjack_packet.c +++ b/common/netjack_packet.c @@ -4,6 +4,7 @@ * * used by the driver and the jacknet_client * + * Copyright (C) 2019 Karl Linden * Copyright (C) 2008 Marc-Olivier Barre * Copyright (C) 2008 Pieter Palmers * Copyright (C) 2006 Torben Hohn @@ -38,6 +39,7 @@ #define _GNU_SOURCE #endif +#include #include #include #include diff --git a/compat/alloca/README.md b/compat/alloca/README.md new file mode 100644 index 00000000..69fc458f --- /dev/null +++ b/compat/alloca/README.md @@ -0,0 +1,7 @@ +# Compatibility Module for alloca + +This module contains a replacement header for alloca. To use this module +simply make sure to `#include ` in the file where alloca +should be used. If the header is missing the path to the replacement +header is added to the global include paths, so nothing more needs to be +done. diff --git a/compat/alloca/alloca.h b/compat/alloca/alloca.h new file mode 100644 index 00000000..7bf0999d --- /dev/null +++ b/compat/alloca/alloca.h @@ -0,0 +1,34 @@ +/* + * alloca.h + * + * Replacement header for systems lacking the alloca.h header required + * to use the alloca function. + * + * Copyright (C) 2018 Karl Linden + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 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 + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, + * USA. + * + */ + +#ifndef ALLOCA_H +# define ALLOCA_H + +# if _MSC_VER +# include +# define alloca _alloca +# endif /* _MSC_VER */ + +#endif /* !ALLOCA_H */ diff --git a/compat/alloca/wscript b/compat/alloca/wscript new file mode 100644 index 00000000..36798973 --- /dev/null +++ b/compat/alloca/wscript @@ -0,0 +1,32 @@ +#!/usr/bin/env python +# encoding: utf-8 +# +# Copyright (C) 2018 Karl Linden +# +# 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. +# +# 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, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# + +from waflib import Errors + +def options(opt): + pass + +def configure(conf): + try: + conf.check(header_name='alloca.h') + except Errors.ConfigurationError: + conf.env.append_unique('INCLUDES', conf.path.abspath()) + +def build(bld): + pass diff --git a/example-clients/alsa_out.c b/example-clients/alsa_out.c index 94955db9..d45a42b6 100644 --- a/example-clients/alsa_out.c +++ b/example-clients/alsa_out.c @@ -4,6 +4,7 @@ * as they would be used by many applications. */ +#include #include #include #include diff --git a/example-clients/session_notify.c b/example-clients/session_notify.c index 435fbcd6..7bb8dafb 100644 --- a/example-clients/session_notify.c +++ b/example-clients/session_notify.c @@ -1,6 +1,7 @@ /* * session_notify.c -- ultra minimal session manager * + * Copyright (C) 2018 Karl Linden * Copyright (C) 2010 Torben Hohn. * * This program is free software; you can redistribute it and/or modify @@ -18,6 +19,7 @@ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#include #include #include #include -- cgit v1.2.1