mirror of
https://github.com/curl/curl.git
synced 2026-08-25 13:53:37 +03:00
functypes: provide the recv and send arg and return types
This header is for providing the argument types for recv() and send() when built to not use a dedicated config-[platfor].h file. Remove the slow brute-force checks from configure and cmake. This change also removes the use of the types for select, as they were not used in code. Closes #9592
This commit is contained in:
parent
eb0167ff7d
commit
eb33ccd533
12 changed files with 130 additions and 630 deletions
|
|
@ -271,6 +271,7 @@ LIB_HFILES = \
|
|||
fileinfo.h \
|
||||
fopen.h \
|
||||
formdata.h \
|
||||
functypes.h \
|
||||
ftp.h \
|
||||
ftplistparser.h \
|
||||
getinfo.h \
|
||||
|
|
|
|||
|
|
@ -86,11 +86,6 @@
|
|||
#define PACKAGE_TARNAME "curl"
|
||||
#define PACKAGE_VERSION "-"
|
||||
#define CURL_CA_BUNDLE "s:curl-ca-bundle.crt"
|
||||
|
||||
#define SELECT_TYPE_ARG1 int
|
||||
#define SELECT_TYPE_ARG234 (fd_set *)
|
||||
#define SELECT_TYPE_ARG5 (struct timeval *)
|
||||
|
||||
#define STDC_HEADERS 1
|
||||
#define TIME_WITH_SYS_TIME 1
|
||||
|
||||
|
|
|
|||
|
|
@ -63,10 +63,6 @@
|
|||
#define RECV_TYPE_RETV int
|
||||
|
||||
#define HAVE_SELECT 1
|
||||
#define SELECT_TYPE_ARG1 int
|
||||
#define SELECT_TYPE_ARG234 fd_set *
|
||||
#define SELECT_TYPE_ARG5 struct timeval *
|
||||
#define SELECT_TYPE_RETV int
|
||||
|
||||
#define HAVE_SEND 1
|
||||
#define SEND_TYPE_ARG1 int
|
||||
|
|
|
|||
|
|
@ -640,54 +640,6 @@
|
|||
/* a suitable file to read random data from */
|
||||
#cmakedefine RANDOM_FILE "${RANDOM_FILE}"
|
||||
|
||||
/* Define to the type of arg 1 for recv. */
|
||||
#cmakedefine RECV_TYPE_ARG1 ${RECV_TYPE_ARG1}
|
||||
|
||||
/* Define to the type of arg 2 for recv. */
|
||||
#cmakedefine RECV_TYPE_ARG2 ${RECV_TYPE_ARG2}
|
||||
|
||||
/* Define to the type of arg 3 for recv. */
|
||||
#cmakedefine RECV_TYPE_ARG3 ${RECV_TYPE_ARG3}
|
||||
|
||||
/* Define to the type of arg 4 for recv. */
|
||||
#cmakedefine RECV_TYPE_ARG4 ${RECV_TYPE_ARG4}
|
||||
|
||||
/* Define to the function return type for recv. */
|
||||
#cmakedefine RECV_TYPE_RETV ${RECV_TYPE_RETV}
|
||||
|
||||
/* Define to the type qualifier of arg 5 for select. */
|
||||
#cmakedefine SELECT_QUAL_ARG5 ${SELECT_QUAL_ARG5}
|
||||
|
||||
/* Define to the type of arg 1 for select. */
|
||||
#cmakedefine SELECT_TYPE_ARG1 ${SELECT_TYPE_ARG1}
|
||||
|
||||
/* Define to the type of args 2, 3 and 4 for select. */
|
||||
#cmakedefine SELECT_TYPE_ARG234 ${SELECT_TYPE_ARG234}
|
||||
|
||||
/* Define to the type of arg 5 for select. */
|
||||
#cmakedefine SELECT_TYPE_ARG5 ${SELECT_TYPE_ARG5}
|
||||
|
||||
/* Define to the function return type for select. */
|
||||
#cmakedefine SELECT_TYPE_RETV ${SELECT_TYPE_RETV}
|
||||
|
||||
/* Define to the type qualifier of arg 2 for send. */
|
||||
#cmakedefine SEND_QUAL_ARG2 ${SEND_QUAL_ARG2}
|
||||
|
||||
/* Define to the type of arg 1 for send. */
|
||||
#cmakedefine SEND_TYPE_ARG1 ${SEND_TYPE_ARG1}
|
||||
|
||||
/* Define to the type of arg 2 for send. */
|
||||
#cmakedefine SEND_TYPE_ARG2 ${SEND_TYPE_ARG2}
|
||||
|
||||
/* Define to the type of arg 3 for send. */
|
||||
#cmakedefine SEND_TYPE_ARG3 ${SEND_TYPE_ARG3}
|
||||
|
||||
/* Define to the type of arg 4 for send. */
|
||||
#cmakedefine SEND_TYPE_ARG4 ${SEND_TYPE_ARG4}
|
||||
|
||||
/* Define to the function return type for send. */
|
||||
#cmakedefine SEND_TYPE_RETV ${SEND_TYPE_RETV}
|
||||
|
||||
/*
|
||||
Note: SIZEOF_* variables are fetched with CMake through check_type_size().
|
||||
As per CMake documentation on CheckTypeSize, C preprocessor code is
|
||||
|
|
|
|||
|
|
@ -87,6 +87,8 @@
|
|||
#include <sys/socket.h>
|
||||
#endif
|
||||
|
||||
#include "functypes.h"
|
||||
|
||||
#ifdef __hpux
|
||||
# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
|
||||
# ifdef OLD_APP32_64BIT_OFF_T
|
||||
|
|
@ -149,20 +151,10 @@ struct timeval {
|
|||
* SEND_TYPE_RETV must also be defined.
|
||||
*/
|
||||
|
||||
#if !defined(RECV_TYPE_ARG1) || \
|
||||
!defined(RECV_TYPE_ARG2) || \
|
||||
!defined(RECV_TYPE_ARG3) || \
|
||||
!defined(RECV_TYPE_ARG4) || \
|
||||
!defined(RECV_TYPE_RETV)
|
||||
/* */
|
||||
Error Missing_definition_of_return_and_arguments_types_of_recv
|
||||
/* */
|
||||
#else
|
||||
#define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
|
||||
(RECV_TYPE_ARG2)(y), \
|
||||
(RECV_TYPE_ARG3)(z), \
|
||||
(RECV_TYPE_ARG4)(0))
|
||||
#endif
|
||||
#else /* HAVE_RECV */
|
||||
#ifndef sread
|
||||
/* */
|
||||
|
|
@ -179,21 +171,10 @@ struct timeval {
|
|||
(SEND_TYPE_ARG3)(z))
|
||||
|
||||
#elif defined(HAVE_SEND)
|
||||
#if !defined(SEND_TYPE_ARG1) || \
|
||||
!defined(SEND_QUAL_ARG2) || \
|
||||
!defined(SEND_TYPE_ARG2) || \
|
||||
!defined(SEND_TYPE_ARG3) || \
|
||||
!defined(SEND_TYPE_ARG4) || \
|
||||
!defined(SEND_TYPE_RETV)
|
||||
/* */
|
||||
Error Missing_definition_of_return_and_arguments_types_of_send
|
||||
/* */
|
||||
#else
|
||||
#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
|
||||
(SEND_QUAL_ARG2 SEND_TYPE_ARG2)(y), \
|
||||
(SEND_TYPE_ARG3)(z), \
|
||||
(SEND_TYPE_ARG4)(SEND_4TH_ARG))
|
||||
#endif
|
||||
#else /* HAVE_SEND */
|
||||
#ifndef swrite
|
||||
/* */
|
||||
|
|
|
|||
115
lib/functypes.h
Normal file
115
lib/functypes.h
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
#ifndef HEADER_CURL_FUNCTYPES_H
|
||||
#define HEADER_CURL_FUNCTYPES_H
|
||||
/***************************************************************************
|
||||
* _ _ ____ _
|
||||
* Project ___| | | | _ \| |
|
||||
* / __| | | | |_) | |
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2022, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
* are also available at https://curl.se/docs/copyright.html.
|
||||
*
|
||||
* You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||
* copies of the Software, and permit persons to whom the Software is
|
||||
* furnished to do so, under the terms of the COPYING file.
|
||||
*
|
||||
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||
* KIND, either express or implied.
|
||||
*
|
||||
* SPDX-License-Identifier: curl
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
#include "curl_setup.h"
|
||||
|
||||
/* defaults:
|
||||
|
||||
ssize_t recv(int, void *, size_t, int);
|
||||
ssize_t send(int, const void *, size_t, int);
|
||||
|
||||
If other argument or return types are needed:
|
||||
|
||||
1. For systems that run configure or cmake, the alternatives are provided
|
||||
here.
|
||||
2. For systems with config-*.h files, define them there.
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
/* int recv(SOCKET, char *, int, int) */
|
||||
#define RECV_TYPE_ARG1 SOCKET
|
||||
#define RECV_TYPE_ARG2 char *
|
||||
#define RECV_TYPE_ARG3 int
|
||||
#define RECV_TYPE_RETV int
|
||||
|
||||
/* int send(SOCKET, const char *, int, int); */
|
||||
#define SEND_TYPE_ARG1 SOCKET
|
||||
#define SEND_TYPE_ARG2 char *
|
||||
#define SEND_TYPE_ARG3 int
|
||||
#define SEND_TYPE_RETV int
|
||||
|
||||
#elif defined(__AMIGA__) /* Any AmigaOS flavour */
|
||||
|
||||
/* long recv(long, char *, long, long); */
|
||||
#define RECV_TYPE_ARG1 long
|
||||
#define RECV_TYPE_ARG2 char *
|
||||
#define RECV_TYPE_ARG3 long
|
||||
#define RECV_TYPE_ARG4 long
|
||||
#define RECV_TYPE_RETV long
|
||||
|
||||
/* int send(int, const char *, int, int); */
|
||||
#define SEND_TYPE_ARG1 int
|
||||
#define SEND_TYPE_ARG2 char *
|
||||
#define SEND_TYPE_ARG3 int
|
||||
#define SEND_TYPE_RETV int
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef RECV_TYPE_ARG1
|
||||
#define RECV_TYPE_ARG1 int
|
||||
#endif
|
||||
|
||||
#ifndef RECV_TYPE_ARG2
|
||||
#define RECV_TYPE_ARG2 void *
|
||||
#endif
|
||||
|
||||
#ifndef RECV_TYPE_ARG3
|
||||
#define RECV_TYPE_ARG3 size_t
|
||||
#endif
|
||||
|
||||
#ifndef RECV_TYPE_ARG4
|
||||
#define RECV_TYPE_ARG4 int
|
||||
#endif
|
||||
|
||||
#ifndef RECV_TYPE_RETV
|
||||
#define RECV_TYPE_RETV ssize_t
|
||||
#endif
|
||||
|
||||
#ifndef SEND_QUAL_ARG2
|
||||
#define SEND_QUAL_ARG2 const
|
||||
#endif
|
||||
|
||||
#ifndef SEND_TYPE_ARG1
|
||||
#define SEND_TYPE_ARG1 int
|
||||
#endif
|
||||
|
||||
#ifndef SEND_TYPE_ARG2
|
||||
#define SEND_TYPE_ARG2 void *
|
||||
#endif
|
||||
|
||||
#ifndef SEND_TYPE_ARG3
|
||||
#define SEND_TYPE_ARG3 size_t
|
||||
#endif
|
||||
|
||||
#ifndef SEND_TYPE_ARG4
|
||||
#define SEND_TYPE_ARG4 int
|
||||
#endif
|
||||
|
||||
#ifndef SEND_TYPE_RETV
|
||||
#define SEND_TYPE_RETV ssize_t
|
||||
#endif
|
||||
|
||||
#endif /* HEADER_CURL_FUNCTYPES_H */
|
||||
|
|
@ -31,6 +31,7 @@
|
|||
*/
|
||||
|
||||
#include <curl/curl.h>
|
||||
#include "functypes.h"
|
||||
|
||||
#if defined(__GNUC__) && __GNUC__ >= 3
|
||||
# define ALLOC_FUNC __attribute__((malloc))
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@
|
|||
|
||||
#include <gsasl.h>
|
||||
|
||||
/* The last #include files should be: */
|
||||
/* The last 3 #include files should be in this order */
|
||||
#include "curl_printf.h"
|
||||
#include "curl_memory.h"
|
||||
#include "memdebug.h"
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue