Discussion:
[Trousers-scm] [GIT] Trousers master branch updated. TROUSERS_0_3_13-15-g3297fcd
Hon Ching(Vicky) Lo
2014-12-30 01:02:20 UTC
Permalink
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "Trousers".

The branch, master has been updated
via 3297fcdf5ac0df868778e976b8b59e35542c1ee2 (commit)
from 2547f81cc156eddc3dd7248e20b9e4b9dcaeb57f (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://trousers.git.sourceforge.net/git/gitweb.cgi?p=trousers/trousers;a=commitdiff;h=3297fcdf5ac0df868778e976b8b59e35542c1ee2

commit 3297fcdf5ac0df868778e976b8b59e35542c1ee2
Author: Mike Pontillo <***@mocana.com>
Date: Fri Dec 19 23:59:45 2014 -0500

Changes to allow building on OS X

1) Not using GCC-specific LDFLAGS when compiling tcsd
2) Use of a public domain portable_endian.h to abstract the fact that you
cannot #include <endian.h> on the Apple platform.
3) Addition of __APPLE__ to some places where __OpenBSD__ and __FreeBSD__
appear
4) Definition of HOST_NAME_MAX to avoid including bits/local_lim.h on
__APPLE__
(I think this is a Linux-specific header)
5) Removal of 'inline' inside 'extern' functions which were being made
available to other object files.
6) Minor change to 'gitignore' to also ignore the 'compile' script that
gets generated.

diff --git a/.gitignore b/.gitignore
index 11e877b..012c996 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,4 @@
/tools/ps_inspect
cscope.out
tags
+compile
diff --git a/configure.in b/configure.in
index add23dc..6f7a946 100644
--- a/configure.in
+++ b/configure.in
@@ -35,13 +35,19 @@ fi

# Arch specific stuff
case $target in
+ *darwin*)
+ TCSD_LDFLAGS=""
+ ;;
*solaris*)
CFLAGS="$CFLAGS -DSOLARIS"
;;
*)
+ TCSD_LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now"
;;
esac

