mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
Fix compilation with macOS mmap/malloc workaround. Add Python (macOS) to CI.
This commit is contained in:
27
.github/workflows/build-majestic.yml
vendored
27
.github/workflows/build-majestic.yml
vendored
@@ -160,3 +160,30 @@ jobs:
|
||||
working-directory: ./src/runtime/haskell
|
||||
run: |
|
||||
cabal test --extra-lib-dirs=/usr/local/lib
|
||||
|
||||
macos-python:
|
||||
name: Python (macOS)
|
||||
runs-on: macOS-11
|
||||
needs: macos-runtime
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Download artifact
|
||||
uses: actions/download-artifact@master
|
||||
with:
|
||||
name: libpgf-macos
|
||||
- run: |
|
||||
sudo mv lib/* /usr/local/lib/
|
||||
sudo mv include/* /usr/local/include/
|
||||
|
||||
- name: Install bindings
|
||||
working-directory: ./src/runtime/python
|
||||
run: |
|
||||
python3 setup.py build
|
||||
sudo python3 setup.py install
|
||||
|
||||
- name: Run testsuite
|
||||
working-directory: ./src/runtime/python
|
||||
run: |
|
||||
pip3 install pytest
|
||||
pytest
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/mman.h>
|
||||
#include <unistd.h>
|
||||
@@ -325,10 +326,10 @@ PgfDB::PgfDB(const char* filepath, int flags, int mode) {
|
||||
|
||||
#ifndef MREMAP_MAYMOVE
|
||||
if (fd >= 0) {
|
||||
ms = (malloc_state*)
|
||||
mmap(NULL, file_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
ms = (malloc_state*)
|
||||
mmap(NULL, file_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
} else {
|
||||
ms = (malloc_state*) malloc(file_size); // doesn't compile
|
||||
ms = (malloc_state*) ::malloc(file_size);
|
||||
}
|
||||
#else
|
||||
int mflags = (fd < 0) ? (MAP_PRIVATE | MAP_ANONYMOUS) : MAP_SHARED;
|
||||
@@ -377,6 +378,11 @@ PgfDB::~PgfDB() {
|
||||
size_t size =
|
||||
ms->top + chunksize(ptr(ms,ms->top)) + sizeof(size_t);
|
||||
|
||||
#ifndef MREMAP_MAYMOVE
|
||||
if (fd < 0) {
|
||||
::free(ms);
|
||||
} else
|
||||
#endif
|
||||
munmap(ms,size);
|
||||
}
|
||||
|
||||
@@ -897,12 +903,12 @@ object PgfDB::malloc_internal(size_t bytes)
|
||||
// OSX mman and mman-win32 do not implement mremap or MREMAP_MAYMOVE
|
||||
#ifndef MREMAP_MAYMOVE
|
||||
if (fd >= 0) {
|
||||
if (munmap(ms, old_size) == -1)
|
||||
throw pgf_systemerror(errno);
|
||||
new_ms =
|
||||
(malloc_state*) mmap(0, new_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
if (munmap(ms, old_size) == -1)
|
||||
throw pgf_systemerror(errno);
|
||||
new_ms =
|
||||
(malloc_state*) mmap(0, new_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
|
||||
} else {
|
||||
new_ms = (malloc_state*) realloc(ms, new_size);
|
||||
new_ms = (malloc_state*) realloc(ms, new_size);
|
||||
}
|
||||
#else
|
||||
new_ms =
|
||||
|
||||
Reference in New Issue
Block a user