From 4e99cfc7634ee7eb1d6ce2507e3a9444d7d025ca Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Wed, 22 Sep 2010 16:26:15 -0500 Subject: [PATCH] Added target support for Apple's iOS devices. Tom Pelaia II and Mark Engbretson contributed the build configuration and OS-dependent files, I modified the build config to bring it up to R3.14.12 standards and added the Release Notes. --- configure/os/CONFIG.Common.ios-arm | 22 ++++++ configure/os/CONFIG.Common.ios-x86 | 16 ++++ configure/os/CONFIG.Common.iosCommon | 86 ++++++++++++++++++++++ configure/os/CONFIG_SITE.Common.iosCommon | 24 ++++++ configure/os/CONFIG_SITE.darwin-x86.Common | 6 +- documentation/RELEASE_NOTES.html | 13 +++- src/libCom/osi/os/iOS/epicsMath.h | 27 +++++++ src/libCom/osi/os/iOS/osdEnv.c | 78 ++++++++++++++++++++ src/libCom/osi/os/iOS/osdSock.h | 82 +++++++++++++++++++++ src/libCom/osi/os/iOS/osdSockAddrReuse.cpp | 48 ++++++++++++ src/libCom/osi/os/iOS/osdTime.h | 30 ++++++++ src/libCom/osi/os/iOS/osiFileName.h | 18 +++++ 12 files changed, 448 insertions(+), 2 deletions(-) create mode 100644 configure/os/CONFIG.Common.ios-arm create mode 100644 configure/os/CONFIG.Common.ios-x86 create mode 100644 configure/os/CONFIG.Common.iosCommon create mode 100644 configure/os/CONFIG_SITE.Common.iosCommon create mode 100644 src/libCom/osi/os/iOS/epicsMath.h create mode 100644 src/libCom/osi/os/iOS/osdEnv.c create mode 100644 src/libCom/osi/os/iOS/osdSock.h create mode 100644 src/libCom/osi/os/iOS/osdSockAddrReuse.cpp create mode 100644 src/libCom/osi/os/iOS/osdTime.h create mode 100644 src/libCom/osi/os/iOS/osiFileName.h diff --git a/configure/os/CONFIG.Common.ios-arm b/configure/os/CONFIG.Common.ios-arm new file mode 100644 index 000000000..b6f1a57b8 --- /dev/null +++ b/configure/os/CONFIG.Common.ios-arm @@ -0,0 +1,22 @@ +# CONFIG.Common.ios-arm +# +# This file is maintained by the build community. +# +# Definitions for ios-arm target builds +#------------------------------------------------------- + +IOS_PLATFORM = iPhoneOS + +# +# Architecture-specific information +# +ARCH_CLASS = armv6 + +OP_SYS_CFLAGS += -fno-inline-functions + +# iOS optimization flags for arm architecture +OPT_CFLAGS_YES = -O2 +OPT_CXXFLAGS_YES = -O2 + +# Include definitions common to all iphone targets +include $(CONFIG)/os/CONFIG.Common.iosCommon diff --git a/configure/os/CONFIG.Common.ios-x86 b/configure/os/CONFIG.Common.ios-x86 new file mode 100644 index 000000000..c236e606c --- /dev/null +++ b/configure/os/CONFIG.Common.ios-x86 @@ -0,0 +1,16 @@ +# CONFIG.Common.ios-x86 +# +# This file is maintained by the build community. +# +# Definitions for ios-x86 target builds +#------------------------------------------------------- + +IOS_PLATFORM = iPhoneSimulator + +# +# Architecture-specific information +# +ARCH_CLASS = i386 + +# Include definitions common to all iOS targets +include $(CONFIG)/os/CONFIG.Common.iosCommon diff --git a/configure/os/CONFIG.Common.iosCommon b/configure/os/CONFIG.Common.iosCommon new file mode 100644 index 000000000..529ae4a03 --- /dev/null +++ b/configure/os/CONFIG.Common.iosCommon @@ -0,0 +1,86 @@ +# CONFIG.Common.iosCommon +# +# $Id$ +# This file is maintained by the build community. +# +# Definitions for iOS target archs +# Sites may override these definitions in CONFIG_SITE.Common.iosCommon +# or CONFIG_SITE..iosCommon +#------------------------------------------------------- + +# Include definitions common to all Unix targets +include $(CONFIG)/os/CONFIG.Common.UnixCommon + +# Include common gnu compiler definitions +include $(CONFIG)/CONFIG.gnuCommon + +#------------------------------------------------------- +# Valid build types +VALID_BUILDS = Ioc + +#------------------------------------------------------- +# operating system class (include/os/) +OS_CLASS = iOS + +#-------------------------------------------------- +# GNU and SDK directories +GNU_DIR = $(PLATFORM_DIR)/Developer/usr +SDK_DIR = $(PLATFORM_DIR)/Developer/SDKs/$(IOS_PLATFORM)$(IOS_VERSION).sdk + +#------------------------------------------------------- +# Build architecture flags +ARCH_DEP_CFLAGS += -arch $(ARCH_CLASS) +ARCH_DEP_LDFLAGS += -arch $(ARCH_CLASS) + +#-------------------------------------------------- +# Operating system flags +OP_SYS_CFLAGS += -isysroot $(SDK_DIR) -D__IPHONE_OS_VERSION_MIN_REQUIRED=30200 + +#-------------------------------------------------- +# Don't try to use precompiled headers when converting sequencer files +CPPSNCFLAGS += -no-cpp-precomp + +#-------------------------------------------------- +# Always compile in debugging symbol table information +# +OPT_CFLAGS_YES += -g +OPT_CXXFLAGS_YES += -g + +#------------------------------------------------------- +# Compiler definitions: +# Use clang instead of gcc +# Must use g++ still +CC = $(GNU_BIN)/clang +CCC = $(GNU_BIN)/c++ + +#------------------------------------------------------- +# Linker flags +OP_SYS_LDFLAGS += -dynamic -Z -L$(SDK_DIR)/usr/lib + +#------------------------------------------------------- +# Shared libraries +SHRLIB_VERSION = $(EPICS_VERSION).$(EPICS_REVISION).$(EPICS_MODIFICATION) +SHRLIB_LDFLAGS = -dynamiclib -flat_namespace -undefined suppress \ + -install_name $(shell perl $(TOOLS)/fullPathName.pl $(INSTALL_LIB))/$@ \ + -compatibility_version $(EPICS_VERSION).$(EPICS_REVISION) \ + -current_version $(SHRLIB_VERSION) +SHRLIB_SUFFIX = .$(SHRLIB_VERSION).dylib + +LOADABLE_SHRLIB_LDFLAGS = -bundle -flat_namespace -undefined suppress + +#-------------------------------------------------- +# code flags +CODE_CFLAGS = -fno-common -Wno-unused-value +CODE_CXXFLAGS = -fno-common + +# +# Add support for Objective-C source +# +vpath %.m $(USR_VPATH) $(ALL_SRC_DIRS) +%.o: %.m + $(COMPILE.c) -c $< + +#-------------------------------------------------- +# Allow site overrides +-include $(CONFIG)/os/CONFIG_SITE.Common.iosCommon +-include $(CONFIG)/os/CONFIG_SITE.$(EPICS_HOST_ARCH).iosCommon diff --git a/configure/os/CONFIG_SITE.Common.iosCommon b/configure/os/CONFIG_SITE.Common.iosCommon new file mode 100644 index 000000000..61458da7d --- /dev/null +++ b/configure/os/CONFIG_SITE.Common.iosCommon @@ -0,0 +1,24 @@ +# CONFIG_SITE.Common.iosCommon +# +# $Id$ +# This file is maintained by the build community. +# +# Site-specific settings for Apple iOS builds +#------------------------------------------------------- + +# iOS Version number + +#IOS_VERSION = 3.2 +IOS_VERSION = 4.1 + + +# Most sites will want shared libraries + +STATIC_BUILD=NO +SHARED_LIBRARIES=YES + + +# Platform path, this is probably correct + +XCODE_PATH := $(shell xcode-select -print-path) +PLATFORM_DIR = $(XCODE_PATH)/Platforms/$(IOS_PLATFORM).platform diff --git a/configure/os/CONFIG_SITE.darwin-x86.Common b/configure/os/CONFIG_SITE.darwin-x86.Common index 35c2157e4..b65232833 100644 --- a/configure/os/CONFIG_SITE.darwin-x86.Common +++ b/configure/os/CONFIG_SITE.darwin-x86.Common @@ -1,7 +1,11 @@ # CONFIG_SITE.darwin-x86.Common # -# $Id$ # This file is maintained by the build community. # +# $Id$ # Site override definitions for darwin-x86 host builds #------------------------------------------------------- + +# Uncomment the following line to cross-compile the +# iOS device (arm) and simulator (x86) binaries +#CROSS_COMPILER_TARGET_ARCHS = ios-arm ios-x86 diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html index 2b8e9337b..572d2a9c3 100644 --- a/documentation/RELEASE_NOTES.html +++ b/documentation/RELEASE_NOTES.html @@ -12,9 +12,20 @@

