-
-
Notifications
You must be signed in to change notification settings - Fork 308
Generate bindings for functions provided by the cshim using bindgen.
#818
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
Closed
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
e22e0bd
Split the shim into a separate header, that we run bindgen on
thomcc a35b1bb
Copy the shim source to OUT_DIR in a more principled way
thomcc 2ff41aa
Use `_Bool` not `bool` in cshim, to ensure our bindings come out as w…
thomcc c31ad83
Add explicit cast to bool in `tupdesc`
thomcc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,61 @@ | ||
| /* | ||
| Portions Copyright 2019-2021 ZomboDB, LLC. | ||
| Portions Copyright 2021-2022 Technology Concepts & Design, Inc. <support@tcdi.com> | ||
|
|
||
| All rights reserved. | ||
|
|
||
| Use of this source code is governed by the MIT license that can be found in the LICENSE file. | ||
| */ | ||
| #pragma once | ||
| #include "postgres.h" | ||
|
|
||
| #define IS_PG_10 (PG_VERSION_NUM >= 100000 && PG_VERSION_NUM < 110000) | ||
| #define IS_PG_11 (PG_VERSION_NUM >= 110000 && PG_VERSION_NUM < 120000) | ||
| #define IS_PG_12 (PG_VERSION_NUM >= 120000 && PG_VERSION_NUM < 130000) | ||
| #define IS_PG_13 (PG_VERSION_NUM >= 130000 && PG_VERSION_NUM < 140000) | ||
|
|
||
| #include "access/htup.h" | ||
| #include "access/htup_details.h" | ||
| #include "catalog/pg_type.h" | ||
| #if IS_PG_10 || IS_PG_11 | ||
| #include "nodes/relation.h" | ||
| #else | ||
| #include "nodes/pathnodes.h" | ||
| #endif | ||
| #include "nodes/pg_list.h" | ||
| #include "parser/parsetree.h" | ||
| #include "utils/memutils.h" | ||
| #include "utils/builtins.h" | ||
| #include "utils/array.h" | ||
| #include "storage/spin.h" | ||
|
|
||
| PGDLLEXPORT MemoryContext pgx_GetMemoryContextChunk(void *ptr); | ||
| PGDLLEXPORT void pgx_elog(int32 level, const char *message); | ||
| PGDLLEXPORT void pgx_elog_error(const char *message); | ||
| PGDLLEXPORT void pgx_ereport(int level, int code, const char *message, const char *file, int lineno, int colno); | ||
| PGDLLEXPORT void pgx_SET_VARSIZE(struct varlena *ptr, int size); | ||
| PGDLLEXPORT void pgx_SET_VARSIZE_SHORT(struct varlena *ptr, int size); | ||
| PGDLLEXPORT Datum pgx_heap_getattr(HeapTupleData *tuple, int attnum, TupleDesc tupdesc, bool *isnull); | ||
| PGDLLEXPORT TransactionId pgx_HeapTupleHeaderGetXmin(HeapTupleHeader htup_header); | ||
| PGDLLEXPORT CommandId pgx_HeapTupleHeaderGetRawCommandId(HeapTupleHeader htup_header); | ||
| PGDLLEXPORT RangeTblEntry *pgx_planner_rt_fetch(Index index, PlannerInfo *plannerInfo); | ||
| PGDLLEXPORT void *pgx_list_nth(List *list, int nth); | ||
| PGDLLEXPORT int pgx_list_nth_int(List *list, int nth); | ||
| PGDLLEXPORT Oid pgx_list_nth_oid(List *list, int nth); | ||
| PGDLLEXPORT ListCell *pgx_list_nth_cell(List *list, int nth); | ||
| #if IS_PG_10 || IS_PG_11 | ||
| PGDLLEXPORT Oid pgx_HeapTupleHeaderGetOid(HeapTupleHeader htup_header); | ||
| #endif | ||
| PGDLLEXPORT char *pgx_GETSTRUCT(HeapTuple tuple); | ||
| PGDLLEXPORT char *pgx_ARR_DATA_PTR(ArrayType *arr); | ||
| PGDLLEXPORT int pgx_ARR_NELEMS(ArrayType *arr); | ||
| PGDLLEXPORT bits8 *pgx_ARR_NULLBITMAP(ArrayType *arr); | ||
| PGDLLEXPORT int pgx_ARR_NDIM(ArrayType *arr); | ||
| PGDLLEXPORT int *pgx_ARR_DIMS(ArrayType *arr); | ||
| PGDLLEXPORT void pgx_SpinLockInit(volatile slock_t *lock); | ||
| PGDLLEXPORT void pgx_SpinLockAcquire(volatile slock_t *lock); | ||
| PGDLLEXPORT void pgx_SpinLockRelease(volatile slock_t *lock); | ||
| // Use `_Bool` and not `bool` until we can drop PG10, since under that version | ||
| // `bool` will be an 8 bit integer, which impacts bindgen output. | ||
| PGDLLEXPORT _Bool pgx_ARR_HASNULL(ArrayType *arr); | ||
| PGDLLEXPORT _Bool pgx_SpinLockFree(slock_t *lock); |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cute.
I wonder if our c-shim should be last? It probably doesn't matter, but I guess bindgen would start by picking up its #includes first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did it first in order to catch any cases where it is using files without including them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Admittedly we'd probably catch that when building the cshim, so I don't mind putting it second really.