Skip to content

Commit

Permalink
Merge pull request #1484 from mayeut/mandatory-inttypes-stdint
Browse files Browse the repository at this point in the history
Require `stdint.h` & `inttypes.h`
  • Loading branch information
rouault committed Dec 8, 2023
2 parents 65282a0 + c4b3a91 commit 2c8c502
Show file tree
Hide file tree
Showing 26 changed files with 39 additions and 143 deletions.
26 changes: 12 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -184,20 +184,18 @@ endif()
# Check if some include files are provided by the system
include(EnsureFileInclude)
# These files are mandatory
ensure_file_include("string.h" HAVE_STRING_H YES)
ensure_file_include("memory.h" HAVE_MEMORY_H YES)
ensure_file_include("stdlib.h" HAVE_STDLIB_H YES)
ensure_file_include("stdio.h" HAVE_STDIO_H YES)
ensure_file_include("math.h" HAVE_MATH_H YES)
ensure_file_include("float.h" HAVE_FLOAT_H YES)
ensure_file_include("time.h" HAVE_TIME_H YES)
ensure_file_include("stdarg.h" HAVE_STDARG_H YES)
ensure_file_include("ctype.h" HAVE_CTYPE_H YES)
ensure_file_include("assert.h" HAVE_ASSERT_H YES)

# For the following files, we provide an alternative, they are not mandatory
ensure_file_include("stdint.h" OPJ_HAVE_STDINT_H NO)
ensure_file_include("inttypes.h" OPJ_HAVE_INTTYPES_H NO)
ensure_file_include("string.h" HAVE_STRING_H YES)
ensure_file_include("memory.h" HAVE_MEMORY_H YES)
ensure_file_include("stdlib.h" HAVE_STDLIB_H YES)
ensure_file_include("stdio.h" HAVE_STDIO_H YES)
ensure_file_include("math.h" HAVE_MATH_H YES)
ensure_file_include("float.h" HAVE_FLOAT_H YES)
ensure_file_include("time.h" HAVE_TIME_H YES)
ensure_file_include("stdarg.h" HAVE_STDARG_H YES)
ensure_file_include("ctype.h" HAVE_CTYPE_H YES)
ensure_file_include("assert.h" HAVE_ASSERT_H YES)
ensure_file_include("stdint.h" HAVE_STDINT_H YES)
ensure_file_include("inttypes.h" HAVE_INTTYPES_H YES)

# why check this one ? for openjpip ?
include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
Expand Down
2 changes: 1 addition & 1 deletion src/bin/jp2/converttif.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include <inttypes.h>

#ifndef OPJ_HAVE_LIBTIFF
# error OPJ_HAVE_LIBTIFF_NOT_DEFINED
Expand All @@ -51,7 +52,6 @@
#include <tiffio.h>
#include "openjpeg.h"
#include "convert.h"
#include "opj_inttypes.h"

/* -->> -->> -->> -->>
Expand Down
2 changes: 1 addition & 1 deletion src/bin/jp2/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <inttypes.h>
#include "openjpeg.h"
#include "index.h"
#include "opj_inttypes.h"

/* ------------------------------------------------------------------------------------ */

