nuttx-update/include/arpa/inet.h
Gregory Nutt 67ec3d7926 Remove CONFIG_CAN_PASS_STRUCT
This commit resolves issue #620:

Remove CONFIG_CAN_PASS_STRUCTS #620

The configuration option CONFIG_CAN_PASS_STRUCTS was added many years ago to support an old version of the SDCC compiler. That compiler is currently used only with the Z80 and Z180 targets. The limitation of that old compiler was that it could not pass structures or unions as either inputs or outputs. For example:

    #ifdef CONFIG_CAN_PASS_STRUCTS
    struct mallinfo mallinfo(void);
    #else
    int      mallinfo(FAR struct mallinfo *info);
    #endif

And even leads to violation of a few POSIX interfaces like:

    #ifdef CONFIG_CAN_PASS_STRUCTS
    int  sigqueue(int pid, int signo, union sigval value);
    #else
    int  sigqueue(int pid, int signo, FAR void *sival_ptr);
    #endif

This breaks the 1st INVIOLABLES rule:

Strict POSIX compliance
-----------------------

  o Strict conformance to the portable standard OS interface as defined at
    OpenGroup.org.
  o A deeply embedded system requires some special support.  Special
    support must be minimized.
  o The portable interface must never be compromised only for the sake of
    expediency.
  o Expediency or even improved performance are not justifications for
   violation of the strict POSIX interface

Also, it appears that the current SDCC compilers have resolve this issue and so, perhaps, this is no longer a problem: z88dk/z88dk#1132

NOTE:  This commit cannot pass the PR checks because it depends on matching changes to the apps/ directory.
2020-04-11 21:19:47 +01:00

114 lines
3.6 KiB
C

/****************************************************************************
* include/arpa/inet.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_ARPA_INET_H
#define __INCLUDE_ARPA_INET_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <netinet/in.h>
/****************************************************************************
* Public Type Definitions
****************************************************************************/
/* This macro to convert a 16/32-bit constant values quantity from host byte
* order to network byte order. The 16-bit version of this macro is required
* for uIP:
*
* Author Adam Dunkels <adam@dunkels.com>
* Copyright (c) 2001-2003, Adam Dunkels.
* All rights reserved.
*/
#ifdef CONFIG_ENDIAN_BIG
# define HTONS(ns) (ns)
# define HTONL(nl) (nl)
#else
# define HTONS(ns) \
(unsigned short) \
(((((unsigned short)(ns)) & 0x00ff) << 8) | \
((((unsigned short)(ns)) >> 8) & 0x00ff))
# define HTONL(nl) \
(unsigned long) \
(((((unsigned long)(nl)) & 0x000000ffUL) << 24) | \
((((unsigned long)(nl)) & 0x0000ff00UL) << 8) | \
((((unsigned long)(nl)) & 0x00ff0000UL) >> 8) | \
((((unsigned long)(nl)) & 0xff000000UL) >> 24))
#endif
#define NTOHS(hs) HTONS(hs)
#define NTOHL(hl) HTONL(hl)
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/* Functions to convert between host and network byte ordering.
*
* REVISIT: Since network order is defined as big-endian, the following
* functions are equivalent to functions declared in endian.h:
*
* htonl htobe32
* htons htobe16
* ntohl be32toh
* ntohs be16toh
*/
uint32_t ntohl(uint32_t nl);
uint16_t ntohs(uint16_t ns);
uint32_t htonl(uint32_t hl);
uint16_t htons(uint16_t hs);
/* Functions to manipulate address representations */
int inet_aton(FAR const char *cp, FAR struct in_addr *inp);
in_addr_t inet_addr(FAR const char *cp);
in_addr_t inet_network(FAR const char *cp);
FAR char *inet_ntoa(struct in_addr in);
in_addr_t inet_lnaof(struct in_addr in);
in_addr_t inet_netof(struct in_addr in);
struct in_addr inet_makeaddr(in_addr_t net, in_addr_t host);
int inet_pton(int af, FAR const char *src, FAR void *dst);
const char *inet_ntop(int af, FAR const void *src, FAR char *dst, socklen_t size);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_ARPA_INET_H */