Skip to contentSkip to conversation

Port: Add OSX libuuid compat

PATCH New Michael Jeanson 2 participants 5 messages Nov 5, 2015 – Feb 11, 2016 3 messages not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 2/3 Port: Add OSX mman.h compat

---
 formats/lttng-live/lttng-live-comm.c |  2 +-
 include/babeltrace/compat/mman.h     | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 include/babeltrace/compat/mman.h
formats/lttng-live/lttng-live-comm.c +1 -1
index 0efae2d..c0a1868 100644
@@ -31,7 +31,6 @@
 #include <errno.h>
 #include <inttypes.h>
 #include <fcntl.h>
-#include <sys/mman.h>
 #include <poll.h>
 
 #include <babeltrace/ctf/ctf-index.h>
@@ -53,6 +52,7 @@
 #include <babeltrace/compat/memstream.h>
 #include <babeltrace/compat/send.h>
 #include <babeltrace/compat/string.h>
+#include <babeltrace/compat/mman.h>
 
 #include "lttng-live.h"
 #include "lttng-viewer-abi.h"
include/babeltrace/compat/mman.h new file +36 -0
new file mode 100644
index 0000000..061e244
@@ -0,0 +1,36 @@
+#ifndef _BABELTRACE_COMPAT_MMAN_H
+#define _BABELTRACE_COMPAT_MMAN_H
+
+/*
+ * babeltrace/compat/mman.h
+ *
+ * Copyright (C) 2015  Michael Jeanson <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <sys/mman.h>
+
+#ifndef MAP_ANONYMOUS
+# ifdef MAP_ANON
+#   define MAP_ANONYMOUS MAP_ANON
+# endif
+#endif
+
+#endif /* _BABELTRACE_COMPAT_MMAN_H */
Signature · 1 line
1.9.1
#2 lore raw

PATCH 3/3 Port: Add OSX libuuid compat

In reply to a message not in the archive

OSX has the libuuid symbols built in the system libraries.

---
 configure.ac | 48 ++++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 20 deletions(-)
configure.ac +28 -20
index f23e460..9c42017 100644
@@ -148,29 +148,37 @@ AM_CONDITIONAL([BABELTRACE_BUILD_WITH_MINGW], [test "x$MINGW32" = "xyes"])
 # Check what libraries are required on this platform to link sockets programs.
 AX_LIB_SOCKET_NSL
 
-# Check for libuuid
-AC_CHECK_LIB([uuid], [uuid_generate],
+# Check for uuid in system libs
+AC_CHECK_FUNCS([uuid_generate],
 [
-	AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBUUID], 1, [Has libuuid support.])
-	have_libuuid=yes
+  AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBUUID], 1, [Has libuuid support.])
+  link_with_libuuid=no
 ],
 [
-	# libuuid not found, check for uuid_create in libc.
-	AC_CHECK_LIB([c], [uuid_create],
-	[
-		AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBC_UUID], 1, [Has libc uuid support.])
-		have_libc_uuid=yes
-	],
-	[
-		# for MinGW32 we have our own internal implemenation of uuid using Windows functions.
-		if test "x$MINGW32" = xno; then
-			AC_MSG_ERROR([Cannot find libuuid uuid_generate nor libc uuid_create. Use [LDFLAGS]=-Ldir to specify their location.])
-		fi
-	])
-]
-)
-AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBUUID], [test "x$have_libuuid" = "xyes"])
-AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBC_UUID], [test "x$have_libc_uuid" = "xyes"])
+  # Check for libuuid
+  AC_CHECK_LIB([uuid], [uuid_generate],
+  [
+    AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBUUID], 1, [Has libuuid support.])
+    link_with_libuuid=yes
+  ],
+  [
+    # libuuid not found, check for uuid_create in libc.
+    AC_CHECK_LIB([c], [uuid_create],
+    [
+      AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBC_UUID], 1, [Has libc uuid support.])
+      link_with_libc_uuid=yes
+    ],
+    [
+      # for MinGW32 we have our own internal implemenation of uuid using Windows functions.
+      if test "x$MINGW32" = xno; then
+        AC_MSG_ERROR([Cannot find libuuid uuid_generate nor libc uuid_create. Use [LDFLAGS]=-Ldir to specify their location.])
+      fi
+    ])
+  ])
+])
+
+AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBUUID], [test "x$link_with_libuuid" = "xyes"])
+AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBC_UUID], [test "x$link_with_libc_uuid" = "xyes"])
 
 # Check for fmemopen
 AC_CHECK_LIB([c], [fmemopen],
Signature · 1 line
1.9.1
#3 lore raw

Re: [PATCH babeltrace 1/3] Port: Add OSX endian.h compat

In reply to a message not in the archive

Merged, thanks!

Jérémie

Quoted 59 lines · Michael Jeanson

From: Alexis Martin <[email protected]>

---
 include/babeltrace/endian.h | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)
include/babeltrace/endian.h +38 -1
index f0299ad..c5e5d70 100644
@@ -81,6 +81,44 @@
 #define BIG_ENDIAN     __BIG_ENDIAN
 #define PDP_ENDIAN     __PDP_ENDIAN
 #define BYTE_ORDER     __BYTE_ORDER
