Home | History | Annotate | Line # | Download | only in compat
      1  1.5  christos /*	$NetBSD: windows-config.h,v 1.6 2024/08/18 20:47:26 christos Exp $	*/
      2  1.1    kardel 
      3  1.1    kardel 
      4  1.2  christos /**
      5  1.2  christos  * \file windows-config.h
      6  1.2  christos  *
      7  1.2  christos  *  This file contains all of the routines that must be linked into
      8  1.2  christos  *  an executable to use the generated option processing.  The optional
      9  1.2  christos  *  routines are in separately compiled modules so that they will not
     10  1.2  christos  *  necessarily be linked in.
     11  1.2  christos  *
     12  1.2  christos  *  This file is part of AutoOpts, a companion to AutoGen.
     13  1.2  christos  *  AutoOpts is free software.
     14  1.6  christos  *  AutoOpts is Copyright (C) 1992-2018 by Bruce Korb - all rights reserved
     15  1.1    kardel  *
     16  1.2  christos  *  AutoOpts is available under any one of two licenses.  The license
     17  1.2  christos  *  in use must be one of these two and the choice is under the control
     18  1.2  christos  *  of the user of the license.
     19  1.1    kardel  *
     20  1.2  christos  *   The GNU Lesser General Public License, version 3 or later
     21  1.2  christos  *      See the files "COPYING.lgplv3" and "COPYING.gplv3"
     22  1.1    kardel  *
     23  1.2  christos  *   The Modified Berkeley Software Distribution License
     24  1.2  christos  *      See the file "COPYING.mbsd"
     25  1.1    kardel  *
     26  1.2  christos  *  These files have the following sha256 sums:
     27  1.1    kardel  *
     28  1.2  christos  *  8584710e9b04216a394078dc156b781d0b47e1729104d666658aecef8ee32e95  COPYING.gplv3
     29  1.2  christos  *  4379e7444a0e2ce2b12dd6f5a52a27a4d02d39d247901d3285c88cf0d37f477b  COPYING.lgplv3
     30  1.2  christos  *  13aa749a5b0a454917a944ed8fffc530b784f5ead522b1aacaf4ec8aa55a6239  COPYING.mbsd
     31  1.1    kardel  */
     32  1.2  christos 
     33  1.1    kardel #ifndef WINDOWS_CONFIG_HACKERY
     34  1.1    kardel #define WINDOWS_CONFIG_HACKERY 1
     35  1.1    kardel 
     36  1.1    kardel /*
     37  1.1    kardel  * The definitions below have been stolen from NTP's config.h for Windows.
     38  1.1    kardel  * However, they may be kept here in order to keep libopts independent from
     39  1.1    kardel  * the NTP project.
     40  1.1    kardel  */
     41  1.1    kardel #ifndef __windows__
     42  1.1    kardel #  define __windows__ 4
     43  1.1    kardel #endif
     44  1.1    kardel 
     45  1.1    kardel /*
     46  1.2  christos  * Miscellaneous functions that Microsoft maps to other names
     47  1.1    kardel  */
     48  1.1    kardel #define snprintf _snprintf
     49  1.1    kardel 
     50  1.1    kardel #define SIZEOF_INT   4
     51  1.1    kardel #define SIZEOF_CHARP 4
     52  1.1    kardel #define SIZEOF_LONG  4
     53  1.1    kardel #define SIZEOF_SHORT 2
     54  1.1    kardel 
     55  1.1    kardel #define HAVE_LIMITS_H   1
     56  1.1    kardel #define HAVE_STRDUP     1
     57  1.1    kardel #define HAVE_STRCHR     1
     58  1.1    kardel #define HAVE_FCNTL_H    1
     59  1.1    kardel 
     60  1.1    kardel /*
     61  1.2  christos  * VS.NET's version of wspiapi.h has a bug in it where it assigns a value
     62  1.2  christos  * to a variable inside an if statement. It should be comparing them.
     63  1.2  christos  * We prevent inclusion since we are not using this code so we don't have
     64  1.2  christos  * to see the warning messages
     65  1.1    kardel  */
     66  1.1    kardel #ifndef _WSPIAPI_H_
     67  1.1    kardel #define _WSPIAPI_H_
     68  1.1    kardel #endif
     69  1.1    kardel 
     70  1.1    kardel /* Prevent inclusion of winsock.h in windows.h */
     71  1.1    kardel #ifndef _WINSOCKAPI_
     72  1.1    kardel #define _WINSOCKAPI_
     73  1.1    kardel #endif
     74  1.1    kardel 
     75  1.1    kardel #ifndef __RPCASYNC_H__
     76  1.1    kardel #define __RPCASYNC_H__
     77  1.1    kardel #endif
     78  1.1    kardel 
     79  1.1    kardel /* Include Windows headers */
     80  1.1    kardel #include <windows.h>
     81  1.1    kardel #include <winsock2.h>
     82  1.1    kardel #include <limits.h>
     83  1.1    kardel 
     84  1.1    kardel /*
     85  1.1    kardel  * Compatibility declarations for Windows, assuming SYS_WINNT
     86  1.1    kardel  * has been defined.
     87  1.1    kardel  */
     88  1.1    kardel #define strdup  _strdup
     89  1.1    kardel #define stat    _stat       /* struct stat from <sys/stat.h> */
     90  1.1    kardel #define unlink  _unlink
     91  1.2  christos #define fchmod( _x, _y )
     92  1.1    kardel #define ssize_t SSIZE_T
     93  1.1    kardel 
     94  1.1    kardel #include <io.h>
     95  1.1    kardel #define open    _open
     96  1.1    kardel #define close   _close
     97  1.1    kardel #define read    _read
     98  1.1    kardel #define write   _write
     99  1.1    kardel #define lseek   _lseek
    100  1.1    kardel #define pipe    _pipe
    101  1.1    kardel #define dup2    _dup2
    102  1.1    kardel 
    103  1.1    kardel #define O_RDWR     _O_RDWR
    104  1.1    kardel #define O_RDONLY   _O_RDONLY
    105  1.1    kardel #define O_EXCL     _O_EXCL
    106  1.1    kardel 
    107  1.1    kardel #ifndef S_ISREG
    108  1.1    kardel #  define S_IFREG _S_IFREG
    109  1.1    kardel #  define       S_ISREG(mode)   (((mode) & S_IFREG) == S_IFREG)
    110  1.1    kardel #endif
    111  1.1    kardel 
    112  1.1    kardel #ifndef S_ISDIR
    113  1.1    kardel #  define S_IFDIR _S_IFDIR
    114  1.1    kardel #  define       S_ISDIR(mode)   (((mode) & S_IFDIR) == S_IFDIR)
    115  1.1    kardel #endif
    116  1.1    kardel 
    117  1.2  christos /* C99 exact size integer support. */
    118  1.2  christos #if defined(HAVE_INTTYPES_H)
    119  1.2  christos # include <inttypes.h>
    120  1.2  christos 
    121  1.2  christos #elif defined(HAVE_STDINT_H)
    122  1.2  christos # include <stdint.h>
    123  1.2  christos # define MISSING_INTTYPES_H 1
    124  1.2  christos 
    125  1.2  christos #elif ! defined(ADDED_EXACT_SIZE_INTEGERS)
    126  1.2  christos # define ADDED_EXACT_SIZE_INTEGERS 1
    127  1.2  christos # define MISSING_INTTYPES_H 1
    128  1.2  christos 
    129  1.2  christos   typedef __int8 int8_t;
    130  1.2  christos   typedef unsigned __int8 uint8_t;
    131  1.2  christos 
    132  1.2  christos   typedef __int16 int16_t;
    133  1.2  christos   typedef unsigned __int16 uint16_t;
    134  1.2  christos 
    135  1.2  christos   typedef __int32 int32_t;
    136  1.2  christos   typedef unsigned __int32 uint32_t;
    137  1.2  christos 
    138  1.2  christos   typedef __int64 int64_t;
    139  1.2  christos   typedef unsigned __int64 uint64_t;
    140  1.2  christos 
    141  1.2  christos   typedef unsigned long uintptr_t;
    142  1.2  christos   typedef long intptr_t;
    143  1.2  christos #endif
    144  1.2  christos 
    145  1.1    kardel #endif /* WINDOWS_CONFIG_HACKERY */
    146  1.2  christos /* windows-config.h ends here */
    147