[libdispatch-changes] [14] trunk

source_changes at macosforge.org source_changes at macosforge.org
Sat Sep 12 13:14:17 PDT 2009


Revision: 14
          http://trac.macosforge.org/projects/libdispatch/changeset/14
Author:   robert at fledge.watson.org
Date:     2009-09-12 13:14:13 -0700 (Sat, 12 Sep 2009)
Log Message:
-----------
Provide compatibility routines for non-portable Mac OS X APIs required
to use libdispatch on FreeBSD:

- __OSX_AVAILABLE_STARTING(): no-op
- Malloc zones: simple wrapper around malloc(3)

Added Paths:
-----------
    trunk/compat/
    trunk/compat/Availability.h
    trunk/compat/malloc_zone.h

Added: trunk/compat/Availability.h
===================================================================
--- trunk/compat/Availability.h	                        (rev 0)
+++ trunk/compat/Availability.h	2009-09-12 20:14:13 UTC (rev 14)
@@ -0,0 +1,26 @@
+/*
+ * Copyright (c) 2009 Apple Inc. All rights reserved.
+ *
+ * @APPLE_APACHE_LICENSE_HEADER_START@
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * @APPLE_APACHE_LICENSE_HEADER_END@
+ */
+
+#ifndef __AVAILABILITY_H__
+#define __AVAILABILITY_H__
+
+#define	__OSX_AVAILABLE_STARTING(x, y)
+
+#endif /* __AVAILABILITY_H__ */

Added: trunk/compat/malloc_zone.h
===================================================================
--- trunk/compat/malloc_zone.h	                        (rev 0)
+++ trunk/compat/malloc_zone.h	2009-09-12 20:14:13 UTC (rev 14)
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2009 Apple Inc. All rights reserved.
+ *
+ * @APPLE_APACHE_LICENSE_HEADER_START@
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * 
+ * @APPLE_APACHE_LICENSE_HEADER_END@
+ */
+
+#ifndef __MALLOC_ZONE_H__
+#define __MALLOC_ZONE_H__
+
+/*
+ * Implement malloc zones as a simple wrapper around malloc(3) on systems
+ * that don't support them.
+ */
+typedef void * malloc_zone_t;
+
+static inline malloc_zone_t *
+malloc_create_zone(size_t start_size, unsigned flags)
+{
+
+	return (NULL);
+}
+
+static inline void
+malloc_destroy_zone(malloc_zone_t *zone)
+{
+
+}
+
+static inline malloc_zone_t *
+malloc_default_zone(void)
+{
+
+	return (NULL);
+}
+
+static inline malloc_zone_t *
+malloc_zone_from_ptr(const void *ptr)
+{
+
+	return (NULL);
+}
+
+static inline void *
+malloc_zone_malloc(malloc_zone_t *zone, size_t size)
+{
+
+	return (malloc(size));
+}
+
+static inline void *
+malloc_zone_calloc(malloc_zone_t *zone, size_t num_items, size_t size)
+{
+
+	return (calloc(num_items, size));
+}
+
+static inline void *
+malloc_zone_realloc(malloc_zone_t *zone, void *ptr, size_t size)
+{
+
+	return (realloc(ptr, size));
+}
+
+static inline void *
+malloc_zone_memalign(malloc_zone_t *zone, size_t alignment, size_t size)
+{
+	void *ptr;
+
+	if (posix_memalign(&ptr, alignment, size) < 0)
+		return (NULL);
+	return (ptr);
+}
+
+static inline void
+malloc_zone_free(malloc_zone_t *zone, void *ptr)
+{
+
+	free(ptr);
+}
+
+static inline void
+malloc_set_zone_name(malloc_zone_t *zone, const char *name)
+{
+
+	/* No-op. */
+}
+
+#endif /* __MALLOC_ZONE_H__ */
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/libdispatch-changes/attachments/20090912/f48e22a4/attachment.html>


More information about the libdispatch-changes mailing list