diff options
author | Karl Linden <karl.j.linden@gmail.com> | 2018-01-01 12:12:15 +0100 |
---|---|---|
committer | Karl Linden <karl.j.linden@gmail.com> | 2018-10-07 13:38:52 +0200 |
commit | 90f72c7c605a0334e2acd6cac9e6441417a3dbb9 (patch) | |
tree | 703accbee668824b98ae3bdb25f4a9d8372958a1 | |
parent | 631c12f4c327bcfa3fdc39498a0016a39196575c (diff) | |
download | jack2-compat.tar.gz |
Handle alloca properlycompat
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
-rw-r--r-- | common/JackNetOneDriver.cpp | 5 | ||||
-rw-r--r-- | common/netjack.c | 2 | ||||
-rw-r--r-- | common/netjack_packet.c | 2 | ||||
-rw-r--r-- | compat/alloca/README.md | 7 | ||||
-rw-r--r-- | compat/alloca/alloca.h | 34 | ||||
-rw-r--r-- | compat/alloca/wscript | 32 | ||||
-rw-r--r-- | example-clients/alsa_out.c | 1 | ||||
-rw-r--r-- | example-clients/session_notify.c | 2 |
8 files changed, 82 insertions, 3 deletions
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 <karl.j.linden@gmail.com> 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 <malloc.h> -#endif +#include <alloca.h> #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 <karl.j.linden@gmail.com> Copyright (C) 2008 Pieter Palmers <pieterpalmers@users.sourceforge.net> Copyright (C) 2006 Torben Hohn <torbenh@gmx.de> Copyright (C) 2003 Robert Ham <rah@bash.sh> @@ -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 <alloca.h> #include <math.h> #include <stdio.h> #include <memory.h> 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 <karl.j.linden@gmail.com> * Copyright (C) 2008 Marc-Olivier Barre <marco@marcochapeau.org> * Copyright (C) 2008 Pieter Palmers <pieterpalmers@users.sourceforge.net> * Copyright (C) 2006 Torben Hohn <torbenh@gmx.de> @@ -38,6 +39,7 @@ #define _GNU_SOURCE #endif +#include <alloca.h> #include <math.h> #include <stdio.h> #include <memory.h> 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 <alloca.h>` 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 <karl.j.linden@gmail.com> + * + * 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 <malloc.h> +# 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 <karl.j.linden@gmail.com> +# +# 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 <alloca.h> #include <stdio.h> #include <errno.h> #include <unistd.h> 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 <karl.j.linden@gmail.com> * 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 <alloca.h> #include <stdio.h> #include <errno.h> #include <unistd.h> |