-
Notifications
You must be signed in to change notification settings - Fork 50
/
Stubs.c
30 lines (26 loc) · 877 Bytes
/
Stubs.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//===----------------------------------------------------------------------===//
//
// This source file is part of the Swift open source project
//
// Copyright (c) 2023 Apple Inc. and the Swift project authors.
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
//
//===----------------------------------------------------------------------===//
#include <stdlib.h>
#include <errno.h>
void *aligned_alloc(size_t alignment, size_t size);
// Embedded Swift currently requires posix_memalign, but the C libraries in the
// Zephyr SDK do not provide it. Let's implement it and forward the calls to
// aligned_alloc(3).
int
posix_memalign(void **memptr, size_t alignment, size_t size)
{
void *p = aligned_alloc(alignment, size);
if (p) {
*memptr = p;
return 0;
}
return errno;
}