Fix OSX build errors

This commit is contained in:
Andrew Bettison 2016-01-18 21:16:01 +10:30
parent b5c62a19d5
commit ae18d765a7
6 changed files with 44 additions and 14 deletions

View File

@ -47,6 +47,7 @@ LIB_SERVAL_OBJS = \
$(addprefix $(OBJSDIR_LIB)/, $(MDP_CLIENT_SOURCES:.c=.o))
MONITOR_CLIENT_OBJS = \
$(addprefix $(OBJSDIR_LIB)/, $(SERVAL_CLIENT_SOURCES:.c=.o)) \
$(addprefix $(OBJSDIR_LIB)/, $(SERVAL_LIB_SOURCES:.c=.o)) \
$(addprefix $(OBJSDIR_LIB)/, $(MONITOR_CLIENT_SRCS:.c=.o))
SIMULATOR_OBJS = \
$(addprefix $(OBJSDIR_TOOLS)/, $(SIMULATOR_SOURCES:.c=.o))

View File

@ -16,6 +16,7 @@ AX_GCC_FUNC_ATTRIBUTE(malloc)
AX_GCC_FUNC_ATTRIBUTE(unused)
AX_GCC_FUNC_ATTRIBUTE(used)
AX_GCC_VAR_ATTRIBUTE(section)
AX_GCC_VAR_ATTRIBUTE(section_seg)
dnl Init pkg-config
PKG_PROG_PKG_CONFIG()

25
log_on_config_change.c Normal file
View File

@ -0,0 +1,25 @@
/*
Serval DNA logging
Copyright 2016 Serval Project Inc.
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, 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 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
// This compilation unit provides an on_log_config_change() function for
// clients that do not define their own.
#include "log.h"
void cf_on_config_change() {}

View File

@ -30,7 +30,8 @@
# deprecated
# mode
# packed
# section (added 23 Nov 2015, Serval Project)
# section (added 23 Nov 2015, Serval Project)
# section_seg (added 18 Jan 2016, Serval Project)
# tls_model
# unused
# used
@ -87,6 +88,9 @@ AC_DEFUN([AX_GCC_VAR_ATTRIBUTE], [
[section], [
int foo __attribute__(($1("a"))) = 0;
],
[section_seg], [
int foo __attribute__((section("a,b"))) = 0;
],
[tls_model], [
__thread int bar1 __attribute__(($1("global-dynamic")));
__thread int bar2 __attribute__(($1("local-dynamic")));

View File

@ -25,29 +25,27 @@
#define SECTION_START(X) __start_##X
#define SECTION_END(X) __stop_##X
#ifndef HAVE_VAR_ATTRIBUTE_SECTION
#error "Compiler does not support __attribute__(section())"
#endif
#ifndef HAVE_FUNC_ATTRIBUTE_ALIGNED
#error "Compiler does not support __attribute__(aligned())"
#endif
#ifndef HAVE_FUNC_ATTRIBUTE_USED
#error "Compiler does not support __attribute__(used)"
#endif
#ifdef __APPLE__
#if defined(HAVE_VAR_ATTRIBUTE_SECTION_SEG)
# define _SECTION_ATTRIBUTE(X) __section__("__DATA,__"#X)
# define DECLARE_SECTION(TYPE, X) \
extern TYPE SECTION_START(X)[] __asm("section$start$__DATA$__" #X);\
extern TYPE SECTION_END(X)[] __asm("section$end$__DATA$__" #X)
#else // !__APPLE__
#elif defined(HAVE_VAR_ATTRIBUTE_SECTION)
# define _SECTION_ATTRIBUTE(X) __section__(#X)
# define DECLARE_SECTION(TYPE, X) \
extern TYPE SECTION_START(X)[];\
extern TYPE SECTION_END(X)[]
#endif // !__APPLE__
#else
#error "Compiler does not support __attribute__(section())"
#endif
#if !defined(HAVE_FUNC_ATTRIBUTE_ALIGNED)
#error "Compiler does not support __attribute__(aligned())"
#elif !defined(HAVE_FUNC_ATTRIBUTE_USED)
#error "Compiler does not support __attribute__(used)"
#else
#define IN_SECTION(name) __attribute__((__used__, __aligned__(sizeof(void *)), _SECTION_ATTRIBUTE(name)))
#endif
#endif // __SERVAL_DNA__SECTION_H

View File

@ -35,6 +35,7 @@ SERVAL_CLIENT_SOURCES = \
# client applications.
SERVAL_LIB_SOURCES = \
log_context.c \
log_on_config_change.c \
log_stderr.c
# These source files are imported and do not depend on any local header files.