Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New driver does not compile on macOS #612

Open
clementval opened this issue Jun 9, 2021 · 0 comments
Open

New driver does not compile on macOS #612

clementval opened this issue Jun 9, 2021 · 0 comments

Comments

@clementval
Copy link
Collaborator

clementval commented Jun 9, 2021

The new driver is making use of a cpp frontend in xcodeml-tools and this does not compile under macOS because it uses posix_fallocate function.

xcodeml-tools/F-FrontEnd-cpp/src/io_cache.cpp:145:17: error: 'posix_fallocate' was not declared in this scope
             if (posix_fallocate(fd, 0, size) != 0)

quick workaround is to add a simple implementation to be able to compile

static int posix_fallocate(int fd, off_t offset, off_t len)
{
    off_t c_test;
    int ret;
    if (!__builtin_saddll_overflow(offset, len, &c_test)) {
        fstore_t store = {F_ALLOCATECONTIG, F_PEOFPOSMODE, 0, offset + len};
        // Try to get a continuous chunk of disk space
        fcntl(fd, F_PREALLOCATE, &store);
        if (ret < 0) {
            // OK, perhaps we are too fragmented, allocate non-continuous
            store.fst_flags = F_ALLOCATEALL;
            ret = fcntl(fd, F_PREALLOCATE, &store);
            if (ret < 0) {
                return ret;
            }
        }
        ret = ftruncate(fd, offset + len);
    } else {
        // offset+len would overflow.
        ret = -1;
    }
    return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant