-
Notifications
You must be signed in to change notification settings - Fork 45
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
Make C++ compatible #13
Conversation
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Signed-off-by: Jorge Perez <jjperez@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Alright, @Snaipe PTAL! |
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
1858560
to
077c389
Compare
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
14c28eb
to
a82593e
Compare
* Target external, undefined symbols only. * Fix indirect symbol type check. * Fix table lookup. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
335b1be
to
46afad4
Compare
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
2665884
to
da21a47
Compare
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
da21a47
to
fb0e5b3
Compare
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
}; | ||
|
||
typedef void(*mmk_fn)(void); | ||
typedef struct mmk_stub *mmk_stub; | ||
struct mmk_stub; |
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.
This breaks the API as far as I'm concerned. I'd rather have mmk_stub be an alias for struct mmk_stub *
. I would be fine if struct mmk_stub
was renamed to struct mmk_stub_
however.
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.
It does break API, but I could only find one place where the mmk_stub
alias was being used instead of struct mmk_stub *
. I figured I'd normalize to the struct <name>
syntax instead.
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.
This is mostly about API usage -- mmk_stub is an opaque type, so having the user type struct mmk_stub
in C is just misleading because you'd expect to be able to change or read some fields in there.
In other words, I am fine with keeping struct and union keywords when it's possible to access the underlying type, and this is not one of these situations.
off[j++] = i; | ||
if ((s->n_type & N_EXT) && ((s->n_type & N_TYPE) == N_UNDF)) { | ||
const char *symname = strtab + s->n_un.n_strx; | ||
if (!strcmp(symname + 1, name)) off[j++] = i; |
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.
nit: I'd prefer if the if statement was over two lines.
if (lc->cmd == MMK_LC_SEGMENT) { | ||
const segment_cmd * sc = (void *) lc; | ||
if (strstr(sc->segname, "TEXT") != NULL) { | ||
text = sc; | ||
} else if (strstr(sc->segname, "LINKEDIT") != NULL) { | ||
linkedit = sc; | ||
} | ||
} |
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.
nit: spacing
# define MMK_COMMA_APPEND(_, prefix, content) (void) (prefix content), | ||
|
||
# define mmk_struct_initialize(variable, ...) \ | ||
(MMK_EXPAND(MMK_APPLY_N_(MMK_COMMA_APPEND, MMK_VA_NARGS(__VA_ARGS__), variable, __VA_ARGS__)) \ |
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.
Hah, what a clever hack -- I love it!
return dst; | ||
} | ||
|
||
va_list & mmk_assign(va_list & dst, va_list src) { |
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.
That should probably be inline
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.
Good point.
This grew massive and hard to review. I'll close this now, and open smaller PRs with these and other fixes. Hope you can take a look @Snaipe. |
Signed-off-by: Stephen Brawner <brawner@gmail.com>
Precisely what the title says. This patch allows
Mimick
to be used in C++ tests for C API.Depends on #11 and #12. Only 31c6ce0, 8381645, and 0b67235 are specific to this patch.