+AC_SUBST(TCSD_LDFLAGS)
+
# Non-standard OpenSSL location
AC_MSG_CHECKING([Non-standard OpenSSL location])
AC_ARG_WITH(openssl,
diff --git a/src/include/portable_endian.h b/src/include/portable_endian.h
new file mode 100644
index 0000000..df0742d
--- /dev/null
+++ b/src/include/portable_endian.h
@@ -0,0 +1,115 @@
+// "License": Public Domain
+// I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
+
+#ifndef PORTABLE_ENDIAN_H__
+#define PORTABLE_ENDIAN_H__
+
+#if (defined(_WIN16) || defined(_WIN32) || defined(_WIN64)) && !defined(__WINDOWS__)
+
+# define __WINDOWS__
+
+#endif
+
+#if defined(__linux__) || defined(__CYGWIN__)
+
+# include <endian.h>
+
+#elif defined(__APPLE__)
+
+# include <libkern/OSByteOrder.h>
+
+# define htobe16(x) OSSwapHostToBigInt16(x)
+# define htole16(x) OSSwapHostToLittleInt16(x)
+# define be16toh(x) OSSwapBigToHostInt16(x)
+# define le16toh(x) OSSwapLittleToHostInt16(x)
+
+# define htobe32(x) OSSwapHostToBigInt32(x)
+# define htole32(x) OSSwapHostToLittleInt32(x)
+# define be32toh(x) OSSwapBigToHostInt32(x)
+# define le32toh(x) OSSwapLittleToHostInt32(x)
+
+# define htobe64(x) OSSwapHostToBigInt64(x)
+# define htole64(x) OSSwapHostToLittleInt64(x)
+# define be64toh(x) OSSwapBigToHostInt64(x)
+# define le64toh(x) OSSwapLittleToHostInt64(x)
+
+# define __BYTE_ORDER BYTE_ORDER
+# define __BIG_ENDIAN BIG_ENDIAN
+# define __LITTLE_ENDIAN LITTLE_ENDIAN
+# define __PDP_ENDIAN PDP_ENDIAN
+
+#elif defined(__OpenBSD__)
+
+# include <sys/endian.h>
+
+#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+
+# include <sys/endian.h>
+
+# define be16toh(x) betoh16(x)
+# define le16toh(x) letoh16(x)
+
+# define be32toh(x) betoh32(x)
+# define le32toh(x) letoh32(x)
+
+# define be64toh(x) betoh64(x)
+# define le64toh(x) letoh64(x)
+
+#elif defined(__WINDOWS__)
+
+# include <winsock2.h>
+# include <sys/param.h>
+
+# if BYTE_ORDER == LITTLE_ENDIAN
+
+# define htobe16(x) htons(x)
+# define htole16(x) (x)
+# define be16toh(x) ntohs(x)
+# define le16toh(x) (x)
+
+# define htobe32(x) htonl(x)
+# define htole32(x) (x)
+# define be32toh(x) ntohl(x)
+# define le32toh(x) (x)
+
+# define htobe64(x) htonll(x)
+# define htole64(x) (x)
+# define be64toh(x) ntohll(x)
+# define le64toh(x) (x)
+
+# elif BYTE_ORDER == BIG_ENDIAN
+
+ /* that would be xbox 360 */
+# define htobe16(x) (x)
+# define htole16(x) __builtin_bswap16(x)
+# define be16toh(x) (x)
+# define le16toh(x) __builtin_bswap16(x)
+
+# define htobe32(x) (x)
+# define htole32(x) __builtin_bswap32(x)
+# define be32toh(x) (x)
+# define le32toh(x) __builtin_bswap32(x)
+
+# define htobe64(x) (x)
+# define htole64(x) __builtin_bswap64(x)
+# define be64toh(x) (x)
+# define le64toh(x) __builtin_bswap64(x)
+
+# else
+
+# error byte order not supported
+
+# endif
+
+# define __BYTE_ORDER BYTE_ORDER
+# define __BIG_ENDIAN BIG_ENDIAN
+# define __LITTLE_ENDIAN LITTLE_ENDIAN
+# define __PDP_ENDIAN PDP_ENDIAN
+
+#else
+
+# error platform not supported
+
+#endif
+
+#endif
diff --git a/src/include/tcsd.h b/src/include/tcsd.h
index a7387ee..5b9462b 100644
--- a/src/include/tcsd.h
+++ b/src/include/tcsd.h
@@ -165,7 +165,9 @@ void *tcsd_thread_run(void *);
void thread_signal_init();

/* signal handling */
+#ifndef __APPLE__
struct sigaction tcsd_sa_int;
struct sigaction tcsd_sa_chld;
+#endif

#endif
diff --git a/src/include/tcsps.h b/src/include/tcsps.h
index 8754296..7a6f935 100644
--- a/src/include/tcsps.h
+++ b/src/include/tcsps.h
@@ -23,13 +23,10 @@ int get_file();
int put_file(int);
void close_file(int);
void ps_destroy();
-#ifdef SOLARIS
+
TSS_RESULT read_data(int, void *, UINT32);
TSS_RESULT write_data(int, void *, UINT32);
-#else
-inline TSS_RESULT read_data(int, void *, UINT32);
-inline TSS_RESULT write_data(int, void *, UINT32);
-#endif
+
int write_key_init(int, UINT32, UINT32, UINT32);
TSS_RESULT cache_key(UINT32, UINT16, TSS_UUID *, TSS_UUID *, UINT16, UINT32, UINT32);
TSS_RESULT UnloadBlob_KEY_PS(UINT16 *, BYTE *, TSS_KEY *);
diff --git a/src/include/trousers_types.h b/src/include/trousers_types.h
index 1c1d79f..ad0f6ef 100644
--- a/src/include/trousers_types.h
+++ b/src/include/trousers_types.h
@@ -120,7 +120,7 @@ typedef struct tdTSS_KEY {

#if (defined (__linux) || defined (linux) || defined (SOLARIS) || defined (__GLIBC__))
#define BSD_CONST
-#elif (defined (__OpenBSD__) || defined (__FreeBSD__))
+#elif (defined (__OpenBSD__) || defined (__FreeBSD__)) || defined (__APPLE__)
#define BSD_CONST const
#endif

diff --git a/src/tcs/ps/ps_utils.c b/src/tcs/ps/ps_utils.c
index 2e7f502..7bb2256 100644
--- a/src/tcs/ps/ps_utils.c
+++ b/src/tcs/ps/ps_utils.c
@@ -16,7 +16,13 @@
#if defined(HAVE_BYTEORDER_H)
#include <sys/byteorder.h>
#elif defined(HTOLE_DEFINED)
+
+#ifndef __APPLE__
#include <endian.h>
+#else
+#include "portable_endian.h"
+#endif
+
#define LE_16 htole16
#define LE_32 htole32
#define LE_64 htole64
@@ -42,11 +48,7 @@
struct key_disk_cache *key_disk_cache_head = NULL;


-#ifdef SOLARIS
TSS_RESULT
-#else
-inline TSS_RESULT
-#endif
read_data(int fd, void *data, UINT32 size)
{
int rc;
@@ -64,11 +66,7 @@ read_data(int fd, void *data, UINT32 size)
}


-#ifdef SOLARIS
TSS_RESULT
-#else
-inline TSS_RESULT
-#endif
write_data(int fd, void *data, UINT32 size)
{
int rc;
diff --git a/src/tcs/ps/tcsps.c b/src/tcs/ps/tcsps.c
index 0d55608..e47154b 100644
--- a/src/tcs/ps/tcsps.c
+++ b/src/tcs/ps/tcsps.c
@@ -20,7 +20,13 @@
#if defined (HAVE_BYTEORDER_H)
#include <sys/byteorder.h>
#elif defined (HTOLE_DEFINED)
+
+#ifndef __APPLE__
#include <endian.h>
+#else
+#include "portable_endian.h"
+#endif
+
#define LE_16 htole16
#define LE_32 htole32
#define LE_64 htole64
diff --git a/src/tcsd/Makefile.am b/src/tcsd/Makefile.am
index 2210734..856cf09 100644
--- a/src/tcsd/Makefile.am
+++ b/src/tcsd/Makefile.am
@@ -2,8 +2,7 @@ sbin_PROGRAMS=tcsd

tcsd_CFLAGS=-DAPPID=\"TCSD\" -DVAR_PREFIX=\"@localstatedir@\" -DETC_PREFIX=\"@sysconfdir@\" -I${top_srcdir}/src/include -fPIE -DPIE
tcsd_LDADD=${top_builddir}/src/tcs/libtcs.a ${top_builddir}/src/tddl/libtddl.a -lpthread @CRYPTOLIB@
-tcsd_LDFLAGS=-pie -Wl,-z,relro -Wl,-z,now
-
+tcsd_LDFLAGS=@TCSD_LDFLAGS@
tcsd_SOURCES=svrside.c tcsd_conf.c tcsd_threads.c platform.c

if TSS_BUILD_PS
diff --git a/src/tcsd/platform.c b/src/tcsd/platform.c
index a46cc34..8d7d96c 100644
--- a/src/tcsd/platform.c
+++ b/src/tcsd/platform.c
@@ -9,7 +9,7 @@
*/


-#if (defined (__FreeBSD__) || defined (__OpenBSD__))
+#if (defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__APPLE__))
#include <sys/param.h>
#include <sys/sysctl.h>
#include <err.h>
@@ -82,7 +82,7 @@ platform_get_runlevel()

return runlevel;
}
-#elif (defined (__FreeBSD__) || defined (__OpenBSD__))
+#elif (defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__APPLE__))

char
platform_get_runlevel()
diff --git a/src/tspi/ps/ps_utils.c b/src/tspi/ps/ps_utils.c
index aac40a1..8325914 100644
--- a/src/tspi/ps/ps_utils.c
+++ b/src/tspi/ps/ps_utils.c
@@ -22,7 +22,7 @@
#include "tspps.h"
#include "tsplog.h"

-inline TSS_RESULT
+TSS_RESULT
read_data(int fd, void *data, UINT32 size)
{
int rc;
@@ -39,7 +39,7 @@ read_data(int fd, void *data, UINT32 size)
return TSS_SUCCESS;
}

-inline TSS_RESULT
+TSS_RESULT
write_data(int fd, void *data, UINT32 size)
{
int rc;
diff --git a/src/tspi/ps/tspps.c b/src/tspi/ps/tspps.c
index c6f9c3d..b5e83d0 100644
--- a/src/tspi/ps/tspps.c
+++ b/src/tspi/ps/tspps.c
@@ -25,7 +25,13 @@
#if defined (HAVE_BYTEORDER_H)
#include <sys/byteorder.h>
#elif defined(HTOLE_DEFINED)
+
+#ifndef __APPLE__
#include <endian.h>
+#else
+#include "portable_endian.h"
+#endif
+
#define LE_16 htole16
#define LE_32 htole32
#define LE_64 htole64
diff --git a/src/tspi/tsp_tcsi_param.c b/src/tspi/tsp_tcsi_param.c
index 670f86f..157e0ec 100644
--- a/src/tspi/tsp_tcsi_param.c
+++ b/src/tspi/tsp_tcsi_param.c
@@ -11,7 +11,14 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
+
+
+#ifndef __APPLE__
#include <bits/local_lim.h>
+#else
+#define HOST_NAME_MAX 64
+#endif
+
#include "trousers/tss.h"
#include "trousers/trousers.h"
#include "trousers_types.h"

-----------------------------------------------------------------------

Summary of changes:
.gitignore | 1 +
configure.in | 6 ++
src/include/portable_endian.h | 115 +++++++++++++++++++++++++++++++++++++++++
src/include/tcsd.h | 2 +
src/include/tcsps.h | 7 +--
src/include/trousers_types.h | 2 +-
src/tcs/ps/ps_utils.c | 14 ++---
src/tcs/ps/tcsps.c | 6 ++
src/tcsd/Makefile.am | 3 +-
src/tcsd/platform.c | 4 +-
src/tspi/ps/ps_utils.c | 4 +-
src/tspi/ps/tspps.c | 6 ++
src/tspi/tsp_tcsi_param.c | 7 +++
13 files changed, 157 insertions(+), 20 deletions(-)
create mode 100644 src/include/portable_endian.h


hooks/post-receive
--
Trousers
Loading...