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.)


git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@35989 f5534014-38df-0310-8fa8-9805f1628bb7
This commit is contained in:
guy 2011-02-17 23:11:49 +00:00
parent d00e4da340
commit 8c1922e87e
9 changed files with 52 additions and 15 deletions

View File

@ -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 */

View File

@ -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@:>@]),

View File

@ -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);

View File

@ -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>

View File

@ -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>

View File

@ -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 */

View File

@ -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;

View File

@ -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 *);

View File

@ -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 */