From 22d2062d954dcb88fa3dc65281d3f3d88ae87d68 Mon Sep 17 00:00:00 2001 From: Edward Thomson Date: Wed, 9 Jan 2019 18:25:10 +0000 Subject: Introduce GIT_CALLBACK macro to enforce cdecl Since we now always build the library with cdecl calling conventions, our callbacks should be decorated as such so that users will not be able to provide callbacks defined with other calling conventions. The `GIT_CALLBACK` macro will inject the `__cdecl` attribute as appropriate. --- include/git2/sys/stream.h | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'include/git2/sys/stream.h') diff --git a/include/git2/sys/stream.h b/include/git2/sys/stream.h index 938793124..255c93e2b 100644 --- a/include/git2/sys/stream.h +++ b/include/git2/sys/stream.h @@ -31,13 +31,13 @@ typedef struct git_stream { int encrypted; int proxy_support; - int (*connect)(struct git_stream *); - int (*certificate)(git_cert **, struct git_stream *); - int (*set_proxy)(struct git_stream *, const git_proxy_options *proxy_opts); - ssize_t (*read)(struct git_stream *, void *, size_t); - ssize_t (*write)(struct git_stream *, const char *, size_t, int); - int (*close)(struct git_stream *); - void (*free)(struct git_stream *); + int GIT_CALLBACK(connect)(struct git_stream *); + int GIT_CALLBACK(certificate)(git_cert **, struct git_stream *); + int GIT_CALLBACK(set_proxy)(struct git_stream *, const git_proxy_options *proxy_opts); + ssize_t GIT_CALLBACK(read)(struct git_stream *, void *, size_t); + ssize_t GIT_CALLBACK(write)(struct git_stream *, const char *, size_t, int); + int GIT_CALLBACK(close)(struct git_stream *); + void GIT_CALLBACK(free)(struct git_stream *); } git_stream; typedef struct { @@ -54,7 +54,7 @@ typedef struct { * service name * @return 0 or an error code */ - int (*init)(git_stream **out, const char *host, const char *port); + int GIT_CALLBACK(init)(git_stream **out, const char *host, const char *port); /** * Called to create a new connection on top of the given stream. If @@ -68,7 +68,7 @@ typedef struct { * for certificate validation * @return 0 or an error code */ - int (*wrap)(git_stream **out, git_stream *in, const char *host); + int GIT_CALLBACK(wrap)(git_stream **out, git_stream *in, const char *host); } git_stream_registration; /** @@ -111,7 +111,7 @@ GIT_EXTERN(int) git_stream_register( * @deprecated Provide a git_stream_registration to git_stream_register * @see git_stream_registration */ -typedef int (*git_stream_cb)(git_stream **out, const char *host, const char *port); +typedef int GIT_CALLBACK(git_stream_cb)(git_stream **out, const char *host, const char *port); /** * Register a TLS stream constructor for the library to use. This stream -- cgit v1.2.1