From 9fdf33076fadc7e5998eb0fbc6568cac5235b89d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 12 Mar 2025 20:06:45 -0700 Subject: [PATCH] Move the source-selection macros to a common header Avoids having to repeat ourselves. Signed-off-by: Thiago Macieira --- src/cborencoder.c | 11 +------ src/cborencoder_close_container_checked.c | 7 +---- src/cborencoder_float.c | 7 +---- src/cborinternalmacros_p.h | 36 +++++++++++++++++++++++ src/cborparser.c | 11 +------ src/cborparser_dup_string.c | 11 +------ src/cborparser_float.c | 7 +---- src/cborpretty.c | 7 +---- src/cbortojson.c | 8 +---- src/cborvalidation.c | 7 +---- 10 files changed, 45 insertions(+), 67 deletions(-) create mode 100644 src/cborinternalmacros_p.h diff --git a/src/cborencoder.c b/src/cborencoder.c index 138caf77..ad242e30 100644 --- a/src/cborencoder.c +++ b/src/cborencoder.c @@ -22,16 +22,7 @@ ** ****************************************************************************/ -#ifndef _BSD_SOURCE -#define _BSD_SOURCE 1 -#endif -#ifndef _DEFAULT_SOURCE -#define _DEFAULT_SOURCE 1 -#endif -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -#endif -#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include "cborinternalmacros_p.h" #include "cbor.h" #include "cborinternal_p.h" diff --git a/src/cborencoder_close_container_checked.c b/src/cborencoder_close_container_checked.c index b88f06cf..fd203a85 100644 --- a/src/cborencoder_close_container_checked.c +++ b/src/cborencoder_close_container_checked.c @@ -22,12 +22,7 @@ ** ****************************************************************************/ -#define _BSD_SOURCE 1 -#define _DEFAULT_SOURCE 1 -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -#endif -#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include "cborinternalmacros_p.h" #include "cbor.h" diff --git a/src/cborencoder_float.c b/src/cborencoder_float.c index d87919e2..ff879423 100644 --- a/src/cborencoder_float.c +++ b/src/cborencoder_float.c @@ -22,12 +22,7 @@ ** ****************************************************************************/ -#define _BSD_SOURCE 1 -#define _DEFAULT_SOURCE 1 -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -#endif -#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include "cborinternalmacros_p.h" #include "cbor.h" diff --git a/src/cborinternalmacros_p.h b/src/cborinternalmacros_p.h new file mode 100644 index 00000000..8450a3b8 --- /dev/null +++ b/src/cborinternalmacros_p.h @@ -0,0 +1,36 @@ +/**************************************************************************** +** +** Copyright (C) 2025 Intel Corporation +** +** Permission is hereby granted, free of charge, to any person obtaining a copy +** of this software and associated documentation files (the "Software"), to deal +** in the Software without restriction, including without limitation the rights +** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +** copies of the Software, and to permit persons to whom the Software is +** furnished to do so, subject to the following conditions: +** +** The above copyright notice and this permission notice shall be included in +** all copies or substantial portions of the Software. +** +** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +** FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +** AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +** LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +** OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +** THE SOFTWARE. +** +****************************************************************************/ + +#ifndef _BSD_SOURCE +# define _BSD_SOURCE 1 +#endif +#ifndef _DEFAULT_SOURCE +# define _DEFAULT_SOURCE 1 +#endif +#ifndef __STDC_LIMIT_MACROS +# define __STDC_LIMIT_MACROS 1 +#endif +#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__ +# define __STDC_WANT_IEC_60559_TYPES_EXT__ +#endif diff --git a/src/cborparser.c b/src/cborparser.c index 449e7f87..31c8d8bf 100644 --- a/src/cborparser.c +++ b/src/cborparser.c @@ -22,16 +22,7 @@ ** ****************************************************************************/ -#ifndef _BSD_SOURCE -#define _BSD_SOURCE 1 -#endif -#ifndef _DEFAULT_SOURCE -#define _DEFAULT_SOURCE 1 -#endif -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -#endif -#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include "cborinternalmacros_p.h" #include "cbor.h" #include "cborinternal_p.h" diff --git a/src/cborparser_dup_string.c b/src/cborparser_dup_string.c index 30a241e2..21d88c25 100644 --- a/src/cborparser_dup_string.c +++ b/src/cborparser_dup_string.c @@ -22,16 +22,7 @@ ** ****************************************************************************/ -#ifndef _BSD_SOURCE -#define _BSD_SOURCE 1 -#endif -#ifndef _DEFAULT_SOURCE -#define _DEFAULT_SOURCE 1 -#endif -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -#endif -#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include "cborinternalmacros_p.h" #include "cbor.h" #include "compilersupport_p.h" diff --git a/src/cborparser_float.c b/src/cborparser_float.c index 268239ee..f7d0189e 100644 --- a/src/cborparser_float.c +++ b/src/cborparser_float.c @@ -22,12 +22,7 @@ ** ****************************************************************************/ -#define _BSD_SOURCE 1 -#define _DEFAULT_SOURCE 1 -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -#endif -#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include "cborinternalmacros_p.h" #include "cbor.h" diff --git a/src/cborpretty.c b/src/cborpretty.c index a07741f7..b1e96848 100644 --- a/src/cborpretty.c +++ b/src/cborpretty.c @@ -22,12 +22,7 @@ ** ****************************************************************************/ -#define _BSD_SOURCE 1 -#define _DEFAULT_SOURCE 1 -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -#endif -#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include "cborinternalmacros_p.h" #include "cbor.h" #include "cborinternal_p.h" diff --git a/src/cbortojson.c b/src/cbortojson.c index 0bf8c662..c48fd4d2 100644 --- a/src/cbortojson.c +++ b/src/cbortojson.c @@ -22,13 +22,7 @@ ** ****************************************************************************/ -#define _BSD_SOURCE 1 -#define _DEFAULT_SOURCE 1 -#define _GNU_SOURCE 1 -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -#endif -#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include "cborinternalmacros_p.h" #include "cbor.h" #include "cborjson.h" diff --git a/src/cborvalidation.c b/src/cborvalidation.c index 6e13138b..2ad0c18c 100644 --- a/src/cborvalidation.c +++ b/src/cborvalidation.c @@ -22,12 +22,7 @@ ** ****************************************************************************/ -#define _BSD_SOURCE 1 -#define _DEFAULT_SOURCE 1 -#ifndef __STDC_LIMIT_MACROS -# define __STDC_LIMIT_MACROS 1 -#endif -#define __STDC_WANT_IEC_60559_TYPES_EXT__ +#include "cborinternalmacros_p.h" #include "cbor.h" #include "cborinternal_p.h"