X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fcompiler.h;h=3b59813c9cab06370dfd5cccea5bcb997c37438f;hb=003ce655b7116d18c86a74c50391e54990346931;hp=e867d72f202a102526c3881b5e7a6b9569a460de;hpb=0e9a76b0052ac88584d985be2e5bf36909803ab3;p=sliver-openvswitch.git diff --git a/lib/compiler.h b/lib/compiler.h index e867d72f2..3b59813c9 100644 --- a/lib/compiler.h +++ b/lib/compiler.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc. + * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -179,6 +179,20 @@ #define OVS_PACKED(DECL) __pragma(pack(push, 1)) DECL __pragma(pack(pop)) #endif +/* For defining a structure whose instances should aligned on an N-byte + * boundary. + * + * e.g. The following: + * OVS_ALIGNED_STRUCT(64, mystruct) { ... }; + * is equivalent to the following except that it specifies 64-byte alignment: + * struct mystruct { ... }; + */ +#ifndef _MSC_VER +#define OVS_ALIGNED_STRUCT(N, TAG) struct __attribute__((aligned(N))) TAG +#else +#define OVS_ALIGNED_STRUCT(N, TAG) __declspec(align(N)) struct TAG +#endif + #ifdef _MSC_VER #define CCALL __cdecl #pragma section(".CRT$XCU",read)