Mercurial > hg > orthanc-postgresql
changeset 142:b93b4039cee8
auto-detection of accept() arguments
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Aug 2017 17:58:09 +0200 (2017-08-23) |
parents | 60d920613610 |
children | a71432534b58 |
files | Resources/CMake/PostgreSQLConfiguration.cmake Resources/Platforms/func_accept_args.cmake |
diffstat | 2 files changed, 62 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/Resources/CMake/PostgreSQLConfiguration.cmake Wed Aug 23 19:46:31 2017 +0200 +++ b/Resources/CMake/PostgreSQLConfiguration.cmake Wed Aug 23 17:58:09 2017 +0200 @@ -131,6 +131,9 @@ ) set(CMAKE_EXTRA_INCLUDE_FILES "sys/socket.h;netdb.h;sys/types.h") + + include(${CMAKE_SOURCE_DIR}/Resources/Platforms/func_accept_args.cmake) + set(ACCEPT_TYPE_ARG3 ${ACCEPT_TYPE_ARG3}) check_type_size("long int" SIZE_LONG_INT) if (SIZE_LONG_INT EQUAL 8) @@ -182,7 +185,6 @@ set(HAVE_STRUCT_SOCKADDR_STORAGE_SS_FAMILY 1) # TODO set(HAVE_STRUCT_SOCKADDR_STORAGE___SS_LEN 1) # TODO - set(ACCEPT_TYPE_ARG3 socklen_t) # TODO # Compute maximum alignment of any basic type. # We assume long's alignment is at least as strong as char, short, or int;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Resources/Platforms/func_accept_args.cmake Wed Aug 23 17:58:09 2017 +0200 @@ -0,0 +1,59 @@ +# This mimics ac_func_accept_argtypes.m4 + +check_include_files(sys/types.h HAVE_SYS_TYPES_H) +check_include_files(sys/socket.h HAVE_SYS_SOCKET_H) + +if(HAVE_SYS_TYPES_H) + set(INCLUDE_SYS_TYPES_H "#include <sys/types.h>") +endif(HAVE_SYS_TYPES_H) + +if(HAVE_SYS_SOCKET_H) + set(INCLUDE_SYS_SOCKET_H "#include <sys/socket.h>") +endif(HAVE_SYS_SOCKET_H) + +message(STATUS "Looking for accept function args") +set(CMAKE_REQUIRED_QUIET 1) +foreach(ac_cv_func_accept_return "int" "unsigned int PASCAL" "SOCKET WSAAPI") + foreach(ac_cv_func_accept_arg1 "int" "unsigned int" "SOCKET") + foreach(ac_cv_func_accept_arg2 "struct sockaddr *" "const struct sockaddr *" "void *") + foreach(ac_cv_func_accept_arg3 "int" "size_t" "socklen_t" "unsigned int" "void") + unset(AC_FUNC_ACCEPT CACHE) + CHECK_C_SOURCE_COMPILES(" +${INCLUDE_SYS_TYPES_H} +${INCLUDE_SYS_SOCKET_H} +extern ${ac_cv_func_accept_return} accept (${ac_cv_func_accept_arg1}, ${ac_cv_func_accept_arg2}, ${ac_cv_func_accept_arg3} *); +int main(void) +{ + return 0; +} + " AC_FUNC_ACCEPT) + if(AC_FUNC_ACCEPT) + set(ACCEPT_TYPE_RETURN ${ac_cv_func_accept_return}) + set(ACCEPT_TYPE_ARG1 ${ac_cv_func_accept_arg1}) + set(ACCEPT_TYPE_ARG2 ${ac_cv_func_accept_arg2}) + set(ACCEPT_TYPE_ARG3 ${ac_cv_func_accept_arg3}) + break() + endif(AC_FUNC_ACCEPT) + endforeach(ac_cv_func_accept_arg3) + if(AC_FUNC_ACCEPT) + break() + endif(AC_FUNC_ACCEPT) + endforeach(ac_cv_func_accept_arg2) + if(AC_FUNC_ACCEPT) + break() + endif(AC_FUNC_ACCEPT) + endforeach(ac_cv_func_accept_arg1) + if(AC_FUNC_ACCEPT) + break() + endif(AC_FUNC_ACCEPT) +endforeach(ac_cv_func_accept_return) +unset(CMAKE_REQUIRED_QUIET) + +if(NOT AC_FUNC_ACCEPT) + message(ERROR "could not determine argument types") +endif(NOT AC_FUNC_ACCEPT) +if(ac_cv_func_accept_arg3 EQUAL "void") + set(ac_cv_func_accept_arg3 "int") +endif(ac_cv_func_accept_arg3 EQUAL "void") + +message(STATUS "Looking for accept function args - found ${ACCEPT_TYPE_RETURN}, ${ACCEPT_TYPE_ARG1}, ${ACCEPT_TYPE_ARG2}, ${ACCEPT_TYPE_ARG3} *")