diff options
author | Guy Harris <guy@alum.mit.edu> | 2011-02-17 23:11:49 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2011-02-17 23:11:49 +0000 |
commit | b4f663a29bc1c9168108538d27c427a58c593668 (patch) | |
tree | 6507c1b3f0ac0ace859a109a49addbf4bc1f9c26 | |
parent | dae52000024e82dbb5ca4d1cf573b95d9a831330 (diff) |
On Windows, try putting __declspec(noreturn) in front of declarations of
routines that don't return. (This requires that some files include
config.h to get WS_MSVC_NORETURN declared properly.)
svn path=/trunk/; revision=35989
-rw-r--r-- | config.h.win32 | 11 | ||||
-rw-r--r-- | configure.in | 11 | ||||
-rw-r--r-- | dumpcap.c | 2 | ||||
-rw-r--r-- | epan/crc16.c | 4 | ||||
-rw-r--r-- | epan/crc32.c | 4 | ||||
-rw-r--r-- | epan/crypt/airpdcap_wep.c | 4 | ||||
-rw-r--r-- | epan/except.c | 14 | ||||
-rw-r--r-- | epan/except.h | 13 | ||||
-rw-r--r-- | timestats.c | 4 |
9 files changed, 52 insertions, 15 deletions
diff --git a/config.h.win32 b/config.h.win32 index 92f7057a16..bfed02b776 100644 --- a/config.h.win32 +++ b/config.h.win32 @@ -85,6 +85,17 @@ # define WS_VAR_IMPORT extern #endif +/* + * Define WS_MSVC_NORETURN appropriately for declarations of routines that + * never return (just like Charlie on the MTA). + * + * Note that MSVC++ expects __declspec(noreturn) to precede the function + * name and GCC, as far as I know, expects __attribute__((noreturn)) to + * follow the function name, so we need two different flavors of + * noreturn tag. + */ +#define WS_MSVC_NORETURN __declspec(noreturn) + /* Define if you have the gethostbyname2 function. */ /* #undef HAVE_GETHOSTBYNAME2 */ diff --git a/configure.in b/configure.in index e2272d490b..2583332f16 100644 --- a/configure.in +++ b/configure.in @@ -1584,6 +1584,17 @@ AC_SUBST(pythondir) # AC_DEFINE(WS_VAR_IMPORT, extern, [Define as the string to precede external variable declarations in dynamically-linked libraries]) +# +# Define WS_MSVC_NORETURN appropriately for declarations of routines that +# never return (just like Charlie on the MTA). +# +# Note that MSVC++ expects __declspec(noreturn) to precede the function +# name and GCC, as far as I know, expects __attribute__((noreturn)) to +# follow the function name, so we need two different flavors of +# noreturn tag. +# +AC_DEFINE(WS_MSVC_NORETURN,, [Define as the string to precede declarations of routines that never return]) + AC_ARG_ENABLE(airpcap, AC_HELP_STRING( [--enable-airpcap], [use airpcap in wireshark. @<:@default=yes@:>@]), @@ -324,7 +324,7 @@ static void capture_loop_packet_cb(u_char *user, const struct pcap_pkthdr *phdr, static void capture_loop_get_errmsg(char *errmsg, int errmsglen, const char *fname, int err, gboolean is_close); -static void exit_main(int err) G_GNUC_NORETURN; +static void WS_MSVC_NORETURN exit_main(int err) G_GNUC_NORETURN; static void report_new_capture_file(const char *filename); static void report_packet_count(int packet_count); diff --git a/epan/crc16.c b/epan/crc16.c index af578c5efa..5fcd105dca 100644 --- a/epan/crc16.c +++ b/epan/crc16.c @@ -33,6 +33,10 @@ * DCEs using asynchronous-to-synchronous conversion", Para. 8.1.1.6.1 */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <glib.h> #include <epan/tvbuff.h> #include <epan/crc16.h> diff --git a/epan/crc32.c b/epan/crc32.c index 3da5f52e2f..0fe2b29547 100644 --- a/epan/crc32.c +++ b/epan/crc32.c @@ -29,6 +29,10 @@ * Routine from Chris Waters */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <glib.h> #include <epan/tvbuff.h> #include <epan/crc32.h> diff --git a/epan/crypt/airpdcap_wep.c b/epan/crypt/airpdcap_wep.c index cfccd733fb..45d02df7eb 100644 --- a/epan/crypt/airpdcap_wep.c +++ b/epan/crypt/airpdcap_wep.c @@ -33,6 +33,10 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + /************************************************************************/ /* File includes */ diff --git a/epan/except.c b/epan/except.c index eea81d3a01..6138488227 100644 --- a/epan/except.c +++ b/epan/except.c @@ -26,6 +26,10 @@ * not freeing that). */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include <assert.h> #include <stdlib.h> #include <stdio.h> @@ -182,7 +186,7 @@ static int match(const volatile except_id_t *thrown, const except_id_t *caught) return group_match && code_match; } -G_GNUC_NORETURN static void do_throw(except_t *except) +G_GNUC_NORETURN WS_MSVC_NORETURN static void do_throw(except_t *except) { struct except_stacknode *top; @@ -263,7 +267,7 @@ struct except_stacknode *except_pop(void) return top; } -G_GNUC_NORETURN void except_rethrow(except_t *except) +G_GNUC_NORETURN WS_MSVC_NORETURN void except_rethrow(except_t *except) { struct except_stacknode *top = get_top(); assert (top != 0); @@ -273,7 +277,7 @@ G_GNUC_NORETURN void except_rethrow(except_t *except) do_throw(except); } -G_GNUC_NORETURN void except_throw(long group, long code, const char *msg) +G_GNUC_NORETURN WS_MSVC_NORETURN void except_throw(long group, long code, const char *msg) { except_t except; @@ -291,7 +295,7 @@ G_GNUC_NORETURN void except_throw(long group, long code, const char *msg) do_throw(&except); } -G_GNUC_NORETURN void except_throwd(long group, long code, const char *msg, void *data) +G_GNUC_NORETURN WS_MSVC_NORETURN void except_throwd(long group, long code, const char *msg, void *data) { except_t except; @@ -308,7 +312,7 @@ G_GNUC_NORETURN void except_throwd(long group, long code, const char *msg, void * XCEPT_BUFFER_SIZE? We could then just use this to generate formatted * messages. */ -G_GNUC_NORETURN void except_throwf(long group, long code, const char *fmt, ...) +G_GNUC_NORETURN WS_MSVC_NORETURN void except_throwf(long group, long code, const char *fmt, ...) { char *buf = except_alloc(XCEPT_BUFFER_SIZE); va_list vl; diff --git a/epan/except.h b/epan/except.h index f648806a20..16ee729a1d 100644 --- a/epan/except.h +++ b/epan/except.h @@ -90,18 +90,13 @@ extern void except_setup_try(struct except_stacknode *, struct except_catch *, const except_id_t [], size_t); extern struct except_stacknode *except_pop(void); -/* - * XXX - is there some way to annotate the G_GNUC_NORETURN functions - * usint the Standard Annotation Language so that Microsoft's static - * code analyzer knows they never return? - */ /* public interface functions */ extern int except_init(void); extern void except_deinit(void); -extern void except_rethrow(except_t *) G_GNUC_NORETURN; -extern void except_throw(long, long, const char *) G_GNUC_NORETURN; -extern void except_throwd(long, long, const char *, void *) G_GNUC_NORETURN; -extern void except_throwf(long, long, const char *, ...) G_GNUC_NORETURN; +extern void WS_MSVC_NORETURN except_rethrow(except_t *) G_GNUC_NORETURN; +extern void WS_MSVC_NORETURN except_throw(long, long, const char *) G_GNUC_NORETURN; +extern void WS_MSVC_NORETURN except_throwd(long, long, const char *, void *) G_GNUC_NORETURN; +extern void WS_MSVC_NORETURN except_throwf(long, long, const char *, ...) G_GNUC_NORETURN; extern void (*except_unhandled_catcher(void (*)(except_t *)))(except_t *); extern unsigned long except_code(except_t *); extern unsigned long except_group(except_t *); diff --git a/timestats.c b/timestats.c index ccbfa16fd0..67bda7a73f 100644 --- a/timestats.c +++ b/timestats.c @@ -23,6 +23,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + #include "timestats.h" /* Initialize a timestat_t struct */ |