"Fossies" - the Fresh Open Source Software Archive

Member "tin-2.4.4/include/missing_fd.h" (20 Nov 2019, 2992 Bytes) of package /linux/misc/tin-2.4.4.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "missing_fd.h" see the Fossies "Dox" file reference documentation.

    1 /*
    2  *  Project   : tin - a Usenet reader
    3  *  Module    : missing_fd.h
    4  *  Author    : Dennis Grevenstein <dennis.grevenstein@gmail.com>
    5  *  Created   : 2019-03-09
    6  *  Updated   : 2019-03-13
    7  *  Notes     :
    8  *
    9  * Copyright (c) 2019-2020 Dennis Grevenstein <dennis.grevenstein@gmail.com>
   10  * All rights reserved.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  *
   16  * 1. Redistributions of source code must retain the above copyright notice,
   17  *    this list of conditions and the following disclaimer.
   18  *
   19  * 2. Redistributions in binary form must reproduce the above copyright
   20  *    notice, this list of conditions and the following disclaimer in the
   21  *    documentation and/or other materials provided with the distribution.
   22  *
   23  * 3. Neither the name of the copyright holder nor the names of its
   24  *    contributors may be used to endorse or promote products derived from
   25  *    this software without specific prior written permission.
   26  *
   27  * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   28  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   29  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   30  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
   31  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   32  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   33  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   34  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   35  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   36  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
   37  * POSSIBILITY OF SUCH DAMAGE.
   38  */
   39 
   40 
   41 #ifndef TIN_MISSING_FD_H
   42 #   define TIN_MISSING_FD_H
   43 #   ifndef HAVE_TYPE_FD_SET
   44 
   45     /* for SunOS 3.5 */
   46     /* luna - 09-MAR-2019 */
   47 #   if defined(sun) || defined(__sun) /* && (!defined(__SVR4) || !defined(__svr4__)) && defined(BSD) && BSD < 199306 */
   48 typedef long    fd_mask;
   49 #       ifndef  FD_SETSIZE
   50 #           ifdef SUNDBE /* Sun DataBase Excelerator */
   51 #               define FD_SETSIZE      2048
   52 #           else
   53 #               define FD_SETSIZE      256
   54 #           endif /* SUNDBE */
   55 #       endif /* !FD_SETSIZE */
   56 #       ifndef NBBY
   57 #           define NBBY 8   /* bits per byte */
   58 #       endif /* !NBBY */
   59 #       define  NFDBITS (sizeof(fd_mask) * NBBY)    /* bits per mask */
   60 #       ifndef howmany
   61 #           define  howmany(x, y)   (((x) + ((y) - 1)) / (y))
   62 #       endif /* !howmany */
   63 
   64 typedef struct fd_set {
   65     fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
   66 } fd_set;
   67 
   68 
   69 #       define  FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
   70 #       define  FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
   71 #       define  FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
   72 #       define  FD_ZERO(p)      memset((void *)(p), 0, sizeof (*(p)))
   73 
   74 #       endif /* sun || __sun */
   75 #   endif /* !HAVE_TYPE_FD_SET */
   76 #endif /* !TIN_MISSING_FD_H */