1#ifndef UTL_GCC_DIAG_H
2#define UTL_GCC_DIAG_H
3
4/*
5 Hanoh Haim
6 Cisco Systems, Inc.
7*/
8
9/*
10Copyright (c) 2015-2015 Cisco Systems, Inc.
11
12Licensed under the Apache License, Version 2.0 (the "License");
13you may not use this file except in compliance with the License.
14You may obtain a copy of the License at
15
16    http://www.apache.org/licenses/LICENSE-2.0
17
18Unless required by applicable law or agreed to in writing, software
19distributed under the License is distributed on an "AS IS" BASIS,
20WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21See the License for the specific language governing permissions and
22limitations under the License.
23*/
24
25
26#define GCC_DIAG_STR(s) #s
27#define GCC_DIAG_JOINSTR(x,y) GCC_DIAG_STR(x ## y)
28# define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
29# define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
30#define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \
31    GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x))
32#define GCC_DIAG_ON() GCC_DIAG_PRAGMA(pop)
33
34#define UNSAFE_CONTAINER_OF_PUSH GCC_DIAG_OFF(invalid-offsetof)
35#define UNSAFE_CONTAINER_OF_POP  GCC_DIAG_ON()
36
37
38
39#endif
40