xref: /freebsd/contrib/ncurses/include/nc_mingw.h (revision 21817992b3314c908ab50f0bb88d2ee750b9c4ac)
106bfebdeSXin LI /****************************************************************************
2*21817992SBaptiste Daroussin  * Copyright 2018-2020,2023 Thomas E. Dickey                                *
3e1865124SBaptiste Daroussin  * Copyright 2008-2010,2017 Free Software Foundation, Inc.                  *
406bfebdeSXin LI  *                                                                          *
506bfebdeSXin LI  * Permission is hereby granted, free of charge, to any person obtaining a  *
606bfebdeSXin LI  * copy of this software and associated documentation files (the            *
706bfebdeSXin LI  * "Software"), to deal in the Software without restriction, including      *
806bfebdeSXin LI  * without limitation the rights to use, copy, modify, merge, publish,      *
906bfebdeSXin LI  * distribute, distribute with modifications, sublicense, and/or sell       *
1006bfebdeSXin LI  * copies of the Software, and to permit persons to whom the Software is    *
1106bfebdeSXin LI  * furnished to do so, subject to the following conditions:                 *
1206bfebdeSXin LI  *                                                                          *
1306bfebdeSXin LI  * The above copyright notice and this permission notice shall be included  *
1406bfebdeSXin LI  * in all copies or substantial portions of the Software.                   *
1506bfebdeSXin LI  *                                                                          *
1606bfebdeSXin LI  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
1706bfebdeSXin LI  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
1806bfebdeSXin LI  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
1906bfebdeSXin LI  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
2006bfebdeSXin LI  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
2106bfebdeSXin LI  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
2206bfebdeSXin LI  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
2306bfebdeSXin LI  *                                                                          *
2406bfebdeSXin LI  * Except as contained in this notice, the name(s) of the above copyright   *
2506bfebdeSXin LI  * holders shall not be used in advertising or otherwise to promote the     *
2606bfebdeSXin LI  * sale, use or other dealings in this Software without prior written       *
2706bfebdeSXin LI  * authorization.                                                           *
2806bfebdeSXin LI  ****************************************************************************/
2906bfebdeSXin LI 
3006bfebdeSXin LI /****************************************************************************
3106bfebdeSXin LI  * Author: Thomas Dickey, 2008-on                                           *
3206bfebdeSXin LI  ****************************************************************************/
3306bfebdeSXin LI 
34*21817992SBaptiste Daroussin /* $Id: nc_mingw.h,v 1.10 2023/02/25 19:59:24 tom Exp $ */
3506bfebdeSXin LI 
3606bfebdeSXin LI #ifndef NC_MINGW_H
3706bfebdeSXin LI #define NC_MINGW_H 1
3806bfebdeSXin LI 
39aae38d10SBaptiste Daroussin #ifdef _WIN32
407a656419SBaptiste Daroussin 
4106bfebdeSXin LI #ifdef WINVER
4206bfebdeSXin LI #  if WINVER < 0x0501
4306bfebdeSXin LI #    error WINVER must at least be 0x0501
4406bfebdeSXin LI #  endif
4506bfebdeSXin LI #else
4606bfebdeSXin LI #  define WINVER 0x0501
4706bfebdeSXin LI #endif
4806bfebdeSXin LI #include <windows.h>
4906bfebdeSXin LI 
5006bfebdeSXin LI #undef sleep
5106bfebdeSXin LI #define sleep(n) Sleep((n) * 1000)
5206bfebdeSXin LI 
537a656419SBaptiste Daroussin #if HAVE_SYS_TIME_H
5406bfebdeSXin LI #include <sys/time.h>		/* for struct timeval */
557a656419SBaptiste Daroussin #endif
5606bfebdeSXin LI 
577a656419SBaptiste Daroussin #ifdef _MSC_VER
587a656419SBaptiste Daroussin #include <winsock2.h>		/* for struct timeval */
597a656419SBaptiste Daroussin #endif
607a656419SBaptiste Daroussin 
617a656419SBaptiste Daroussin #ifdef __cplusplus
627a656419SBaptiste Daroussin extern "C" {
637a656419SBaptiste Daroussin #endif
647a656419SBaptiste Daroussin 
657a656419SBaptiste Daroussin #include <ncurses_dll.h>
667a656419SBaptiste Daroussin 
67*21817992SBaptiste Daroussin #if !HAVE_CLOCK_GETTIME && !HAVE_GETTIMEOFDAY
687a656419SBaptiste Daroussin NCURSES_EXPORT(int) _nc_gettimeofday(struct timeval *, void *);
6906bfebdeSXin LI #undef HAVE_GETTIMEOFDAY
70*21817992SBaptiste Daroussin #define HAVE_GETTIMEOFDAY 2
71*21817992SBaptiste Daroussin #define gettimeofday(tv,tz) _nc_gettimeofday(tv,tz)
72*21817992SBaptiste Daroussin #endif
7306bfebdeSXin LI 
7406bfebdeSXin LI #define SIGHUP  1
7506bfebdeSXin LI #define SIGKILL 9
7606bfebdeSXin LI #define getlogin() "username"
7706bfebdeSXin LI 
7806bfebdeSXin LI #undef wcwidth
79aae38d10SBaptiste Daroussin #define wcwidth(ucs) _nc_wcwidth((wchar_t)(ucs))
807a656419SBaptiste Daroussin NCURSES_EXPORT(int) _nc_wcwidth(wchar_t);
817a656419SBaptiste Daroussin 
827a656419SBaptiste Daroussin #ifdef __cplusplus
837a656419SBaptiste Daroussin }
847a656419SBaptiste Daroussin #endif
8506bfebdeSXin LI 
86aae38d10SBaptiste Daroussin #endif /* _WIN32 */
87aae38d10SBaptiste Daroussin 
8806bfebdeSXin LI #endif /* NC_MINGW_H */
89