Changes between 3.14.11 and 3.14.12

+

Added Apple iOS target architectures

+ +

Tom Pelaia II and Mark Engbretson contributed build configuration files to +cross-compile Base for Apple's iOS operating system as used in the iPhone and +iPad. The target architecture for these is ios-arm, and there is also an ios-x86 +target which compiles for the iPhone Simulator running on darwin-x86.

+ +

To build these for iOS, uncomment the CROSS_COMPILER_TARGET_ARCHS +definition in configure/os/CONFIG_SITE.darwin-x86.Common and check the +settings in configure/os/CONFIG_SITE.Common.iosCommon.

+

Dynamic arrays over CA

-

Dymanic array sizing was developed by Michael Abbott at the 2010 EPICS +

Dynamic array sizing was developed by Michael Abbott at the 2010 EPICS Codeathon. It permits a CA client to fetch only the currently valid elements of an array by specifying a COUNT of zero to either of the ca_array_get_callback() or ca_create_subscription() routines. It has never before been legal to pass a diff --git a/src/libCom/osi/os/iOS/epicsMath.h b/src/libCom/osi/os/iOS/epicsMath.h new file mode 100644 index 000000000..493583f70 --- /dev/null +++ b/src/libCom/osi/os/iOS/epicsMath.h @@ -0,0 +1,27 @@ +/*************************************************************************\ +* Copyright (c) 2010 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +#ifndef epicsMathh +#define epicsMathh + +#include +#include + +#define finite(x) isfinite(x) + +#ifdef __cplusplus +extern "C" { +#endif + +epicsShareExtern float epicsNAN; +epicsShareExtern float epicsINF; + +#ifdef __cplusplus +} +#endif + +#endif /* epicsMathh */ diff --git a/src/libCom/osi/os/iOS/osdEnv.c b/src/libCom/osi/os/iOS/osdEnv.c new file mode 100644 index 000000000..25e8d2328 --- /dev/null +++ b/src/libCom/osi/os/iOS/osdEnv.c @@ -0,0 +1,78 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Saskatchewan +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* osdEnv.c */ +/* + * $Id$ + * + * Author: Eric Norum + * Date: May 7, 2001 + * + * Routines to modify/display environment variables and EPICS parameters + * + */ + +#include +#include +#include +#include +#include + +#define epicsExportSharedSymbols +#include +#include +#include +#include +#include +#include "epicsFindSymbol.h" + + +/* + * Set the value of an environment variable + * Leaks memory, but the assumption is that this routine won't be + * called often enough for the leak to be a problem. + */ +epicsShareFunc void epicsShareAPI epicsEnvSet (const char *name, const char *value) +{ + char *cp; + + cp = mallocMustSucceed (strlen (name) + strlen (value) + 2, "epicsEnvSet"); + strcpy (cp, name); + strcat (cp, "="); + strcat (cp, value); + if (putenv (cp) < 0) { + errPrintf( + -1L, + __FILE__, + __LINE__, + "Failed to set environment parameter \"%s\" to \"%s\": %s\n", + name, + value, + strerror (errno)); + free (cp); + } +} + +/* + * Show the value of the specified, or all, environment variables + */ +epicsShareFunc void epicsShareAPI epicsEnvShow (const char *name) +{ + if (name == NULL) { + extern char **environ; + char **sp; + + for (sp = environ ; (sp != NULL) && (*sp != NULL) ; sp++) + printf ("%s\n", *sp); + } + else { + const char *cp = getenv (name); + if (cp == NULL) + printf ("%s is not an environment variable.\n", name); + else + printf ("%s=%s\n", name, cp); + } +} diff --git a/src/libCom/osi/os/iOS/osdSock.h b/src/libCom/osi/os/iOS/osdSock.h new file mode 100644 index 000000000..fccc2897b --- /dev/null +++ b/src/libCom/osi/os/iOS/osdSock.h @@ -0,0 +1,82 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Saskatchewan +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * $Id$ + * + * Author: Eric Norum + */ + +#ifndef osdSockH +#define osdSockH + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +#include +#include /* for MAXHOSTNAMELEN */ +#include +#include +#include +/*#include +#include */ +#include +#include +#include +#include +#include +#include /* close() and others */ + + +#ifdef __cplusplus +} +#endif + +typedef int SOCKET; +#define INVALID_SOCKET (-1) +#define SOCKERRNO errno +#define socket_ioctl(A,B,C) ioctl(A,B,C) +typedef int osiSockIoctl_t; +typedef socklen_t osiSocklen_t; + +#define FD_IN_FDSET(FD) ((FD)ifr_addr.sa_len + sizeof((pifreq)->ifr_name)) + +#endif /*osdSockH*/ diff --git a/src/libCom/osi/os/iOS/osdSockAddrReuse.cpp b/src/libCom/osi/os/iOS/osdSockAddrReuse.cpp new file mode 100644 index 000000000..768b24865 --- /dev/null +++ b/src/libCom/osi/os/iOS/osdSockAddrReuse.cpp @@ -0,0 +1,48 @@ +/*************************************************************************\ +* Copyright (c) 2010 UChicago Argonne LLC, as Operator of Argonne +* National Laboratory. +* Copyright (c) 2002 The Regents of the University of California, as +* Operator of Los Alamos National Laboratory. +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * $Id$ + * Author: Jeff Hill + */ + +#define epicsExportSharedSymbols +#include "osiSock.h" +#include "errlog.h" + +epicsShareFunc void epicsShareAPI + epicsSocketEnableAddressReuseDuringTimeWaitState ( SOCKET s ) +{ + int yes = true; + int status; + status = setsockopt ( s, SOL_SOCKET, SO_REUSEADDR, + (char *) & yes, sizeof ( yes ) ); + if ( status < 0 ) { + errlogPrintf ( + "epicsSocketEnablePortUseForDatagramFanout: " + "unable to set SO_REUSEADDR?\n"); + } +} + +/* + * SO_REUSEPORT is not in POSIX + */ +epicsShareFunc void epicsShareAPI + epicsSocketEnableAddressUseForDatagramFanout ( SOCKET s ) +{ + int yes = true; + int status; + status = setsockopt ( s, SOL_SOCKET, SO_REUSEPORT, + (char *) & yes, sizeof ( yes ) ); + if ( status < 0 ) { + errlogPrintf ( + "epicsSocketEnablePortUseForDatagramFanout: " + "unable to set SO_REUSEPORT?\n"); + } +} diff --git a/src/libCom/osi/os/iOS/osdTime.h b/src/libCom/osi/os/iOS/osdTime.h new file mode 100644 index 000000000..615f8c4cf --- /dev/null +++ b/src/libCom/osi/os/iOS/osdTime.h @@ -0,0 +1,30 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Saskatchewan +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * $Id$ + * + * Author: Eric Norum + */ + +#ifndef osdTimeh +#define osdTimeh + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +epicsShareFunc void convertDoubleToWakeTime(double timeout, + struct timespec *wakeTime); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* ifndef osdTimeh */ + diff --git a/src/libCom/osi/os/iOS/osiFileName.h b/src/libCom/osi/os/iOS/osiFileName.h new file mode 100644 index 000000000..cd691ef74 --- /dev/null +++ b/src/libCom/osi/os/iOS/osiFileName.h @@ -0,0 +1,18 @@ +/*************************************************************************\ +* Copyright (c) 2002 The University of Saskatchewan +* EPICS BASE is distributed subject to a Software License Agreement found +* in file LICENSE that is included with this distribution. +\*************************************************************************/ + +/* + * $Id$ + * + * Author: Eric Norum + */ + +#ifndef osiFileNameH +#define osiFileNameH + +#include "unixFileName.h" + +#endif /* osiFileNameH */