/* port.h -- Portability interface header
|
/* port.h -- Portability interface header
|
|
|
Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
|
Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
|
Copyright (C) 2008 Embecosm Limited
|
Copyright (C) 2008 Embecosm Limited
|
|
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
|
|
|
This file is part of OpenRISC 1000 Architectural Simulator.
|
This file is part of OpenRISC 1000 Architectural Simulator.
|
|
|
This program is free software; you can redistribute it and/or modify it
|
This program is free software; you can redistribute it and/or modify it
|
under the terms of the GNU General Public License as published by the Free
|
under the terms of the GNU General Public License as published by the Free
|
Software Foundation; either version 3 of the License, or (at your option)
|
Software Foundation; either version 3 of the License, or (at your option)
|
any later version.
|
any later version.
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
more details.
|
more details.
|
|
|
You should have received a copy of the GNU General Public License along
|
You should have received a copy of the GNU General Public License along
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
with this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
|
/* This program is commented throughout in a fashion suitable for processing
|
/* This program is commented throughout in a fashion suitable for processing
|
with Doxygen. */
|
with Doxygen. */
|
|
|
|
|
#ifndef PORT__H
|
#ifndef PORT__H
|
#define PORT__H
|
#define PORT__H
|
|
|
/* System includes */
|
/* System includes */
|
#include <string.h>
|
#include <string.h>
|
#include <ctype.h>
|
#include <ctype.h>
|
|
|
#if HAVE_INTTYPES_H
|
#if HAVE_INTTYPES_H
|
#include <inttypes.h>
|
#include <inttypes.h>
|
#endif
|
#endif
|
|
|
|
|
/* Substitute strndup () if necessary */
|
/* Substitute strndup () if necessary */
|
#ifndef HAVE_STRNDUP
|
#ifndef HAVE_STRNDUP
|
char * strndup (const char *s, size_t n);
|
char * strndup (const char *s, size_t n);
|
#endif
|
#endif
|
|
|
/* Substitute isblank () if necessary */
|
/* Substitute isblank () if necessary */
|
#ifndef HAVE_ISBLANK
|
#ifndef HAVE_ISBLANK
|
int isblank(int c);
|
int isblank(int c);
|
#endif
|
#endif
|
|
|
/* Substitute all the inttypes fields that are missing */
|
/* Substitute all the inttypes fields that are missing */
|
|
|
#ifndef PRIx32
|
#ifndef PRIx32
|
# if SIZEOF_INT == 4
|
# if SIZEOF_INT == 4
|
# define PRIx32 "x"
|
# define PRIx32 "x"
|
# elif SIZEOF_LONG == 4
|
# elif SIZEOF_LONG == 4
|
# define PRIx32 "lx"
|
# define PRIx32 "lx"
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef PRIx16
|
#ifndef PRIx16
|
# if SIZEOF_SHORT == 2
|
# if SIZEOF_SHORT == 2
|
# define PRIx16 "hx"
|
# define PRIx16 "hx"
|
# else
|
# else
|
# define PRIx16 "x"
|
# define PRIx16 "x"
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef PRIx8
|
#ifndef PRIx8
|
# if SIZEOF_CHAR == 1
|
# if SIZEOF_CHAR == 1
|
# define PRIx8 "hhx"
|
# define PRIx8 "hhx"
|
# else
|
# else
|
# define PRIx8 "x"
|
# define PRIx8 "x"
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef PRIi32
|
#ifndef PRIi32
|
# if SIZEOF_INT == 4
|
# if SIZEOF_INT == 4
|
# define PRIi32 "i"
|
# define PRIi32 "i"
|
# elif SIZEOF_LONG == 4
|
# elif SIZEOF_LONG == 4
|
# define PRIi32 "li"
|
# define PRIi32 "li"
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef PRId32
|
#ifndef PRId32
|
# if SIZEOF_INT == 4
|
# if SIZEOF_INT == 4
|
# define PRId32 "d"
|
# define PRId32 "d"
|
# elif SIZEOF_LONG == 4
|
# elif SIZEOF_LONG == 4
|
# define PRId32 "ld"
|
# define PRId32 "ld"
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef UINT32_C
|
#ifndef UINT32_C
|
# if SIZEOF_INT == 4
|
# if SIZEOF_INT == 4
|
# define UINT32_C(c) c
|
# define UINT32_C(c) c
|
# elif SIZEOF_LONG == 4
|
# elif SIZEOF_LONG == 4
|
# define UINT32_C(c) c l
|
# define UINT32_C(c) c l
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef HAVE_UINT32_T
|
#ifndef HAVE_UINT32_T
|
# if SIZEOF_INT == 4
|
# if SIZEOF_INT == 4
|
typedef unsigned int uint32_t;
|
typedef unsigned int uint32_t;
|
# elif SIZEOF_LONG == 4
|
# elif SIZEOF_LONG == 4
|
typedef unsigned long uint32_t;
|
typedef unsigned long uint32_t;
|
# else
|
# else
|
# error "Can't find a 32-bit type"
|
# error "Can't find a 32-bit type"
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef HAVE_INT32_T
|
#ifndef HAVE_INT32_T
|
# if SIZEOF_INT == 4
|
# if SIZEOF_INT == 4
|
typedef signed int int32_t;
|
typedef signed int int32_t;
|
# elif SIZEOF_LONG == 4
|
# elif SIZEOF_LONG == 4
|
typedef signed long int32_t;
|
typedef signed long int32_t;
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef HAVE_UINT16_T
|
#ifndef HAVE_UINT16_T
|
# if SIZEOF_SHORT == 2
|
# if SIZEOF_SHORT == 2
|
typedef unsigned short uint16_t;
|
typedef unsigned short uint16_t;
|
# else
|
# else
|
# error "Can't find a 16-bit type"
|
# error "Can't find a 16-bit type"
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef HAVE_INT16_T
|
#ifndef HAVE_INT16_T
|
# if SIZEOF_SHORT == 2
|
# if SIZEOF_SHORT == 2
|
typedef signed short int16_t;
|
typedef signed short int16_t;
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef HAVE_UINT8_T
|
#ifndef HAVE_UINT8_T
|
# if SIZEOF_CHAR == 1
|
# if SIZEOF_CHAR == 1
|
typedef unsigned char uint8_t;
|
typedef unsigned char uint8_t;
|
# else
|
# else
|
# error "Can't find a 8-bit type"
|
# error "Can't find a 8-bit type"
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
#ifndef HAVE_INT8_T
|
#ifndef HAVE_INT8_T
|
# if SIZEOF_CHAR == 1
|
# if SIZEOF_CHAR == 1
|
typedef signed char int8_t;
|
typedef signed char int8_t;
|
# endif
|
# endif
|
#endif
|
#endif
|
|
|
|
|
#endif /* PORT__H */
|
#endif /* PORT__H */
|
|
|