Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Prettier koptcontext FFI 🗡️ (Use leptonica types directly. Functionally identical). It already needs postprocessing for the leptonica require anyway... * Unbreak pthreads... pthread_attr should be used as a pointer It's an union with a char array of variable size depending on the arch (56 on x64, 32 on x86, 36 otherwise). So far, we were using the largest size (x64), and I refreshed it on arm, which obviously broke running the testsuite on x64. I have *no* idea how bad of an idea it is to use the wrong array for the target arch, because that's obviously a nice ABI mismatch right there... * So, try very hard to do pthreads right, by using the prototype that matches the current arch.
- Loading branch information
Showing
8 changed files
with
64 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local ffi = require("ffi") | ||
|
||
ffi.cdef[[ | ||
typedef long unsigned int pthread_t; | ||
typedef union { | ||
char __size[36]; | ||
long int __align; | ||
} pthread_attr_t; | ||
int pthread_attr_init(pthread_attr_t *) __attribute__((__nothrow__, __leaf__)); | ||
int pthread_attr_setdetachstate(pthread_attr_t *, int) __attribute__((__nothrow__, __leaf__)); | ||
int pthread_attr_destroy(pthread_attr_t *) __attribute__((__nothrow__, __leaf__)); | ||
static const int PTHREAD_CREATE_DETACHED = 1; | ||
int pthread_create(pthread_t *restrict, const pthread_attr_t *restrict, void *(*)(void *), void *restrict) __attribute__((__nothrow__)); | ||
]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
local ffi = require("ffi") | ||
|
||
ffi.cdef[[ | ||
typedef long unsigned int pthread_t; | ||
typedef union { | ||
char __size[36]; | ||
long int __align; | ||
} pthread_attr_t; | ||
int pthread_attr_init(pthread_attr_t *) __attribute__((__nothrow__, __leaf__)); | ||
int pthread_attr_setdetachstate(pthread_attr_t *, int) __attribute__((__nothrow__, __leaf__)); | ||
int pthread_attr_destroy(pthread_attr_t *) __attribute__((__nothrow__, __leaf__)); | ||
static const int PTHREAD_CREATE_DETACHED = 1; | ||
int pthread_create(pthread_t *restrict, const pthread_attr_t *restrict, void *(*)(void *), void *restrict) __attribute__((__nothrow__)); | ||
]] | ||
-- The declaration vary depending on the arch, load the right one... | ||
|
||
if ffi.arch == "x64" then | ||
require("ffi/pthread_x64_h") | ||
elseif ffi.arch == "x86" then | ||
require("ffi/pthread_x86_h") | ||
else | ||
require("ffi/pthread_def_h") | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local ffi = require("ffi") | ||
|
||
ffi.cdef[[ | ||
typedef long unsigned int pthread_t; | ||
typedef union { | ||
char __size[56]; | ||
long int __align; | ||
} pthread_attr_t; | ||
int pthread_attr_init(pthread_attr_t *) __attribute__((__nothrow__, __leaf__)); | ||
int pthread_attr_setdetachstate(pthread_attr_t *, int) __attribute__((__nothrow__, __leaf__)); | ||
int pthread_attr_destroy(pthread_attr_t *) __attribute__((__nothrow__, __leaf__)); | ||
static const int PTHREAD_CREATE_DETACHED = 1; | ||
int pthread_create(pthread_t *restrict, const pthread_attr_t *restrict, void *(*)(void *), void *restrict) __attribute__((__nothrow__)); | ||
]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local ffi = require("ffi") | ||
|
||
ffi.cdef[[ | ||
typedef long unsigned int pthread_t; | ||
typedef union { | ||
char __size[32]; | ||
long int __align; | ||
} pthread_attr_t; | ||
int pthread_attr_init(pthread_attr_t *) __attribute__((__nothrow__, __leaf__)); | ||
int pthread_attr_setdetachstate(pthread_attr_t *, int) __attribute__((__nothrow__, __leaf__)); | ||
int pthread_attr_destroy(pthread_attr_t *) __attribute__((__nothrow__, __leaf__)); | ||
static const int PTHREAD_CREATE_DETACHED = 1; | ||
int pthread_create(pthread_t *restrict, const pthread_attr_t *restrict, void *(*)(void *), void *restrict) __attribute__((__nothrow__)); | ||
]] |