Skip to content

Commit

Permalink
Add support for long double
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Nov 28, 2021
1 parent a2f982d commit 76bcbd5
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ impl<'a> Generator<'a> {

fn rust2c(&self, ty: &str) -> String {
match ty {
"c_longdouble" | "c_long_double" => format!("long double"),
t if t.starts_with("c_") => match &ty[2..].replace("long", " long")[..] {
s if s.starts_with('u') => format!("unsigned {}", &s[1..]),
"short" => "short".to_string(),
Expand Down
5 changes: 5 additions & 0 deletions testcrate/src/t1.h
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,8 @@ typedef struct
timeval tv;
char message[LOG_MAX_LINE_LENGTH];
} log_record_t;

typedef struct
{
long double inner;
} LongDoubleWrap;
11 changes: 11 additions & 0 deletions testcrate/src/t1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,14 @@ struct log_record_t {
tv: timeval,
message: [c_char; LOG_MAX_LINE_LENGTH],
}

#[cfg(not(any(target_pointer_width = "16", target_pointer_width = "32")))]
#[repr(C, align(16))]
struct LongDoubleWrap {
inner: u128,
}
#[cfg(any(target_pointer_width = "16", target_pointer_width = "32"))]
#[repr(C)]
struct LongDoubleWrap {
inner: c_double,
}

0 comments on commit 76bcbd5

Please sign in to comment.