+
+#elif defined(__APPLE__)
+# include <machine/endian.h>
+# include <libkern/OSByteOrder.h>
+
+# if BYTE_ORDER == LITTLE_ENDIAN
+#  define htobe16(x) OSSwapConstInt16(x)
+#  define htole16(x) (x)
+#  define be16toh(x) OSSwapConstInt16(x)
+#  define le16toh(x) (x)
+
+#  define htobe32(x) OSSwapConstInt32(x)
+#  define htole32(x) (x)
+#  define be32toh(x) OSSwapConstInt32(x)
+#  define le32toh(x) (x)
+
+#  define htobe64(x) OSSwapConstInt64(x)
+#  define htole64(x) (x)
+#  define be64toh(x) OSSwapConstInt64(x)
+#  define le64toh(x) (x)
+
+# else /* BYTE_ORDER == LITTLE_ENDIAN */
+#  define htobe16(x) (x)
+#  define htole16(x) OSSwapConstInt16(x)
+#  define be16toh(x) (x)
+#  define le16toh(x) OSSwapConstInt16(x)
+
+#  define htobe32(x) (x)
+#  define htole32(x) OSSwapConstInt32(x)
+#  define be32toh(x) (x)
+#  define le32toh(x) OSSwapConstInt32(x)
+
+#  define htobe64(x) (x)
+#  define htole64(x) OSSwapConstInt64(x)
+#  define be64toh(x) (x)
+#  define le64toh(x) OSSwapConstInt64(x)
+#  endif
+
 #else
 #include <endian.h>
 
--

1.9.1

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#5 lore raw

Re: [PATCH babeltrace 2/3] Port: Add OSX mman.h compat

Merged, thanks!

Jérémie

Quoted 72 lines · Michael Jeanson
---
 formats/lttng-live/lttng-live-comm.c |  2 +-
 include/babeltrace/compat/mman.h     | 36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 1 deletion(-)
 create mode 100644 include/babeltrace/compat/mman.h
formats/lttng-live/lttng-live-comm.c +1 -1
index 0efae2d..c0a1868 100644
@@ -31,7 +31,6 @@
 #include <errno.h>
 #include <inttypes.h>
 #include <fcntl.h>
-#include <sys/mman.h>
 #include <poll.h>
 
 #include <babeltrace/ctf/ctf-index.h>
@@ -53,6 +52,7 @@
 #include <babeltrace/compat/memstream.h>
 #include <babeltrace/compat/send.h>
 #include <babeltrace/compat/string.h>
+#include <babeltrace/compat/mman.h>
 
 #include "lttng-live.h"
 #include "lttng-viewer-abi.h"
include/babeltrace/compat/mman.h new file +36 -1
new file mode 100644
index 0000000..061e244
@@ -0,0 +1,36 @@
+#ifndef _BABELTRACE_COMPAT_MMAN_H
+#define _BABELTRACE_COMPAT_MMAN_H
+
+/*
+ * babeltrace/compat/mman.h
+ *
+ * Copyright (C) 2015  Michael Jeanson <[email protected]>
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+
+#include <sys/mman.h>
+
+#ifndef MAP_ANONYMOUS
+# ifdef MAP_ANON
+#   define MAP_ANONYMOUS MAP_ANON
+# endif
+#endif
+
+#endif /* _BABELTRACE_COMPAT_MMAN_H */
--

1.9.1

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev

A message that is not in the archive (sent off-list or not yet received): [email protected]

#7 lore raw

Merged, thanks!

Jérémie

Quoted 72 lines · Michael Jeanson

OSX has the libuuid symbols built in the system libraries.

---
 configure.ac | 48 ++++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 20 deletions(-)
configure.ac +28 -21
index f23e460..9c42017 100644
@@ -148,29 +148,37 @@ AM_CONDITIONAL([BABELTRACE_BUILD_WITH_MINGW], [test "x$MINGW32" = "xyes"])
 # Check what libraries are required on this platform to link sockets programs.
 AX_LIB_SOCKET_NSL
 
-# Check for libuuid
-AC_CHECK_LIB([uuid], [uuid_generate],
+# Check for uuid in system libs
+AC_CHECK_FUNCS([uuid_generate],
 [
-       AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBUUID], 1, [Has libuuid support.])
-       have_libuuid=yes
+  AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBUUID], 1, [Has libuuid support.])
+  link_with_libuuid=no
 ],
 [
-       # libuuid not found, check for uuid_create in libc.
-       AC_CHECK_LIB([c], [uuid_create],
-       [
-               AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBC_UUID], 1, [Has libc uuid support.])
-               have_libc_uuid=yes
-       ],
-       [
-               # for MinGW32 we have our own internal implemenation of uuid using Windows functions.
-               if test "x$MINGW32" = xno; then
-                       AC_MSG_ERROR([Cannot find libuuid uuid_generate nor libc uuid_create. Use [LDFLAGS]=-Ldir to specify their location.])
-               fi
-       ])
-]
-)
-AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBUUID], [test "x$have_libuuid" = "xyes"])
-AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBC_UUID], [test "x$have_libc_uuid" = "xyes"])
+  # Check for libuuid
+  AC_CHECK_LIB([uuid], [uuid_generate],
+  [
+    AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBUUID], 1, [Has libuuid support.])
+    link_with_libuuid=yes
+  ],
+  [
+    # libuuid not found, check for uuid_create in libc.
+    AC_CHECK_LIB([c], [uuid_create],
+    [
+      AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBC_UUID], 1, [Has libc uuid support.])
+      link_with_libc_uuid=yes
+    ],
+    [
+      # for MinGW32 we have our own internal implemenation of uuid using Windows functions.
+      if test "x$MINGW32" = xno; then
+        AC_MSG_ERROR([Cannot find libuuid uuid_generate nor libc uuid_create. Use [LDFLAGS]=-Ldir to specify their location.])
+      fi
+    ])
+  ])
+])
+
+AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBUUID], [test "x$link_with_libuuid" = "xyes"])
+AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBC_UUID], [test "x$link_with_libc_uuid" = "xyes"])
 
 # Check for fmemopen
 AC_CHECK_LIB([c], [fmemopen],
--

1.9.1

Signature · 8 lines
Jérémie Galarneau
EfficiOS Inc.
http://www.efficios.com

_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev