X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fsgen%2Fsgen-protocol.h;h=8b82dc3794aee3a4eb19c7bf3b06da97f34115db;hb=HEAD;hp=220418e8167deea8101378669fffc325ee38be66;hpb=3bc22b19614835c73c42101eaf58de6f666ef81a;p=mono.git diff --git a/mono/sgen/sgen-protocol.h b/mono/sgen/sgen-protocol.h index 220418e8167..8b82dc3794a 100644 --- a/mono/sgen/sgen-protocol.h +++ b/mono/sgen/sgen-protocol.h @@ -1,23 +1,12 @@ -/* - * sgen-protocol.h: Binary protocol of internal activity, to aid - * debugging. +/** + * \file + * Binary protocol of internal activity, to aid debugging. * * Copyright 2001-2003 Ximian, Inc * Copyright 2003-2010 Novell, Inc. * Copyright (C) 2012 Xamarin Inc * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Library General Public - * License 2.0 as published by the Free Software Foundation; - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Library General Public License for more details. - * - * You should have received a copy of the GNU Library General Public - * License 2.0 along with this library; if not, write to the Free - * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #ifndef __MONO_SGENPROTOCOL_H__ @@ -25,6 +14,15 @@ #include "sgen-gc.h" +#define PROTOCOL_HEADER_CHECK 0xde7ec7ab1ec0de +/* + * The version needs to be bumped every time we introduce breaking changes (like + * adding new protocol entries or various format changes). The latest protocol grepper + * should be able to handle all the previous versions, while an old grepper will + * be able to tell if it cannot handle the format. + */ +#define PROTOCOL_HEADER_VERSION 2 + /* Special indices returned by MATCH_INDEX. */ #define BINARY_PROTOCOL_NO_MATCH (-1) #define BINARY_PROTOCOL_MATCH (-2) @@ -33,11 +31,21 @@ #define PROTOCOL_STRUCT(method) method ## _struct #define CLIENT_PROTOCOL_NAME(method) sgen_client_ ## method +#ifndef TYPE_INT #define TYPE_INT int +#endif +#ifndef TYPE_LONGLONG #define TYPE_LONGLONG long long +#endif +#ifndef TYPE_SIZE #define TYPE_SIZE size_t +#endif +#ifndef TYPE_POINTER #define TYPE_POINTER gpointer +#endif +#ifndef TYPE_BOOL #define TYPE_BOOL gboolean +#endif enum { #define BEGIN_PROTOCOL_ENTRY0(method) PROTOCOL_ID(method), @@ -69,31 +77,44 @@ enum { #include "sgen-protocol-def.h" }; +/* We pack all protocol structs by default unless specified otherwise */ +#ifndef PROTOCOL_STRUCT_ATTR + +#define PROTOCOL_PACK_STRUCTS + +#if defined(__GNUC__) +#define PROTOCOL_STRUCT_ATTR __attribute__ ((__packed__)) +#else +#define PROTOCOL_STRUCT_ATTR +#endif + +#endif + #define BEGIN_PROTOCOL_ENTRY0(method) #define BEGIN_PROTOCOL_ENTRY1(method,t1,f1) \ - typedef struct { \ + typedef struct PROTOCOL_STRUCT_ATTR { \ t1 f1; \ } PROTOCOL_STRUCT(method); #define BEGIN_PROTOCOL_ENTRY2(method,t1,f1,t2,f2) \ - typedef struct { \ + typedef struct PROTOCOL_STRUCT_ATTR { \ t1 f1; \ t2 f2; \ } PROTOCOL_STRUCT(method); #define BEGIN_PROTOCOL_ENTRY3(method,t1,f1,t2,f2,t3,f3) \ - typedef struct { \ + typedef struct PROTOCOL_STRUCT_ATTR { \ t1 f1; \ t2 f2; \ t3 f3; \ } PROTOCOL_STRUCT(method); #define BEGIN_PROTOCOL_ENTRY4(method,t1,f1,t2,f2,t3,f3,t4,f4) \ - typedef struct { \ + typedef struct PROTOCOL_STRUCT_ATTR { \ t1 f1; \ t2 f2; \ t3 f3; \ t4 f4; \ } PROTOCOL_STRUCT(method); #define BEGIN_PROTOCOL_ENTRY5(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5) \ - typedef struct { \ + typedef struct PROTOCOL_STRUCT_ATTR { \ t1 f1; \ t2 f2; \ t3 f3; \ @@ -101,7 +122,7 @@ enum { t5 f5; \ } PROTOCOL_STRUCT(method); #define BEGIN_PROTOCOL_ENTRY6(method,t1,f1,t2,f2,t3,f3,t4,f4,t5,f5,t6,f6) \ - typedef struct { \ + typedef struct PROTOCOL_STRUCT_ATTR { \ t1 f1; \ t2 f2; \ t3 f3; \ @@ -136,14 +157,22 @@ enum { #define END_PROTOCOL_ENTRY_FLUSH #define END_PROTOCOL_ENTRY_HEAVY +#if defined(_MSC_VER) && defined(PROTOCOL_PACK_STRUCTS) +#pragma pack(push) +#pragma pack(1) +#endif #include "sgen-protocol-def.h" +#if defined(_MSC_VER) && defined(PROTOCOL_PACK_STRUCTS) +#pragma pack(pop) +#undef PROTOCOL_PACK_STRUCTS +#endif /* missing: finalizers, roots, non-store wbarriers */ void binary_protocol_init (const char *filename, long long limit); gboolean binary_protocol_is_enabled (void); -void binary_protocol_flush_buffers (gboolean force); +gboolean binary_protocol_flush_buffers (gboolean force); #define BEGIN_PROTOCOL_ENTRY0(method) \ void method (void);