-
Notifications
You must be signed in to change notification settings - Fork 9
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
Create a new ddcommon-ffi crate and factorise generic ffi code inside it #24
Changes from all commits
c8e8aa6
a000f1e
ffcb1e7
1b2a692
5e5b3fc
55a6aac
4185102
2907292
8d4fb77
e296a8d
5f19eaf
abaa7ef
36ad2f3
e325341
ae191a4
78546c0
004f9bf
0a5c2d8
9bb1391
c763a5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
root_name: "ddprof, ddprof-exporter, ddcommon, ddprof-profiles, ddprof-ffi" | ||
root_name: "ddprof, ddprof-exporter, ddcommon, ddprof-profiles, ddprof-ffi, ddcommon-ffi, ddtelemetry" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should |
||
third_party_libraries: | ||
- package_name: aho-corasick | ||
package_version: 0.7.18 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ else () | |
set(DDProf_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/..") | ||
endif () | ||
|
||
find_path(DDProf_INCLUDE_DIR ddprof/ffi.h | ||
find_path(DDProf_INCLUDE_DIR datadog/profiling.h | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we take the opportunity to rename this file (On the other hand I realize this PR already includes quite a lot of things, so I'm also OK with leaving this for later -- it's not like we'll forget about it, it's pretty obvious and easy to find) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Leaving it for latter |
||
HINTS ${DDProf_ROOT}/include | ||
) | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
# This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc. | ||
|
||
[package] | ||
name = "ddcommon-ffi" | ||
Comment on lines
+4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ⬆️ I think we're missing the usual licence two-liner here |
||
version = "0.7.0-rc.1" | ||
edition = "2021" | ||
license = "Apache-2.0" | ||
|
||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html | ||
|
||
[dependencies] | ||
ddcommon = { path = "../ddcommon", version = "0.7.0-rc.1" } | ||
anyhow = "1.0" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
# This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc. | ||
|
||
language = "C" | ||
tab_width = 2 | ||
header = """// Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc. | ||
""" | ||
include_guard = "DDOG_COMMON_H" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Minor: Should this be |
||
style = "both" | ||
|
||
no_includes = true | ||
sys_includes = ["stdbool.h", "stddef.h", "stdint.h"] | ||
|
||
after_includes = """ | ||
|
||
#if defined(_MSC_VER) | ||
#define DDOG_CHARSLICE_C(string) \\ | ||
/* NOTE: Compilation fails if you pass in a char* instead of a literal */ {.ptr = "" string, .len = sizeof(string) - 1} | ||
#else | ||
#define DDOG_CHARSLICE_C(string) \\ | ||
/* NOTE: Compilation fails if you pass in a char* instead of a literal */ ((ddog_CharSlice){ .ptr = "" string, .len = sizeof(string) - 1 }) | ||
Comment on lines
+17
to
+22
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting that we needed the top variant for Windows; I also run into issues with really old versions of GCC (https://github.com/DataDog/dd-trace-rb/blob/master/ext/ddtrace_profiling_native_extension/stack_recorder.h#L16) in some cases... |
||
#endif | ||
|
||
#if defined(__cplusplus) && (__cplusplus >= 201703L) | ||
# define DDOG_CHECK_RETURN [[nodiscard]] | ||
#elif defined(_Check_return_) /* SAL */ | ||
# define DDOG_CHECK_RETURN _Check_return_ | ||
#elif (defined(__has_attribute) && __has_attribute(warn_unused_result)) || \\ | ||
(defined(__GNUC__) && (__GNUC__ >= 4)) | ||
# define DDOG_CHECK_RETURN __attribute__((__warn_unused_result__)) | ||
#else | ||
# define DDOG_CHECK_RETURN | ||
#endif""" | ||
|
||
[export] | ||
prefix = "ddog_" | ||
|
||
[export.mangle] | ||
rename_types="SnakeCase" | ||
|
||
[enum] | ||
prefix_with_name = true | ||
rename_variants = "ScreamingSnakeCase" | ||
|
||
[fn] | ||
must_use = "DDOG_CHECK_RETURN" | ||
|
||
[parse] | ||
parse_deps = true | ||
include = ["ddcommon"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2021-Present Datadog, Inc. | ||
|
||
pub mod slice; | ||
pub mod tags; | ||
pub mod vec; | ||
|
||
pub use slice::Slice; | ||
pub use vec::Vec; |
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 was talking a bit to Levi about how many packages we have yesterday and I got to wondering: why exactly do we need to have the ffi packages separated from the non-ffi ones?
I realize that if you're consuming these things from Rust, then you don't care about the ffi parts of the code. But if you're just using Rust, can't the compiler realize you're not using the ffi bits and just drop them from the final binary?
E.g. what would be the problem if we folded every
-ffi
package back into its "parent"?(This may be an incredibly stupid question, apologies!)
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.
Actually, not that bad of an idea. I don't think it would cause issues.
We could probably have an ffi module in ddcommon, ddprof, etc.. that exposes only what needs to be exposed.