19508e956SHanoh Haim#ifndef UTL_GCC_DIAG_H
29508e956SHanoh Haim#define UTL_GCC_DIAG_H
39508e956SHanoh Haim
49508e956SHanoh Haim/*
59508e956SHanoh Haim Hanoh Haim
69508e956SHanoh Haim Cisco Systems, Inc.
79508e956SHanoh Haim*/
89508e956SHanoh Haim
99508e956SHanoh Haim/*
109508e956SHanoh HaimCopyright (c) 2015-2015 Cisco Systems, Inc.
119508e956SHanoh Haim
129508e956SHanoh HaimLicensed under the Apache License, Version 2.0 (the "License");
139508e956SHanoh Haimyou may not use this file except in compliance with the License.
149508e956SHanoh HaimYou may obtain a copy of the License at
159508e956SHanoh Haim
169508e956SHanoh Haim    http://www.apache.org/licenses/LICENSE-2.0
179508e956SHanoh Haim
189508e956SHanoh HaimUnless required by applicable law or agreed to in writing, software
199508e956SHanoh Haimdistributed under the License is distributed on an "AS IS" BASIS,
209508e956SHanoh HaimWITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
219508e956SHanoh HaimSee the License for the specific language governing permissions and
229508e956SHanoh Haimlimitations under the License.
239508e956SHanoh Haim*/
249508e956SHanoh Haim
259508e956SHanoh Haim
269508e956SHanoh Haim#define GCC_DIAG_STR(s) #s
279508e956SHanoh Haim#define GCC_DIAG_JOINSTR(x,y) GCC_DIAG_STR(x ## y)
289508e956SHanoh Haim# define GCC_DIAG_DO_PRAGMA(x) _Pragma (#x)
299508e956SHanoh Haim# define GCC_DIAG_PRAGMA(x) GCC_DIAG_DO_PRAGMA(GCC diagnostic x)
309508e956SHanoh Haim#define GCC_DIAG_OFF(x) GCC_DIAG_PRAGMA(push) \
319508e956SHanoh Haim    GCC_DIAG_PRAGMA(ignored GCC_DIAG_JOINSTR(-W,x))
329508e956SHanoh Haim#define GCC_DIAG_ON() GCC_DIAG_PRAGMA(pop)
339508e956SHanoh Haim
349508e956SHanoh Haim#define UNSAFE_CONTAINER_OF_PUSH GCC_DIAG_OFF(invalid-offsetof)
359508e956SHanoh Haim#define UNSAFE_CONTAINER_OF_POP  GCC_DIAG_ON()
369508e956SHanoh Haim
379508e956SHanoh Haim
389508e956SHanoh Haim
399508e956SHanoh Haim#endif
40