Browse Source

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
tags/v1.9.13
Karl Linden Karl Lindén 7 years ago
parent
commit
45f9332f54
8 changed files with 82 additions and 3 deletions
  1. +2
    -3
      common/JackNetOneDriver.cpp
  2. +2
    -0
      common/netjack.c
  3. +2
    -0
      common/netjack_packet.c
  4. +7
    -0
      compat/alloca/README.md
  5. +34
    -0
      compat/alloca/alloca.h
  6. +32
    -0
      compat/alloca/wscript
  7. +1
    -0
      example-clients/alsa_out.c
  8. +2
    -0
      example-clients/session_notify.c

+ 2
- 3
common/JackNetOneDriver.cpp View File

@@ -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"


+ 2
- 0
common/netjack.c View File

@@ -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>


+ 2
- 0
common/netjack_packet.c View File

@@ -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>


+ 7
- 0
compat/alloca/README.md View File

@@ -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.

+ 34
- 0
compat/alloca/alloca.h View File

@@ -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 */

+ 32
- 0
compat/alloca/wscript View File

@@ -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

+ 1
- 0
example-clients/alsa_out.c View File

@@ -4,6 +4,7 @@
* as they would be used by many applications.
*/

#include <alloca.h>
#include <stdio.h>
#include <errno.h>
#include <unistd.h>


+ 2
- 0
example-clients/session_notify.c View File

@@ -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>


Loading…
Cancel
Save