view anagram/support/port.h @ 21:1c9dac05d040

Add lint-style FALLTHROUGH annotations to fallthrough cases. (in the parse engine and thus the output code) Document this, because the old output causes warnings with gcc10.
author David A. Holland
date Mon, 13 Jun 2022 00:04:38 -0400
parents 13d2b8934445
children
line wrap: on
line source

/*
 * AnaGram, A System for Syntax Directed Programming
 * Copyright 1993-2002 Parsifal Software. All Rights Reserved.
 * Copyright 2006 David A. Holland. All rights reserved.
 * See the file COPYING for license and usage terms.
 *
 * port.h - portability file
 */

#ifndef PORT_H
#define PORT_H

/*
 * OS issues
 * (note that a bunch of file-related issues are handled in file.h)
 */

#ifdef AG_ON_UNIX
#define stricmp strcasecmp
#define strnicmp strncasecmp
#define _MAX_PATH PATH_MAX

char *strlwr(char *string);
#endif

#ifdef AG_ON_WINDOWS
#define PATH_MAX _MAX_PATH
#endif

/*
 * Compiler issues
 */

#ifdef __GNUC__
#define PRINTFFY(a,b) __attribute__((__format__(__printf__, a, b)))
#else
#define PRINTFFY(a,b)
#endif

#ifdef __IBMCPP__
/* obsolete compiler, no snprintf */
int snprintf(char *, unsigned, const char *, ...) PRINTFFY(3,4);
#endif

/* this is some kind of function pointer weirdness, maybe dll-related */
#ifdef __IBMCPP__
#define OPTLINK _Optlink
#else
#define OPTLINK
#endif

/*
 * Nothing currently supported has a useful way to check for stack
 * overflow.
 */

//#define check_stack if (stackavail() < 0x100) bad_stack();
#define check_stack

/*
 * these are used by dict.cpp, stk.cpp, and tsd.cpp and it's not at all
 * clear why they're here, or where they should go. (XXX)
 */

#define MAX_BYTES 10000000U
#define MAX_INTS  10000000U

#endif /* PORT_H */