Expand Down
3 changes: 1 addition & 2 deletions src/lib/openjp2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ set(OPENJPEG_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/opj_intmath.h
${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.c
${CMAKE_CURRENT_SOURCE_DIR}/opj_malloc.h
${CMAKE_CURRENT_SOURCE_DIR}/opj_stdint.h
${CMAKE_CURRENT_SOURCE_DIR}/sparse_array.c
${CMAKE_CURRENT_SOURCE_DIR}/sparse_array.h
)
Expand Down Expand Up @@ -123,7 +122,7 @@ install(TARGETS ${INSTALL_LIBS}
)

# Install includes files
install(FILES openjpeg.h opj_stdint.h
install(FILES openjpeg.h
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/${OPENJPEG_INSTALL_SUBDIR} COMPONENT Headers
)

Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjp2/openjpeg.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ typedef float OPJ_FLOAT32;
typedef double OPJ_FLOAT64;
typedef unsigned char OPJ_BYTE;

#include "opj_stdint.h"
#include <stdint.h>

typedef int8_t OPJ_INT8;
typedef uint8_t OPJ_UINT8;
Expand Down
1 change: 0 additions & 1 deletion src/lib/openjp2/opj_config.h.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* create opj_config.h for CMake */
#cmakedefine OPJ_HAVE_STDINT_H @OPJ_HAVE_STDINT_H@

/*--------------------------------------------------------------------------*/
/* OpenJPEG Versioning */
Expand Down
3 changes: 2 additions & 1 deletion src/lib/openjp2/opj_config_private.h.cmake.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* create opj_config_private.h for CMake */
#cmakedefine OPJ_HAVE_INTTYPES_H @OPJ_HAVE_INTTYPES_H@

#define OPJ_PACKAGE_VERSION "@PACKAGE_VERSION@"

Expand All @@ -11,6 +10,8 @@
/*#cmakedefine HAVE_SYS_STAT_H @HAVE_SYS_STAT_H@*/
/*#cmakedefine HAVE_SYS_TYPES_H @HAVE_SYS_TYPES_H@ */
/*#cmakedefine HAVE_UNISTD_H @HAVE_UNISTD_H@*/
/*#cmakedefine HAVE_INTTYPES_H @HAVE_INTTYPES_H@ */
/*#cmakedefine HAVE_STDINT_H @HAVE_STDINT_H@ */

#cmakedefine _LARGEFILE_SOURCE
#cmakedefine _LARGE_FILES
Expand Down
3 changes: 2 additions & 1 deletion src/lib/openjp2/opj_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
#include <ctype.h>
#include <assert.h>
#include <limits.h>
#include <stdint.h>
#include <inttypes.h>

/*
Use fseeko() and ftello() if they are available since they use
Expand Down Expand Up @@ -218,7 +220,6 @@ typedef unsigned int OPJ_BITFIELD;

#define OPJ_UNUSED(x) (void)x

#include "opj_inttypes.h"
#include "opj_clock.h"
#include "opj_malloc.h"
#include "event.h"
Expand Down
48 changes: 0 additions & 48 deletions src/lib/openjp2/opj_inttypes.h

This file was deleted.

52 changes: 0 additions & 52 deletions src/lib/openjp2/opj_stdint.h

This file was deleted.

10 changes: 4 additions & 6 deletions src/lib/openjp2/t1_ht_generate_luts.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,7 @@
#include <string.h>
#include <stdio.h>
#include <assert.h>

typedef int OPJ_BOOL;
#define OPJ_TRUE 1
#define OPJ_FALSE 0

#include "opj_stdint.h"
#include <stdint.h>

typedef int8_t OPJ_INT8;
typedef uint8_t OPJ_UINT8;
Expand All @@ -53,6 +48,9 @@ typedef int32_t OPJ_INT32;
typedef uint32_t OPJ_UINT32;
typedef int64_t OPJ_INT64;
typedef uint64_t OPJ_UINT64;
typedef int OPJ_BOOL;
#define OPJ_TRUE 1
#define OPJ_FALSE 0

//************************************************************************/
/** @brief HT decoding tables, as given in the standard
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/box_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
#include <stdlib.h>
#include <ctype.h>
#include <assert.h>
#include <inttypes.h>
#include "box_manager.h"
#include "opj_inttypes.h"

#ifdef SERVER
#include "fcgi_stdio.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/boxheader_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <inttypes.h>
#include "boxheader_manager.h"
#include "opj_inttypes.h"

#ifdef SERVER
#include "fcgi_stdio.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/byte_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#define BYTE_MANAGER_H_

#include <stddef.h>
#include <stdint.h>
#include "openjpeg.h"
#include "opj_stdint.h"
typedef uint8_t Byte_t;
typedef uint16_t Byte2_t;
typedef uint32_t Byte4_t;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/cachemodel_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "cachemodel_manager.h"
#include "faixbox_manager.h"
#include "opj_inttypes.h"

#ifdef SERVER
#include "fcgi_stdio.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/codestream_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
*/

#include <stdio.h>
#include <inttypes.h>
#include "codestream_manager.h"
#include "opj_inttypes.h"

#ifdef SERVER
#include "fcgi_stdio.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/dec_clientmsg_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <inttypes.h>
#include "dec_clientmsg_handler.h"
#include "ihdrbox_manager.h"
#include "jpipstream_manager.h"
#include "jp2k_encoder.h"
#include "opj_inttypes.h"

void handle_JPIPstreamMSG(SOCKET connected_socket, cachelist_param_t *cachelist,
Byte_t **jpipstream, OPJ_SIZE_T *streamlen, msgqueue_param_t *msgqueue)
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/faixbox_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "faixbox_manager.h"
#include "opj_inttypes.h"

#ifdef SERVER
#include "fcgi_stdio.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/index_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <inttypes.h>

#include "opj_inttypes.h"
#include "index_manager.h"
#include "box_manager.h"
#include "manfbox_manager.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/jp2k_encoder.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@
#include <string.h>
#include <math.h>
#include <assert.h>
#include <inttypes.h>
#include "jp2k_encoder.h"
#include "j2kheader_manager.h"
#include "imgreg_manager.h"
#include "opj_inttypes.h"


#ifdef SERVER
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/metadata_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

#include "metadata_manager.h"
#include "opj_inttypes.h"
#include <inttypes.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/mhixbox_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "mhixbox_manager.h"
#include "opj_inttypes.h"

#ifdef SERVER
#include "fcgi_stdio.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/msgqueue_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include <ctype.h>
#include <assert.h>
#include <limits.h>
#include <inttypes.h>
#ifdef _WIN32
#include <io.h>
#else
Expand All @@ -45,7 +46,6 @@
#include "msgqueue_manager.h"
#include "metadata_manager.h"
#include "index_manager.h"
#include "opj_inttypes.h"

#ifdef SERVER
#include "fcgi_stdio.h"
Expand Down
2 changes: 1 addition & 1 deletion src/lib/openjpip/placeholder_manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <inttypes.h>
#include "placeholder_manager.h"
#include "opj_inttypes.h"

#ifdef SERVER
#include "fcgi_stdio.h"
Expand Down
Loading

0 comments on commit 2c8c502

Please sign in to comment.